[virt-tools-list] [PATCH 5/5] headerbar: Add ability to "Change CD" in fullscreen

Fabiano Fidêncio fidencio at redhat.com
Sat Dec 17 16:50:12 UTC 2016


While still there's no formal request for this it's something that will
make the users lives easier.

Signed-off-by: Fabiano Fidêncio <fabiano at fidencio.org>
---
 src/remote-viewer.c             |  4 ++++
 src/resources/ui/virt-viewer.ui | 19 +++++++++++++++++++
 src/virt-viewer-window.c        | 23 +++++++++++++++++++++++
 src/virt-viewer-window.h        |  1 +
 4 files changed, 47 insertions(+)

diff --git a/src/remote-viewer.c b/src/remote-viewer.c
index 2313d73..16922cd 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -774,10 +774,14 @@ ovirt_foreign_menu_update(GtkApplication *gtkapp, GtkWindow *gtkwin, G_GNUC_UNUS
     RemoteViewer *self = REMOTE_VIEWER(gtkapp);
     VirtViewerWindow *win = g_object_get_data(G_OBJECT(gtkwin), "virt-viewer-window");
     GtkButton *button = virt_viewer_window_get_button_change_cd(win);
+    GtkButton *fullscreen_button = virt_viewer_window_get_fullscreen_button_change_cd(win);
     gboolean has_ovirt_foreign_menu = self->priv->ovirt_foreign_menu != NULL;
 
     gtk_widget_set_sensitive(GTK_WIDGET(button), has_ovirt_foreign_menu);
     gtk_widget_set_visible(GTK_WIDGET(button), has_ovirt_foreign_menu);
+
+    gtk_widget_set_sensitive(GTK_WIDGET(fullscreen_button), has_ovirt_foreign_menu);
+    gtk_widget_set_visible(GTK_WIDGET(fullscreen_button), has_ovirt_foreign_menu);
 }
 
 static void
diff --git a/src/resources/ui/virt-viewer.ui b/src/resources/ui/virt-viewer.ui
index c211440..7f93266 100644
--- a/src/resources/ui/virt-viewer.ui
+++ b/src/resources/ui/virt-viewer.ui
@@ -226,6 +226,25 @@
     <property name="visible">True</property>
     <property name="show-close-button">True</property>
     <child>
+      <object class="GtkButton" id="fullscreen-change-cd">
+        <property name="visible">False</property>
+        <property name="tooltip-text">Change CD</property>
+        <style>
+          <class name="image-button"/>
+        </style>
+        <child>
+          <object class="GtkImage" id="fullscreen-change-cd-icon">
+            <property name="visible">True</property>
+            <property name="icon-name">media-optical-symbolic</property>
+            <property name="icon-size">1</property>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="pack-type">end</property>
+      </packing>
+    </child>
+    <child>
       <object class="GtkButton" id="fullscreen-usb-devices">
         <property name="visible">False</property>
         <property name="tooltip-text">USB device selection</property>
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index 60ab088..2544013 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -84,6 +84,7 @@ struct _VirtViewerWindowPrivate {
     GtkWidget *header;
     GtkWidget *fullscreen_headerbar;
     GtkWidget *toolbar_usb_device_selection;
+    GtkWidget *toolbar_change_cd;
     GtkAccelGroup *accel_group;
     VirtViewerNotebook *notebook;
     VirtViewerDisplay *display;
@@ -981,6 +982,7 @@ static void
 virt_viewer_window_fullscreen_headerbar_setup(VirtViewerWindow *self)
 {
     GtkWidget *overlay;
+    GtkWidget *change_cd_button;
     GtkWidget *leave_fullscreen_button;
     GtkWidget *usb_devices_button;
     GtkWidget *send_keys_button;
@@ -1001,10 +1003,23 @@ virt_viewer_window_fullscreen_headerbar_setup(VirtViewerWindow *self)
     g_signal_connect(usb_devices_button, "clicked",
                      G_CALLBACK(virt_viewer_window_headerbar_usb_device_selection), self);
 
+    change_cd_button = GTK_WIDGET(gtk_builder_get_object(priv->builder, "fullscreen-change-cd"));
+    priv->toolbar_change_cd = change_cd_button;
+    g_signal_connect(change_cd_button, "clicked",
+                     G_CALLBACK(virt_viewer_window_change_cd_cb), self);
+
     priv->fullscreen_headerbar = GTK_WIDGET(gtk_builder_get_object(priv->builder, "fullscreen-headerbar"));
     priv->revealer = virt_viewer_timed_revealer_new(priv->fullscreen_headerbar);
     overlay = GTK_WIDGET(gtk_builder_get_object(priv->builder, "viewer-overlay"));
     gtk_overlay_add_overlay(GTK_OVERLAY(overlay), GTK_WIDGET(priv->revealer));
+
+    /*
+     * The timerevelear will show all the widgets that are part of it.
+     * As the "foreign-menu" must be not visible by default, we have to,
+     * explicitly, change its visibility here.
+     */
+    gtk_widget_set_sensitive(priv->toolbar_change_cd, FALSE);
+    gtk_widget_set_visible(priv->toolbar_change_cd, FALSE);
 }
 
 VirtViewerNotebook*
@@ -1346,6 +1361,14 @@ virt_viewer_window_get_button_change_cd(VirtViewerWindow *self)
     return GTK_BUTTON(gtk_builder_get_object(self->priv->builder, "change-cd"));
 }
 
+GtkButton*
+virt_viewer_window_get_fullscreen_button_change_cd(VirtViewerWindow *self)
+{
+    g_return_val_if_fail(VIRT_VIEWER_IS_WINDOW(self), NULL);
+
+    return GTK_BUTTON(gtk_builder_get_object(self->priv->builder, "fullscreen-change-cd"));
+}
+
 GtkBuilder*
 virt_viewer_window_get_builder(VirtViewerWindow *self)
 {
diff --git a/src/virt-viewer-window.h b/src/virt-viewer-window.h
index 17cc6cf..a031032 100644
--- a/src/virt-viewer-window.h
+++ b/src/virt-viewer-window.h
@@ -80,6 +80,7 @@ void virt_viewer_window_leave_fullscreen(VirtViewerWindow *self);
 void virt_viewer_window_enter_fullscreen(VirtViewerWindow *self, gint monitor);
 GtkMenuButton *virt_viewer_window_get_menu_button_displays(VirtViewerWindow *self);
 GtkButton *virt_viewer_window_get_button_change_cd(VirtViewerWindow *self);
+GtkButton *virt_viewer_window_get_fullscreen_button_change_cd(VirtViewerWindow *self);
 GtkBuilder* virt_viewer_window_get_builder(VirtViewerWindow *window);
 void virt_viewer_window_set_kiosk(VirtViewerWindow *self, gboolean enabled);
 
-- 
2.9.3




More information about the virt-tools-list mailing list