pidgin/pidginaccountmanager.c

Tue, 22 Mar 2022 07:46:43 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 22 Mar 2022 07:46:43 -0500
changeset 41310
53e4815ef254
child 41319
04d027ed3d63
permissions
-rw-r--r--

Create a new PidginAccountManager that replaces the manually built one.

The old code was left to keep this change as clean as possible and will be
removed afterwards.

Drag and drop as been removed as it's completely different in GTK4 and I didn't
want to waste time on it since it's going to be deleted when it's rewritten.

I also didn't implement the double click to modify account as that's different
in GTK4 and we don't yet have new Event Controller for it in GTK3.

Support for selecting multiple accounts was dropped and now only one account may be selected at a time.

Finally, I changed the title of the "Delete" button to "Remove" as "Remove"
seems more clear.

Testing Done:
Used the previous dialog to add, remove, and modify accounts and verified they were updated appropriately.
Also started pidgin without any accounts enabled, to verify that the new dialog was shown instead of the old.
Tested the add, modify, remove, and close buttons.
Tested that the modify and remove buttons are only sensitive when an account is selected.

Bugs closed: PIDGIN-17589

Reviewed at https://reviews.imfreedom.org/r/1318/

41310
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <glib/gi18n.h>
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include <purple.h>
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include "pidginaccountmanager.h"
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 #include "gtkaccount.h"
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 #include "pidgincore.h"
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 #include "pidgingdkpixbuf.h"
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 struct _PidginAccountManager {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 GtkDialog parent;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 GtkListStore *model;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 GtkTreeSelection *selection;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 GtkWidget *modify_button;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 GtkWidget *remove_button;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 };
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 enum {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 RESPONSE_ADD,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 RESPONSE_MODIFY,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 RESPONSE_REMOVE
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 };
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 enum {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 COLUMN_ENABLED,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 COLUMN_AVATAR,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 COLUMN_USERNAME,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 COLUMN_PROTOCOL_ICON,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 COLUMN_PROTOCOL_NAME,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 COLUMN_ACCOUNT
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 };
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 G_DEFINE_TYPE(PidginAccountManager, pidgin_account_manager, GTK_TYPE_DIALOG)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 static void pidgin_account_manager_account_notify_cb(GObject *obj, GParamSpec *pspec, gpointer data);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 /******************************************************************************
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 * Helpers
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 *****************************************************************************/
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 static gboolean
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 pidgin_account_manager_find_account(PidginAccountManager *manager,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 PurpleAccount *account, GtkTreeIter *iter)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 GtkTreeModel *model = GTK_TREE_MODEL(manager->model);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 if(!gtk_tree_model_get_iter_first(model, iter)) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 return FALSE;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 do {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 PurpleAccount *current = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 gtk_tree_model_get(model, iter,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 COLUMN_ACCOUNT, &current,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 -1);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 if(current == account) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 g_clear_object(&current);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 return TRUE;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 g_clear_object(&current);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 } while(gtk_tree_model_iter_next(model, iter));
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 return FALSE;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 static PurpleAccount *
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 pidgin_account_manager_get_selected_account(PidginAccountManager *manager) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 PurpleAccount *account = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 GtkTreeIter iter;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 if(gtk_tree_selection_count_selected_rows(manager->selection) == 0) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 return NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 gtk_tree_selection_get_selected(manager->selection, NULL, &iter);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 gtk_tree_model_get(GTK_TREE_MODEL(manager->model), &iter,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 COLUMN_ACCOUNT, &account,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 -1);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 return account;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 pidgin_account_manager_refresh_account(PidginAccountManager *manager,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 PurpleAccount *account,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 GtkTreeIter *iter)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 PurpleImage *image = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 PurpleProtocol *protocol = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 GdkPixbuf *avatar = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 const gchar *protocol_icon = NULL, *protocol_name = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 /* Try to find the avatar for the account. */
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 image = purple_buddy_icons_find_account_icon(account);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 if(image != NULL) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 GdkPixbuf *raw = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 raw = pidgin_pixbuf_from_image(image);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 g_object_unref(image);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 avatar = gdk_pixbuf_scale_simple(raw, 22, 22, GDK_INTERP_HYPER);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 g_clear_object(&raw);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 /* Get the protocol fields. */
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 protocol = purple_account_get_protocol(account);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 if(PURPLE_IS_PROTOCOL(protocol)) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 protocol_name = purple_protocol_get_name(protocol);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 protocol_icon = purple_protocol_get_icon_name(protocol);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 } else {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 protocol_name = _("Unknown");
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 gtk_list_store_set(manager->model, iter,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 COLUMN_ENABLED, purple_account_get_enabled(account, PIDGIN_UI),
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 COLUMN_AVATAR, avatar,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 COLUMN_USERNAME, purple_account_get_username(account),
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 COLUMN_PROTOCOL_ICON, protocol_icon,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 COLUMN_PROTOCOL_NAME, protocol_name,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 COLUMN_ACCOUNT, account,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 -1);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 g_clear_object(&avatar);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 pidgin_account_manager_update_account(PidginAccountManager *manager,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 PurpleAccount *account)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 GtkTreeIter iter;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 if(pidgin_account_manager_find_account(manager, account, &iter)) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 pidgin_account_manager_refresh_account(manager, account, &iter);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 pidgin_account_manager_add_account(PidginAccountManager *manager,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 PurpleAccount *account)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 GtkTreeIter iter;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 gtk_list_store_append(manager->model, &iter);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 pidgin_account_manager_refresh_account(manager, account, &iter);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 g_signal_connect_object(account, "notify",
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 G_CALLBACK(pidgin_account_manager_account_notify_cb),
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 manager, 0);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 pidgin_account_manager_populate_helper(PurpleAccount *account, gpointer data) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 pidgin_account_manager_add_account(PIDGIN_ACCOUNT_MANAGER(data), account);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 pidgin_account_manager_populate(PidginAccountManager *manager) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 purple_account_manager_foreach(purple_account_manager_get_default(),
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 pidgin_account_manager_populate_helper,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 manager);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 /******************************************************************************
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 * Callbacks
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 *****************************************************************************/
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 pidgin_account_manager_account_notify_cb(GObject *obj,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 G_GNUC_UNUSED GParamSpec *pspec,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 gpointer data)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 PidginAccountManager *manager = PIDGIN_ACCOUNT_MANAGER(data);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 PurpleAccount *account = PURPLE_ACCOUNT(obj);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 pidgin_account_manager_update_account(manager, account);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 pidgin_account_manager_response_cb(GtkDialog *dialog, gint response_id,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 G_GNUC_UNUSED gpointer data)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 PidginAccountManager *manager = PIDGIN_ACCOUNT_MANAGER(dialog);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 PurpleAccount *account = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 switch(response_id) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 case RESPONSE_ADD:
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 pidgin_account_dialog_show(PIDGIN_ADD_ACCOUNT_DIALOG, NULL);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 break;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 case RESPONSE_MODIFY:
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 account = pidgin_account_manager_get_selected_account(manager);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 pidgin_account_dialog_show(PIDGIN_MODIFY_ACCOUNT_DIALOG, account);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 g_clear_object(&account);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 break;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 case RESPONSE_REMOVE:
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 account = pidgin_account_manager_get_selected_account(manager);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 purple_accounts_delete(account);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 g_clear_object(&account);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 break;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 case GTK_RESPONSE_CLOSE:
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 gtk_widget_destroy(GTK_WIDGET(dialog));
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236 break;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 default:
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238 g_warning("not sure how you got here...");
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
240 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 pidgin_account_manager_selection_changed_cb(GtkTreeSelection *selection,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244 gpointer data)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 PidginAccountManager *manager = data;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247 gboolean sensitive = TRUE;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249 if(gtk_tree_selection_count_selected_rows(selection) == 0) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 sensitive = FALSE;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253 gtk_widget_set_sensitive(manager->modify_button, sensitive);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 gtk_widget_set_sensitive(manager->remove_button, sensitive);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258 pidgin_account_manager_row_activated_cb(G_GNUC_UNUSED GtkTreeView *tree_view,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259 GtkTreePath *path,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260 G_GNUC_UNUSED GtkTreeViewColumn *column,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261 gpointer data)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
262 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263 PidginAccountManager *manager = data;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 GtkTreeIter iter;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266 if(gtk_tree_model_get_iter(GTK_TREE_MODEL(manager->model), &iter, path)) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267 PurpleAccount *account = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269 gtk_tree_model_get(GTK_TREE_MODEL(manager->model), &iter,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270 COLUMN_ACCOUNT, &account,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271 -1);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273 pidgin_account_dialog_show(PIDGIN_MODIFY_ACCOUNT_DIALOG, account);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
275 g_clear_object(&account);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
276 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
278
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 pidgin_account_manager_enable_toggled_cb(G_GNUC_UNUSED GtkCellRendererToggle *renderer,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281 gchar *path, gpointer data)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
283 PidginAccountManager *manager = data;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
284 GtkTreeModel *model = GTK_TREE_MODEL(manager->model);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285 GtkTreeIter iter;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
287 if(gtk_tree_model_get_iter_from_string(model, &iter, path)) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 PurpleAccount *account = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289 gboolean enabled = FALSE;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
291 /* The value of enabled in the model is the old value, so if enabled
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
292 * is currently set to TRUE, we are disabling the account and vice
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293 * versa.
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294 */
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295 gtk_tree_model_get(model, &iter,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 COLUMN_ENABLED, &enabled,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297 COLUMN_ACCOUNT, &account,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298 -1);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 /* The account was just enabled, so set its status. */
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301 if(!enabled) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
302 PurpleSavedStatus *status = purple_savedstatus_get_current();
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
303 purple_savedstatus_activate_for_account(status, account);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
304 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
305
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
306 purple_account_set_enabled(account, PIDGIN_UI, !enabled);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 /* We don't update the model here, as it's updated via the notify
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309 * signal.
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310 */
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
312 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
313
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
314 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
315 pidgin_account_manager_account_added_cb(G_GNUC_UNUSED PurpleAccountManager *purple_manager,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
316 PurpleAccount *account,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
317 gpointer data)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
318 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
319 PidginAccountManager *manager = data;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
320
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
321 pidgin_account_manager_add_account(manager, account);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
322 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
323
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
324 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
325 pidgin_account_manager_account_removed_cb(G_GNUC_UNUSED PurpleAccountManager *purple_manager,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
326 PurpleAccount *account,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
327 gpointer data)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
328 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
329 PidginAccountManager *manager = data;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
330 GtkTreeIter iter;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
331
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
332 if(pidgin_account_manager_find_account(manager, account, &iter)) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
333 gtk_list_store_remove(manager->model, &iter);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
334 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
335 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
336
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
337 /******************************************************************************
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338 * GObject Implementation
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339 *****************************************************************************/
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341 pidgin_account_manager_init(PidginAccountManager *manager) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342 PurpleAccountManager *purple_manager = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
343
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
344 gtk_widget_init_template(GTK_WIDGET(manager));
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
345
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
346 pidgin_account_manager_populate(manager);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
348 purple_manager = purple_account_manager_get_default();
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
349 g_signal_connect_object(purple_manager, "added",
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
350 G_CALLBACK(pidgin_account_manager_account_added_cb),
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351 manager, 0);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
352 g_signal_connect_object(purple_manager, "removed",
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
353 G_CALLBACK(pidgin_account_manager_account_removed_cb),
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354 manager, 0);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
355 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
356
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
357 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
358 pidgin_account_manager_class_init(PidginAccountManagerClass *klass) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
359 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
360
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
361 gtk_widget_class_set_template_from_resource(
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
362 widget_class,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
363 "/im/pidgin/Pidgin3/Accounts/manager.ui"
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
364 );
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
365
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
366 gtk_widget_class_bind_template_child(widget_class, PidginAccountManager,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
367 model);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
368 gtk_widget_class_bind_template_child(widget_class, PidginAccountManager,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
369 selection);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
370
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
371 gtk_widget_class_bind_template_child(widget_class, PidginAccountManager,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
372 modify_button);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
373 gtk_widget_class_bind_template_child(widget_class, PidginAccountManager,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
374 remove_button);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
375
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
376 gtk_widget_class_bind_template_callback(widget_class,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
377 pidgin_account_manager_enable_toggled_cb);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
378 gtk_widget_class_bind_template_callback(widget_class,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
379 pidgin_account_manager_response_cb);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
380 gtk_widget_class_bind_template_callback(widget_class,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
381 pidgin_account_manager_row_activated_cb);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
382 gtk_widget_class_bind_template_callback(widget_class,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
383 pidgin_account_manager_selection_changed_cb);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
384 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
385
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
386 /******************************************************************************
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
387 * Public API
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
388 *****************************************************************************/
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
389 GtkWidget *
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
390 pidgin_account_manager_new(void) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
391 return g_object_new(PIDGIN_TYPE_ACCOUNT_MANAGER, NULL);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
392 }

mercurial