~teejee2008/timeshift/trunk

« back to all changes in this revision

Viewing changes to src/Gtk/RsyncLogWindow.vala

  • Committer: Tony George
  • Date: 2016-08-28 04:41:17 UTC
  • Revision ID: tony.george.kol@gmail.com-20160828044117-5uwh25dpbagm9181
Moved UI helper code to GtkHelper

Show diffs side-by-side

added added

removed removed

Lines of Context:
201
201
                log_debug("init_toolbar(): finished");
202
202
        }
203
203
 
204
 
        /*
205
 
        private void init_toolbar2(){
206
 
                var hbox_row1 = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
207
 
        vbox_main.add(hbox_row1);
208
 
 
209
 
                Gtk.SizeGroup size_group = null;
210
 
 
211
 
                // button box for state
212
 
 
213
 
                var hbox_state = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
214
 
                //hbox_state.set_layout (Gtk.ButtonBoxStyle.EXPAND);
215
 
        hbox_row1.add(hbox_state);
216
 
        
217
 
                size_group = null;
218
 
 
219
 
                var btn_state_all = add_toggle_button(hbox_state, _("All"), "", ref size_group, null);
220
 
                btn_state_all.active = view_state_all;
221
 
        btn_state_all.toggled.connect(()=>{
222
 
                        view_state_all = btn_state_all.active;
223
 
                        tv_files_refresh();
224
 
                });
225
 
                
226
 
                var btn_created = add_toggle_button(hbox_state, _("Created"), "", ref size_group, null);
227
 
                btn_created.active = view_created;
228
 
        btn_created.toggled.connect(()=>{
229
 
                        view_created = btn_created.active;
230
 
 
231
 
                        if (view_created && btn_state_all.active){
232
 
                                btn_state_all.active = false;
233
 
                        }
234
 
                        else{
235
 
                                tv_files_refresh();
236
 
                        }
237
 
                });
238
 
 
239
 
                var btn_modified = add_toggle_button(hbox_state, _("Modified"), "", ref size_group, null);
240
 
                btn_modified.active = view_modified;
241
 
        btn_modified.toggled.connect(()=>{
242
 
                        view_modified = btn_modified.active;
243
 
 
244
 
                        if (view_modified && btn_state_all.active){
245
 
                                btn_state_all.active = false;
246
 
                        }
247
 
                        else{
248
 
                                tv_files_refresh();
249
 
                        }
250
 
                });
251
 
 
252
 
                var btn_deleted = add_toggle_button(hbox_state, _("Deleted"), "", ref size_group, null);
253
 
                btn_deleted.active = view_deleted;
254
 
        btn_deleted.toggled.connect(()=>{
255
 
                        view_deleted = btn_deleted.active;
256
 
 
257
 
                        if (view_deleted && btn_state_all.active){
258
 
                                btn_state_all.active = false;
259
 
                        }
260
 
                        else{
261
 
                                tv_files_refresh();
262
 
                        }
263
 
                });
264
 
 
265
 
                var label = add_label(hbox_row1, "");
266
 
                label.hexpand = true;
267
 
                
268
 
                // flat view
269
 
 
270
 
                size_group = null;
271
 
                
272
 
                var btn_flat = add_toggle_button(hbox_row1, _("Flat View"), "", ref size_group, null);
273
 
                btn_flat.active = flat_view;
274
 
        btn_flat.toggled.connect(()=>{
275
 
                        flat_view = btn_flat.active;
276
 
                        tv_files_refresh();
277
 
                });
278
 
 
279
 
                // next row ----------------
280
 
 
281
 
 
282
 
                var hbox_row2 = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
283
 
        vbox_main.add(hbox_row2);
284
 
        
285
 
                // button box - hbox_modified
286
 
 
287
 
                var bbox_modified = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
288
 
                //bbox_modified.set_layout (Gtk.ButtonBoxStyle.START);
289
 
        hbox_row2.add(bbox_modified);
290
 
 
291
 
                size_group = null;
292
 
                
293
 
        var btn_modified_all = add_toggle_button(bbox_modified, _("All"), "", ref size_group, null);
294
 
                btn_modified_all.active = view_modified_all;
295
 
        btn_modified_all.toggled.connect(()=>{
296
 
                        view_modified_all = btn_modified_all.active;
297
 
                        tv_files_refresh();
298
 
                });
299
 
                
300
 
                size_group = null;
301
 
                
302
 
                var btn_checksum = add_toggle_button(
303
 
                        bbox_modified, _("Checksum"), "", ref size_group, null);
304
 
                        
305
 
                btn_checksum.active = view_checksum;
306
 
                
307
 
        btn_checksum.toggled.connect(()=>{
308
 
                        view_checksum = btn_checksum.active;
309
 
 
310
 
                        if (view_checksum && btn_modified_all.active){
311
 
                                btn_modified_all.active = false;
312
 
                        }
313
 
                        else{
314
 
                                tv_files_refresh();
315
 
                        }
316
 
                });
317
 
 
318
 
                size_group = null;
319
 
                
320
 
                var btn_size = add_toggle_button(
321
 
                        bbox_modified, _("Size"), "", ref size_group, null);
322
 
                        
323
 
                btn_size.active = view_size;
324
 
                
325
 
        btn_size.toggled.connect(()=>{
326
 
                        view_size = btn_size.active;
327
 
 
328
 
                        if (view_size && btn_modified_all.active){
329
 
                                btn_modified_all.active = false;
330
 
                        }
331
 
                        else{
332
 
                                tv_files_refresh();
333
 
                        }
334
 
                });
335
 
 
336
 
                size_group = null;
337
 
                
338
 
                var btn_timestamp = add_toggle_button(
339
 
                        bbox_modified, _("Timestamp"), "", ref size_group, null);
340
 
                        
341
 
                btn_timestamp.active = view_timestamp;
342
 
                
343
 
        btn_timestamp.toggled.connect(()=>{
344
 
                        view_timestamp = btn_timestamp.active;
345
 
 
346
 
                        if (view_timestamp && btn_modified_all.active){
347
 
                                btn_modified_all.active = false;
348
 
                        }
349
 
                        else{
350
 
                                tv_files_refresh();
351
 
                        }
352
 
                });
353
 
 
354
 
                size_group = null;
355
 
                
356
 
                var btn_permissions = add_toggle_button(
357
 
                        bbox_modified, _("Permissions"), "", ref size_group, null);
358
 
 
359
 
                btn_permissions.active = view_permissions;
360
 
                        
361
 
        btn_permissions.toggled.connect(()=>{
362
 
                        view_permissions = btn_permissions.active;
363
 
 
364
 
                        if (view_permissions && btn_modified_all.active){
365
 
                                btn_modified_all.active = false;
366
 
                        }
367
 
                        else{
368
 
                                tv_files_refresh();
369
 
                        }
370
 
                });
371
 
 
372
 
                size_group = null;
373
 
                
374
 
                var btn_owner = add_toggle_button(
375
 
                        bbox_modified, _("Owner"), "", ref size_group, null);
376
 
 
377
 
                btn_owner.active = view_owner;
378
 
                
379
 
        btn_owner.toggled.connect(()=>{
380
 
                        view_owner = btn_owner.active;
381
 
 
382
 
                        if (view_owner && btn_modified_all.active){
383
 
                                btn_modified_all.active = false;
384
 
                        }
385
 
                        else{
386
 
                                tv_files_refresh();
387
 
                        }
388
 
                });
389
 
 
390
 
                size_group = null;
391
 
                
392
 
                var btn_group = add_toggle_button(
393
 
                        bbox_modified, _("Group"), "", ref size_group, null);
394
 
 
395
 
                btn_group.active = view_group;
396
 
                
397
 
        btn_group.toggled.connect(()=>{
398
 
                        view_group = btn_group.active;
399
 
 
400
 
                        if (view_group && btn_modified_all.active){
401
 
                                btn_modified_all.active = false;
402
 
                        }
403
 
                        else{
404
 
                                tv_files_refresh();
405
 
                        }
406
 
                });
407
 
 
408
 
                label = add_label(hbox_row2, "");
409
 
                label.hexpand = true;
410
 
        }
411
 
        * */
412
 
 
413
 
 
414
204
        private void init_tv_files() {
415
205
                // tv_files
416
206
                tv_files = new TreeView();
695
485
                }
696
486
        }
697
487
 
698
 
 
699
488
        private TreeIter? tv_append_to_iter(
700
489
                ref TreeStore model, ref TreeIter iter0, FileItem? item,
701
490
                bool odd_row, bool addItem = true) {
765
554
                return iter1;
766
555
        }
767
556
 
768
 
        /*private bool check_visibility2(FileItem item){
769
 
                bool is_visible = false;
770
 
                
771
 
                if (flat_view && (item.file_type == FileType.DIRECTORY)){
772
 
                        return false;
773
 
                }
774
 
                
775
 
                if ((item.file_status == "new") && (view_state_all || view_created)){
776
 
                        return true;
777
 
                }
778
 
                
779
 
                if ((item.file_status == "deleted") && (view_state_all || view_deleted)){
780
 
                        return true;
781
 
                }
782
 
 
783
 
                if ((item.file_status == "checksum") &&
784
 
                        view_modified && (view_modified_all || view_checksum)){
785
 
                        return true;
786
 
                }
787
 
 
788
 
                if ((item.file_status == "size") &&
789
 
                        view_modified && (view_modified_all || view_size)){
790
 
                        return true;
791
 
                }
792
 
 
793
 
                if ((item.file_status == "timestamp") &&
794
 
                        view_modified && (view_modified_all || view_timestamp)){
795
 
                        return true;
796
 
                }
797
 
 
798
 
                if ((item.file_status == "permissions") &&
799
 
                        view_modified && (view_modified_all || view_permissions)){
800
 
                        return true;
801
 
                }
802
 
 
803
 
                if ((item.file_status == "owner") &&
804
 
                        view_modified && (view_modified_all || view_owner)){
805
 
                        return true;
806
 
                }
807
 
 
808
 
                if ((item.file_status == "group") &&
809
 
                        view_modified && (view_modified_all || view_group)){
810
 
                        return true;
811
 
                }
812
 
                
813
 
                return is_visible;
814
 
        }*/
815
 
        
816
557
        private bool check_visibility(FileItem item){
817
558
 
818
559
                if (item.file_type == FileType.DIRECTORY){
887
628
                }
888
629
        }
889
630
 
890
 
        private Gtk.Label add_label(
891
 
                Gtk.Box box, string text, bool is_bold = false, bool is_italic = false, bool is_large = false){
892
 
                        
893
 
                string msg = "<span%s%s%s>%s</span>".printf(
894
 
                        (is_bold ? " weight=\"bold\"" : ""),
895
 
                        (is_italic ? " style=\"italic\"" : ""),
896
 
                        (is_large ? " size=\"x-large\"" : ""),
897
 
                        text);
898
 
                        
899
 
                var label = new Gtk.Label(msg);
900
 
                label.set_use_markup(true);
901
 
                label.xalign = (float) 0.0;
902
 
                box.add(label);
903
 
                return label;
904
 
        }
905
 
 
906
 
        private Gtk.Button add_button(
907
 
                Gtk.Box box, string text, string tooltip,
908
 
                ref Gtk.SizeGroup? size_group,
909
 
                Gtk.Image? icon = null){
910
 
                        
911
 
                var button = new Gtk.Button();
912
 
        box.add(button);
913
 
 
914
 
        button.set_label(text);
915
 
        button.set_tooltip_text(tooltip);
916
 
 
917
 
        if (icon != null){
918
 
                        button.set_image(icon);
919
 
                        button.set_always_show_image(true);
920
 
                }
921
 
 
922
 
                if (size_group == null){
923
 
                        size_group = new Gtk.SizeGroup(SizeGroupMode.HORIZONTAL);
924
 
                }
925
 
                
926
 
                //size_group.add_widget(button);
927
 
                
928
 
        return button;
929
 
        }
930
 
 
931
 
        private Gtk.ToggleButton add_toggle_button(
932
 
                Gtk.Box box, string text, string tooltip,
933
 
                ref Gtk.SizeGroup? size_group,
934
 
                Gtk.Image? icon = null){
935
 
                        
936
 
                var button = new Gtk.ToggleButton();
937
 
        box.add(button);
938
 
 
939
 
        button.set_label(text);
940
 
        button.set_tooltip_text(tooltip);
941
 
 
942
 
        if (icon != null){
943
 
                        button.set_image(icon);
944
 
                        button.set_always_show_image(true);
945
 
                }
946
 
 
947
 
                if (size_group == null){
948
 
                        size_group = new Gtk.SizeGroup(SizeGroupMode.HORIZONTAL);
949
 
                }
950
 
                
951
 
                size_group.add_widget(button);
952
 
                
953
 
        return button;
954
 
        }
955
 
        
956
631
}