FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora Development

 
 
LinkBack Thread Tools
 
Old 04-30-2010, 12:16 PM
Ales Kozumplik
 
Default gui: gray out OK button while adding raid set (#587161).

This has a tricky part: the checkbox toggle callback in our implementation
(WideCheckList.toggled_item) is called *before* the actual toggle
occurs. This has to be considered in the button-enabling code. An
alternative would be to change/extend the toggle callback hook mechanism.
---
iw/raid_dialog_gui.py | 36 ++++++++++++++++++++++++++++++++++--
1 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/iw/raid_dialog_gui.py b/iw/raid_dialog_gui.py
index 8e31767..2e11cb5 100644
--- a/iw/raid_dialog_gui.py
+++ b/iw/raid_dialog_gui.py
@@ -45,7 +45,8 @@ class RaidEditor:
store = gtk.TreeStore(gobject.TYPE_BOOLEAN,
gobject.TYPE_STRING,
gobject.TYPE_STRING)
- partlist = WideCheckList(2, store)
+ partlist = WideCheckList(2, store,
+ clickCB=self.raidlist_toggle_callback)

sw = gtk.ScrolledWindow()
sw.add(partlist)
@@ -137,6 +138,7 @@ class RaidEditor:
return []

while 1:
+ self.allow_ok_button()
rc = self.dialog.run()

# user hit cancel, do nothing
@@ -400,7 +402,7 @@ class RaidEditor:
dialog = gtk.Dialog(tstr, self.parent)
gui.addFrame(dialog)
dialog.add_button('gtk-cancel', 2)
- dialog.add_button('gtk-ok', 1)
+ self.ok_button = dialog.add_button('gtk-ok', 1)
dialog.set_position(gtk.WIN_POS_CENTER)

maintable = gtk.Table()
@@ -576,7 +578,37 @@ class RaidEditor:
self.dialog = dialog
return

+ def allow_ok_button(self, path=None):
+ """
+ Determine if the OK button should be enabled.
+
+ If path is given it points to the row where the toggle state is about to
+ change.
+ """
+ model = self.raidlist.get_model()
+ allow = False
+ iter = model.get_iter_first()
+ toggled_iter = None
+ if path:
+ toggled_iter = model.get_iter(path)
+ while iter:
+ val = model.get_value(iter, 0)
+ if toggled_iter and
+ model.get_value(toggled_iter, 1) ==
+ model.get_value(iter, 1):
+ # this is being toggled, negate the value:
+ if not val:
+ allow = True
+ else:
+ if val:
+ allow = True
+ iter = model.iter_next(iter)
+
+ self.ok_button.set_sensitive(allow)

+ def raidlist_toggle_callback(self, data, path):
+ self.allow_ok_button(path)
+ return 1

class RaidCloneDialog:
def createDriveList(self, disks):
--
1.6.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 04-30-2010, 08:10 PM
David Cantrell
 
Default gui: gray out OK button while adding raid set (#587161).

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ack with one minor nit below.

On Fri, 30 Apr 2010, Ales Kozumplik wrote:


This has a tricky part: the checkbox toggle callback in our implementation
(WideCheckList.toggled_item) is called *before* the actual toggle
occurs. This has to be considered in the button-enabling code. An
alternative would be to change/extend the toggle callback hook mechanism.
---
iw/raid_dialog_gui.py | 36 ++++++++++++++++++++++++++++++++++--
1 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/iw/raid_dialog_gui.py b/iw/raid_dialog_gui.py
index 8e31767..2e11cb5 100644
--- a/iw/raid_dialog_gui.py
+++ b/iw/raid_dialog_gui.py
@@ -45,7 +45,8 @@ class RaidEditor:
store = gtk.TreeStore(gobject.TYPE_BOOLEAN,
gobject.TYPE_STRING,
gobject.TYPE_STRING)
- partlist = WideCheckList(2, store)
+ partlist = WideCheckList(2, store,
+ clickCB=self.raidlist_toggle_callback)

sw = gtk.ScrolledWindow()
sw.add(partlist)
@@ -137,6 +138,7 @@ class RaidEditor:
return []

while 1:
+ self.allow_ok_button()
rc = self.dialog.run()


This while block uses tab to indent, please follow that.


# user hit cancel, do nothing
@@ -400,7 +402,7 @@ class RaidEditor:
dialog = gtk.Dialog(tstr, self.parent)
gui.addFrame(dialog)
dialog.add_button('gtk-cancel', 2)
- dialog.add_button('gtk-ok', 1)
+ self.ok_button = dialog.add_button('gtk-ok', 1)
dialog.set_position(gtk.WIN_POS_CENTER)

maintable = gtk.Table()
@@ -576,7 +578,37 @@ class RaidEditor:
self.dialog = dialog
return

+ def allow_ok_button(self, path=None):
+ """
+ Determine if the OK button should be enabled.
+
+ If path is given it points to the row where the toggle state is about to
+ change.
+ """
+ model = self.raidlist.get_model()
+ allow = False
+ iter = model.get_iter_first()
+ toggled_iter = None
+ if path:
+ toggled_iter = model.get_iter(path)
+ while iter:
+ val = model.get_value(iter, 0)
+ if toggled_iter and
+ model.get_value(toggled_iter, 1) ==
+ model.get_value(iter, 1):
+ # this is being toggled, negate the value:
+ if not val:
+ allow = True
+ else:
+ if val:
+ allow = True
+ iter = model.iter_next(iter)
+
+ self.ok_button.set_sensitive(allow)

+ def raidlist_toggle_callback(self, data, path):
+ self.allow_ok_button(path)
+ return 1

class RaidCloneDialog:
def createDriveList(self, disks):



- --
David Cantrell <dcantrell@redhat.com>

Red Hat / Honolulu, HI

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkvbOUkACgkQ5hsjjIy1VkkK8ACdHUgf5R7MSm o23c9drScGZuLe
njMAnjaFXAxTROfIZNzFT8Ozikc/SjjF
=7dZw
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 03:19 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org