qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: "David Hildenbrand" <david@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Kashyap Chamarthy" <kchamart@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Eric Auger" <eric.auger@redhat.com>,
	"Christian Schoenebeck" <qemu_oss@crudebyte.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Eric Blake" <eblake@redhat.com>,
	"Bryce Mills" <brycemills@proton.me>
Subject: [PULL 24/26] gtk: Add show_menubar=on|off command line option.
Date: Thu, 13 Oct 2022 08:52:22 +0200	[thread overview]
Message-ID: <20221013065224.1864145-25-kraxel@redhat.com> (raw)
In-Reply-To: <20221013065224.1864145-1-kraxel@redhat.com>

From: Bryce Mills <brycemills@proton.me>

The patch adds "show_menubar" command line option for GTK UI similar to
"show_tabs". This option allows to hide menu bar initially, it still can
be toggled by shortcut and other shortcuts still work.

Signed-off-by: Bryce Mills <brycemills@proton.me>
Acked-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <NWO_zx1CT5Aj9vAXsRlqBppXd63gcKwL9V1qM1Meh36M_9tCw-EsCnfpvONXhHjmtKIUoSuCy9OO6cHS7M8b0oHBOCZG6f1jZ4Q2tqgI2Qo=@proton.me>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/gtk.c        | 15 ++++++++++-----
 qapi/ui.json    |  5 ++++-
 qemu-options.hx |  3 +++
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 6fc2e2396393..92daaa6a6edb 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -2171,7 +2171,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
     return group;
 }
 
-static GtkWidget *gd_create_menu_view(GtkDisplayState *s)
+static GtkWidget *gd_create_menu_view(GtkDisplayState *s, DisplayOptions *opts)
 {
     GSList *group = NULL;
     GtkWidget *view_menu;
@@ -2269,7 +2269,8 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState *s)
     s->show_menubar_item = gtk_check_menu_item_new_with_mnemonic(
             _("Show Menubar"));
     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->show_menubar_item),
-                                   TRUE);
+                                   !opts->u.gtk.has_show_menubar ||
+                                   opts->u.gtk.show_menubar);
     gtk_accel_group_connect(s->accel_group, GDK_KEY_m, HOTKEY_MODIFIERS, 0,
             g_cclosure_new_swap(G_CALLBACK(gd_accel_show_menubar), s, NULL));
     gtk_accel_label_set_accel(
@@ -2280,13 +2281,13 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState *s)
     return view_menu;
 }
 
-static void gd_create_menus(GtkDisplayState *s)
+static void gd_create_menus(GtkDisplayState *s, DisplayOptions *opts)
 {
     GtkSettings *settings;
 
     s->accel_group = gtk_accel_group_new();
     s->machine_menu = gd_create_menu_machine(s);
-    s->view_menu = gd_create_menu_view(s);
+    s->view_menu = gd_create_menu_view(s, opts);
 
     s->machine_menu_item = gtk_menu_item_new_with_mnemonic(_("_Machine"));
     gtk_menu_item_set_submenu(GTK_MENU_ITEM(s->machine_menu_item),
@@ -2363,7 +2364,7 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
 
     gtk_window_set_icon_name(GTK_WINDOW(s->window), "qemu");
 
-    gd_create_menus(s);
+    gd_create_menus(s, opts);
 
     gd_connect_signals(s);
 
@@ -2378,6 +2379,10 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
     gtk_container_add(GTK_CONTAINER(s->window), s->vbox);
 
     gtk_widget_show_all(s->window);
+    if (opts->u.gtk.has_show_menubar &&
+        !opts->u.gtk.show_menubar) {
+        gtk_widget_hide(s->menu_bar);
+    }
 
     vc = gd_vc_find_current(s);
     gtk_widget_set_sensitive(s->view_menu, vc != NULL);
diff --git a/qapi/ui.json b/qapi/ui.json
index 286c5731d1c3..0abba3e930a4 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1199,13 +1199,16 @@
 #               interfaces (e.g. VGA and virtual console character devices)
 #               by default.
 #               Since 7.1
+# @show-menubar: Display the main window menubar. Defaults to "on".
+#                Since 8.0
 #
 # Since: 2.12
 ##
 { 'struct'  : 'DisplayGTK',
   'data'    : { '*grab-on-hover' : 'bool',
                 '*zoom-to-fit'   : 'bool',
-                '*show-tabs'     : 'bool'  } }
+                '*show-tabs'     : 'bool',
+                '*show-menubar'  : 'bool'  } }
 
 ##
 # @DisplayEGLHeadless:
diff --git a/qemu-options.hx b/qemu-options.hx
index 95b998a13b01..bb0979bef908 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1969,6 +1969,7 @@ DEF("display", HAS_ARG, QEMU_OPTION_display,
 #if defined(CONFIG_GTK)
     "-display gtk[,full-screen=on|off][,gl=on|off][,grab-on-hover=on|off]\n"
     "            [,show-tabs=on|off][,show-cursor=on|off][,window-close=on|off]\n"
+    "            [,show-menubar=on|off]\n"
 #endif
 #if defined(CONFIG_VNC)
     "-display vnc=<display>[,<optargs>]\n"
@@ -2061,6 +2062,8 @@ SRST
 
         ``window-close=on|off`` : Allow to quit qemu with window close button
 
+        ``show-menubar=on|off`` : Display the main window menubar, defaults to "on"
+
     ``curses[,charset=<encoding>]``
         Display video output via curses. For graphics device models
         which support a text mode, QEMU can display this output using a
-- 
2.37.3



  parent reply	other threads:[~2022-10-13  7:41 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-13  6:51 [PULL 00/26] Kraxel 20221013 patches Gerd Hoffmann
2022-10-13  6:51 ` [PULL 01/26] audio: refactor code in audio_run_out() Gerd Hoffmann
2022-10-13  6:52 ` [PULL 02/26] audio: fix GUS audio playback with out.mixing-engine=off Gerd Hoffmann
2022-10-13  6:52 ` [PULL 03/26] audio: run downstream playback queue unconditionally Gerd Hoffmann
2022-10-13  6:52 ` [PULL 04/26] alsaaudio: reduce playback latency Gerd Hoffmann
2022-10-13  6:52 ` [PULL 05/26] audio: add more audio rate control functions Gerd Hoffmann
2022-10-13  6:52 ` [PULL 06/26] spiceaudio: add a pcm_ops buffer_get_free function Gerd Hoffmann
2022-10-13  6:52 ` [PULL 07/26] spiceaudio: update comment Gerd Hoffmann
2022-10-13  6:52 ` [PULL 08/26] audio: swap audio_rate_get_bytes() function parameters Gerd Hoffmann
2022-10-13  6:52 ` [PULL 09/26] audio: rename audio_sw_bytes_free() Gerd Hoffmann
2022-10-13  6:52 ` [PULL 10/26] audio: refactor audio_get_avail() Gerd Hoffmann
2022-10-13  6:52 ` [PULL 11/26] audio: fix sw->buf size for audio recording Gerd Hoffmann
2022-10-13  6:52 ` [PULL 12/26] audio: prevent an integer overflow in resampling code Gerd Hoffmann
2022-10-13  6:52 ` [PULL 13/26] ui/vnc-clipboard: fix integer underflow in vnc_client_cut_text_ext Gerd Hoffmann
2022-10-13  6:52 ` [PULL 14/26] ui/gtk-egl: egl context needs to be unbound in the end of gd_egl_switch Gerd Hoffmann
2022-10-13  6:52 ` [PULL 15/26] cirrus_vga: fix potential memory overflow Gerd Hoffmann
2022-10-13  6:52 ` [PULL 16/26] docs: add firmware feature flags Gerd Hoffmann
2022-10-13  6:52 ` [PULL 17/26] pci-ids: drop PCI_DEVICE_ID_VIRTIO_IOMMU Gerd Hoffmann
2022-10-13  6:52 ` [PULL 18/26] pci-ids: drop PCI_DEVICE_ID_VIRTIO_MEM Gerd Hoffmann
2022-10-13  6:52 ` [PULL 19/26] pci-ids: drop PCI_DEVICE_ID_VIRTIO_PMEM Gerd Hoffmann
2022-10-13  6:52 ` [PULL 20/26] pci-ids: drop list of modern virtio devices Gerd Hoffmann
2022-10-13  6:52 ` [PULL 21/26] pci-ids: document modern virtio-pci ids in pci.h too Gerd Hoffmann
2022-10-13  6:52 ` [PULL 22/26] ui/gtk: Fix the implicit mouse ungrabbing logic Gerd Hoffmann
2022-10-13  6:52 ` [PULL 23/26] qemu-edid: Restrict input parameter -d to avoid division by zero Gerd Hoffmann
2022-10-13  6:52 ` Gerd Hoffmann [this message]
2022-10-13  6:52 ` [PULL 25/26] audio: fix in.voices test Gerd Hoffmann
2022-10-13  6:52 ` [PULL 26/26] audio: improve out.voices test Gerd Hoffmann
2022-10-13 20:29 ` [PULL 00/26] Kraxel 20221013 patches Stefan Hajnoczi

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=20221013065224.1864145-25-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=brycemills@proton.me \
    --cc=david@redhat.com \
    --cc=eblake@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=kchamart@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu_oss@crudebyte.com \
    /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).