[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [PATCH virt-viewer 2/9] Add VirtViewerApp:enable-accel property



---
 src/virt-viewer-app.c    |   28 ++++++++++++++++++++++++++++
 src/virt-viewer-app.h    |    1 +
 src/virt-viewer-window.c |    6 ++++++
 3 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 985edca..0ba57b6 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -111,6 +111,7 @@ struct _VirtViewerAppPrivate {
 
     gboolean direct;
     gboolean verbose;
+    gboolean enable_accel;
     gboolean authretry;
     gboolean started;
     gboolean fullscreen;
@@ -150,6 +151,7 @@ enum {
     PROP_GURI,
     PROP_FULLSCREEN,
     PROP_TITLE,
+    PROP_ENABLE_ACCEL,
 };
 
 enum {
@@ -1121,6 +1123,10 @@ virt_viewer_app_get_property (GObject *object, guint property_id,
         g_value_set_string(value, priv->title);
         break;
 
+    case PROP_ENABLE_ACCEL:
+        g_value_set_boolean(value, virt_viewer_app_get_enable_accel(self));
+        break;
+
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     }
@@ -1165,6 +1171,10 @@ virt_viewer_app_set_property (GObject *object, guint property_id,
         virt_viewer_app_set_all_window_subtitles(self);
         break;
 
+    case PROP_ENABLE_ACCEL:
+        priv->enable_accel = g_value_get_boolean(value);
+        break;
+
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
     }
@@ -1342,6 +1352,16 @@ virt_viewer_app_class_init (VirtViewerAppClass *klass)
                                                         G_PARAM_WRITABLE |
                                                         G_PARAM_STATIC_STRINGS));
 
+    g_object_class_install_property(object_class,
+                                    PROP_ENABLE_ACCEL,
+                                    g_param_spec_boolean("enable-accel",
+                                                         "Enable Accel",
+                                                         "Enable accelerators",
+                                                         FALSE,
+                                                         G_PARAM_CONSTRUCT |
+                                                         G_PARAM_READWRITE |
+                                                         G_PARAM_STATIC_STRINGS));
+
     signals[SIGNAL_WINDOW_ADDED] =
         g_signal_new("window-added",
                      G_OBJECT_CLASS_TYPE(object_class),
@@ -1638,6 +1658,14 @@ virt_viewer_app_show_display(VirtViewerApp *self)
     g_hash_table_foreach(self->priv->windows, show_display_cb, self);
 }
 
+gboolean
+virt_viewer_app_get_enable_accel(VirtViewerApp *self)
+{
+    g_return_val_if_fail(VIRT_VIEWER_IS_APP(self), FALSE);
+
+    return self->priv->enable_accel;
+}
+
 GHashTable*
 virt_viewer_app_get_windows(VirtViewerApp *self)
 {
diff --git a/src/virt-viewer-app.h b/src/virt-viewer-app.h
index 4022ddf..52f43ea 100644
--- a/src/virt-viewer-app.h
+++ b/src/virt-viewer-app.h
@@ -94,6 +94,7 @@ GHashTable* virt_viewer_app_get_windows(VirtViewerApp *self);
 
 void virt_viewer_app_usb_device_selection(VirtViewerApp   *self,
                                           GtkWindow       *parent);
+gboolean virt_viewer_app_get_enable_accel(VirtViewerApp *self);
 
 G_END_DECLS
 
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 0b1d397..fd08fcb 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -587,6 +587,9 @@ virt_viewer_window_disable_modifiers(VirtViewerWindow *self)
 
     /* This stops global accelerators like Ctrl+Q == Quit */
     for (accels = priv->accel_list ; accels ; accels = accels->next) {
+        if (virt_viewer_app_get_enable_accel(priv->app) &&
+            priv->accel_group == accels->data)
+            continue;
         gtk_window_remove_accel_group(GTK_WINDOW(priv->window), accels->data);
     }
 
@@ -620,6 +623,9 @@ virt_viewer_window_enable_modifiers(VirtViewerWindow *self)
 
     /* This allows global accelerators like Ctrl+Q == Quit */
     for (accels = priv->accel_list ; accels ; accels = accels->next) {
+        if (virt_viewer_app_get_enable_accel(priv->app) &&
+            priv->accel_group == accels->data)
+            continue;
         gtk_window_add_accel_group(GTK_WINDOW(priv->window), accels->data);
     }
 
-- 
1.7.7.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]