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>
Subject: [Qemu-devel] [PULL 05/24] gtk: remove page numbering assumtions from the code
Date: Mon, 26 May 2014 10:14:00 +0200	[thread overview]
Message-ID: <1401092059-18503-6-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1401092059-18503-1-git-send-email-kraxel@redhat.com>

Lookup page numbers using gtk_notebook_page_num() instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/gtk.c | 40 ++++++++++++++++++++++++++++++----------
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 6a3fe00..49753ef 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -190,7 +190,11 @@ static bool gd_grab_on_hover(GtkDisplayState *s)
 
 static bool gd_on_vga(GtkDisplayState *s)
 {
-    return gtk_notebook_get_current_page(GTK_NOTEBOOK(s->notebook)) == 0;
+    gint p1, p2;
+
+    p1 = gtk_notebook_get_current_page(GTK_NOTEBOOK(s->notebook));
+    p2 = gtk_notebook_page_num(GTK_NOTEBOOK(s->notebook), s->drawing_area);
+    return p1 == p2;
 }
 
 static void gd_update_cursor(GtkDisplayState *s, gboolean override)
@@ -805,19 +809,25 @@ static void gd_menu_quit(GtkMenuItem *item, void *opaque)
 static void gd_menu_switch_vc(GtkMenuItem *item, void *opaque)
 {
     GtkDisplayState *s = opaque;
+    gint page;
 
     if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(s->vga_item))) {
-        gtk_notebook_set_current_page(GTK_NOTEBOOK(s->notebook), 0);
+        page = gtk_notebook_page_num(GTK_NOTEBOOK(s->notebook),
+                                     s->drawing_area);
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(s->notebook), page);
     } else {
-        int i;
-
         gtk_release_modifiers(s);
+#if defined(CONFIG_VTE)
+        gint i;
         for (i = 0; i < s->nb_vcs; i++) {
             if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(s->vc[i].menu_item))) {
-                gtk_notebook_set_current_page(GTK_NOTEBOOK(s->notebook), i + 1);
-                break;
+                page = gtk_notebook_page_num(GTK_NOTEBOOK(s->notebook),
+                                             s->vc[i].box);
+                gtk_notebook_set_current_page(GTK_NOTEBOOK(s->notebook), page);
+                return;
             }
         }
+#endif
     }
 }
 
@@ -1061,12 +1071,14 @@ static void gd_change_page(GtkNotebook *nb, gpointer arg1, guint arg2,
 {
     GtkDisplayState *s = data;
     gboolean on_vga;
+    gint page;
 
     if (!gtk_widget_get_realized(s->notebook)) {
         return;
     }
 
-    on_vga = arg2 == 0;
+    page = gtk_notebook_page_num(GTK_NOTEBOOK(s->notebook), s->drawing_area);
+    on_vga = arg2 == page;
 
     if (!on_vga) {
         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
@@ -1076,12 +1088,20 @@ static void gd_change_page(GtkNotebook *nb, gpointer arg1, guint arg2,
                                        TRUE);
     }
 
-    if (arg2 == 0) {
+    if (on_vga) {
         gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->vga_item), TRUE);
     } else {
 #if defined(CONFIG_VTE)
-        VirtualConsole *vc = &s->vc[arg2 - 1];
-        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(vc->menu_item), TRUE);
+        VirtualConsole *vc;
+        gint page, i;
+        for (i = 0; i < s->nb_vcs; i++) {
+            vc = &s->vc[i];
+            page = gtk_notebook_page_num(GTK_NOTEBOOK(s->notebook), vc->box);
+            if (page == arg2) {
+                gtk_check_menu_item_set_active
+                    (GTK_CHECK_MENU_ITEM(vc->menu_item), TRUE);
+            }
+        }
 #else
         g_assert_not_reached();
 #endif
-- 
1.8.3.1

  parent reply	other threads:[~2014-05-26  8:14 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-26  8:13 [Qemu-devel] [PULL 00/24] gtk: ui overhaul, multiwindow support Gerd Hoffmann
2014-05-26  8:13 ` [Qemu-devel] [PULL 01/24] gtk: zap scrolled_window Gerd Hoffmann
2014-05-26  8:13 ` [Qemu-devel] [PULL 02/24] gtk: zap vte size requests Gerd Hoffmann
2014-05-26  8:13 ` [Qemu-devel] [PULL 03/24] gtk: cleanup CONFIG_VTE ifdef a bit Gerd Hoffmann
2014-05-26  8:13 ` [Qemu-devel] [PULL 04/24] gtk: Add a scrollbar for text consoles Gerd Hoffmann
2014-05-26  8:14 ` Gerd Hoffmann [this message]
2014-05-26  8:14 ` [Qemu-devel] [PULL 06/24] gtk: VirtualConsole restruction Gerd Hoffmann
2014-05-26  8:14 ` [Qemu-devel] [PULL 07/24] gtk: move vga state into VirtualGfxConsole Gerd Hoffmann
2014-05-26  8:14 ` [Qemu-devel] [PULL 08/24] gtk: support multiple gfx displays Gerd Hoffmann
2014-05-26  8:14 ` [Qemu-devel] [PULL 09/24] gtk: use device type as label Gerd Hoffmann
2014-05-26  8:14 ` [Qemu-devel] [PULL 10/24] gtk: simplify resize Gerd Hoffmann
2014-05-26  8:14 ` [Qemu-devel] [PULL 11/24] gtk: allow moving tabs to windows and back Gerd Hoffmann
2014-05-26  8:14 ` [Qemu-devel] [PULL 12/24] gtk: add tab to trace events Gerd Hoffmann
2014-05-26  8:14 ` [Qemu-devel] [PULL 13/24] gtk: add gd_grab trace event Gerd Hoffmann
2014-05-26  8:14 ` [Qemu-devel] [PULL 14/24] gtk: keep track of grab owner Gerd Hoffmann
2014-05-26  8:14 ` [Qemu-devel] [PULL 15/24] gtk: skip keyboard grab when hover autograb is active Gerd Hoffmann
2014-05-26  8:14 ` [Qemu-devel] [PULL 16/24] gtk: update gd_update_caption Gerd Hoffmann
2014-05-26  8:14 ` [Qemu-devel] [PULL 17/24] gtk: fix grab checks Gerd Hoffmann
2014-05-26  8:14 ` [Qemu-devel] [PULL 18/24] gtk: update all windows on mouse mode changes Gerd Hoffmann
2014-05-26  8:14 ` [Qemu-devel] [PULL 19/24] gtk: detached window pointer grabs Gerd Hoffmann
2014-05-26  8:14 ` [Qemu-devel] [PULL 20/24] gtk: enable untabify for gfx Gerd Hoffmann
2014-05-26  8:14 ` [Qemu-devel] [PULL 21/24] gtk: Add handling for the xfree86 keycodes Gerd Hoffmann
2014-05-26  8:14 ` [Qemu-devel] [PULL 22/24] gtk: zap unused global_state Gerd Hoffmann
2014-05-26  8:14 ` [Qemu-devel] [PULL 23/24] gtk: window sizing overhaul Gerd Hoffmann
2014-05-26  8:14 ` [Qemu-devel] [PULL 24/24] gtk: workaround gtk2 vte resize issue 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=1401092059-18503-6-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=aliguori@amazon.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).