summaryrefslogtreecommitdiffstats
path: root/src/Gui
diff options
context:
space:
mode:
authorJiri Moskovcak <jmoskovc@redhat.com>2009-07-22 13:34:30 +0200
committerJiri Moskovcak <jmoskovc@redhat.com>2009-07-22 13:34:30 +0200
commitae56d56a984b4c669a6457b5256e6ad759bb1f3c (patch)
tree13f7a981cab7a011d1b7261878ff9e162babca5e /src/Gui
parentb21a17491ab4eab43b871da791a8a8ef84489be1 (diff)
downloadabrt-ae56d56a984b4c669a6457b5256e6ad759bb1f3c.tar.gz
abrt-ae56d56a984b4c669a6457b5256e6ad759bb1f3c.tar.xz
abrt-ae56d56a984b4c669a6457b5256e6ad759bb1f3c.zip
GUI: single instance pattern rhbz#512390, trac#60
- improved status window
Diffstat (limited to 'src/Gui')
-rw-r--r--src/Gui/ABRTExceptions.py6
-rw-r--r--src/Gui/CCDBusBackend.py47
-rw-r--r--src/Gui/CCMainWindow.py40
-rw-r--r--src/Gui/Makefile.am2
4 files changed, 83 insertions, 12 deletions
diff --git a/src/Gui/ABRTExceptions.py b/src/Gui/ABRTExceptions.py
new file mode 100644
index 00000000..5f759dd2
--- /dev/null
+++ b/src/Gui/ABRTExceptions.py
@@ -0,0 +1,6 @@
+class IsRunning(Exception):
+ def __init__(self):
+ self.what = "Another client is already running, trying to wake it."
+ def __str__(self):
+ return self.what
+
diff --git a/src/Gui/CCDBusBackend.py b/src/Gui/CCDBusBackend.py
index 21d24252..d7801ee1 100644
--- a/src/Gui/CCDBusBackend.py
+++ b/src/Gui/CCDBusBackend.py
@@ -1,14 +1,19 @@
# -*- coding: utf-8 -*-
import dbus
+import dbus.service
import gobject
from dbus.mainloop.glib import DBusGMainLoop
import gtk
+from dbus.exceptions import *
+import ABRTExceptions
CC_NAME = 'com.redhat.abrt'
CC_IFACE = 'com.redhat.abrt'
CC_PATH = '/com/redhat/abrt'
+
APP_NAME = 'com.redhat.abrt.gui'
-
+APP_PATH = '/com/redhat/abrt/gui'
+APP_IFACE = 'com.redhat.abrt.gui'
class DBusManager(gobject.GObject):
""" Class to provide communication with daemon over dbus """
@@ -17,6 +22,32 @@ class DBusManager(gobject.GObject):
pending_jobs = []
def __init__(self):
session = None
+ # binds the dbus to glib mainloop
+ DBusGMainLoop(set_as_default=True)
+ class DBusInterface(dbus.service.Object):
+ def __init__(self, dbusmanager):
+ self.dbusmanager = dbusmanager
+ dbus.service.Object.__init__(self, dbus.SessionBus(), APP_PATH)
+
+ @dbus.service.method(dbus_interface=APP_IFACE)
+ def show(self):
+ self.dbusmanager.emit("show")
+ try:
+ session = dbus.SessionBus()
+ except Exception, e:
+ print e
+
+ try:
+ app_proxy = session.get_object(APP_NAME,APP_PATH)
+ app_iface = dbus.Interface(app_proxy, dbus_interface=APP_IFACE)
+ # app is running, so make it show it self
+ app_iface.show()
+ raise ABRTExceptions.IsRunning()
+ except DBusException, e:
+ # cannot create proxy or call the method => gui is not running
+ pass
+
+ """
try:
session = dbus.SessionBus()
except:
@@ -25,7 +56,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,())
@@ -35,8 +66,14 @@ class DBusManager(gobject.GObject):
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)
+ # signal emited to show gui if user try to run it again
+ gobject.signal_new ("show", self ,gobject.SIGNAL_RUN_FIRST,gobject.TYPE_NONE,())
+
+ # export the app dbus interface
+ if session:
+ session.request_name(APP_NAME)
+ iface = DBusInterface(self)
+
self.proxy = None
self.proxy = self.connect_to_daemon()
if self.proxy:
@@ -123,7 +160,7 @@ class DBusManager(gobject.GObject):
#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)
+ raise Exception(e)
def Report(self,report):
# FIXME async
diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py
index 6e378fc7..fa01882c 100644
--- a/src/Gui/CCMainWindow.py
+++ b/src/Gui/CCMainWindow.py
@@ -13,18 +13,24 @@ from CCDumpList import getDumpList, DumpList
from CCReporterDialog import ReporterDialog
from CCReport import Report
from exception import installExceptionHandler, handleMyException
+import ABRTExceptions
+
try:
import rpm
except Exception, ex:
rpm = None
-installExceptionHandler("abrt-gui", "0.0.2")
+#installExceptionHandler("abrt-gui", "0.0.4")
class MainWindow():
+ ccdaemon = None
def __init__(self):
- self.theme = theme = gtk.icon_theme_get_default()
+ self.theme = gtk.icon_theme_get_default()
try:
self.ccdaemon = CCDBusBackend.DBusManager()
+ except ABRTExceptions.IsRunning, e:
+ # another instance is running, so exit quietly
+ sys.exit()
except Exception, e:
# show error message if connection fails
# FIXME add an option to start the daemon
@@ -40,6 +46,11 @@ class MainWindow():
if (self.window):
self.window.connect("delete_event", self.delete_event_cb)
self.window.connect("destroy", self.destroy)
+ self.window.connect("focus-in-event", self.focus_in_cb)
+
+ self.statusWindow = self.wTree.get_widget("pBarWindow")
+ if self.statusWindow:
+ self.statusWindow.connect("delete_event", self.sw_delete_event_cb)
self.appBar = self.wTree.get_widget("appBar")
# pregress bar window to show while bt is being extracted
@@ -94,6 +105,7 @@ class MainWindow():
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)
+ self.ccdaemon.connect("show", self.show_cb)
# load data
#self.load()
@@ -231,18 +243,34 @@ class MainWindow():
except Exception, e:
# FIXME #3 dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply
# do this async and wait for yum to end with debuginfoinstal
- gui_error_message("Error getting the report: %s" % e.message)
+ if self.timer:
+ gobject.source_remove(self.timer)
+ self.pBarWindow.hide()
+ gui_error_message("Error getting the report: %s" % e)
return
-
+ def sw_delete_event_cb(self, widget, event, data=None):
+ if self.timer:
+ gobject.source_remove(self.timer)
+ widget.hide()
+ return True
+
def delete_event_cb(self, widget, event, data=None):
gtk.main_quit()
-
+
+ def focus_in_cb(self, widget, event, data=None):
+ self.window.set_urgency_hint(False)
+
def on_bQuit_clicked(self, widget):
gtk.main_quit()
def show(self):
self.window.show()
-
+
+ def show_cb(self, daemon):
+ if self.window:
+ if self.window.is_active():
+ return
+ self.window.set_urgency_hint(True)
if __name__ == "__main__":
cc = MainWindow()
diff --git a/src/Gui/Makefile.am b/src/Gui/Makefile.am
index 9112cf83..1715588a 100644
--- a/src/Gui/Makefile.am
+++ b/src/Gui/Makefile.am
@@ -4,7 +4,7 @@ bin_SCRIPTS = abrt-gui
PYTHON_FILES = CCDBusBackend.py CCDumpList.py CCDump.py CC_gui_functions.py \
ccgui.glade report.glade CCReporterDialog.py CCReport.py \
- CCMainWindow.py exception.py CellRenderers.py
+ CCMainWindow.py exception.py CellRenderers.py ABRTExceptions.py
GLADE_FILES = ccgui.glade report.glade