enhancements to the naming alert

- focus the title entry
- add accelerator for the 'Keep' button which is enter/return
This commit is contained in:
Simon Schampijer 2009-01-19 16:57:59 +01:00
parent 817a981288
commit 9e3a8ab007

View File

@ -62,8 +62,8 @@ class NamingToolbar(gtk.Toolbar):
self._add_separator(True) self._add_separator(True)
self._keep_button = ToolButton('dialog-ok') self._keep_button = ToolButton('dialog-ok', tooltip=_('Keep'))
self._keep_button.set_tooltip(_('Keep')) self._keep_button.props.accelerator = 'Return'
self._keep_button.connect('clicked', self.__keep_button_clicked_cb) self._keep_button.connect('clicked', self.__keep_button_clicked_cb)
self.insert(self._keep_button, -1) self.insert(self._keep_button, -1)
self._keep_button.show() self._keep_button.show()
@ -142,6 +142,10 @@ class NamingAlert(gtk.Window):
self._description = None self._description = None
self._tags = 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) self.set_border_width(style.LINE_WIDTH)
offset = style.GRID_CELL_SIZE offset = style.GRID_CELL_SIZE
width = gtk.gdk.screen_width() - offset * 2 width = gtk.gdk.screen_width() - offset * 2
@ -174,6 +178,9 @@ class NamingAlert(gtk.Window):
body = self._create_body() body = self._create_body()
self._root.append(body, hippo.PACK_EXPAND) self._root.append(body, hippo.PACK_EXPAND)
widget = self._title.get_property('widget')
widget.grab_focus()
def _create_body(self): def _create_body(self):
body = hippo.CanvasBox() body = hippo.CanvasBox()
body.props.orientation = hippo.ORIENTATION_VERTICAL body.props.orientation = hippo.ORIENTATION_VERTICAL
@ -240,7 +247,7 @@ class NamingAlert(gtk.Window):
title.set_background(style.COLOR_WHITE.get_html()) title.set_background(style.COLOR_WHITE.get_html())
title.props.text = self._activity.metadata.get('title', _('Untitled')) title.props.text = self._activity.metadata.get('title', _('Untitled'))
return title return title
def _create_description(self): def _create_description(self):
vbox = hippo.CanvasBox() vbox = hippo.CanvasBox()
vbox.props.spacing = style.DEFAULT_SPACING vbox.props.spacing = style.DEFAULT_SPACING