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 > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 03-30-2012, 07:55 PM
Vratislav Podzimek
 
Default Add days and cities filters

---
pyanaconda/ui/gui/spokes/datetime_spoke.py | 50 +++++++++++++++++++++++++--
pyanaconda/ui/gui/spokes/datetime_spoke.ui | 7 +---
2 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/datetime_spoke.py b/pyanaconda/ui/gui/spokes/datetime_spoke.py
index 598d488..65b35c2 100644
--- a/pyanaconda/ui/gui/spokes/datetime_spoke.py
+++ b/pyanaconda/ui/gui/spokes/datetime_spoke.py
@@ -35,10 +35,14 @@ import datetime
__all__ = ["DatetimeSpoke"]

class DatetimeSpoke(NormalSpoke):
- builderObjects = ["datetimeWindow", "days", "months", "years", "regions",
- "cities", "upImage", "upImage1", "upImage2", "downImage",
- "downImage1", "downImage2", "downImage3", "citiesFilter",
- "daysFilter", "citiesSort", "regionsSort"]
+ builderObjects = ["datetimeWindow",
+ "days", "months", "years", "regions", "cities",
+ "upImage", "upImage1", "upImage2", "downImage",
+ "downImage1", "downImage2", "downImage3",
+ "citiesFilter", "daysFilter", "citiesSort", "regionsSort",
+ "regionCombobox", "cityCombobox", "monthCombobox",
+ "dayCombobox", "yearCombobox"]
+
mainWidgetName = "datetimeWindow"
uiFile = "spokes/datetime_spoke.ui"

@@ -80,6 +84,18 @@ class DatetimeSpoke(NormalSpoke):
for city in self._regions_zones[region]:
self.add_to_store(self._citiesStore, city)

+ self._regionCombo = self.builder.get_object("regionCombobox")
+ self._cityCombo = self.builder.get_object("cityCombobox")
+ self._monthCombo = self.builder.get_object("monthCombobox")
+ self._dayCombo = self.builder.get_object("dayCombobox")
+ self._yearCombo = self.builder.get_object("yearCombobox")
+
+ self._daysFilter = self.builder.get_object("daysFilter")
+ self._daysFilter.set_visible_func(self.existing_da te, None)
+
+ self._citiesFilter = self.builder.get_object("citiesFilter")
+ self._citiesFilter.set_visible_func(self.city_in_r egion, None)
+
self._tzmap.set_timezone("Europe/Prague")

@property
@@ -100,3 +116,29 @@ class DatetimeSpoke(NormalSpoke):

def add_to_store(self, store, item):
store.append([item])
+
+ def existing_date(self, model, itr, user_data=None):
+ day = model[itr][0]
+ months_model = self._monthCombo.get_model()
+ months_iter = self._monthCombo.get_active_iter()
+ month = months_model[months_iter][0]
+
+ years_model = self._yearCombo.get_model()
+ years_iter = self._yearCombo.get_active_iter()
+ year = years_model[years_iter][0]
+
+ try:
+ if not month:
+ return False
+ datetime.date(year, self._months_nums[month], day)
+ return True
+ except ValueError as valerr:
+ return False
+
+ def city_in_region(self, model, itr, user_data=None):
+ city = model[itr][0]
+ regions_model = self._regionCombo.get_model()
+ regions_iter = self._regionCombo.get_active_iter()
+ region = regions_model[regions_iter][0]
+
+ return city in self._regions_zones[region]
diff --git a/pyanaconda/ui/gui/spokes/datetime_spoke.ui b/pyanaconda/ui/gui/spokes/datetime_spoke.ui
index 8ca1876..0aa0af3 100644
--- a/pyanaconda/ui/gui/spokes/datetime_spoke.ui
+++ b/pyanaconda/ui/gui/spokes/datetime_spoke.ui
@@ -81,7 +81,7 @@
<object class="GtkComboBox" id="regionCombobox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="model">regionsFilter</property>
+ <property name="model">regionsSort</property>
<child>
<object class="GtkCellRendererText" id="regionsComboRenderer"/>
<attributes>
@@ -589,11 +589,8 @@
<column type="gchararray"/>
</columns>
</object>
- <object class="GtkTreeModelFilter" id="regionsFilter">
- <property name="child_model">regions</property>
- </object>
<object class="GtkTreeModelSort" id="regionsSort">
- <property name="model">regionsFilter</property>
+ <property name="model">regions</property>
</object>
<object class="GtkImage" id="upImage">
<property name="visible">True</property>
--
1.7.4.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 04-02-2012, 03:13 PM
Vratislav Podzimek
 
Default Add days and cities filters

---
pyanaconda/ui/gui/spokes/datetime_spoke.py | 56 ++++++++++++++++++++++++++--
pyanaconda/ui/gui/spokes/datetime_spoke.ui | 7 +--
2 files changed, 54 insertions(+), 9 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/datetime_spoke.py b/pyanaconda/ui/gui/spokes/datetime_spoke.py
index 598d488..bed4ddc 100644
--- a/pyanaconda/ui/gui/spokes/datetime_spoke.py
+++ b/pyanaconda/ui/gui/spokes/datetime_spoke.py
@@ -35,10 +35,13 @@ import datetime
__all__ = ["DatetimeSpoke"]

class DatetimeSpoke(NormalSpoke):
- builderObjects = ["datetimeWindow", "days", "months", "years", "regions",
- "cities", "upImage", "upImage1", "upImage2", "downImage",
- "downImage1", "downImage2", "downImage3", "citiesFilter",
- "daysFilter", "citiesSort", "regionsSort"]
+ builderObjects = ["datetimeWindow",
+ "days", "months", "years", "regions", "cities",
+ "upImage", "upImage1", "upImage2", "downImage",
+ "downImage1", "downImage2", "downImage3",
+ "citiesFilter", "daysFilter", "citiesSort", "regionsSort",
+ ]
+
mainWidgetName = "datetimeWindow"
uiFile = "spokes/datetime_spoke.ui"

@@ -80,6 +83,18 @@ class DatetimeSpoke(NormalSpoke):
for city in self._regions_zones[region]:
self.add_to_store(self._citiesStore, city)

+ self._regionCombo = self.builder.get_object("regionCombobox")
+ self._cityCombo = self.builder.get_object("cityCombobox")
+ self._monthCombo = self.builder.get_object("monthCombobox")
+ self._dayCombo = self.builder.get_object("dayCombobox")
+ self._yearCombo = self.builder.get_object("yearCombobox")
+
+ self._daysFilter = self.builder.get_object("daysFilter")
+ self._daysFilter.set_visible_func(self.existing_da te, None)
+
+ self._citiesFilter = self.builder.get_object("citiesFilter")
+ self._citiesFilter.set_visible_func(self.city_in_r egion, None)
+
self._tzmap.set_timezone("Europe/Prague")

@property
@@ -100,3 +115,36 @@ class DatetimeSpoke(NormalSpoke):

def add_to_store(self, store, item):
store.append([item])
+
+ def existing_date(self, model, itr, user_data=None):
+ day = model[itr][0]
+
+ #days 1-28 are in every month every year
+ if day < 29:
+ return True
+
+ months_model = self._monthCombo.get_model()
+ months_iter = self._monthCombo.get_active_iter()
+ if not months_iter:
+ return True
+ month = months_model[months_iter][0]
+
+ years_model = self._yearCombo.get_model()
+ years_iter = self._yearCombo.get_active_iter()
+ if not years_iter:
+ return True
+ year = years_model[years_iter][0]
+
+ try:
+ datetime.date(year, self._months_nums[month], day)
+ return True
+ except ValueError as valerr:
+ return False
+
+ def city_in_region(self, model, itr, user_data=None):
+ city = model[itr][0]
+ regions_model = self._regionCombo.get_model()
+ regions_iter = self._regionCombo.get_active_iter()
+ region = regions_model[regions_iter][0]
+
+ return city in self._regions_zones[region]
diff --git a/pyanaconda/ui/gui/spokes/datetime_spoke.ui b/pyanaconda/ui/gui/spokes/datetime_spoke.ui
index 8ca1876..0aa0af3 100644
--- a/pyanaconda/ui/gui/spokes/datetime_spoke.ui
+++ b/pyanaconda/ui/gui/spokes/datetime_spoke.ui
@@ -81,7 +81,7 @@
<object class="GtkComboBox" id="regionCombobox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="model">regionsFilter</property>
+ <property name="model">regionsSort</property>
<child>
<object class="GtkCellRendererText" id="regionsComboRenderer"/>
<attributes>
@@ -589,11 +589,8 @@
<column type="gchararray"/>
</columns>
</object>
- <object class="GtkTreeModelFilter" id="regionsFilter">
- <property name="child_model">regions</property>
- </object>
<object class="GtkTreeModelSort" id="regionsSort">
- <property name="model">regionsFilter</property>
+ <property name="model">regions</property>
</object>
<object class="GtkImage" id="upImage">
<property name="visible">True</property>
--
1.7.4.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 04-02-2012, 03:41 PM
Chris Lumens
 
Default Add days and cities filters

> @@ -100,3 +115,36 @@ class DatetimeSpoke(NormalSpoke):
>
> def add_to_store(self, store, item):
> store.append([item])
> +
> + def existing_date(self, model, itr, user_data=None):
> + day = model[itr][0]

You should be defensive here and consider the possibility that itr is
none (like in the case where the user ctrl-clicked on the current
selection and unselected everything, among others).

> + def city_in_region(self, model, itr, user_data=None):
> + city = model[itr][0]
> + regions_model = self._regionCombo.get_model()
> + regions_iter = self._regionCombo.get_active_iter()
> + region = regions_model[regions_iter][0]

Same here with itr and regions_itr.

- Chris

_______________________________________________
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 10:41 PM.

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