~ubuntu-branches/ubuntu/saucy/geary/saucy-updates

« back to all changes in this revision

Viewing changes to src/client/sidebar/sidebar-tree.vala

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2013-03-14 13:48:23 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20130314134823-gyk5av1g508zyj8a
Tags: 0.3.0~pr1-0ubuntu1
New upstream version (FFE lp: #1154316), supports multiple account as
well as full conversation views with inline replies

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    private class RootWrapper : EntryWrapper {
38
38
        public int root_position;
39
39
        
40
 
        public RootWrapper(Gtk.TreeModel model, Sidebar.Entry entry, Gtk.TreePath path, int root_position) 
41
 
            requires (root_position >= 0) {
 
40
        public RootWrapper(Gtk.TreeModel model, Sidebar.Entry entry, Gtk.TreePath path, int root_position) {
42
41
            base (model, entry, path);
43
42
            
44
43
            this.root_position = root_position;
262
261
        return rows.length() != 0 ? rows.nth_data(0) : null;
263
262
    }
264
263
 
 
264
    private string get_name_for_entry(Sidebar.Entry entry) {
 
265
        string name = Geary.HTML.escape_markup(entry.get_sidebar_name());
 
266
        
 
267
        Sidebar.EmphasizableEntry? emphasizable_entry = entry as Sidebar.EmphasizableEntry;
 
268
        if (emphasizable_entry != null && emphasizable_entry.is_emphasized())
 
269
            name = "<b>%s</b>".printf(name);
 
270
        
 
271
        return name;
 
272
    }
 
273
    
265
274
    public override void cursor_changed() {
266
275
        Gtk.TreePath? path = get_selected_path();
267
276
        if (path == null) {
343
352
        return branches.has_key(branch);
344
353
    }
345
354
    
346
 
    public void graft(Sidebar.Branch branch, int position) requires (position >= 0) {
 
355
    public void graft(Sidebar.Branch branch, int position) {
347
356
        assert(!branches.has_key(branch));
348
357
        
349
358
        branches.set(branch, position);
368
377
        branch_added(branch);
369
378
    }
370
379
    
 
380
    public int get_position_for_branch(Sidebar.Branch branch) {
 
381
        if (branches.has_key(branch))
 
382
            return branches.get(branch);
 
383
        
 
384
        return int.MIN;
 
385
    }
 
386
    
371
387
    // This is used to associate a known branch with the TreeView.
372
388
    private void associate_branch(Sidebar.Branch branch) {
373
389
        assert(branches.has_key(branch));
429
445
        assert(!entry_map.has_key(entry));
430
446
        entry_map.set(entry, wrapper);
431
447
        
432
 
        store.set(assoc_iter, Columns.NAME, Geary.HTML.escape_markup(entry.get_sidebar_name()));
 
448
        store.set(assoc_iter, Columns.NAME, get_name_for_entry(entry));
433
449
        store.set(assoc_iter, Columns.TOOLTIP, entry.get_sidebar_tooltip() != null ?
434
450
            Geary.HTML.escape_markup(entry.get_sidebar_tooltip()) : null);
435
451
        store.set(assoc_iter, Columns.WRAPPER, wrapper);
442
458
        if (renameable != null)
443
459
            renameable.sidebar_name_changed.connect(on_sidebar_name_changed);
444
460
        
 
461
        Sidebar.EmphasizableEntry? emphasizable = entry as Sidebar.EmphasizableEntry;
 
462
        if (emphasizable != null)
 
463
            emphasizable.is_emphasized_changed.connect(on_is_emphasized_changed);
 
464
        
445
465
        Sidebar.ExpandableEntry? expandable = entry as Sidebar.ExpandableEntry;
446
466
        if (expandable != null)
447
467
            expandable.sidebar_open_closed_icons_changed.connect(on_sidebar_open_closed_icons_changed);
458
478
        EntryWrapper new_wrapper = new EntryWrapper(store, entry, store.get_path(new_iter));
459
479
        entry_map.set(entry, new_wrapper);
460
480
        
461
 
        store.set(new_iter, Columns.NAME, Geary.HTML.escape_markup(entry.get_sidebar_name()));
 
481
        store.set(new_iter, Columns.NAME, get_name_for_entry(entry));
462
482
        store.set(new_iter, Columns.TOOLTIP, Geary.HTML.escape_markup(entry.get_sidebar_tooltip()));
463
483
        store.set(new_iter, Columns.WRAPPER, new_wrapper);
464
484
        load_entry_icons(new_iter);
554
574
        if (renameable != null)
555
575
            renameable.sidebar_name_changed.disconnect(on_sidebar_name_changed);
556
576
        
 
577
        Sidebar.EmphasizableEntry? emphasizable = entry as Sidebar.EmphasizableEntry;
 
578
        if (emphasizable != null)
 
579
            emphasizable.is_emphasized_changed.disconnect(on_is_emphasized_changed);
 
580
        
557
581
        Sidebar.ExpandableEntry? expandable = entry as Sidebar.ExpandableEntry;
558
582
        if (expandable != null)
559
583
            expandable.sidebar_open_closed_icons_changed.disconnect(on_sidebar_open_closed_icons_changed);
703
727
        store.set(wrapper.get_iter(), Columns.CLOSED_PIXBUF, fetch_icon_pixbuf(closed));
704
728
    }
705
729
    
 
730
    private void rename_entry(Sidebar.Entry entry) {
 
731
        EntryWrapper? wrapper = get_wrapper(entry);
 
732
        assert(wrapper != null);
 
733
        
 
734
        store.set(wrapper.get_iter(), Columns.NAME, get_name_for_entry(entry));
 
735
    }
 
736
    
706
737
    private void on_sidebar_name_changed(Sidebar.RenameableEntry entry, string name) {
707
 
        EntryWrapper? wrapper = get_wrapper(entry);
708
 
        assert(wrapper != null);
709
 
        
710
 
        store.set(wrapper.get_iter(), Columns.NAME, Geary.HTML.escape_markup(name));
 
738
        rename_entry(entry);
 
739
    }
 
740
    
 
741
    private void on_is_emphasized_changed(Sidebar.EmphasizableEntry entry, bool is_emphasized) {
 
742
        rename_entry(entry);
711
743
    }
712
744
    
713
745
    private Gdk.Pixbuf? fetch_icon_pixbuf(GLib.Icon? gicon) {