Reimplement the favorite icon as a ToggleButton, and use standard
boxes, entrys and textviews for the other aspects.
---
src/sugar/activity/namingalert.py | 227 +++--
1 files changed, 90 insertions(+), 137 deletions(-)
I know there is some discussion around removing this dialog, but to
keep things moving and unblocked on the hippo removal front, here is
a quick port.
For correct visual appearance, depends on:
[PATCH sugar-artwork] Add style for naming alert
diff --git a/src/sugar/activity/namingalert.py
b/src/sugar/activity/namingalert.py
index c3d45df..80d3e14 100644
--- a/src/sugar/activity/namingalert.py
+++ b/src/sugar/activity/namingalert.py
@@ -21,17 +21,13 @@ import os
import gio
import gtk
import gobject
-import hippo
import gconf
from sugar.graphics import style
from sugar.graphics.icon import Icon
from sugar.graphics.xocolor import XoColor
-from sugar.graphics.icon import CanvasIcon
from sugar.graphics.icon import get_icon_file_name
-from sugar.graphics.entry import CanvasEntry
from sugar.graphics.toolbutton import ToolButton
-from sugar.graphics.canvastextview import CanvasTextView
from sugar.bundle.activitybundle import ActivityBundle
@@ -114,45 +110,37 @@ class NamingToolbar(gtk.Toolbar):
self.emit('keep-clicked')
-class FavoriteIcon(CanvasIcon):
+class FavoriteIcon(gtk.ToggleButton):
-def __init__(self, favorite):
-CanvasIcon.__init__(self, icon_name='emblem-favorite',
-box_width=style.GRID_CELL_SIZE * 3 / 5,
-size=style.SMALL_ICON_SIZE)
-self._favorite = None
-self.set_favorite(favorite)
-self.connect('button-release-event', self.__release_event_cb)
-self.connect('motion-notify-event', self.__motion_notify_event_cb)
+def __init__(self):
+gtk.ToggleButton.__init__(self)
+self.set_relief(gtk.RELIEF_NONE)
+self.set_focus_on_click(False)
+
+self._icon = Icon(icon_name='emblem-favorite',
+ pixel_size=style.SMALL_ICON_SIZE)
+self.set_image(self._icon)
-def set_favorite(self, favorite):
-if favorite == self._favorite:
-return
+self.connect('toggled', self.__toggled_cb)
+self.connect('leave-notify-event', self.__leave_notify_event_cb)
+self.connect('enter-notify-event', self.__enter_notify_event_cb)
-self._favorite = favorite
-if favorite:
+def __toggled_cb(self, widget):
+if self.get_active():
client = gconf.client_get_default()
color = XoColor(client.get_string('/desktop/sugar/user/color'))
-self.props.xo_color = color
+self._icon.props.xo_color = color
else:
-self.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
-self.props.fill_color = style.COLOR_WHITE.get_svg()
-
-def get_favorite(self):
-return self._favorite
-
-favorite = gobject.property(
-type=bool, default=False, getter=get_favorite, setter=set_favorite)
+self._icon.props.stroke_color = style.COLOR_BUTTON_GREY.get_svg()
+self._icon.props.fill_color = style.COLOR_WHITE.get_svg()
-def __release_event_cb(self, icon, event):
-self.props.favorite = not self.props.favorite
+def __enter_notify_event_cb(self, icon, event):
+if not self.get_active():
+self._icon.props.fill_color = style.COLOR_BUTTON_GREY.get_svg()
-def __motion_notify_event_cb(self, icon, event):
-if not self._favorite:
-if event.detail == hippo.MOTION_DETAIL_ENTER:
-icon.props.fill_color = style.COLOR_BUTTON_GREY.get_svg()
-elif event.detail == hippo.MOTION_DETAIL_LEAVE:
-icon.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
+def __leave_notify_event_cb(self, icon, event):
+if not self.get_active():
+self._icon.props.fill_color = style.COLOR_TRANSPARENT.get_svg()
class NamingAlert(gtk.Window):
@@ -194,71 +182,66 @@ class NamingAlert(gtk.Window):
vbox.pack_start(toolbar, False)
toolbar.show()
-canvas = hippo.Canvas()
-self._root = hippo.CanvasBox()
-self._root.props.background_color = style.COLOR_WHITE.get_int()
-canvas.set_root(self._root)
-vbox.pack_start(canvas)
-canvas.show()
-
body = self._create_body()
-self._root.append(body, hippo.PACK_EXPAND)
+vbox.pack_start(body, expand=True, fill=True)
+body.show()
-widget = self._title.get_property('widget')
-widget.grab_focus()
+self._title.grab_focus()
def _create_body(self):
-body = hippo.CanvasBox()
-body.props.orientation = hippo.ORIENTATION_VERTICAL
-body.props.background_color = style.COLOR_WHITE.get_int()
-body.props.padding_top = style.DEFAULT_SPACING * 3
+body =