~artem-anufrij/scratch/improve-split-view

« back to all changes in this revision

Viewing changes to plugins/outline/OutlinePlugin.vala

  • Committer: artem-anufrij
  • Date: 2014-12-31 11:17:49 UTC
  • mfrom: (1421.2.21 scratch)
  • Revision ID: artem-anufrij-20141231111749-jtd2u1wxzueka41g
only merge lp:scratch

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
 
47
47
        public void activate () {
48
48
            scratch_interface = (Scratch.Services.Interface)object;
49
 
            scratch_interface.hook_notebook_context.connect (on_hook_context);
 
49
 
50
50
            scratch_interface.hook_document.connect (on_hook_document);
51
 
            scratch_interface.hook_split_view.connect (on_hook_split_view);
 
51
 
 
52
            scratch_interface.hook_notebook_sidebar.connect (on_hook_sidebar);
 
53
 
52
54
            views = new Gee.LinkedList<SymbolOutline> ();
53
55
        }
54
56
 
59
61
        public void update_state () {
60
62
        }
61
63
 
62
 
        void on_hook_context (Gtk.Notebook notebook) {
 
64
        void on_hook_sidebar (Gtk.Notebook notebook) {
63
65
            if (container != null)
64
66
                return;
65
67
            if (this.notebook == null)
66
68
                this.notebook = notebook;
67
 
                
 
69
 
68
70
            container = new Gtk.EventBox ();
69
71
            container.visible = false;
 
72
            if (this.notebook != null)
 
73
                notebook.append_page (container, new Gtk.Label (_("Symbols")));
70
74
        }
71
75
 
72
76
        void on_hook_document (Scratch.Services.Document doc) {
73
 
            if (current_view != null && current_view.doc == doc) 
 
77
            if (current_view != null && current_view.doc == doc)
74
78
                return;
75
79
 
76
80
            if (current_view != null)
83
87
                    break;
84
88
                }
85
89
            }
 
90
 
86
91
            if (view == null && doc.file != null) {
87
92
                if (doc.get_mime_type () == "text/x-vala") {
88
93
                    view = new ValaSymbolOutline (doc);
108
113
                remove_container ();
109
114
            }
110
115
        }
111
 
        
 
116
 
112
117
        void add_container () {
113
118
            if(notebook.page_num (container) == -1) {
114
119
                notebook.append_page (container, new Gtk.Label (_("Symbols")));
115
120
                container.show_all ();
116
121
            }
117
122
        }
118
 
        
 
123
 
119
124
        void remove_container () {
120
125
            if (notebook.page_num (container) != -1)
121
126
                notebook.remove (container);
122
127
        }
123
 
        
124
 
        void on_hook_split_view (Scratch.Widgets.SplitView view) {
125
 
            view.welcome_shown.connect (() => {
126
 
                remove_container ();
127
 
            });
128
 
            view.welcome_hidden.connect (() => {
129
 
                add_container ();
130
 
            });
131
 
        }
132
 
        
 
128
 
133
129
        void update_timeout () {
134
130
            if (refresh_timeout != 0)
135
131
                Source.remove (refresh_timeout);
163
159
[ModuleInit]
164
160
public void peas_register_types (GLib.TypeModule module)
165
161
{
166
 
  var objmodule = module as Peas.ObjectModule;
167
 
  objmodule.register_extension_type (typeof (Peas.Activatable), typeof (Scratch.Plugins.OutlinePlugin));
168
 
}
 
 
b'\\ No newline at end of file'
 
162
    var objmodule = module as Peas.ObjectModule;
 
163
    objmodule.register_extension_type (typeof (Peas.Activatable), typeof (Scratch.Plugins.OutlinePlugin));
 
164
}