enter key after editing title will closes the activity toolbar(if present)

- No change for activities having titleEntry without the toolbar (Eg: chat)

Tested on:
Ubuntu 16.04, Sugar 0.112, GTK 3.18.9
This commit is contained in:
Pro-Panda 2018-03-02 23:24:06 +05:30 committed by James Cameron
parent cc2357c787
commit 1bc171d5d6

View File

@ -19,6 +19,7 @@
from gi.repository import Gdk from gi.repository import Gdk
from gi.repository import Gtk from gi.repository import Gtk
from gi.repository import GObject
import gettext import gettext
from sugar3.graphics.toolbutton import ToolButton from sugar3.graphics.toolbutton import ToolButton
@ -71,6 +72,7 @@ class ActivityToolbarButton(ToolbarButton):
def __init__(self, activity, **kwargs): def __init__(self, activity, **kwargs):
toolbar = ActivityToolbar(activity, orientation_left=True) toolbar = ActivityToolbar(activity, orientation_left=True)
toolbar.connect('entered', lambda widget: self.emit('clicked'))
ToolbarButton.__init__(self, page=toolbar, **kwargs) ToolbarButton.__init__(self, page=toolbar, **kwargs)
@ -167,6 +169,9 @@ class ShareButton(RadioMenuButton):
class TitleEntry(Gtk.ToolItem): class TitleEntry(Gtk.ToolItem):
__gsignals__ = {
'entered': (GObject.SignalFlags.RUN_FIRST, None, ([])),
}
def __init__(self, activity, **kwargs): def __init__(self, activity, **kwargs):
Gtk.ToolItem.__init__(self) Gtk.ToolItem.__init__(self)
@ -190,6 +195,7 @@ class TitleEntry(Gtk.ToolItem):
entry.select_region(0, 0) entry.select_region(0, 0)
entry.hide() entry.hide()
entry.show() entry.show()
self.emit('entered')
return False return False
def modify_bg(self, state, color): def modify_bg(self, state, color):
@ -320,6 +326,9 @@ class DescriptionItem(ToolButton):
class ActivityToolbar(Gtk.Toolbar): class ActivityToolbar(Gtk.Toolbar):
"""The Activity toolbar with the Journal entry title and sharing button""" """The Activity toolbar with the Journal entry title and sharing button"""
__gsignals__ = {
'entered': (GObject.SignalFlags.RUN_FIRST, None, ([])),
}
def __init__(self, activity, orientation_left=False): def __init__(self, activity, orientation_left=False):
Gtk.Toolbar.__init__(self) Gtk.Toolbar.__init__(self)
@ -328,6 +337,7 @@ class ActivityToolbar(Gtk.Toolbar):
if activity.metadata: if activity.metadata:
title_button = TitleEntry(activity) title_button = TitleEntry(activity)
title_button.connect('entered', lambda widget: self.emit('entered'))
title_button.show() title_button.show()
self.insert(title_button, -1) self.insert(title_button, -1)
self.title = title_button.entry self.title = title_button.entry