[jhbuild: 43/60] [gui] do not initiate an action when selecting a error resolution



commit a29fc337bc003c35f7fb36cf2372caa4fffdf673
Author: Frédéric Péters <fpeters 0d be>
Date:   Sun May 24 10:30:06 2009 +0200

    [gui] do not initiate an action when selecting a error resolution
    
    The HIG says "Do not initiate an action when the user selects an item
    from an drop-down list"; so there is now a "Apply" button next to the
    error resolution combo box.
---
 jhbuild/frontends/gtkui.py |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/jhbuild/frontends/gtkui.py b/jhbuild/frontends/gtkui.py
index 73313b0..4328302 100644
--- a/jhbuild/frontends/gtkui.py
+++ b/jhbuild/frontends/gtkui.py
@@ -204,6 +204,9 @@ class AppWindow(gtk.Window, buildscript.BuildScript):
         self.error_label.set_alignment(0, 0.5)
 
         # label, code
+        second_hbox = gtk.HBox()
+        vbox.pack_start(second_hbox)
+
         self.error_resolution_model = gtk.ListStore(str, str)
         self.error_combo = gtk.ComboBox(self.error_resolution_model)
         self.error_combo.connect('changed', self.on_error_resolution_changed_cb)
@@ -211,7 +214,12 @@ class AppWindow(gtk.Window, buildscript.BuildScript):
         cell = gtk.CellRendererText()
         self.error_combo.pack_start(cell, True)
         self.error_combo.add_attribute(cell, 'markup', 0)
-        vbox.pack_start(self.error_combo)
+        second_hbox.pack_start(self.error_combo)
+
+        self.error_apply_button = gtk.Button(stock = gtk.STOCK_APPLY)
+        self.error_apply_button.set_sensitive(False)
+        self.error_apply_button.connect('clicked', self.on_resolution_apply_clicked)
+        second_hbox.pack_start(self.error_apply_button, fill=False, expand=False)
 
         return error_hbox
 
@@ -219,6 +227,15 @@ class AppWindow(gtk.Window, buildscript.BuildScript):
         iter = self.error_combo.get_active_iter()
         if not iter:
             return
+        if not self.error_resolution_model.get(iter, 1)[0]:
+            return
+        self.error_apply_button.set_sensitive(True)
+
+    def on_resolution_apply_clicked(self, *args):
+        self.error_apply_button.set_sensitive(False)
+        iter = self.error_combo.get_active_iter()
+        if not iter:
+            return
         self.error_resolution = self.error_resolution_model.get(iter, 1)[0]
 
     def on_help_cb(self, *args):
@@ -347,6 +364,7 @@ class AppWindow(gtk.Window, buildscript.BuildScript):
         self.error_resolution = None
 
         while True:
+            self.error_resolution = None
             while gtk.events_pending():
                 gtk.main_iteration()
                 if self.quit:



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