Thu, 25 Aug 2022 20:28:29 -0500
Port the AccountChooser to GTK4
Testing Done:
Open the new im dialog and verified the account chooser worked as expected.
Reviewed at https://reviews.imfreedom.org/r/1645/
|
40297
082c07053a79
Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
40296
diff
changeset
|
1 | /* |
|
082c07053a79
Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
40296
diff
changeset
|
2 | * Pidgin - Internet Messenger |
|
082c07053a79
Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
40296
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
40296
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * Pidgin is the legal property of its developers, whose names are too numerous |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * source distribution. |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * This program is free software; you can redistribute it and/or modify |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * it under the terms of the GNU General Public License as published by |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * the Free Software Foundation; either version 2 of the License, or |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * (at your option) any later version. |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * This program is distributed in the hope that it will be useful, |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | * GNU General Public License for more details. |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | * |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | * along with this program; if not, write to the Free Software |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | */ |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | #include "pidgin/pidginprotocolstore.h" |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | |
|
40297
082c07053a79
Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
40296
diff
changeset
|
26 | #include "gtkutils.h" |
|
082c07053a79
Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
40296
diff
changeset
|
27 | |
|
40296
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | struct _PidginProtocolStore { |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | GtkListStore parent; |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | }; |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | /****************************************************************************** |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | * Helpers |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | *****************************************************************************/ |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | static void |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | pidgin_protocol_store_add_protocol(PidginProtocolStore *store, |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | PurpleProtocol *protocol) |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | { |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | GtkTreeIter iter; |
|
41280
9d5a101a7663
Update PidginProtocolStore to use the icon-name rather than GdkPixbuf
Gary Kramlich <grim@reaperworld.com>
parents:
40741
diff
changeset
|
40 | const gchar *icon_name = NULL; |
|
40297
082c07053a79
Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
40296
diff
changeset
|
41 | |
|
41280
9d5a101a7663
Update PidginProtocolStore to use the icon-name rather than GdkPixbuf
Gary Kramlich <grim@reaperworld.com>
parents:
40741
diff
changeset
|
42 | icon_name = purple_protocol_get_icon_name(protocol); |
|
40296
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | gtk_list_store_append(GTK_LIST_STORE(store), &iter); |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | gtk_list_store_set( |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | GTK_LIST_STORE(store), |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | &iter, |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | PIDGIN_PROTOCOL_STORE_COLUMN_PROTOCOL, protocol, |
|
40741
850137e8737c
Select the proper protocol in the account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
40738
diff
changeset
|
49 | PIDGIN_PROTOCOL_STORE_COLUMN_ID, purple_protocol_get_id(protocol), |
|
40296
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | PIDGIN_PROTOCOL_STORE_COLUMN_NAME, purple_protocol_get_name(protocol), |
|
41280
9d5a101a7663
Update PidginProtocolStore to use the icon-name rather than GdkPixbuf
Gary Kramlich <grim@reaperworld.com>
parents:
40741
diff
changeset
|
51 | PIDGIN_PROTOCOL_STORE_COLUMN_ICON_NAME, icon_name, |
|
40296
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | -1 |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | ); |
|
40297
082c07053a79
Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
40296
diff
changeset
|
54 | } |
|
082c07053a79
Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
40296
diff
changeset
|
55 | |
|
082c07053a79
Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
40296
diff
changeset
|
56 | static void |
|
082c07053a79
Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
40296
diff
changeset
|
57 | pidgin_protocol_store_add_protocol_helper(gpointer data, gpointer user_data) { |
|
082c07053a79
Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
40296
diff
changeset
|
58 | if(PURPLE_IS_PROTOCOL(data)) { |
|
082c07053a79
Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
40296
diff
changeset
|
59 | pidgin_protocol_store_add_protocol(PIDGIN_PROTOCOL_STORE(user_data), |
|
082c07053a79
Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
40296
diff
changeset
|
60 | PURPLE_PROTOCOL(data)); |
|
082c07053a79
Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
40296
diff
changeset
|
61 | } |
|
40296
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | } |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | static void |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | pidgin_protocol_store_add_protocols(PidginProtocolStore *store) { |
|
40735
cc0679f47fd9
Create a new PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents:
40297
diff
changeset
|
66 | PurpleProtocolManager *manager = purple_protocol_manager_get_default(); |
|
cc0679f47fd9
Create a new PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents:
40297
diff
changeset
|
67 | GList *protocols = NULL; |
|
cc0679f47fd9
Create a new PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents:
40297
diff
changeset
|
68 | |
|
cc0679f47fd9
Create a new PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents:
40297
diff
changeset
|
69 | protocols = purple_protocol_manager_get_all(manager); |
|
cc0679f47fd9
Create a new PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents:
40297
diff
changeset
|
70 | g_list_foreach(protocols, pidgin_protocol_store_add_protocol_helper, |
|
cc0679f47fd9
Create a new PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents:
40297
diff
changeset
|
71 | store); |
|
cc0679f47fd9
Create a new PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents:
40297
diff
changeset
|
72 | g_list_free(protocols); |
|
40296
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | } |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | static void |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
76 | pidgin_protocol_store_remove_protocol(PidginProtocolStore *store, |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | PurpleProtocol *protocol) |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | { |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | GtkTreeIter iter; |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 | |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | if(gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter) == FALSE) { |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | purple_debug_warning("protocol-store", |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | "protocol %s was removed but not in the store", |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
84 | purple_protocol_get_name(protocol)); |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | return; |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | } |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | /* walk through the store and look for the protocol to remove */ |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | do { |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | PurpleProtocol *prpl = NULL; |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | gtk_tree_model_get( |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | GTK_TREE_MODEL(store), |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | &iter, |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | PIDGIN_PROTOCOL_STORE_COLUMN_PROTOCOL, &prpl, |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | -1 |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | ); |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
98 | |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | if(prpl == protocol) { |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | g_object_unref(G_OBJECT(prpl)); |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | gtk_list_store_remove(GTK_LIST_STORE(store), &iter); |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
103 | |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
104 | return; |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
105 | } |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter)); |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | } |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
108 | |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
109 | /****************************************************************************** |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
110 | * Callbacks |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
111 | *****************************************************************************/ |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | static void |
|
40735
cc0679f47fd9
Create a new PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents:
40297
diff
changeset
|
113 | pidgin_protocol_store_registered_cb(PurpleProtocolManager *manager, |
|
cc0679f47fd9
Create a new PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents:
40297
diff
changeset
|
114 | PurpleProtocol *protocol, gpointer data) |
|
40296
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | { |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
116 | pidgin_protocol_store_add_protocol(PIDGIN_PROTOCOL_STORE(data), protocol); |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | } |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | static void |
|
40735
cc0679f47fd9
Create a new PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents:
40297
diff
changeset
|
120 | pidgin_protocol_store_unregistered_cb(PurpleProtocolManager *manager, |
|
cc0679f47fd9
Create a new PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents:
40297
diff
changeset
|
121 | PurpleProtocol *protocol, gpointer data) |
|
40296
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | { |
|
40735
cc0679f47fd9
Create a new PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents:
40297
diff
changeset
|
123 | pidgin_protocol_store_remove_protocol(PIDGIN_PROTOCOL_STORE(data), |
|
cc0679f47fd9
Create a new PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents:
40297
diff
changeset
|
124 | protocol); |
|
40296
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | } |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
127 | /****************************************************************************** |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | * GObject Implementation |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
129 | *****************************************************************************/ |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | G_DEFINE_TYPE(PidginProtocolStore, pidgin_protocol_store, GTK_TYPE_LIST_STORE) |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
131 | |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
132 | static void |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
133 | pidgin_protocol_store_init(PidginProtocolStore *store) { |
|
40735
cc0679f47fd9
Create a new PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents:
40297
diff
changeset
|
134 | PurpleProtocolManager *manager = NULL; |
|
40296
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
135 | GType types[PIDGIN_PROTOCOL_STORE_N_COLUMNS] = { |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
136 | PURPLE_TYPE_PROTOCOL, |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
137 | G_TYPE_STRING, |
|
40741
850137e8737c
Select the proper protocol in the account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
40738
diff
changeset
|
138 | G_TYPE_STRING, |
|
41280
9d5a101a7663
Update PidginProtocolStore to use the icon-name rather than GdkPixbuf
Gary Kramlich <grim@reaperworld.com>
parents:
40741
diff
changeset
|
139 | G_TYPE_STRING, |
|
40296
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
140 | }; |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
141 | |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
142 | gtk_list_store_set_column_types( |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
143 | GTK_LIST_STORE(store), |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
144 | PIDGIN_PROTOCOL_STORE_N_COLUMNS, |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
145 | types |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
146 | ); |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
147 | |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
148 | /* add the known protocols */ |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
149 | pidgin_protocol_store_add_protocols(store); |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
150 | |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
151 | /* add the signal handlers to dynamically add/remove protocols */ |
|
40735
cc0679f47fd9
Create a new PurpleProtocolManager
Gary Kramlich <grim@reaperworld.com>
parents:
40297
diff
changeset
|
152 | manager = purple_protocol_manager_get_default(); |
|
40738
c3cb91c3b693
Use g_signal_connect_object for PidginProtocolStore to follow the life cycle of the objects and avoid memory errors.
Gary Kramlich <grim@reaperworld.com>
parents:
40735
diff
changeset
|
153 | g_signal_connect_object(G_OBJECT(manager), "registered", |
|
c3cb91c3b693
Use g_signal_connect_object for PidginProtocolStore to follow the life cycle of the objects and avoid memory errors.
Gary Kramlich <grim@reaperworld.com>
parents:
40735
diff
changeset
|
154 | G_CALLBACK(pidgin_protocol_store_registered_cb), |
|
c3cb91c3b693
Use g_signal_connect_object for PidginProtocolStore to follow the life cycle of the objects and avoid memory errors.
Gary Kramlich <grim@reaperworld.com>
parents:
40735
diff
changeset
|
155 | store, 0); |
|
c3cb91c3b693
Use g_signal_connect_object for PidginProtocolStore to follow the life cycle of the objects and avoid memory errors.
Gary Kramlich <grim@reaperworld.com>
parents:
40735
diff
changeset
|
156 | g_signal_connect_object(G_OBJECT(manager), "unregistered", |
|
c3cb91c3b693
Use g_signal_connect_object for PidginProtocolStore to follow the life cycle of the objects and avoid memory errors.
Gary Kramlich <grim@reaperworld.com>
parents:
40735
diff
changeset
|
157 | G_CALLBACK(pidgin_protocol_store_unregistered_cb), |
|
c3cb91c3b693
Use g_signal_connect_object for PidginProtocolStore to follow the life cycle of the objects and avoid memory errors.
Gary Kramlich <grim@reaperworld.com>
parents:
40735
diff
changeset
|
158 | store, 0); |
|
40296
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
159 | } |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
160 | |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
161 | static void |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
162 | pidgin_protocol_store_class_init(PidginProtocolStoreClass *klass) { |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
163 | } |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
164 | |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
165 | /****************************************************************************** |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
166 | * API |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
167 | *****************************************************************************/ |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
168 | GtkListStore * |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
169 | pidgin_protocol_store_new(void) { |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
170 | return GTK_LIST_STORE(g_object_new(PIDGIN_TYPE_PROTOCOL_STORE, NULL)); |
|
c9900fc6e689
Initial start of PidginProtocolStore
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
171 | } |