gedit r6782 - in trunk: . plugins/externaltools plugins/externaltools/data plugins/externaltools/tools plugins/snippets plugins/snippets/data plugins/snippets/data/lang plugins/snippets/snippets
- From: jessevdk svn gnome org
- To: svn-commits-list gnome org
- Subject: gedit r6782 - in trunk: . plugins/externaltools plugins/externaltools/data plugins/externaltools/tools plugins/snippets plugins/snippets/data plugins/snippets/data/lang plugins/snippets/snippets
- Date: Thu, 1 Jan 2009 18:37:41 +0000 (UTC)
Author: jessevdk
Date: Thu Jan 1 18:37:40 2009
New Revision: 6782
URL: http://svn.gnome.org/viewvc/gedit?rev=6782&view=rev
Log:
* configure.ac:
* plugins/externaltools:
* plugins/snippets:
Added GEDIT_PLUGINS_LIB_DIR and GEDIT_PLUGINS_DATA_DIR to configure.ac
to be used in Makefile.am of plugins. Fixed loading ui files using
plugin.get_data_dir() for snippets and tools. Fixed data dirs for
win32 in snippets and externaltools. Added remembering dialog size
for snippets and tools. Changed showing error in snippets by using
icons instead of color changes (for usability, fixes: #352945)
Modified:
trunk/ChangeLog
trunk/plugins/externaltools/Makefile.am
trunk/plugins/externaltools/data/Makefile.am
trunk/plugins/externaltools/tools/Makefile.am
trunk/plugins/externaltools/tools/__init__.py
trunk/plugins/externaltools/tools/library.py
trunk/plugins/externaltools/tools/manager.py
trunk/plugins/externaltools/tools/outputpanel.py
trunk/plugins/externaltools/tools/tools.ui
trunk/plugins/snippets/Makefile.am
trunk/plugins/snippets/data/Makefile.am
trunk/plugins/snippets/data/lang/Makefile.am
trunk/plugins/snippets/snippets/Makefile.am
trunk/plugins/snippets/snippets/Manager.py
trunk/plugins/snippets/snippets/__init__.py
trunk/plugins/snippets/snippets/snippets.ui
Modified: trunk/plugins/externaltools/Makefile.am
==============================================================================
--- trunk/plugins/externaltools/Makefile.am (original)
+++ trunk/plugins/externaltools/Makefile.am Thu Jan 1 18:37:40 2009
@@ -1,6 +1,6 @@
# External Tools plugin
SUBDIRS = tools data scripts
-plugindir = $(libdir)/gedit-2/plugins
+plugindir = $(GEDIT_PLUGINS_LIB_DIR)
plugin_in_files = externaltools.gedit-plugin.desktop.in
%.gedit-plugin: %.gedit-plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
Modified: trunk/plugins/externaltools/data/Makefile.am
==============================================================================
--- trunk/plugins/externaltools/data/Makefile.am (original)
+++ trunk/plugins/externaltools/data/Makefile.am Thu Jan 1 18:37:40 2009
@@ -9,7 +9,7 @@
desktop_in_files = $(tools_in_files:.tool.in=.desktop.in)
desktop_files = $(tools_in_files:.tool.in=.desktop)
tools_SCRIPTS = $(tools_in_files:.tool.in=)
-toolsdir = $(datadir)/gedit-2/plugins/tools
+toolsdir = $(GEDIT_PLUGINS_DATA_DIR)/tools
@INTLTOOL_DESKTOP_RULE@
Modified: trunk/plugins/externaltools/tools/Makefile.am
==============================================================================
--- trunk/plugins/externaltools/tools/Makefile.am (original)
+++ trunk/plugins/externaltools/tools/Makefile.am Thu Jan 1 18:37:40 2009
@@ -1,5 +1,6 @@
# Python snippets plugin
+plugindir = $(GEDIT_PLUGINS_LIB_DIR)/externaltools
plugin_PYTHON = \
__init__.py \
capture.py \
@@ -9,12 +10,11 @@
manager.py \
outputpanel.py
-plugin_DATA = tools.ui \
+uidir = $(GEDIT_PLUGINS_DATA_DIR)/externaltools/ui
+ui_DATA = tools.ui \
outputpanel.ui
-plugindir = $(libdir)/gedit-2/plugins/externaltools
-
-EXTRA_DIST = $(plugin_DATA)
+EXTRA_DIST = $(ui_DATA)
CLEANFILES = *.bak *.gladep
DISTCLEANFILES = *.bak *.gladep
Modified: trunk/plugins/externaltools/tools/__init__.py
==============================================================================
--- trunk/plugins/externaltools/tools/__init__.py (original)
+++ trunk/plugins/externaltools/tools/__init__.py Thu Jan 1 18:37:40 2009
@@ -152,7 +152,7 @@
manager.ensure_update()
# Create output console
- self._output_buffer = OutputPanel(window)
+ self._output_buffer = OutputPanel(self._plugin.get_data_dir(), window)
bottom = window.get_bottom_panel()
bottom.add_item(self._output_buffer.panel,
_("Shell Output"),
@@ -177,6 +177,8 @@
def __init__(self):
super(ExternalToolsPlugin, self).__init__()
+
+ ToolLibrary().set_locations(self.get_data_dir())
def activate(self, window):
helper = ExternalToolsWindowHelper(self, window)
@@ -193,10 +195,13 @@
return self.open_dialog()
def open_dialog(self):
- tm = Manager().dialog
+ m = Manager(self.get_data_dir())
+
+ m.run()
window = gedit.app_get_default().get_active_window()
if window:
- tm.set_transient_for(window)
- return tm
+ m.dialog.set_transient_for(window)
+
+ return m.dialog
# ex:ts=4:et:
Modified: trunk/plugins/externaltools/tools/library.py
==============================================================================
--- trunk/plugins/externaltools/tools/library.py (original)
+++ trunk/plugins/externaltools/tools/library.py Thu Jan 1 18:37:40 2009
@@ -19,21 +19,38 @@
import os
import re
import locale
+import platform
-class ToolLibrary(object):
+class Singleton(object):
_instance = None
- def __new__(cls):
- if cls._instance is None:
- cls._instance = object.__new__(cls)
+ def __new__(cls, *args, **kwargs):
+ if not cls._instance:
+ cls._instance = super(Singleton, cls).__new__(
+ cls, *args, **kwargs)
+ cls._instance.__init_once__()
+
return cls._instance
- def __init__(self):
- self.locations = [os.path.join(d, 'gedit-2/plugins/tools')
- for d in self.get_xdg_data_dirs()]
+class ToolLibrary(Singleton):
+ def __init_once__(self):
+ self.locations = []
+
+ def set_locations(self, datadir):
+ self.locations = []
+
+ if platform.platform() != 'Windows':
+ for d in self.get_xdg_data_dirs():
+ self.locations.append(os.path.join(d, 'gedit-2/plugins/tools'))
+
+ self.locations.append(datadir)
# self.locations[0] is where we save the custom scripts
- self.locations.insert(0, os.path.expanduser('~/.gnome2/gedit/tools'))
+ if platform.platform() == 'Windows':
+ self.locations.insert(0, os.path.expanduser('~/gedit/tools'))
+ else:
+ self.locations.insert(0, os.path.expanduser('~/.gnome2/gedit/tools'))
+
if not os.path.isdir(self.locations[0]):
os.makedirs(self.locations[0])
self.tree = ToolDirectory(self, '')
Modified: trunk/plugins/externaltools/tools/manager.py
==============================================================================
--- trunk/plugins/externaltools/tools/manager.py (original)
+++ trunk/plugins/externaltools/tools/manager.py Thu Jan 1 18:37:40 2009
@@ -26,23 +26,30 @@
from functions import *
import hashlib
-class Manager(object):
- UI_FILE = os.path.join(os.path.dirname(__file__), "tools.ui")
+class Singleton(object):
+ _instance = None
+
+ def __new__(cls, *args, **kwargs):
+ if not cls._instance:
+ cls._instance = super(Singleton, cls).__new__(
+ cls, *args, **kwargs)
+ cls._instance.__init_once__()
+ return cls._instance
+
+class Manager(Singleton):
LABEL_COLUMN = 0 # For Combo and Tree
NODE_COLUMN = 1 # For Tree only
NAME_COLUMN = 1 # For Combo only
- __shared_state = None
+ def __init__(self, datadir):
+ self.datadir = datadir
- _instance = None
-
- def __new__(cls):
- if cls._instance is None:
- cls._instance = object.__new__(cls)
- return cls._instance
-
- def __init__(self):
+ def __init_once__(self):
+ self.default_size = None
+ self.dialog = None
+
+ def build(self):
callbacks = {
'on_new_tool_button_clicked' : self.on_new_tool_button_clicked,
'on_remove_tool_button_clicked' : self.on_remove_tool_button_clicked,
@@ -55,16 +62,26 @@
# Load the "main-window" widget from the ui file.
self.ui = gtk.Builder()
- self.ui.add_from_file(self.UI_FILE)
+ self.ui.add_from_file(os.path.join(self.datadir, 'ui', 'tools.ui'))
self.ui.connect_signals(callbacks)
self.dialog = self.ui.get_object('tool-manager-dialog')
+
+ if self.default_size != None:
+ self.dialog.set_default_size(*self.default_size)
+
self.view = self.ui.get_object('view')
for name in ['input', 'output', 'applicability']:
self.__init_combobox(name)
self.__init_tools_model()
self.__init_tools_view()
- self.dialog.show()
-
+
+ def run(self):
+ if self.dialog == None:
+ self.build()
+ self.dialog.show()
+ else:
+ self.dialog.present()
+
def __init_tools_model(self):
self.tools = ToolLibrary()
self.current_node = None
@@ -329,7 +346,8 @@
return
self.on_tool_manager_dialog_focus_out(dialog, None)
-
+ self.default_size = [self.dialog.allocation.width, self.dialog.allocation.height]
+
self.dialog.destroy()
self.dialog = None
self.tools = None
Modified: trunk/plugins/externaltools/tools/outputpanel.py
==============================================================================
--- trunk/plugins/externaltools/tools/outputpanel.py (original)
+++ trunk/plugins/externaltools/tools/outputpanel.py Thu Jan 1 18:37:40 2009
@@ -25,8 +25,6 @@
from weakref import WeakKeyDictionary
from capture import *
-UI_FILE = os.path.join(os.path.dirname(__file__), "outputpanel.ui")
-
class UniqueById:
__shared_state = WeakKeyDictionary()
@@ -42,7 +40,7 @@
return self.__class__.__shared_state
class OutputPanel(UniqueById):
- def __init__(self, window):
+ def __init__(self, datadir, window):
if UniqueById.__init__(self, window):
return
@@ -52,7 +50,7 @@
self.window = window
self.ui = gtk.Builder()
- self.ui.add_from_file(UI_FILE)
+ self.ui.add_from_file(os.path.join(datadir, 'ui', 'outputpanel.ui'))
self.ui.connect_signals(callbacks)
self.panel = self["output-panel"]
Modified: trunk/plugins/externaltools/tools/tools.ui
==============================================================================
--- trunk/plugins/externaltools/tools/tools.ui (original)
+++ trunk/plugins/externaltools/tools/tools.ui Thu Jan 1 18:37:40 2009
@@ -113,8 +113,8 @@
<object class="GtkSourceBuffer" id="commands_buffer"/>
<object class="GtkDialog" id="tool-manager-dialog">
<property name="title" translatable="yes">External Tools Manager</property>
- <property name="default_width">400</property>
- <property name="default_height">300</property>
+ <property name="default_width">750</property>
+ <property name="default_height">500</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="skip_taskbar_hint">True</property>
<property name="has_separator">False</property>
Modified: trunk/plugins/snippets/Makefile.am
==============================================================================
--- trunk/plugins/snippets/Makefile.am (original)
+++ trunk/plugins/snippets/Makefile.am Thu Jan 1 18:37:40 2009
@@ -1,6 +1,6 @@
# Python snippets plugin
SUBDIRS = snippets data
-plugindir = $(libdir)/gedit-2/plugins
+plugindir = $(GEDIT_PLUGINS_LIB_DIR)
plugin_in_files = snippets.gedit-plugin.desktop.in
%.gedit-plugin: %.gedit-plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
Modified: trunk/plugins/snippets/data/Makefile.am
==============================================================================
--- trunk/plugins/snippets/data/Makefile.am (original)
+++ trunk/plugins/snippets/data/Makefile.am Thu Jan 1 18:37:40 2009
@@ -22,6 +22,6 @@
tcl.xml \
xml.xml
-snippetsdir = $(datadir)/gedit-2/plugins/snippets
+snippetsdir = $(GEDIT_PLUGINS_DATA_DIR)/snippets
-EXTRA_DIST = $(snippets_DATA) $(lang_DATA)
+EXTRA_DIST = $(snippets_DATA)
Modified: trunk/plugins/snippets/data/lang/Makefile.am
==============================================================================
--- trunk/plugins/snippets/data/lang/Makefile.am (original)
+++ trunk/plugins/snippets/data/lang/Makefile.am Thu Jan 1 18:37:40 2009
@@ -2,6 +2,6 @@
lang_DATA = \
snippets.lang
-langdir = $(datadir)/gedit-2/plugins/snippets/lang
+langdir = $(GEDIT_PLUGINS_DATA_DIR)/snippets/lang
EXTRA_DIST = $(lang_DATA)
Modified: trunk/plugins/snippets/snippets/Makefile.am
==============================================================================
--- trunk/plugins/snippets/snippets/Makefile.am (original)
+++ trunk/plugins/snippets/snippets/Makefile.am Thu Jan 1 18:37:40 2009
@@ -1,5 +1,5 @@
# Python snippets plugin
-plugindir = $(libdir)/gedit-2/plugins/snippets
+plugindir = $(GEDIT_PLUGINS_LIB_DIR)/snippets
plugin_PYTHON = \
__init__.py \
@@ -17,9 +17,10 @@
Importer.py \
Exporter.py
-plugin_DATA = snippets.ui
+uidir = $(GEDIT_PLUGINS_DATA_DIR)/snippets/ui
+ui_DATA = snippets.ui
-EXTRA_DIST = snippets.ui
+EXTRA_DIST = $(ui_DATA)
CLEANFILES = *.bak *.gladep *.pyc
DISTCLEANFILES = *.bak *.gladep *.pyc
Modified: trunk/plugins/snippets/snippets/Manager.py
==============================================================================
--- trunk/plugins/snippets/snippets/Manager.py (original)
+++ trunk/plugins/snippets/snippets/Manager.py Thu Jan 1 18:37:40 2009
@@ -46,12 +46,14 @@
dragging = False
dnd_target_list = [('text/uri-list', 0, TARGET_URI)]
- def __init__(self):
+ def __init__(self, datadir):
+ self.datadir = datadir
self.snippet = None
self.dlg = None
self._temp_export = None
self.snippets_doc = None
self.manager = None
+ self.default_size = None
self.key_press_id = 0
self.tooltips = gtk.Tooltips()
@@ -157,20 +159,25 @@
tree_view.expand_row(self.model.get_path(expand), False)
self.select_iter(expand)
- def get_cell_data_cb(self, column, cell, model, iter):
+ def get_cell_data_pixbuf_cb(self, column, cell, model, iter):
s = model.get_value(iter, self.OBJ_COLUMN)
snippet = isinstance(s, SnippetData)
- cell.set_property('editable', snippet)
-
if snippet and not s.valid:
- cell.set_property('foreground-gdk', gdk.color_parse('red'))
+ cell.set_property('stock-id', gtk.STOCK_DIALOG_ERROR)
else:
- cell.set_property('foreground-set', False)
+ cell.set_property('stock-id', None)
+
+ cell.set_property('xalign', 1.0)
- cell.set_property('markup', model.get_value(iter, self.NAME_COLUMN))
+ def get_cell_data_cb(self, column, cell, model, iter):
+ s = model.get_value(iter, self.OBJ_COLUMN)
+
+ snippet = isinstance(s, SnippetData)
+ cell.set_property('editable', snippet)
+ cell.set_property('markup', model.get_value(iter, self.NAME_COLUMN))
def on_tree_view_drag_data_get(self, widget, context, selection_data, info, time):
gfile = gio.File(self._temp_export)
@@ -256,10 +263,15 @@
self.tree_view = self['tree_view_snippets']
self.column = gtk.TreeViewColumn(None)
+
self.renderer = gtk.CellRendererText()
self.column.pack_start(self.renderer, False)
self.column.set_cell_data_func(self.renderer, self.get_cell_data_cb)
-
+
+ renderer = gtk.CellRendererPixbuf()
+ self.column.pack_start(renderer, True)
+ self.column.set_cell_data_func(renderer, self.get_cell_data_pixbuf_cb)
+
self.tree_view.append_column(self.column)
self.renderer.connect('edited', self.on_cell_edited)
@@ -285,7 +297,7 @@
def build(self):
self.builder = gtk.Builder()
- self.builder.add_from_file(os.path.dirname(__file__) + '/snippets.ui')
+ self.builder.add_from_file(os.path.join(self.datadir, 'ui', 'snippets.ui'))
handlers_dic = {
'on_dialog_snippets_response': self.on_dialog_snippets_response,
@@ -329,6 +341,9 @@
entry.drag_dest_set_target_list(lst)
self.dlg = self['dialog_snippets']
+
+ if self.default_size:
+ self.dlg.set_default_size(*self.default_size)
def __getitem__(self, key):
return self.builder.get_object(key)
@@ -432,7 +447,7 @@
def run(self):
if not self.dlg:
self.build()
- self.dlg.show_all()
+ self.dlg.show()
else:
self.build_model()
self.dlg.present()
@@ -599,6 +614,7 @@
if self.snippets_doc:
self.snippets_doc.stop()
+ self.default_size = [dlg.allocation.width, dlg.allocation.height]
self.manager = None
self.unref_languages()
@@ -664,16 +680,18 @@
text = entry.get_text()
if text and not Library().valid_tab_trigger(text):
- entry.modify_base(gtk.STATE_NORMAL, gtk.gdk.Color(0xffff, 0x6666, \
- 0x6666))
- entry.modify_text(gtk.STATE_NORMAL, gtk.gdk.Color(0xffff, 0xffff, \
- 0xffff))
+ img = self['image_tab_trigger']
+ img.set_from_stock(gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_BUTTON)
+ img.show()
- self.tooltips.set_tip(entry, _('This is not a valid tab trigger. Triggers can either contain letters or a single, non alphanumeric, character like {, [, etcetera.'))
+ #self['hbox_tab_trigger'].set_spacing(3)
+ tip = _('This is not a valid tab trigger. Triggers can either contain letters or a single, non alphanumeric, character like {, [, etcetera.')
+
+ self.tooltips.set_tip(entry, tip)
+ self.tooltips.set_tip(img, tip)
else:
- entry.modify_base(gtk.STATE_NORMAL, None)
- entry.modify_text(gtk.STATE_NORMAL, None)
-
+ self['image_tab_trigger'].hide()
+ #self['hbox_tab_trigger'].set_spacing(0)
self.tooltips.set_tip(entry, _('Single word with which the snippet is activated after pressing tab'))
return False
Modified: trunk/plugins/snippets/snippets/__init__.py
==============================================================================
--- trunk/plugins/snippets/snippets/__init__.py (original)
+++ trunk/plugins/snippets/snippets/__init__.py Thu Jan 1 18:37:40 2009
@@ -22,6 +22,7 @@
import gtk
from gtk import gdk
import gedit
+import platform
from WindowHelper import WindowHelper
from Library import Library
@@ -37,23 +38,29 @@
library = Library()
library.set_accelerator_callback(self.accelerator_activated)
- userdir = os.path.join(os.environ['HOME'], '.gnome2', 'gedit', 'snippets')
+ if platform.platform() == 'Windows':
+ userdir = os.path.expanduser('~/gedit/snippets')
+ else:
+ userdir = os.path.expanduser('~/.gnome2/gedit/snippets')
+
library.set_dirs(userdir, self.system_dirs())
def system_dirs(self):
- if 'XDG_DATA_DIRS' in os.environ:
- datadirs = os.environ['XDG_DATA_DIRS']
- else:
- datadirs = '/usr/local/share:/usr/share'
-
- dirs = []
-
- for d in datadirs.split(':'):
- d = os.path.join(d, 'gedit-2', 'plugins', 'snippets')
-
- if os.path.isdir(d):
- dirs.append(d)
+ if platform.platform() != 'Windows':
+ if 'XDG_DATA_DIRS' in os.environ:
+ datadirs = os.environ['XDG_DATA_DIRS']
+ else:
+ datadirs = '/usr/local/share:/usr/share'
+
+ dirs = []
+
+ for d in datadirs.split(':'):
+ d = os.path.join(d, 'gedit-2', 'plugins', 'snippets')
+
+ if os.path.isdir(d):
+ dirs.append(d)
+ dirs.append(self.get_data_dir())
return dirs
def activate(self, window):
@@ -70,7 +77,7 @@
def create_configure_dialog(self):
if not self.dlg:
- self.dlg = Manager()
+ self.dlg = Manager(self.get_data_dir())
else:
self.dlg.run()
Modified: trunk/plugins/snippets/snippets/snippets.ui
==============================================================================
--- trunk/plugins/snippets/snippets/snippets.ui (original)
+++ trunk/plugins/snippets/snippets/snippets.ui Thu Jan 1 18:37:40 2009
@@ -454,20 +454,39 @@
</packing>
</child>
<child>
- <object class="GtkEntry" id="entry_tab_trigger">
+ <object class="GtkHBox" id="hbox_tab_trigger">
<property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="tooltip-text" translatable="yes">Single word with which the snippet is activated after pressing tab</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="visibility">True</property>
- <property name="max_length">0</property>
- <property name="text" translatable="yes"/>
- <property name="has_frame">True</property>
- <property name="invisible_char">*</property>
- <property name="activates_default">False</property>
- <signal handler="on_entry_tab_trigger_focus_out" last_modification_time="Wed, 04 Jan 2006 14:07:29 GMT" name="focus_out_event"/>
- <signal handler="on_entry_tab_trigger_changed" last_modification_time="Fri, 28 Apr 2006 16:50:34 GMT" name="changed"/>
+ <child>
+ <object class="GtkEntry" id="entry_tab_trigger">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="tooltip-text" translatable="yes">Single word with which the snippet is activated after pressing tab</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="visibility">True</property>
+ <property name="max_length">0</property>
+ <property name="text" translatable="yes"/>
+ <property name="has_frame">True</property>
+ <property name="invisible_char">*</property>
+ <property name="activates_default">False</property>
+ <signal handler="on_entry_tab_trigger_focus_out" last_modification_time="Wed, 04 Jan 2006 14:07:29 GMT" name="focus_out_event"/>
+ <signal handler="on_entry_tab_trigger_changed" last_modification_time="Fri, 28 Apr 2006 16:50:34 GMT" name="changed"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkImage" id="image_tab_trigger">
+ <property name="visible">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ <property name="padding">3</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="left_attach">1</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]