[d-feet/pygi] initial port to gi
- From: John Palmieri <johnp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [d-feet/pygi] initial port to gi
- Date: Mon, 20 Jun 2011 20:37:23 +0000 (UTC)
commit aa65bf360dc38b1006ca9e1f8d61d32bdf1ce035
Author: John (J5) Palmieri <johnp redhat com>
Date: Tue Mar 15 20:01:29 2011 -0400
initial port to gi
d-feet | 3 +-
dfeet/DFeetApp.py | 29 +++---
dfeet/_ui/addconnectiondialog.py | 2 +-
dfeet/_ui/busbox.py | 12 +-
dfeet/_ui/busnamebox.py | 10 +-
dfeet/_ui/busnameinfobox.py | 18 ++--
dfeet/_ui/busnameview.py | 44 ++++----
dfeet/_ui/executemethoddialog.py | 2 +-
dfeet/_ui/uiloader.py | 4 +-
dfeet/_ui/wnck_utils.py | 8 +-
dfeet/dbus_introspector.py | 233 +++++++++++++++-----------------------
dfeet/introspect_data.py | 6 +-
tests/uifile_tests.py | 16 ++--
13 files changed, 168 insertions(+), 219 deletions(-)
---
diff --git a/d-feet b/d-feet
index 8f6383f..8e85c5e 100755
--- a/d-feet
+++ b/d-feet
@@ -49,4 +49,5 @@ import dfeet.DFeetApp as DFeetApp
app = DFeetApp.DFeetApp()
if options.bus_address is not None:
app.select_or_add_bus(address=options.bus_address)
-DFeetApp.gtk.main()
+
+app.run()
diff --git a/dfeet/DFeetApp.py b/dfeet/DFeetApp.py
index 37afe47..6463592 100644
--- a/dfeet/DFeetApp.py
+++ b/dfeet/DFeetApp.py
@@ -1,7 +1,6 @@
import os
import sys
-import gtk
-import gobject
+from gi.repository import Gtk
import _ui
import _util
@@ -27,7 +26,7 @@ class DFeetApp:
'execute_method': self.execute_current_method_cb,
'quit': self.quit_cb}
- self.ICON_SIZE_CLOSE_BUTTON = gtk.icon_size_register('ICON_SIZE_CLOSE_BUTTON', 14, 14)
+ self.ICON_SIZE_CLOSE_BUTTON = Gtk.icon_size_register('ICON_SIZE_CLOSE_BUTTON', 14, 14)
settings = Settings.get_instance()
@@ -66,7 +65,7 @@ class DFeetApp:
def _load_addbus_history(self, settings):
self.add_bus_history = []
- self.combo_addbus_history_model = gtk.ListStore(str)
+ self.combo_addbus_history_model = Gtk.ListStore(str)
for bus_add in settings.general['addbus_list']:
if bus_add != '':
self.add_bus_history.append(bus_add)
@@ -77,16 +76,16 @@ class DFeetApp:
bus_paned.connect('introspectnode-selected',
self.introspect_node_selected_cb)
bus_paned.show_all()
- hbox = gtk.HBox()
- hbox.pack_start(gtk.Label(name), True, True)
- close_btn = gtk.Button()
- img = gtk.Image()
- img.set_from_stock(gtk.STOCK_CLOSE, self.ICON_SIZE_CLOSE_BUTTON)
+ hbox = Gtk.HBox()
+ hbox.pack_start(Gtk.Label(name), True, True, 0)
+ close_btn = Gtk.Button()
+ img = Gtk.Image()
+ img.set_from_stock(Gtk.STOCK_CLOSE, self.ICON_SIZE_CLOSE_BUTTON)
img.show()
close_btn.set_image(img)
- close_btn.set_relief(gtk.RELIEF_NONE)
+ close_btn.set_relief(Gtk.ReliefStyle.NONE)
close_btn.connect('clicked', self.close_tab_cb, bus_paned)
- hbox.pack_start(close_btn, False, False)
+ hbox.pack_start(close_btn, False, False, 0)
hbox.show_all()
if position:
@@ -226,8 +225,10 @@ class DFeetApp:
settings.write()
- gtk.main_quit()
+ Gtk.main_quit()
+
+ def run(self):
+ Gtk.main()
if __name__ == "__main__":
- DFeetApp()
- gtk.main()
+ DFeetApp().run()
diff --git a/dfeet/_ui/addconnectiondialog.py b/dfeet/_ui/addconnectiondialog.py
index af99ae9..4cecaf0 100644
--- a/dfeet/_ui/addconnectiondialog.py
+++ b/dfeet/_ui/addconnectiondialog.py
@@ -1,4 +1,4 @@
-import gtk
+from gi.repository import Gtk
from uiloader import UILoader
class AddConnectionDialog:
diff --git a/dfeet/_ui/busbox.py b/dfeet/_ui/busbox.py
index 7b52485..13ba36a 100644
--- a/dfeet/_ui/busbox.py
+++ b/dfeet/_ui/busbox.py
@@ -1,5 +1,5 @@
import gobject
-import gtk
+from gi.repository import Gtk
from dfeet import _util
@@ -7,7 +7,7 @@ from busnamebox import BusNameBox
from busnameinfobox import BusNameInfoBox
from uiloader import UILoader
-class BusBox(gtk.VBox):
+class BusBox(Gtk.VBox):
__gsignals__ = {
'introspectnode-selected': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_PYOBJECT,))
@@ -29,9 +29,9 @@ class BusBox(gtk.VBox):
filter_box = ui.get_root_widget()
filter_entry = ui.get_widget('filter_entry1')
- self.pack_start(filter_box, False, False)
+ self.pack_start(filter_box, False, False, 0)
- self.completion = gtk.EntryCompletion()
+ self.completion = Gtk.EntryCompletion()
self.completion.set_model(watch)
self.completion.set_inline_completion(True)
@@ -45,7 +45,7 @@ class BusBox(gtk.VBox):
filter_entry.set_completion(self.completion)
# Content
- self.paned = gtk.HPaned()
+ self.paned = Gtk.HPaned()
self.busname_box = BusNameBox(watch)
self.busname_info_box = BusNameInfoBox()
@@ -55,7 +55,7 @@ class BusBox(gtk.VBox):
self.paned.pack1(self.busname_box)
self.paned.pack2(self.busname_info_box)
self.paned.set_position(300)
- self.pack_start(self.paned, True, True)
+ self.pack_start(self.paned, True, True, 0)
ui.connect_signals(signal_dict)
diff --git a/dfeet/_ui/busnamebox.py b/dfeet/_ui/busnamebox.py
index cb48e81..393d2a3 100644
--- a/dfeet/_ui/busnamebox.py
+++ b/dfeet/_ui/busnamebox.py
@@ -1,11 +1,11 @@
import gobject
-import gtk
+from gi.repository import Gtk
from dfeet.dbus_introspector import BusWatch
from busnameview import BusNameView
-class BusNameBox(gtk.VBox):
+class BusNameBox(Gtk.VBox):
__gsignals__ = {
'busname-selected' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_PYOBJECT,))
@@ -17,10 +17,10 @@ class BusNameBox(gtk.VBox):
self.tree_view = BusNameView(watch)
self.tree_view.connect('cursor_changed', self.busname_selected_cb)
- scroll = gtk.ScrolledWindow()
+ scroll = Gtk.ScrolledWindow()
scroll.add(self.tree_view)
- self.pack_start(scroll, True, True)
- scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ self.pack_start(scroll, True, True, 0)
+ scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self.show_all()
diff --git a/dfeet/_ui/busnameinfobox.py b/dfeet/_ui/busnameinfobox.py
index 8041a43..c84f274 100644
--- a/dfeet/_ui/busnameinfobox.py
+++ b/dfeet/_ui/busnameinfobox.py
@@ -1,5 +1,5 @@
import gobject
-import gtk
+from gi.repository import Gtk
import pango
from dfeet import _util
@@ -8,7 +8,7 @@ from dfeet.introspect_data import IntrospectData, Method, Signal
from executemethoddialog import ExecuteMethodDialog
from uiloader import UILoader
-class BusNameInfoBox(gtk.VBox):
+class BusNameInfoBox(Gtk.VBox):
__gsignals__ = {
'selected': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_PYOBJECT,))
@@ -26,11 +26,11 @@ class BusNameInfoBox(gtk.VBox):
self.process_label = ui.get_widget('process_label1')
self.introspection_box = ui.get_widget('introspect_box1')
- self.introspect_tree_view = gtk.TreeView()
+ self.introspect_tree_view = Gtk.TreeView()
- button_renderer = gtk.CellRendererPixbuf()
- text_renderer = gtk.CellRendererText()
- column = gtk.TreeViewColumn("Introspection Data",
+ button_renderer = Gtk.CellRendererPixbuf()
+ text_renderer = Gtk.CellRendererText()
+ column = Gtk.TreeViewColumn("Introspection Data",
None)
column.pack_start(button_renderer, False)
@@ -54,12 +54,12 @@ class BusNameInfoBox(gtk.VBox):
self.introspect_tree_view.append_column(column)
- scroll = gtk.ScrolledWindow()
+ scroll = Gtk.ScrolledWindow()
scroll.add(self.introspect_tree_view)
self.introspection_box.pack_start(scroll,
- True, True)
+ True, True, 0)
- scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self.introspect_tree_view.show_all()
diff --git a/dfeet/_ui/busnameview.py b/dfeet/_ui/busnameview.py
index 948c033..eda692a 100644
--- a/dfeet/_ui/busnameview.py
+++ b/dfeet/_ui/busnameview.py
@@ -1,9 +1,9 @@
import gobject
-import gtk
+from gi.repository import Gtk
from dfeet.dbus_introspector import BusWatch
-class BusNameView(gtk.TreeView):
+class BusNameView(Gtk.TreeView):
def __init__(self, watch):
super(BusNameView, self).__init__()
@@ -14,15 +14,15 @@ class BusNameView(gtk.TreeView):
self.set_property('enable-grid-lines', False)
self.watch = watch
- self.filter_model = self.watch.filter_new()
- self.filter_model.set_visible_func(self._filter_cb)
+ self.filter_model = self.watch.filter_new(None)
+ self.filter_model.set_visible_func(self._filter_cb, None)
- self.sort_model = gtk.TreeModelSort(self.filter_model)
- self.sort_model.set_sort_column_id(self.watch.COMMON_NAME_COL, gtk.SORT_ASCENDING)
+ self.sort_model = Gtk.TreeModelSort(model=self.filter_model)
+ self.sort_model.set_sort_column_id(self.watch.COMMON_NAME_COL, Gtk.SortType.ASCENDING)
self.sort_model.set_sort_func(self.watch.COMMON_NAME_COL, self._sort_on_name, (self.watch.COMMON_NAME_COL, self.watch.UNIQUE_NAME_COL))
- renderer = gtk.CellRendererPixbuf()
- column = gtk.TreeViewColumn("",
+ renderer = Gtk.CellRendererPixbuf()
+ column = Gtk.TreeViewColumn("",
renderer,
pixbuf=watch.ICON_COL
)
@@ -30,8 +30,8 @@ class BusNameView(gtk.TreeView):
column.set_sort_column_id(watch.PROCESS_ID_COL)
self.append_column(column)
- renderer = gtk.CellRendererText()
- column = gtk.TreeViewColumn("Bus Name",
+ renderer = Gtk.CellRendererText()
+ column = Gtk.TreeViewColumn("Bus Name",
renderer,
markup=watch.DISPLAY_COL
)
@@ -40,7 +40,7 @@ class BusNameView(gtk.TreeView):
self.append_column(column)
"""
- column = gtk.TreeViewColumn("Unique Name",
+ column = Gtk.TreeViewColumn("Unique Name",
renderer,
text=watch.UNIQUE_NAME_COL
)
@@ -49,7 +49,7 @@ class BusNameView(gtk.TreeView):
self.append_column(column)
"""
- column = gtk.TreeViewColumn("Process",
+ column = Gtk.TreeViewColumn("Process",
renderer,
text=watch.PROCESS_NAME_COL
)
@@ -58,7 +58,7 @@ class BusNameView(gtk.TreeView):
self.append_column(column)
"""
- column = gtk.TreeViewColumn("PID",
+ column = Gtk.TreeViewColumn("PID",
renderer,
text=watch.PROCESS_ID_COL
)
@@ -69,11 +69,11 @@ class BusNameView(gtk.TreeView):
self.set_headers_clickable(True)
self.set_reorderable(False)
- self.set_search_equal_func(self._search_cb)
+ self.set_search_equal_func(self._search_cb, None)
self.set_model(self.sort_model)
def set_sort_column(self, col):
- self.sort_model.set_sort_column_id(col, gtk.SORT_ASCENDING)
+ self.sort_model.set_sort_column_id(col, Gtk.SortType.ASCENDING)
def set_hide_private(self, value):
self.hide_private = value
@@ -118,11 +118,11 @@ class BusNameView(gtk.TreeView):
return True
- def _search_cb(self, model, column, key, iter):
- return not self._is_iter_equal(model, iter, key)
+ def _search_cb(self, model, column, key, iter_):
+ return not self._is_iter_equal(model, iter_, key)
- def _filter_cb(self, model, iter):
- return self._is_iter_equal(model, iter, self.filter_string)
+ def _filter_cb(self, model, iter_, data):
+ return self._is_iter_equal(model, iter_, self.filter_string)
def _sort_on_name(self, model, iter1, iter2, cols):
(col, alt_col) = cols
@@ -130,10 +130,10 @@ class BusNameView(gtk.TreeView):
un1 = model.get_value(iter1, col)
un2 = model.get_value(iter2, col)
- if not un1:
+ if un1 is None:
un1 = model.get_value(iter1, alt_col)
-
- if not un2:
+
+ if un2 is None:
un2 = model.get_value(iter2, alt_col)
# covert to integers if comparing two unique names
diff --git a/dfeet/_ui/executemethoddialog.py b/dfeet/_ui/executemethoddialog.py
index 8c43c30..7a542ae 100644
--- a/dfeet/_ui/executemethoddialog.py
+++ b/dfeet/_ui/executemethoddialog.py
@@ -1,4 +1,4 @@
-import gtk
+from gi.repository import Gtk
import dbus
from dfeet import _util
diff --git a/dfeet/_ui/uiloader.py b/dfeet/_ui/uiloader.py
index 2bf7bf4..a25ead1 100644
--- a/dfeet/_ui/uiloader.py
+++ b/dfeet/_ui/uiloader.py
@@ -1,4 +1,4 @@
-import gtk
+from gi.repository import Gtk
from dfeet import _util
@@ -31,7 +31,7 @@ class UILoader:
ui_dir = _util.get_ui_dir()
ui_info = self._ui_map[ui]
- self.ui = gtk.Builder()
+ self.ui = Gtk.Builder()
#load ui files
for file in ui_info[0]:
diff --git a/dfeet/_ui/wnck_utils.py b/dfeet/_ui/wnck_utils.py
index e44f8f4..a5f1e21 100644
--- a/dfeet/_ui/wnck_utils.py
+++ b/dfeet/_ui/wnck_utils.py
@@ -3,10 +3,10 @@
# behvior
import gobject
-import gtk
+from gi.repository import Gtk
try:
- import wnck
+ from gi.repository import Wnck
has_libwnck = True
except:
has_libwnck = False
@@ -18,11 +18,11 @@ class IconTable:
# {pid: icon}
self.app_map = {}
- icon_theme = gtk.icon_theme_get_default()
+ icon_theme = Gtk.IconTheme.get_default()
self.default_icon = icon_theme.load_icon('dfeet-icon-default-service', 16, 0)
if has_libwnck:
- screen = wnck.screen_get_default()
+ screen = Wnck.Screen.get_default()
screen.connect('application_opened', self.on_app_open)
screen.connect('application_closed', self.on_app_close)
diff --git a/dfeet/dbus_introspector.py b/dfeet/dbus_introspector.py
index 7e5e097..5bda27d 100644
--- a/dfeet/dbus_introspector.py
+++ b/dfeet/dbus_introspector.py
@@ -1,8 +1,5 @@
-import dbus
-import dbus.bus
-import dbus.mainloop.glib
-import gobject
-import gtk
+
+from gi.repository import GObject, Gdk, GdkPixbuf, Gtk, Gio
import _util
import _introspect_parser
import os
@@ -14,8 +11,6 @@ SESSION_BUS = 1
SYSTEM_BUS = 2
ADDRESS_BUS = 3
-dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
-
class Error(Exception):
pass
@@ -33,9 +28,9 @@ class InvalidColumnError(Error):
def __str__(self):
return repr('Column number \'%i\' requested but is not valid' % self.column)
-class CommonNameData(gobject.GObject):
+class CommonNameData(GObject.GObject):
__gsignals__ = {
- 'introspect_data_changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,())
+ 'introspect_data_changed' : (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE,())
}
def __init__(self):
@@ -86,9 +81,9 @@ class CommonNameData(gobject.GObject):
self.emit('introspect_data_changed')
-class BusName(gobject.GObject):
+class BusName(GObject.GObject):
__gsignals__ = {
- 'changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,())
+ 'changed' : (GObject.SIGNAL_RUN_LAST, GObject.TYPE_NONE,())
}
@@ -200,10 +195,10 @@ class BusName(gobject.GObject):
return result
-class BusWatch(gtk.GenericTreeModel):
+class BusWatch(Gtk.ListStore):
NUM_COL = 9
- (BUSNAME_OBJ_COL,
+ (BUSNAME_OBJ_COL,
UNIQUE_NAME_COL,
COMMON_NAME_COL,
IS_PUBLIC_COL, # has a common name
@@ -213,15 +208,15 @@ class BusWatch(gtk.GenericTreeModel):
DISPLAY_COL,
ICON_COL) = range(NUM_COL)
- COL_TYPES = (gobject.TYPE_PYOBJECT,
- gobject.TYPE_STRING,
- gobject.TYPE_STRING,
- gobject.TYPE_BOOLEAN,
- gobject.TYPE_STRING,
- gobject.TYPE_PYOBJECT,
- gobject.TYPE_STRING,
- gobject.TYPE_STRING,
- gtk.gdk.Pixbuf)
+ COL_TYPES = (GObject.TYPE_PYOBJECT,
+ GObject.TYPE_STRING,
+ GObject.TYPE_STRING,
+ GObject.TYPE_BOOLEAN,
+ GObject.TYPE_STRING,
+ GObject.TYPE_PYOBJECT,
+ GObject.TYPE_STRING,
+ GObject.TYPE_STRING,
+ GdkPixbuf.Pixbuf)
def __init__(self, bus, address=None):
self.bus = None
@@ -229,33 +224,43 @@ class BusWatch(gtk.GenericTreeModel):
self.name_list = []
self.bus_type = bus
self.address = address
- #self.completion_model = gtk.ListStore()
+ #self.completion_model = Gtk.ListStore()
- super(BusWatch, self).__init__()
+ super(BusWatch, self).__init__(*self.COL_TYPES)
if bus == SESSION_BUS:
- self.bus = dbus.SessionBus()
+ self.bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
elif bus == SYSTEM_BUS:
- self.bus = dbus.SystemBus()
+ self.bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
else:
if not address:
raise BusAddressError(address)
- self.bus = dbus.bus.BusConnection(address)
+ self.bus = Gio.DBusConnection.new_for_address_sync(
+ address,
+ Gio.DBusConnectionFlags.MESSAGE_BUS_CONNECTION,
+ None, None)
if not self.bus:
raise BusAddressError(address)
- self.bus.add_signal_receiver(self.name_owner_changed_cb,
- dbus_interface='org.freedesktop.DBus',
- signal_name='NameOwnerChanged')
-
- bus_object = self.bus.get_object('org.freedesktop.DBus',
- '/org/freedesktop/DBus')
- self.bus_interface = dbus.Interface(bus_object,
- 'org.freedesktop.DBus')
-
- self.bus_interface.ListNames(reply_handler=self.list_names_handler,
- error_handler=self.list_names_error_handler)
+ self.bus.signal_subscribe('',
+ 'org.freedesktop.DBus',
+ 'NameOwnerChanged',
+ '',
+ '',
+ 0,
+ self.name_owner_changed_cb,
+ None)
+ self.bus_proxy = Gio.DBusProxy.new_sync(self.bus,
+ Gio.DBusProxyFlags.NONE,
+ None,
+ 'org.freedesktop.DBus',
+ '/org/freedesktop/DBus',
+ 'org.freedesktop.DBus', None)
+
+ self.bus_proxy.ListNames('()',
+ result_handler=self.list_names_handler,
+ error_handler=self.list_names_error_handler)
def get_bus_name(self):
if self.bus_type == SESSION_BUS:
@@ -280,30 +285,32 @@ class BusWatch(gtk.GenericTreeModel):
def get_completion_model(self):
return self.completion_model()
- def get_unix_process_id_cb(self, name, id):
+ def get_unix_process_id_cb(self, obj, id_, name):
names = self.unique_names[name]
if not names:
return
-
+
name = names[0]
if not name:
return
- process_path = _util.get_proc_from_pid(id)
- name.set_process_info(id, process_path)
+ process_path = _util.get_proc_from_pid(id_)
+ name.set_process_info(id_, process_path)
- def get_unix_process_id_error_cb(self, name, error):
+ def get_unix_process_id_error_cb(self, obj, error, name):
print error
# get the Unix process ID so we can associate the name
# with a process (this will only work under Unix like OS's)
def get_unix_process_id_async_helper(self, name):
- self.bus_interface.GetConnectionUnixProcessID(name,
- reply_handler = lambda id: self.get_unix_process_id_cb(name, id),
- error_handler = lambda error: self.get_unix_process_id_error_cb(name, error))
+ self.bus_proxy.GetConnectionUnixProcessID('(s)', name,
+ result_handler = self.get_unix_process_id_cb,
+ error_handler = self.get_unix_process_id_error_cb,
+ user_data=name)
def name_changed_cb(self, name):
+ pass
path = (self.name_list.index(name,))
iter = self.get_iter(path)
self.row_changed(path, iter)
@@ -320,14 +327,21 @@ class BusWatch(gtk.GenericTreeModel):
self.unique_names[name] = [busnameobj]
self.get_unix_process_id_async_helper(name)
self.name_list.append(busnameobj)
- path = (self.name_list.index(busnameobj),)
- iter = self.get_iter(path)
- self.row_inserted(path, iter)
+
+ self.append((busnameobj,
+ busnameobj.get_unique_name(),
+ busnameobj.get_common_name(),
+ busnameobj.is_public(),
+ busnameobj.get_process_id(),
+ busnameobj.get_process_path(),
+ busnameobj.get_process_name(),
+ busnameobj.get_unique_name(),
+ busnameobj.get_icon()))
else:
if not owner:
- owner = self.bus_interface.GetNameOwner(name)
+ owner = self.bus_proxy.GetNameOwner('(s)', name)
if owner == 'org.freedesktop.DBus':
- return
+ return
# if owner still does not exist then we move on
if not owner:
@@ -339,9 +353,16 @@ class BusWatch(gtk.GenericTreeModel):
busnameobj = BusName(owner, self.bus, name, busnameobj)
self.unique_names[owner].append(busnameobj)
self.name_list.append(busnameobj)
- path = (self.name_list.index(busnameobj),)
- iter = self.get_iter(path)
- self.row_inserted(path, iter)
+
+ self.append((busnameobj,
+ busnameobj.get_unique_name(),
+ busnameobj.get_common_name(),
+ busnameobj.is_public(),
+ busnameobj.get_process_id(),
+ busnameobj.get_process_path(),
+ busnameobj.get_process_name(),
+ busnameobj.get_common_name(),
+ busnameobj.get_icon()))
else:
busnameobj.set_common_name(name)
@@ -350,9 +371,15 @@ class BusWatch(gtk.GenericTreeModel):
self.unique_names[owner] = [busnameobj]
self.name_list.append(busnameobj)
self.get_unix_process_id_async_helper(owner)
- path = (self.name_list.index(busnameobj),)
- iter = self.get_iter(path)
- self.row_inserted(path, iter)
+ self.append((busnameobj,
+ busnameobj.get_unique_name(),
+ busnameobj.get_common_name(),
+ busnameobj.is_public(),
+ busnameobj.get_process_id(),
+ busnameobj.get_process_path(),
+ busnameobj.get_process_name(),
+ busnameobj.get_common_name(),
+ busnameobj.get_icon()))
def remove_name(self, name, owner=None):
if not name:
@@ -403,41 +430,17 @@ class BusWatch(gtk.GenericTreeModel):
if old_owner:
self.remove_name(name, old_owner)
- def list_names_handler(self, names):
+ def list_names_handler(self, obj, results, userdata):
+ names = results
for n in names:
self.add_name(n)
- def list_names_error_handler(self, error):
+ def list_names_error_handler(self, obj, error, userdata):
print "error getting bus names - %s" % str(error)
def get_name_list(self):
return self.name_list
- def on_get_flags(self):
- return gtk.TREE_MODEL_ITERS_PERSIST
-
- def on_get_n_columns(self):
- return self.NUM_COL
-
- def on_get_column_type(self, n):
- return self.COL_TYPES[n]
-
- def on_get_iter(self, path):
- try:
- if len(path) == 1:
- return (self.name_list[path[0]],)
- else:
- return (self.name_list[path[0]],path[1])
- except IndexError:
- return None
-
- def on_get_path(self, rowref):
- index = self.files.index(rowref[0])
- if len(rowref) == 1:
- return (index,)
- else:
- return (index, rowref[1])
-
def on_get_value(self, rowref, column):
name = rowref[0]
child = -1
@@ -462,69 +465,13 @@ class BusWatch(gtk.GenericTreeModel):
return name.get_icon()
elif column == self.DISPLAY_COL:
if child == -1:
- return '<b>' + gobject.markup_escape_text(name.get_display_name()) + '</b>'
+ return '<b>' + GObject.markup_escape_text(name.get_display_name()) + '</b>'
elif child == 1:
- return '<b>Command Line: </b>' + gobject.markup_escape_text(name.get_process_name()) + ' (' + gobject.markup_escape_text(str(name.get_process_id())) + ')'
+ return '<b>Command Line: </b>' + GObject.markup_escape_text(name.get_process_name()) + ' (' + GObject.markup_escape_text(str(name.get_process_id())) + ')'
elif child == 0:
- return '<b>Unique Name: </b>'+ gobject.markup_escape_text(name.get_unique_name())
+ return '<b>Unique Name: </b>'+ GObject.markup_escape_text(name.get_unique_name())
else:
raise InvalidColumnError(column)
return None
- def on_iter_next(self, rowref):
- try:
- name = rowref[0]
- child = -1
- if len(rowref) == 2:
- child = rowref[1]
-
- if child == 0:
- return (name, child +1)
- elif child == 1:
- return None
- else:
- i = self.name_list.index(rowref[0]) + 1
- return (self.name_list[i],)
- except IndexError:
- return None
-
- def on_iter_children(self, parent):
- if parent:
- if len(parent) == 1:
- return (parent[0], 0)
- else:
- return None
-
- return (self.name_list[0],)
-
- def on_iter_has_child(self, rowref):
- return False
- if len(rowref) == 1:
- return True
- else:
- return False
-
- def on_iter_n_children(self, rowref):
- if rowref:
- if len(rowref) == 1:
- return 2
- else:
- return None
-
- return len(self.name_list)
-
- def on_iter_nth_child(self, parent, n):
- if parent:
- if n < 2:
- return (parent, n)
- else:
- return None
- try:
- return (self.name_list[n],)
- except IndexError:
- return None
-
- def on_iter_parent(self, child):
- return (child[0],)
-
diff --git a/dfeet/introspect_data.py b/dfeet/introspect_data.py
index f68ed19..8a71746 100644
--- a/dfeet/introspect_data.py
+++ b/dfeet/introspect_data.py
@@ -1,4 +1,4 @@
-import gtk
+from gi.repository import Gtk
import gobject
import dbus_utils
import dbus
@@ -540,7 +540,7 @@ class ObjectPathLabel(Node):
def __str__(self):
return self._label
-class IntrospectData(gtk.GenericTreeModel):
+class IntrospectData(Gtk.TreeStore):
NUM_COL = 3
(SUBTREE_COL,
@@ -586,7 +586,7 @@ class IntrospectData(gtk.GenericTreeModel):
del(data)
def on_get_flags(self):
- return gtk.TREE_MODEL_ITERS_PERSIST
+ return Gtk.TREE_MODEL_ITERS_PERSIST
def on_get_n_columns(self):
return self.NUM_COL
diff --git a/tests/uifile_tests.py b/tests/uifile_tests.py
index f23d9a0..ca2294e 100755
--- a/tests/uifile_tests.py
+++ b/tests/uifile_tests.py
@@ -1,33 +1,33 @@
#!/usr/bin/env python
-import gtk
+from gi.repository import Gtk
-main_ui = gtk.Builder()
+main_ui = Gtk.Builder()
main_ui.add_from_file("../ui/default-actiongroup.ui")
main_ui.add_from_file("../ui/mainwindow.ui")
win = main_ui.get_object("appwindow1")
win.show_all()
-filterbox_ui = gtk.Builder()
+filterbox_ui = Gtk.Builder()
filterbox_ui.add_from_file("../ui/filterbox.ui")
-filterbox_win = gtk.Window(gtk.WINDOW_TOPLEVEL)
+filterbox_win = Gtk.Window(Gtk.WindowType.TOPLEVEL)
filterbox = filterbox_ui.get_object("filterbox_table1")
filterbox_win.add(filterbox)
filterbox_win.show_all()
-introspectview_ui = gtk.Builder()
+introspectview_ui = Gtk.Builder()
introspectview_ui.add_from_file("../ui/introspectview.ui")
-introspectview_win = gtk.Window(gtk.WINDOW_TOPLEVEL)
+introspectview_win = Gtk.Window(Gtk.WindowType.TOPLEVEL)
introspectview = introspectview_ui.get_object("introspectview_table1")
introspectview_win.add(introspectview)
introspectview_win.show_all()
-executedialog_ui = gtk.Builder()
+executedialog_ui = Gtk.Builder()
executedialog_ui.add_from_file("../ui/executedialog.ui")
executedialog_win = executedialog_ui.get_object("executedialog1")
executedialog_win.show_all()
-gtk.main()
+Gtk.main()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]