qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>,
	Anthony Liguori <aliguori@amazon.com>,
	Cole Robinson <crobinso@redhat.com>
Subject: [Qemu-devel] [PULL 2/5] gtk: Install fullscreen accelerator on toplevel window
Date: Tue,  4 Nov 2014 11:41:08 +0100	[thread overview]
Message-ID: <1415097671-15343-3-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1415097671-15343-1-git-send-email-kraxel@redhat.com>

From: Cole Robinson <crobinso@redhat.com>

Instead of installing it on the menu. This will be needed to keep the
fullscreen keyboard shortcut working when we hide the menu (in future
patches).

On gtk < 3.8, this has the unfortunate side effect of no longer listing
the key combo in the UI. We could manually change the label in that case,
but it will look visually out of place, and I'm not sure if anyone really
cares.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/gtk.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 97ac4c9..af8b2d0 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1123,6 +1123,12 @@ static void gd_menu_full_screen(GtkMenuItem *item, void *opaque)
     gd_update_cursor(vc);
 }
 
+static void gd_accel_full_screen(void *opaque)
+{
+    GtkDisplayState *s = opaque;
+    gtk_menu_item_activate(GTK_MENU_ITEM(s->full_screen_item));
+}
+
 static void gd_menu_zoom_in(GtkMenuItem *item, void *opaque)
 {
     GtkDisplayState *s = opaque;
@@ -1704,10 +1710,14 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState *s)
     gtk_menu_set_accel_group(GTK_MENU(view_menu), s->accel_group);
 
     s->full_screen_item = gtk_menu_item_new_with_mnemonic(_("_Fullscreen"));
-    gtk_menu_item_set_accel_path(GTK_MENU_ITEM(s->full_screen_item),
-                                 "<QEMU>/View/Full Screen");
-    gtk_accel_map_add_entry("<QEMU>/View/Full Screen", GDK_KEY_f,
-                            HOTKEY_MODIFIERS);
+
+    gtk_accel_group_connect(s->accel_group, GDK_KEY_f, HOTKEY_MODIFIERS, 0,
+            g_cclosure_new_swap(G_CALLBACK(gd_accel_full_screen), s, NULL));
+#if GTK_CHECK_VERSION(3, 8, 0)
+    gtk_accel_label_set_accel(
+            GTK_ACCEL_LABEL(gtk_bin_get_child(GTK_BIN(s->full_screen_item))),
+            GDK_KEY_f, HOTKEY_MODIFIERS);
+#endif
     gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->full_screen_item);
 
     separator = gtk_separator_menu_item_new();
-- 
1.8.3.1

  parent reply	other threads:[~2014-11-04 10:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-04 10:41 [Qemu-devel] [PULL 0/5] gtk: fix fullscreen with gtk3, fix build with older gtk2 versions Gerd Hoffmann
2014-11-04 10:41 ` [Qemu-devel] [PULL 1/5] gtk: Grab accel_group from GtkDisplayState Gerd Hoffmann
2014-11-04 10:41 ` Gerd Hoffmann [this message]
2014-11-04 10:41 ` [Qemu-devel] [PULL 3/5] gtk: Install vc accelerators on parent window Gerd Hoffmann
2014-11-04 10:41 ` [Qemu-devel] [PULL 4/5] gtk: Hide the menubar when in fullscreen mode (lp 1294898) Gerd Hoffmann
2014-11-04 10:41 ` [Qemu-devel] [PULL 5/5] gtk: add GDK_KEY_pause #define Gerd Hoffmann
2014-11-04 11:51   ` Cornelia Huck
2014-11-04 13:39     ` Alexander Graf
2014-11-04 12:57 ` [Qemu-devel] [PULL 0/5] gtk: fix fullscreen with gtk3, fix build with older gtk2 versions Peter Maydell
2014-11-04 13:38   ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1415097671-15343-3-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=crobinso@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).