Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2009-07-31 20:05:40 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2009-08-01 11:23:20 (GMT)
commit6e724c3d8d0ff7ce42b50a6459e523a0fbe39fa4 (patch)
tree731cfe305a52da9f0fdf6ced5fc35103bf482030
parent45a4ed104b40b47b5b04ddfa3bd9e36a72e0c960 (diff)
Set background color for activity.widgets.TitleEntry
-rw-r--r--src/sugar/activity/widgets.py39
-rw-r--r--src/sugar/graphics/toolbarbox.py14
2 files changed, 30 insertions, 23 deletions
diff --git a/src/sugar/activity/widgets.py b/src/sugar/activity/widgets.py
index 8485605..123e6ec 100644
--- a/src/sugar/activity/widgets.py
+++ b/src/sugar/activity/widgets.py
@@ -134,19 +134,28 @@ class KeepButton(ToolButton):
def __keep_button_clicked_cb(self, button, activity):
activity.copy()
-class TitleEntry(gtk.Entry):
+class TitleEntry(gtk.ToolItem):
def __init__(self, activity, **kwargs):
- gtk.Entry.__init__(self, **kwargs)
+ gtk.ToolItem.__init__(self)
+ self.set_expand(False)
self._update_title_sid = None
- self.set_size_request(int(gtk.gdk.screen_width() / 3), -1)
- self.set_text(activity.metadata['title'])
- self.connect('changed', self.__title_changed_cb, activity)
+ self.entry = gtk.Entry(**kwargs)
+ self.entry.set_size_request(int(gtk.gdk.screen_width() / 3), -1)
+ self.entry.set_text(activity.metadata['title'])
+ self.entry.connect('changed', self.__title_changed_cb, activity)
+ self.entry.show()
+ self.add(self.entry)
activity.metadata.connect('updated', self.__jobject_updated_cb)
+ def modify_bg(self, state, color):
+ gtk.ToolItem.modify_bg(self, state, color)
+ if state == gtk.STATE_NORMAL:
+ self.entry.modify_bg(gtk.STATE_INSENSITIVE, color)
+
def __jobject_updated_cb(self, jobject):
- self.set_text(jobject['title'])
+ self.entry.set_text(jobject['title'])
def __title_changed_cb(self, entry, activity):
if not self._update_title_sid:
@@ -154,7 +163,7 @@ class TitleEntry(gtk.Entry):
1, self.__update_title_cb, activity)
def __update_title_cb(self, activity):
- title = self.get_text()
+ title = self.entry.get_text()
activity.metadata['title'] = title
activity.metadata['title_set_by_user'] = '1'
@@ -180,8 +189,10 @@ class ActivityToolbar(gtk.Toolbar):
self._activity = activity
if activity.metadata:
- self.title = TitleEntry(activity)
- self._add_widget(self.title)
+ title_button = TitleEntry(activity)
+ title_button.show()
+ self.insert(title_button, -1)
+ self.title = title_button.entry
separator = gtk.SeparatorToolItem()
separator.props.draw = False
@@ -201,16 +212,6 @@ class ActivityToolbar(gtk.Toolbar):
self.insert(self.stop, -1)
self.stop.show()
- def _add_widget(self, widget, expand=False):
- tool_item = gtk.ToolItem()
- tool_item.set_expand(expand)
-
- tool_item.add(widget)
- widget.show()
-
- self.insert(tool_item, -1)
- tool_item.show()
-
class EditToolbar(gtk.Toolbar):
"""Provides the standard edit toolbar for Activities.
diff --git a/src/sugar/graphics/toolbarbox.py b/src/sugar/graphics/toolbarbox.py
index f2f3ef8..2344b53 100644
--- a/src/sugar/graphics/toolbarbox.py
+++ b/src/sugar/graphics/toolbarbox.py
@@ -210,12 +210,18 @@ class _Box(gtk.EventBox):
alloc.width - style._FOCUS_LINE_WIDTH*2,
style._FOCUS_LINE_WIDTH)
-def _setup_page(page, color, hpad):
+def _setup_page(page_widget, color, hpad):
vpad = style._FOCUS_LINE_WIDTH
- page.child.set_padding(vpad, vpad, hpad, hpad)
- page.child.child.modify_bg(gtk.STATE_NORMAL, color)
+ page_widget.child.set_padding(vpad, vpad, hpad, hpad)
+
+ page = page_widget.child.child
page.modify_bg(gtk.STATE_NORMAL, color)
- page.modify_bg(gtk.STATE_PRELIGHT, color)
+ if isinstance(page, gtk.Container):
+ for i in page.get_children():
+ i.modify_bg(gtk.STATE_NORMAL, color)
+
+ page_widget.modify_bg(gtk.STATE_NORMAL, color)
+ page_widget.modify_bg(gtk.STATE_PRELIGHT, color)
def _embody_page(box_class, widget):
widget.show()