35
35
public class OutlinePlugin : Peas.ExtensionBase, Peas.Activatable {
36
36
public Object object { owned get; construct; }
38
Gtk.ToggleToolButton? tool_button = null;
38
//Gtk.ToggleToolButton? tool_button = null;
39
39
Scratch.Services.Interface scratch_interface;
40
40
SymbolOutline? current_view = null;
41
41
Gtk.EventBox? container = null;
51
51
scratch_interface.hook_document.connect (on_hook_document);
53
scratch_interface.hook_split_view.connect (on_hook_split_view);
55
scratch_interface.hook_notebook_context.connect (on_hook_context);
57
scratch_interface.hook_toolbar.connect (on_hook_toolbar);
53
scratch_interface.hook_notebook_sidebar.connect (on_hook_sidebar);
59
55
views = new Gee.LinkedList<SymbolOutline> ();
62
58
public void deactivate () {
63
if (tool_button != null)
64
tool_button.destroy ();
66
59
container.destroy ();
69
62
public void update_state () {
72
void on_hook_toolbar (Scratch.Widgets.Toolbar toolbar) {
73
if (tool_button != null)
76
var icon = new Gtk.Image.from_icon_name ("error", Gtk.IconSize.LARGE_TOOLBAR);
77
tool_button = new Gtk.ToggleToolButton ();
78
tool_button.set_icon_widget (icon);
79
tool_button.tooltip_text = _("Show Ouline");
80
tool_button.toggled.connect (toggle_plugin_visibility);
82
tool_button.show_all ();
84
toolbar.pack_end (tool_button);
87
void toggle_plugin_visibility () {
88
if (tool_button.active) {
89
notebook.set_current_page (notebook.append_page (container, new Gtk.Label (_("Symbols"))));
90
tool_button.tooltip_text = _("Hide Outline");
92
notebook.remove (container);
93
tool_button.tooltip_text = _("Show Outline");
97
void on_hook_context (Gtk.Notebook notebook) {
65
void on_hook_sidebar (Gtk.Notebook notebook) {
98
66
if (container != null)
100
68
if (this.notebook == null)
101
69
this.notebook = notebook;
103
this.notebook.switch_page.connect ((page, page_num) => {
104
if(tool_button.active != (container == page))
105
tool_button.active = (container == page);
108
71
container = new Gtk.EventBox ();
109
72
container.visible = false;
110
if (this.notebook == null)
73
if (this.notebook != null)
111
74
notebook.append_page (container, new Gtk.Label (_("Symbols")));
163
127
notebook.remove (container);
166
void on_hook_split_view (Scratch.Widgets.SplitView view) {
167
this.tool_button.visible = ! view.is_empty ();
168
view.welcome_shown.connect (() => {
169
this.tool_button.visible = false;
171
view.welcome_hidden.connect (() => {
172
this.tool_button.visible = true;
176
130
void update_timeout () {
177
131
if (refresh_timeout != 0)
178
132
Source.remove (refresh_timeout);
207
161
public void peas_register_types (GLib.TypeModule module)
209
var objmodule = module as Peas.ObjectModule;
210
objmodule.register_extension_type (typeof (Peas.Activatable), typeof (Scratch.Plugins.OutlinePlugin));
163
var objmodule = module as Peas.ObjectModule;
164
objmodule.register_extension_type (typeof (Peas.Activatable), typeof (Scratch.Plugins.OutlinePlugin));