[virt-tools-list] [PATCH 3/4] virt-viewer-window: Add show / hide utility functions

Hans de Goede hdegoede at redhat.com
Mon Mar 5 15:22:09 UTC 2012


Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 src/virt-viewer-app.c    |   32 +++++++++-----------------------
 src/virt-viewer-window.c |   12 ++++++++++++
 src/virt-viewer-window.h |    2 ++
 3 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 49b50d4..fc22721 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -248,24 +248,22 @@ virt_viewer_app_get_n_windows(VirtViewerApp *self)
 
 gboolean
 virt_viewer_app_window_set_visible(VirtViewerApp *self,
-                                   VirtViewerWindow *vwin,
+                                   VirtViewerWindow *window,
                                    gboolean visible)
 {
-    GtkWidget *window;
     g_return_val_if_fail(VIRT_VIEWER_IS_APP(self), FALSE);
-    g_return_val_if_fail(VIRT_VIEWER_IS_WINDOW(vwin), FALSE);
+    g_return_val_if_fail(VIRT_VIEWER_IS_WINDOW(window), FALSE);
 
-    window = GTK_WIDGET(virt_viewer_window_get_window(vwin));
     if (visible) {
-        gtk_widget_show(window);
+        virt_viewer_window_show(window);
         return TRUE;
     } else {
         if (virt_viewer_app_get_n_windows_visible(self) > 1) {
-            gtk_widget_hide(window);
+            virt_viewer_window_hide(window);
             return FALSE;
         } else if (virt_viewer_app_get_n_windows(self) > 1) {
             GtkWidget *dialog =
-                gtk_message_dialog_new (GTK_WINDOW(window),
+                gtk_message_dialog_new (virt_viewer_window_get_window(window),
                                         GTK_DIALOG_DESTROY_WITH_PARENT,
                                         GTK_MESSAGE_QUESTION,
                                         GTK_BUTTONS_OK_CANCEL,
@@ -595,7 +593,6 @@ display_show_hint(VirtViewerDisplay *display,
 {
     VirtViewerApp *self;
     VirtViewerNotebook *nb = virt_viewer_window_get_notebook(win);
-    GtkWindow *w = virt_viewer_window_get_window(win);
     gint nth, hint;
 
     g_object_get(win,
@@ -609,12 +606,12 @@ display_show_hint(VirtViewerDisplay *display,
     if (hint == VIRT_VIEWER_DISPLAY_SHOW_HINT_HIDE) {
         if (win != self->priv->main_window &&
             g_getenv("VIRT_VIEWER_HIDE"))
-            gtk_widget_hide(GTK_WIDGET(w));
+            virt_viewer_window_hide(win);
         virt_viewer_notebook_show_status(nb, _("Waiting for display %d..."), nth + 1);
     } else {
         virt_viewer_notebook_show_display(nb);
-        gtk_widget_show(GTK_WIDGET(w));
-        gtk_window_present(w);
+        virt_viewer_window_show(win);
+        gtk_window_present(virt_viewer_window_get_window(win));
     }
 
     g_object_unref(self);
@@ -1256,18 +1253,7 @@ virt_viewer_app_dispose (GObject *object)
 static gboolean
 virt_viewer_app_default_start(VirtViewerApp *self)
 {
-    VirtViewerAppPrivate *priv;
-    GtkWindow *win;
-    priv = self->priv;
-
-    win = virt_viewer_window_get_window(priv->main_window);
-    if (win)
-        gtk_widget_show(GTK_WIDGET(win));
-    else {
-        gtk_box_pack_end(GTK_BOX(priv->container), priv->main_notebook, TRUE, TRUE, 0);
-        gtk_widget_show(GTK_WIDGET(priv->main_notebook));
-    }
-
+    virt_viewer_window_show(self->priv->main_window);
     return TRUE;
 }
 
diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
index f86b5b7..d80d760 100644
--- a/src/virt-viewer-window.c
+++ b/src/virt-viewer-window.c
@@ -957,6 +957,18 @@ virt_viewer_window_set_display(VirtViewerWindow *self, VirtViewerDisplay *displa
 }
 
 void
+virt_viewer_window_show(VirtViewerWindow *self)
+{
+    gtk_widget_show(self->priv->window);
+}
+
+void
+virt_viewer_window_hide(VirtViewerWindow *self)
+{
+    gtk_widget_hide(self->priv->window);
+}
+
+void
 virt_viewer_window_set_zoom_level(VirtViewerWindow *self, gint zoom_level)
 {
     g_return_if_fail(VIRT_VIEWER_IS_WINDOW(self));
diff --git a/src/virt-viewer-window.h b/src/virt-viewer-window.h
index 273d909..f80c4c7 100644
--- a/src/virt-viewer-window.h
+++ b/src/virt-viewer-window.h
@@ -65,6 +65,8 @@ VirtViewerNotebook* virt_viewer_window_get_notebook (VirtViewerWindow* window);
 void virt_viewer_window_set_display(VirtViewerWindow *self, VirtViewerDisplay *display);
 void virt_viewer_window_set_usb_options_sensitive(VirtViewerWindow *self, gboolean sensitive);
 void virt_viewer_window_update_title(VirtViewerWindow *self);
+void virt_viewer_window_show(VirtViewerWindow *self);
+void virt_viewer_window_hide(VirtViewerWindow *self);
 void virt_viewer_window_set_zoom_level(VirtViewerWindow *self, gint zoom_level);
 gint virt_viewer_window_get_zoom_level(VirtViewerWindow *self);
 void virt_viewer_window_leave_fullscreen(VirtViewerWindow *self);
-- 
1.7.7.6




More information about the virt-tools-list mailing list