pidgin/pidginaccountmanager.c

Fri, 27 May 2022 03:05:57 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 27 May 2022 03:05:57 -0500
changeset 41411
c2969c67490e
parent 41392
b5c84f55d5d2
child 41439
3745e6e9d836
permissions
-rw-r--r--

Remove a bunch of unused stuff in the gtkblist and set some sane defaults

Testing Done:
Ran and verified that the buddylist displayed all options by default now.

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

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
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 struct _PidginAccountManager {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 GtkDialog parent;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 GtkListStore *model;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 GtkTreeSelection *selection;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 GtkWidget *modify_button;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 GtkWidget *remove_button;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 };
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 enum {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 RESPONSE_ADD,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 RESPONSE_MODIFY,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 RESPONSE_REMOVE
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 };
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 enum {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 COLUMN_ENABLED,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 COLUMN_AVATAR,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 COLUMN_USERNAME,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 COLUMN_PROTOCOL_ICON,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 COLUMN_PROTOCOL_NAME,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 COLUMN_ACCOUNT
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 };
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 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
58
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 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
60
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 * Helpers
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 *****************************************************************************/
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 static gboolean
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 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
66 PurpleAccount *account, GtkTreeIter *iter)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 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
69
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 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
71 return FALSE;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 }
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 do {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 PurpleAccount *current = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 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
78 COLUMN_ACCOUNT, &current,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 -1);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 if(current == account) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 g_clear_object(&current);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 return TRUE;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 }
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 g_clear_object(&current);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 } 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
89
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 return FALSE;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 }
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 static PurpleAccount *
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 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
95 PurpleAccount *account = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 GtkTreeIter iter;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 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
99 return NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 }
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 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
103
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 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
105 COLUMN_ACCOUNT, &account,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 -1);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 return account;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 }
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 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 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
113 PurpleAccount *account,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 GtkTreeIter *iter)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 PurpleImage *image = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 PurpleProtocol *protocol = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 GdkPixbuf *avatar = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 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
120
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 /* 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
122 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
123 if(image != NULL) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 GdkPixbuf *raw = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125
41319
04d027ed3d63 Add gdk-pixbuf as a libpurple dependency and move helpers from pidgin to purple
Gary Kramlich <grim@reaperworld.com>
parents: 41310
diff changeset
126 raw = purple_gdk_pixbuf_from_image(image);
41310
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 g_object_unref(image);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 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
130 g_clear_object(&raw);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 }
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 /* Get the protocol fields. */
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 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
135 if(PURPLE_IS_PROTOCOL(protocol)) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 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
137 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
138 } else {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 protocol_name = _("Unknown");
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 }
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 gtk_list_store_set(manager->model, iter,
41392
b5c84f55d5d2 Remove the ui parameter from purple_account_[gs]et_enabled
Gary Kramlich <grim@reaperworld.com>
parents: 41319
diff changeset
143 COLUMN_ENABLED, purple_account_get_enabled(account),
41310
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 COLUMN_AVATAR, avatar,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 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
146 COLUMN_PROTOCOL_ICON, protocol_icon,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 COLUMN_PROTOCOL_NAME, protocol_name,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 COLUMN_ACCOUNT, account,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 -1);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 g_clear_object(&avatar);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 }
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 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 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
156 PurpleAccount *account)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 GtkTreeIter iter;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 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
161 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
162 }
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 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 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
167 PurpleAccount *account)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 GtkTreeIter iter;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 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
172
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 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
174
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 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
176 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
177 manager, 0);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 }
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 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 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
182 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
183 }
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 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 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
187 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
188 pidgin_account_manager_populate_helper,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 manager);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 }
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 * Callbacks
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 *****************************************************************************/
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 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
197 G_GNUC_UNUSED GParamSpec *pspec,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 gpointer data)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 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
201 PurpleAccount *account = PURPLE_ACCOUNT(obj);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 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
204 }
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 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 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
208 G_GNUC_UNUSED gpointer data)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 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
211 PurpleAccount *account = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 switch(response_id) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 case RESPONSE_ADD:
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 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
216 break;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 case RESPONSE_MODIFY:
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 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
219
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 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
221
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 g_clear_object(&account);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 break;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 case RESPONSE_REMOVE:
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 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
227
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 purple_accounts_delete(account);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230 g_clear_object(&account);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 break;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 case GTK_RESPONSE_CLOSE:
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 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
235 break;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236 default:
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 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
238 }
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 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242 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
243 gpointer data)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245 PidginAccountManager *manager = data;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 gboolean sensitive = TRUE;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 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
249 sensitive = FALSE;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 }
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 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
253 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
254 }
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 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 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
258 GtkTreePath *path,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259 G_GNUC_UNUSED GtkTreeViewColumn *column,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260 gpointer data)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
262 PidginAccountManager *manager = data;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263 GtkTreeIter iter;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265 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
266 PurpleAccount *account = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268 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
269 COLUMN_ACCOUNT, &account,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270 -1);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272 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
273
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274 g_clear_object(&account);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
275 }
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 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279 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
280 gchar *path, gpointer data)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282 PidginAccountManager *manager = data;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
283 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
284 GtkTreeIter iter;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286 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
287 PurpleAccount *account = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 gboolean enabled = FALSE;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290 /* 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
291 * 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
292 * versa.
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293 */
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294 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
295 COLUMN_ENABLED, &enabled,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 COLUMN_ACCOUNT, &account,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297 -1);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299 /* 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
300 if(!enabled) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301 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
302 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
303 }
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
304
41392
b5c84f55d5d2 Remove the ui parameter from purple_account_[gs]et_enabled
Gary Kramlich <grim@reaperworld.com>
parents: 41319
diff changeset
305 purple_account_set_enabled(account, !enabled);
41310
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
306
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307 /* 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
308 * signal.
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309 */
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 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
314 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
315 PurpleAccount *account,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
316 gpointer data)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
317 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
318 PidginAccountManager *manager = data;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
319
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
320 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
321 }
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 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
324 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
325 PurpleAccount *account,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
326 gpointer data)
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
327 {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
328 PidginAccountManager *manager = data;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
329 GtkTreeIter iter;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
330
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
331 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
332 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
333 }
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 * GObject Implementation
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338 *****************************************************************************/
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340 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
341 PurpleAccountManager *purple_manager = NULL;
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
343 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
344
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
345 pidgin_account_manager_populate(manager);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
346
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347 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
348 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
349 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
350 manager, 0);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351 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
352 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
353 manager, 0);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354 }
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 static void
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
357 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
358 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
359
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
360 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
361 widget_class,
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
362 "/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
363 );
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 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
366 model);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
367 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
368 selection);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
369
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
370 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
371 modify_button);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
372 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
373 remove_button);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
374
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
375 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
376 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
377 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
378 pidgin_account_manager_response_cb);
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
379 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
380 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
381 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
382 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
383 }
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 * Public API
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
387 *****************************************************************************/
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
388 GtkWidget *
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
389 pidgin_account_manager_new(void) {
53e4815ef254 Create a new PidginAccountManager that replaces the manually built one.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
390 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
391 }

mercurial