From 9e3a8ab007dc6b5ad3429bae5b2e7979139c6eb8 Mon Sep 17 00:00:00 2001 From: Simon Schampijer Date: Mon, 19 Jan 2009 16:57:59 +0100 Subject: [PATCH] enhancements to the naming alert - focus the title entry - add accelerator for the 'Keep' button which is enter/return --- src/sugar/activity/namingalert.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/sugar/activity/namingalert.py b/src/sugar/activity/namingalert.py index 84705424..400d4ab7 100644 --- a/src/sugar/activity/namingalert.py +++ b/src/sugar/activity/namingalert.py @@ -62,8 +62,8 @@ class NamingToolbar(gtk.Toolbar): self._add_separator(True) - self._keep_button = ToolButton('dialog-ok') - self._keep_button.set_tooltip(_('Keep')) + self._keep_button = ToolButton('dialog-ok', tooltip=_('Keep')) + self._keep_button.props.accelerator = 'Return' self._keep_button.connect('clicked', self.__keep_button_clicked_cb) self.insert(self._keep_button, -1) self._keep_button.show() @@ -142,6 +142,10 @@ class NamingAlert(gtk.Window): self._description = None self._tags = None + accel_group = gtk.AccelGroup() + self.set_data('sugar-accel-group', accel_group) + self.add_accel_group(accel_group) + self.set_border_width(style.LINE_WIDTH) offset = style.GRID_CELL_SIZE width = gtk.gdk.screen_width() - offset * 2 @@ -174,6 +178,9 @@ class NamingAlert(gtk.Window): body = self._create_body() self._root.append(body, hippo.PACK_EXPAND) + widget = self._title.get_property('widget') + widget.grab_focus() + def _create_body(self): body = hippo.CanvasBox() body.props.orientation = hippo.ORIENTATION_VERTICAL @@ -240,7 +247,7 @@ class NamingAlert(gtk.Window): title.set_background(style.COLOR_WHITE.get_html()) title.props.text = self._activity.metadata.get('title', _('Untitled')) return title - + def _create_description(self): vbox = hippo.CanvasBox() vbox.props.spacing = style.DEFAULT_SPACING