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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
|
/*
* em-subscription-editor.c
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
*/
#include "em-subscription-editor.h"
#include <config.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include "mail-tools.h"
#include "mail-ops.h"
#include "mail-mt.h"
#include <e-util/e-util.h>
#include <e-util/e-account-utils.h>
#include <e-util/e-util-private.h>
#include <e-util/gconf-bridge.h>
#include "em-folder-utils.h"
/* backward-compatibility cruft */
#include "e-util/gtk-compat.h"
#define EM_SUBSCRIPTION_EDITOR_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), EM_TYPE_SUBSCRIPTION_EDITOR, EMSubscriptionEditorPrivate))
#define FOLDER_CAN_SELECT(folder_info) \
((folder_info) != NULL && \
((folder_info)->flags & CAMEL_FOLDER_NOSELECT) == 0)
#define FOLDER_SUBSCRIBED(folder_info) \
((folder_info) != NULL && \
((folder_info)->flags & CAMEL_FOLDER_SUBSCRIBED) != 0)
typedef struct _AsyncContext AsyncContext;
typedef struct _StoreData StoreData;
struct _EMSubscriptionEditorPrivate {
CamelSession *session;
EAccount *initial_account;
GtkWidget *combo_box; /* not referenced */
GtkWidget *entry; /* not referenced */
GtkWidget *notebook; /* not referenced */
GtkWidget *subscribe_button; /* not referenced */
GtkWidget *unsubscribe_button; /* not referenced */
GtkWidget *collapse_all_button; /* not referenced */
GtkWidget *expand_all_button; /* not referenced */
GtkWidget *refresh_button; /* not referenced */
GtkWidget *stop_button; /* not referenced */
/* Indicies coincide with the combo box. */
GPtrArray *stores;
/* Points at an item in the stores array. */
StoreData *active;
/* Casefolded search string. */
gchar *search_string;
guint timeout_id;
};
struct _AsyncContext {
EMSubscriptionEditor *editor;
CamelFolderInfo *folder_info;
GtkTreeRowReference *reference;
};
struct _StoreData {
EAccount *account;
CamelStore *store;
GtkTreeView *tree_view;
GtkTreeModel *list_store;
GtkTreeModel *tree_store;
GCancellable *cancellable;
CamelFolderInfo *folder_info;
gboolean filtered_view;
gboolean needs_refresh;
};
enum {
PROP_0,
PROP_ACCOUNT,
PROP_SESSION
};
enum {
COL_CASEFOLDED, /* G_TYPE_STRING */
COL_FOLDER_NAME, /* G_TYPE_STRING */
COL_FOLDER_ICON, /* G_TYPE_STRING */
COL_FOLDER_INFO, /* G_TYPE_POINTER */
N_COLUMNS
};
G_DEFINE_TYPE (EMSubscriptionEditor, em_subscription_editor, GTK_TYPE_DIALOG)
static void
async_context_free (AsyncContext *context)
{
g_object_unref (context->editor);
gtk_tree_row_reference_free (context->reference);
g_slice_free (AsyncContext, context);
}
static void
store_data_free (StoreData *data)
{
if (data->account != NULL)
g_object_unref (data->account);
if (data->store != NULL)
g_object_unref (data->store);
if (data->tree_view != NULL)
g_object_unref (data->tree_view);
if (data->list_store != NULL)
g_object_unref (data->list_store);
if (data->tree_store != NULL)
g_object_unref (data->tree_store);
if (data->cancellable != NULL) {
g_cancellable_cancel (data->cancellable);
g_object_unref (data->cancellable);
}
camel_folder_info_free (data->folder_info);
g_slice_free (StoreData, data);
}
static void
subscription_editor_populate (EMSubscriptionEditor *editor,
CamelFolderInfo *folder_info,
GtkTreeIter *parent)
{
GtkTreeView *tree_view;
GtkListStore *list_store;
GtkTreeStore *tree_store;
tree_view = editor->priv->active->tree_view;
list_store = GTK_LIST_STORE (editor->priv->active->list_store);
tree_store = GTK_TREE_STORE (editor->priv->active->tree_store);
while (folder_info != NULL) {
GtkTreeIter iter;
const gchar *icon_name;
gchar *casefolded;
icon_name =
em_folder_utils_get_icon_name (folder_info->flags);
casefolded = g_utf8_casefold (folder_info->full_name, -1);
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (
list_store, &iter,
COL_CASEFOLDED, casefolded,
COL_FOLDER_ICON, icon_name,
COL_FOLDER_NAME, folder_info->full_name,
COL_FOLDER_INFO, folder_info, -1);
gtk_tree_store_append (tree_store, &iter, parent);
gtk_tree_store_set (
tree_store, &iter,
COL_CASEFOLDED, NULL, /* not needed */
COL_FOLDER_ICON, icon_name,
COL_FOLDER_NAME, folder_info->name,
COL_FOLDER_INFO, folder_info, -1);
if (FOLDER_SUBSCRIBED (folder_info)) {
GtkTreePath *path;
path = gtk_tree_model_get_path (
GTK_TREE_MODEL (tree_store), &iter);
gtk_tree_view_expand_to_path (tree_view, path);
gtk_tree_path_free (path);
}
g_free (casefolded);
if (folder_info->child != NULL)
subscription_editor_populate (
editor, folder_info->child, &iter);
folder_info = folder_info->next;
}
}
static void
subscription_editor_get_folder_info_done (CamelStore *store,
GAsyncResult *result,
EMSubscriptionEditor *editor)
{
GtkTreePath *path;
GtkTreeView *tree_view;
GtkTreeModel *list_store;
GtkTreeModel *tree_store;
GtkTreeSelection *selection;
CamelFolderInfo *folder_info;
GdkWindow *window;
GError *error = NULL;
folder_info = camel_store_get_folder_info_finish (
store, result, &error);
/* Just return quietly if we were cancelled. */
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
g_warn_if_fail (folder_info == NULL);
g_error_free (error);
goto exit;
}
gtk_widget_set_sensitive (editor->priv->notebook, TRUE);
gtk_widget_set_sensitive (editor->priv->refresh_button, TRUE);
gtk_widget_set_sensitive (editor->priv->stop_button, FALSE);
window = gtk_widget_get_window (GTK_WIDGET (editor));
gdk_window_set_cursor (window, NULL);
/* XXX Do something smarter with errors. */
if (error != NULL) {
g_warn_if_fail (folder_info == NULL);
g_warning ("%s", error->message);
g_error_free (error);
goto exit;
}
g_return_if_fail (folder_info != NULL);
camel_folder_info_free (editor->priv->active->folder_info);
editor->priv->active->folder_info = folder_info;
tree_view = editor->priv->active->tree_view;
list_store = editor->priv->active->list_store;
tree_store = editor->priv->active->tree_store;
gtk_list_store_clear (GTK_LIST_STORE (list_store));
gtk_tree_store_clear (GTK_TREE_STORE (tree_store));
subscription_editor_populate (editor, folder_info, NULL);
path = gtk_tree_path_new_first ();
selection = gtk_tree_view_get_selection (tree_view);
gtk_tree_selection_select_path (selection, path);
gtk_tree_path_free (path);
gtk_widget_grab_focus (GTK_WIDGET (tree_view));
exit:
g_object_unref (editor);
}
static void
subscription_editor_subscribe_folder_done (CamelStore *store,
GAsyncResult *result,
AsyncContext *context)
{
GtkTreeView *tree_view;
GtkTreeModel *tree_model;
GtkTreeSelection *selection;
GtkTreePath *path;
GtkTreeIter iter;
GdkWindow *window;
GError *error = NULL;
camel_store_subscribe_folder_finish (store, result, &error);
/* Just return quietly if we were cancelled. */
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
g_error_free (error);
goto exit;
}
/* XXX Do something smarter with errors. */
if (error == NULL)
context->folder_info->flags |= CAMEL_FOLDER_SUBSCRIBED;
else {
g_warning ("%s", error->message);
g_error_free (error);
}
gtk_widget_set_sensitive (context->editor->priv->notebook, TRUE);
gtk_widget_set_sensitive (context->editor->priv->refresh_button, TRUE);
gtk_widget_set_sensitive (context->editor->priv->stop_button, FALSE);
window = gtk_widget_get_window (GTK_WIDGET (context->editor));
gdk_window_set_cursor (window, NULL);
/* Update the Subscription/Unsubscription buttons. */
tree_view = context->editor->priv->active->tree_view;
selection = gtk_tree_view_get_selection (tree_view);
g_signal_emit_by_name (selection, "changed");
/* Update the toggle renderer in the selected row. */
tree_model = gtk_tree_row_reference_get_model (context->reference);
path = gtk_tree_row_reference_get_path (context->reference);
gtk_tree_model_get_iter (tree_model, &iter, path);
gtk_tree_model_row_changed (tree_model, path, &iter);
gtk_tree_path_free (path);
exit:
async_context_free (context);
}
static void
subscription_editor_unsubscribe_folder_done (CamelStore *store,
GAsyncResult *result,
AsyncContext *context)
{
GtkTreeView *tree_view;
GtkTreeModel *tree_model;
GtkTreeSelection *selection;
GtkTreePath *path;
GtkTreeIter iter;
GdkWindow *window;
GError *error = NULL;
camel_store_unsubscribe_folder_finish (store, result, &error);
/* Just return quietly if we were cancelled. */
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
g_error_free (error);
goto exit;
}
/* XXX Do something smarter with errors. */
if (error == NULL)
context->folder_info->flags &= ~CAMEL_FOLDER_SUBSCRIBED;
else {
g_warning ("%s", error->message);
g_error_free (error);
}
gtk_widget_set_sensitive (context->editor->priv->notebook, TRUE);
gtk_widget_set_sensitive (context->editor->priv->refresh_button, TRUE);
gtk_widget_set_sensitive (context->editor->priv->stop_button, FALSE);
window = gtk_widget_get_window (GTK_WIDGET (context->editor));
gdk_window_set_cursor (window, NULL);
/* Update the Subscription/Unsubscription buttons. */
tree_view = context->editor->priv->active->tree_view;
selection = gtk_tree_view_get_selection (tree_view);
g_signal_emit_by_name (selection, "changed");
/* Update the toggle renderer in the selected row. */
tree_model = gtk_tree_row_reference_get_model (context->reference);
path = gtk_tree_row_reference_get_path (context->reference);
gtk_tree_model_get_iter (tree_model, &iter, path);
gtk_tree_model_row_changed (tree_model, path, &iter);
gtk_tree_path_free (path);
exit:
async_context_free (context);
}
static void
subscription_editor_subscribe (EMSubscriptionEditor *editor)
{
CamelFolderInfo *folder_info;
GtkTreeRowReference *reference;
GtkTreeSelection *selection;
GtkTreeModel *tree_model;
GtkTreeView *tree_view;
GtkTreePath *path;
GtkTreeIter iter;
GdkCursor *cursor;
GdkWindow *window;
AsyncContext *context;
gboolean have_selection;
tree_view = editor->priv->active->tree_view;
selection = gtk_tree_view_get_selection (tree_view);
have_selection = gtk_tree_selection_get_selected (
selection, &tree_model, &iter);
g_return_if_fail (have_selection);
/* Cancel any operation on this store still in progress. */
gtk_button_clicked (GTK_BUTTON (editor->priv->stop_button));
/* Start a new 'subscription' operation. */
editor->priv->active->cancellable = g_cancellable_new ();
gtk_widget_set_sensitive (editor->priv->notebook, FALSE);
gtk_widget_set_sensitive (editor->priv->subscribe_button, FALSE);
gtk_widget_set_sensitive (editor->priv->unsubscribe_button, FALSE);
gtk_widget_set_sensitive (editor->priv->refresh_button, FALSE);
gtk_widget_set_sensitive (editor->priv->stop_button, TRUE);
cursor = gdk_cursor_new (GDK_WATCH);
window = gtk_widget_get_window (GTK_WIDGET (editor));
gdk_window_set_cursor (window, cursor);
gdk_cursor_unref (cursor);
gtk_tree_model_get (
tree_model, &iter, COL_FOLDER_INFO, &folder_info, -1);
path = gtk_tree_model_get_path (tree_model, &iter);
reference = gtk_tree_row_reference_new (tree_model, path);
gtk_tree_path_free (path);
context = g_slice_new0 (AsyncContext);
context->editor = g_object_ref (editor);
context->folder_info = folder_info;
context->reference = reference;
camel_store_subscribe_folder (
editor->priv->active->store,
folder_info->full_name, G_PRIORITY_DEFAULT,
editor->priv->active->cancellable, (GAsyncReadyCallback)
subscription_editor_subscribe_folder_done, context);
}
static void
subscription_editor_unsubscribe (EMSubscriptionEditor *editor)
{
CamelFolderInfo *folder_info;
GtkTreeRowReference *reference;
GtkTreeSelection *selection;
GtkTreeModel *tree_model;
GtkTreeView *tree_view;
GtkTreePath *path;
GtkTreeIter iter;
GdkCursor *cursor;
GdkWindow *window;
AsyncContext *context;
gboolean have_selection;
tree_view = editor->priv->active->tree_view;
selection = gtk_tree_view_get_selection (tree_view);
have_selection = gtk_tree_selection_get_selected (
selection, &tree_model, &iter);
g_return_if_fail (have_selection);
/* Cancel any operation on this store still in progress. */
gtk_button_clicked (GTK_BUTTON (editor->priv->stop_button));
/* Start a new 'unsubscription' operation. */
editor->priv->active->cancellable = g_cancellable_new ();
gtk_widget_set_sensitive (editor->priv->notebook, FALSE);
gtk_widget_set_sensitive (editor->priv->subscribe_button, FALSE);
gtk_widget_set_sensitive (editor->priv->unsubscribe_button, FALSE);
gtk_widget_set_sensitive (editor->priv->refresh_button, FALSE);
gtk_widget_set_sensitive (editor->priv->stop_button, TRUE);
cursor = gdk_cursor_new (GDK_WATCH);
window = gtk_widget_get_window (GTK_WIDGET (editor));
gdk_window_set_cursor (window, cursor);
gdk_cursor_unref (cursor);
gtk_tree_model_get (
tree_model, &iter, COL_FOLDER_INFO, &folder_info, -1);
path = gtk_tree_model_get_path (tree_model, &iter);
reference = gtk_tree_row_reference_new (tree_model, path);
gtk_tree_path_free (path);
context = g_slice_new0 (AsyncContext);
context->editor = g_object_ref (editor);
context->folder_info = folder_info;
context->reference = reference;
camel_store_unsubscribe_folder (
editor->priv->active->store,
folder_info->full_name, G_PRIORITY_DEFAULT,
editor->priv->active->cancellable, (GAsyncReadyCallback)
subscription_editor_unsubscribe_folder_done, context);
}
static void
subscription_editor_collapse_all (EMSubscriptionEditor *editor)
{
gtk_tree_view_collapse_all (editor->priv->active->tree_view);
}
static void
subscription_editor_expand_all (EMSubscriptionEditor *editor)
{
gtk_tree_view_expand_all (editor->priv->active->tree_view);
}
static void
subscription_editor_refresh (EMSubscriptionEditor *editor)
{
GdkCursor *cursor;
GdkWindow *window;
/* Cancel any operation on this store still in progress. */
gtk_button_clicked (GTK_BUTTON (editor->priv->stop_button));
/* Start a new 'refresh' operation. */
editor->priv->active->cancellable = g_cancellable_new ();
gtk_widget_set_sensitive (editor->priv->notebook, FALSE);
gtk_widget_set_sensitive (editor->priv->subscribe_button, FALSE);
gtk_widget_set_sensitive (editor->priv->unsubscribe_button, FALSE);
gtk_widget_set_sensitive (editor->priv->refresh_button, FALSE);
gtk_widget_set_sensitive (editor->priv->stop_button, TRUE);
cursor = gdk_cursor_new (GDK_WATCH);
window = gtk_widget_get_window (GTK_WIDGET (editor));
gdk_window_set_cursor (window, cursor);
gdk_cursor_unref (cursor);
camel_store_get_folder_info (
editor->priv->active->store, NULL,
CAMEL_STORE_FOLDER_INFO_RECURSIVE |
CAMEL_STORE_FOLDER_INFO_NO_VIRTUAL |
CAMEL_STORE_FOLDER_INFO_SUBSCRIPTION_LIST,
G_PRIORITY_DEFAULT, editor->priv->active->cancellable,
(GAsyncReadyCallback) subscription_editor_get_folder_info_done,
g_object_ref (editor));
}
static void
subscription_editor_stop (EMSubscriptionEditor *editor)
{
GdkWindow *window;
if (editor->priv->active->cancellable != NULL) {
g_cancellable_cancel (editor->priv->active->cancellable);
g_object_unref (editor->priv->active->cancellable);
editor->priv->active->cancellable = NULL;
}
gtk_widget_set_sensitive (editor->priv->notebook, TRUE);
gtk_widget_set_sensitive (editor->priv->subscribe_button, TRUE);
gtk_widget_set_sensitive (editor->priv->unsubscribe_button, TRUE);
gtk_widget_set_sensitive (editor->priv->refresh_button, TRUE);
gtk_widget_set_sensitive (editor->priv->stop_button, FALSE);
window = gtk_widget_get_window (GTK_WIDGET (editor));
gdk_window_set_cursor (window, NULL);
}
static gboolean
subscription_editor_filter_cb (GtkTreeModel *tree_model,
GtkTreeIter *iter,
EMSubscriptionEditor *editor)
{
CamelFolderInfo *folder_info;
gchar *casefolded;
gboolean match;
/* If there's no search string let everything through. */
if (editor->priv->search_string == NULL)
return TRUE;
gtk_tree_model_get (
tree_model, iter,
COL_CASEFOLDED, &casefolded,
COL_FOLDER_INFO, &folder_info, -1);
match = FOLDER_CAN_SELECT (folder_info) &&
(casefolded != NULL) && (*casefolded != '\0') &&
(strstr (casefolded, editor->priv->search_string) != NULL);
g_free (casefolded);
return match;
}
static void
subscription_editor_update_view (EMSubscriptionEditor *editor)
{
GtkEntry *entry;
GtkTreeView *tree_view;
GtkTreeModel *tree_model;
const gchar *text;
entry = GTK_ENTRY (editor->priv->entry);
tree_view = editor->priv->active->tree_view;
editor->priv->timeout_id = 0;
text = gtk_entry_get_text (entry);
if (text != NULL && *text != '\0') {
g_free (editor->priv->search_string);
editor->priv->search_string = g_utf8_casefold (text, -1);
/* Install the list store in the tree view if needed. */
if (!editor->priv->active->filtered_view) {
GtkTreeSelection *selection;
GtkTreePath *path;
tree_model = gtk_tree_model_filter_new (
editor->priv->active->list_store, NULL);
gtk_tree_model_filter_set_visible_func (
GTK_TREE_MODEL_FILTER (tree_model),
(GtkTreeModelFilterVisibleFunc)
subscription_editor_filter_cb, editor,
(GDestroyNotify) NULL);
gtk_tree_view_set_model (tree_view, tree_model);
g_object_unref (tree_model);
path = gtk_tree_path_new_first ();
selection = gtk_tree_view_get_selection (tree_view);
gtk_tree_selection_select_path (selection, path);
gtk_tree_path_free (path);
editor->priv->active->filtered_view = TRUE;
}
tree_model = gtk_tree_view_get_model (tree_view);
gtk_tree_model_filter_refilter (
GTK_TREE_MODEL_FILTER (tree_model));
gtk_entry_set_icon_sensitive (
entry, GTK_ENTRY_ICON_SECONDARY, TRUE);
gtk_widget_set_sensitive (
editor->priv->collapse_all_button, FALSE);
gtk_widget_set_sensitive (
editor->priv->expand_all_button, FALSE);
} else {
/* Install the tree store in the tree view if needed. */
if (editor->priv->active->filtered_view) {
GtkTreeSelection *selection;
GtkTreePath *path;
tree_model = editor->priv->active->tree_store;
gtk_tree_view_set_model (tree_view, tree_model);
path = gtk_tree_path_new_first ();
selection = gtk_tree_view_get_selection (tree_view);
gtk_tree_selection_select_path (selection, path);
gtk_tree_path_free (path);
editor->priv->active->filtered_view = FALSE;
}
gtk_entry_set_icon_sensitive (
entry, GTK_ENTRY_ICON_SECONDARY, FALSE);
gtk_widget_set_sensitive (
editor->priv->collapse_all_button, TRUE);
gtk_widget_set_sensitive (
editor->priv->expand_all_button, TRUE);
}
}
static gboolean
subscription_editor_timeout_cb (EMSubscriptionEditor *editor)
{
subscription_editor_update_view (editor);
editor->priv->timeout_id = 0;
return FALSE;
}
static void
subscription_editor_combo_box_changed_cb (GtkComboBox *combo_box,
EMSubscriptionEditor *editor)
{
StoreData *data;
gint index;
index = gtk_combo_box_get_active (combo_box);
g_return_if_fail (index < editor->priv->stores->len);
data = g_ptr_array_index (editor->priv->stores, index);
g_return_if_fail (data != NULL);
editor->priv->active = data;
subscription_editor_stop (editor);
subscription_editor_update_view (editor);
g_object_notify (G_OBJECT (editor), "account");
if (data->needs_refresh) {
subscription_editor_refresh (editor);
data->needs_refresh = FALSE;
}
}
static void
subscription_editor_entry_changed_cb (GtkEntry *entry,
EMSubscriptionEditor *editor)
{
const gchar *text;
if (editor->priv->timeout_id > 0) {
g_source_remove (editor->priv->timeout_id);
editor->priv->timeout_id = 0;
}
text = gtk_entry_get_text (entry);
if (text != NULL && *text != '\0')
editor->priv->timeout_id = g_timeout_add_seconds (
1, (GSourceFunc) subscription_editor_timeout_cb, editor);
else
subscription_editor_update_view (editor);
}
static void
subscription_editor_icon_release_cb (GtkEntry *entry,
GtkEntryIconPosition icon_pos,
GdkEvent *event,
EMSubscriptionEditor *editor)
{
if (icon_pos == GTK_ENTRY_ICON_SECONDARY)
gtk_entry_set_text (entry, "");
}
static void
subscription_editor_renderer_toggled_cb (GtkCellRendererToggle *renderer,
const gchar *path_string,
EMSubscriptionEditor *editor)
{
GtkTreeSelection *selection;
GtkTreeView *tree_view;
GtkTreePath *path;
tree_view = editor->priv->active->tree_view;
selection = gtk_tree_view_get_selection (tree_view);
path = gtk_tree_path_new_from_string (path_string);
gtk_tree_selection_select_path (selection, path);
gtk_tree_path_free (path);
if (gtk_cell_renderer_toggle_get_active (renderer))
subscription_editor_unsubscribe (editor);
else
subscription_editor_subscribe (editor);
}
static void
subscription_editor_render_toggle_cb (GtkCellLayout *cell_layout,
GtkCellRenderer *renderer,
GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
CamelFolderInfo *folder_info;
gtk_tree_model_get (
tree_model, iter, COL_FOLDER_INFO, &folder_info, -1);
g_object_set (
renderer, "active", FOLDER_SUBSCRIBED (folder_info),
"visible", FOLDER_CAN_SELECT (folder_info), NULL);
}
static void
subscription_editor_selection_changed_cb (GtkTreeSelection *selection,
EMSubscriptionEditor *editor)
{
GtkTreeModel *tree_model;
GtkTreeIter iter;
if (gtk_tree_selection_get_selected (selection, &tree_model, &iter)) {
CamelFolderInfo *folder_info;
gtk_tree_model_get (
tree_model, &iter,
COL_FOLDER_INFO, &folder_info, -1);
gtk_widget_set_sensitive (
editor->priv->subscribe_button,
FOLDER_CAN_SELECT (folder_info) &&
!FOLDER_SUBSCRIBED (folder_info));
gtk_widget_set_sensitive (
editor->priv->unsubscribe_button,
FOLDER_CAN_SELECT (folder_info) &&
FOLDER_SUBSCRIBED (folder_info));
} else {
gtk_widget_set_sensitive (
editor->priv->subscribe_button, FALSE);
gtk_widget_set_sensitive (
editor->priv->subscribe_button, FALSE);
}
}
static void
subscription_editor_add_account (EMSubscriptionEditor *editor,
EAccount *account)
{
StoreData *data;
CamelStore *store;
CamelSession *session;
GtkListStore *list_store;
GtkTreeStore *tree_store;
GtkTreeViewColumn *column;
GtkTreeSelection *selection;
GtkCellRenderer *renderer;
GtkComboBoxText *combo_box;
GtkWidget *container;
GtkWidget *widget;
const gchar *url;
combo_box = GTK_COMBO_BOX_TEXT (editor->priv->combo_box);
gtk_combo_box_text_append_text (combo_box, account->name);
session = em_subscription_editor_get_session (editor);
url = e_account_get_string (account, E_ACCOUNT_SOURCE_URL);
store = (CamelStore *) camel_session_get_service (
session, url, CAMEL_PROVIDER_STORE, NULL);
tree_store = gtk_tree_store_new (
N_COLUMNS,
/* COL_CASEFOLDED */ G_TYPE_STRING,
/* COL_FOLDER_ICON */ G_TYPE_STRING,
/* COL_FOLDER_NAME */ G_TYPE_STRING,
/* COL_FOLDER_INFO */ G_TYPE_POINTER);
list_store = gtk_list_store_new (
N_COLUMNS,
/* COL_CASEFOLDED */ G_TYPE_STRING,
/* COL_FOLDER_ICON */ G_TYPE_STRING,
/* COL_FOLDER_NAME */ G_TYPE_STRING,
/* COL_FOLDER_INFO */ G_TYPE_POINTER);
container = editor->priv->notebook;
widget = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (
GTK_SCROLLED_WINDOW (widget),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (
GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
gtk_notebook_append_page (GTK_NOTEBOOK (container), widget, NULL);
gtk_widget_show (widget);
container = widget;
widget = gtk_tree_view_new_with_model (GTK_TREE_MODEL (tree_store));
gtk_tree_view_set_enable_search (GTK_TREE_VIEW (widget), TRUE);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (widget), FALSE);
gtk_tree_view_set_search_column (
GTK_TREE_VIEW (widget), COL_FOLDER_NAME);
gtk_container_add (GTK_CONTAINER (container), widget);
gtk_widget_show (widget);
column = gtk_tree_view_column_new ();
gtk_tree_view_append_column (GTK_TREE_VIEW (widget), column);
renderer = gtk_cell_renderer_toggle_new ();
g_object_set (renderer, "activatable", TRUE, NULL);
gtk_tree_view_column_pack_start (column, renderer, FALSE);
gtk_cell_layout_set_cell_data_func (
GTK_CELL_LAYOUT (column), renderer,
(GtkCellLayoutDataFunc) subscription_editor_render_toggle_cb,
NULL, (GDestroyNotify) NULL);
g_signal_connect (
renderer, "toggled",
G_CALLBACK (subscription_editor_renderer_toggled_cb), editor);
column = gtk_tree_view_column_new ();
gtk_tree_view_append_column (GTK_TREE_VIEW (widget), column);
gtk_tree_view_set_expander_column (GTK_TREE_VIEW (widget), column);
renderer = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_column_pack_start (column, renderer, FALSE);
gtk_tree_view_column_add_attribute (
column, renderer, "icon-name", COL_FOLDER_ICON);
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_column_pack_start (column, renderer, TRUE);
gtk_tree_view_column_add_attribute (
column, renderer, "text", COL_FOLDER_NAME);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
g_signal_connect (
selection, "changed",
G_CALLBACK (subscription_editor_selection_changed_cb), editor);
data = g_slice_new0 (StoreData);
data->account = g_object_ref (account);
data->store = g_object_ref (store);
data->tree_view = g_object_ref (widget);
data->list_store = GTK_TREE_MODEL (list_store);
data->tree_store = GTK_TREE_MODEL (tree_store);
data->needs_refresh = TRUE;
g_ptr_array_add (editor->priv->stores, data);
}
static gboolean
subscription_editor_test_account (EMSubscriptionEditor *editor,
EAccount *account)
{
CamelSession *session;
CamelStore *store;
const gchar *url;
/* Account must be enabled. */
if (!account->enabled)
return FALSE;
session = em_subscription_editor_get_session (editor);
url = e_account_get_string (account, E_ACCOUNT_SOURCE_URL);
store = (CamelStore *) camel_session_get_service (
session, url, CAMEL_PROVIDER_STORE, NULL);
/* Corresponding CamelStore must support subscriptions. */
return (store != NULL) && camel_store_supports_subscriptions (store);
}
static void
subscription_editor_set_account (EMSubscriptionEditor *editor,
EAccount *account)
{
g_return_if_fail (editor->priv->initial_account == NULL);
if (account == NULL)
account = e_get_default_account ();
if (E_IS_ACCOUNT (account))
editor->priv->initial_account = g_object_ref (account);
}
static void
subscription_editor_set_session (EMSubscriptionEditor *editor,
CamelSession *session)
{
g_return_if_fail (CAMEL_IS_SESSION (session));
g_return_if_fail (editor->priv->session == NULL);
editor->priv->session = g_object_ref (session);
}
static void
subscription_editor_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
switch (property_id) {
case PROP_ACCOUNT:
subscription_editor_set_account (
EM_SUBSCRIPTION_EDITOR (object),
g_value_get_object (value));
return;
case PROP_SESSION:
subscription_editor_set_session (
EM_SUBSCRIPTION_EDITOR (object),
g_value_get_object (value));
return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static void
subscription_editor_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
switch (property_id) {
case PROP_ACCOUNT:
g_value_set_object (
value,
em_subscription_editor_get_account (
EM_SUBSCRIPTION_EDITOR (object)));
return;
case PROP_SESSION:
g_value_set_object (
value,
em_subscription_editor_get_session (
EM_SUBSCRIPTION_EDITOR (object)));
return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static void
subscription_editor_dispose (GObject *object)
{
EMSubscriptionEditorPrivate *priv;
priv = EM_SUBSCRIPTION_EDITOR_GET_PRIVATE (object);
if (priv->session != NULL) {
g_object_unref (priv->session);
priv->session = NULL;
}
if (priv->initial_account != NULL) {
g_object_unref (priv->initial_account);
priv->initial_account = NULL;
}
if (priv->timeout_id > 0) {
g_source_remove (priv->timeout_id);
priv->timeout_id = 0;
}
g_ptr_array_set_size (priv->stores, 0);
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (em_subscription_editor_parent_class)->dispose (object);
}
static void
subscription_editor_finalize (GObject *object)
{
EMSubscriptionEditorPrivate *priv;
priv = EM_SUBSCRIPTION_EDITOR_GET_PRIVATE (object);
g_ptr_array_free (priv->stores, TRUE);
g_free (priv->search_string);
/* Chain up to parent's finalize() method. */
G_OBJECT_CLASS (em_subscription_editor_parent_class)->finalize (object);
}
static void
subscription_editor_realize (GtkWidget *widget)
{
EMSubscriptionEditor *editor;
GtkComboBox *combo_box;
CamelSession *session;
GList *list, *iter;
gint initial_index = 0;
editor = EM_SUBSCRIPTION_EDITOR (widget);
session = em_subscription_editor_get_session (editor);
/* Chain up to parent's realize() method. */
GTK_WIDGET_CLASS (em_subscription_editor_parent_class)->realize (widget);
/* Find accounts to display, and watch for the default account. */
list = e_get_subscribable_accounts (session);
for (iter = list; iter != NULL; iter = g_list_next (iter)) {
EAccount *account = E_ACCOUNT (iter->data);
if (account == editor->priv->initial_account)
initial_index = editor->priv->stores->len;
subscription_editor_add_account (editor, account);
}
g_list_free (list);
/* The subscription editor should only be accessible if
* at least one enabled account supports subscriptions. */
g_return_if_fail (editor->priv->stores->len > 0);
combo_box = GTK_COMBO_BOX (editor->priv->combo_box);
gtk_combo_box_set_active (combo_box, initial_index);
}
static void
em_subscription_editor_class_init (EMSubscriptionEditorClass *class)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
g_type_class_add_private (class, sizeof (EMSubscriptionEditorPrivate));
object_class = G_OBJECT_CLASS (class);
object_class->set_property = subscription_editor_set_property;
object_class->get_property = subscription_editor_get_property;
object_class->dispose = subscription_editor_dispose;
object_class->finalize = subscription_editor_finalize;
widget_class = GTK_WIDGET_CLASS (class);
widget_class->realize = subscription_editor_realize;
g_object_class_install_property (
object_class,
PROP_ACCOUNT,
g_param_spec_object (
"account",
NULL,
NULL,
E_TYPE_ACCOUNT,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (
object_class,
PROP_SESSION,
g_param_spec_object (
"session",
NULL,
NULL,
CAMEL_TYPE_SESSION,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
}
static void
em_subscription_editor_init (EMSubscriptionEditor *editor)
{
GtkWidget *container;
GtkWidget *widget;
GtkWidget *box;
const gchar *tooltip;
editor->priv = EM_SUBSCRIPTION_EDITOR_GET_PRIVATE (editor);
editor->priv->stores = g_ptr_array_new_with_free_func (
(GDestroyNotify) store_data_free);
gtk_container_set_border_width (GTK_CONTAINER (editor), 5);
gtk_window_set_title (GTK_WINDOW (editor), _("Folder Subscriptions"));
gconf_bridge_bind_window_size (
gconf_bridge_get (),
"/apps/evolution/mail/subscription_editor",
GTK_WINDOW (editor));
gtk_dialog_add_button (
GTK_DIALOG (editor),
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
container = gtk_dialog_get_content_area (GTK_DIALOG (editor));
widget = gtk_vbox_new (FALSE, 12);
gtk_container_set_border_width (GTK_CONTAINER (widget), 5);
gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
gtk_widget_show (widget);
container = box = widget;
widget = gtk_table_new (2, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (widget), 6);
gtk_table_set_row_spacings (GTK_TABLE (widget), 6);
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
gtk_widget_show (widget);
container = widget;
widget = gtk_combo_box_text_new ();
gtk_table_attach (
GTK_TABLE (container), widget,
1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
editor->priv->combo_box = widget;
gtk_widget_show (widget);
g_signal_connect (
widget, "changed",
G_CALLBACK (subscription_editor_combo_box_changed_cb), editor);
widget = gtk_label_new_with_mnemonic (_("_Account:"));
gtk_label_set_mnemonic_widget (
GTK_LABEL (widget), editor->priv->combo_box);
gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
gtk_table_attach (
GTK_TABLE (container), widget,
0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (widget);
widget = gtk_entry_new ();
gtk_entry_set_icon_from_stock (
GTK_ENTRY (widget),
GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
gtk_entry_set_icon_tooltip_text (
GTK_ENTRY (widget),
GTK_ENTRY_ICON_SECONDARY, _("Clear Search"));
gtk_entry_set_icon_sensitive (
GTK_ENTRY (widget),
GTK_ENTRY_ICON_SECONDARY, FALSE);
gtk_table_attach (
GTK_TABLE (container), widget,
1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
editor->priv->entry = widget;
gtk_widget_show (widget);
g_signal_connect (
widget, "changed",
G_CALLBACK (subscription_editor_entry_changed_cb), editor);
g_signal_connect (
widget, "icon-release",
G_CALLBACK (subscription_editor_icon_release_cb), editor);
widget = gtk_label_new_with_mnemonic (_("Sho_w items that contain:"));
gtk_label_set_mnemonic_widget (
GTK_LABEL (widget), editor->priv->entry);
gtk_misc_set_alignment (GTK_MISC (widget), 1.0, 0.5);
gtk_table_attach (
GTK_TABLE (container), widget,
0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (widget);
container = box;
widget = gtk_hbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
gtk_widget_show (widget);
container = widget;
widget = gtk_notebook_new ();
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
gtk_container_add (GTK_CONTAINER (container), widget);
editor->priv->notebook = widget;
gtk_widget_show (widget);
g_object_bind_property (
editor->priv->combo_box, "active",
editor->priv->notebook, "page",
G_BINDING_BIDIRECTIONAL |
G_BINDING_SYNC_CREATE);
widget = gtk_vbutton_box_new ();
gtk_box_set_spacing (GTK_BOX (widget), 6);
gtk_button_box_set_layout (
GTK_BUTTON_BOX (widget), GTK_BUTTONBOX_START);
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0);
gtk_widget_show (widget);
container = widget;
tooltip = _("Subscribe to the selected folder");
widget = gtk_button_new_with_mnemonic (_("Su_bscribe"));
gtk_widget_set_sensitive (widget, FALSE);
gtk_widget_set_tooltip_text (widget, tooltip);
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
editor->priv->subscribe_button = widget;
gtk_widget_show (widget);
g_signal_connect_swapped (
widget, "clicked",
G_CALLBACK (subscription_editor_subscribe), editor);
tooltip = _("Unsubscribe from the selected folder");
widget = gtk_button_new_with_mnemonic (_("_Unsubscribe"));
gtk_widget_set_sensitive (widget, FALSE);
gtk_widget_set_tooltip_text (widget, tooltip);
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
editor->priv->unsubscribe_button = widget;
gtk_widget_show (widget);
g_signal_connect_swapped (
widget, "clicked",
G_CALLBACK (subscription_editor_unsubscribe), editor);
tooltip = _("Collapse all folders");
widget = gtk_button_new_with_mnemonic (_("C_ollapse All"));
gtk_widget_set_tooltip_text (widget, tooltip);
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
editor->priv->collapse_all_button = widget;
gtk_widget_show (widget);
g_signal_connect_swapped (
widget, "clicked",
G_CALLBACK (subscription_editor_collapse_all), editor);
tooltip = _("Expand all folders");
widget = gtk_button_new_with_mnemonic (_("E_xpand All"));
gtk_widget_set_tooltip_text (widget, tooltip);
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
editor->priv->expand_all_button = widget;
gtk_widget_show (widget);
g_signal_connect_swapped (
widget, "clicked",
G_CALLBACK (subscription_editor_expand_all), editor);
tooltip = _("Refresh the folder list");
widget = gtk_button_new_from_stock (GTK_STOCK_REFRESH);
gtk_widget_set_tooltip_text (widget, tooltip);
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
gtk_widget_set_sensitive (widget, FALSE);
editor->priv->refresh_button = widget;
gtk_widget_show (widget);
g_signal_connect_swapped (
widget, "clicked",
G_CALLBACK (subscription_editor_refresh), editor);
tooltip = _("Stop the current operation");
widget = gtk_button_new_from_stock (GTK_STOCK_STOP);
gtk_widget_set_tooltip_text (widget, tooltip);
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
gtk_widget_set_sensitive (widget, FALSE);
editor->priv->stop_button = widget;
gtk_widget_show (widget);
g_signal_connect_swapped (
widget, "clicked",
G_CALLBACK (subscription_editor_stop), editor);
}
GtkWidget *
em_subscription_editor_new (GtkWindow *parent,
CamelSession *session,
EAccount *account)
{
g_return_val_if_fail (GTK_IS_WINDOW (parent), NULL);
g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
return g_object_new (
EM_TYPE_SUBSCRIPTION_EDITOR,
"account", account,
"session", session,
"transient-for", parent,
NULL);
}
EAccount *
em_subscription_editor_get_account (EMSubscriptionEditor *editor)
{
g_return_val_if_fail (EM_IS_SUBSCRIPTION_EDITOR (editor), NULL);
if (editor->priv->active == NULL)
return NULL;
return editor->priv->active->account;
}
CamelSession *
em_subscription_editor_get_session (EMSubscriptionEditor *editor)
{
g_return_val_if_fail (EM_IS_SUBSCRIPTION_EDITOR (editor), NULL);
return editor->priv->session;
}
|