[vinagre] Rework widget visibility toggling
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vinagre] Rework widget visibility toggling
- Date: Thu, 30 Jun 2011 21:30:52 +0000 (UTC)
commit b4a1238c94e55f0c855efe8458ca89a3dfbba3f4
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Tue Apr 12 22:38:58 2011 +0200
Rework widget visibility toggling
Replace Vinagre.Utils.toggle_widget_visible() with
Vinagre.Utils.set_widget_visible(). This allows for better control of
the visibility state. Remove unused _toggle_widget_visible()
Signed-off-by: David King <amigadave amigadave com>
vinagre/vinagre-commands.c | 14 ++++----------
vinagre/vinagre-main.c | 2 +-
vinagre/vinagre-utils.vala | 8 ++++----
vinagre/vinagre-window.c | 2 ++
4 files changed, 11 insertions(+), 15 deletions(-)
---
diff --git a/vinagre/vinagre-commands.c b/vinagre/vinagre-commands.c
index 8812d0d..1604a4f 100644
--- a/vinagre/vinagre-commands.c
+++ b/vinagre/vinagre-commands.c
@@ -39,14 +39,6 @@
#include "vinagre-cache-prefs.h"
#include "vinagre-plugins-engine.h"
-static void _toggle_widget_visible (GtkWidget *widget)
-{
- if (gtk_widget_get_visible (widget))
- gtk_widget_hide (widget);
- else
- gtk_widget_show_all (widget);
-}
-
void
vinagre_cmd_direct_connect (VinagreConnection *conn,
VinagreWindow *window)
@@ -253,9 +245,10 @@ void
vinagre_cmd_view_show_toolbar (GtkAction *action,
VinagreWindow *window)
{
+ gboolean active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
g_return_if_fail (VINAGRE_IS_WINDOW (window));
- _toggle_widget_visible (window->priv->toolbar);
+ vinagre_utils_set_widget_visible (window->priv->toolbar, active);
vinagre_cache_prefs_set_boolean ("window",
"toolbar-visible",
@@ -266,9 +259,10 @@ void
vinagre_cmd_view_show_statusbar (GtkAction *action,
VinagreWindow *window)
{
+ gboolean active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
g_return_if_fail (VINAGRE_IS_WINDOW (window));
- _toggle_widget_visible (window->priv->statusbar);
+ vinagre_utils_set_widget_visible (window->priv->statusbar, active);
vinagre_cache_prefs_set_boolean ("window",
"statusbar-visible",
diff --git a/vinagre/vinagre-main.c b/vinagre/vinagre-main.c
index 1e52e33..e3d8994 100644
--- a/vinagre/vinagre-main.c
+++ b/vinagre/vinagre-main.c
@@ -60,7 +60,7 @@ app_init (GtkApplication *app)
window = GTK_WINDOW (vinagre_window_new ());
gtk_window_set_application (window, app);
- gtk_widget_show_all (GTK_WIDGET (window));
+ gtk_widget_show (GTK_WIDGET (window));
#ifdef VINAGRE_HAVE_TELEPATHY_GLIB
vinagre_tubes_manager = vinagre_tubes_manager_new (VINAGRE_WINDOW (window));
diff --git a/vinagre/vinagre-utils.vala b/vinagre/vinagre-utils.vala
index 16f4e19..f1e0eee 100644
--- a/vinagre/vinagre-utils.vala
+++ b/vinagre/vinagre-utils.vala
@@ -26,11 +26,11 @@ namespace Vinagre.Utils {
return false;
}
- public void toggle_widget_visible (Widget widget) {
- if (widget.visible)
- widget.hide ();
- else
+ public void set_widget_visible (Widget widget, bool visible) {
+ if (visible)
widget.show_all ();
+ else
+ widget.hide ();
}
public void show_error_dialog (string? title,
diff --git a/vinagre/vinagre-window.c b/vinagre/vinagre-window.c
index 26df706..746975c 100644
--- a/vinagre/vinagre-window.c
+++ b/vinagre/vinagre-window.c
@@ -641,6 +641,7 @@ init_widgets_visibility (VinagreWindow *window)
visible = vinagre_cache_prefs_get_boolean ("window", "toolbar-visible", TRUE);
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
+ vinagre_utils_set_widget_visible (window->priv->toolbar, visible);
/* statusbar visibility */
action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
@@ -648,6 +649,7 @@ init_widgets_visibility (VinagreWindow *window)
visible = vinagre_cache_prefs_get_boolean ("window", "statusbar-visible", TRUE);
if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
+ vinagre_utils_set_widget_visible (window->priv->statusbar, visible);
gtk_window_set_default_size (GTK_WINDOW (window),
vinagre_cache_prefs_get_integer ("window", "window-width", 650),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]