Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Cluster Development (http://www.linux-archive.org/cluster-development/)
-   -   Use proper store types for DataComboBoxes. (http://www.linux-archive.org/cluster-development/504578-use-proper-store-types-datacomboboxes.html)

Ales Kozumplik 03-23-2011 08:34 AM

Use proper store types for DataComboBoxes.
 
GTK has become stricter about how the values inserted into a treestore
need to adhere to the declared type of the store.

Related: rhbz#682543
---
pyanaconda/iw/datacombo.py | 14 ++++++++------
pyanaconda/iw/lvm_dialog_gui.py | 3 ++-
pyanaconda/iw/osbootwidget.py | 7 ++++---
pyanaconda/iw/partition_gui.py | 2 +-
pyanaconda/iw/raid_dialog_gui.py | 3 ++-
5 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/pyanaconda/iw/datacombo.py b/pyanaconda/iw/datacombo.py
index 9b6a092..5d27b7a 100644
--- a/pyanaconda/iw/datacombo.py
+++ b/pyanaconda/iw/datacombo.py
@@ -24,12 +24,13 @@ import gtk
import gobject

class DataComboBox(gtk.ComboBox):
- """A class derived from gtk.ComboBox to allow setting a user visible
- string and (not-visible) data string"""
+ """ A class derived from gtk.ComboBox to allow setting a user visible string
+ and (not-visible) data object.
+ """

def __init__(self, store = None):
if store is None:
- self.store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
+ self.store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
else:
self.store = store
gtk.ComboBox.__init__(self, self.store)
@@ -80,10 +81,11 @@ if __name__ == "__main__":
def mycb(widget, *args):
idx = widget.get_active()
print(idx, widget.get_stored_data(idx), widget.get_text(idx))
-
+
win = gtk.Window()

- cb = DataComboBox()
+ store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
+ cb = DataComboBox(store)
cb.append("/dev/hda5", "hda5")
cb.append("/dev/hda6", "hda6")
cb.append("/dev/hda7", "hda7")
@@ -91,7 +93,7 @@ if __name__ == "__main__":
cb.set_active_text("/dev/hda7")

cb.connect('changed', mycb)
-
+
win.add(cb)
win.show_all()

diff --git a/pyanaconda/iw/lvm_dialog_gui.py b/pyanaconda/iw/lvm_dialog_gui.py
index 389b54e..c0703e0 100644
--- a/pyanaconda/iw/lvm_dialog_gui.py
+++ b/pyanaconda/iw/lvm_dialog_gui.py
@@ -255,7 +255,8 @@ class VolumeGroupEditor:
return "%s GB" % (val/1024/1024,)

def createPEOptionMenu(self, default=4096):
- peCombo = datacombo.DataComboBox()
+ store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_INT)
+ peCombo = datacombo.DataComboBox(store)

actualPE = []
for curpe in lvm.getPossiblePhysicalExtents(floor=1024):
diff --git a/pyanaconda/iw/osbootwidget.py b/pyanaconda/iw/osbootwidget.py
index 9fc3dbd..1b18070 100644
--- a/pyanaconda/iw/osbootwidget.py
+++ b/pyanaconda/iw/osbootwidget.py
@@ -163,7 +163,8 @@ class OSBootWidget:

parts.append(part)

- deviceCombo = datacombo.DataComboBox()
+ store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
+ deviceCombo = datacombo.DataComboBox(store)
defindex = 0
i = 0
for part in parts:
@@ -174,7 +175,7 @@ class OSBootWidget:


deviceCombo.set_active(defindex)
-
+
table.attach(deviceCombo, 1, 2, 2, 3, gtk.FILL, 0, 10)
label.set_mnemonic_widget(deviceCombo)
else:
@@ -189,7 +190,7 @@ class OSBootWidget:
default.set_sensitive(False)
else:
default.set_sensitive(True)
-
+
dialog.vbox.pack_start(table)
dialog.show_all()

diff --git a/pyanaconda/iw/partition_gui.py b/pyanaconda/iw/partition_gui.py
index bb2c9fc..2a2ce97 100644
--- a/pyanaconda/iw/partition_gui.py
+++ b/pyanaconda/iw/partition_gui.py
@@ -969,7 +969,7 @@ class PartitionWindow(InstallWindow):
if vg.freeSpace > 0:
iter = self.tree.append(vgparent)
self.tree[iter]['Device'] = _("Free")
- self.tree[iter]['Size (MB)'] = vg.freeSpace
+ self.tree[iter]['Size (MB)'] = str(vg.freeSpace)
self.tree[iter]['PyObject'] = None
self.tree[iter]['Mount Point'] = ""
self.tree[iter]['IsLeaf'] = True
diff --git a/pyanaconda/iw/raid_dialog_gui.py b/pyanaconda/iw/raid_dialog_gui.py
index 731f6ee..35f23f9 100644
--- a/pyanaconda/iw/raid_dialog_gui.py
+++ b/pyanaconda/iw/raid_dialog_gui.py
@@ -100,7 +100,8 @@ class RaidEditor:
return levelcombo

def createRaidMinorMenu(self, minors, reqminor):
- minorcombo = datacombo.DataComboBox()
+ store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_INT)
+ minorcombo = datacombo.DataComboBox(store)
defindex = 0
i = 0
for minor in minors:
--
1.7.3.3

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


All times are GMT. The time now is 01:38 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.