diff options
author | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-07-20 17:01:01 +0200 |
---|---|---|
committer | Jiri Moskovcak <jmoskovc@redhat.com> | 2009-07-20 17:01:01 +0200 |
commit | c581668d59fc839f42a9e42ff4b371b02789aaa3 (patch) | |
tree | 7191f4085b1763b01dd4f813caedd93bae157ba8 /src/Gui | |
parent | ede175cb92ada7e1235b9b1ee8777d7d1ad32613 (diff) | |
download | abrt-c581668d59fc839f42a9e42ff4b371b02789aaa3.tar.gz abrt-c581668d59fc839f42a9e42ff4b371b02789aaa3.tar.xz abrt-c581668d59fc839f42a9e42ff4b371b02789aaa3.zip |
Daemon: added threaded CreateReport -> breaks CLI!
Diffstat (limited to 'src/Gui')
-rw-r--r-- | src/Gui/CCDBusBackend.py | 37 | ||||
-rw-r--r-- | src/Gui/CCMainWindow.py | 15 | ||||
-rw-r--r-- | src/Gui/ccgui.glade | 64 |
3 files changed, 89 insertions, 27 deletions
diff --git a/src/Gui/CCDBusBackend.py b/src/Gui/CCDBusBackend.py index 12326c7b..21d24252 100644 --- a/src/Gui/CCDBusBackend.py +++ b/src/Gui/CCDBusBackend.py @@ -13,6 +13,8 @@ APP_NAME = 'com.redhat.abrt.gui' class DBusManager(gobject.GObject): """ Class to provide communication with daemon over dbus """ # and later with policyKit + uniq_name = None + pending_jobs = [] def __init__(self): session = None try: @@ -23,7 +25,7 @@ class DBusManager(gobject.GObject): if session: if session.request_name(APP_NAME, dbus.bus.NAME_FLAG_DO_NOT_QUEUE) != dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER: raise Exception("Name %s is taken,\nanother instance is already running." % APP_NAME) - + gobject.GObject.__init__(self) # signal emited when new crash is detected gobject.signal_new ("crash", self ,gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,()) @@ -31,6 +33,8 @@ class DBusManager(gobject.GObject): gobject.signal_new ("analyze-complete", self ,gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,(gobject.TYPE_PYOBJECT,)) # signal emited when smth fails gobject.signal_new ("error", self ,gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,(gobject.TYPE_PYOBJECT,)) + # signal emited to update gui with current status + gobject.signal_new ("update", self ,gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,(gobject.TYPE_PYOBJECT,)) # binds the dbus to glib mainloop DBusGMainLoop(set_as_default=True) self.proxy = None @@ -44,6 +48,10 @@ class DBusManager(gobject.GObject): self.acconnection = self.proxy.connect_to_signal("AnalyzeComplete",self.analyze_complete_cb,dbus_interface=CC_IFACE) # Catch Errors self.acconnection = self.proxy.connect_to_signal("Error",self.error_handler_cb,dbus_interface=CC_IFACE) + # watch for updates + self.acconnection = self.proxy.connect_to_signal("Update",self.update_cb,dbus_interface=CC_IFACE) + # watch for job-done signals + self.acconnection = self.proxy.connect_to_signal("JobDone",self.jobdone_cb,dbus_interface=CC_IFACE) else: raise Exception("Please check if abrt daemon is running.") @@ -69,16 +77,23 @@ class DBusManager(gobject.GObject): #emit a signal #print "crash" self.emit("crash") + + def update_cb(self, dest, message): + # FIXME: use dest instead of 0 once we implement it in daemon + #if self.uniq_name == dest: + self.emit("update", message) def analyze_complete_cb(self,dump): #for arg in args: # print "Analyze complete for: %s" % arg # emit signal to let clients know that analyze has been completed # FIXME - rewrite with CCReport class - self.emit("analyze-complete", dump) - + # self.emit("analyze-complete", dump) + pass + def connect_to_daemon(self): bus = dbus.SystemBus() + self.uniq_name = bus.get_unique_name() if not bus: raise Exception("Can't connect to dbus") try: @@ -88,11 +103,25 @@ class DBusManager(gobject.GObject): except Exception, e: raise Exception(e.message + "\nCannot create a proxy object!") + def addJob(self, job_id): + self.pending_jobs.append(job_id) + + def jobdone_cb(self, job_id): + #if self.uniq_name == client_id: + try: + self.pending_jobs.index(job_id) + except: + return + dump = self.cc.GetJobResult(job_id) + if dump: + self.emit("analyze-complete", dump) + def getReport(self, UUID): try: # let's try it async # even if it's async it timeouts, so let's try to set the timeout to 60sec - self.cc.CreateReport(UUID, reply_handler=self.dummy, error_handler=self.error_handler, timeout=60) + #self.cc.CreateReport(UUID, reply_handler=self.addJob, error_handler=self.error_handler, timeout=60) + self.addJob(self.cc.CreateReport(UUID, timeout=60)) except dbus.exceptions.DBusException, e: raise Exception(e.message) diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py index 5a92b9f6..6e378fc7 100644 --- a/src/Gui/CCMainWindow.py +++ b/src/Gui/CCMainWindow.py @@ -93,6 +93,7 @@ class MainWindow(): self.ccdaemon.connect("crash", self.on_data_changed_cb, None) self.ccdaemon.connect("analyze-complete", self.on_analyze_complete_cb, self.pBarWindow) self.ccdaemon.connect("error", self.error_cb) + self.ccdaemon.connect("update", self.update_cb) # load data #self.load() @@ -110,12 +111,15 @@ class MainWindow(): except Exception, e: pass gui_error_message("Unable to get report!\n%s" % message) + + def update_cb(self, daemon, message): + self.wTree.get_widget("lStatus").set_text(message) # call to update the progressbar def progress_update_cb(self, *args): self.pBar.pulse() return True - + def hydrate(self): n = None self.dumpsListStore.clear() @@ -185,7 +189,10 @@ class MainWindow(): self.dlist.set_cursor(path[0]) def on_analyze_complete_cb(self, daemon, report, pBarWindow): - gobject.source_remove(self.timer) + try: + gobject.source_remove(self.timer) + except: + pass self.pBarWindow.hide() #FIXME - why we need this?? -> timeout warnings # try: @@ -213,8 +220,8 @@ class MainWindow(): if not path: return self.update_pBar = False - self.pBar.show() - self.pBarWindow.show() + #self.pBar.show() + self.pBarWindow.show_all() self.timer = gobject.timeout_add (100,self.progress_update_cb) dump = dumpsListStore.get_value(dumpsListStore.get_iter(path[0]), dumpsListStore.get_n_columns()-1) diff --git a/src/Gui/ccgui.glade b/src/Gui/ccgui.glade index 56ab653f..53da45b6 100644 --- a/src/Gui/ccgui.glade +++ b/src/Gui/ccgui.glade @@ -1,10 +1,10 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> -<!--Generated with glade3 3.4.5 on Fri Mar 13 14:32:54 2009 --> +<?xml version="1.0"?> <glade-interface> + <!-- interface-requires gtk+ 2.16 --> + <!-- interface-naming-policy toplevel-contextual --> <widget class="GtkWindow" id="main_window2"> <property name="title" translatable="yes">Automatic Bug Reporting Tool</property> - <property name="window_position">GTK_WIN_POS_CENTER</property> + <property name="window_position">center</property> <child> <widget class="GtkVBox" id="vbox4"> <property name="visible">True</property> @@ -21,8 +21,8 @@ <property name="visible">True</property> <child> <widget class="GtkImageMenuItem" id="miQuit"> + <property name="label">gtk-quit</property> <property name="visible">True</property> - <property name="label" translatable="yes">gtk-quit</property> <property name="use_underline">True</property> <property name="use_stock">True</property> </widget> @@ -41,8 +41,8 @@ <property name="visible">True</property> <child> <widget class="GtkImageMenuItem" id="miAbout"> + <property name="label">gtk-about</property> <property name="visible">True</property> - <property name="label" translatable="yes">gtk-about</property> <property name="use_underline">True</property> <property name="use_stock">True</property> </widget> @@ -54,6 +54,7 @@ </widget> <packing> <property name="expand">False</property> + <property name="position">0</property> </packing> </child> <child> @@ -67,6 +68,7 @@ <property name="stock_id">gtk-delete</property> </widget> <packing> + <property name="expand">False</property> <property name="homogeneous">True</property> </packing> </child> @@ -78,6 +80,7 @@ <property name="stock_id">gtk-save</property> </widget> <packing> + <property name="expand">False</property> <property name="homogeneous">True</property> </packing> </child> @@ -86,6 +89,7 @@ <property name="visible">True</property> </widget> <packing> + <property name="expand">False</property> <property name="homogeneous">True</property> </packing> </child> @@ -99,8 +103,8 @@ <widget class="GtkScrolledWindow" id="swDumps"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> <child> <widget class="GtkTreeView" id="tvDumps"> <property name="visible">True</property> @@ -133,18 +137,18 @@ <widget class="GtkScrolledWindow" id="swDesscription"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> <child> <widget class="GtkViewport" id="vDescription"> <property name="visible">True</property> - <property name="resize_mode">GTK_RESIZE_QUEUE</property> + <property name="resize_mode">queue</property> <child> <widget class="GtkLabel" id="lDescription"> <property name="visible">True</property> <property name="xalign">0.10000000149011612</property> <property name="yalign">0.20000000298023224</property> - <property name="justify">GTK_JUSTIFY_FILL</property> + <property name="justify">fill</property> <property name="selectable">True</property> </widget> </child> @@ -171,7 +175,7 @@ <widget class="GtkWindow" id="pBarWindow"> <property name="title" translatable="yes">Please wait..</property> <property name="modal">True</property> - <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property> + <property name="window_position">center-on-parent</property> <property name="default_width">270</property> <child> <widget class="GtkVBox" id="vbox1"> @@ -183,6 +187,7 @@ </widget> <packing> <property name="expand">False</property> + <property name="position">0</property> </packing> </child> <child> @@ -195,12 +200,32 @@ </packing> </child> <child> - <widget class="GtkStatusbar" id="statusbar2"> + <widget class="GtkHBox" id="hbox1"> <property name="visible">True</property> - <property name="spacing">2</property> + <child> + <widget class="GtkArrow" id="arrow1"> + <property name="visible">True</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="lStatus"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes"> </property> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> </widget> <packing> <property name="expand">False</property> + <property name="fill">False</property> <property name="position">2</property> </packing> </child> @@ -211,8 +236,8 @@ <property name="border_width">5</property> <property name="title" translatable="yes">About ABRT</property> <property name="resizable">False</property> - <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property> - <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> + <property name="window_position">center-on-parent</property> + <property name="type_hint">dialog</property> <property name="has_separator">False</property> <property name="program_name">ABRT</property> <property name="copyright" translatable="yes">(C) 2009 Red Hat, Inc.</property> @@ -235,11 +260,12 @@ Zdenek Prikryl <zprikryl@redhat.com></property> <child internal-child="action_area"> <widget class="GtkHButtonBox" id="dialog-action_area3"> <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> + <property name="layout_style">end</property> </widget> <packing> <property name="expand">False</property> - <property name="pack_type">GTK_PACK_END</property> + <property name="pack_type">end</property> + <property name="position">0</property> </packing> </child> </widget> |