Mon, 06 Dec 2021 23:11:42 -0600
Move conversation management from gtkconv.c to PidginConversationWindow.
This replaces the conversation window's notebook with a treeview and is the
first steps in keeping conversations alive even when they're closed in the
Pidgin ui.
Testing Done:
Opened an im, closed the window, opened the same im again. Opened multiple ims and a chat, verified all functioned as expected.
Reviewed at https://reviews.imfreedom.org/r/1108/
| 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; | |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
262 | PurpleConversationManager *manager = NULL; |
| 35122 | 263 | PurpleAccount *account; |
| 264 | ||
| 265 | char *type = sections[0]; | |
| 266 | char *cname = sections[1]; | |
| 267 | char *aname = sections[2]; | |
| 268 | char *protocol = sections[3]; | |
| 269 | ||
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
270 | manager = purple_conversation_manager_get_default(); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
271 | |
| 35122 | 272 | account = purple_accounts_find(aname, protocol); |
| 35123 | 273 | |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
274 | if (g_strcmp0(type, "im") == 0) { |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
275 | conv = purple_conversation_manager_find_im(manager, account, cname); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
276 | } else if (g_strcmp0(type, "chat") == 0) { |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
277 | conv = purple_conversation_manager_find_chat(manager, account, cname); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
278 | } else { |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
279 | conv = purple_conversation_manager_find(manager, account, cname); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
280 | } |
| 35122 | 281 | |
| 282 | if (conv) { | |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
283 | GtkWidget *win = NULL; |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
284 | PidginConversationWindow *convwin = NULL; |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
285 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
286 | 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
|
287 | convwin = PIDGIN_CONVERSATION_WINDOW(win); |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
288 | |
| 35122 | 289 | unalert(conv); |
|
41184
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 | pidgin_conversation_window_select(convwin, conv); |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
292 | gdk_window_focus(gtk_widget_get_window(win), time(NULL)); |
| 35122 | 293 | } |
| 294 | g_strfreev (sections); | |
| 295 | } | |
| 296 | ||
| 297 | static PurpleSavedStatus * | |
| 298 | create_transient_status(PurpleStatusPrimitive primitive, PurpleStatusType *status_type) | |
| 299 | { | |
| 300 | PurpleSavedStatus *saved_status = purple_savedstatus_new(NULL, primitive); | |
| 301 | ||
| 302 | if(status_type != NULL) { | |
| 303 | GList *tmp, *active_accts = purple_accounts_get_all_active(); | |
| 304 | for (tmp = active_accts; tmp != NULL; tmp = tmp->next) { | |
| 305 | purple_savedstatus_set_substatus(saved_status, | |
| 306 | (PurpleAccount*) tmp->data, status_type, NULL); | |
| 307 | } | |
| 308 | g_list_free(active_accts); | |
| 309 | } | |
| 310 | ||
| 311 | return saved_status; | |
| 312 | } | |
| 313 | ||
| 314 | static void | |
| 315 | status_changed_cb(PurpleSavedStatus *saved_status) | |
| 316 | { | |
| 317 | MessagingMenuStatus status = MESSAGING_MENU_STATUS_AVAILABLE; | |
| 318 | ||
|
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
|
319 | switch (purple_savedstatus_get_primitive_type(saved_status)) { |
| 35122 | 320 | case PURPLE_STATUS_AVAILABLE: |
| 321 | case PURPLE_STATUS_MOOD: | |
| 322 | case PURPLE_STATUS_TUNE: | |
| 323 | case PURPLE_STATUS_UNSET: | |
| 324 | status = MESSAGING_MENU_STATUS_AVAILABLE; | |
| 325 | break; | |
| 326 | ||
| 327 | case PURPLE_STATUS_AWAY: | |
| 328 | case PURPLE_STATUS_EXTENDED_AWAY: | |
| 329 | status = MESSAGING_MENU_STATUS_AWAY; | |
| 330 | break; | |
| 331 | ||
| 332 | case PURPLE_STATUS_INVISIBLE: | |
| 333 | status = MESSAGING_MENU_STATUS_INVISIBLE; | |
| 334 | break; | |
| 335 | ||
| 336 | case PURPLE_STATUS_MOBILE: | |
| 337 | case PURPLE_STATUS_OFFLINE: | |
| 338 | status = MESSAGING_MENU_STATUS_OFFLINE; | |
| 339 | break; | |
| 340 | ||
| 341 | case PURPLE_STATUS_UNAVAILABLE: | |
| 342 | status = MESSAGING_MENU_STATUS_BUSY; | |
| 343 | break; | |
| 344 | ||
| 345 | default: | |
| 346 | g_assert_not_reached(); | |
| 347 | } | |
| 348 | messaging_menu_app_set_status(mmapp, status); | |
| 349 | } | |
| 350 | ||
| 351 | static void | |
| 352 | messaging_menu_status_changed(MessagingMenuApp *mmapp, | |
| 35123 | 353 | MessagingMenuStatus mm_status, gpointer user_data) |
| 35122 | 354 | { |
| 355 | PurpleSavedStatus *saved_status; | |
| 356 | PurpleStatusPrimitive primitive = PURPLE_STATUS_UNSET; | |
| 357 | ||
| 358 | switch (mm_status) { | |
| 359 | case MESSAGING_MENU_STATUS_AVAILABLE: | |
| 360 | primitive = PURPLE_STATUS_AVAILABLE; | |
| 361 | break; | |
| 362 | ||
| 363 | case MESSAGING_MENU_STATUS_AWAY: | |
| 364 | primitive = PURPLE_STATUS_AWAY; | |
| 365 | break; | |
| 366 | ||
| 367 | case MESSAGING_MENU_STATUS_BUSY: | |
| 368 | primitive = PURPLE_STATUS_UNAVAILABLE; | |
| 369 | break; | |
| 370 | ||
| 371 | case MESSAGING_MENU_STATUS_INVISIBLE: | |
| 372 | primitive = PURPLE_STATUS_INVISIBLE; | |
| 373 | break; | |
| 374 | ||
| 375 | case MESSAGING_MENU_STATUS_OFFLINE: | |
| 376 | primitive = PURPLE_STATUS_OFFLINE; | |
| 377 | break; | |
| 378 | ||
| 379 | default: | |
| 380 | g_assert_not_reached(); | |
| 381 | } | |
| 382 | ||
| 383 | saved_status = purple_savedstatus_find_transient_by_type_and_message(primitive, NULL); | |
| 384 | if (saved_status == NULL) | |
| 385 | saved_status = create_transient_status(primitive, NULL); | |
| 386 | purple_savedstatus_activate(saved_status); | |
| 387 | } | |
| 388 | ||
| 389 | static void | |
| 390 | alert_config_cb(GtkWidget *widget, gpointer data) | |
| 391 | { | |
| 392 | gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
| 393 | purple_prefs_set_bool("/plugins/gtk/unity/alert_chat_nick", on); | |
| 394 | alert_chat_nick = on; | |
| 395 | } | |
| 396 | ||
| 397 | static void | |
| 398 | launcher_config_cb(GtkWidget *widget, gpointer data) | |
| 399 | { | |
| 400 | gint option = GPOINTER_TO_INT(data); | |
| 35124 | 401 | if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) |
| 402 | return; | |
| 35122 | 403 | |
| 404 | purple_prefs_set_int("/plugins/gtk/unity/launcher_count", option); | |
| 405 | launcher_count = option; | |
| 406 | if (option == LAUNCHER_COUNT_DISABLE) | |
| 407 | unity_launcher_entry_set_count_visible(launcher, FALSE); | |
| 408 | else | |
| 409 | update_launcher(); | |
| 410 | } | |
| 411 | ||
| 412 | static void | |
| 413 | messaging_menu_config_cb(GtkWidget *widget, gpointer data) | |
| 414 | { | |
| 415 | gint option = GPOINTER_TO_INT(data); | |
| 35124 | 416 | if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) |
| 417 | return; | |
| 35122 | 418 | |
| 419 | purple_prefs_set_int("/plugins/gtk/unity/messaging_menu_text", option); | |
| 420 | messaging_menu_text = option; | |
| 421 | refill_messaging_menu(); | |
| 422 | } | |
| 423 | ||
| 424 | static int | |
| 425 | attach_signals(PurpleConversation *conv) | |
| 426 | { | |
| 427 | PidginConversation *gtkconv = NULL; | |
| 428 | guint id; | |
| 429 | ||
| 430 | gtkconv = PIDGIN_CONVERSATION(conv); | |
| 431 | if (!gtkconv) | |
| 432 | return 0; | |
| 433 | ||
| 434 | id = g_signal_connect(G_OBJECT(gtkconv->entry), "focus-in-event", | |
| 35123 | 435 | G_CALLBACK(unalert_cb), conv); |
| 436 | g_object_set_data(G_OBJECT(conv), "unity-entry-signal", GUINT_TO_POINTER(id)); | |
| 35122 | 437 | |
|
40947
4169f8090a0e
Make the unity plugin compile again and add stuff to ci ubuntu builds
Gary Kramlich <grim@reaperworld.com>
parents:
40894
diff
changeset
|
438 | id = g_signal_connect(G_OBJECT(gtkconv->history), "focus-in-event", |
| 35123 | 439 | 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
|
440 | g_object_set_data(G_OBJECT(conv), "unity-history-signal", GUINT_TO_POINTER(id)); |
| 35122 | 441 | |
| 442 | return 0; | |
| 443 | } | |
| 444 | ||
| 445 | static void | |
| 446 | detach_signals(PurpleConversation *conv) | |
| 447 | { | |
| 448 | PidginConversation *gtkconv = NULL; | |
| 449 | guint id; | |
| 450 | gtkconv = PIDGIN_CONVERSATION(conv); | |
| 451 | if (!gtkconv) | |
| 452 | return; | |
| 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 = 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
|
455 | g_signal_handler_disconnect(gtkconv->history, id); |
| 35122 | 456 | |
| 35123 | 457 | id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), "unity-entry-signal")); |
| 35122 | 458 | g_signal_handler_disconnect(gtkconv->entry, id); |
| 459 | ||
| 35123 | 460 | g_object_set_data(G_OBJECT(conv), "unity-message-count", |
| 461 | GINT_TO_POINTER(0)); | |
| 35122 | 462 | } |
| 463 | ||
| 464 | static GtkWidget * | |
| 465 | get_config_frame(PurplePlugin *plugin) | |
| 466 | { | |
| 467 | GtkWidget *ret = NULL, *frame = NULL; | |
| 468 | GtkWidget *vbox = NULL, *toggle = NULL; | |
| 469 | ||
|
35534
8e72593def2c
Fix gtk_[hv]box_new gtk3 deprecation warnings in unity plugin
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
470 | ret = gtk_box_new(GTK_ORIENTATION_VERTICAL, 18); |
| 35122 | 471 | gtk_container_set_border_width(GTK_CONTAINER (ret), 12); |
| 472 | ||
| 473 | /* Alerts */ | |
| 474 | ||
| 475 | 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
|
476 | vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); |
| 35122 | 477 | gtk_container_add(GTK_CONTAINER(frame), vbox); |
| 478 | ||
| 479 | toggle = gtk_check_button_new_with_mnemonic(_("Chatroom message alerts _only where someone says your username")); | |
| 480 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 481 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 35123 | 482 | purple_prefs_get_bool("/plugins/gtk/unity/alert_chat_nick")); |
| 35122 | 483 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 35123 | 484 | G_CALLBACK(alert_config_cb), NULL); |
| 35122 | 485 | |
| 486 | /* Launcher integration */ | |
| 487 | ||
| 488 | 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
|
489 | vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); |
| 35122 | 490 | gtk_container_add(GTK_CONTAINER(frame), vbox); |
| 491 | ||
| 492 | toggle = gtk_radio_button_new_with_mnemonic(NULL, _("_Disable launcher integration")); | |
| 493 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); | |
| 494 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 495 | purple_prefs_get_int("/plugins/gtk/unity/launcher_count") == LAUNCHER_COUNT_DISABLE); | |
| 496 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 35123 | 497 | G_CALLBACK(launcher_config_cb), GUINT_TO_POINTER(LAUNCHER_COUNT_DISABLE)); |
| 35122 | 498 | |
| 499 | toggle = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(toggle), | |
| 35123 | 500 | _("Show number of unread _messages on launcher icon")); |
| 35122 | 501 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 502 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 503 | purple_prefs_get_int("/plugins/gtk/unity/launcher_count") == LAUNCHER_COUNT_MESSAGES); | |
| 504 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 35123 | 505 | G_CALLBACK(launcher_config_cb), GUINT_TO_POINTER(LAUNCHER_COUNT_MESSAGES)); |
| 35122 | 506 | |
| 507 | 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
|
508 | _("Show number of unread co_nversations on launcher icon")); |
| 35122 | 509 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 510 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 511 | purple_prefs_get_int("/plugins/gtk/unity/launcher_count") == LAUNCHER_COUNT_SOURCES); | |
| 512 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 35123 | 513 | G_CALLBACK(launcher_config_cb), GUINT_TO_POINTER(LAUNCHER_COUNT_SOURCES)); |
| 35122 | 514 | |
| 515 | /* Messaging menu integration */ | |
| 516 | ||
| 517 | 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
|
518 | vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); |
| 35122 | 519 | gtk_container_add(GTK_CONTAINER(frame), vbox); |
| 520 | ||
| 521 | toggle = gtk_radio_button_new_with_mnemonic(NULL, | |
| 35123 | 522 | _("Show number of _unread messages for conversations in messaging menu")); |
| 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/messaging_menu_text") == MESSAGING_MENU_COUNT); | |
| 526 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 35123 | 527 | G_CALLBACK(messaging_menu_config_cb), GUINT_TO_POINTER(MESSAGING_MENU_COUNT)); |
| 35122 | 528 | |
| 529 | toggle = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(toggle), | |
| 35123 | 530 | _("Show _elapsed time for unread conversations in messaging menu")); |
| 35122 | 531 | gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
| 532 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), | |
| 533 | purple_prefs_get_int("/plugins/gtk/unity/messaging_menu_text") == MESSAGING_MENU_TIME); | |
| 534 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 35123 | 535 | G_CALLBACK(messaging_menu_config_cb), GUINT_TO_POINTER(MESSAGING_MENU_TIME)); |
| 35122 | 536 | |
| 537 | gtk_widget_show_all(ret); | |
| 538 | return ret; | |
| 539 | } | |
| 540 | ||
|
40894
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
541 | static GPluginPluginInfo * |
|
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
542 | unity_query(GError **error) |
|
36969
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
543 | { |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
544 | const gchar * const authors[] = { |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
545 | "Ankit Vani <a@nevitus.org>", |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
546 | NULL |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
547 | }; |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
548 | |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
549 | return pidgin_plugin_info_new( |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
550 | "id", UNITY_PLUGIN_ID, |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
551 | "name", N_("Unity Integration"), |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
552 | "version", DISPLAY_VERSION, |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
553 | "category", N_("Notification"), |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
554 | "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
|
555 | "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
|
556 | "messaging menu and launcher."), |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
557 | "authors", authors, |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
558 | "website", PURPLE_WEBSITE, |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
559 | "abi-version", PURPLE_ABI_VERSION, |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
560 | "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
|
561 | NULL |
|
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 | } |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
564 | |
| 35122 | 565 | static gboolean |
|
40894
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
566 | 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
|
567 | GList *convs = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
568 | PurpleConversationManager *manager = NULL; |
| 35122 | 569 | PurpleSavedStatus *saved_status; |
| 570 | void *conv_handle = purple_conversations_get_handle(); | |
| 571 | void *gtk_conv_handle = pidgin_conversations_get_handle(); | |
| 572 | void *savedstat_handle = purple_savedstatuses_get_handle(); | |
| 573 | ||
|
36969
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
574 | 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
|
575 | 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
|
576 | 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
|
577 | 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
|
578 | 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
|
579 | |
| 35122 | 580 | alert_chat_nick = purple_prefs_get_bool("/plugins/gtk/unity/alert_chat_nick"); |
| 581 | ||
| 582 | mmapp = messaging_menu_app_new("pidgin.desktop"); | |
| 583 | g_object_ref(mmapp); | |
| 584 | messaging_menu_app_register(mmapp); | |
| 585 | messaging_menu_text = purple_prefs_get_int("/plugins/gtk/unity/messaging_menu_text"); | |
| 586 | ||
| 587 | g_signal_connect(mmapp, "activate-source", | |
| 35123 | 588 | G_CALLBACK(message_source_activated), NULL); |
| 35122 | 589 | g_signal_connect(mmapp, "status-changed", |
| 35123 | 590 | G_CALLBACK(messaging_menu_status_changed), NULL); |
| 35122 | 591 | |
| 592 | saved_status = purple_savedstatus_get_current(); | |
| 593 | status_changed_cb(saved_status); | |
| 594 | ||
| 595 | purple_signal_connect(savedstat_handle, "savedstatus-changed", plugin, | |
| 35123 | 596 | PURPLE_CALLBACK(status_changed_cb), NULL); |
| 35122 | 597 | |
| 598 | launcher = unity_launcher_entry_get_for_desktop_id("pidgin.desktop"); | |
| 599 | g_object_ref(launcher); | |
| 600 | launcher_count = purple_prefs_get_int("/plugins/gtk/unity/launcher_count"); | |
| 601 | ||
| 602 | purple_signal_connect(gtk_conv_handle, "displayed-im-msg", plugin, | |
| 35123 | 603 | PURPLE_CALLBACK(message_displayed_cb), NULL); |
| 35122 | 604 | purple_signal_connect(gtk_conv_handle, "displayed-chat-msg", plugin, |
| 35123 | 605 | PURPLE_CALLBACK(message_displayed_cb), NULL); |
| 35122 | 606 | purple_signal_connect(conv_handle, "sent-im-msg", plugin, |
| 35123 | 607 | PURPLE_CALLBACK(im_sent_im), NULL); |
| 35122 | 608 | purple_signal_connect(conv_handle, "sent-chat-msg", plugin, |
| 35123 | 609 | PURPLE_CALLBACK(chat_sent_im), NULL); |
| 35122 | 610 | purple_signal_connect(conv_handle, "conversation-created", plugin, |
| 35123 | 611 | PURPLE_CALLBACK(conv_created), NULL); |
| 35122 | 612 | purple_signal_connect(conv_handle, "deleting-conversation", plugin, |
| 35123 | 613 | PURPLE_CALLBACK(deleting_conv), NULL); |
| 35122 | 614 | |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
615 | manager = purple_conversation_manager_get_default(); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
616 | 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
|
617 | while(convs != NULL) { |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
618 | PurpleConversation *conv = PURPLE_CONVERSATION(convs->data); |
| 35122 | 619 | attach_signals(conv); |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
620 | convs = g_list_delete_link(convs, convs); |
| 35122 | 621 | } |
| 622 | ||
| 623 | return TRUE; | |
| 624 | } | |
| 625 | ||
| 626 | 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
|
627 | 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
|
628 | GList *convs = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
629 | PurpleConversationManager *manager = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
630 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
631 | manager = purple_conversation_manager_get_default(); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
632 | 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
|
633 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
634 | while(convs != NULL) { |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
635 | PurpleConversation *conv = PURPLE_CONVERSATION(convs->data); |
| 35122 | 636 | unalert(conv); |
| 637 | detach_signals(conv); | |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
638 | convs = g_list_delete_link(convs, convs); |
| 35122 | 639 | } |
|
40894
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
640 | |
| 35122 | 641 | unity_launcher_entry_set_count_visible(launcher, FALSE); |
| 642 | messaging_menu_app_unregister(mmapp); | |
| 643 | ||
| 644 | g_object_unref(launcher); | |
| 645 | g_object_unref(mmapp); | |
| 646 | return TRUE; | |
| 647 | } | |
| 648 | ||
|
40894
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
649 | GPLUGIN_NATIVE_PLUGIN_DECLARE(unity) |