[gnome-clocks] Set the accel on the quit menu item
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] Set the accel on the quit menu item
- Date: Tue, 21 Aug 2012 19:48:51 +0000 (UTC)
commit faed1c78362837f4884d9f3e7188198c8140569f
Author: Paolo Borelli <pborelli gnome org>
Date: Tue Aug 21 21:27:44 2012 +0200
Set the accel on the quit menu item
This is the proper way instead of manually handling on-key-press
gnomeclocks/app.py | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/gnomeclocks/app.py b/gnomeclocks/app.py
index db1d7b0..b39755a 100644
--- a/gnomeclocks/app.py
+++ b/gnomeclocks/app.py
@@ -18,7 +18,7 @@
import os
from gettext import ngettext
-from gi.repository import Gtk, Gdk, GObject, Gio
+from gi.repository import Gtk, Gdk, GObject, GLib, Gio
from clocks import Clock, World, Alarm, Timer, Stopwatch
from utils import Dirs
from gnomeclocks import __version__, AUTHORS, COPYRIGHTS
@@ -136,8 +136,6 @@ class Window(Gtk.ApplicationWindow):
if event.state and Gdk.ModifierType.CONTROL_MASK:
if keyname == 'n':
self.toolbar._on_new_clicked(None)
- elif keyname in ('q', 'w'):
- self.app.quit()
class SelectionToolbar(Gtk.Toolbar):
@@ -388,12 +386,6 @@ class ClocksApplication(Gtk.Application):
def do_startup(self):
Gtk.Application.do_startup(self)
- menu = Gio.Menu()
-
- menu.append(_("About Clocks"), "app.about")
- menu.append(_("Quit"), "app.quit")
- self.set_app_menu(menu)
-
about_action = Gio.SimpleAction.new("about", None)
about_action.connect("activate", self.about_cb)
self.add_action(about_action)
@@ -401,3 +393,15 @@ class ClocksApplication(Gtk.Application):
quit_action = Gio.SimpleAction.new("quit", None)
quit_action.connect("activate", self.quit_cb)
self.add_action(quit_action)
+
+ menu = Gio.Menu()
+
+ menu.append(_("About Clocks"), "app.about")
+
+ quit = Gio.MenuItem()
+ quit.set_attribute_value("label", GLib.Variant("s", _("Quit")))
+ quit.set_attribute_value("action", GLib.Variant("s", "app.quit"))
+ quit.set_attribute_value("accel", GLib.Variant("s", "<Primary>q"))
+ menu.append_item(quit)
+
+ self.set_app_menu(menu)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]