Port externaltools to libpeas/gsettings/pygi

parent 33bc0189
......@@ -423,6 +423,7 @@ plugins/checkupdate/org.gnome.gedit.plugins.checkupdate.gschema.xml.in
plugins/checkupdate/Makefile
plugins/externaltools/data/Makefile
plugins/externaltools/Makefile
plugins/externaltools/org.gnome.gedit.plugins.externaltools.gschema.xml.in
plugins/externaltools/scripts/Makefile
plugins/externaltools/tools/Makefile
plugins/docinfo/Makefile
......
......@@ -7,7 +7,12 @@ plugin_in_files = externaltools.plugin.desktop.in
plugin_DATA = $(plugin_in_files:.plugin.desktop.in=.plugin)
EXTRA_DIST = $(plugin_in_files)
gsettings_SCHEMAS = org.gnome.gedit.plugins.externaltools.gschema.xml
@INTLTOOL_XML_NOMERGE_RULE@
@GSETTINGS_RULES@
EXTRA_DIST = $(plugin_in_files) org.gnome.gedit.plugins.externaltools.gschema.xml.in.in
CLEANFILES = $(plugin_DATA)
DISTCLEANFILES = $(plugin_DATA)
......
<schemalist>
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gedit.plugins.externaltools" path="/org/gnome/gedit/plugins/externaltools/">
<key name="use-system-font" type="b">
<default>true</default>
<_summary>Whether to use the system font</_summary>
<_description>
If true, the external tools will use the desktop-global standard
font if it's monospace (and the most similar font it can
come up with otherwise).
</_description>
</key>
<key name="font" type="s">
<default>'Monospace 10'</default>
<_summary>Font</_summary>
<_description>
A Pango font name. Examples are "Sans 12" or "Monospace Bold 14".
</_description>
</key>
</schema>
</schemalist>
......@@ -16,11 +16,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
__all__ = ('ExternalToolsPlugin', 'ExternalToolsWindowHelper',
'Manager', 'OutputPanel', 'Capture', 'UniqueById')
__all__ = ('ExternalToolsPlugin', 'Manager', 'OutputPanel', 'Capture', 'UniqueById')
import gedit
import gtk
from gi.repository import GObject, Gtk, Gedit, PeasGtk
from manager import Manager
from library import ToolLibrary
from outputpanel import OutputPanel
......@@ -38,7 +36,7 @@ class ToolMenu(object):
self._menupath = menupath
self._merge_id = 0
self._action_group = gtk.ActionGroup("ExternalToolsPluginToolActions")
self._action_group = Gtk.ActionGroup("ExternalToolsPluginToolActions")
self._signals = []
self.update()
......@@ -62,31 +60,31 @@ class ToolMenu(object):
action.set_data(self.ACTION_HANDLER_DATA_KEY, None)
self._action_group.remove_action(action)
accelmap = gtk.accel_map_get()
accelmap = Gtk.AccelMap.get()
for s in self._signals:
accelmap.disconnect(s)
self._signals = []
def _insert_directory(self, directory, path):
manager = self._window.get_ui_manager()
ui_manager = self._window.get_ui_manager()
for item in directory.subdirs:
action_name = 'ExternalToolDirectory%X' % id(item)
action = gtk.Action(action_name, item.name.replace('_', '__'), None, None)
action = Gtk.Action(action_name, item.name.replace('_', '__'), None, None)
self._action_group.add_action(action)
manager.add_ui(self._merge_id, path,
action_name, action_name,
gtk.UI_MANAGER_MENU, False)
ui_manager.add_ui(self._merge_id, path,
action_name, action_name,
Gtk.UIManagerItemType.MENU, False)
self._insert_directory(item, path + '/' + action_name)
for item in directory.tools:
action_name = 'ExternalToolTool%X' % id(item)
action = gtk.Action(action_name, item.name.replace('_', '__'), item.comment, None)
action = Gtk.Action(action_name, item.name.replace('_', '__'), item.comment, None)
handler = action.connect("activate", capture_menu_action, self._window, item)
action.set_data(self.ACTION_ITEM_DATA_KEY, item)
......@@ -96,19 +94,19 @@ class ToolMenu(object):
accelpath = '<Actions>/ExternalToolsPluginToolActions/%s' % (action_name, )
if item.shortcut:
key, mod = gtk.accelerator_parse(item.shortcut)
gtk.accel_map_change_entry(accelpath, key, mod, True)
self._signals.append(gtk.accel_map_get().connect('changed::%s' % (accelpath,), self.on_accelmap_changed, item))
key, mod = Gtk.accelerator_parse(item.shortcut)
Gtk.AccelMap.change_entry(accelpath, key, mod, True)
self._signals.append(Gtk.AccelMap.get().connect('changed::%s' % (accelpath,), self.on_accelmap_changed, item))
self._action_group.add_action_with_accel(action, item.shortcut)
manager.add_ui(self._merge_id, path,
action_name, action_name,
gtk.UI_MANAGER_MENUITEM, False)
ui_manager.add_ui(self._merge_id, path,
action_name, action_name,
Gtk.UIManagerItemType.MENUITEM, False)
def on_accelmap_changed(self, accelmap, path, key, mod, tool):
tool.shortcut = gtk.accelerator_name(key, mod)
tool.shortcut = Gtk.accelerator_name(key, mod)
tool.save()
self._window.get_data("ExternalToolsPluginWindowData").update_manager(tool)
......@@ -155,31 +153,32 @@ class ToolMenu(object):
if item is not None:
action.set_visible(states[item.applicability] and self.filter_language(language, item))
class ExternalToolsWindowHelper(object):
def __init__(self, plugin, window):
super(ExternalToolsWindowHelper, self).__init__()
class ExternalToolsPlugin(GObject.Object, Gedit.WindowActivatable, PeasGtk.Configurable):
__gtype_name__ = "ExternalToolsPlugin"
self._window = window
self._plugin = plugin
window = GObject.property(type=Gedit.Window)
def __init__(self):
GObject.Object.__init__(self)
self._manager = None
self._manager_default_size = None
def do_activate(self):
self._library = ToolLibrary()
self._library.set_locations(os.path.join(self.plugin_info.get_data_dir(), 'tools'))
manager = window.get_ui_manager()
ui_manager = self.window.get_ui_manager()
self._action_group = gtk.ActionGroup('ExternalToolsPluginActions')
self._action_group = Gtk.ActionGroup(name='ExternalToolsPluginActions')
self._action_group.set_translation_domain('gedit')
self._action_group.add_actions([('ExternalToolManager',
None,
_('Manage _External Tools...'),
None,
self._action_group.add_actions([('ExternalToolManager', None,
_('Manage _External Tools...'), None,
_("Opens the External Tools Manager"),
lambda action: plugin.open_dialog()),
('ExternalTools',
None,
_('External _Tools'),
None,
_("External tools"),
None)])
manager.insert_action_group(self._action_group, -1)
lambda action, data: self.open_dialog()),
('ExternalTools', None,
_('External _Tools'), None,
_("External tools"), None)])
ui_manager.insert_action_group(self._action_group, -1)
ui_string = """
<ui>
......@@ -199,72 +198,54 @@ class ExternalToolsWindowHelper(object):
</menubar>
</ui>"""
self._merge_id = manager.add_ui_from_string(ui_string)
self._merge_id = ui_manager.add_ui_from_string(ui_string)
self.menu = ToolMenu(self._library, self._window,
self.menu = ToolMenu(self._library, self.window,
"/MenuBar/ToolsMenu/ToolsOps_4/ExternalToolsMenu/ExternalToolPlaceholder")
manager.ensure_update()
ui_manager.ensure_update()
# Create output console
self._output_buffer = OutputPanel(self._plugin.get_data_dir(), window)
bottom = window.get_bottom_panel()
self._output_buffer = OutputPanel(self.plugin_info.get_data_dir(), self.window)
bottom = self.window.get_bottom_panel()
image = Gtk.Image(stock=Gtk.STOCK_EXECUTE, icon_size=Gtk.IconSize.MENU)
bottom.add_item(self._output_buffer.panel,
"GeditExternalToolsShellOutput",
_("Shell Output"),
gtk.STOCK_EXECUTE)
image)
def update_ui(self):
self.menu.filter(self._window.get_active_document())
self._window.get_ui_manager().ensure_update()
def do_update_state(self):
return
self.menu.filter(self.window.get_active_document())
self.window.get_ui_manager().ensure_update()
def deactivate(self):
manager = self._window.get_ui_manager()
def do_deactivate(self):
ui_manager = self.window.get_ui_manager()
self.menu.deactivate()
manager.remove_ui(self._merge_id)
manager.remove_action_group(self._action_group)
manager.ensure_update()
ui_manager.remove_ui(self._merge_id)
ui_manager.remove_action_group(self._action_group)
ui_manager.ensure_update()
bottom = self._window.get_bottom_panel()
bottom = self.window.get_bottom_panel()
bottom.remove_item(self._output_buffer.panel)
def update_manager(self, tool):
self._plugin.update_manager(tool)
class ExternalToolsPlugin(gedit.Plugin):
WINDOW_DATA_KEY = "ExternalToolsPluginWindowData"
def __init__(self):
super(ExternalToolsPlugin, self).__init__()
self._manager = None
self._manager_default_size = None
ToolLibrary().set_locations(os.path.join(self.get_data_dir(), 'tools'))
def activate(self, window):
helper = ExternalToolsWindowHelper(self, window)
window.set_data(self.WINDOW_DATA_KEY, helper)
def deactivate(self, window):
window.get_data(self.WINDOW_DATA_KEY).deactivate()
window.set_data(self.WINDOW_DATA_KEY, None)
def update_ui(self, window):
window.get_data(self.WINDOW_DATA_KEY).update_ui()
self.update_manager(tool)
def create_configure_dialog(self):
return self.open_dialog()
def do_create_configure_widget(self):
#FIXME
#return self.open_dialog()
pass
def open_dialog(self):
if not self._manager:
self._manager = Manager(self.get_data_dir())
self._manager = Manager(self.plugin_info.get_data_dir())
if self._manager_default_size:
self._manager.dialog.set_default_size(*self._manager_default_size)
self._manager.dialog.connect('destroy', self.on_manager_destroy)
window = gedit.app_get_default().get_active_window()
window = Gedit.App.get_default().get_active_window()
self._manager.run(window)
return self._manager.dialog
......@@ -276,7 +257,8 @@ class ExternalToolsPlugin(gedit.Plugin):
self._manager.tool_changed(tool, True)
def on_manager_destroy(self, dialog):
self._manager_default_size = [dialog.allocation.width, dialog.allocation.height]
alloc = dialog.get_allocation()
self._manager_default_size = [alloc.width, alloc.height]
self._manager = None
# ex:ts=4:et:
......@@ -21,11 +21,10 @@ __all__ = ('Capture', )
import os, sys, signal
import locale
import subprocess
import gobject
import fcntl
import glib
from gi.repository import GObject, GLib
class Capture(gobject.GObject):
class Capture(GObject.Object):
CAPTURE_STDOUT = 0x01
CAPTURE_STDERR = 0x02
CAPTURE_BOTH = 0x03
......@@ -34,14 +33,14 @@ class Capture(gobject.GObject):
WRITE_BUFFER_SIZE = 0x4000
__gsignals__ = {
'stdout-line' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)),
'stderr-line' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)),
'begin-execute': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, tuple()),
'end-execute' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_INT,))
'stdout-line' : (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, (GObject.TYPE_STRING,)),
'stderr-line' : (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, (GObject.TYPE_STRING,)),
'begin-execute': (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, tuple()),
'end-execute' : (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE, (GObject.TYPE_INT,))
}
def __init__(self, command, cwd = None, env = {}):
gobject.GObject.__init__(self)
GObject.GObject.__init__(self)
self.pipe = None
self.env = env
self.cwd = cwd
......@@ -101,8 +100,8 @@ class Capture(gobject.GObject):
flags = fcntl.fcntl(self.pipe.stdout.fileno(), fcntl.F_GETFL) | os.O_NONBLOCK
fcntl.fcntl(self.pipe.stdout.fileno(), fcntl.F_SETFL, flags)
gobject.io_add_watch(self.pipe.stdout,
gobject.IO_IN | gobject.IO_HUP,
GObject.io_add_watch(self.pipe.stdout,
GObject.IO_IN | GObject.IO_HUP,
self.on_output)
if self.flags & self.CAPTURE_STDERR:
......@@ -110,8 +109,8 @@ class Capture(gobject.GObject):
flags = fcntl.fcntl(self.pipe.stderr.fileno(), fcntl.F_GETFL) | os.O_NONBLOCK
fcntl.fcntl(self.pipe.stderr.fileno(), fcntl.F_SETFL, flags)
gobject.io_add_watch(self.pipe.stderr,
gobject.IO_IN | gobject.IO_HUP,
GObject.io_add_watch(self.pipe.stderr,
GObject.IO_IN | GObject.IO_HUP,
self.on_output)
# IO
......@@ -120,10 +119,10 @@ class Capture(gobject.GObject):
self.write_buffer = str(self.input_text)
if self.idle_write_chunk():
self.idle_write_id = gobject.idle_add(self.idle_write_chunk)
self.idle_write_id = GObject.idle_add(self.idle_write_chunk)
# Wait for the process to complete
gobject.child_watch_add(self.pipe.pid, self.on_child_end)
GObject.child_watch_add(self.pipe.pid, self.on_child_end)
def idle_write_chunk(self):
if not self.pipe:
......@@ -153,7 +152,7 @@ class Capture(gobject.GObject):
return False
def on_output(self, source, condition):
if condition & (glib.IO_IN | glib.IO_PRI):
if condition & (GLib.IO_IN | GLib.IO_PRI):
line = source.read()
if len(line) > 0:
......@@ -179,7 +178,7 @@ class Capture(gobject.GObject):
else:
self.emit('stderr-line', line)
if condition & ~(glib.IO_IN | glib.IO_PRI):
if condition & ~(GLib.IO_IN | GLib.IO_PRI):
if self.read_buffer:
if source == self.pipe.stdout:
self.emit('stdout-line', self.read_buffer)
......@@ -197,7 +196,7 @@ class Capture(gobject.GObject):
def stop(self, error_code = -1):
if self.pipe is not None:
if self.idle_write_id:
gobject.source_remove(self.idle_write_id)
GObject.source_remove(self.idle_write_id)
self.idle_write_id = 0
if not self.tried_killing:
......@@ -209,6 +208,6 @@ class Capture(gobject.GObject):
def on_child_end(self, pid, error_code):
# In an idle, so it is emitted after all the std*-line signals
# have been intercepted
gobject.idle_add(self.emit, 'end-execute', error_code)
GObject.idle_add(self.emit, 'end-execute', error_code)
# ex:ts=4:et:
......@@ -17,8 +17,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import os
import gio
import gedit
from gi.repository import Gio, Gedit
class FileLookup:
"""
......@@ -110,7 +109,7 @@ class OpenDocumentRelPathFileLookupProvider(FileLookupProvider):
if path.startswith('/'):
return None
for doc in gedit.app_get_default().get_documents():
for doc in Gedit.app_get_default().get_documents():
if doc.is_local():
location = doc.get_location()
if location:
......@@ -135,7 +134,7 @@ class OpenDocumentFileLookupProvider(FileLookupProvider):
if path.startswith('/'):
return None
for doc in gedit.app_get_default().get_documents():
for doc in Gedit.app_get_default().get_documents():
if doc.is_local():
location = doc.get_location()
if location and location.get_uri().endswith(path):
......
......@@ -17,11 +17,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import os
import gtk
from gtk import gdk
import gio
import gedit
#import gtksourceview
from gi.repository import Gio, Gtk, Gdk, Gedit
from outputpanel import OutputPanel
from capture import *
......@@ -92,7 +88,7 @@ def run_external_tool(window, node):
capture.set_env(GEDIT_CURRENT_DOCUMENT_URI = location.get_uri(),
GEDIT_CURRENT_DOCUMENT_NAME = name,
GEDIT_CURRENT_DOCUMENT_SCHEME = scheme)
if gedit.utils.location_has_file_scheme(location):
if Gedit.utils.location_has_file_scheme(location):
path = location.get_path()
cwd = os.path.dirname(path)
capture.set_cwd(cwd)
......@@ -107,7 +103,7 @@ def run_external_tool(window, node):
if location.get_uri() is not None]
documents_path = [location.get_path()
for location in documents_location
if gedit.utils.location_has_file_scheme(location)]
if Gedit.utils.location_has_file_scheme(location)]
capture.set_env(GEDIT_DOCUMENTS_URI = ' '.join(documents_uri),
GEDIT_DOCUMENTS_PATH = ' '.join(documents_path))
......@@ -226,7 +222,7 @@ class MultipleDocumentsSaver:
for doc in docs:
signals[doc] = doc.connect('saving', self.on_document_saving)
gedit.commands.save_document(window, doc)
Gedit.commands.save_document(window, doc)
doc.disconnect(signals[doc])
def on_document_saving(self, doc, size, total_size):
......@@ -262,7 +258,7 @@ def capture_stderr_line_panel(capture, line, panel):
panel.write(line, panel.error_tag)
def capture_begin_execute_panel(capture, panel, view, label):
view.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor(gdk.Cursor(gdk.WATCH))
view.get_window(Gtk.TextWindowType.TEXT).set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH))
panel['stop'].set_sensitive(True)
panel.clear()
......@@ -279,8 +275,8 @@ def capture_end_execute_panel(capture, exit_code, panel, view, output_type):
end.forward_chars(300)
uri = ''
mtype = gio.content_type_guess(data=doc.get_text(start, end))
lmanager = gedit.get_language_manager()
mtype = Gio.content_type_guess(data=doc.get_text(start, end))
lmanager = Gedit.get_language_manager()
location = doc.get_location()
if location:
......@@ -290,7 +286,7 @@ def capture_end_execute_panel(capture, exit_code, panel, view, output_type):
if language is not None:
doc.set_language(language)
view.get_window(gtk.TEXT_WINDOW_TEXT).set_cursor(gdk.Cursor(gdk.XTERM))
view.get_window(Gtk.TEXT_WINDOW_TEXT).set_cursor(Gdk.Cursor(Gdk.CursorType.XTERM))
view.set_cursor_visible(True)
view.set_editable(True)
......
......@@ -41,7 +41,7 @@ class ToolLibrary(Singleton):
if platform.platform() != 'Windows':
for d in self.get_xdg_data_dirs():
self.locations.append(os.path.join(d, 'gedit-2', 'plugins', 'externaltools', 'tools'))
self.locations.append(os.path.join(d, 'gedit', 'plugins', 'externaltools', 'tools'))
self.locations.append(datadir)
......@@ -53,7 +53,7 @@ class ToolLibrary(Singleton):
if userdir:
toolsdir = os.path.join(userdir, 'gedit/tools')
else:
toolsdir = os.path.expanduser('~/.gnome2/gedit/tools')
toolsdir = os.path.expanduser('~/.config/gedit/tools')
self.locations.insert(0, toolsdir);
......@@ -82,7 +82,7 @@ class ToolLibrary(Singleton):
if userdir:
filename = os.path.join(userdir, 'gedit/gedit-tools.xml')
else:
filename = os.path.expanduser('~/.gnome2/gedit/gedit-tools.xml')
filename = os.path.expanduser('~/.config/gedit/gedit-tools.xml')
if not os.path.isfile(filename):
return
......
......@@ -18,24 +18,23 @@
__all__ = ('Manager', )
import gedit
import gtk
import gtksourceview2 as gsv
import os.path
from library import *
from functions import *
import hashlib
from xml.sax import saxutils
import gobject
from gi.repository import GObject, Gtk, GtkSource, Gedit
class LanguagesPopup(Gtk.Window):
__gtype_name__ = "LanguagePopup"
class LanguagesPopup(gtk.Window):
COLUMN_NAME = 0
COLUMN_ID = 1
COLUMN_ENABLED = 2
def __init__(self, languages):
gtk.Window.__init__(self, gtk.WINDOW_POPUP)
Gtk.Window.__init__(self, type=Gtk.WindowType.POPUP)
self.set_default_size(200, 200)
self.props.can_focus = True
......@@ -47,40 +46,40 @@ class LanguagesPopup(gtk.Window):
self.grab_add()
gtk.gdk.keyboard_grab(self.window, False, 0L)
gtk.gdk.pointer_grab(self.window, False, gtk.gdk.BUTTON_PRESS_MASK |
gtk.gdk.BUTTON_RELEASE_MASK |
gtk.gdk.POINTER_MOTION_MASK |
gtk.gdk.ENTER_NOTIFY_MASK |
gtk.gdk.LEAVE_NOTIFY_MASK |
gtk.gdk.PROXIMITY_IN_MASK |
gtk.gdk.PROXIMITY_OUT_MASK, None, None, 0L)
Gdk.keyboard_grab(self.window, False, 0L)
Gdk.pointer_grab(self.window, False, Gdk.BUTTON_PRESS_MASK |
Gdk.BUTTON_RELEASE_MASK |
Gdk.POINTER_MOTION_MASK |
Gdk.ENTER_NOTIFY_MASK |
Gdk.LEAVE_NOTIFY_MASK |
Gdk.PROXIMITY_IN_MASK |
Gdk.PROXIMITY_OUT_MASK, None, None, 0L)
self.view.get_selection().select_path((0,))
def build(self):
self.model = gtk.ListStore(str, str, bool)
self.model = Gtk.ListStore(str, str, bool)
self.sw = gtk.ScrolledWindow()
self.sw = Gtk.ScrolledWindow()
self.sw.show()
self.sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self.sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
self.sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self.sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
self.view = gtk.TreeView(self.model)
self.view = Gtk.TreeView(self.model)
self.view.show()
self.view.set_headers_visible(False)
column = gtk.TreeViewColumn()
column = Gtk.TreeViewColumn()
renderer = gtk.CellRendererToggle()
renderer = Gtk.CellRendererToggle()
column.pack_start(renderer, False)
column.set_attributes(renderer, active=self.COLUMN_ENABLED)
renderer.connect('toggled', self.on_language_toggled)
renderer = gtk.CellRendererText()
renderer = Gtk.CellRendererText()
column.pack_start(renderer, True)
column.set_attributes(renderer, text=self.COLUMN_NAME)
......@@ -113,7 +112,7 @@ class LanguagesPopup(gtk.Window):
return val == '-'
def init_languages(self, languages):
manager = gsv.LanguageManager()
manager = GtkSource.LanguageManager()
langs = gedit.language_manager_list_languages_sorted(manager, True)
self.model.append([_('All languages'), None, not languages])
......@@ -142,7 +141,7 @@ class LanguagesPopup(gtk.Window):
self.model.set_value(self.model.get_iter_first(), self.COLUMN_ENABLED, False)
def do_key_press_event(self, event):
if event.keyval == gtk.keysyms.Escape:
if event.keyval == Gtk.keysyms.Escape:
self.destroy()
return True
else:
......@@ -166,10 +165,10 @@ class LanguagesPopup(gtk.Window):
event.y_root <= origin[1] + geometry[3]
def do_destroy(self):
gtk.gdk.keyboard_ungrab(0L)
gtk.gdk.pointer_ungrab(0L)
Gdk.keyboard_ungrab(0L)
Gdk.pointer_ungrab(0L)
return gtk.Window.do_destroy(self)
return Gtk.Window.do_destroy(self)
def setup_event(self, event, window):
fr = event.window.get_origin()
......@@ -182,7 +181,7 @@ class LanguagesPopup(gtk.Window):
def resolve_widgets(self, root):
res = [root]
if isinstance(root, gtk.Container):
if isinstance(root, Gtk.Container):
root.forall(lambda x, y: res.extend(self.resolve_widgets(x)), None)
return res
......@@ -210,7 +209,7 @@ class LanguagesPopup(gtk.Window):
if not (window.get_events() & event.type):
continue
if self.in_window(event, window):
if self.in_window(event, window):
self.setup_event(event, window)
if widget.event(event):
......@@ -248,8 +247,6 @@ class LanguagesPopup(gtk.Window):
def do_proximity_out_event(self, event):
return self.propagate_mouse_event(event)
gobject.type_register(LanguagesPopup)
class Manager:
TOOL_COLUMN = 0 # For Tree
NAME_COLUMN = 1 # For Combo
......@@ -275,7 +272,7 @@ class Manager:
}
# Load the "main-window" widget from the ui file.
self.ui = gtk.Builder()
self.ui = Gtk.Builder()
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')
......@@ -345,7 +342,7 @@ class Manager:
del self.accelerators[shortcut]
def add_tool_to_language(self, tool, language):
if isinstance(language, gsv.Language):
if isinstance(language, GtkSource.Language):
lid = language.get_id()
else:
lid = language
......@@ -353,7 +350,7 @@ class Manager:
if not lid in self._languages:
piter = self.model.append(None, [language])
parent = gtk.TreeRowReference(self.model, self.model.get_path(piter))
parent = Gtk.TreeRowReference.new(self.model, self.model.get_path(piter))
self._languages[lid] = parent
else:
parent = self._languages[lid]
......@@ -364,11 +361,11 @@ class Manager:
if not tool in self._tool_rows:
self._tool_rows[tool] = []
self._tool_rows[tool].append(gtk.TreeRowReference(self.model, self.model.get_path(child)))
self._tool_rows[tool].append(Gtk.TreeRowReference.new(self.model, self.model.get_path(child)))
return child
def add_tool(self, tool):
manager = gsv.LanguageManager()
manager = GtkSource.LanguageManager()
ret = None
for lang in tool.languages:
......@@ -391,16 +388,16 @@ class Manager:
self.script_hash = None