diff options
author | Ignacio Casal Quinteiro <icq@gnome.org> | 2013-04-27 16:08:30 +0200 |
---|---|---|
committer | Ignacio Casal Quinteiro <icq@gnome.org> | 2013-04-27 16:24:29 +0200 |
commit | 2b68f97caf86741b19e66c3dbd2367caa19a7221 (patch) | |
tree | 814221196226fa25747e85f42a3f2e7df6c3ec7e | |
parent | d933fbd9bbfef4f6be8e0d970a06ee664e7bbb2f (diff) | |
download | gedit-wip/configurable.tar.gz |
snippets: use the new configurable extension pointwip/configurable
-rw-r--r-- | plugins/snippets/snippets/Makefile.am | 1 | ||||
-rw-r--r-- | plugins/snippets/snippets/__init__.py | 1 | ||||
-rw-r--r-- | plugins/snippets/snippets/configurable.py | 38 | ||||
-rw-r--r-- | plugins/snippets/snippets/manager.py | 15 | ||||
-rw-r--r-- | plugins/snippets/snippets/shareddata.py | 20 | ||||
-rw-r--r-- | plugins/snippets/snippets/snippets.ui | 614 | ||||
-rw-r--r-- | plugins/snippets/snippets/windowactivatable.py | 29 |
7 files changed, 315 insertions, 403 deletions
diff --git a/plugins/snippets/snippets/Makefile.am b/plugins/snippets/snippets/Makefile.am index f8f8dd59d..998cc4b0d 100644 --- a/plugins/snippets/snippets/Makefile.am +++ b/plugins/snippets/snippets/Makefile.am @@ -4,6 +4,7 @@ plugindir = $(GEDIT_PLUGINS_LIBS_DIR)/snippets plugin_PYTHON = \ __init__.py \ appactivatable.py \ + configurable.py \ windowactivatable.py \ document.py \ library.py \ diff --git a/plugins/snippets/snippets/__init__.py b/plugins/snippets/snippets/__init__.py index 305d4c844..1100a26d9 100644 --- a/plugins/snippets/snippets/__init__.py +++ b/plugins/snippets/snippets/__init__.py @@ -17,6 +17,7 @@ from .appactivatable import AppActivatable from .windowactivatable import WindowActivatable +from .configurable import Configurable from .document import Document # ex:ts=8:et: diff --git a/plugins/snippets/snippets/configurable.py b/plugins/snippets/snippets/configurable.py new file mode 100644 index 000000000..5d854cb6b --- /dev/null +++ b/plugins/snippets/snippets/configurable.py @@ -0,0 +1,38 @@ +# Gedit snippets plugin +# Copyright (C) 2005-2006 Jesse van den Kieboom <jesse@icecrew.nl> +# Copyright (C) 2013 Ignacio Casal Quinteiro <icq@gnome.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +import os +from gi.repository import Gtk, Gedit, GObject + +class Configurable(GObject.Object, Gedit.Configurable): + + def __init__(self): + GObject.Object.__init__(self) + + def do_get_page_id(self): + return "snippets" + + def do_get_page_name(self): + return _("Snippets") + + def do_create_configure_widget(self): + builder = Gtk.Builder() + builder.add_from_file(os.path.join(self.plugin_info.get_data_dir(), 'ui', 'snippets.ui')) + return builder.get_object('snippets_manager') + +# ex:ts=8:et: diff --git a/plugins/snippets/snippets/manager.py b/plugins/snippets/snippets/manager.py index 7ff73423c..8472329b8 100644 --- a/plugins/snippets/snippets/manager.py +++ b/plugins/snippets/snippets/manager.py @@ -29,7 +29,7 @@ from .exporter import * from .document import Document from .languagemanager import get_language_manager -class Manager(Gtk.Dialog, Gtk.Buildable): +class Manager(Gtk.Grid, Gtk.Buildable): NAME_COLUMN = 0 SORT_COLUMN = 1 LANG_COLUMN = 2 @@ -46,15 +46,11 @@ class Manager(Gtk.Dialog, Gtk.Buildable): def __init__(self): self.snippet = None self._temp_export = None - self._size = (0, 0) self.key_press_id = 0 self.dnd_target_list = Gtk.TargetList.new([]) self.dnd_target_list.add(Gdk.atom_intern("text/uri-list", True), 0, self.TARGET_URI) - def get_final_size(self): - return self._size - def get_language_snippets(self, path, name = None): library = Library() @@ -329,13 +325,6 @@ class Manager(Gtk.Dialog, Gtk.Buildable): lst = entry.drag_dest_get_target_list() lst.add_uri_targets(self.TARGET_URI) - def do_configure_event(self, event): - if self.get_realized(): - alloc = self.get_allocation() - self._size = (alloc.width, alloc.height) - - return Gtk.Dialog.do_configure_event(self, event) - def __getitem__(self, key): return self.builder.get_object(key) @@ -593,7 +582,7 @@ class Manager(Gtk.Dialog, Gtk.Buildable): # Callbacks def do_destroy(self): - Gtk.Dialog.do_destroy(self) + Gtk.Grid.do_destroy(self) if not self.model: return diff --git a/plugins/snippets/snippets/shareddata.py b/plugins/snippets/snippets/shareddata.py index f3268acea..44c4962aa 100644 --- a/plugins/snippets/snippets/shareddata.py +++ b/plugins/snippets/snippets/shareddata.py @@ -22,8 +22,6 @@ from gi.repository import Gtk class SharedData(object, metaclass=Singleton): def __init__(self): - self.dlg = None - self.dlg_default_size = None self.controller_registry = {} self.windows = {} @@ -59,22 +57,4 @@ class SharedData(object, metaclass=Singleton): else: return None - def manager_destroyed(self, dlg): - self.dlg_default_size = dlg.get_final_size() - self.dlg = None - - def show_manager(self, window, datadir): - if not self.dlg: - builder = Gtk.Builder() - builder.add_from_file(os.path.join(datadir, 'ui', 'snippets.ui')) - - self.dlg = builder.get_object('snippets_manager') - self.dlg.connect('destroy', self.manager_destroyed) - - if self.dlg_default_size: - self.dlg.set_default_size(self.dlg_default_size[0], self.dlg_default_size[1]) - - self.dlg.set_transient_for(window) - self.dlg.present() - # vi:ex:ts=4:et diff --git a/plugins/snippets/snippets/snippets.ui b/plugins/snippets/snippets/snippets.ui index a8327e047..347be3ecd 100644 --- a/plugins/snippets/snippets/snippets.ui +++ b/plugins/snippets/snippets/snippets.ui @@ -50,48 +50,152 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="border_width">5</property> - <property name="title" translatable="yes">Manage Snippets</property> - <property name="default_width">750</property> - <property name="default_height">500</property> - <property name="destroy_with_parent">True</property> - <property name="type_hint">dialog</property> - <property name="skip_taskbar_hint">True</property> - <child internal-child="vbox"> - <object class="GtkBox" id="dialog-vbox1"> + <child> + <object class="GtkHPaned" id="hpaned_paned"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="orientation">vertical</property> - <property name="spacing">2</property> - <child internal-child="action_area"> - <object class="GtkButtonBox" id="dialog-action_area1"> + <property name="can_focus">True</property> + <property name="border_width">6</property> + <property name="position">275</property> + <child> + <object class="GtkBox" id="vbox_selection"> + <property name="width_request">230</property> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="layout_style">end</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> <child> - <object class="GtkButton" id="closebutton1"> - <property name="label">gtk-close</property> + <object class="GtkLabel" id="label1"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="receives_default">False</property> - <property name="use_action_appearance">False</property> - <property name="use_stock">True</property> + <property name="can_focus">False</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">_Snippets:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">tree_view_snippets</property> </object> <packing> <property name="expand">False</property> - <property name="fill">True</property> + <property name="fill">False</property> <property name="position">0</property> </packing> </child> <child> - <object class="GtkButton" id="button1"> - <property name="label">gtk-help</property> + <object class="GtkBox" id="box2"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="receives_default">False</property> - <property name="use_action_appearance">False</property> - <property name="use_stock">True</property> + <property name="can_focus">False</property> + <property name="vexpand">True</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkScrolledWindow" id="scrolled_window_snippets"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="tree_view_snippets"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="headers_visible">False</property> + <signal name="row-expanded" handler="on_tree_view_snippets_row_expanded" swapped="no"/> + <signal name="key-press-event" handler="on_tree_view_snippets_key_press" swapped="no"/> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="treeview-selection"/> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkToolbar" id="toolbar"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="toolbar_style">icons</property> + <property name="icon_size">1</property> + <style> + <class name="inline-toolbar"/> + </style> + <child> + <object class="GtkToolButton" id="add_snippet_button"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="has_tooltip">True</property> + <property name="tooltip_markup" translatable="yes">Create new snippet</property> + <property name="tooltip_text" translatable="yes">Create new snippet</property> + <property name="related_action">add_snippet_action</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">Add Snippet</property> + <property name="use_underline">True</property> + <property name="icon_name">list-add-symbolic</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToolButton" id="remove_snippet_button"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="has_tooltip">True</property> + <property name="tooltip_markup" translatable="yes">Delete selected snippet</property> + <property name="tooltip_text" translatable="yes">Delete selected snippet</property> + <property name="related_action">remove_snippet_action</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">Remove Snippet</property> + <property name="use_underline">True</property> + <property name="icon_name">list-remove-symbolic</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToolButton" id="import_snippets_button"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="has_tooltip">True</property> + <property name="tooltip_markup" translatable="yes">Import snippets</property> + <property name="tooltip_text" translatable="yes">Import snippets</property> + <property name="related_action">import_snippets_action</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">Import Snippets</property> + <property name="use_underline">True</property> + <property name="icon_name">document-open-symbolic</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToolButton" id="export_snippets_button"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="has_tooltip">True</property> + <property name="tooltip_markup" translatable="yes">Export selected snippets</property> + <property name="tooltip_text" translatable="yes">Export selected snippets</property> + <property name="related_action">export_snippets_action</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">Export Snippets</property> + <property name="use_underline">True</property> + <property name="icon_name">document-save-as-symbolic</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> </object> <packing> <property name="expand">False</property> @@ -101,33 +205,29 @@ </child> </object> <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">end</property> - <property name="position">0</property> + <property name="resize">False</property> + <property name="shrink">False</property> </packing> </child> <child> - <object class="GtkHPaned" id="hpaned_paned"> + <object class="GtkBox" id="vbox_snippet"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="border_width">6</property> - <property name="position">275</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">12</property> <child> - <object class="GtkBox" id="vbox_selection"> - <property name="width_request">230</property> + <object class="GtkBox" id="vbox2"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="orientation">vertical</property> <property name="spacing">6</property> <child> - <object class="GtkLabel" id="label1"> + <object class="GtkLabel" id="label4"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="xalign">0</property> - <property name="label" translatable="yes">_Snippets:</property> + <property name="label" translatable="yes">_Edit:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">tree_view_snippets</property> </object> <packing> <property name="expand">False</property> @@ -136,204 +236,63 @@ </packing> </child> <child> - <object class="GtkBox" id="box2"> + <object class="GtkScrolledWindow" id="scrolled_window_snippet"> <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="vexpand">True</property> - <property name="orientation">vertical</property> + <property name="can_focus">True</property> + <property name="shadow_type">in</property> <child> - <object class="GtkScrolledWindow" id="scrolled_window_snippets"> + <object class="GeditView" id="source_view_snippet"> + <property name="buffer">source_buffer</property> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="shadow_type">in</property> - <child> - <object class="GtkTreeView" id="tree_view_snippets"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="headers_visible">False</property> - <signal name="row-expanded" handler="on_tree_view_snippets_row_expanded" swapped="no"/> - <signal name="key-press-event" handler="on_tree_view_snippets_key_press" swapped="no"/> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="treeview-selection"/> - </child> - </object> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkToolbar" id="toolbar"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="toolbar_style">icons</property> - <property name="icon_size">1</property> - <style> - <class name="inline-toolbar"/> - </style> - <child> - <object class="GtkToolButton" id="add_snippet_button"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="has_tooltip">True</property> - <property name="tooltip_markup" translatable="yes">Create new snippet</property> - <property name="tooltip_text" translatable="yes">Create new snippet</property> - <property name="related_action">add_snippet_action</property> - <property name="use_action_appearance">False</property> - <property name="label" translatable="yes">Add Snippet</property> - <property name="use_underline">True</property> - <property name="icon_name">list-add-symbolic</property> - </object> - <packing> - <property name="expand">False</property> - <property name="homogeneous">True</property> - </packing> - </child> - <child> - <object class="GtkToolButton" id="remove_snippet_button"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="has_tooltip">True</property> - <property name="tooltip_markup" translatable="yes">Delete selected snippet</property> - <property name="tooltip_text" translatable="yes">Delete selected snippet</property> - <property name="related_action">remove_snippet_action</property> - <property name="use_action_appearance">False</property> - <property name="label" translatable="yes">Remove Snippet</property> - <property name="use_underline">True</property> - <property name="icon_name">list-remove-symbolic</property> - </object> - <packing> - <property name="expand">False</property> - <property name="homogeneous">True</property> - </packing> - </child> - <child> - <object class="GtkToolButton" id="import_snippets_button"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="has_tooltip">True</property> - <property name="tooltip_markup" translatable="yes">Import snippets</property> - <property name="tooltip_text" translatable="yes">Import snippets</property> - <property name="related_action">import_snippets_action</property> - <property name="use_action_appearance">False</property> - <property name="label" translatable="yes">Import Snippets</property> - <property name="use_underline">True</property> - <property name="icon_name">document-open-symbolic</property> - </object> - <packing> - <property name="expand">False</property> - <property name="homogeneous">True</property> - </packing> - </child> - <child> - <object class="GtkToolButton" id="export_snippets_button"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="has_tooltip">True</property> - <property name="tooltip_markup" translatable="yes">Export selected snippets</property> - <property name="tooltip_text" translatable="yes">Export selected snippets</property> - <property name="related_action">export_snippets_action</property> - <property name="use_action_appearance">False</property> - <property name="label" translatable="yes">Export Snippets</property> - <property name="use_underline">True</property> - <property name="icon_name">document-save-as-symbolic</property> - </object> - <packing> - <property name="expand">False</property> - <property name="homogeneous">True</property> - </packing> - </child> + <signal handler="on_source_view_snippet_focus_out" name="focus_out_event"/> </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> </child> </object> <packing> - <property name="expand">False</property> + <property name="expand">True</property> <property name="fill">True</property> <property name="position">1</property> </packing> </child> </object> <packing> - <property name="resize">False</property> - <property name="shrink">False</property> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> </packing> </child> <child> - <object class="GtkBox" id="vbox_snippet"> + <object class="GtkBox" id="vbox1"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="orientation">vertical</property> - <property name="spacing">12</property> + <property name="spacing">6</property> <child> - <object class="GtkBox" id="vbox2"> + <object class="GtkLabel" id="label3"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - <child> - <object class="GtkLabel" id="label4"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Edit:</property> - <property name="use_underline">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkScrolledWindow" id="scrolled_window_snippet"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="shadow_type">in</property> - <child> - <object class="GeditView" id="source_view_snippet"> - <property name="buffer">source_buffer</property> - <property name="visible">True</property> - <signal handler="on_source_view_snippet_focus_out" name="focus_out_event"/> - </object> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> + <property name="xalign">0</property> + <property name="label" translatable="yes">Activation</property> + <property name="use_markup">True</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> </object> <packing> - <property name="expand">True</property> - <property name="fill">True</property> + <property name="expand">False</property> + <property name="fill">False</property> <property name="position">0</property> </packing> </child> <child> - <object class="GtkBox" id="vbox1"> + <object class="GtkBox" id="hbox1"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> <child> - <object class="GtkLabel" id="label3"> + <object class="GtkLabel" id="label2"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Activation</property> - <property name="use_markup">True</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> + <property name="label" translatable="yes"> </property> </object> <packing> <property name="expand">False</property> @@ -342,166 +301,143 @@ </packing> </child> <child> - <object class="GtkBox" id="hbox1"> + <object class="GtkGrid" id="grid1"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="row_spacing">6</property> + <property name="column_spacing">6</property> <child> - <object class="GtkLabel" id="label2"> + <object class="GtkLabel" id="label_tab_trigger"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="label" translatable="yes"> </property> + <property name="xalign">0</property> + <property name="label" translatable="yes" comments=""tab" here means the tab key, not the notebook tab!">_Tab trigger:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">entry_tab_trigger</property> </object> <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> <child> - <object class="GtkGrid" id="grid1"> + <object class="GtkBox" id="hbox_tab_trigger"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - <child> - <object class="GtkLabel" id="label_tab_trigger"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes" comments=""tab" here means the tab key, not the notebook tab!">_Tab trigger:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_tab_trigger</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> <child> - <object class="GtkBox" id="hbox_tab_trigger"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <child> - <object class="GtkEntry" id="entry_tab_trigger"> - <property name="visible">True</property> - <property name="sensitive">False</property> - <property name="can_focus">True</property> - <property name="tooltip_text" translatable="yes">Single word the snippet is activated with after pressing Tab</property> - <signal name="changed" handler="on_entry_tab_trigger_changed" swapped="no"/> - <signal name="focus-out-event" handler="on_entry_tab_trigger_focus_out" swapped="no"/> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkImage" id="image_tab_trigger"> - <property name="can_focus">False</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="padding">3</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_accelerator"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">S_hortcut key:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_accelerator</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_accelerator"> + <object class="GtkEntry" id="entry_tab_trigger"> <property name="visible">True</property> <property name="sensitive">False</property> <property name="can_focus">True</property> - <property name="tooltip_text" translatable="yes">Shortcut key with which the snippet is activated</property> - <property name="editable">False</property> - <signal name="key-press-event" handler="on_entry_accelerator_key_press" swapped="no"/> - <signal name="focus-out-event" handler="on_entry_accelerator_focus_out" swapped="no"/> - <signal name="focus-in-event" handler="on_entry_accelerator_focus_in" swapped="no"/> + <property name="tooltip_text" translatable="yes">Single word the snippet is activated with after pressing Tab</property> + <signal name="changed" handler="on_entry_tab_trigger_changed" swapped="no"/> + <signal name="focus-out-event" handler="on_entry_tab_trigger_focus_out" swapped="no"/> </object> <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> </packing> </child> <child> - <object class="GtkLabel" id="label_drop_targets"> - <property name="visible">True</property> + <object class="GtkImage" id="image_tab_trigger"> <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Drop targets:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_accelerator</property> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="padding">3</property> + <property name="position">1</property> </packing> </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label_accelerator"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">S_hortcut key:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">entry_accelerator</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="entry_accelerator"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="tooltip_text" translatable="yes">Shortcut key with which the snippet is activated</property> + <property name="editable">False</property> + <signal name="key-press-event" handler="on_entry_accelerator_key_press" swapped="no"/> + <signal name="focus-out-event" handler="on_entry_accelerator_focus_out" swapped="no"/> + <signal name="focus-in-event" handler="on_entry_accelerator_focus_in" swapped="no"/> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label_drop_targets"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">_Drop targets:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">entry_accelerator</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="combo_drop_targets"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="model">model1</property> + <property name="has_entry">True</property> <child> - <object class="GtkComboBox" id="combo_drop_targets"> - <property name="visible">True</property> + <object class="GtkCellRendererText" id="renderer1"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + <child internal-child="entry"> + <object class="GtkEntry" id="combobox-entry2"> <property name="can_focus">False</property> - <property name="model">model1</property> - <property name="has_entry">True</property> - <child> - <object class="GtkCellRendererText" id="renderer1"/> - <attributes> - <attribute name="text">0</attribute> - </attributes> - </child> - <child internal-child="entry"> - <object class="GtkEntry" id="combobox-entry2"> - <property name="can_focus">False</property> - </object> - </child> </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> </child> </object> <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + <property name="width">1</property> + <property name="height">1</property> </packing> </child> </object> <packing> - <property name="expand">False</property> + <property name="expand">True</property> <property name="fill">True</property> <property name="position">1</property> </packing> @@ -509,28 +445,24 @@ </object> <packing> <property name="expand">False</property> - <property name="fill">False</property> + <property name="fill">True</property> <property name="position">1</property> </packing> </child> </object> <packing> - <property name="resize">True</property> - <property name="shrink">True</property> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> </packing> </child> </object> <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> + <property name="resize">True</property> + <property name="shrink">True</property> </packing> </child> </object> </child> - <action-widgets> - <action-widget response="-7">closebutton1</action-widget> - <action-widget response="-11">button1</action-widget> - </action-widgets> </object> </interface> diff --git a/plugins/snippets/snippets/windowactivatable.py b/plugins/snippets/snippets/windowactivatable.py index d34e279d2..703e1e3b3 100644 --- a/plugins/snippets/snippets/windowactivatable.py +++ b/plugins/snippets/snippets/windowactivatable.py @@ -48,7 +48,6 @@ class WindowActivatable(GObject.Object, Gedit.WindowActivatable, Signals): self.current_language_accel_group = None def do_activate(self): - self.insert_menu() self.register_messages() library = Library() @@ -73,7 +72,6 @@ class WindowActivatable(GObject.Object, Gedit.WindowActivatable, Signals): self.accel_group = None - self.remove_menu() self.unregister_messages() library = Library() @@ -145,27 +143,6 @@ class WindowActivatable(GObject.Object, Gedit.WindowActivatable, Signals): controller.parse_and_run_snippet(message.props.snippet, iter) - def insert_menu(self): - manager = self.window.get_ui_manager() - - self.action_group = Gtk.ActionGroup("GeditSnippetPluginActions") - self.action_group.set_translation_domain('gedit') - self.action_group.add_actions([('ManageSnippets', None, - _('Manage _Snippets...'), \ - None, _('Manage snippets'), \ - self.on_action_snippets_activate)]) - - self.merge_id = manager.new_merge_id() - manager.insert_action_group(self.action_group, -1) - manager.add_ui(self.merge_id, '/MenuBar/ToolsMenu/ToolsOps_5', \ - 'ManageSnippets', 'ManageSnippets', Gtk.UIManagerItemType.MENUITEM, False) - - def remove_menu(self): - manager = self.window.get_ui_manager() - manager.remove_ui(self.merge_id) - manager.remove_action_group(self.action_group) - self.action_group = None - def find_snippet(self, snippets, tag): result = [] @@ -202,12 +179,6 @@ class WindowActivatable(GObject.Object, Gedit.WindowActivatable, Signals): self.update_language(SharedData().get_controller(tab.get_view())) # Callbacks - def create_configure_dialog(self): - SharedData().show_manager(self.window, self.plugin_info.get_data_dir()) - - def on_action_snippets_activate(self, action): - self.create_configure_dialog() - def accelerator_activated(self, group, obj, keyval, mod): if obj == self.window: controller = SharedData().get_active_controller(self.window) |