forked from JDimproved/JDim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
articleviewbase.cpp
4253 lines (3273 loc) · 125 KB
/
articleviewbase.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ライセンス: GPL2
//#define _DEBUG
#include "jddebug.h"
#include "gtkmmversion.h"
#include "articleadmin.h"
#include "articleviewbase.h"
#include "drawareamain.h"
#include "skeleton/msgdiag.h"
#include "jdlib/miscutil.h"
#include "jdlib/miscgtk.h"
#include "jdlib/miscx.h"
#include "jdlib/misccharcode.h"
#include "dbtree/articlebase.h"
#include "dbtree/interface.h"
#include "dbimg/imginterface.h"
#include "skeleton/popupwin.h"
#include "config/globalconf.h"
#include "history/historymanager.h"
#include "message/logmanager.h"
#include "image/imageviewpopup.h"
#include "xml/document.h"
#include "xml/tools.h"
#include "control/controlutil.h"
#include "control/controlid.h"
#include "global.h"
#include "type.h"
#include "httpcode.h"
#include "command.h"
#include "session.h"
#include "viewfactory.h"
#include "sharedbuffer.h"
#include "prefdiagfactory.h"
#include "usrcmdmanager.h"
#include "linkfiltermanager.h"
#include "compmanager.h"
#include "icons/iconmanager.h"
#include <sstream>
#include <cstring>
#ifndef MAX
#define MAX( a, b ) ( a > b ? a : b )
#endif
#ifndef MIN
#define MIN( a, b ) ( a < b ? a : b )
#endif
using namespace ARTICLE;
#define PROTO_URL4REPORT "url4report://"
ArticleViewBase::ArticleViewBase( const std::string& url, const std::string& url_article )
: SKELETON::View( url ),
m_url_article( url_article ),
m_popup_win( NULL ),
m_popup_shown( false ),
m_hidepopup_counter( 0 ),
m_enable_menuslot( true ),
m_current_bm( 0 ),
m_current_post( 0 ),
m_show_url4report( false ),
m_url_show_status( false ),
m_enable_live( false ),
m_live( false )
{
#ifdef _DEBUG
std::cout << "ArticleViewBase::ArticleViewBase : " << get_url() << " : " << m_url_article << std::endl;
#endif
set_id_toolbar( TOOLBAR_ARTICLE );
// マウスジェスチャ可能
set_enable_mg( true );
// コントロールモード設定
get_control().add_mode( CONTROL::MODE_ARTICLE );
// 板名セット
update_boardname();
}
ArticleViewBase::~ArticleViewBase()
{
#ifdef _DEBUG
std::cout << "ArticleViewBase::~ArticleViewBase : " << get_url() << std::endl;
#endif
hide_popup( true );
delete_popup();
}
SKELETON::Admin* ArticleViewBase::get_admin()
{
return ARTICLE::get_admin();
}
//
// コピー用URL( readcgi型 )
//
// メインウィンドウのURLバーなどの表示用にも使う
//
std::string ArticleViewBase::url_for_copy()
{
return DBTREE::url_readcgi( m_url_article, 0, 0 );
}
const JDLIB::RefPtr_Lock< DBTREE::ArticleBase >& ArticleViewBase::get_article() const noexcept
{
assert( m_article );
return m_article;
}
DrawAreaBase* ArticleViewBase::drawarea()
{
assert( m_drawarea );
return m_drawarea;
}
DrawAreaBase* ArticleViewBase::create_drawarea()
{
return Gtk::manage( new ARTICLE::DrawAreaMain( m_url_article ) );
}
//
// セットアップ
//
// 各派生ビューで初期設定が済んだ後に呼ばれる
//
void ArticleViewBase::setup_view()
{
#ifdef _DEBUG
std::cout << "ArticleViewBase::setup_view " << get_url() << " url_article = " << m_url_article << std::endl;
#endif
m_article = DBTREE::get_article( m_url_article );
m_drawarea = create_drawarea();
assert( m_article );
assert( m_drawarea );
m_drawarea->sig_button_press().connect( sigc::mem_fun( *this, &ArticleViewBase::slot_button_press ));
m_drawarea->sig_button_release().connect( sigc::mem_fun( *this, &ArticleViewBase::slot_button_release ));
m_drawarea->sig_motion_notify().connect( sigc::mem_fun( *this, &ArticleViewBase::slot_motion_notify ) );
m_drawarea->sig_key_press().connect( sigc::mem_fun(*this, &ArticleViewBase::slot_key_press ) );
m_drawarea->sig_key_release().connect( sigc::mem_fun(*this, &ArticleViewBase::slot_key_release ) );
m_drawarea->sig_scroll_event().connect( sigc::mem_fun( *this, &ArticleViewBase::slot_scroll_event ));
m_drawarea->sig_leave_notify().connect( sigc::mem_fun( *this, &ArticleViewBase::slot_leave_notify ) );
m_drawarea->sig_on_url().connect( sigc::mem_fun(*this, &ArticleViewBase::slot_on_url ) );
m_drawarea->sig_leave_url().connect( sigc::mem_fun(*this, &ArticleViewBase::slot_leave_url ) );
pack_start( *m_drawarea, Gtk::PACK_EXPAND_WIDGET );
setup_action();
show_all_children();
}
//
// アクション初期化
//
void ArticleViewBase::setup_action()
{
#ifdef _DEBUG
std::cout << "ArticleViewBase::setup_action\n";
#endif
// アクショングループを作ってUIマネージャに登録
action_group().reset();
action_group() = Gtk::ActionGroup::create();
action_group()->add( Gtk::Action::create( "BookMark", "しおりを設定/解除(_B)"), sigc::mem_fun( *this, &ArticleViewBase::slot_bookmark ) );
action_group()->add( Gtk::Action::create( "PostedMark", "書き込みマークを設定/解除(_P)"), sigc::mem_fun( *this, &ArticleViewBase::slot_postedmark ) );
action_group()->add( Gtk::Action::create( "OpenBrowser", ITEM_NAME_OPEN_BROWSER "(_W)" ),
sigc::mem_fun( *this, &ArticleViewBase::slot_open_browser ) );
action_group()->add( Gtk::Action::create( "OpenBrowserRes", ITEM_NAME_OPEN_BROWSER "(_S)" ), // レスをクリックした時のメニュー用
sigc::mem_fun( *this, &ArticleViewBase::slot_open_browser ) );
action_group()->add( Gtk::Action::create( "OpenCacheBrowser", ITEM_NAME_OPEN_CACHE_BROWSER "(_X)" ),
sigc::mem_fun( *this, &ArticleViewBase::slot_open_cache_browser ) );
action_group()->add( Gtk::Action::create( "CopyURL", ITEM_NAME_COPY_URL "(_U)" ),
sigc::mem_fun( *this, &ArticleViewBase::slot_copy_current_url ) );
action_group()->add( Gtk::Action::create( "CopyTitleURL", ITEM_NAME_COPY_TITLE_URL_THREAD "(_L)" ),
sigc::mem_fun( *this, &ArticleViewBase::slot_copy_title_url ) );
action_group()->add( Gtk::Action::create( "CopyNAME", "名前コピー(_N)"), sigc::mem_fun( *this, &ArticleViewBase::slot_copy_name ) );
action_group()->add( Gtk::Action::create( "CopyID", "IDコピー(_D)"), sigc::mem_fun( *this, &ArticleViewBase::slot_copy_id ) );
action_group()->add( Gtk::Action::create( "Copy", "Copy"), sigc::mem_fun( *this, &ArticleViewBase::slot_copy_selection_str ) );
action_group()->add( Gtk::Action::create( "WriteRes", "レスする(_W)" ),sigc::mem_fun( *this, &ArticleViewBase::slot_write_res ) );
action_group()->add( Gtk::Action::create( "QuoteRes", "引用してレスする(_Q)"),sigc::mem_fun( *this, &ArticleViewBase::slot_quote_res ) );
action_group()->add( Gtk::Action::create( "QuoteSelectionRes", ITEM_NAME_QUOTE_SELECTION "(_Q)" ),
sigc::mem_fun( *this, &ArticleViewBase::slot_quote_selection_res ) );
action_group()->add( Gtk::Action::create( "CopyRes", "レスをコピー(_R)"),
sigc::bind< bool >( sigc::mem_fun( *this, &ArticleViewBase::slot_copy_res ), false ) );
action_group()->add( Gtk::Action::create( "CopyResRef", "引用コピー(_F)"),
sigc::bind< bool >( sigc::mem_fun( *this, &ArticleViewBase::slot_copy_res ), true ) );
action_group()->add( Gtk::Action::create( "Delete_Menu", "削除(_D)" ) );
action_group()->add( Gtk::Action::create( "Delete", "Delete"), sigc::mem_fun( *this, &ArticleViewBase::exec_delete ) );
action_group()->add( Gtk::Action::create( "DeleteOpen", "スレ情報を消さずにスレ再取得(_R)"), sigc::mem_fun( *this, &ArticleViewBase::delete_open_view ) );
action_group()->add( Gtk::Action::create( "AppendFavorite", "AppendFavorite"), sigc::mem_fun( *this, &ArticleViewBase::set_favorite ) );
action_group()->add( Gtk::Action::create( "Reload", "Reload"), sigc::mem_fun( *this, &ArticleViewBase::exec_reload ) );
action_group()->add( Gtk::Action::create( "PreferenceArticle", "PreferenceArticle" ), sigc::mem_fun( *this, &ArticleViewBase::show_preference ) );
action_group()->add( Gtk::Action::create( "PreferenceImage", ITEM_NAME_PREF_IMAGE "(_M)..." ), sigc::mem_fun( *this, &ArticleViewBase::slot_preferences_image ) );
// 検索
action_group()->add( Gtk::Action::create( "Search_Menu", ITEM_NAME_SEARCH "(_H)" ) );
action_group()->add( Gtk::Action::create( "SearchNextArticle", "SearchNextArticle"), sigc::mem_fun( *this, &ArticleViewBase::slot_search_next ) );
action_group()->add( Gtk::Action::create( "SearchWeb", "SearchWeb" ), sigc::mem_fun( *this, &ArticleViewBase::slot_search_web ) );
action_group()->add( Gtk::Action::create( "SearchCacheLocal", "SearchCacheLocal" ), sigc::mem_fun( *this, &ArticleViewBase::slot_search_cachelocal ) );
action_group()->add( Gtk::Action::create( "SearchCacheAll", "SearchCacheAll") );
action_group()->add( Gtk::Action::create( "ExecSearchCacheAll", "検索する(_E)"), sigc::mem_fun( *this, &ArticleViewBase::slot_search_cacheall ) );
action_group()->add( Gtk::Action::create( "SearchTitle", "SearchTitle" ), sigc::mem_fun( *this, &ArticleViewBase::slot_search_title ) );
// 抽出系
action_group()->add( Gtk::Action::create( "Drawout_Menu", ITEM_NAME_DRAWOUT "(_E)" ) );
action_group()->add( Gtk::Action::create( "DrawoutWord", "キーワード抽出(_K)"), sigc::mem_fun( *this, &ArticleViewBase::slot_drawout_selection_str ) );
action_group()->add( Gtk::Action::create( "DrawoutRes", "レス抽出(_R)"), sigc::mem_fun( *this, &ArticleViewBase::slot_drawout_res ) );
action_group()->add( Gtk::Action::create( "DrawoutNAME", "名前抽出(_E)"), sigc::mem_fun( *this, &ArticleViewBase::slot_drawout_name ) );
action_group()->add( Gtk::Action::create( "DrawoutID", "ID抽出(_I)"), sigc::mem_fun( *this, &ArticleViewBase::slot_drawout_id ) );
action_group()->add( Gtk::Action::create( "DrawoutBM", "しおり抽出(_B)"), sigc::mem_fun( *this, &ArticleViewBase::slot_drawout_bm ) );
action_group()->add( Gtk::Action::create( "DrawoutPost", "書き込み抽出(_W)"), sigc::mem_fun( *this, &ArticleViewBase::slot_drawout_post ) );
action_group()->add( Gtk::Action::create( "DrawoutURL", "URL抽出(_U)"), sigc::mem_fun( *this, &ArticleViewBase::slot_drawout_url ) );
action_group()->add( Gtk::Action::create( "DrawoutRefer", "参照抽出(_E)"), sigc::mem_fun( *this, &ArticleViewBase::slot_drawout_refer ) );
action_group()->add( Gtk::Action::create( "DrawoutAround", "周辺抽出(_A)"), sigc::mem_fun( *this, &ArticleViewBase::slot_drawout_around ) );
action_group()->add( Gtk::Action::create( "DrawoutTmp", "テンプレート抽出(_T)"), sigc::mem_fun( *this, &ArticleViewBase::slot_drawout_tmp ) );
// あぼーん系
action_group()->add( Gtk::Action::create( "AboneWord_Menu", ITEM_NAME_NGWORD "(_N)" ) );
action_group()->add( Gtk::Action::create( "AboneRes", "レスをあぼ〜んする(_A)"), sigc::mem_fun( *this, &ArticleViewBase::slot_abone_res ) );
action_group()->add( Gtk::Action::create( "AboneSelectionRes", "AboneSelectionRes" ),
sigc::mem_fun( *this, &ArticleViewBase::slot_abone_selection_res ) );
action_group()->add( Gtk::Action::create( "AboneID", "NG IDに追加(_G)"), sigc::mem_fun( *this, &ArticleViewBase::slot_abone_id ) );
action_group()->add( Gtk::Action::create( "AboneName", "NG 名前に追加 (対象: ローカル)(_L)"), sigc::mem_fun( *this, &ArticleViewBase::slot_abone_name ) );
action_group()->add( Gtk::Action::create( "AboneWord", "NG ワードに追加 (対象: ローカル)(_L)"), sigc::mem_fun( *this, &ArticleViewBase::slot_abone_word ) );
action_group()->add( Gtk::Action::create( "AboneNameBoard", "NG 名前に追加 (対象: 板)(_B)" ) );
action_group()->add( Gtk::Action::create( "SetAboneNameBoard", "追加する(_A)"), sigc::mem_fun( *this, &ArticleViewBase::slot_abone_name_board ) );
action_group()->add( Gtk::Action::create( "AboneWordBoard", "NG ワードに追加 (対象: 板)(_B)" ) );
action_group()->add( Gtk::Action::create( "SetAboneWordBoard", "追加する(_A)"), sigc::mem_fun( *this, &ArticleViewBase::slot_abone_word_board ) );
action_group()->add( Gtk::Action::create( "GlobalAboneName", "NG 名前に追加 (対象: 全体)(_A)" ) );
action_group()->add( Gtk::Action::create( "SetGlobalAboneName", "追加する(_A)"), sigc::mem_fun( *this, &ArticleViewBase::slot_global_abone_name ) );
action_group()->add( Gtk::Action::create( "GlobalAboneWord", "NG ワードに追加 (対象: 全体)(_A)" ) );
action_group()->add( Gtk::Action::create( "SetGlobalAboneWord", "追加する(_A)"), sigc::mem_fun( *this, &ArticleViewBase::slot_global_abone_word ) );
action_group()->add( Gtk::ToggleAction::create( "TranspAbone", "透明あぼ〜ん(_T)", std::string(), false ),
sigc::mem_fun( *this, &ArticleViewBase::slot_toggle_abone_transp ) );
action_group()->add( Gtk::ToggleAction::create( "TranspChainAbone", "透明/連鎖あぼ〜ん(_C)", std::string(), false ),
sigc::mem_fun( *this, &ArticleViewBase::slot_toggle_abone_transp_chain ) );
action_group()->add( Gtk::Action::create( "SetupAbone", "あぼ〜ん設定(対象: ローカル)(_L)..."), sigc::mem_fun( *this, &ArticleViewBase::slot_setup_abone ) );
action_group()->add( Gtk::Action::create( "SetupAboneBoard", "あぼ〜ん設定(対象: 板)(_B)..." ), sigc::mem_fun( *this, &ArticleViewBase::slot_setup_abone_board ) );
action_group()->add( Gtk::Action::create( "SetupAboneAll", "あぼ〜ん設定(対象: 全体)(_A)..." ), sigc::mem_fun( *this, &ArticleViewBase::slot_setup_abone_all ) );
// 移動系
action_group()->add( Gtk::Action::create( "Move_Menu", ITEM_NAME_GO "(_M)" ) );
action_group()->add( Gtk::Action::create( "Home", "Home"), sigc::mem_fun( *this, &ArticleViewBase::goto_top ) );
action_group()->add( Gtk::Action::create( "GotoNew", "GotoNew"), sigc::mem_fun( *this, &ArticleViewBase::goto_new ) );
action_group()->add( Gtk::Action::create( "End", "End"), sigc::mem_fun( *this, &ArticleViewBase::goto_bottom ) );
action_group()->add( Gtk::Action::create( "PreBookMark", "PreBookMark"), sigc::mem_fun( *this, &ArticleViewBase::slot_pre_bm ) );
action_group()->add( Gtk::Action::create( "NextBookMark", "NextBookMark"), sigc::mem_fun( *this, &ArticleViewBase::slot_next_bm ) );
action_group()->add( Gtk::Action::create( "PrePost", "PrePost"), sigc::mem_fun( *this, &ArticleViewBase::slot_pre_post ) );
action_group()->add( Gtk::Action::create( "NextPost", "NextPost"), sigc::mem_fun( *this, &ArticleViewBase::slot_next_post ) );
action_group()->add( Gtk::Action::create( "Jump", "ジャンプ(_J)"), sigc::mem_fun( *this, &ArticleViewBase::slot_jump ) );
action_group()->add( Gtk::Action::create( "PrevView", "PrevView"),
sigc::bind< int >( sigc::mem_fun( *this, &ArticleViewBase::back_viewhistory ), 1 ) );
action_group()->add( Gtk::Action::create( "NextView", "NextView"),
sigc::bind< int >( sigc::mem_fun( *this, &ArticleViewBase::forward_viewhistory ), 1 ) );
// 画像系
action_group()->add( Gtk::Action::create( "Cancel_Mosaic", "モザイク解除(_C)"), sigc::mem_fun( *this, &ArticleViewBase::slot_cancel_mosaic ) );
action_group()->add( Gtk::Action::create( "Show_Mosaic", "モザイクで開く(_M)"), sigc::mem_fun( *this, &ArticleViewBase::slot_show_image_with_mosaic ) );
action_group()->add( Gtk::Action::create( "ShowSelectImage", "ShowSelectImage" )
, sigc::mem_fun( *this, &ArticleViewBase::slot_show_selection_images ) );
action_group()->add( Gtk::Action::create( "DeleteSelectImage_Menu", ITEM_NAME_SELECTDELIMG "(_T)" ) );
action_group()->add( Gtk::Action::create( "DeleteSelectImage", "DeleteSelectImage"), sigc::mem_fun( *this, &ArticleViewBase::slot_delete_selection_images ) );
action_group()->add( Gtk::Action::create( "AboneSelectImage_Menu", ITEM_NAME_SELECTABONEIMG "(_B)" ) );
action_group()->add( Gtk::Action::create( "AboneSelectImage", "AboneSelectImage"), sigc::mem_fun( *this, &ArticleViewBase::slot_abone_selection_images ) );
action_group()->add( Gtk::Action::create( "ShowLargeImg", "サイズが大きい画像を表示(_L)"),
sigc::mem_fun( *this, &ArticleViewBase::slot_show_large_img ) );
action_group()->add( Gtk::ToggleAction::create( "ProtectImage", "キャッシュを保護する(_P)", std::string(), false ),
sigc::mem_fun( *this, &ArticleViewBase::slot_toggle_protectimage ) );
action_group()->add( Gtk::Action::create( "DeleteImage_Menu", "削除(_D)" ) );
action_group()->add( Gtk::Action::create( "DeleteImage", "削除する(_D)"), sigc::mem_fun( *this, &ArticleViewBase::slot_deleteimage ) );
action_group()->add( Gtk::Action::create( "SaveImage", "名前を付けて保存(_S)..."), sigc::mem_fun( *this, &ArticleViewBase::slot_saveimage ) );
action_group()->add( Gtk::ToggleAction::create( "AboneImage", "画像をあぼ〜んする(_A)", std::string(), false ),
sigc::mem_fun( *this, &ArticleViewBase::slot_abone_img ) );
// その他
action_group()->add( Gtk::Action::create( "Etc_Menu", ITEM_NAME_ETC "(_O)" ) );
action_group()->add( Gtk::Action::create( "SaveDat", "SaveDat" ), sigc::mem_fun( *this, &ArticleViewBase::slot_save_dat ) );
action_group()->add( Gtk::Action::create( "CopyInfo", ITEM_NAME_COPY_THREAD_INFO "(_I)..." ),
sigc::mem_fun( *this, &ArticleViewBase::slot_copy_article_info ) );
m_usrcmd = CORE::get_usrcmd_manager()->create_usrcmd_menu( action_group() );
const int usrcmd_size = CORE::get_usrcmd_manager()->get_size();
for( int i = 0; i < usrcmd_size; ++i ){
Glib::RefPtr< Gtk::Action > act = CORE::get_usrcmd_manager()->get_action( action_group(), i );
if( act ) act->signal_activate().connect(
sigc::bind< int >( sigc::mem_fun( *this, &ArticleViewBase::slot_usrcmd ), i ) );
}
ui_manager().reset();
ui_manager() = Gtk::UIManager::create();
ui_manager()->insert_action_group( action_group() );
// 削除ボタン押したときのポップアップ
const std::string menu_delete =
"<popup name='popup_menu_delete'>"
"<menuitem action='Delete'/>"
"<separator/>"
"<menuitem action='DeleteOpen'/>"
"</popup>";
// 壊れていますをクリックしたときのポップアップ
const std::string menu_broken =
"<popup name='popup_menu_broken'>"
"<menuitem action='DeleteOpen'/>"
"</popup>";
// レス番号をクリックしたときのメニュー
const std::string menu_res =
"<popup name='popup_menu_res'>"
"<menuitem action='BookMark'/>"
"<menuitem action='PostedMark'/>"
"<separator/>"
"<menu action='Drawout_Menu'>"
"<menuitem action='Jump'/>"
"<menuitem action='DrawoutRefer'/>"
"<menuitem action='DrawoutAround'/>"
"<menuitem action='DrawoutRes'/>"
"</menu>"
"<separator/>"
"<menuitem action='WriteRes'/>"
"<menuitem action='QuoteRes'/>"
"<separator/>"
"<menuitem action='OpenBrowserRes'/>"
"<separator/>"
"<menuitem action='CopyURL'/>"
"<menuitem action='CopyRes'/>"
"<menuitem action='CopyResRef'/>"
"<separator/>"
"<menuitem action='AboneRes'/>"
"</popup>";
// レスアンカーをクリックしたときのメニュー
const std::string menu_anc =
"<popup name='popup_menu_anc'>"
"<menuitem action='Jump'/>"
"<menuitem action='DrawoutAround'/>"
"<menuitem action='DrawoutRes'/>"
"</popup>";
// IDをクリックしたときのメニュー
const std::string menu_id =
"<popup name='popup_menu_id'>"
"<menuitem action='DrawoutID'/>"
"<menuitem action='CopyID'/>"
"<separator/>"
"<menuitem action='AboneID'/>"
"</popup>";
// 名前をクリックしたときのメニュー
const std::string menu_name =
"<popup name='popup_menu_name'>"
"<menuitem action='DrawoutNAME'/>"
"<menuitem action='CopyNAME'/>"
"<separator/>"
"<menuitem action='AboneName'/>"
"<menu action='AboneNameBoard'>"
"<menuitem action='SetAboneNameBoard'/>"
"</menu>"
"<menu action='GlobalAboneName'>"
"<menuitem action='SetGlobalAboneName'/>"
"</menu>"
"</popup>";
// あぼーんをクリックしたときのメニュー
const std::string menu_abone =
"<popup name='popup_menu_abone'>"
"<menuitem action='TranspAbone'/>"
"<menuitem action='TranspChainAbone'/>"
"<separator/>"
"<menuitem action='SetupAbone'/>"
"<menuitem action='SetupAboneBoard'/>"
"<menuitem action='SetupAboneAll'/>"
"</popup>";
// 画像メニュー
const std::string menu_img =
"<popup name='popup_menu_img'>"
"<menuitem action='Cancel_Mosaic'/>"
"<menuitem action='Show_Mosaic'/>"
"<menuitem action='ShowLargeImg'/>"
"<separator/>"
"<menuitem action='OpenBrowser'/>"
"<menuitem action='OpenCacheBrowser'/>"
+ m_usrcmd
+ std::string(
"<separator/>"
"<menuitem action='CopyURL'/>"
"<separator/>"
"<menuitem action='SaveImage'/>"
"<separator/>"
"<menuitem action='ProtectImage'/>"
"<menu action='DeleteImage_Menu'>"
"<menuitem action='DeleteImage'/>"
"</menu>"
"<separator/>"
"<menuitem action='AboneImage'/>"
"<separator/>"
"<menuitem action='PreferenceImage'/>"
"</popup>"
);
ui_manager()->add_ui_from_string(
"<ui>"
+ menu_delete
+ menu_broken
+ menu_res
+ menu_anc
+ menu_id
+ menu_name
+ menu_abone
+ menu_img
+ create_context_menu()
+ "</ui>"
);
// ポップアップメニューにショートカットキーやマウスジェスチャを表示
Gtk::Menu* popupmenu = dynamic_cast< Gtk::Menu* >( ui_manager()->get_widget( "/popup_menu" ) );
CONTROL::set_menu_motion( popupmenu );
popupmenu = dynamic_cast< Gtk::Menu* >( ui_manager()->get_widget( "/popup_menu_delete" ) );
CONTROL::set_menu_motion( popupmenu );
}
//
// 通常の右クリックメニューの作成
//
std::string ArticleViewBase::create_context_menu()
{
std::list< int > list_menu;
list_menu.push_back( ITEM_DRAWOUT );
list_menu.push_back( ITEM_GO );
list_menu.push_back( ITEM_SEARCH );
list_menu.push_back( ITEM_NGWORD );
list_menu.push_back( ITEM_QUOTE_SELECTION );
list_menu.push_back( ITEM_OPEN_BROWSER );
list_menu.push_back( ITEM_USER_COMMAND );
list_menu.push_back( ITEM_COPY_URL );
list_menu.push_back( ITEM_COPY );
list_menu.push_back( ITEM_RELOAD );
list_menu.push_back( ITEM_DELETE );
list_menu.push_back( ITEM_COPY_TITLE_URL_THREAD );
list_menu.push_back( ITEM_SAVE_DAT );
list_menu.push_back( ITEM_COPY_THREAD_INFO );
list_menu.push_back( ITEM_APPENDFAVORITE );
list_menu.push_back( ITEM_ABONE_SELECTION );
list_menu.push_back( ITEM_SELECTIMG );
list_menu.push_back( ITEM_SELECTDELIMG );
list_menu.push_back( ITEM_SELECTABONEIMG );
list_menu.push_back( ITEM_PREF_THREAD );
// メニューに含まれていない項目を抜き出して「その他」に含める
int num = 0;
for(;;){
const int item = SESSION::get_item_article_menu( num );
if( item == ITEM_END ) break;
list_menu.remove( item );
++num;
}
std::string menu;
num = 0;
for(;;){
const int item = SESSION::get_item_article_menu( num );
if( item == ITEM_END ) break;
else if( item == ITEM_ETC && list_menu.size() ){
menu += std::string( "<menu action='Etc_Menu'>" );
std::list< int >::iterator it = list_menu.begin();
for( ; it != list_menu.end(); ++it ) menu += get_menu_item( *it );
menu += std::string( "</menu>" );
}
else menu += get_menu_item( item );
++num;
}
#ifdef _DEBUG
std::cout << "menu = " << menu << std::endl;
#endif
return "<popup name='popup_menu'>" + menu + "</popup>";
}
const char* ArticleViewBase::get_menu_item( const int item )
{
switch( item ){
// 抽出
case ITEM_DRAWOUT:
return
"<menu action='Drawout_Menu'>"
"<menuitem action='DrawoutWord'/>"
"<menuitem action='DrawoutBM'/>"
"<menuitem action='DrawoutPost'/>"
"<menuitem action='DrawoutURL'/>"
"<menuitem action='DrawoutTmp'/>"
"</menu>"
;
// 移動
case ITEM_GO:
return
"<menu action='Move_Menu'>"
"<menuitem action='PrevView'/>"
"<menuitem action='NextView'/>"
"<separator/>"
"<menuitem action='Home'/>"
"<menuitem action='End'/>"
"<separator/>"
"<menuitem action='GotoNew'/>"
"<separator/>"
"<menuitem action='PreBookMark'/>"
"<menuitem action='NextBookMark'/>"
"<separator/>"
"<menuitem action='PrePost'/>"
"<menuitem action='NextPost'/>"
"</menu>"
;
// 検索
case ITEM_SEARCH:
return
"<menu action='Search_Menu'>"
"<menuitem action='SearchWeb'/>"
"<separator/>"
"<menuitem action='SearchNextArticle' />"
"<separator/>"
"<menuitem action='SearchTitle' />"
"<separator/>"
"<menuitem action='SearchCacheLocal'/>"
"<menu action='SearchCacheAll'>"
"<menuitem action='ExecSearchCacheAll'/>"
"</menu>"
"</menu>"
;
// NGワード
case ITEM_NGWORD:
return
"<menu action='AboneWord_Menu'>"
"<menuitem action='AboneWord'/>"
"<menu action='AboneWordBoard'>"
"<menuitem action='SetAboneWordBoard'/>"
"</menu>"
"<menu action='GlobalAboneWord'>"
"<menuitem action='SetGlobalAboneWord'/>"
"</menu>"
"</menu>"
;
// 選択範囲のレスをあぼーん
case ITEM_ABONE_SELECTION:
return
"<menuitem action='AboneSelectionRes' />"
;
// 引用してレス
case ITEM_QUOTE_SELECTION:
return "<menuitem action='QuoteSelectionRes' />";
// リンクをブラウザで開く
case ITEM_OPEN_BROWSER:
return "<menuitem action='OpenBrowser'/>";
// ユーザコマンド
case ITEM_USER_COMMAND:
return m_usrcmd.c_str();
// リンクのURLをコピー
case ITEM_COPY_URL:
return "<menuitem action='CopyURL'/>";
// スレのタイトルとURLをコピー
case ITEM_COPY_TITLE_URL_THREAD:
return "<menuitem action='CopyTitleURL'/>";
// コピー
case ITEM_COPY:
return "<menuitem action='Copy'/>";
// 再読み込み
case ITEM_RELOAD:
return "<menuitem action='Reload'/>";
// dat 保存
case ITEM_SAVE_DAT:
return "<menuitem action='SaveDat'/>";
// 情報コピー
case ITEM_COPY_THREAD_INFO:
return "<menuitem action='CopyInfo'/>";
// お気に入り
case ITEM_APPENDFAVORITE:
return "<menuitem action='AppendFavorite'/>";
// プロパティ
case ITEM_PREF_THREAD:
return "<menuitem action='PreferenceArticle'/>";
// 選択範囲の画像を開く
case ITEM_SELECTIMG:
return "<menuitem action='ShowSelectImage'/>";
// 選択範囲の画像を削除
case ITEM_SELECTDELIMG:
return "<menu action='DeleteSelectImage_Menu'>"
"<menuitem action='DeleteSelectImage'/>"
"</menu>";
// 選択範囲の画像をあぼーん
case ITEM_SELECTABONEIMG:
return "<menu action='AboneSelectImage_Menu'>"
"<menuitem action='AboneSelectImage'/>"
"</menu>";
// 区切り
case ITEM_SEPARATOR:
return "<separator/>";
// 削除
case ITEM_DELETE:
return "<menu action='Delete_Menu'>"
"<menuitem action='Delete'/>"
"<menuitem action='DeleteOpen'/>"
"</menu>";
}
return "";
}
//
// クライアント領域幅
//
int ArticleViewBase::width_client()
{
#ifdef _DEBUG
if( m_drawarea ) std::cout << "ArticleViewBase::width_client : " << m_drawarea->width_client() << std::endl;
#endif
if( m_drawarea ) return m_drawarea->width_client();
return SKELETON::View::width_client();
}
//
// クライアント領高さ
//
int ArticleViewBase::height_client()
{
#ifdef _DEBUG
if( m_drawarea ) std::cout << "ArticleViewBase::height_client : " << m_drawarea->height_client() << std::endl;
#endif
if( m_drawarea ) return m_drawarea->height_client();
return SKELETON::View::height_client();
}
// アイコンのID取得
int ArticleViewBase::get_icon( const std::string& iconname )
{
int id = ICON::NONE;
if( iconname == "default" ) id = ICON::THREAD;
if( iconname == "loading" ) id = ICON::LOADING;
if( iconname == "loading_stop" ) id = ICON::LOADING_STOP;
if( iconname == "update" ) id = ICON::THREAD_UPDATE; // 更新チェックしで更新があった場合
if( iconname == "updated" ) id = ICON::THREAD_UPDATED;
if( iconname == "old" ) id = ICON::THREAD_OLD;
#ifdef _DEBUG
std::cout << "ArticleViewBase::get_icon : " << iconname << " url = " << get_url() << std::endl;
#endif
return id;
}
//
// コマンド
//
bool ArticleViewBase::set_command( const std::string& command, const std::string& arg1, const std::string& arg2 )
{
#ifdef _DEBUG
std::cout << "ArticleViewBase::set_command " << get_url() << std::endl
<< "command = " << command << std::endl;
#endif
if( command == "append_dat" ) append_dat( arg1, -1 );
else if( command == "append_html" ) append_html( arg1 );
else if( command == "clear_screen" )
{
if( m_drawarea ) m_drawarea->clear_screen();
}
else if( command == "goto_num" ) goto_num( atoi( arg1.c_str() ), atoi( arg2.c_str() ) );
else if( command == "hide_popup" ) hide_popup( true );
else if( command == "delete_popup" ) delete_popup();
else if( command == "clear_highlight" ) clear_highlight();
else if( command == "reset_popupmenu" ) setup_action();
// 実況手動切り替え
else if( command == "live_start_stop" ){
if( ! get_enable_live() ){
if( m_enable_live && ! DBTREE::board_get_live_sec( m_url_article ) ){
SKELETON::MsgDiag mdiag( get_parent_win(), "実況を行うには板のプロパティで更新間隔を設定して下さい。" );
mdiag.run();
}
return true;
}
if( get_live() ){
live_stop();
// 実況したスレは終了時に削除する
SESSION::remove_delete_list( m_url_article );
}
else{
live_start();
// 手動で停止した場合は終了時の削除をキャンセルする
SESSION::append_delete_list( m_url_article );
}
}
// dat落ちや更新が無い場合は実況停止
// 終了時にスレを削除する
else if( command == "live_stop" && get_enable_live() ) live_stop();
return true;
}
//
// クロック入力
//
// クロックタイマーの本体はコアが持っていて、定期的にadminがアクティブなviewにクロック入力を渡す
//
// virtual
void ArticleViewBase::clock_in()
{
assert( m_drawarea );
View::clock_in();
// ポップアップを時間差で消す
if( m_hidepopup_counter ){
--m_hidepopup_counter;
if( ! m_hidepopup_counter ){
// ポインタがポップアップ上に戻っていたらキャンセル
if( ! is_mouse_on_popup() ) slot_hide_popup();
}
}
// ポップアップが出てたらそっちにクロックを回す
if( is_popup_shown() && m_popup_win->view() ){
m_popup_win->view()->clock_in();
return;
}
m_drawarea->clock_in();
}
//
// スムーススクロール用クロック入力
//
// タイマー本体はArticleAdminが持っている
//
void ArticleViewBase::clock_in_smooth_scroll()
{
assert( m_drawarea );
// ポップアップが出てたらそっちにクロックを回す
if( is_popup_shown() && m_popup_win->view() ){
ArticleViewBase* view = dynamic_cast< ArticleViewBase* >( m_popup_win->view() );
if( view ) view->clock_in_smooth_scroll();
return;
}
m_drawarea->clock_in_smooth_scroll();
}
//
// 再読み込みボタンを押した
//
void ArticleViewBase::reload()
{
if( m_article->empty() ) return;
if( CONFIG::get_reload_allthreads() ) ARTICLE::get_admin()->set_command( "reload_all_tabs" );
else exec_reload();
}
//
// 再読み込み実行
//
// virtual
void ArticleViewBase::exec_reload()
{
reload_article();
}
//
// 元のスレを開く (shift+s)
//
void ArticleViewBase::reload_article()
{
if( m_article->empty() ) return;
CORE::core_set_command( "open_article", m_url_article , "newtab", "" );
}
//
// ロード停止
//
void ArticleViewBase::stop()
{
assert( m_article );
m_article->stop_load();
}
//
// 再描画
//
void ArticleViewBase::redraw_view()
{
// 起動中とシャットダウン中は処理しない
if( SESSION::is_booting() ) return;
if( SESSION::is_quitting() ) return;
#ifdef _DEBUG
std::cout << "ArticleViewBase::redraw_view " << get_url() << std::endl;
#endif
assert( m_drawarea );
m_drawarea->redraw_view_force();
// ポップアップが表示されていたらポップアップも再描画
if( is_popup_shown() ) m_popup_win->view()->redraw_view();
}
//
// フォーカスイン
//
void ArticleViewBase::focus_view()
{
assert( m_drawarea );
#ifdef _DEBUG
std::cout << "ArticleViewBase::focus_view " << get_url() << std::endl;
#endif
m_drawarea->focus_view();
m_drawarea->redraw_view();
}
//
// フォーカスアウト
//
void ArticleViewBase::focus_out()
{
SKELETON::View::focus_out();
#ifdef _DEBUG
std::cout << "ArticleViewBase::focus_out " << get_url() << std::endl;
#endif
m_drawarea->focus_out();
if( is_popup_shown() ){
// フォーカスアウトした瞬間に、子ポップアップが表示されていて、かつ
// ポインタがその上だったらポップアップは消さない
if( is_mouse_on_popup() ) return;
if( CONFIG::get_hide_popup_msec() ) m_hidepopup_counter = CONFIG::get_hide_popup_msec() / TIMER_TIMEOUT;
else hide_popup();
}
}
//
// 閉じる
//
void ArticleViewBase::close_view()
{
if( m_article->is_loading() ){
SKELETON::MsgDiag mdiag( get_parent_win(), "読み込み中です" );
mdiag.run();
return;
}
ARTICLE::get_admin()->set_command( "close_view", get_url() );
}
//
// 削除ボタンを押した
//
void ArticleViewBase::delete_view()
{
show_popupmenu( "popup_menu_delete", false );
}
//
// 削除実行
//
void ArticleViewBase::exec_delete()
{
CORE::core_set_command( "delete_article", m_url_article );
ARTICLE::get_admin()->set_command( "switch_admin" );
}
//
// スレ再取得
//
void ArticleViewBase::delete_open_view()
{
if( ! SESSION::is_online() ){
SKELETON::MsgDiag mdiag( get_parent_win(), "オフラインです" );
mdiag.run();
return;
}
if( DBTREE::article_status( m_url_article ) & STATUS_OLD ){
SKELETON::MsgDiag mdiag( get_parent_win(), "DAT落ちしています。\n\nログが消える恐れがあります。実行しますか?", false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO );
mdiag.set_default_response( Gtk::RESPONSE_NO );
if( mdiag.run() != Gtk::RESPONSE_YES ) return;
}