From a1a6d017403f00f39d34611d0890edb8cebf9389 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Mon, 20 Apr 2009 02:02:57 +0100 Subject: Set Enabled dbus property to the correct value depending on whether the signal is connected and whether the pause button is pressed. Signed-off-by: Jonny Lamb --- src/empathy-debug-dialog.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/empathy-debug-dialog.c b/src/empathy-debug-dialog.c index 5b6b509be..ec9c9ddb8 100644 --- a/src/empathy-debug-dialog.c +++ b/src/empathy-debug-dialog.c @@ -150,6 +150,21 @@ debug_dialog_new_debug_message_cb (TpProxy *proxy, message); } +static void +debug_dialog_set_enabled (EmpathyDebugDialog *debug_dialog, + gboolean enabled) +{ + EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog); + GValue *val; + + val = tp_g_value_slice_new_boolean (enabled); + + tp_cli_dbus_properties_call_set (priv->proxy, -1, EMP_IFACE_DEBUG, + "Enabled", val, NULL, NULL, NULL, NULL); + + tp_g_value_slice_free (val); +} + static void debug_dialog_get_messages_cb (TpProxy *proxy, const GPtrArray *messages, @@ -182,6 +197,9 @@ debug_dialog_get_messages_cb (TpProxy *proxy, priv->signal_connection = emp_cli_debug_connect_to_new_debug_message ( proxy, debug_dialog_new_debug_message_cb, debug_dialog, NULL, NULL, NULL); + + /* Set Enabled as appropriate */ + debug_dialog_set_enabled (debug_dialog, !priv->paused); } static void @@ -222,8 +240,8 @@ debug_dialog_account_chooser_changed_cb (GtkComboBox *account_chooser, return; } - if (priv->proxy) - g_object_unref (priv->proxy); + /* Disable debug signalling */ + debug_dialog_set_enabled (debug_dialog, FALSE); /* Disconnect from previous NewDebugMessage signal */ if (priv->signal_connection) @@ -232,6 +250,9 @@ debug_dialog_account_chooser_changed_cb (GtkComboBox *account_chooser, priv->signal_connection = NULL; } + if (priv->proxy) + g_object_unref (priv->proxy); + priv->proxy = TP_PROXY (g_object_ref (connection)); emp_cli_debug_call_get_messages (priv->proxy, -1, @@ -247,16 +268,10 @@ debug_dialog_pause_toggled_cb (GtkToggleToolButton *pause, EmpathyDebugDialog *debug_dialog) { EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog); - GValue *val; priv->paused = gtk_toggle_tool_button_get_active (pause); - val = tp_g_value_slice_new_boolean (!priv->paused); - - tp_cli_dbus_properties_call_set (priv->proxy, -1, EMP_IFACE_DEBUG, - "Enabled", val, NULL, NULL, NULL, NULL); - - tp_g_value_slice_free (val); + debug_dialog_set_enabled (debug_dialog, !priv->paused); } static GObject * @@ -481,6 +496,8 @@ debug_dialog_dispose (GObject *object) if (priv->store) g_object_unref (priv->store); + debug_dialog_set_enabled (EMPATHY_DEBUG_DIALOG (object), FALSE); + if (priv->proxy) g_object_unref (priv->proxy); -- cgit v1.2.3