pidgin/plugins/unity/unity.c

Fri, 16 Sep 2022 01:54:11 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Fri, 16 Sep 2022 01:54:11 -0500
changeset 41694
83e6692c76a3
parent 41665
149e5ba1e807
child 41696
35f8ce475b21
permissions
-rw-r--r--

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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
1 /*
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
2 * Integration with Unity's messaging menu and launcher
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
3 * Copyright (C) 2013 Ankit Vani <a@nevitus.org>
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
4 *
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
7 * the Free Software Foundation; either version 2 of the License, or
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
8 * (at your option) any later version.
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
9 *
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
13 * GNU General Public License for more details.
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
14 *
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
16 * along with this program; if not, write to the Free Software
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
28 #include <unity.h>
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
29 #include <messaging-menu.h>
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
30
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
31 #define UNITY_PLUGIN_ID "gtk-unity-integration"
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
32
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
33 static MessagingMenuApp *mmapp = NULL;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
34 static UnityLauncherEntry *launcher = NULL;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
35 static guint n_sources = 0;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
36 static gint launcher_count;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
37 static gint messaging_menu_text;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
38 static gboolean alert_chat_nick = TRUE;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
39
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
40 enum {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
41 LAUNCHER_COUNT_DISABLE,
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
42 LAUNCHER_COUNT_MESSAGES,
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
43 LAUNCHER_COUNT_SOURCES,
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
44 };
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
45
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
46 enum {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
47 MESSAGING_MENU_COUNT,
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
48 MESSAGING_MENU_TIME,
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
49 };
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
50
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
51 static int attach_signals(PurpleConversation *conv);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
52 static void detach_signals(PurpleConversation *conv);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
53
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
54 static void
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
55 update_launcher()
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
56 {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
57 guint count = 0;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
58 GList *convs = NULL;
35124
7ea89f3b3b58 Silence some warnings
Ankit Vani <a@nevitus.org>
parents: 35122
diff changeset
59 g_return_if_fail(launcher != NULL);
7ea89f3b3b58 Silence some warnings
Ankit Vani <a@nevitus.org>
parents: 35122
diff changeset
60 if (launcher_count == LAUNCHER_COUNT_DISABLE)
7ea89f3b3b58 Silence some warnings
Ankit Vani <a@nevitus.org>
parents: 35122
diff changeset
61 return;
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
62
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
70 PurpleConversation *conv = convs->data;
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
71 count += GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv),
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
74 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
75 } else {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
76 count = n_sources;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
77 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
78
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
79 if (launcher != NULL) {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
80 if (count > 0)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
81 unity_launcher_entry_set_count_visible(launcher, TRUE);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
82 else
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
83 unity_launcher_entry_set_count_visible(launcher, FALSE);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
84 unity_launcher_entry_set_count(launcher, count);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
85 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
86 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
87
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
88 static gchar *
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
89 conversation_id(PurpleConversation *conv)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
90 {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
91 PurpleAccount *account = purple_conversation_get_account(conv);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
92
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
93 return g_strconcat((PURPLE_IS_IM_CONVERSATION(conv) ? "im" :
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
94 PURPLE_IS_CHAT_CONVERSATION(conv) ? "chat" : "misc"), ":",
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
95 purple_conversation_get_name(conv), ":",
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
96 purple_account_get_username(account), ":",
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
97 purple_account_get_protocol_id(account), NULL);
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
98 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
99
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
100 static void
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
101 messaging_menu_add_conversation(PurpleConversation *conv, gint count)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
102 {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
103 gchar *id;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
104 g_return_if_fail(count > 0);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
105 id = conversation_id(conv);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
106
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
107 /* GBytesIcon may be useful for messaging menu source icons using buddy
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
108 icon data for IMs */
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
109 if (!messaging_menu_app_has_source(mmapp, id))
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
110 messaging_menu_app_append_source(mmapp, id, NULL,
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
111 purple_conversation_get_title(conv));
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
112
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
113 if (messaging_menu_text == MESSAGING_MENU_TIME)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
114 messaging_menu_app_set_source_time(mmapp, id, g_get_real_time());
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
115 else if (messaging_menu_text == MESSAGING_MENU_COUNT)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
116 messaging_menu_app_set_source_count(mmapp, id, count);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
117 messaging_menu_app_draw_attention(mmapp, id);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
118
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
119 g_free(id);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
120 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
121
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
122 static void
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
123 messaging_menu_remove_conversation(PurpleConversation *conv)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
124 {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
125 gchar *id = conversation_id(conv);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
126 if (messaging_menu_app_has_source(mmapp, id))
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
127 messaging_menu_app_remove_source(mmapp, id);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
128 g_free(id);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
129 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
130
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
131 static void
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
132 refill_messaging_menu()
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
135 GList *convs;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
140 PurpleConversation *conv = convs->data;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
141 messaging_menu_add_conversation(conv,
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
142 GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv),
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
145 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
146 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
147
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
148 static int
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
149 alert(PurpleConversation *conv)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
150 {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
157 if (conv == NULL || PIDGIN_CONVERSATION(conv) == NULL)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
158 return 0;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
167 {
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
168 count = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv),
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
169 "unity-message-count"));
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
170 if (!count++)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
171 ++n_sources;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
172
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
173 g_object_set_data(G_OBJECT(conv), "unity-message-count",
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
174 GINT_TO_POINTER(count));
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
175 messaging_menu_add_conversation(conv, count);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
176 update_launcher();
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
177 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
178
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
179 return 0;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
180 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
181
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
182 static void
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
183 unalert(PurpleConversation *conv)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
184 {
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
185 if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), "unity-message-count")) > 0)
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
186 --n_sources;
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
187
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
188 g_object_set_data(G_OBJECT(conv), "unity-message-count",
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
189 GINT_TO_POINTER(0));
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
190 messaging_menu_remove_conversation(conv);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
191 update_launcher();
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
192 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
193
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
194 static int
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
195 unalert_cb(GtkWidget *widget, gpointer data, PurpleConversation *conv)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
196 {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
197 unalert(conv);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
198 return 0;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
199 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
200
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
206 if ((PURPLE_IS_CHAT_CONVERSATION(conv) && alert_chat_nick &&
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
207 !(flags & PURPLE_MESSAGE_NICK)))
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
208 return FALSE;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
209
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
210 if ((flags & PURPLE_MESSAGE_RECV) && !(flags & PURPLE_MESSAGE_DELAYED))
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
211 alert(conv);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
212
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
213 return FALSE;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
214 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
215
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
228 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
229
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
241 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
242
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
243 static void
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
244 conv_created(PurpleConversation *conv)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
245 {
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
246 g_object_set_data(G_OBJECT(conv), "unity-message-count",
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
247 GINT_TO_POINTER(0));
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
248 attach_signals(conv);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
249 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
250
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
251 static void
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
252 deleting_conv(PurpleConversation *conv)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
253 {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
254 detach_signals(conv);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
255 unalert(conv);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
256 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
257
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
258 static void
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
259 message_source_activated(MessagingMenuApp *app, const gchar *id,
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
260 gpointer user_data)
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
261 {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
262 gchar **sections = g_strsplit(id, ":", 0);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
267
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
268 char *type = sections[0];
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
269 char *cname = sections[1];
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
270 char *aname = sections[2];
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
271 char *protocol = sections[3];
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
288
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
303 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
304 g_strfreev (sections);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
305 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
306
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
310 {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
311 PurpleSavedStatus *saved_status = purple_savedstatus_new(NULL, primitive);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
312
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
327 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
328 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
329
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
330 return saved_status;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
331 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
332
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
333 static void
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
334 status_changed_cb(PurpleSavedStatus *saved_status)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
335 {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
336 MessagingMenuStatus status = MESSAGING_MENU_STATUS_AVAILABLE;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
339 case PURPLE_STATUS_AVAILABLE:
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
340 case PURPLE_STATUS_MOOD:
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
341 case PURPLE_STATUS_TUNE:
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
342 case PURPLE_STATUS_UNSET:
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
343 status = MESSAGING_MENU_STATUS_AVAILABLE;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
344 break;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
345
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
346 case PURPLE_STATUS_AWAY:
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
347 case PURPLE_STATUS_EXTENDED_AWAY:
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
348 status = MESSAGING_MENU_STATUS_AWAY;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
349 break;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
350
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
351 case PURPLE_STATUS_INVISIBLE:
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
352 status = MESSAGING_MENU_STATUS_INVISIBLE;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
353 break;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
354
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
355 case PURPLE_STATUS_MOBILE:
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
356 case PURPLE_STATUS_OFFLINE:
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
357 status = MESSAGING_MENU_STATUS_OFFLINE;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
358 break;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
359
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
360 case PURPLE_STATUS_UNAVAILABLE:
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
361 status = MESSAGING_MENU_STATUS_BUSY;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
362 break;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
363
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
364 default:
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
365 g_assert_not_reached();
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
366 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
367 messaging_menu_app_set_status(mmapp, status);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
368 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
369
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
370 static void
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
371 messaging_menu_status_changed(MessagingMenuApp *mmapp,
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
372 MessagingMenuStatus mm_status, gpointer user_data)
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
373 {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
374 PurpleSavedStatus *saved_status;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
375 PurpleStatusPrimitive primitive = PURPLE_STATUS_UNSET;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
376
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
377 switch (mm_status) {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
378 case MESSAGING_MENU_STATUS_AVAILABLE:
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
379 primitive = PURPLE_STATUS_AVAILABLE;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
380 break;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
381
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
382 case MESSAGING_MENU_STATUS_AWAY:
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
383 primitive = PURPLE_STATUS_AWAY;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
384 break;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
385
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
386 case MESSAGING_MENU_STATUS_BUSY:
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
387 primitive = PURPLE_STATUS_UNAVAILABLE;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
388 break;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
389
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
390 case MESSAGING_MENU_STATUS_INVISIBLE:
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
391 primitive = PURPLE_STATUS_INVISIBLE;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
392 break;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
393
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
394 case MESSAGING_MENU_STATUS_OFFLINE:
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
395 primitive = PURPLE_STATUS_OFFLINE;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
396 break;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
397
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
398 default:
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
399 g_assert_not_reached();
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
400 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
401
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
402 saved_status = purple_savedstatus_find_transient_by_type_and_message(primitive, NULL);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
403 if (saved_status == NULL)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
404 saved_status = create_transient_status(primitive, NULL);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
405 purple_savedstatus_activate(saved_status);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
406 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
407
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
408 static void
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
409 alert_config_cb(GtkWidget *widget, gpointer data)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
410 {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
411 gboolean on = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
412 purple_prefs_set_bool("/plugins/gtk/unity/alert_chat_nick", on);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
413 alert_chat_nick = on;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
414 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
415
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
416 static void
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
417 launcher_config_cb(GtkWidget *widget, gpointer data)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
418 {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
419 gint option = GPOINTER_TO_INT(data);
35124
7ea89f3b3b58 Silence some warnings
Ankit Vani <a@nevitus.org>
parents: 35122
diff changeset
420 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
7ea89f3b3b58 Silence some warnings
Ankit Vani <a@nevitus.org>
parents: 35122
diff changeset
421 return;
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
422
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
423 purple_prefs_set_int("/plugins/gtk/unity/launcher_count", option);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
424 launcher_count = option;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
425 if (option == LAUNCHER_COUNT_DISABLE)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
426 unity_launcher_entry_set_count_visible(launcher, FALSE);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
427 else
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
428 update_launcher();
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
429 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
430
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
431 static void
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
432 messaging_menu_config_cb(GtkWidget *widget, gpointer data)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
433 {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
434 gint option = GPOINTER_TO_INT(data);
35124
7ea89f3b3b58 Silence some warnings
Ankit Vani <a@nevitus.org>
parents: 35122
diff changeset
435 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)))
7ea89f3b3b58 Silence some warnings
Ankit Vani <a@nevitus.org>
parents: 35122
diff changeset
436 return;
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
437
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
438 purple_prefs_set_int("/plugins/gtk/unity/messaging_menu_text", option);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
439 messaging_menu_text = option;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
440 refill_messaging_menu();
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
441 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
442
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
443 static int
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
444 attach_signals(PurpleConversation *conv)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
445 {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
446 PidginConversation *gtkconv = NULL;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
447 guint id;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
448
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
449 gtkconv = PIDGIN_CONVERSATION(conv);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
450 if (!gtkconv)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
451 return 0;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
452
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
453 id = g_signal_connect(G_OBJECT(gtkconv->entry), "focus-in-event",
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
454 G_CALLBACK(unalert_cb), conv);
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
455 g_object_set_data(G_OBJECT(conv), "unity-entry-signal", GUINT_TO_POINTER(id));
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
460
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
461 return 0;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
462 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
463
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
464 static void
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
465 detach_signals(PurpleConversation *conv)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
466 {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
467 PidginConversation *gtkconv = NULL;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
468 guint id;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
469 gtkconv = PIDGIN_CONVERSATION(conv);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
470 if (!gtkconv)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
471 return;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
475
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
476 id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(conv), "unity-entry-signal"));
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
477 g_signal_handler_disconnect(gtkconv->entry, id);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
478
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
479 g_object_set_data(G_OBJECT(conv), "unity-message-count",
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
480 GINT_TO_POINTER(0));
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
481 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
482
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
483 static GtkWidget *
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
484 get_config_frame(PurplePlugin *plugin)
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
485 {
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
490
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
491 /* Alerts */
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
492
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
496
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
500 purple_prefs_get_bool("/plugins/gtk/unity/alert_chat_nick"));
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
501 g_signal_connect(G_OBJECT(toggle), "toggled",
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
502 G_CALLBACK(alert_config_cb), NULL);
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
503
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
504 /* Launcher integration */
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
505
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
514 purple_prefs_get_int("/plugins/gtk/unity/launcher_count") == LAUNCHER_COUNT_DISABLE);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
515 g_signal_connect(G_OBJECT(toggle), "toggled",
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
516 G_CALLBACK(launcher_config_cb), GUINT_TO_POINTER(LAUNCHER_COUNT_DISABLE));
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
524 purple_prefs_get_int("/plugins/gtk/unity/launcher_count") == LAUNCHER_COUNT_MESSAGES);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
525 g_signal_connect(G_OBJECT(toggle), "toggled",
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
526 G_CALLBACK(launcher_config_cb), GUINT_TO_POINTER(LAUNCHER_COUNT_MESSAGES));
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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>
parents: 35136 35186
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
534 purple_prefs_get_int("/plugins/gtk/unity/launcher_count") == LAUNCHER_COUNT_SOURCES);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
535 g_signal_connect(G_OBJECT(toggle), "toggled",
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
536 G_CALLBACK(launcher_config_cb), GUINT_TO_POINTER(LAUNCHER_COUNT_SOURCES));
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
537
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
538 /* Messaging menu integration */
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
539
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
549 purple_prefs_get_int("/plugins/gtk/unity/messaging_menu_text") == MESSAGING_MENU_COUNT);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
550 g_signal_connect(G_OBJECT(toggle), "toggled",
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
551 G_CALLBACK(messaging_menu_config_cb), GUINT_TO_POINTER(MESSAGING_MENU_COUNT));
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
559 purple_prefs_get_int("/plugins/gtk/unity/messaging_menu_text") == MESSAGING_MENU_TIME);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
560 g_signal_connect(G_OBJECT(toggle), "toggled",
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
561 G_CALLBACK(messaging_menu_config_cb), GUINT_TO_POINTER(MESSAGING_MENU_TIME));
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
562
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
563 return ret;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
564 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
594 PurpleSavedStatus *saved_status;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
595 void *conv_handle = purple_conversations_get_handle();
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
596 void *gtk_conv_handle = pidgin_conversations_get_handle();
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
597 void *savedstat_handle = purple_savedstatuses_get_handle();
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
605 alert_chat_nick = purple_prefs_get_bool("/plugins/gtk/unity/alert_chat_nick");
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
606
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
607 mmapp = messaging_menu_app_new("pidgin.desktop");
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
608 g_object_ref(mmapp);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
609 messaging_menu_app_register(mmapp);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
610 messaging_menu_text = purple_prefs_get_int("/plugins/gtk/unity/messaging_menu_text");
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
611
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
612 g_signal_connect(mmapp, "activate-source",
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
613 G_CALLBACK(message_source_activated), NULL);
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
614 g_signal_connect(mmapp, "status-changed",
35123
3d1148d9cb71 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
615 G_CALLBACK(messaging_menu_status_changed), NULL);
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
616
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
617 saved_status = purple_savedstatus_get_current();
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
618 status_changed_cb(saved_status);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
619
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
622
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
623 launcher = unity_launcher_entry_get_for_desktop_id("pidgin.desktop");
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
624 g_object_ref(launcher);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
625 launcher_count = purple_prefs_get_int("/plugins/gtk/unity/launcher_count");
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
626
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
646 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
647
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
648 return TRUE;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
649 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
650
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
661 unalert(conv);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
664 }
40894
80d9d7a73a60 Convert the Pidgin plugins to use GPLUGIN_NATIVE_PLUGIN_DECLARE
Gary Kramlich <grim@reaperworld.com>
parents: 40502
diff changeset
665
35122
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
666 unity_launcher_entry_set_count_visible(launcher, FALSE);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
667 messaging_menu_app_unregister(mmapp);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
668
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
669 g_object_unref(launcher);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
670 g_object_unref(mmapp);
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
671 return TRUE;
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
672 }
30af0986aa62 Added the Unity integration plugin
Ankit Vani <a@nevitus.org>
parents:
diff changeset
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)

mercurial