Set background color for activity.widgets.TitleEntry

This commit is contained in:
Aleksey Lim 2009-07-31 20:05:40 +00:00
parent 45a4ed104b
commit 6e724c3d8d
2 changed files with 30 additions and 23 deletions

View File

@ -134,19 +134,28 @@ class KeepButton(ToolButton):
def __keep_button_clicked_cb(self, button, activity): def __keep_button_clicked_cb(self, button, activity):
activity.copy() activity.copy()
class TitleEntry(gtk.Entry): class TitleEntry(gtk.ToolItem):
def __init__(self, activity, **kwargs): def __init__(self, activity, **kwargs):
gtk.Entry.__init__(self, **kwargs) gtk.ToolItem.__init__(self)
self.set_expand(False)
self._update_title_sid = None self._update_title_sid = None
self.set_size_request(int(gtk.gdk.screen_width() / 3), -1) self.entry = gtk.Entry(**kwargs)
self.set_text(activity.metadata['title']) self.entry.set_size_request(int(gtk.gdk.screen_width() / 3), -1)
self.connect('changed', self.__title_changed_cb, activity) 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) 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): def __jobject_updated_cb(self, jobject):
self.set_text(jobject['title']) self.entry.set_text(jobject['title'])
def __title_changed_cb(self, entry, activity): def __title_changed_cb(self, entry, activity):
if not self._update_title_sid: if not self._update_title_sid:
@ -154,7 +163,7 @@ class TitleEntry(gtk.Entry):
1, self.__update_title_cb, activity) 1, self.__update_title_cb, activity)
def __update_title_cb(self, activity): def __update_title_cb(self, activity):
title = self.get_text() title = self.entry.get_text()
activity.metadata['title'] = title activity.metadata['title'] = title
activity.metadata['title_set_by_user'] = '1' activity.metadata['title_set_by_user'] = '1'
@ -180,8 +189,10 @@ class ActivityToolbar(gtk.Toolbar):
self._activity = activity self._activity = activity
if activity.metadata: if activity.metadata:
self.title = TitleEntry(activity) title_button = TitleEntry(activity)
self._add_widget(self.title) title_button.show()
self.insert(title_button, -1)
self.title = title_button.entry
separator = gtk.SeparatorToolItem() separator = gtk.SeparatorToolItem()
separator.props.draw = False separator.props.draw = False
@ -201,16 +212,6 @@ class ActivityToolbar(gtk.Toolbar):
self.insert(self.stop, -1) self.insert(self.stop, -1)
self.stop.show() 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): class EditToolbar(gtk.Toolbar):
"""Provides the standard edit toolbar for Activities. """Provides the standard edit toolbar for Activities.

View File

@ -210,12 +210,18 @@ class _Box(gtk.EventBox):
alloc.width - style._FOCUS_LINE_WIDTH*2, alloc.width - style._FOCUS_LINE_WIDTH*2,
style._FOCUS_LINE_WIDTH) style._FOCUS_LINE_WIDTH)
def _setup_page(page, color, hpad): def _setup_page(page_widget, color, hpad):
vpad = style._FOCUS_LINE_WIDTH vpad = style._FOCUS_LINE_WIDTH
page.child.set_padding(vpad, vpad, hpad, hpad) page_widget.child.set_padding(vpad, vpad, hpad, hpad)
page.child.child.modify_bg(gtk.STATE_NORMAL, color)
page = page_widget.child.child
page.modify_bg(gtk.STATE_NORMAL, color) 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): def _embody_page(box_class, widget):
widget.show() widget.show()