Fri, 16 Sep 2022 01:54:11 -0500
Change the credential provider row active indicator to a CheckButton
Because I noticed that Adw has a style that is for this sort of thing.
Testing Done:
Opened Credential prefs, and changed selected provider. Also checked that clicking the check button didn't accidentally change its state without changing the row, and that it could not be selected by keyboard separately from the row.
Reviewed at https://reviews.imfreedom.org/r/1775/
| 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; |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
154 | GtkRoot *root = NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
155 | GtkWidget *win = NULL; |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
156 | |
| 35122 | 157 | if (conv == NULL || PIDGIN_CONVERSATION(conv) == NULL) |
| 158 | return 0; | |
| 159 | ||
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
160 | gtkconv = PIDGIN_CONVERSATION(conv); |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
161 | root = gtk_widget_get_root(gtkconv->tab_cont); |
|
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
162 | win = GTK_WIDGET(root); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
163 | convwin = PIDGIN_CONVERSATION_WINDOW(win); |
| 35122 | 164 | |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
165 | if (!gtk_widget_has_focus(win) || |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
166 | !pidgin_conversation_window_conversation_is_selected(convwin, conv)) |
| 35122 | 167 | { |
| 35123 | 168 | count = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), |
| 169 | "unity-message-count")); | |
| 35122 | 170 | if (!count++) |
| 171 | ++n_sources; | |
| 172 | ||
| 35123 | 173 | g_object_set_data(G_OBJECT(conv), "unity-message-count", |
| 174 | GINT_TO_POINTER(count)); | |
| 35122 | 175 | messaging_menu_add_conversation(conv, count); |
| 176 | update_launcher(); | |
| 177 | } | |
| 178 | ||
| 179 | return 0; | |
| 180 | } | |
| 181 | ||
| 182 | static void | |
| 183 | unalert(PurpleConversation *conv) | |
| 184 | { | |
| 35123 | 185 | if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), "unity-message-count")) > 0) |
| 35122 | 186 | --n_sources; |
| 35123 | 187 | |
| 188 | g_object_set_data(G_OBJECT(conv), "unity-message-count", | |
| 189 | GINT_TO_POINTER(0)); | |
| 35122 | 190 | messaging_menu_remove_conversation(conv); |
| 191 | update_launcher(); | |
| 192 | } | |
| 193 | ||
| 194 | static int | |
| 195 | unalert_cb(GtkWidget *widget, gpointer data, PurpleConversation *conv) | |
| 196 | { | |
| 197 | unalert(conv); | |
| 198 | return 0; | |
| 199 | } | |
| 200 | ||
| 201 | static gboolean | |
|
36110
63663622e327
Switch write_conv and (displaying|displayed)-(im|chat)-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36103
diff
changeset
|
202 | message_displayed_cb(PurpleConversation *conv, PurpleMessage *msg, gpointer _unused) |
| 35122 | 203 | { |
|
36110
63663622e327
Switch write_conv and (displaying|displayed)-(im|chat)-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36103
diff
changeset
|
204 | 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
|
205 | |
| 35123 | 206 | if ((PURPLE_IS_CHAT_CONVERSATION(conv) && alert_chat_nick && |
| 207 | !(flags & PURPLE_MESSAGE_NICK))) | |
| 35122 | 208 | return FALSE; |
| 209 | ||
| 210 | if ((flags & PURPLE_MESSAGE_RECV) && !(flags & PURPLE_MESSAGE_DELAYED)) | |
| 211 | alert(conv); | |
| 212 | ||
| 213 | return FALSE; | |
| 214 | } | |
| 215 | ||
| 216 | static void | |
|
36081
6764e037a308
Switch sent-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35610
diff
changeset
|
217 | im_sent_im(PurpleAccount *account, PurpleMessage *msg, gpointer _unused) |
| 35122 | 218 | { |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
219 | PurpleConversation *im = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
220 | PurpleConversationManager *manager = NULL; |
|
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 | manager = purple_conversation_manager_get_default(); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
223 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
224 | 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
|
225 | purple_message_get_recipient(msg)); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
226 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
227 | unalert(im); |
| 35122 | 228 | } |
| 229 | ||
| 230 | static void | |
|
36082
247d94c903c3
Switch sent-chat-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36081
diff
changeset
|
231 | chat_sent_im(PurpleAccount *account, PurpleMessage *msg, int id) |
| 35122 | 232 | { |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
233 | PurpleConversation *chat = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
234 | PurpleConversationManager *manager = NULL; |
|
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 | manager = purple_conversation_manager_get_default(); |
|
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 | 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
|
239 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
240 | unalert(chat); |
| 35122 | 241 | } |
| 242 | ||
| 243 | static void | |
| 244 | conv_created(PurpleConversation *conv) | |
| 245 | { | |
| 35123 | 246 | g_object_set_data(G_OBJECT(conv), "unity-message-count", |
| 247 | GINT_TO_POINTER(0)); | |
| 35122 | 248 | attach_signals(conv); |
| 249 | } | |
| 250 | ||
| 251 | static void | |
| 252 | deleting_conv(PurpleConversation *conv) | |
| 253 | { | |
| 254 | detach_signals(conv); | |
| 255 | unalert(conv); | |
| 256 | } | |
| 257 | ||
| 258 | static void | |
| 259 | message_source_activated(MessagingMenuApp *app, const gchar *id, | |
| 35123 | 260 | gpointer user_data) |
| 35122 | 261 | { |
| 262 | gchar **sections = g_strsplit(id, ":", 0); | |
| 263 | PurpleConversation *conv = NULL; | |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
264 | PurpleConversationManager *conversation_manager = NULL; |
| 35122 | 265 | PurpleAccount *account; |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
266 | PurpleAccountManager *account_manager = NULL; |
| 35122 | 267 | |
| 268 | char *type = sections[0]; | |
| 269 | char *cname = sections[1]; | |
| 270 | char *aname = sections[2]; | |
| 271 | char *protocol = sections[3]; | |
| 272 | ||
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
273 | 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
|
274 | |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
275 | account_manager = purple_account_manager_get_default(); |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
276 | account = purple_account_manager_find(account_manager, aname, protocol); |
| 35123 | 277 | |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
278 | if (g_strcmp0(type, "im") == 0) { |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
279 | 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
|
280 | account, cname); |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
281 | } 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
|
282 | 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
|
283 | account, cname); |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
284 | } else { |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
285 | conv = purple_conversation_manager_find(conversation_manager, |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
286 | account, cname); |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
287 | } |
| 35122 | 288 | |
| 289 | if (conv) { | |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
290 | GtkRoot *root = NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
291 | GtkWidget *win = NULL; |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
292 | PidginConversationWindow *convwin = NULL; |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
293 | |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
294 | root = gtk_widget_get_root(PIDGIN_CONVERSATION(conv)->tab_cont); |
|
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
295 | win = GTK_WIDGET(root); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
296 | convwin = PIDGIN_CONVERSATION_WINDOW(win); |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
297 | |
| 35122 | 298 | unalert(conv); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
299 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41081
diff
changeset
|
300 | pidgin_conversation_window_select(convwin, conv); |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
301 | |
|
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
302 | gtk_root_set_focus(root, PIDGIN_CONVERSATION(conv)->entry); |
| 35122 | 303 | } |
| 304 | g_strfreev (sections); | |
| 305 | } | |
| 306 | ||
| 307 | static PurpleSavedStatus * | |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
308 | create_transient_status(PurpleStatusPrimitive primitive, |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
309 | PurpleStatusType *status_type) |
| 35122 | 310 | { |
| 311 | PurpleSavedStatus *saved_status = purple_savedstatus_new(NULL, primitive); | |
| 312 | ||
| 313 | if(status_type != NULL) { | |
|
41209
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
314 | PurpleAccountManager *manager = NULL; |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
315 | GList *active_accts = NULL; |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
316 | |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
317 | 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
|
318 | 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
|
319 | |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
320 | while(active_accts != NULL) { |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
321 | PurpleAccount *account = PURPLE_ACCOUNT(active_accts->data); |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
322 | |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
323 | purple_savedstatus_set_substatus(saved_status, account, |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
324 | status_type, NULL); |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
325 | |
|
909561f42b1f
port Pidgin to the new PurpleAccountManager api
Gary Kramlich <grim@reaperworld.com>
parents:
41184
diff
changeset
|
326 | active_accts = g_list_delete_link(active_accts, active_accts); |
| 35122 | 327 | } |
| 328 | } | |
| 329 | ||
| 330 | return saved_status; | |
| 331 | } | |
| 332 | ||
| 333 | static void | |
| 334 | status_changed_cb(PurpleSavedStatus *saved_status) | |
| 335 | { | |
| 336 | MessagingMenuStatus status = MESSAGING_MENU_STATUS_AVAILABLE; | |
| 337 | ||
|
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
|
338 | switch (purple_savedstatus_get_primitive_type(saved_status)) { |
| 35122 | 339 | case PURPLE_STATUS_AVAILABLE: |
| 340 | case PURPLE_STATUS_MOOD: | |
| 341 | case PURPLE_STATUS_TUNE: | |
| 342 | case PURPLE_STATUS_UNSET: | |
| 343 | status = MESSAGING_MENU_STATUS_AVAILABLE; | |
| 344 | break; | |
| 345 | ||
| 346 | case PURPLE_STATUS_AWAY: | |
| 347 | case PURPLE_STATUS_EXTENDED_AWAY: | |
| 348 | status = MESSAGING_MENU_STATUS_AWAY; | |
| 349 | break; | |
| 350 | ||
| 351 | case PURPLE_STATUS_INVISIBLE: | |
| 352 | status = MESSAGING_MENU_STATUS_INVISIBLE; | |
| 353 | break; | |
| 354 | ||
| 355 | case PURPLE_STATUS_MOBILE: | |
| 356 | case PURPLE_STATUS_OFFLINE: | |
| 357 | status = MESSAGING_MENU_STATUS_OFFLINE; | |
| 358 | break; | |
| 359 | ||
| 360 | case PURPLE_STATUS_UNAVAILABLE: | |
| 361 | status = MESSAGING_MENU_STATUS_BUSY; | |
| 362 | break; | |
| 363 | ||
| 364 | default: | |
| 365 | g_assert_not_reached(); | |
| 366 | } | |
| 367 | messaging_menu_app_set_status(mmapp, status); | |
| 368 | } | |
| 369 | ||
| 370 | static void | |
| 371 | messaging_menu_status_changed(MessagingMenuApp *mmapp, | |
| 35123 | 372 | MessagingMenuStatus mm_status, gpointer user_data) |
| 35122 | 373 | { |
| 374 | PurpleSavedStatus *saved_status; | |
| 375 | PurpleStatusPrimitive primitive = PURPLE_STATUS_UNSET; | |
| 376 | ||
| 377 | switch (mm_status) { | |
| 378 | case MESSAGING_MENU_STATUS_AVAILABLE: | |
| 379 | primitive = PURPLE_STATUS_AVAILABLE; | |
| 380 | break; | |
| 381 | ||
| 382 | case MESSAGING_MENU_STATUS_AWAY: | |
| 383 | primitive = PURPLE_STATUS_AWAY; | |
| 384 | break; | |
| 385 | ||
| 386 | case MESSAGING_MENU_STATUS_BUSY: | |
| 387 | primitive = PURPLE_STATUS_UNAVAILABLE; | |
| 388 | break; | |
| 389 | ||
| 390 | case MESSAGING_MENU_STATUS_INVISIBLE: | |
| 391 | primitive = PURPLE_STATUS_INVISIBLE; | |
| 392 | break; | |
| 393 | ||
| 394 | case MESSAGING_MENU_STATUS_OFFLINE: | |
| 395 | primitive = PURPLE_STATUS_OFFLINE; | |
| 396 | break; | |
| 397 | ||
| 398 | default: | |
| 399 | g_assert_not_reached(); | |
| 400 | } | |
| 401 | ||
| 402 | saved_status = purple_savedstatus_find_transient_by_type_and_message(primitive, NULL); | |
| 403 | if (saved_status == NULL) | |
| 404 | saved_status = create_transient_status(primitive, NULL); | |
| 405 | purple_savedstatus_activate(saved_status); | |
| 406 | } | |
| 407 | ||
| 408 | static void | |
| 409 | alert_config_cb(GtkWidget *widget, gpointer data) | |
| 410 | { | |
| 411 | gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | |
| 412 | purple_prefs_set_bool("/plugins/gtk/unity/alert_chat_nick", on); | |
| 413 | alert_chat_nick = on; | |
| 414 | } | |
| 415 | ||
| 416 | static void | |
| 417 | launcher_config_cb(GtkWidget *widget, gpointer data) | |
| 418 | { | |
| 419 | gint option = GPOINTER_TO_INT(data); | |
| 35124 | 420 | if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) |
| 421 | return; | |
| 35122 | 422 | |
| 423 | purple_prefs_set_int("/plugins/gtk/unity/launcher_count", option); | |
| 424 | launcher_count = option; | |
| 425 | if (option == LAUNCHER_COUNT_DISABLE) | |
| 426 | unity_launcher_entry_set_count_visible(launcher, FALSE); | |
| 427 | else | |
| 428 | update_launcher(); | |
| 429 | } | |
| 430 | ||
| 431 | static void | |
| 432 | messaging_menu_config_cb(GtkWidget *widget, gpointer data) | |
| 433 | { | |
| 434 | gint option = GPOINTER_TO_INT(data); | |
| 35124 | 435 | if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) |
| 436 | return; | |
| 35122 | 437 | |
| 438 | purple_prefs_set_int("/plugins/gtk/unity/messaging_menu_text", option); | |
| 439 | messaging_menu_text = option; | |
| 440 | refill_messaging_menu(); | |
| 441 | } | |
| 442 | ||
| 443 | static int | |
| 444 | attach_signals(PurpleConversation *conv) | |
| 445 | { | |
| 446 | PidginConversation *gtkconv = NULL; | |
| 447 | guint id; | |
| 448 | ||
| 449 | gtkconv = PIDGIN_CONVERSATION(conv); | |
| 450 | if (!gtkconv) | |
| 451 | return 0; | |
| 452 | ||
| 453 | id = g_signal_connect(G_OBJECT(gtkconv->entry), "focus-in-event", | |
| 35123 | 454 | G_CALLBACK(unalert_cb), conv); |
| 455 | g_object_set_data(G_OBJECT(conv), "unity-entry-signal", GUINT_TO_POINTER(id)); | |
| 35122 | 456 | |
|
40947
4169f8090a0e
Make the unity plugin compile again and add stuff to ci ubuntu builds
Gary Kramlich <grim@reaperworld.com>
parents:
40894
diff
changeset
|
457 | id = g_signal_connect(G_OBJECT(gtkconv->history), "focus-in-event", |
| 35123 | 458 | 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
|
459 | g_object_set_data(G_OBJECT(conv), "unity-history-signal", GUINT_TO_POINTER(id)); |
| 35122 | 460 | |
| 461 | return 0; | |
| 462 | } | |
| 463 | ||
| 464 | static void | |
| 465 | detach_signals(PurpleConversation *conv) | |
| 466 | { | |
| 467 | PidginConversation *gtkconv = NULL; | |
| 468 | guint id; | |
| 469 | gtkconv = PIDGIN_CONVERSATION(conv); | |
| 470 | if (!gtkconv) | |
| 471 | return; | |
| 472 | ||
|
40947
4169f8090a0e
Make the unity plugin compile again and add stuff to ci ubuntu builds
Gary Kramlich <grim@reaperworld.com>
parents:
40894
diff
changeset
|
473 | 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
|
474 | g_signal_handler_disconnect(gtkconv->history, id); |
| 35122 | 475 | |
| 35123 | 476 | id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), "unity-entry-signal")); |
| 35122 | 477 | g_signal_handler_disconnect(gtkconv->entry, id); |
| 478 | ||
| 35123 | 479 | g_object_set_data(G_OBJECT(conv), "unity-message-count", |
| 480 | GINT_TO_POINTER(0)); | |
| 35122 | 481 | } |
| 482 | ||
| 483 | static GtkWidget * | |
| 484 | get_config_frame(PurplePlugin *plugin) | |
| 485 | { | |
| 486 | GtkWidget *ret = NULL, *frame = NULL; | |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
487 | GtkWidget *vbox = NULL, *toggle = NULL, *group = NULL; |
| 35122 | 488 | |
|
35534
8e72593def2c
Fix gtk_[hv]box_new gtk3 deprecation warnings in unity plugin
Ankit Vani <a@nevitus.org>
parents:
35378
diff
changeset
|
489 | ret = gtk_box_new(GTK_ORIENTATION_VERTICAL, 18); |
| 35122 | 490 | |
| 491 | /* Alerts */ | |
| 492 | ||
| 493 | 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
|
494 | vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
495 | gtk_box_append(GTK_BOX(frame), vbox); |
| 35122 | 496 | |
| 497 | toggle = gtk_check_button_new_with_mnemonic(_("Chatroom message alerts _only where someone says your username")); | |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
498 | gtk_box_append(GTK_BOX(vbox), toggle); |
|
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
499 | gtk_check_button_set_active(GTK_CHECK_BUTTON(toggle), |
| 35123 | 500 | purple_prefs_get_bool("/plugins/gtk/unity/alert_chat_nick")); |
| 35122 | 501 | g_signal_connect(G_OBJECT(toggle), "toggled", |
| 35123 | 502 | G_CALLBACK(alert_config_cb), NULL); |
| 35122 | 503 | |
| 504 | /* Launcher integration */ | |
| 505 | ||
| 506 | 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
|
507 | vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
508 | gtk_box_append(GTK_BOX(frame), vbox); |
| 35122 | 509 | |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
510 | toggle = gtk_check_button_new_with_mnemonic(_("_Disable launcher integration")); |
|
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
511 | group = toggle; |
|
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
512 | gtk_box_append(GTK_BOX(vbox), toggle); |
|
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
513 | gtk_check_button_set_active(GTK_CHECK_BUTTON(toggle), |
| 35122 | 514 | purple_prefs_get_int("/plugins/gtk/unity/launcher_count") == LAUNCHER_COUNT_DISABLE); |
| 515 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 35123 | 516 | G_CALLBACK(launcher_config_cb), GUINT_TO_POINTER(LAUNCHER_COUNT_DISABLE)); |
| 35122 | 517 | |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
518 | toggle = gtk_check_button_new_with_mnemonic( |
| 35123 | 519 | _("Show number of unread _messages on launcher icon")); |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
520 | gtk_check_button_set_group(GTK_CHECK_BUTTON(toggle), |
|
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
521 | GTK_CHECK_BUTTON(group)); |
|
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
522 | gtk_box_append(GTK_BOX(vbox), toggle); |
|
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
523 | gtk_check_button_set_active(GTK_CHECK_BUTTON(toggle), |
| 35122 | 524 | purple_prefs_get_int("/plugins/gtk/unity/launcher_count") == LAUNCHER_COUNT_MESSAGES); |
| 525 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 35123 | 526 | G_CALLBACK(launcher_config_cb), GUINT_TO_POINTER(LAUNCHER_COUNT_MESSAGES)); |
| 35122 | 527 | |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
528 | toggle = gtk_check_button_new_with_mnemonic( |
|
35317
3c9c77b80a6c
Merge the release-2.x.y branch into default.
Mark Doliner <mark@kingant.net>
diff
changeset
|
529 | _("Show number of unread co_nversations on launcher icon")); |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
530 | gtk_check_button_set_group(GTK_CHECK_BUTTON(toggle), |
|
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
531 | GTK_CHECK_BUTTON(group)); |
|
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
532 | gtk_box_append(GTK_BOX(vbox), toggle); |
|
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
533 | gtk_check_button_set_active(GTK_CHECK_BUTTON(toggle), |
| 35122 | 534 | purple_prefs_get_int("/plugins/gtk/unity/launcher_count") == LAUNCHER_COUNT_SOURCES); |
| 535 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 35123 | 536 | G_CALLBACK(launcher_config_cb), GUINT_TO_POINTER(LAUNCHER_COUNT_SOURCES)); |
| 35122 | 537 | |
| 538 | /* Messaging menu integration */ | |
| 539 | ||
| 540 | 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
|
541 | vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
542 | gtk_box_append(GTK_BOX(frame), vbox); |
| 35122 | 543 | |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
544 | toggle = gtk_check_button_new_with_mnemonic( |
| 35123 | 545 | _("Show number of _unread messages for conversations in messaging menu")); |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
546 | group = toggle; |
|
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
547 | gtk_box_append(GTK_BOX(vbox), toggle); |
|
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
548 | gtk_check_button_set_active(GTK_CHECK_BUTTON(toggle), |
| 35122 | 549 | purple_prefs_get_int("/plugins/gtk/unity/messaging_menu_text") == MESSAGING_MENU_COUNT); |
| 550 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 35123 | 551 | G_CALLBACK(messaging_menu_config_cb), GUINT_TO_POINTER(MESSAGING_MENU_COUNT)); |
| 35122 | 552 | |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
553 | toggle = gtk_check_button_new_with_mnemonic( |
| 35123 | 554 | _("Show _elapsed time for unread conversations in messaging menu")); |
|
41580
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
555 | gtk_check_button_set_group(GTK_CHECK_BUTTON(toggle), |
|
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
556 | GTK_CHECK_BUTTON(group)); |
|
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
557 | gtk_box_append(GTK_BOX(vbox), toggle); |
|
787ca853b6c4
Port the unity plugin to gtk4
Gary Kramlich <grim@reaperworld.com>
parents:
41454
diff
changeset
|
558 | gtk_check_button_set_active(GTK_CHECK_BUTTON(toggle), |
| 35122 | 559 | purple_prefs_get_int("/plugins/gtk/unity/messaging_menu_text") == MESSAGING_MENU_TIME); |
| 560 | g_signal_connect(G_OBJECT(toggle), "toggled", | |
| 35123 | 561 | G_CALLBACK(messaging_menu_config_cb), GUINT_TO_POINTER(MESSAGING_MENU_TIME)); |
| 35122 | 562 | |
| 563 | return ret; | |
| 564 | } | |
| 565 | ||
|
40894
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
566 | static GPluginPluginInfo * |
|
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
567 | unity_query(GError **error) |
|
36969
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
568 | { |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
569 | const gchar * const authors[] = { |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
570 | "Ankit Vani <a@nevitus.org>", |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
571 | NULL |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
572 | }; |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
573 | |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
574 | return pidgin_plugin_info_new( |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
575 | "id", UNITY_PLUGIN_ID, |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
576 | "name", N_("Unity Integration"), |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
577 | "version", DISPLAY_VERSION, |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
578 | "category", N_("Notification"), |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
579 | "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
|
580 | "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
|
581 | "messaging menu and launcher."), |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
582 | "authors", authors, |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
583 | "website", PURPLE_WEBSITE, |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
584 | "abi-version", PURPLE_ABI_VERSION, |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
585 | "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
|
586 | NULL |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
587 | ); |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
588 | } |
|
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
589 | |
| 35122 | 590 | static gboolean |
|
40894
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
591 | 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
|
592 | GList *convs = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
593 | PurpleConversationManager *manager = NULL; |
| 35122 | 594 | PurpleSavedStatus *saved_status; |
| 595 | void *conv_handle = purple_conversations_get_handle(); | |
| 596 | void *gtk_conv_handle = pidgin_conversations_get_handle(); | |
| 597 | void *savedstat_handle = purple_savedstatuses_get_handle(); | |
| 598 | ||
|
36969
c78437610c6d
Refactored unity plugin to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
35125
diff
changeset
|
599 | 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
|
600 | 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
|
601 | 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
|
602 | 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
|
603 | 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
|
604 | |
| 35122 | 605 | alert_chat_nick = purple_prefs_get_bool("/plugins/gtk/unity/alert_chat_nick"); |
| 606 | ||
| 607 | mmapp = messaging_menu_app_new("pidgin.desktop"); | |
| 608 | g_object_ref(mmapp); | |
| 609 | messaging_menu_app_register(mmapp); | |
| 610 | messaging_menu_text = purple_prefs_get_int("/plugins/gtk/unity/messaging_menu_text"); | |
| 611 | ||
| 612 | g_signal_connect(mmapp, "activate-source", | |
| 35123 | 613 | G_CALLBACK(message_source_activated), NULL); |
| 35122 | 614 | g_signal_connect(mmapp, "status-changed", |
| 35123 | 615 | G_CALLBACK(messaging_menu_status_changed), NULL); |
| 35122 | 616 | |
| 617 | saved_status = purple_savedstatus_get_current(); | |
| 618 | status_changed_cb(saved_status); | |
| 619 | ||
| 620 | 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
|
621 | G_CALLBACK(status_changed_cb), NULL); |
| 35122 | 622 | |
| 623 | launcher = unity_launcher_entry_get_for_desktop_id("pidgin.desktop"); | |
| 624 | g_object_ref(launcher); | |
| 625 | launcher_count = purple_prefs_get_int("/plugins/gtk/unity/launcher_count"); | |
| 626 | ||
| 627 | 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
|
628 | G_CALLBACK(message_displayed_cb), NULL); |
| 35122 | 629 | 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
|
630 | G_CALLBACK(message_displayed_cb), NULL); |
| 35122 | 631 | 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
|
632 | G_CALLBACK(im_sent_im), NULL); |
| 35122 | 633 | 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
|
634 | G_CALLBACK(chat_sent_im), NULL); |
| 35122 | 635 | 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
|
636 | G_CALLBACK(conv_created), NULL); |
| 35122 | 637 | 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
|
638 | G_CALLBACK(deleting_conv), NULL); |
| 35122 | 639 | |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
640 | manager = purple_conversation_manager_get_default(); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
641 | 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
|
642 | while(convs != NULL) { |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
643 | PurpleConversation *conv = PURPLE_CONVERSATION(convs->data); |
| 35122 | 644 | attach_signals(conv); |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
645 | convs = g_list_delete_link(convs, convs); |
| 35122 | 646 | } |
| 647 | ||
| 648 | return TRUE; | |
| 649 | } | |
| 650 | ||
| 651 | 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
|
652 | 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
|
653 | GList *convs = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
654 | PurpleConversationManager *manager = NULL; |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
655 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
656 | manager = purple_conversation_manager_get_default(); |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
657 | 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
|
658 | |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
659 | while(convs != NULL) { |
|
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
660 | PurpleConversation *conv = PURPLE_CONVERSATION(convs->data); |
| 35122 | 661 | unalert(conv); |
| 662 | detach_signals(conv); | |
|
41002
717c8a3f95a3
Update the unity plugin for the PurpleConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents:
40947
diff
changeset
|
663 | convs = g_list_delete_link(convs, convs); |
| 35122 | 664 | } |
|
40894
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
665 | |
| 35122 | 666 | unity_launcher_entry_set_count_visible(launcher, FALSE); |
| 667 | messaging_menu_app_unregister(mmapp); | |
| 668 | ||
| 669 | g_object_unref(launcher); | |
| 670 | g_object_unref(mmapp); | |
| 671 | return TRUE; | |
| 672 | } | |
| 673 | ||
|
40894
80d9d7a73a60
Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents:
40502
diff
changeset
|
674 | GPLUGIN_NATIVE_PLUGIN_DECLARE(unity) |