Sun, 10 Aug 2025 23:44:08 +0800
Add Purple.Conversation.find_message_by_id
The method was added so that a protocol or plugin could easily lookup
for the reference for a message. This will be especially useful when a
protocol received a quoted message but only with an id.
| 35122 | 1 | /* |
| 2 | * Integration with Unity's messaging menu and launcher | |
| 3 | * Copyright (C) 2013 Ankit Vani <a@nevitus.org> | |
| 4 | * | |
| 5 | * This program is free software; you can redistribute it and/or modify | |
| 6 | * it under the terms of the GNU General Public License as published by | |
| 7 | * the Free Software Foundation; either version 2 of the License, or | |
| 8 | * (at your option) any later version. | |
| 9 | * | |
| 10 | * This program is distributed in the hope that it will be useful, | |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 | * GNU General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU General Public License | |
| 16 | * along with this program; if not, write to the Free Software | |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA | |
| 18 | */ | |
|
40947
4169f8090a0e
Make the unity plugin compile again and add stuff to ci ubuntu builds
Gary Kramlich <grim@reaperworld.com>
parents:
40894
diff
changeset
|
19 | #include <glib.h> |
|
4169f8090a0e
Make the unity plugin compile again and add stuff to ci ubuntu builds
Gary Kramlich <grim@reaperworld.com>
parents:
40894
diff
changeset
|
20 | #include <glib/gi18n-lib.h> |
|
4169f8090a0e
Make the unity plugin compile again and add stuff to ci ubuntu builds
Gary Kramlich <grim@reaperworld.com>
parents:
40894
diff
changeset
|
21 | |
|
40360
e21f3bbcc2a5
Update all of the pidgin code to include purple.h
Gary Kramlich <grim@reaperworld.com>
parents:
40197
diff
changeset
|
22 | #include <purple.h> |
| 35122 | 23 | |
|
40502
875489636847
pidgin.h phase3: create pidgin.h and force its usage
Gary Kramlich <grim@reaperworld.com>
parents:
40360
diff
changeset
|
24 | #include <pidgin.h> |
| 35122 | 25 | |
| 26 | #include <unity.h> | |
| 27 | #include <messaging-menu.h> | |
| 28 | ||
| 29 | #define UNITY_PLUGIN_ID "gtk-unity-integration" | |
|
42452
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
30 | #define SETTINGS_SCHEMA_ID "im.pidgin.Pidgin.plugin.Unity" |
| 35122 | 31 | |
| 32 | static MessagingMenuApp *mmapp = NULL; | |
| 33 | static UnityLauncherEntry *launcher = NULL; | |
| 34 | static guint n_sources = 0; | |
| 35 | static gint launcher_count; | |
| 36 | static gint messaging_menu_text; | |
| 37 | static gboolean alert_chat_nick = TRUE; | |
| 38 | ||
| 39 | enum { | |
| 40 | LAUNCHER_COUNT_DISABLE, | |
| 41 | LAUNCHER_COUNT_MESSAGES, | |
| 42 | LAUNCHER_COUNT_SOURCES, | |
| 43 | }; | |
| 44 | ||
| 45 | enum { | |
| 46 | MESSAGING_MENU_COUNT, | |
| 47 | MESSAGING_MENU_TIME, | |
| 48 | }; | |
| 49 | ||
| 50 | static int attach_signals(PurpleConversation *conv); | |
| 51 | static void detach_signals(PurpleConversation *conv); | |
| 52 | ||
| 53 | static void | |
|
41840
fe350460fb1c
Remove C99-obsoleted constructs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41696
diff
changeset
|
54 | update_launcher(void) |
| 35122 | 55 | { |
| 56 | guint count = 0; | |
| 57 | GList *convs = NULL; | |
| 35124 | 58 | g_return_if_fail(launcher != NULL); |
| 59 | if (launcher_count == LAUNCHER_COUNT_DISABLE) | |
| 60 | return; | |
| 35122 | 61 | |
| 62 | if (launcher_count == LAUNCHER_COUNT_MESSAGES) { | |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
63 | PurpleConversationManager *manager = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
64 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
65 | manager = purple_conversation_manager_get_default(); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
66 | convs = purple_conversation_manager_get_all(manager); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
67 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
68 | while(convs != NULL) { |
| 35122 | 69 | PurpleConversation *conv = convs->data; |
| 35123 | 70 | count += GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), |
| 71 | "unity-message-count")); | |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
72 | convs = g_list_delete_link(convs, convs); |
| 35122 | 73 | } |
| 74 | } else { | |
| 75 | count = n_sources; | |
| 76 | } | |
| 77 | ||
| 78 | if (launcher != NULL) { | |
| 79 | if (count > 0) | |
| 80 | unity_launcher_entry_set_count_visible(launcher, TRUE); | |
| 81 | else | |
| 82 | unity_launcher_entry_set_count_visible(launcher, FALSE); | |
| 83 | unity_launcher_entry_set_count(launcher, count); | |
| 84 | } | |
| 85 | } | |
| 86 | ||
| 87 | static gchar * | |
| 88 | conversation_id(PurpleConversation *conv) | |
| 89 | { | |
| 90 | PurpleAccount *account = purple_conversation_get_account(conv); | |
|
41962
f802660eaef2
Update Pidgin to stop using deprecated account methods
Gary Kramlich <grim@reaperworld.com>
parents:
41840
diff
changeset
|
91 | const char *type = "misc"; |
| 35122 | 92 | |
|
41962
f802660eaef2
Update Pidgin to stop using deprecated account methods
Gary Kramlich <grim@reaperworld.com>
parents:
41840
diff
changeset
|
93 | if(PURPLE_IS_IM_CONVERSATION(conv)) { |
|
f802660eaef2
Update Pidgin to stop using deprecated account methods
Gary Kramlich <grim@reaperworld.com>
parents:
41840
diff
changeset
|
94 | type = "im"; |
|
f802660eaef2
Update Pidgin to stop using deprecated account methods
Gary Kramlich <grim@reaperworld.com>
parents:
41840
diff
changeset
|
95 | } else if(PURPLE_IS_CHAT_CONVERSATION(conv)) { |
|
f802660eaef2
Update Pidgin to stop using deprecated account methods
Gary Kramlich <grim@reaperworld.com>
parents:
41840
diff
changeset
|
96 | type = "chat"; |
|
f802660eaef2
Update Pidgin to stop using deprecated account methods
Gary Kramlich <grim@reaperworld.com>
parents:
41840
diff
changeset
|
97 | } |
|
f802660eaef2
Update Pidgin to stop using deprecated account methods
Gary Kramlich <grim@reaperworld.com>
parents:
41840
diff
changeset
|
98 | |
|
f802660eaef2
Update Pidgin to stop using deprecated account methods
Gary Kramlich <grim@reaperworld.com>
parents:
41840
diff
changeset
|
99 | return g_strdup_printf("%s:%s:%s:%s", |
|
f802660eaef2
Update Pidgin to stop using deprecated account methods
Gary Kramlich <grim@reaperworld.com>
parents:
41840
diff
changeset
|
100 | type, |
|
f802660eaef2
Update Pidgin to stop using deprecated account methods
Gary Kramlich <grim@reaperworld.com>
parents:
41840
diff
changeset
|
101 | purple_conversation_get_name(conv), |
|
42804
be8c8b5471ca
Update pidgin to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents:
42453
diff
changeset
|
102 | purple_account_get_username(account), |
|
41962
f802660eaef2
Update Pidgin to stop using deprecated account methods
Gary Kramlich <grim@reaperworld.com>
parents:
41840
diff
changeset
|
103 | purple_account_get_protocol_id(account)); |
| 35122 | 104 | } |
| 105 | ||
| 106 | static void | |
| 107 | messaging_menu_add_conversation(PurpleConversation *conv, gint count) | |
| 108 | { | |
| 109 | gchar *id; | |
| 110 | g_return_if_fail(count > 0); | |
| 111 | id = conversation_id(conv); | |
| 112 | ||
| 113 | /* GBytesIcon may be useful for messaging menu source icons using buddy | |
| 114 | icon data for IMs */ | |
| 115 | if (!messaging_menu_app_has_source(mmapp, id)) | |
| 116 | messaging_menu_app_append_source(mmapp, id, NULL, | |
| 35123 | 117 | purple_conversation_get_title(conv)); |
| 35122 | 118 | |
| 119 | if (messaging_menu_text == MESSAGING_MENU_TIME) | |
| 120 | messaging_menu_app_set_source_time(mmapp, id, g_get_real_time()); | |
| 121 | else if (messaging_menu_text == MESSAGING_MENU_COUNT) | |
| 122 | messaging_menu_app_set_source_count(mmapp, id, count); | |
| 123 | messaging_menu_app_draw_attention(mmapp, id); | |
| 124 | ||
| 125 | g_free(id); | |
| 126 | } | |
| 127 | ||
| 128 | static void | |
| 129 | messaging_menu_remove_conversation(PurpleConversation *conv) | |
| 130 | { | |
| 131 | gchar *id = conversation_id(conv); | |
| 132 | if (messaging_menu_app_has_source(mmapp, id)) | |
| 133 | messaging_menu_app_remove_source(mmapp, id); | |
| 134 | g_free(id); | |
| 135 | } | |
| 136 | ||
| 137 | static void | |
|
41840
fe350460fb1c
Remove C99-obsoleted constructs
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41696
diff
changeset
|
138 | refill_messaging_menu(void) |
| 35122 | 139 | { |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
140 | PurpleConversationManager *manager = NULL; |
| 35122 | 141 | GList *convs; |
| 142 | ||
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
143 | manager = purple_conversation_manager_get_default(); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
144 | convs = purple_conversation_manager_get_all(manager); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
145 | while(convs != NULL) { |
| 35122 | 146 | PurpleConversation *conv = convs->data; |
| 147 | messaging_menu_add_conversation(conv, | |
| 35123 | 148 | GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), |
| 149 | "unity-message-count"))); | |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
150 | convs = g_list_delete_link(convs, convs); |
| 35122 | 151 | } |
| 152 | } | |
| 153 | ||
| 154 | static int | |
| 155 | alert(PurpleConversation *conv) | |
| 156 | { | |
| 157 | gint count; | |
|
42295
5ac321d71801
Rename PidginConversation to PidginConversationOld
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
158 | PidginConversationOld *gtkconv = NULL; |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41665
diff
changeset
|
159 | PidginDisplayWindow *displaywin = NULL; |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
160 | GtkRoot *root = NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
161 | GtkWidget *win = NULL; |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
162 | |
|
42295
5ac321d71801
Rename PidginConversation to PidginConversationOld
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
163 | if (conv == NULL || PIDGIN_CONVERSATION_OLD(conv) == NULL) |
| 35122 | 164 | return 0; |
| 165 | ||
|
42295
5ac321d71801
Rename PidginConversation to PidginConversationOld
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
166 | gtkconv = PIDGIN_CONVERSATION_OLD(conv); |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
167 | root = gtk_widget_get_root(gtkconv->tab_cont); |
|
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
168 | win = GTK_WIDGET(root); |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41665
diff
changeset
|
169 | displaywin = PIDGIN_DISPLAY_WINDOW(win); |
| 35122 | 170 | |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
171 | if (!gtk_widget_has_focus(win) || |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41665
diff
changeset
|
172 | !pidgin_display_window_conversation_is_selected(displaywin, conv)) |
| 35122 | 173 | { |
| 35123 | 174 | count = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), |
| 175 | "unity-message-count")); | |
| 35122 | 176 | if (!count++) |
| 177 | ++n_sources; | |
| 178 | ||
| 35123 | 179 | g_object_set_data(G_OBJECT(conv), "unity-message-count", |
| 180 | GINT_TO_POINTER(count)); | |
| 35122 | 181 | messaging_menu_add_conversation(conv, count); |
| 182 | update_launcher(); | |
| 183 | } | |
| 184 | ||
| 185 | return 0; | |
| 186 | } | |
| 187 | ||
| 188 | static void | |
| 189 | unalert(PurpleConversation *conv) | |
| 190 | { | |
| 35123 | 191 | if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), "unity-message-count")) > 0) |
| 35122 | 192 | --n_sources; |
| 35123 | 193 | |
| 194 | g_object_set_data(G_OBJECT(conv), "unity-message-count", | |
| 195 | GINT_TO_POINTER(0)); | |
| 35122 | 196 | messaging_menu_remove_conversation(conv); |
| 197 | update_launcher(); | |
| 198 | } | |
| 199 | ||
| 200 | static int | |
|
42074
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41962
diff
changeset
|
201 | unalert_cb(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED gpointer data, |
|
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41962
diff
changeset
|
202 | PurpleConversation *conv) |
| 35122 | 203 | { |
| 204 | unalert(conv); | |
| 205 | return 0; | |
| 206 | } | |
| 207 | ||
| 208 | static gboolean | |
|
42074
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41962
diff
changeset
|
209 | message_displayed_cb(PurpleConversation *conv, PurpleMessage *msg, |
|
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41962
diff
changeset
|
210 | G_GNUC_UNUSED gpointer data) |
| 35122 | 211 | { |
|
36110
63663622e327
Switch write_conv and (displaying|displayed)-(im|chat)-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36103
diff
changeset
|
212 | PurpleMessageFlags flags = purple_message_get_flags(msg); |
|
63663622e327
Switch write_conv and (displaying|displayed)-(im|chat)-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36103
diff
changeset
|
213 | |
| 35123 | 214 | if ((PURPLE_IS_CHAT_CONVERSATION(conv) && alert_chat_nick && |
| 215 | !(flags & PURPLE_MESSAGE_NICK))) | |
| 35122 | 216 | return FALSE; |
| 217 | ||
| 218 | if ((flags & PURPLE_MESSAGE_RECV) && !(flags & PURPLE_MESSAGE_DELAYED)) | |
| 219 | alert(conv); | |
| 220 | ||
| 221 | return FALSE; | |
| 222 | } | |
| 223 | ||
| 224 | static void | |
|
42074
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41962
diff
changeset
|
225 | im_sent_im(PurpleAccount *account, PurpleMessage *msg, |
|
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41962
diff
changeset
|
226 | G_GNUC_UNUSED gpointer data) |
| 35122 | 227 | { |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
228 | PurpleConversation *im = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
229 | PurpleConversationManager *manager = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
230 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
231 | manager = purple_conversation_manager_get_default(); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
232 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
233 | im = purple_conversation_manager_find_im(manager, account, |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
234 | purple_message_get_recipient(msg)); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
235 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
236 | unalert(im); |
| 35122 | 237 | } |
| 238 | ||
| 239 | static void | |
|
42074
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41962
diff
changeset
|
240 | chat_sent_im(PurpleAccount *account, G_GNUC_UNUSED PurpleMessage *msg, int id) |
| 35122 | 241 | { |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
242 | PurpleConversation *chat = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
243 | PurpleConversationManager *manager = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
244 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
245 | manager = purple_conversation_manager_get_default(); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
246 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
247 | chat = purple_conversation_manager_find_chat_by_id(manager, account, id); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
248 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
249 | unalert(chat); |
| 35122 | 250 | } |
| 251 | ||
| 252 | static void | |
| 253 | conv_created(PurpleConversation *conv) | |
| 254 | { | |
| 35123 | 255 | g_object_set_data(G_OBJECT(conv), "unity-message-count", |
| 256 | GINT_TO_POINTER(0)); | |
| 35122 | 257 | attach_signals(conv); |
| 258 | } | |
| 259 | ||
| 260 | static void | |
| 261 | deleting_conv(PurpleConversation *conv) | |
| 262 | { | |
| 263 | detach_signals(conv); | |
| 264 | unalert(conv); | |
| 265 | } | |
| 266 | ||
| 267 | static void | |
|
42074
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41962
diff
changeset
|
268 | message_source_activated(G_GNUC_UNUSED MessagingMenuApp *app, |
|
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41962
diff
changeset
|
269 | const gchar *id, |
|
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41962
diff
changeset
|
270 | G_GNUC_UNUSED gpointer user_data) |
| 35122 | 271 | { |
| 272 | gchar **sections = g_strsplit(id, ":", 0); | |
| 273 | PurpleConversation *conv = NULL; | |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
274 | PurpleConversationManager *conversation_manager = NULL; |
| 35122 | 275 | PurpleAccount *account; |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
276 | PurpleAccountManager *account_manager = NULL; |
| 35122 | 277 | |
| 278 | char *type = sections[0]; | |
| 279 | char *cname = sections[1]; | |
| 280 | char *aname = sections[2]; | |
| 281 | char *protocol = sections[3]; | |
| 282 | ||
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
283 | conversation_manager = purple_conversation_manager_get_default(); |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
284 | |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
285 | account_manager = purple_account_manager_get_default(); |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
286 | account = purple_account_manager_find(account_manager, aname, protocol); |
| 35123 | 287 | |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
288 | if (g_strcmp0(type, "im") == 0) { |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
289 | conv = purple_conversation_manager_find_im(conversation_manager, |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
290 | account, cname); |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
291 | } else if (g_strcmp0(type, "chat") == 0) { |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
292 | conv = purple_conversation_manager_find_chat(conversation_manager, |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
293 | account, cname); |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
294 | } else { |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
295 | conv = purple_conversation_manager_find(conversation_manager, |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
296 | account, cname); |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
297 | } |
| 35122 | 298 | |
|
42291
a86b7bcbb471
Make the purple_account_manager_find functions return transfer full.
Gary Kramlich <grim@reaperworld.com>
parents:
42164
diff
changeset
|
299 | g_clear_object(&account); |
|
a86b7bcbb471
Make the purple_account_manager_find functions return transfer full.
Gary Kramlich <grim@reaperworld.com>
parents:
42164
diff
changeset
|
300 | |
| 35122 | 301 | if (conv) { |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
302 | GtkRoot *root = NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
303 | GtkWidget *win = NULL; |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41665
diff
changeset
|
304 | PidginDisplayWindow *displaywin = NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
305 | |
|
42295
5ac321d71801
Rename PidginConversation to PidginConversationOld
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
306 | root = gtk_widget_get_root(PIDGIN_CONVERSATION_OLD(conv)->tab_cont); |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
307 | win = GTK_WIDGET(root); |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41665
diff
changeset
|
308 | displaywin = PIDGIN_DISPLAY_WINDOW(win); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
309 | |
| 35122 | 310 | unalert(conv); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
311 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41665
diff
changeset
|
312 | pidgin_display_window_select(displaywin, conv); |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
313 | |
|
42295
5ac321d71801
Rename PidginConversation to PidginConversationOld
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
314 | gtk_root_set_focus(root, PIDGIN_CONVERSATION_OLD(conv)->entry); |
| 35122 | 315 | } |
| 316 | g_strfreev (sections); | |
| 317 | } | |
| 318 | ||
| 319 | static PurpleSavedStatus * | |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
320 | create_transient_status(PurpleStatusPrimitive primitive, |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
321 | PurpleStatusType *status_type) |
| 35122 | 322 | { |
| 323 | PurpleSavedStatus *saved_status = purple_savedstatus_new(NULL, primitive); | |
| 324 | ||
| 325 | if(status_type != NULL) { | |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
326 | PurpleAccountManager *manager = NULL; |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
327 | GList *active_accts = NULL; |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
328 | |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
329 | manager = purple_account_manager_get_default(); |
|
41454
7cc69bde919d
Update pidgin for the purple_account_manager_get_(in)active deprecations
Gary Kramlich <grim@reaperworld.com>
parents:
41314
diff
changeset
|
330 | active_accts = purple_account_manager_get_enabled(manager); |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
331 | |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
332 | while(active_accts != NULL) { |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
333 | PurpleAccount *account = PURPLE_ACCOUNT(active_accts->data); |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
334 | |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
335 | purple_savedstatus_set_substatus(saved_status, account, |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
336 | status_type, NULL); |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
337 | |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
338 | active_accts = g_list_delete_link(active_accts, active_accts); |
| 35122 | 339 | } |
| 340 | } | |
| 341 | ||
| 342 | return saved_status; | |
| 343 | } | |
| 344 | ||
| 345 | static void | |
| 346 | status_changed_cb(PurpleSavedStatus *saved_status) | |
| 347 | { | |
| 348 | MessagingMenuStatus status = MESSAGING_MENU_STATUS_AVAILABLE; | |
| 349 | ||
|
35378
5d9e2581005b
gtk-doc prep: *_get_type() functions are hidden as standard GType-returning funcs, so rename them.
Ankit Vani <a@nevitus.org>
parents:
35317
diff
changeset
|
350 | switch (purple_savedstatus_get_primitive_type(saved_status)) { |
| 35122 | 351 | case PURPLE_STATUS_AVAILABLE: |
| 352 | case PURPLE_STATUS_UNSET: | |
| 353 | status = MESSAGING_MENU_STATUS_AVAILABLE; | |
| 354 | break; | |
| 355 | ||
| 356 | case PURPLE_STATUS_AWAY: | |
| 357 | case PURPLE_STATUS_EXTENDED_AWAY: | |
| 358 | status = MESSAGING_MENU_STATUS_AWAY; | |
| 359 | break; | |
| 360 | ||
| 361 | case PURPLE_STATUS_INVISIBLE: | |
| 362 | status = MESSAGING_MENU_STATUS_INVISIBLE; | |
| 363 | break; | |
| 364 | ||
| 365 | case PURPLE_STATUS_MOBILE: | |
| 366 | case PURPLE_STATUS_OFFLINE: | |
| 367 | status = MESSAGING_MENU_STATUS_OFFLINE; | |
| 368 | break; | |
| 369 | ||
| 370 | case PURPLE_STATUS_UNAVAILABLE: | |
| 371 | status = MESSAGING_MENU_STATUS_BUSY; | |
| 372 | break; | |
| 373 | ||
| 374 | default: | |
| 375 | g_assert_not_reached(); | |
| 376 | } | |
| 377 | messaging_menu_app_set_status(mmapp, status); | |
| 378 | } | |
| 379 | ||
| 380 | static void | |
|
42074
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41962
diff
changeset
|
381 | messaging_menu_status_changed(G_GNUC_UNUSED MessagingMenuApp *mmapp, |
|
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41962
diff
changeset
|
382 | MessagingMenuStatus mm_status, |
|
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41962
diff
changeset
|
383 | G_GNUC_UNUSED gpointer user_data) |
| 35122 | 384 | { |
| 385 | PurpleSavedStatus *saved_status; | |
| 386 | PurpleStatusPrimitive primitive = PURPLE_STATUS_UNSET; | |
| 387 | ||
| 388 | switch (mm_status) { | |
| 389 | case MESSAGING_MENU_STATUS_AVAILABLE: | |
| 390 | primitive = PURPLE_STATUS_AVAILABLE; | |
| 391 | break; | |
| 392 | ||
| 393 | case MESSAGING_MENU_STATUS_AWAY: | |
| 394 | primitive = PURPLE_STATUS_AWAY; | |
| 395 | break; | |
| 396 | ||
| 397 | case MESSAGING_MENU_STATUS_BUSY: | |
| 398 | primitive = PURPLE_STATUS_UNAVAILABLE; | |
| 399 | break; | |
| 400 | ||
| 401 | case MESSAGING_MENU_STATUS_INVISIBLE: | |
| 402 | primitive = PURPLE_STATUS_INVISIBLE; | |
| 403 | break; | |
| 404 | ||
| 405 | case MESSAGING_MENU_STATUS_OFFLINE: | |
| 406 | primitive = PURPLE_STATUS_OFFLINE; | |
| 407 | break; | |
| 408 | ||
| 409 | default: | |
| 410 | g_assert_not_reached(); | |
| 411 | } | |
| 412 | ||
| 413 | saved_status = purple_savedstatus_find_transient_by_type_and_message(primitive, NULL); | |
| 414 | if (saved_status == NULL) | |
| 415 | saved_status = create_transient_status(primitive, NULL); | |
| 416 | purple_savedstatus_activate(saved_status); | |
| 417 | } | |
| 418 | ||
| 419 | static void | |
|
42452
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
420 | settings_change_cb(GSettings *settings, char *key, G_GNUC_UNUSED gpointer data) |
| 35122 | 421 | { |
|
42452
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
422 | if(purple_strequal(key, "alert-chat-nick")) { |
|
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
423 | alert_chat_nick = g_settings_get_boolean(settings, key); |
|
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
424 | } else if(purple_strequal(key, "launcher-count")) { |
|
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
425 | launcher_count = g_settings_get_enum(settings, key); |
|
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
426 | if(launcher_count == LAUNCHER_COUNT_DISABLE) { |
|
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
427 | unity_launcher_entry_set_count_visible(launcher, FALSE); |
|
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
428 | } else { |
|
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
429 | update_launcher(); |
|
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
430 | } |
|
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
431 | } else if(purple_strequal(key, "messaging-menu-text")) { |
|
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
432 | messaging_menu_text = g_settings_get_enum(settings, key); |
|
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
433 | refill_messaging_menu(); |
|
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
434 | } else { |
|
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
435 | g_warning("Got unity-integration settings change for unknown key: %s", |
|
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
436 | key); |
|
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
437 | } |
| 35122 | 438 | } |
| 439 | ||
| 440 | static int | |
| 441 | attach_signals(PurpleConversation *conv) | |
| 442 | { | |
|
42295
5ac321d71801
Rename PidginConversation to PidginConversationOld
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
443 | PidginConversationOld *gtkconv = NULL; |
| 35122 | 444 | guint id; |
| 445 | ||
|
42295
5ac321d71801
Rename PidginConversation to PidginConversationOld
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
446 | gtkconv = PIDGIN_CONVERSATION_OLD(conv); |
| 35122 | 447 | if (!gtkconv) |
| 448 | return 0; | |
| 449 | ||
| 450 | id = g_signal_connect(G_OBJECT(gtkconv->entry), "focus-in-event", | |
| 35123 | 451 | G_CALLBACK(unalert_cb), conv); |
| 452 | g_object_set_data(G_OBJECT(conv), "unity-entry-signal", GUINT_TO_POINTER(id)); | |
| 35122 | 453 | |
|
40947
4169f8090a0e
Make the unity plugin compile again and add stuff to ci ubuntu builds
Gary Kramlich <grim@reaperworld.com>
parents:
40894
diff
changeset
|
454 | id = g_signal_connect(G_OBJECT(gtkconv->history), "focus-in-event", |
| 35123 | 455 | G_CALLBACK(unalert_cb), conv); |
|
40947
4169f8090a0e
Make the unity plugin compile again and add stuff to ci ubuntu builds
Gary Kramlich <grim@reaperworld.com>
parents:
40894
diff
changeset
|
456 | g_object_set_data(G_OBJECT(conv), "unity-history-signal", GUINT_TO_POINTER(id)); |
| 35122 | 457 | |
| 458 | return 0; | |
| 459 | } | |
| 460 | ||
| 461 | static void | |
| 462 | detach_signals(PurpleConversation *conv) | |
| 463 | { | |
|
42295
5ac321d71801
Rename PidginConversation to PidginConversationOld
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
464 | PidginConversationOld *gtkconv = NULL; |
| 35122 | 465 | guint id; |
|
42295
5ac321d71801
Rename PidginConversation to PidginConversationOld
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
466 | gtkconv = PIDGIN_CONVERSATION_OLD(conv); |
| 35122 | 467 | if (!gtkconv) |
| 468 | return; | |
| 469 | ||
|
40947
4169f8090a0e
Make the unity plugin compile again and add stuff to ci ubuntu builds
Gary Kramlich <grim@reaperworld.com>
parents:
40894
diff
changeset
|
470 | id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), "unity-history-signal")); |
|
4169f8090a0e
Make the unity plugin compile again and add stuff to ci ubuntu builds
Gary Kramlich <grim@reaperworld.com>
parents:
40894
diff
changeset
|
471 | g_signal_handler_disconnect(gtkconv->history, id); |
| 35122 | 472 | |
| 35123 | 473 | id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), "unity-entry-signal")); |
| 35122 | 474 | g_signal_handler_disconnect(gtkconv->entry, id); |
| 475 | ||
| 35123 | 476 | g_object_set_data(G_OBJECT(conv), "unity-message-count", |
| 477 | GINT_TO_POINTER(0)); | |
| 35122 | 478 | } |
| 479 | ||
|
40894
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
480 | static GPluginPluginInfo * |
|
42074
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41962
diff
changeset
|
481 | unity_query(G_GNUC_UNUSED GError **error) |
|
36969
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
482 | { |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
483 | const gchar * const authors[] = { |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
484 | "Ankit Vani <a@nevitus.org>", |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
485 | NULL |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
486 | }; |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
487 | |
|
42453
1c13bc243b7d
Remove PidginPluginInfo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42452
diff
changeset
|
488 | return purple_plugin_info_new( |
|
36969
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
489 | "id", UNITY_PLUGIN_ID, |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
490 | "name", N_("Unity Integration"), |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
491 | "version", DISPLAY_VERSION, |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
492 | "category", N_("Notification"), |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
493 | "summary", N_("Provides integration with Unity."), |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
494 | "description", N_("Provides integration with Unity's " |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
495 | "messaging menu and launcher."), |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
496 | "authors", authors, |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
497 | "website", PURPLE_WEBSITE, |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
498 | "abi-version", PURPLE_ABI_VERSION, |
|
42452
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
499 | "settings-schema", SETTINGS_SCHEMA_ID, |
|
36969
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
500 | NULL |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
501 | ); |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
502 | } |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
503 | |
| 35122 | 504 | static gboolean |
|
42074
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41962
diff
changeset
|
505 | unity_load(GPluginPlugin *plugin, G_GNUC_UNUSED GError **error) { |
|
42452
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
506 | GSettings *settings = NULL; |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
507 | GList *convs = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
508 | PurpleConversationManager *manager = NULL; |
| 35122 | 509 | PurpleSavedStatus *saved_status; |
| 510 | void *conv_handle = purple_conversations_get_handle(); | |
| 511 | void *gtk_conv_handle = pidgin_conversations_get_handle(); | |
| 512 | void *savedstat_handle = purple_savedstatuses_get_handle(); | |
| 513 | ||
|
42452
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
514 | settings = g_settings_new_with_backend(SETTINGS_SCHEMA_ID, |
|
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
515 | purple_core_get_settings_backend()); |
|
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
516 | g_signal_connect(settings, "changed", |
|
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
517 | G_CALLBACK(settings_change_cb), NULL); |
|
36969
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
518 | |
|
42452
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
519 | alert_chat_nick = g_settings_get_boolean(settings, "alert-chat-nick"); |
| 35122 | 520 | |
| 521 | mmapp = messaging_menu_app_new("pidgin.desktop"); | |
| 522 | g_object_ref(mmapp); | |
| 523 | messaging_menu_app_register(mmapp); | |
|
42452
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
524 | messaging_menu_text = g_settings_get_enum(settings, "messaging-menu-text"); |
| 35122 | 525 | |
| 526 | g_signal_connect(mmapp, "activate-source", | |
| 35123 | 527 | G_CALLBACK(message_source_activated), NULL); |
| 35122 | 528 | g_signal_connect(mmapp, "status-changed", |
| 35123 | 529 | G_CALLBACK(messaging_menu_status_changed), NULL); |
| 35122 | 530 | |
| 531 | saved_status = purple_savedstatus_get_current(); | |
| 532 | status_changed_cb(saved_status); | |
| 533 | ||
| 534 | purple_signal_connect(savedstat_handle, "savedstatus-changed", plugin, | |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41209
diff
changeset
|
535 | G_CALLBACK(status_changed_cb), NULL); |
| 35122 | 536 | |
| 537 | launcher = unity_launcher_entry_get_for_desktop_id("pidgin.desktop"); | |
| 538 | g_object_ref(launcher); | |
|
42452
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
539 | launcher_count = g_settings_get_enum(settings, "launcher-count"); |
| 35122 | 540 | |
| 541 | purple_signal_connect(gtk_conv_handle, "displayed-im-msg", plugin, | |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41209
diff
changeset
|
542 | G_CALLBACK(message_displayed_cb), NULL); |
| 35122 | 543 | purple_signal_connect(gtk_conv_handle, "displayed-chat-msg", plugin, |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41209
diff
changeset
|
544 | G_CALLBACK(message_displayed_cb), NULL); |
| 35122 | 545 | purple_signal_connect(conv_handle, "sent-im-msg", plugin, |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41209
diff
changeset
|
546 | G_CALLBACK(im_sent_im), NULL); |
| 35122 | 547 | purple_signal_connect(conv_handle, "sent-chat-msg", plugin, |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41209
diff
changeset
|
548 | G_CALLBACK(chat_sent_im), NULL); |
| 35122 | 549 | purple_signal_connect(conv_handle, "conversation-created", plugin, |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41209
diff
changeset
|
550 | G_CALLBACK(conv_created), NULL); |
| 35122 | 551 | purple_signal_connect(conv_handle, "deleting-conversation", plugin, |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41209
diff
changeset
|
552 | G_CALLBACK(deleting_conv), NULL); |
| 35122 | 553 | |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
554 | manager = purple_conversation_manager_get_default(); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
555 | convs = purple_conversation_manager_get_all(manager); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
556 | while(convs != NULL) { |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
557 | PurpleConversation *conv = PURPLE_CONVERSATION(convs->data); |
| 35122 | 558 | attach_signals(conv); |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
559 | convs = g_list_delete_link(convs, convs); |
| 35122 | 560 | } |
| 561 | ||
|
42452
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
562 | g_object_unref(settings); |
|
8b5a5b21d6da
Port Unity integration plugin prefs to GSettings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42342
diff
changeset
|
563 | |
| 35122 | 564 | return TRUE; |
| 565 | } | |
| 566 | ||
| 567 | static gboolean | |
|
42074
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41962
diff
changeset
|
568 | unity_unload(G_GNUC_UNUSED GPluginPlugin *plugin, |
|
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41962
diff
changeset
|
569 | G_GNUC_UNUSED gboolean shutdown, |
|
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41962
diff
changeset
|
570 | G_GNUC_UNUSED GError **error) |
|
58ae70ad7f21
Mark unused parameters as such for all of the pidgin plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41962
diff
changeset
|
571 | { |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
572 | GList *convs = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
573 | PurpleConversationManager *manager = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
574 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
575 | manager = purple_conversation_manager_get_default(); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
576 | convs = purple_conversation_manager_get_all(manager); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
577 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
578 | while(convs != NULL) { |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
579 | PurpleConversation *conv = PURPLE_CONVERSATION(convs->data); |
| 35122 | 580 | unalert(conv); |
| 581 | detach_signals(conv); | |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
582 | convs = g_list_delete_link(convs, convs); |
| 35122 | 583 | } |
|
40894
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
584 | |
| 35122 | 585 | unity_launcher_entry_set_count_visible(launcher, FALSE); |
| 586 | messaging_menu_app_unregister(mmapp); | |
| 587 | ||
| 588 | g_object_unref(launcher); | |
| 589 | g_object_unref(mmapp); | |
| 590 | return TRUE; | |
| 591 | } | |
| 592 | ||
|
40894
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
593 | GPLUGIN_NATIVE_PLUGIN_DECLARE(unity) |