From 0110c94c6abdbb25b4fea6a21f20f00b82a0fdd8 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 19 Feb 2009 05:52:33 +0000 Subject: Rename EShell:online-mode to EShell:online and update docs. Use EBindings instead of a notify callback to keep other widgets and actions synchronized with EShell:online. Cleaner and less error prone. svn path=/branches/kill-bonobo/; revision=37293 --- shell/e-shell-window-actions.c | 4 +-- shell/e-shell-window-private.c | 25 ++++++++++++++ shell/e-shell-window.c | 35 +------------------- shell/e-shell.c | 74 +++++++++++++++++++++--------------------- shell/e-shell.h | 6 ++-- shell/main.c | 10 +++--- 6 files changed, 73 insertions(+), 81 deletions(-) (limited to 'shell') diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c index a9ed7efb09..2364a69e4b 100644 --- a/shell/e-shell-window-actions.c +++ b/shell/e-shell-window-actions.c @@ -1360,7 +1360,7 @@ action_work_offline_cb (GtkAction *action, EShell *shell; shell = e_shell_window_get_shell (shell_window); - e_shell_set_online_mode (shell, FALSE); + e_shell_set_online (shell, FALSE); } /** @@ -1378,7 +1378,7 @@ action_work_online_cb (GtkAction *action, EShell *shell; shell = e_shell_window_get_shell (shell_window); - e_shell_set_online_mode (shell, TRUE); + e_shell_set_online (shell, TRUE); } /** diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c index bfaa87396b..38d3926d67 100644 --- a/shell/e-shell-window-private.c +++ b/shell/e-shell-window-private.c @@ -336,6 +336,7 @@ e_shell_window_private_constructed (EShellWindow *shell_window) EShell *shell; GConfBridge *bridge; GtkActionGroup *action_group; + GtkAction *action; GObject *object; const gchar *key; @@ -369,6 +370,30 @@ e_shell_window_private_constructed (EShellWindow *shell_window) G_OBJECT (shell_settings), "disable-save-to-disk", G_OBJECT (action_group), "sensitive"); + /* Bind GObject properties to GObject properties. */ + + action = ACTION (SEND_RECEIVE); + + e_binding_new ( + G_OBJECT (shell), "online", + G_OBJECT (action), "sensitive"); + + action = ACTION (WORK_OFFLINE); + + e_binding_new ( + G_OBJECT (shell), "online", + G_OBJECT (action), "visible"); + + action = ACTION (WORK_ONLINE); + + e_binding_new_with_negation ( + G_OBJECT (shell), "online", + G_OBJECT (action), "visible"); + + e_binding_new ( + G_OBJECT (shell), "online", + G_OBJECT (shell_window->priv->online_button), "online"); + /* Bind GObject properties to GConf keys. */ bridge = gconf_bridge_get (); diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c index 6adfe6e9b7..d6d49cfe3c 100644 --- a/shell/e-shell-window.c +++ b/shell/e-shell-window.c @@ -105,32 +105,6 @@ shell_window_new_view (EShellWindow *shell_window, return shell_view; } -static void -shell_window_online_mode_notify_cb (EShell *shell, - GParamSpec *pspec, - EShellWindow *shell_window) -{ - GtkAction *action; - EOnlineButton *online_button; - gboolean online_mode; - - online_mode = e_shell_get_online_mode (shell); - - action = ACTION (SEND_RECEIVE); - gtk_action_set_sensitive (action, online_mode); - - action = ACTION (WORK_OFFLINE); - gtk_action_set_sensitive (action, TRUE); - gtk_action_set_visible (action, online_mode); - - action = ACTION (WORK_ONLINE); - gtk_action_set_sensitive (action, TRUE); - gtk_action_set_visible (action, !online_mode); - - online_button = E_ONLINE_BUTTON (shell_window->priv->online_button); - e_online_button_set_online (online_button, online_mode); -} - static void shell_window_update_close_action_cb (EShellWindow *shell_window) { @@ -172,13 +146,6 @@ shell_window_set_shell (EShellWindow *shell_window, array = shell_window->priv->signal_handler_ids; - handler_id = g_signal_connect ( - shell, "notify::online-mode", - G_CALLBACK (shell_window_online_mode_notify_cb), - shell_window); - - g_array_append_val (array, handler_id); - handler_id = g_signal_connect_swapped ( shell, "window-created", G_CALLBACK (shell_window_update_close_action_cb), @@ -193,7 +160,7 @@ shell_window_set_shell (EShellWindow *shell_window, g_array_append_val (array, handler_id); - g_object_notify (G_OBJECT (shell), "online-mode"); + g_object_notify (G_OBJECT (shell), "online"); } static void diff --git a/shell/e-shell.c b/shell/e-shell.c index 203e216344..3b5c78393d 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -51,14 +51,14 @@ struct _EShellPrivate { guint auto_reconnect : 1; guint network_available : 1; - guint online_mode : 1; + guint online : 1; guint safe_mode : 1; }; enum { PROP_0, PROP_NETWORK_AVAILABLE, - PROP_ONLINE_MODE, + PROP_ONLINE, PROP_SHELL_SETTINGS }; @@ -103,11 +103,11 @@ shell_parse_debug_string (EShell *shell) } static void -shell_notify_online_mode_cb (EShell *shell) +shell_notify_online_cb (EShell *shell) { gboolean online; - online = e_shell_get_online_mode (shell); + online = e_shell_get_online (shell); e_passwords_set_online (online); } @@ -175,8 +175,8 @@ shell_ready_for_offline (EShell *shell, G_OBJECT (activity), (GToggleNotify) shell_ready_for_offline, shell); - shell->priv->online_mode = FALSE; - g_object_notify (G_OBJECT (shell), "online-mode"); + shell->priv->online = FALSE; + g_object_notify (G_OBJECT (shell), "online"); g_message ("Offline preparations complete."); } @@ -222,8 +222,8 @@ shell_ready_for_online (EShell *shell, G_OBJECT (activity), (GToggleNotify) shell_ready_for_online, shell); - shell->priv->online_mode = TRUE; - g_object_notify (G_OBJECT (shell), "online-mode"); + shell->priv->online = TRUE; + g_object_notify (G_OBJECT (shell), "online"); g_message ("Online preparations complete."); } @@ -409,8 +409,8 @@ shell_set_property (GObject *object, g_value_get_boolean (value)); return; - case PROP_ONLINE_MODE: - e_shell_set_online_mode ( + case PROP_ONLINE: + e_shell_set_online ( E_SHELL (object), g_value_get_boolean (value)); return; @@ -432,9 +432,9 @@ shell_get_property (GObject *object, E_SHELL (object))); return; - case PROP_ONLINE_MODE: + case PROP_ONLINE: g_value_set_boolean ( - value, e_shell_get_online_mode ( + value, e_shell_get_online ( E_SHELL (object))); return; @@ -615,16 +615,16 @@ shell_class_init (EShellClass *class) G_PARAM_CONSTRUCT)); /** - * EShell:online-mode + * EShell:online * * Whether the shell is online. **/ g_object_class_install_property ( object_class, - PROP_ONLINE_MODE, + PROP_ONLINE, g_param_spec_boolean ( - "online-mode", - _("Online Mode"), + "online", + _("Online"), _("Whether the shell is online"), FALSE, G_PARAM_READWRITE | @@ -848,8 +848,8 @@ shell_init (EShell *shell) shell_parse_debug_string (shell); g_signal_connect ( - shell, "notify::online-mode", - G_CALLBACK (shell_notify_online_mode_cb), NULL); + shell, "notify::online", + G_CALLBACK (shell_notify_online_cb), NULL); e_shell_settings_bind_to_gconf ( shell->priv->settings, "disable-application-handlers", @@ -1264,9 +1264,9 @@ e_shell_get_network_available (EShell *shell) * * Sets whether a network is available. This is usually called in * response to a status change signal from NetworkManager. If the - * network becomes unavailable while #EShell:online-mode is %TRUE, - * the @shell will force #EShell:online-mode to %FALSE until the - * network becomes available again. + * network becomes unavailable while #EShell:online is %TRUE, the + * @shell will force #EShell:online to %FALSE until the network + * becomes available again. **/ void e_shell_set_network_available (EShell *shell, @@ -1282,52 +1282,52 @@ e_shell_set_network_available (EShell *shell, /* If we're being forced offline, perhaps due to a network outage, * reconnect automatically when the network becomes available. */ - if (!network_available && shell->priv->online_mode) { + if (!network_available && shell->priv->online) { g_message ("Network disconnected. Forced offline."); - e_shell_set_online_mode (shell, FALSE); + e_shell_set_online (shell, FALSE); shell->priv->auto_reconnect = TRUE; } else if (network_available && shell->priv->auto_reconnect) { g_message ("Connection established. Going online."); - e_shell_set_online_mode (shell, TRUE); + e_shell_set_online (shell, TRUE); shell->priv->auto_reconnect = FALSE; } } /** - * e_shell_get_online_mode: + * e_shell_get_online: * @shell: an #EShell * - * Returns %TRUE if Evolution is in online mode, %FALSE if Evolution is - * offline. Evolution may be offline because the user elected to work - * offline, or because the network has become unavailable. + * Returns %TRUE if Evolution is online, %FALSE if Evolution is offline. + * Evolution may be offline because the user elected to work offline, or + * because the network has become unavailable. * - * Returns: %TRUE if Evolution is in online mode + * Returns: %TRUE if Evolution is online **/ gboolean -e_shell_get_online_mode (EShell *shell) +e_shell_get_online (EShell *shell) { g_return_val_if_fail (E_IS_SHELL (shell), FALSE); - return shell->priv->online_mode; + return shell->priv->online; } /** - * e_shell_set_online_mode: + * e_shell_set_online: * @shell: an #EShell - * @online_mode: whether to put Evolution in online mode + * @online: %TRUE to go online, %FALSE to go offline * * Asynchronously places Evolution in online or offline mode. **/ void -e_shell_set_online_mode (EShell *shell, - gboolean online_mode) +e_shell_set_online (EShell *shell, + gboolean online) { g_return_if_fail (E_IS_SHELL (shell)); - if (online_mode == shell->priv->online_mode) + if (online == shell->priv->online) return; - if (online_mode) + if (online) shell_prepare_for_online (shell); else shell_prepare_for_offline (shell); diff --git a/shell/e-shell.h b/shell/e-shell.h index 137900214d..91ff459a65 100644 --- a/shell/e-shell.h +++ b/shell/e-shell.h @@ -99,9 +99,9 @@ void e_shell_send_receive (EShell *shell, gboolean e_shell_get_network_available (EShell *shell); void e_shell_set_network_available (EShell *shell, gboolean network_available); -gboolean e_shell_get_online_mode (EShell *shell); -void e_shell_set_online_mode (EShell *shell, - gboolean online_mode); +gboolean e_shell_get_online (EShell *shell); +void e_shell_set_online (EShell *shell, + gboolean online); GtkWidget * e_shell_get_preferences_window (void); void e_shell_event (EShell *shell, const gchar *event_name, diff --git a/shell/main.c b/shell/main.c index ce1b467754..df542568f3 100644 --- a/shell/main.c +++ b/shell/main.c @@ -578,7 +578,7 @@ create_default_shell (void) EShell *shell; GConfClient *conf_client; GnomeClient *master_client; - gboolean online_mode = TRUE; + gboolean online = TRUE; gchar *startup_id; GError *error = NULL; @@ -586,9 +586,9 @@ create_default_shell (void) master_client = gnome_master_client (); if (start_online) - online_mode = TRUE; + online = TRUE; else if (start_offline) - online_mode = FALSE; + online = FALSE; else { const gchar *key; gboolean value; @@ -596,7 +596,7 @@ create_default_shell (void) key = "/apps/evolution/shell/start_offline"; value = gconf_client_get_bool (conf_client, key, &error); if (error == NULL) - online_mode = !value; + online = !value; else { g_warning ("%s", error->message); g_error_free (error); @@ -608,7 +608,7 @@ create_default_shell (void) shell = g_object_new ( E_TYPE_SHELL, "name", "org.gnome.evolution", - "online-mode", online_mode, + "online", online, "startup-id", startup_id, NULL); -- cgit v1.2.3