[virt-tools-list] [PATCH virt-viewer] Make ctrl-[+-] zoom in/out in fullscreen

Marc-André Lureau marcandre.lureau at gmail.com
Sun Jul 6 22:15:52 UTC 2014


Make ctrl-[+-] zoom in/out in fullscreen
with mouse over the control bar.

https://bugzilla.redhat.com/show_bug.cgi?id=987549
---
 src/virt-gtk-compat.h    | 2 ++
 src/virt-viewer-app.c    | 4 ++++
 src/virt-viewer-window.c | 4 ++++
 src/virt-viewer.xml      | 2 ++
 4 files changed, 12 insertions(+)

diff --git a/src/virt-gtk-compat.h b/src/virt-gtk-compat.h
index 67ac768..110c17a 100644
--- a/src/virt-gtk-compat.h
+++ b/src/virt-gtk-compat.h
@@ -55,6 +55,8 @@ G_BEGIN_DECLS
 #define GDK_F11 GDK_KEY_F11
 #define GDK_F12 GDK_KEY_F12
 #define GDK_0 GDK_KEY_0
+#define GDK_plus GDK_KEY_plus
+#define GDK_minus GDK_KEY_minus
 #endif
 
 #if !GTK_CHECK_VERSION(3, 0, 0)
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 2046990..964a38b 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -1710,6 +1710,8 @@ virt_viewer_app_constructor (GType gtype,
     gtk_accel_map_add_entry("<virt-viewer>/view/toggle-fullscreen", GDK_F11, 0);
     gtk_accel_map_add_entry("<virt-viewer>/view/release-cursor", GDK_F12, GDK_SHIFT_MASK);
     gtk_accel_map_add_entry("<virt-viewer>/view/zoom-reset", GDK_0, GDK_CONTROL_MASK);
+    gtk_accel_map_add_entry("<virt-viewer>/view/zoom-out", GDK_minus, GDK_CONTROL_MASK);
+    gtk_accel_map_add_entry("<virt-viewer>/view/zoom-in", GDK_plus, GDK_CONTROL_MASK);
     gtk_accel_map_add_entry("<virt-viewer>/send/secure-attention", GDK_End, GDK_CONTROL_MASK | GDK_MOD1_MASK);
 
     virt_viewer_app_set_fullscreen(self, opt_fullscreen);
@@ -1877,6 +1879,8 @@ virt_viewer_app_clear_hotkeys(VirtViewerApp *self)
     gtk_accel_map_change_entry("<virt-viewer>/view/toggle-fullscreen", 0, 0, TRUE);
     gtk_accel_map_change_entry("<virt-viewer>/view/release-cursor", 0, 0, TRUE);
     gtk_accel_map_change_entry("<virt-viewer>/view/zoom-reset", 0, 0, TRUE);
+    gtk_accel_map_change_entry("<virt-viewer>/view/zoom-in", 0, 0, TRUE);
+    gtk_accel_map_change_entry("<virt-viewer>/view/zoom-out", 0, 0, TRUE);
     gtk_accel_map_change_entry("<virt-viewer>/send/secure-attention", 0, 0, TRUE);
     virt_viewer_set_insert_smartcard_accel(self, 0, 0);
     virt_viewer_set_remove_smartcard_accel(self, 0, 0);
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 22326e8..fadf0bb 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -315,6 +315,10 @@ virt_viewer_window_init (VirtViewerWindow *self)
                      "can-activate-accel", G_CALLBACK(can_activate_cb), self);
     g_signal_connect(gtk_builder_get_object(priv->builder, "menu-view-zoom-reset"),
                      "can-activate-accel", G_CALLBACK(can_activate_cb), self);
+    g_signal_connect(gtk_builder_get_object(priv->builder, "menu-view-zoom-in"),
+                     "can-activate-accel", G_CALLBACK(can_activate_cb), self);
+    g_signal_connect(gtk_builder_get_object(priv->builder, "menu-view-zoom-out"),
+                     "can-activate-accel", G_CALLBACK(can_activate_cb), self);
 
     vbox = GTK_WIDGET(gtk_builder_get_object(priv->builder, "viewer-box"));
     virt_viewer_window_toolbar_setup(self);
diff --git a/src/virt-viewer.xml b/src/virt-viewer.xml
index 8a3d3c0..fd8295f 100644
--- a/src/virt-viewer.xml
+++ b/src/virt-viewer.xml
@@ -127,6 +127,7 @@
                             <property name="accel_group">accelgroup</property>
                             <child>
                               <object class="GtkImageMenuItem" id="menu-view-zoom-in">
+                                <property name="accel_path"><virt-viewer>/view/zoom-in</property>
                                 <property name="label">gtk-zoom-in</property>
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
@@ -139,6 +140,7 @@
                             </child>
                             <child>
                               <object class="GtkImageMenuItem" id="menu-view-zoom-out">
+                                <property name="accel_path"><virt-viewer>/view/zoom-out</property>
                                 <property name="label">gtk-zoom-out</property>
                                 <property name="visible">True</property>
                                 <property name="can_focus">False</property>
-- 
1.9.3




More information about the virt-tools-list mailing list