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