Thu, 21 Jul 2022 01:10:22 -0500
Update pidgin for the purple_account_manager_get_(in)active deprecations
Testing Done:
Compiled and made sure the menus still functioned as expected.
Reviewed at https://reviews.imfreedom.org/r/1536/
| 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 | |
|
40947
4169f8090a0e
Make the unity plugin compile again and add stuff to ci ubuntu builds
Gary Kramlich <grim@reaperworld.com>
parents:
40894
diff
changeset
|
26 | #include <talkatu.h> |
|
4169f8090a0e
Make the unity plugin compile again and add stuff to ci ubuntu builds
Gary Kramlich <grim@reaperworld.com>
parents:
40894
diff
changeset
|
27 | |
| 35122 | 28 | #include <unity.h> |
| 29 | #include <messaging-menu.h> | |
| 30 | ||
| 31 | #define UNITY_PLUGIN_ID "gtk-unity-integration" | |
| 32 | ||
| 33 | static MessagingMenuApp *mmapp = NULL; | |
| 34 | static UnityLauncherEntry *launcher = NULL; | |
| 35 | static guint n_sources = 0; | |
| 36 | static gint launcher_count; | |
| 37 | static gint messaging_menu_text; | |
| 38 | static gboolean alert_chat_nick = TRUE; | |
| 39 | ||
| 40 | enum { | |
| 41 | LAUNCHER_COUNT_DISABLE, | |
| 42 | LAUNCHER_COUNT_MESSAGES, | |
| 43 | LAUNCHER_COUNT_SOURCES, | |
| 44 | }; | |
| 45 | ||
| 46 | enum { | |
| 47 | MESSAGING_MENU_COUNT, | |
| 48 | MESSAGING_MENU_TIME, | |
| 49 | }; | |
| 50 | ||
| 51 | static int attach_signals(PurpleConversation *conv); | |
| 52 | static void detach_signals(PurpleConversation *conv); | |
| 53 | ||
| 54 | static void | |
| 55 | update_launcher() | |
| 56 | { | |
| 57 | guint count = 0; | |
| 58 | GList *convs = NULL; | |
| 35124 | 59 | g_return_if_fail(launcher != NULL); |
| 60 | if (launcher_count == LAUNCHER_COUNT_DISABLE) | |
| 61 | return; | |
| 35122 | 62 | |
| 63 | 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
|
64 | PurpleConversationManager *manager = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
65 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
66 | manager = purple_conversation_manager_get_default(); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
67 | 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
|
68 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
69 | while(convs != NULL) { |
| 35122 | 70 | PurpleConversation *conv = convs->data; |
| 35123 | 71 | count += GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), |
| 72 | "unity-message-count")); | |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
73 | convs = g_list_delete_link(convs, convs); |
| 35122 | 74 | } |
| 75 | } else { | |
| 76 | count = n_sources; | |
| 77 | } | |
| 78 | ||
| 79 | if (launcher != NULL) { | |
| 80 | if (count > 0) | |
| 81 | unity_launcher_entry_set_count_visible(launcher, TRUE); | |
| 82 | else | |
| 83 | unity_launcher_entry_set_count_visible(launcher, FALSE); | |
| 84 | unity_launcher_entry_set_count(launcher, count); | |
| 85 | } | |
| 86 | } | |
| 87 | ||
| 88 | static gchar * | |
| 89 | conversation_id(PurpleConversation *conv) | |
| 90 | { | |
| 91 | PurpleAccount *account = purple_conversation_get_account(conv); | |
| 92 | ||
| 35123 | 93 | return g_strconcat((PURPLE_IS_IM_CONVERSATION(conv) ? "im" : |
| 94 | PURPLE_IS_CHAT_CONVERSATION(conv) ? "chat" : "misc"), ":", | |
| 95 | purple_conversation_get_name(conv), ":", | |
| 96 | purple_account_get_username(account), ":", | |
| 97 | purple_account_get_protocol_id(account), NULL); | |
| 35122 | 98 | } |
| 99 | ||
| 100 | static void | |
| 101 | messaging_menu_add_conversation(PurpleConversation *conv, gint count) | |
| 102 | { | |
| 103 | gchar *id; | |
| 104 | g_return_if_fail(count > 0); | |
| 105 | id = conversation_id(conv); | |
| 106 | ||
| 107 | /* GBytesIcon may be useful for messaging menu source icons using buddy | |
| 108 | icon data for IMs */ | |
| 109 | if (!messaging_menu_app_has_source(mmapp, id)) | |
| 110 | messaging_menu_app_append_source(mmapp, id, NULL, | |
| 35123 | 111 | purple_conversation_get_title(conv)); |
| 35122 | 112 | |
| 113 | if (messaging_menu_text == MESSAGING_MENU_TIME) | |
| 114 | messaging_menu_app_set_source_time(mmapp, id, g_get_real_time()); | |
| 115 | else if (messaging_menu_text == MESSAGING_MENU_COUNT) | |
| 116 | messaging_menu_app_set_source_count(mmapp, id, count); | |
| 117 | messaging_menu_app_draw_attention(mmapp, id); | |
| 118 | ||
| 119 | g_free(id); | |
| 120 | } | |
| 121 | ||
| 122 | static void | |
| 123 | messaging_menu_remove_conversation(PurpleConversation *conv) | |
| 124 | { | |
| 125 | gchar *id = conversation_id(conv); | |
| 126 | if (messaging_menu_app_has_source(mmapp, id)) | |
| 127 | messaging_menu_app_remove_source(mmapp, id); | |
| 128 | g_free(id); | |
| 129 | } | |
| 130 | ||
| 131 | static void | |
| 132 | refill_messaging_menu() | |
| 133 | { | |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
134 | PurpleConversationManager *manager = NULL; |
| 35122 | 135 | GList *convs; |
| 136 | ||
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
137 | manager = purple_conversation_manager_get_default(); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
138 | 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
|
139 | while(convs != NULL) { |
| 35122 | 140 | PurpleConversation *conv = convs->data; |
| 141 | messaging_menu_add_conversation(conv, | |
| 35123 | 142 | GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), |
| 143 | "unity-message-count"))); | |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
144 | convs = g_list_delete_link(convs, convs); |
| 35122 | 145 | } |
| 146 | } | |
| 147 | ||
| 148 | static int | |
| 149 | alert(PurpleConversation *conv) | |
| 150 | { | |
| 151 | gint count; | |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
152 | PidginConversation *gtkconv = NULL; |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
153 | PidginConversationWindow *convwin = NULL; |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
154 | GtkWidget *win = NULL; |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
155 | |
| 35122 | 156 | if (conv == NULL || PIDGIN_CONVERSATION(conv) == NULL) |
| 157 | return 0; | |
| 158 | ||
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
159 | gtkconv = PIDGIN_CONVERSATION(conv); |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
160 | win = gtk_widget_get_toplevel(gtkconv->tab_cont); |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
161 | convwin = PIDGIN_CONVERSATION_WINDOW(win); |
| 35122 | 162 | |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
163 | if (!gtk_widget_has_focus(win) || |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
164 | !pidgin_conversation_window_conversation_is_selected(convwin, conv)) |
| 35122 | 165 | { |
| 35123 | 166 | count = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), |
| 167 | "unity-message-count")); | |
| 35122 | 168 | if (!count++) |
| 169 | ++n_sources; | |
| 170 | ||
| 35123 | 171 | g_object_set_data(G_OBJECT(conv), "unity-message-count", |
| 172 | GINT_TO_POINTER(count)); | |
| 35122 | 173 | messaging_menu_add_conversation(conv, count); |
| 174 | update_launcher(); | |
| 175 | } | |
| 176 | ||
| 177 | return 0; | |
| 178 | } | |
| 179 | ||
| 180 | static void | |
| 181 | unalert(PurpleConversation *conv) | |
| 182 | { | |
| 35123 | 183 | if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), "unity-message-count")) > 0) |
| 35122 | 184 | --n_sources; |
| 35123 | 185 | |
| 186 | g_object_set_data(G_OBJECT(conv), "unity-message-count", | |
| 187 | GINT_TO_POINTER(0)); | |
| 35122 | 188 | messaging_menu_remove_conversation(conv); |
| 189 | update_launcher(); | |
| 190 | } | |
| 191 | ||
| 192 | static int | |
| 193 | unalert_cb(GtkWidget *widget, gpointer data, PurpleConversation *conv) | |
| 194 | { | |
| 195 | unalert(conv); | |
| 196 | return 0; | |
| 197 | } | |
| 198 | ||
| 199 | static gboolean | |
|
36110
63663622e327
Switch write_conv and (displaying|displayed)-(im|chat)-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36103
diff
changeset
|
200 | message_displayed_cb(PurpleConversation *conv, PurpleMessage *msg, gpointer _unused) |
| 35122 | 201 | { |
|
36110
63663622e327
Switch write_conv and (displaying|displayed)-(im|chat)-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36103
diff
changeset
|
202 | 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
|
203 | |
| 35123 | 204 | if ((PURPLE_IS_CHAT_CONVERSATION(conv) && alert_chat_nick && |
| 205 | !(flags & PURPLE_MESSAGE_NICK))) | |
| 35122 | 206 | return FALSE; |
| 207 | ||
| 208 | if ((flags & PURPLE_MESSAGE_RECV) && !(flags & PURPLE_MESSAGE_DELAYED)) | |
| 209 | alert(conv); | |
| 210 | ||
| 211 | return FALSE; | |
| 212 | } | |
| 213 | ||
| 214 | static void | |
|
36081
6764e037a308
Switch sent-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35610
diff
changeset
|
215 | im_sent_im(PurpleAccount *account, PurpleMessage *msg, gpointer _unused) |
| 35122 | 216 | { |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
217 | PurpleConversation *im = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
218 | PurpleConversationManager *manager = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
219 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
220 | manager = purple_conversation_manager_get_default(); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
221 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
222 | 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
|
223 | purple_message_get_recipient(msg)); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
224 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
225 | unalert(im); |
| 35122 | 226 | } |
| 227 | ||
| 228 | static void | |
|
36082
247d94c903c3
Switch sent-chat-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36081
diff
changeset
|
229 | chat_sent_im(PurpleAccount *account, PurpleMessage *msg, int id) |
| 35122 | 230 | { |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
231 | PurpleConversation *chat = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
232 | PurpleConversationManager *manager = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
233 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
234 | manager = purple_conversation_manager_get_default(); |
|
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 | 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
|
237 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
238 | unalert(chat); |
| 35122 | 239 | } |
| 240 | ||
| 241 | static void | |
| 242 | conv_created(PurpleConversation *conv) | |
| 243 | { | |
| 35123 | 244 | g_object_set_data(G_OBJECT(conv), "unity-message-count", |
| 245 | GINT_TO_POINTER(0)); | |
| 35122 | 246 | attach_signals(conv); |
| 247 | } | |
| 248 | ||
| 249 | static void | |
| 250 | deleting_conv(PurpleConversation *conv) | |
| 251 | { | |
| 252 | detach_signals(conv); | |
| 253 | unalert(conv); | |
| 254 | } | |
| 255 | ||
| 256 | static void | |
| 257 | message_source_activated(MessagingMenuApp *app, const gchar *id, | |
| 35123 | 258 | gpointer user_data) |
| 35122 | 259 | { |
| 260 | gchar **sections = g_strsplit(id, ":", 0); | |
| 261 | PurpleConversation *conv = NULL; | |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
262 | PurpleConversationManager *conversation_manager = NULL; |
| 35122 | 263 | PurpleAccount *account; |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
264 | PurpleAccountManager *account_manager = NULL; |
| 35122 | 265 | |
| 266 | char *type = sections[0]; | |
| 267 | char *cname = sections[1]; | |
| 268 | char *aname = sections[2]; | |
| 269 | char *protocol = sections[3]; | |
| 270 | ||
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
271 | 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
|
272 | |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
273 | account_manager = purple_account_manager_get_default(); |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
274 | account = purple_account_manager_find(account_manager, aname, protocol); |
| 35123 | 275 | |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
276 | if (g_strcmp0(type, "im") == 0) { |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
277 | 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
|
278 | account, cname); |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
279 | } 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
|
280 | 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
|
281 | account, cname); |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
282 | } else { |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
283 | conv = purple_conversation_manager_find(conversation_manager, |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
284 | account, cname); |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
285 | } |
| 35122 | 286 | |
| 287 | if (conv) { | |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
288 | GtkWidget *win = NULL; |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
289 | PidginConversationWindow *convwin = NULL; |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
290 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
291 | win = gtk_widget_get_toplevel(PIDGIN_CONVERSATION(conv)->tab_cont); |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
292 | convwin = PIDGIN_CONVERSATION_WINDOW(win); |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
293 | |
| 35122 | 294 | unalert(conv); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
295 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
296 | pidgin_conversation_window_select(convwin, conv); |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
297 | gdk_window_focus(gtk_widget_get_window(win), time(NULL)); |
| 35122 | 298 | } |
| 299 | g_strfreev (sections); | |
| 300 | } | |
| 301 | ||
| 302 | static PurpleSavedStatus * | |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
303 | create_transient_status(PurpleStatusPrimitive primitive, |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
304 | PurpleStatusType *status_type) |
| 35122 | 305 | { |
| 306 | PurpleSavedStatus *saved_status = purple_savedstatus_new(NULL, primitive); | |
| 307 | ||
| 308 | if(status_type != NULL) { | |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
309 | PurpleAccountManager *manager = NULL; |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
310 | GList *active_accts = NULL; |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
311 | |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
312 | 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
|
313 | 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
|
314 | |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
315 | while(active_accts != NULL) { |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
316 | PurpleAccount *account = PURPLE_ACCOUNT(active_accts->data); |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
317 | |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
318 | purple_savedstatus_set_substatus(saved_status, account, |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
319 | status_type, NULL); |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
320 | |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
321 | active_accts = g_list_delete_link(active_accts, active_accts); |
| 35122 | 322 | } |
| 323 | } | |
| 324 | ||
| 325 | return saved_status; | |
| 326 | } | |
| 327 | ||
| 328 | static void | |
| 329 | status_changed_cb(PurpleSavedStatus *saved_status) | |
| 330 | { | |
| 331 | MessagingMenuStatus status = MESSAGING_MENU_STATUS_AVAILABLE; | |
| 332 | ||
|
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
|
333 | switch (purple_savedstatus_get_primitive_type(saved_status)) { |
| 35122 | 334 | case PURPLE_STATUS_AVAILABLE: |
| 335 | case PURPLE_STATUS_MOOD: | |
| 336 | case PURPLE_STATUS_TUNE: | |
| 337 | case PURPLE_STATUS_UNSET: | |
| 338 | status = MESSAGING_MENU_STATUS_AVAILABLE; | |
| 339 | break; | |
| 340 | ||
| 341 | case PURPLE_STATUS_AWAY: | |
| 342 | case PURPLE_STATUS_EXTENDED_AWAY: | |
| 343 | status = MESSAGING_MENU_STATUS_AWAY; | |
| 344 | break; | |
| 345 | ||
| 346 | case PURPLE_STATUS_INVISIBLE: | |
| 347 | status = MESSAGING_MENU_STATUS_INVISIBLE; | |
| 348 | break; | |
| 349 | ||
| 350 | case PURPLE_STATUS_MOBILE: | |
| 351 | case PURPLE_STATUS_OFFLINE: | |
| 352 | status = MESSAGING_MENU_STATUS_OFFLINE; | |
| 353 | break; | |
| 354 | ||
| 355 | case PURPLE_STATUS_UNAVAILABLE: | |
| 356 | status = MESSAGING_MENU_STATUS_BUSY; | |
| 357 | break; | |
| 358 | ||
| 359 | default: | |
| 360 | g_assert_not_reached(); | |
| 361 | } | |
| 362 | messaging_menu_app_set_status(mmapp, status); | |
| 363 | } | |
| 364 | ||
| 365 | static void | |
| 366 | messaging_menu_status_changed(MessagingMenuApp *mmapp, | |
| 35123 | 367 | MessagingMenuStatus mm_status, gpointer user_data) |
| 35122 | 368 | { |
| 369 | PurpleSavedStatus *saved_status; | |
| 370 | PurpleStatusPrimitive primitive = PURPLE_STATUS_UNSET; | |
| 371 | ||
| 372 | switch (mm_status) { | |
| 373 | case MESSAGING_MENU_STATUS_AVAILABLE: | |
| 374 | primitive = PURPLE_STATUS_AVAILABLE; | |
| 375 | break; | |
| 376 | ||
| 377 | case MESSAGING_MENU_STATUS_AWAY: | |
| 378 | primitive = PURPLE_STATUS_AWAY; | |
| 379 | break; | |
| 380 | ||
| 381 | case MESSAGING_MENU_STATUS_BUSY: | |
| 382 | primitive = PURPLE_STATUS_UNAVAILABLE; | |
| 383 | break; | |
| 384 | ||
| 385 | case MESSAGING_MENU_STATUS_INVISIBLE: | |
| 386 | primitive = PURPLE_STATUS_INVISIBLE; | |
| 387 | break; | |
| 388 | ||
| 389 | case MESSAGING_MENU_STATUS_OFFLINE: | |
| 390 | primitive = PURPLE_STATUS_OFFLINE; | |
| 391 | break; | |
| 392 | ||
| 393 | default: | |
| 394 | g_assert_not_reached(); | |
| 395 | } | |
| 396 | ||
| 397 | saved_status = purple_savedstatus_find_transient_by_type_and_message(primitive, NULL); | |
| 398 | if (saved_status == NULL) | |
| 399 | saved_status = create_transient_status(primitive, NULL); | |
| 400 | purple_savedstatus_activate(saved_status); | |
| 401 | } | |
| 402 | ||
| 403 | static void | |
| 404 | alert_config_cb(GtkWidget *widget, gpointer data) | |
| 405 | { | |
| 406 | gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
| 407 | purple_prefs_set_bool("/plugins/gtk/unity/alert_chat_nick", on); | |
| 408 | alert_chat_nick = on; | |
| 409 | } | |
| 410 | ||
| 411 | static void | |
| 412 | launcher_config_cb(GtkWidget *widget, gpointer data) | |
| 413 | { | |
| 414 | gint option = GPOINTER_TO_INT(data); | |
| 35124 | 415 | if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) |
| 416 | return; | |
| 35122 | 417 | |
| 418 | purple_prefs_set_int("/plugins/gtk/unity/launcher_count", option); | |
| 419 | launcher_count = option; | |
| 420 | if (option == LAUNCHER_COUNT_DISABLE) | |
| 421 | unity_launcher_entry_set_count_visible(launcher, FALSE); | |
| 422 | else | |
| 423 | update_launcher(); | |
| 424 | } | |
| 425 | ||
| 426 | static void | |
| 427 | messaging_menu_config_cb(GtkWidget *widget, gpointer data) | |
| 428 | { | |
| 429 | gint option = GPOINTER_TO_INT(data); | |
| 35124 | 430 | if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) |
| 431 | return; | |
| 35122 | 432 | |
| 433 | purple_prefs_set_int("/plugins/gtk/unity/messaging_menu_text", option); | |
| 434 | messaging_menu_text = option; | |
| 435 | refill_messaging_menu(); | |
| 436 | } | |
| 437 | ||
| 438 | static int | |
| 439 | attach_signals(PurpleConversation *conv) | |
| 440 | { | |
| 441 | PidginConversation *gtkconv = NULL; | |
| 442 | guint id; | |
| 443 | ||
| 444 | gtkconv = PIDGIN_CONVERSATION(conv); | |
| 445 | if (!gtkconv) | |
| 446 | return 0; | |
| 447 | ||
| 448 | id = g_signal_connect(G_OBJECT(gtkconv->entry), "focus-in-event", | |
| 35123 | 449 | G_CALLBACK(unalert_cb), conv); |
| 450 | g_object_set_data(G_OBJECT(conv), "unity-entry-signal", GUINT_TO_POINTER(id)); | |
| 35122 | 451 | |
|
40947
4169f8090a0e
Make the unity plugin compile again and add stuff to ci ubuntu builds
Gary Kramlich <grim@reaperworld.com>
parents:
40894
diff
changeset
|
452 | id = g_signal_connect(G_OBJECT(gtkconv->history), "focus-in-event", |
| 35123 | 453 | 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
|
454 | g_object_set_data(G_OBJECT(conv), "unity-history-signal", GUINT_TO_POINTER(id)); |
| 35122 | 455 | |
| 456 | return 0; | |
| 457 | } | |
| 458 | ||
| 459 | static void | |
| 460 | detach_signals(PurpleConversation *conv) | |
| 461 | { | |
| 462 | PidginConversation *gtkconv = NULL; | |
| 463 | guint id; | |
| 464 | gtkconv = PIDGIN_CONVERSATION(conv); | |
| 465 | if (!gtkconv) | |
| 466 | return; | |
| 467 | ||
|
40947
4169f8090a0e
Make the unity plugin compile again and add stuff to ci ubuntu builds
Gary Kramlich <grim@reaperworld.com>
parents:
40894
diff
changeset
|
468 | 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
|
469 | g_signal_handler_disconnect(gtkconv->history, id); |
| 35122 | 470 | |
| 35123 | 471 | id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), "unity-entry-signal")); |
| 35122 | 472 | g_signal_handler_disconnect(gtkconv->entry, id); |
| 473 | ||
| 35123 | 474 | g_object_set_data(G_OBJECT(conv), "unity-message-count", |
| 475 | GINT_TO_POINTER(0)); | |
| 35122 | 476 | } |
| 477 | ||
| 478 | static GtkWidget * | |
| 479 | get_config_frame(PurplePlugin *plugin) | |
| 480 | { | |
| 481 | GtkWidget *ret = NULL, *frame = NULL; | |
| 482 | GtkWidget *vbox = NULL, *toggle = NULL; | |
| 483 | ||
|
35534
8e72593def2c
Fix gtk_[hv]box_new gtk3 deprecation warnings in unity plugin
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
484 | ret = gtk_box_new(GTK_ORIENTATION_VERTICAL, 18); |
| 35122 | 485 | gtk_container_set_border_width(GTK_CONTAINER (ret), 12); |
| 486 | ||
| 487 | /* Alerts */ | |
| 488 | ||
| 489 | frame = pidgin_make_frame(ret, _("Chatroom alerts")); | |
|
35534
8e72593def2c
Fix gtk_[hv]box_new gtk3 deprecation warnings in unity plugin
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
490 | vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); |
| 35122 | 491 | gtk_container_add(GTK_CONTAINER(frame), vbox); |
| 492 | ||
| 493 | toggle = gtk_check_button_new_with_mnemonic(_("Chatroom message alerts _only where someone says your username")); | |
| 494 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 495 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 35123 | 496 | purple_prefs_get_bool("/plugins/gtk/unity/alert_chat_nick")); |
| 35122 | 497 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 35123 | 498 | G_CALLBACK(alert_config_cb), NULL); |
| 35122 | 499 | |
| 500 | /* Launcher integration */ | |
| 501 | ||
| 502 | frame = pidgin_make_frame(ret, _("Launcher Icon")); | |
|
35534
8e72593def2c
Fix gtk_[hv]box_new gtk3 deprecation warnings in unity plugin
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
503 | vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); |
| 35122 | 504 | gtk_container_add(GTK_CONTAINER(frame), vbox); |
| 505 | ||
| 506 | toggle = gtk_radio_button_new_with_mnemonic(NULL, _("_Disable launcher integration")); | |
| 507 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 508 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 509 | purple_prefs_get_int("/plugins/gtk/unity/launcher_count") == LAUNCHER_COUNT_DISABLE); | |
| 510 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 35123 | 511 | G_CALLBACK(launcher_config_cb), GUINT_TO_POINTER(LAUNCHER_COUNT_DISABLE)); |
| 35122 | 512 | |
| 513 | toggle = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(toggle), | |
| 35123 | 514 | _("Show number of unread _messages on launcher icon")); |
| 35122 | 515 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 516 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 517 | purple_prefs_get_int("/plugins/gtk/unity/launcher_count") == LAUNCHER_COUNT_MESSAGES); | |
| 518 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 35123 | 519 | G_CALLBACK(launcher_config_cb), GUINT_TO_POINTER(LAUNCHER_COUNT_MESSAGES)); |
| 35122 | 520 | |
| 521 | toggle = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(toggle), | |
|
35317
3c9c77b80a6c
Merge the release-2.x.y branch into default.
Mark Doliner <mark@kingant.net>
diff
changeset
|
522 | _("Show number of unread co_nversations on launcher icon")); |
| 35122 | 523 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 524 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 525 | purple_prefs_get_int("/plugins/gtk/unity/launcher_count") == LAUNCHER_COUNT_SOURCES); | |
| 526 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 35123 | 527 | G_CALLBACK(launcher_config_cb), GUINT_TO_POINTER(LAUNCHER_COUNT_SOURCES)); |
| 35122 | 528 | |
| 529 | /* Messaging menu integration */ | |
| 530 | ||
| 531 | frame = pidgin_make_frame(ret, _("Messaging Menu")); | |
|
35534
8e72593def2c
Fix gtk_[hv]box_new gtk3 deprecation warnings in unity plugin
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
532 | vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); |
| 35122 | 533 | gtk_container_add(GTK_CONTAINER(frame), vbox); |
| 534 | ||
| 535 | toggle = gtk_radio_button_new_with_mnemonic(NULL, | |
| 35123 | 536 | _("Show number of _unread messages for conversations in messaging menu")); |
| 35122 | 537 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 538 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 539 | purple_prefs_get_int("/plugins/gtk/unity/messaging_menu_text") == MESSAGING_MENU_COUNT); | |
| 540 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 35123 | 541 | G_CALLBACK(messaging_menu_config_cb), GUINT_TO_POINTER(MESSAGING_MENU_COUNT)); |
| 35122 | 542 | |
| 543 | toggle = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(toggle), | |
| 35123 | 544 | _("Show _elapsed time for unread conversations in messaging menu")); |
| 35122 | 545 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 546 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 547 | purple_prefs_get_int("/plugins/gtk/unity/messaging_menu_text") == MESSAGING_MENU_TIME); | |
| 548 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 35123 | 549 | G_CALLBACK(messaging_menu_config_cb), GUINT_TO_POINTER(MESSAGING_MENU_TIME)); |
| 35122 | 550 | |
| 551 | gtk_widget_show_all(ret); | |
| 552 | return ret; | |
| 553 | } | |
| 554 | ||
|
40894
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
555 | static GPluginPluginInfo * |
|
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
556 | unity_query(GError **error) |
|
36969
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
557 | { |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
558 | const gchar * const authors[] = { |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
559 | "Ankit Vani <a@nevitus.org>", |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
560 | NULL |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
561 | }; |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
562 | |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
563 | return pidgin_plugin_info_new( |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
564 | "id", UNITY_PLUGIN_ID, |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
565 | "name", N_("Unity Integration"), |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
566 | "version", DISPLAY_VERSION, |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
567 | "category", N_("Notification"), |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
568 | "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
|
569 | "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
|
570 | "messaging menu and launcher."), |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
571 | "authors", authors, |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
572 | "website", PURPLE_WEBSITE, |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
573 | "abi-version", PURPLE_ABI_VERSION, |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
574 | "gtk-config-frame-cb", get_config_frame, |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
575 | NULL |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
576 | ); |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
577 | } |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
578 | |
| 35122 | 579 | static gboolean |
|
40894
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
580 | unity_load(GPluginPlugin *plugin, GError **error) { |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
581 | GList *convs = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
582 | PurpleConversationManager *manager = NULL; |
| 35122 | 583 | PurpleSavedStatus *saved_status; |
| 584 | void *conv_handle = purple_conversations_get_handle(); | |
| 585 | void *gtk_conv_handle = pidgin_conversations_get_handle(); | |
| 586 | void *savedstat_handle = purple_savedstatuses_get_handle(); | |
| 587 | ||
|
36969
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
588 | purple_prefs_add_none("/plugins/gtk"); |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
589 | purple_prefs_add_none("/plugins/gtk/unity"); |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
590 | purple_prefs_add_int("/plugins/gtk/unity/launcher_count", LAUNCHER_COUNT_SOURCES); |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
591 | purple_prefs_add_int("/plugins/gtk/unity/messaging_menu_text", MESSAGING_MENU_COUNT); |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
592 | purple_prefs_add_bool("/plugins/gtk/unity/alert_chat_nick", TRUE); |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
593 | |
| 35122 | 594 | alert_chat_nick = purple_prefs_get_bool("/plugins/gtk/unity/alert_chat_nick"); |
| 595 | ||
| 596 | mmapp = messaging_menu_app_new("pidgin.desktop"); | |
| 597 | g_object_ref(mmapp); | |
| 598 | messaging_menu_app_register(mmapp); | |
| 599 | messaging_menu_text = purple_prefs_get_int("/plugins/gtk/unity/messaging_menu_text"); | |
| 600 | ||
| 601 | g_signal_connect(mmapp, "activate-source", | |
| 35123 | 602 | G_CALLBACK(message_source_activated), NULL); |
| 35122 | 603 | g_signal_connect(mmapp, "status-changed", |
| 35123 | 604 | G_CALLBACK(messaging_menu_status_changed), NULL); |
| 35122 | 605 | |
| 606 | saved_status = purple_savedstatus_get_current(); | |
| 607 | status_changed_cb(saved_status); | |
| 608 | ||
| 609 | 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
|
610 | G_CALLBACK(status_changed_cb), NULL); |
| 35122 | 611 | |
| 612 | launcher = unity_launcher_entry_get_for_desktop_id("pidgin.desktop"); | |
| 613 | g_object_ref(launcher); | |
| 614 | launcher_count = purple_prefs_get_int("/plugins/gtk/unity/launcher_count"); | |
| 615 | ||
| 616 | 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
|
617 | G_CALLBACK(message_displayed_cb), NULL); |
| 35122 | 618 | 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
|
619 | G_CALLBACK(message_displayed_cb), NULL); |
| 35122 | 620 | 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
|
621 | G_CALLBACK(im_sent_im), NULL); |
| 35122 | 622 | 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
|
623 | G_CALLBACK(chat_sent_im), NULL); |
| 35122 | 624 | 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
|
625 | G_CALLBACK(conv_created), NULL); |
| 35122 | 626 | 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
|
627 | G_CALLBACK(deleting_conv), NULL); |
| 35122 | 628 | |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
629 | manager = purple_conversation_manager_get_default(); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
630 | 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
|
631 | while(convs != NULL) { |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
632 | PurpleConversation *conv = PURPLE_CONVERSATION(convs->data); |
| 35122 | 633 | attach_signals(conv); |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
634 | convs = g_list_delete_link(convs, convs); |
| 35122 | 635 | } |
| 636 | ||
| 637 | return TRUE; | |
| 638 | } | |
| 639 | ||
| 640 | static gboolean | |
|
41081
0c1c063d71f6
Add the unload parameter to a few plugins that I missed on the gplugin 0.35.0 update
Gary Kramlich <grim@reaperworld.com>
parents:
41002
diff
changeset
|
641 | unity_unload(GPluginPlugin *plugin, gboolean shutdown, GError **error) { |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
642 | GList *convs = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
643 | PurpleConversationManager *manager = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
644 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
645 | manager = purple_conversation_manager_get_default(); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
646 | 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
|
647 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
648 | while(convs != NULL) { |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
649 | PurpleConversation *conv = PURPLE_CONVERSATION(convs->data); |
| 35122 | 650 | unalert(conv); |
| 651 | detach_signals(conv); | |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
652 | convs = g_list_delete_link(convs, convs); |
| 35122 | 653 | } |
|
40894
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
654 | |
| 35122 | 655 | unity_launcher_entry_set_count_visible(launcher, FALSE); |
| 656 | messaging_menu_app_unregister(mmapp); | |
| 657 | ||
| 658 | g_object_unref(launcher); | |
| 659 | g_object_unref(mmapp); | |
| 660 | return TRUE; | |
| 661 | } | |
| 662 | ||
|
40894
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
663 | GPLUGIN_NATIVE_PLUGIN_DECLARE(unity) |