mirror of
https://gitlab.gnome.org/World/Authenticator.git
synced 2025-03-04 08:44:40 +01:00
use gio.menu as model for popover
This commit is contained in:
parent
a337b69cb9
commit
f69bd36d50
5 changed files with 35 additions and 72 deletions
|
@ -59,8 +59,8 @@ class Application(Gtk.Application):
|
|||
|
||||
def do_startup(self):
|
||||
Gtk.Application.do_startup(self)
|
||||
self.generate_menu()
|
||||
if self.use_GMenu:
|
||||
self.generate_menu()
|
||||
logging.debug("Adding gnome shell menu")
|
||||
|
||||
def generate_menu(self):
|
||||
|
@ -80,8 +80,6 @@ class Application(Gtk.Application):
|
|||
help_section = Gio.MenuItem.new_section(None, help_content)
|
||||
self.menu.append_item(help_section)
|
||||
|
||||
self.set_app_menu(self.menu)
|
||||
|
||||
self.settings_action = Gio.SimpleAction.new("settings", None)
|
||||
self.settings_action.connect("activate", self.on_settings)
|
||||
self.settings_action.set_enabled(not self.locked)
|
||||
|
@ -100,6 +98,10 @@ class Application(Gtk.Application):
|
|||
action.connect("activate", self.on_quit)
|
||||
self.add_action(action)
|
||||
|
||||
if self.use_GMenu:
|
||||
self.set_app_menu(self.menu)
|
||||
logging.debug("Adding gnome shell menu")
|
||||
|
||||
def do_activate(self, *args):
|
||||
self.win = Window(self)
|
||||
self.win.show_all()
|
||||
|
|
|
@ -29,7 +29,8 @@ class ApplicationChooserWindow(Gtk.Window):
|
|||
self.connect("destroy", self.close_window)
|
||||
self.resize(410, 550)
|
||||
self.set_size_request(410, 550)
|
||||
self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
|
||||
x, y = self.parent.parent.get_position()
|
||||
self.move(x, y)
|
||||
self.set_resizable(False)
|
||||
self.set_transient_for(self.parent)
|
||||
self.connect("key_press_event", self.on_key_press)
|
||||
|
|
|
@ -24,8 +24,8 @@ class SettingsWindow(Gtk.Window):
|
|||
Gtk.Window.__init__(self,title=_("Settings"),type=Gtk.WindowType.TOPLEVEL,
|
||||
destroy_with_parent=True, modal=True)
|
||||
self.connect("delete-event", self.close_window)
|
||||
self.resize(410, 300)
|
||||
self.set_size_request(410, 300)
|
||||
self.resize(400, 300)
|
||||
self.set_size_request(400, 300)
|
||||
self.set_resizable(False)
|
||||
self.set_position(Gtk.WindowPosition.CENTER_ON_PARENT)
|
||||
self.set_transient_for(self.parent)
|
||||
|
|
|
@ -34,7 +34,7 @@ class Window(Gtk.ApplicationWindow):
|
|||
select_button = Gtk.Button()
|
||||
lock_button = Gtk.Button()
|
||||
|
||||
popover = Gtk.PopoverMenu().new()
|
||||
popover = None
|
||||
settings_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
||||
pop_settings = Gtk.ModelButton.new()
|
||||
password_entry = Gtk.Entry()
|
||||
|
@ -310,48 +310,8 @@ class Window(Gtk.ApplicationWindow):
|
|||
self.settings_button.set_image(settings_image)
|
||||
self.settings_button.connect("clicked", self.toggle_popover)
|
||||
|
||||
self.popover.get_style_context().add_class("choose-popover")
|
||||
self.popover.set_relative_to(self.settings_button)
|
||||
|
||||
popover_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
popover_box.set_property('margin', 12)
|
||||
popover_box.set_property('width-request', 150)
|
||||
self.popover.add(popover_box)
|
||||
|
||||
shortcuts_enabled = Gtk.get_major_version() >= 3 and Gtk.get_minor_version() >= 20
|
||||
|
||||
self.pop_settings.set_label(_("Settings"))
|
||||
self.pop_settings.get_style_context().add_class("flat")
|
||||
self.pop_settings.connect("clicked", self.app.on_settings)
|
||||
self.pop_settings.set_sensitive(not self.app.locked)
|
||||
|
||||
settings_section_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
settings_section_box.pack_start(self.pop_settings, False, False, 0)
|
||||
settings_section_box.pack_start(Gtk.Separator(), False, False, 0)
|
||||
|
||||
self.settings_box.pack_start(settings_section_box, True, True, 0)
|
||||
popover_box.pack_start(self.settings_box, True, True, 0)
|
||||
|
||||
shortcuts = Gtk.ModelButton.new()
|
||||
shortcuts.get_style_context().add_class("popover-item")
|
||||
shortcuts.set_label(_("Shortcuts"))
|
||||
shortcuts.connect("clicked", self.show_shortcuts)
|
||||
shortcuts.set_visible(shortcuts_enabled)
|
||||
shortcuts.set_no_show_all(not shortcuts_enabled)
|
||||
popover_box.pack_start(shortcuts, False, False, 0)
|
||||
|
||||
about = Gtk.ModelButton.new()
|
||||
about.get_style_context().add_class("popover-item")
|
||||
about.set_label(_("About"))
|
||||
about.connect("clicked", self.show_about)
|
||||
popover_box.pack_start(about, False, False, 0)
|
||||
|
||||
quit = Gtk.ModelButton.new()
|
||||
quit.set_label(_("Quit"))
|
||||
shortcuts.get_style_context().add_class("popover-item")
|
||||
quit.connect("clicked", self.app.on_quit)
|
||||
popover_box.pack_start(quit, False, False, 0)
|
||||
|
||||
self.popover = Gtk.Popover.new_from_model(self.settings_button, self.app.menu)
|
||||
self.popover.props.width_request = 200
|
||||
box.add(self.settings_button)
|
||||
|
||||
def toggle_popover(self, *args):
|
||||
|
@ -624,9 +584,9 @@ class Window(Gtk.ApplicationWindow):
|
|||
"""
|
||||
Save window position
|
||||
"""
|
||||
x, y = self.win.get_position()
|
||||
self.cfg.update("position-x", x, "preferences")
|
||||
self.cfg.update("position-y", y, "preferences")
|
||||
x, y = self.get_position()
|
||||
self.app.cfg.update("position-x", x, "preferences")
|
||||
self.app.cfg.update("position-y", y, "preferences")
|
||||
|
||||
def move_latest_position(self):
|
||||
"""
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-06-03 16:52+0200\n"
|
||||
"POT-Creation-Date: 2016-06-03 17:21+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -102,32 +102,20 @@ msgstr ""
|
|||
|
||||
#: TwoFactorAuth/widgets/window.py:290 TwoFactorAuth/widgets/add_account.py:48
|
||||
#: TwoFactorAuth/widgets/change_password.py:139
|
||||
#: TwoFactorAuth/widgets/applications_list.py:91
|
||||
#: TwoFactorAuth/widgets/applications_list.py:92
|
||||
msgid "Cancel"
|
||||
msgstr ""
|
||||
|
||||
#: TwoFactorAuth/widgets/window.py:309 TwoFactorAuth/widgets/window.py:323
|
||||
#: TwoFactorAuth/widgets/settings.py:24 TwoFactorAuth/application.py:69
|
||||
#: TwoFactorAuth/widgets/window.py:309 TwoFactorAuth/widgets/settings.py:24
|
||||
#: TwoFactorAuth/application.py:69
|
||||
msgid "Settings"
|
||||
msgstr ""
|
||||
|
||||
#: TwoFactorAuth/widgets/window.py:337 TwoFactorAuth/application.py:76
|
||||
msgid "Shortcuts"
|
||||
msgstr ""
|
||||
|
||||
#: TwoFactorAuth/widgets/window.py:345 TwoFactorAuth/application.py:78
|
||||
msgid "About"
|
||||
msgstr ""
|
||||
|
||||
#: TwoFactorAuth/widgets/window.py:350 TwoFactorAuth/application.py:79
|
||||
msgid "Quit"
|
||||
msgstr ""
|
||||
|
||||
#: TwoFactorAuth/widgets/window.py:515
|
||||
#: TwoFactorAuth/widgets/window.py:475
|
||||
msgid "There's no application at the moment"
|
||||
msgstr ""
|
||||
|
||||
#: TwoFactorAuth/widgets/window.py:610
|
||||
#: TwoFactorAuth/widgets/window.py:570
|
||||
msgid "Do you really want to remove the application?"
|
||||
msgstr ""
|
||||
|
||||
|
@ -168,11 +156,11 @@ msgstr ""
|
|||
msgid "Repeat new password"
|
||||
msgstr ""
|
||||
|
||||
#: TwoFactorAuth/widgets/applications_list.py:86
|
||||
#: TwoFactorAuth/widgets/applications_list.py:87
|
||||
msgid "Select an application"
|
||||
msgstr ""
|
||||
|
||||
#: TwoFactorAuth/widgets/applications_list.py:96
|
||||
#: TwoFactorAuth/widgets/applications_list.py:97
|
||||
msgid "Next"
|
||||
msgstr ""
|
||||
|
||||
|
@ -216,3 +204,15 @@ msgstr ""
|
|||
#: TwoFactorAuth/widgets/listrow.py:229
|
||||
msgid "Couldn't generate the secret code"
|
||||
msgstr ""
|
||||
|
||||
#: TwoFactorAuth/application.py:76
|
||||
msgid "Shortcuts"
|
||||
msgstr ""
|
||||
|
||||
#: TwoFactorAuth/application.py:78
|
||||
msgid "About"
|
||||
msgstr ""
|
||||
|
||||
#: TwoFactorAuth/application.py:79
|
||||
msgid "Quit"
|
||||
msgstr ""
|
||||
|
|
Loading…
Add table
Reference in a new issue