Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2011-08-04 21:23:58 (GMT)
committer Rafael Ortiz <rafael@activitycentral.com>2011-08-07 03:17:07 (GMT)
commit3dfc846d290ea1239516f5cf06687a4996af7b82 (patch)
treef75d476d2895ed396ffd9334ece4c9fead6ddd23
parent394413a48ab840ecc443b1e3ef9494f5e11cb30c (diff)
fix problem with invisible labels on Atmossphere toolbar
Signed-off-by: Rafael Ortiz <rafael@activitycentral.com>
-rw-r--r--activity.py7
-rw-r--r--atm_toolbars.py82
2 files changed, 48 insertions, 41 deletions
diff --git a/activity.py b/activity.py
index daa25b1..b6c06b3 100644
--- a/activity.py
+++ b/activity.py
@@ -120,10 +120,9 @@ class AcousticMeasureActivity(activity.Activity):
self._t_h_bar = atm_toolbars.TempToolbar()
tb = gtk.HBox()
- self._t_h_bar.bigbox.reparent(tb)
- self._t_h_bar.bigbox.show_all()
- adj_button = ToolbarButton(page=tb,
- icon_name='preferences-system')
+ self._t_h_bar.show_all()
+ adj_button = ToolbarButton(page=self._t_h_bar,
+ icon_name='preferences-system')
toolbar_box.toolbar.insert(adj_button, -1)
adj_button.show()
diff --git a/atm_toolbars.py b/atm_toolbars.py
index 7b8ca36..1b6f972 100644
--- a/atm_toolbars.py
+++ b/atm_toolbars.py
@@ -18,7 +18,42 @@ import gtk
import gobject
import arange
import locale
-from gettext import gettext
+from gettext import gettext as _
+
+
+def _label_factory(label, toolbar):
+ ''' Factory for adding a label to a toolbar '''
+ my_label = gtk.Label(label)
+ my_label.set_line_wrap(True)
+ my_label.show()
+ _toolitem = gtk.ToolItem()
+ _toolitem.add(my_label)
+ toolbar.insert(_toolitem, -1)
+ _toolitem.show()
+ return my_label
+
+
+def _entry_factory(length, toolbar, callback):
+ ''' Factory for adding a text enrty to a toolbar '''
+ my_entry = gtk.Entry()
+ my_entry.set_max_length(length)
+ my_entry.set_width_chars(length)
+ my_entry.connect('changed', callback)
+ my_entry.show()
+ _toolitem = gtk.ToolItem()
+ _toolitem.add(my_entry)
+ toolbar.insert(_toolitem, -1)
+ _toolitem.show()
+ return my_entry
+
+
+def _separator_factory(toolbar, expand=False, visible=False):
+ """ add a separator to a toolbar """
+ _separator = gtk.SeparatorToolItem()
+ _separator.props.draw = visible
+ _separator.set_expand(expand)
+ toolbar.insert(_separator, -1)
+ _separator.show()
class TempToolbar(gtk.Toolbar):
@@ -27,49 +62,22 @@ class TempToolbar(gtk.Toolbar):
def __init__(self):
gtk.Toolbar.__init__(self)
- temp_label = gtk.Label(gettext("Temperature (C): "))
- self._temp_field = gtk.Entry()
- self._temp_field.set_max_length(6)
- self._temp_field.set_width_chars(6)
- self._temp_field.connect("changed", self._update_cb)
+ temp_label = _label_factory(_("Temperature (C): "), self)
+ self._temp_field = _entry_factory(6, self, self._update_cb)
- temp_group = gtk.HBox()
- temp_group.pack_start(temp_label, expand=False, fill=False)
- temp_group.pack_end(self._temp_field, expand=False, fill=False)
-
- humid_label = gtk.Label(gettext("Relative Humidity (%): "))
- self._humid_field = gtk.Entry()
- self._humid_field.set_max_length(5)
- self._humid_field.set_width_chars(5)
- self._humid_field.connect("changed", self._update_cb)
-
- humid_group = gtk.HBox()
- humid_group.pack_start(humid_label, expand=False, fill=False)
- humid_group.pack_end(self._humid_field, expand=False, fill=False)
-
- result_label = gtk.Label(gettext("Speed of Sound (m/s): "))
- self._result = gtk.Label()
-
- result_group = gtk.HBox()
- result_group.pack_start(result_label, expand=False, fill=False)
- result_group.pack_end(self._result, expand=False, fill=False)
-
- self.bigbox = gtk.HBox()
+ _separator_factory(self)
+
+ humid_label = _label_factory(_("Relative Humidity (%): "), self)
+ self._humid_field = _entry_factory(5, self, self._update_cb)
- self.bigbox.pack_start(temp_group, expand=False, fill=False)
- self.bigbox.pack_start(humid_group, expand=True, fill=False)
- self.bigbox.pack_end(result_group, expand=False, fill=False)
+ _separator_factory(self)
+
+ self._result = _label_factory(_("Speed of Sound (m/s): "), self)
self.set_temp(25)
self.set_humid(60)
self.update_speed()
- tool_item = gtk.ToolItem()
- tool_item.add(self.bigbox)
- tool_item.set_expand(True)
- self.insert(tool_item, 0)
- tool_item.show()
-
def get_temp(self):
try:
t = locale.atof(self._temp_field.get_text())