[pessulus] [pessulus] Use gtk.show_uri() and remove gnome-python requirement



commit 8bff1c4a58eae9add62cf17b44dea859b8299565
Author: Vincent Untz <vuntz gnome org>
Date:   Tue Jul 28 17:39:19 2009 +0200

    [pessulus] Use gtk.show_uri() and remove gnome-python requirement
    
    Closes: http://bugzilla.gnome.org/show_bug.cgi?id=572357
    Closes: http://bugzilla.gnome.org/show_bug.cgi?id=530882

 Pessulus/main.py       |    5 +----
 Pessulus/maindialog.py |   38 +++++++++++++++++++++++++++-----------
 configure.ac           |    3 +--
 3 files changed, 29 insertions(+), 17 deletions(-)
---
diff --git a/Pessulus/main.py b/Pessulus/main.py
index dc334e2..cd51dfb 100644
--- a/Pessulus/main.py
+++ b/Pessulus/main.py
@@ -29,7 +29,6 @@ def main (args):
     
     import gtk
     import gtk.glade
-    import gnome
 
     import maindialog
     import lockdownappliergconf
@@ -42,8 +41,6 @@ def main (args):
     gettext.install (config.PACKAGE, config.LOCALEDIR)
     gtk.glade.bindtextdomain (config.PACKAGE, config.LOCALEDIR)
 
-    prog = gnome.program_init (config.PACKAGE, config.VERSION)
-
     gtk.window_set_default_icon_name ("pessulus")
 
     applier = lockdownappliergconf.PessulusLockdownApplierGconf ()
@@ -60,7 +57,7 @@ def main (args):
         dialog.run ()
         return
 
-    dialog = maindialog.PessulusMainDialog (applier, gnome_program = prog)
+    dialog = maindialog.PessulusMainDialog (applier)
 
     gtk.main ()
 
diff --git a/Pessulus/maindialog.py b/Pessulus/maindialog.py
index b7122d1..18dfd00 100644
--- a/Pessulus/maindialog.py
+++ b/Pessulus/maindialog.py
@@ -24,7 +24,8 @@ import gettext
 import gobject
 import gtk
 import gtk.glade
-import gnome
+
+from xml.sax.saxutils import escape as escape_pango
 
 from config import *
 
@@ -81,7 +82,7 @@ class PessulusMainDialog:
         COLUMN_PAGENUMBER
     ) = range (3)
 
-    def __init__ (self, applier, quit_on_close = True, gnome_program = None):
+    def __init__ (self, applier, quit_on_close = True):
         globalvar.applier = applier
         globalvar.tooltips = gtk.Tooltips ()
 
@@ -93,11 +94,6 @@ class PessulusMainDialog:
         self.glade_file = os.path.join (GLADEDIR, "pessulus.glade")
         self.xml = gtk.glade.XML (self.glade_file, "dialogEditor", PACKAGE)
 
-        if gnome_program:
-            self.gnome_program = gnome_program
-        else:
-            self.xml.get_widget ("helpbutton").hide ()
-
         self.window = self.xml.get_widget ("dialogEditor")
         self.window.connect ("response", self.__on_dialog_response)
 
@@ -214,12 +210,32 @@ class PessulusMainDialog:
         iter = model.get_iter (selector.get_cursor ()[0])
         notebook.set_current_page (model[iter][self.COLUMN_PAGENUMBER])
 
+    def __error_dialog (self, primary, secondary = None):
+        def __on_response (dialog, response_id):
+            dialog.destroy ()
+
+        dialog = gtk.MessageDialog (parent = self.window,
+                                    flags = gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT,
+                                    type = gtk.MESSAGE_ERROR,
+                                    buttons = gtk.BUTTONS_CLOSE,
+                                    message_format = primary)
+        if secondary:
+            dialog.format_secondary_text (secondary)
+
+        dialog.connect ("response", __on_response)
+        dialog.show ()
+
     def __on_dialog_response (self, dialog, response_id):
         if dialog == self.window and response_id == gtk.RESPONSE_HELP:
-            gnome.help_display_desktop (self.gnome_program,
-                                        "system-admin-guide",
-                                        "system-admin-guide",
-                                        "lockdown")
+            doc_id = "system-admin-guide"
+            uri = "ghelp:%s#lockdown" % doc_id
+
+            try:
+                gtk.show_uri (self.window.get_screen(), uri,
+                              gtk.get_current_event_time())
+            except gobject.GError, e:
+                primary = _("Could not display help document '%s'") % escape_pango (doc_id)
+                self.__error_dialog (primary, str (e))
             return
         
         dialog.hide ()
diff --git a/configure.ac b/configure.ac
index bc5cdb9..9163eb4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,8 +12,7 @@ dnl make sure we keep ACLOCAL_FLAGS around for maintainer builds to work
 AC_SUBST(ACLOCAL_AMFLAGS, "$ACLOCAL_FLAGS")
 
 PKG_CHECK_MODULES(PESSULUS,
-		  pygtk-2.0 >= 2.6.0		\
-		  gnome-python-2.0 >= 2.6.0	\
+		  pygtk-2.0 >= 2.13.0		\
 		  gnome-python-desktop-2.0 >= 2.17.2)
 
 GETTEXT_PACKAGE=pessulus



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]