[d-feet] Use correct data dir
- From: Thomas Bechtold <toabctl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [d-feet] Use correct data dir
- Date: Tue, 14 May 2013 15:28:12 +0000 (UTC)
commit 9c0534b573a9d8a2811502722bd2af0a5a5bbb5d
Author: Thomas Bechtold <thomasbechtold jpberlin de>
Date: Tue May 14 16:24:17 2013 +0200
Use correct data dir
src/dfeet/addconnectiondialog.py | 6 +++---
src/dfeet/application.py | 10 +++++-----
src/dfeet/bus_watch.py | 21 +++++++++++----------
src/dfeet/executemethoddialog.py | 12 ++++++------
src/dfeet/introspection.py | 13 +++++++------
src/dfeet/uiloader.py | 15 +++++----------
6 files changed, 37 insertions(+), 40 deletions(-)
---
diff --git a/src/dfeet/addconnectiondialog.py b/src/dfeet/addconnectiondialog.py
index d7c889a..a1a500c 100644
--- a/src/dfeet/addconnectiondialog.py
+++ b/src/dfeet/addconnectiondialog.py
@@ -4,8 +4,8 @@ from dfeet.uiloader import UILoader
class AddConnectionDialog:
- def __init__(self, parent, address_bus_history=[]):
- ui = UILoader(UILoader.UI_ADDCONNECTIONDIALOG)
+ def __init__(self, data_dir, parent, address_bus_history=[]):
+ ui = UILoader(data_dir, UILoader.UI_ADDCONNECTIONDIALOG)
self.dialog = ui.get_root_widget()
@@ -26,7 +26,7 @@ class AddConnectionDialog:
self.dialog.add_button('gtk-cancel', Gtk.ResponseType.CANCEL)
self.dialog.add_button('gtk-connect', Gtk.ResponseType.OK)
-
+
@property
def address(self):
tree_iter = self.address_combo_box.get_active_iter()
diff --git a/src/dfeet/application.py b/src/dfeet/application.py
index 610c640..0d3fbad 100644
--- a/src/dfeet/application.py
+++ b/src/dfeet/application.py
@@ -57,7 +57,7 @@ class DFeetApp(Gtk.Application):
settings = Settings.get_instance()
- ui = UILoader(UILoader.UI_MAINWINDOW)
+ ui = UILoader(self.data_dir, UILoader.UI_MAINWINDOW)
self.main_window = ui.get_root_widget()
self.main_window.connect('delete-event', self.__quit_dfeet)
self.main_window.set_default_size(int(settings.general['windowwidth']),
@@ -96,19 +96,19 @@ class DFeetApp(Gtk.Application):
def __systembus_connect_cb(self, action):
"""connect to system bus"""
- bw = BusWatch(Gio.BusType.SYSTEM)
+ bw = BusWatch(self.data_dir, Gio.BusType.SYSTEM)
self.__notebook_append_page(bw.paned_buswatch, "System Bus")
def __sessionbus_connect_cb(self, action):
"""connect to session bus"""
- bw = BusWatch(Gio.BusType.SESSION)
+ bw = BusWatch(self.data_dir, Gio.BusType.SESSION)
self.__notebook_append_page(bw.paned_buswatch, "Session Bus")
def __otherbus_connect_cb(self, action):
"""connect to other bus"""
- dialog = AddConnectionDialog(self.main_window, self.bus_history)
+ dialog = AddConnectionDialog(self.data_dir, self.main_window, self.bus_history)
result = dialog.run()
if result == Gtk.ResponseType.OK:
address = dialog.address
@@ -120,7 +120,7 @@ class DFeetApp(Gtk.Application):
return
else:
try:
- bw = BusWatch(address)
+ bw = BusWatch(self.data_dir, address)
self.__notebook_append_page(bw.paned_buswatch, address)
# Fill history
if address in self.bus_history:
diff --git a/src/dfeet/bus_watch.py b/src/dfeet/bus_watch.py
index 2ba403d..5d4d4ac 100644
--- a/src/dfeet/bus_watch.py
+++ b/src/dfeet/bus_watch.py
@@ -33,7 +33,7 @@ class DBusBusName(GObject.GObject):
@property
def pid(self):
return self.__pid
-
+
@pid.setter
def pid(self, pid_new):
self.__pid = pid_new
@@ -49,10 +49,11 @@ class DBusBusName(GObject.GObject):
class BusWatch(object):
"""watch for a given bus"""
- def __init__(self, address):
+ def __init__(self, data_dir, address):
+ self.data_dir = data_dir
self.address = address
#setup UI
- ui = UILoader(UILoader.UI_BUSWATCH)
+ ui = UILoader(self.data_dir, UILoader.UI_BUSWATCH)
self.paned_buswatch = ui.get_root_widget()
self.liststore_model = ui.get_widget('liststore_buswatch')
self.treemodelfilter_buswatch = ui.get_widget('treemodelfilter_buswatch')
@@ -87,8 +88,8 @@ class BusWatch(object):
None, None, 0, self.__name_owner_changed_cb, None)
self.bus_proxy = Gio.DBusProxy.new_sync(self.connection,
- Gio.DBusProxyFlags.NONE,
- None,
+ Gio.DBusProxyFlags.NONE,
+ None,
'org.freedesktop.DBus',
'/org/freedesktop/DBus',
'org.freedesktop.DBus', None)
@@ -116,7 +117,7 @@ class BusWatch(object):
model, iter_ = selection.get_selected()
if not iter_:
return
-
+
bus_name_obj = model.get(iter_, 0)[0]
#remove current child
c2 = self.paned_buswatch.get_child2()
@@ -128,15 +129,15 @@ class BusWatch(object):
pass
#add Introspection to paned
- self.addr_info = AddressInfo(self.address, bus_name_obj.bus_name_unique, connection_is_bus=True)
+ self.addr_info = AddressInfo(self.data_dir, self.address, bus_name_obj.bus_name_unique,
connection_is_bus=True)
self.paned_buswatch.add2(self.addr_info.introspect_box)
-
+
#update info about selected bus name
self.label_bus_name_selected_name.set_text(bus_name_obj.bus_name_unique)
self.label_bus_name_selected_pid.set_text("%s" % bus_name_obj.pid)
self.label_bus_name_selected_cmdline.set_text(bus_name_obj.cmdline)
self.grid_bus_name_selected_info.set_visible(True)
-
+
def __liststore_model_add(self, bus_name_obj):
"""add a DBusBusName object to the liststore model"""
@@ -155,7 +156,7 @@ class BusWatch(object):
if obj[2] == bus_name_obj.bus_name_unique:
del(self.liststore_model[n])
break
-
+
def __liststore_model_get(self, bus_name_obj):
"""get a object from the liststore"""
for n, obj in enumerate(self.liststore_model):
diff --git a/src/dfeet/executemethoddialog.py b/src/dfeet/executemethoddialog.py
index 1f2e05c..1148e92 100644
--- a/src/dfeet/executemethoddialog.py
+++ b/src/dfeet/executemethoddialog.py
@@ -7,18 +7,18 @@ from dfeet.uiloader import UILoader
class ExecuteMethodDialog:
- def __init__(self, connection, connection_is_bus, bus_name, method_obj):
- signal_dict = {
+ def __init__(self, data_dir, connection, connection_is_bus, bus_name, method_obj):
+ signal_dict = {
'execute_dbus_method_cb' : self.execute_cb,
'execute_dialog_close_cb': self.close_cb
- }
+ }
self.connection = connection
self.connection_is_bus = connection_is_bus
self.bus_name = bus_name
self.method_obj = method_obj
- ui = UILoader(UILoader.UI_EXECUTEDIALOG)
+ ui = UILoader(data_dir, UILoader.UI_EXECUTEDIALOG)
self.dialog = ui.get_root_widget()
self.label_method_name = ui.get_widget('label_method_name')
self.label_object_path = ui.get_widget('label_object_path')
@@ -39,7 +39,7 @@ class ExecuteMethodDialog:
def execute_cb(self, widget):
#get given parameters
buf = self.parameter_textview.get_buffer()
- params = buf.get_text(buf.get_start_iter(),
+ params = buf.get_text(buf.get_start_iter(),
buf.get_end_iter(), False)
#reset the statistics stuff
@@ -50,7 +50,7 @@ class ExecuteMethodDialog:
'avg': 0,
'count': 0,
}
-
+
try:
#build a GVariant
if params:
diff --git a/src/dfeet/introspection.py b/src/dfeet/introspection.py
index bcf2445..544e168 100644
--- a/src/dfeet/introspection.py
+++ b/src/dfeet/introspection.py
@@ -20,7 +20,8 @@ class AddressInfo():
except:
pass
- def __init__(self, address, name, connection_is_bus=True):
+ def __init__(self, data_dir, address, name, connection_is_bus=True):
+ self.data_dir = data_dir
signal_dict = {
'treeview_row_activated_cb' : self.__treeview_row_activated_cb,
'treeview_row_expanded_cb' : self.__treeview_row_expanded_cb,
@@ -32,7 +33,7 @@ class AddressInfo():
self.connection_is_bus = connection_is_bus # is it a bus or a p2p connection?
#setup UI
- ui = UILoader(UILoader.UI_INTROSPECTION)
+ ui = UILoader(self.data_dir, UILoader.UI_INTROSPECTION)
self.introspect_box = ui.get_root_widget() #this is the main box with the treeview
self.__spinner = ui.get_widget('spinner') #the spinner is used to show progress during the
introspection
self.__scrolledwindow = ui.get_widget('scrolledwindow') #the scrolledwindow contains the treeview
@@ -70,7 +71,7 @@ class AddressInfo():
else:
self.connection = None
raise Exception("Invalid p2p address '%s'" % (self.address))
-
+
#start processing data
self.introspect_start()
@@ -86,13 +87,13 @@ class AddressInfo():
if isinstance(obj, DBusMethod):
#execute the selected method
- dialog = ExecuteMethodDialog(self.connection, self.connection_is_bus, self.name, obj)
+ dialog = ExecuteMethodDialog(self.data_dir, self.connection, self.connection_is_bus, self.name,
obj)
dialog.run()
elif isinstance(obj, DBusProperty):
#update the selected property (TODO: do this async)
proxy = Gio.DBusProxy.new_sync(self.connection,
- Gio.DBusProxyFlags.NONE,
- None,
+ Gio.DBusProxyFlags.NONE,
+ None,
self.name,
obj.object_path,
"org.freedesktop.DBus.Properties", None)
diff --git a/src/dfeet/uiloader.py b/src/dfeet/uiloader.py
index 484626e..21c66cf 100644
--- a/src/dfeet/uiloader.py
+++ b/src/dfeet/uiloader.py
@@ -5,7 +5,7 @@ from gi.repository import Gtk
class UILoader:
instance = None
-
+
UI_COUNT = 5
(UI_MAINWINDOW,
@@ -16,7 +16,7 @@ class UILoader:
) = range(UI_COUNT)
# {ui_id: ((files,...), root widget)}
- _ui_map = {UI_MAINWINDOW : (('mainwindow.ui',),
+ _ui_map = {UI_MAINWINDOW : (('mainwindow.ui',),
'appwindow1'),
UI_INTROSPECTION : (('introspection.ui',),
'box_introspectview'),
@@ -28,9 +28,10 @@ class UILoader:
'add_connection_dialog1')
}
- def __init__(self, ui):
+ def __init__(self, data_dir, ui):
ui_info = self._ui_map[ui]
self.ui = Gtk.Builder()
+ self.data_dir = data_dir
#load ui files
for f in ui_info[0]:
@@ -49,10 +50,4 @@ class UILoader:
@property
def ui_dir(self):
- try:
- ui_dir = os.environ['DFEET_DATA_PATH']
- except:
- ui_dir = "../ui"
-
- return ui_dir
-
+ return os.path.join(self.data_dir, "ui")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]