[nautilus] toolbar: don't explicitly show/hide stop/reload buttons
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] toolbar: don't explicitly show/hide stop/reload buttons
- Date: Sun, 25 Jan 2015 15:22:30 +0000 (UTC)
commit 81f618714c50a727db1baa6e84806b885397a5b2
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Sun Jan 25 12:34:29 2015 +0000
toolbar: don't explicitly show/hide stop/reload buttons
Just connect to the action enabled notification from the window's
GActionGroup.
src/nautilus-toolbar.c | 58 +++++++++++++++++++++++++++--------------------
src/nautilus-toolbar.h | 4 ---
src/nautilus-window.c | 7 -----
3 files changed, 33 insertions(+), 36 deletions(-)
---
diff --git a/src/nautilus-toolbar.c b/src/nautilus-toolbar.c
index 15c99bb..5cce59d 100644
--- a/src/nautilus-toolbar.c
+++ b/src/nautilus-toolbar.c
@@ -293,6 +293,38 @@ show_menu (NautilusToolbar *self,
button, event_time);
}
+static void
+action_reload_enabled_changed (GActionGroup *action_group,
+ gchar *action_name,
+ gboolean enabled,
+ gpointer user_data)
+{
+ NautilusToolbar *self = user_data;
+ gtk_widget_set_visible (self->priv->reload, enabled);
+}
+
+static void
+action_stop_enabled_changed (GActionGroup *action_group,
+ gchar *action_name,
+ gboolean enabled,
+ gpointer user_data)
+{
+ NautilusToolbar *self = user_data;
+ gtk_widget_set_visible (self->priv->stop, enabled);
+}
+
+static void
+nautilus_toolbar_set_window (NautilusToolbar *self,
+ NautilusWindow *window)
+
+{
+ self->priv->window = window;
+ g_signal_connect (self->priv->window, "action-enabled-changed::stop",
+ G_CALLBACK (action_stop_enabled_changed), self);
+ g_signal_connect (self->priv->window, "action-enabled-changed::reload",
+ G_CALLBACK (action_reload_enabled_changed), self);
+}
+
#define MENU_POPUP_TIMEOUT 1200
typedef struct {
@@ -481,7 +513,7 @@ nautilus_toolbar_set_property (GObject *object,
switch (property_id) {
case PROP_WINDOW:
- self->priv->window = g_value_get_object (value);
+ nautilus_toolbar_set_window (self, g_value_get_object (value));
break;
case PROP_SHOW_LOCATION_ENTRY:
nautilus_toolbar_set_show_location_entry (self, g_value_get_boolean (value));
@@ -610,30 +642,6 @@ nautilus_toolbar_show_visible_columns (NautilusToolbar *self)
}
void
-nautilus_toolbar_show_stop (NautilusToolbar *self)
-{
- gtk_widget_show (self->priv->stop);
-}
-
-void
-nautilus_toolbar_show_reload (NautilusToolbar *self)
-{
- gtk_widget_show (self->priv->reload);
-}
-
-void
-nautilus_toolbar_hide_stop (NautilusToolbar *self)
-{
- gtk_widget_hide (self->priv->stop);
-}
-
-void
-nautilus_toolbar_hide_reload (NautilusToolbar *self)
-{
- gtk_widget_hide (self->priv->reload);
-}
-
-void
nautilus_toolbar_view_menu_widget_set_zoom_level (NautilusToolbar *self,
gdouble level)
{
diff --git a/src/nautilus-toolbar.h b/src/nautilus-toolbar.h
index 9b04443..9acf3f9 100644
--- a/src/nautilus-toolbar.h
+++ b/src/nautilus-toolbar.h
@@ -87,9 +87,5 @@ void nautilus_toolbar_show_sort_menu (NautilusToolbar *self);
void nautilus_toolbar_show_sort_trash_time (NautilusToolbar *self);
void nautilus_toolbar_show_sort_search_relevance (NautilusToolbar *self);
void nautilus_toolbar_show_visible_columns (NautilusToolbar *self);
-void nautilus_toolbar_show_stop (NautilusToolbar *self);
-void nautilus_toolbar_show_reload (NautilusToolbar *self);
-void nautilus_toolbar_hide_stop (NautilusToolbar *self);
-void nautilus_toolbar_hide_reload (NautilusToolbar *self);
#endif /* __NAUTILUS_TOOLBAR_H__ */
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index b56ce6f..3b5dd81 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -742,13 +742,6 @@ nautilus_window_sync_allow_stop (NautilusWindow *window,
if (slot_is_active) {
g_simple_action_set_enabled (G_SIMPLE_ACTION (stop_action), slot_allow_stop);
g_simple_action_set_enabled (G_SIMPLE_ACTION (reload_action), !slot_allow_stop);
- if (slot_allow_stop) {
- nautilus_toolbar_hide_reload (NAUTILUS_TOOLBAR (window->details->toolbar));
- nautilus_toolbar_show_stop (NAUTILUS_TOOLBAR (window->details->toolbar));
- } else {
- nautilus_toolbar_hide_stop (NAUTILUS_TOOLBAR (window->details->toolbar));
- nautilus_toolbar_show_reload (NAUTILUS_TOOLBAR (window->details->toolbar));
- }
}
if (gtk_widget_get_realized (GTK_WIDGET (window))) {
update_cursor (window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]