Mercurial > pidgin.yaz
changeset 12070:e4666705944b
[gaim-migrate @ 14365]
patches [ 1353462 ] account-disabled/enabled signals, use them in account dialog
and [ 1355690 ] Add/remove statusbox when accounts are enabled/disabled
some parts of the first one didn't apply, but they were doc changes, so
i figured charkins could diff them.
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Sun, 13 Nov 2005 03:45:16 +0000 |
parents | 1019f1d510d6 |
children | f4a066f2e6be |
files | doc/account-signals.dox src/account.c src/gtkaccount.c src/gtkblist.c |
diffstat | 4 files changed, 97 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/account-signals.dox Sun Nov 13 03:39:06 2005 +0000 +++ b/doc/account-signals.dox Sun Nov 13 03:45:16 2005 +0000 @@ -38,6 +38,24 @@ @param account The account that was removed. @endsignaldef + @signaldef account-disabled + @signalproto +void (*account_disabled)(GaimAccount *account); + @endsignalproto + @signaldesc + Emitted when an account is disabled. + @param account The account that was disabled. + @endsignaldef + + @signaldef account-enabled + @signalproto +void (*account_enabled)(GaimAccount *account); + @endsignalproto + @signaldesc + Emitted when an account is enabled. + @param account The account that was enabled. + @endsignaldef + @signaldef account-setting-info @signalproto void (*account_setting_info)(GaimAccount *account, const char *new_info);
--- a/src/account.c Sun Nov 13 03:39:06 2005 +0000 +++ b/src/account.c Sun Nov 13 03:45:16 2005 +0000 @@ -1292,13 +1292,21 @@ gboolean value) { GaimConnection *gc; + gboolean was_enabled = FALSE; g_return_if_fail(account != NULL); g_return_if_fail(ui != NULL); + was_enabled = gaim_account_get_enabled(account, ui); + gaim_account_set_ui_bool(account, ui, "auto-login", value); gc = gaim_account_get_connection(account); + if(was_enabled && !value) + gaim_signal_emit(gaim_accounts_get_handle(), "account-disabled", account); + else if(!was_enabled && value) + gaim_signal_emit(gaim_accounts_get_handle(), "account-enabled", account); + if ((gc != NULL) && (gc->wants_to_die == TRUE)) return; @@ -2252,6 +2260,16 @@ gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_ACCOUNT)); + gaim_signal_register(handle, "account-disabled", + gaim_marshal_VOID__POINTER, NULL, 1, + gaim_value_new(GAIM_TYPE_SUBTYPE, + GAIM_SUBTYPE_ACCOUNT)); + + gaim_signal_register(handle, "account-enabled", + gaim_marshal_VOID__POINTER, NULL, 1, + gaim_value_new(GAIM_TYPE_SUBTYPE, + GAIM_SUBTYPE_ACCOUNT)); + gaim_signal_register(handle, "account-setting-info", gaim_marshal_VOID__POINTER_POINTER, NULL, 2, gaim_value_new(GAIM_TYPE_SUBTYPE,
--- a/src/gtkaccount.c Sun Nov 13 03:39:06 2005 +0000 +++ b/src/gtkaccount.c Sun Nov 13 03:45:16 2005 +0000 @@ -1904,6 +1904,21 @@ } static void +account_abled_cb(GaimAccount *account, gpointer user_data) +{ + GtkTreeIter iter; + + if (accounts_window == NULL) + return; + + /* update the account in the GtkListStore */ + if (accounts_window_find_account_in_treemodel(&iter, account)) + gtk_list_store_set(accounts_window->model, &iter, + COLUMN_ENABLED, GPOINTER_TO_INT(user_data), + -1); +} + +static void drag_data_get_cb(GtkWidget *widget, GdkDragContext *ctx, GtkSelectionData *data, guint info, guint time, AccountsWindow *dialog) @@ -2167,10 +2182,6 @@ gaim_savedstatus_activate_for_account(saved_status, account); gaim_account_set_enabled(account, GAIM_GTK_UI, !enabled); - - gtk_list_store_set(dialog->model, &iter, - COLUMN_ENABLED, !enabled, - -1); } static void @@ -2620,6 +2631,12 @@ gaim_signal_connect(gaim_accounts_get_handle(), "account-removed", gaim_gtk_account_get_handle(), GAIM_CALLBACK(account_removed_cb), NULL); + gaim_signal_connect(gaim_accounts_get_handle(), "account-disabled", + gaim_gtk_account_get_handle(), + GAIM_CALLBACK(account_abled_cb), GINT_TO_POINTER(FALSE)); + gaim_signal_connect(gaim_accounts_get_handle(), "account-enabled", + gaim_gtk_account_get_handle(), + GAIM_CALLBACK(account_abled_cb), GINT_TO_POINTER(TRUE)); account_pref_wins = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL);
--- a/src/gtkblist.c Sun Nov 13 03:39:06 2005 +0000 +++ b/src/gtkblist.c Sun Nov 13 03:45:16 2005 +0000 @@ -3247,6 +3247,41 @@ return result; } +static void account_enabled(GaimAccount *account, GaimGtkBuddyList *gtkblist) +{ + GtkWidget *box; + + if (!gtkblist) + return; + + box = gtk_gaim_status_box_new_with_account(account); + gtkblist->statusboxes = g_list_append(gtkblist->statusboxes, box); + gtk_box_pack_start(GTK_BOX(gtkblist->statusboxbox), box, FALSE, TRUE, 0); + gtk_widget_show(box); +} + +static void account_disabled(GaimAccount *account, GaimGtkBuddyList *gtkblist) +{ + GList *iter; + + if (!gtkblist) + return; + + for (iter = gtkblist->statusboxes; iter; iter = iter->next) + { + GtkWidget *box = iter->data; + GaimAccount *ac = NULL; + + g_object_get(G_OBJECT(box), "account", &ac, NULL); + if (ac == account) + { + gtkblist->statusboxes = g_list_remove_link(gtkblist->statusboxes, iter); + gtk_widget_destroy(box); + break; + } + } +} + static void gaim_gtk_blist_show(GaimBuddyList *list) { void *handle; @@ -3480,6 +3515,11 @@ gaim_gtk_blist_sound_method_pref_cb, NULL); /* Setup some gaim signal handlers. */ + gaim_signal_connect(gaim_accounts_get_handle(), "account-disabled", + gtkblist, GAIM_CALLBACK(account_disabled), gtkblist); + gaim_signal_connect(gaim_accounts_get_handle(), "account-enabled", + gtkblist, GAIM_CALLBACK(account_enabled), gtkblist); + gaim_signal_connect(gaim_connections_get_handle(), "signed-on", gtkblist, GAIM_CALLBACK(sign_on_off_cb), list); gaim_signal_connect(gaim_connections_get_handle(), "signed-off",