[pybliographer/wip/gtk3] gnomeui: Migate gnome_app_warning to GtkMessageDialog



commit 8e295c801c65ac95de62d7577da3019bd4dbc567
Author: Germán Poo-Caamaño <gpoo gnome org>
Date:   Tue Oct 10 17:24:37 2017 -0300

    gnomeui: Migate gnome_app_warning to GtkMessageDialog

 Pyblio/GnomeUI/Config.py |   12 +++++-------
 Pyblio/GnomeUI/Fields.py |   16 +++++++---------
 Pyblio/GnomeUI/Utils.py  |   10 ++++++++++
 3 files changed, 22 insertions(+), 16 deletions(-)
---
diff --git a/Pyblio/GnomeUI/Config.py b/Pyblio/GnomeUI/Config.py
index 4d22c2a..6cda7cd 100644
--- a/Pyblio/GnomeUI/Config.py
+++ b/Pyblio/GnomeUI/Config.py
@@ -53,7 +53,7 @@ class ConfigDialog (Utils.GladeWindow):
 
         content.pack_start (self.w, True, True, 0)
         
-        self.warning = 0
+        self.warning = False
         self.parent = parent
         
         domains = Config.domains ()
@@ -128,13 +128,11 @@ class ConfigDialog (Utils.GladeWindow):
     def show (self):
         self.dialog.show_all()
         
-    def changed (self):
+    def changed(self):
         if not self.warning:
-            self.warning = 1
-            self.parent.warning (
-                _("Some changes require to restart Pybliographic\n"
-                  "to be correctly taken into account"))
-
+            self.warning = True
+            Utils.warning_dialog_s(self.parent, _("Some changes require to restart Pybliographic\n"
+                                   "to be correctly taken into account"))
 
 class BaseConfig:
     def __init__ (self, dtype, props, key, parent=None, help_text=''):
diff --git a/Pyblio/GnomeUI/Fields.py b/Pyblio/GnomeUI/Fields.py
index e93c1ae..ec94b1b 100644
--- a/Pyblio/GnomeUI/Fields.py
+++ b/Pyblio/GnomeUI/Fields.py
@@ -63,7 +63,7 @@ class FieldsDialog (Utils.GladeWindow):
         self.w = self.xml.get_object('notebook')
 
         self.menu_items = []
-        self.warning = 0
+        self.warning = False
         self.parent = parent
         self.init_page_1()
         self.init_page_2()
@@ -412,18 +412,16 @@ class FieldsDialog (Utils.GladeWindow):
         return
 
 
-    def apply (self, * arg):
-        if not self.changed: return
-        
-        result = self.get ()
+    def apply(self, *arg):
+        if not self.changed:
+            return
         
-        Config.set_and_save ('base/fields', result)
+        result = self.get()
+        Config.set_and_save('base/fields', result)
 
         if self.parent:
-            self.parent.warning (_("Some changes require to restart Pybliographic\n"
+            Utils.warning_dialog_s(self.parent, _("Some changes require to restart Pybliographic\n"
                                    "to be correctly taken into account"))
-        return
-
 
     def add_cb (self, * arg):
         name = string.strip (self.name.get_text ())
diff --git a/Pyblio/GnomeUI/Utils.py b/Pyblio/GnomeUI/Utils.py
index 2961265..8cdae7b 100644
--- a/Pyblio/GnomeUI/Utils.py
+++ b/Pyblio/GnomeUI/Utils.py
@@ -213,3 +213,13 @@ def error_dialog_s(parent, primary, secondary=None):
         dialog.format_secondary_text(secondary)
     dialog.run()
     dialog.destroy()
+
+def warning_dialog_s(parent, primary, secondary=None):
+    dialog = Gtk.MessageDialog(parent,
+                               Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT,
+                               Gtk.MessageType.WARNING,
+                               Gtk.ButtonsType.CLOSE, primary)
+    if secondary:
+        dialog.format_secondary_text(secondary)
+    dialog.run()
+    dialog.destroy()


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