Fri, 12 Oct 2007 11:18:58 +0000
Patch from QuLogic to not use underscores in saved-statuses as mnemonics
in the docklet's context menu. Fixes #2510, closes #3495.
| 14743 | 1 | /* |
| 15884 | 2 | * System tray icon (aka docklet) plugin for Purple |
| 14743 | 3 | * |
| 4 | * Copyright (C) 2002-3 Robert McQueen <robot101@debian.org> | |
| 5 | * Copyright (C) 2003 Herman Bloggs <hermanator12002@yahoo.com> | |
| 6 | * Inspired by a similar plugin by: | |
| 7 | * John (J5) Palmieri <johnp@martianrock.com> | |
| 8 | * | |
| 9 | * This program is free software; you can redistribute it and/or | |
| 10 | * modify it under the terms of the GNU General Public License as | |
| 11 | * published by the Free Software Foundation; either version 2 of the | |
| 12 | * License, or (at your option) any later version. | |
| 13 | * | |
| 14 | * This program is distributed in the hope that it will be useful, but | |
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 17 | * General Public License for more details. | |
| 18 | * | |
| 19 | * You should have received a copy of the GNU General Public License | |
| 20 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19215
diff
changeset
|
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19215
diff
changeset
|
22 | * 02111-1301, USA. |
| 14743 | 23 | */ |
| 24 | #include "internal.h" | |
| 15577 | 25 | #include "pidgin.h" |
| 14743 | 26 | |
| 27 | #include "core.h" | |
| 28 | #include "conversation.h" | |
| 29 | #include "debug.h" | |
| 30 | #include "prefs.h" | |
| 31 | #include "signals.h" | |
| 32 | #include "sound.h" | |
| 33 | ||
| 34 | #include "gtkaccount.h" | |
| 35 | #include "gtkblist.h" | |
| 36 | #include "gtkconv.h" | |
| 37 | #include "gtkplugin.h" | |
| 38 | #include "gtkprefs.h" | |
| 39 | #include "gtksavedstatuses.h" | |
| 40 | #include "gtksound.h" | |
| 41 | #include "gtkutils.h" | |
|
15883
969b74a3e27a
According to etags, pidgin/ should be completely clean of references to 'gaim' as a client
Sean Egan <seanegan@pidgin.im>
parents:
15882
diff
changeset
|
42 | #include "pidginstock.h" |
| 14743 | 43 | #include "gtkdocklet.h" |
| 44 | #include "gtkdialogs.h" | |
| 45 | ||
| 46 | #ifndef DOCKLET_TOOLTIP_LINE_LIMIT | |
| 47 | #define DOCKLET_TOOLTIP_LINE_LIMIT 5 | |
| 48 | #endif | |
| 49 | ||
| 50 | /* globals */ | |
| 51 | static struct docklet_ui_ops *ui_ops = NULL; | |
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
52 | static PurpleStatusPrimitive status = PURPLE_STATUS_OFFLINE; |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
53 | static gboolean pending = FALSE; |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
54 | static gboolean connecting = FALSE; |
| 14743 | 55 | static gboolean enable_join_chat = FALSE; |
| 56 | static guint docklet_blinking_timer = 0; | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
57 | static gboolean visible = FALSE; |
| 14743 | 58 | static gboolean visibility_manager = FALSE; |
| 59 | ||
| 60 | /************************************************************************** | |
| 61 | * docklet status and utility functions | |
| 62 | **************************************************************************/ | |
| 63 | static gboolean | |
| 64 | docklet_blink_icon() | |
| 65 | { | |
| 66 | static gboolean blinked = FALSE; | |
| 67 | gboolean ret = FALSE; /* by default, don't keep blinking */ | |
| 68 | ||
| 69 | blinked = !blinked; | |
| 70 | ||
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
71 | if(pending && !connecting) { |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
72 | if (blinked) { |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
73 | if (ui_ops && ui_ops->blank_icon) |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
74 | ui_ops->blank_icon(); |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
75 | } else { |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
76 | pidgin_docklet_update_icon(); |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
77 | } |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
78 | ret = TRUE; /* keep blinking */ |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
79 | } else { |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
80 | docklet_blinking_timer = 0; |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
81 | blinked = FALSE; |
| 14743 | 82 | } |
| 83 | ||
| 84 | return ret; | |
| 85 | } | |
| 86 | ||
| 87 | static GList * | |
| 88 | get_pending_list(guint max) | |
| 89 | { | |
| 90 | GList *l_im = NULL; | |
| 91 | GList *l_chat = NULL; | |
| 92 | ||
| 15884 | 93 | l_im = pidgin_conversations_find_unseen_list(PURPLE_CONV_TYPE_IM, |
|
15566
ce486027d329
GAIM_UNSEEN to PIDGIN_UNSEEN
Sean Egan <seanegan@pidgin.im>
parents:
15563
diff
changeset
|
94 | PIDGIN_UNSEEN_TEXT, |
|
14813
c24dda7fb69e
[gaim-migrate @ 17508]
Casey Harkins <charkins@pidgin.im>
parents:
14745
diff
changeset
|
95 | FALSE, max); |
| 14743 | 96 | |
| 15884 | 97 | l_chat = pidgin_conversations_find_unseen_list(PURPLE_CONV_TYPE_CHAT, |
|
15566
ce486027d329
GAIM_UNSEEN to PIDGIN_UNSEEN
Sean Egan <seanegan@pidgin.im>
parents:
15563
diff
changeset
|
98 | PIDGIN_UNSEEN_NICK, |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
99 | FALSE, max); |
| 14743 | 100 | |
| 101 | if (l_im != NULL && l_chat != NULL) | |
| 102 | return g_list_concat(l_im, l_chat); | |
| 103 | else if (l_im != NULL) | |
| 104 | return l_im; | |
| 105 | else | |
| 106 | return l_chat; | |
| 107 | } | |
| 108 | ||
| 109 | static gboolean | |
| 110 | docklet_update_status() | |
| 111 | { | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
112 | GList *convs, *l; |
| 14743 | 113 | int count; |
| 15884 | 114 | PurpleSavedStatus *saved_status; |
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
115 | PurpleStatusPrimitive newstatus = PURPLE_STATUS_OFFLINE; |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
116 | gboolean newpending = FALSE, newconnecting = FALSE; |
| 14743 | 117 | |
|
16681
c15974a4ff5d
Patch from charkins in ticket #198 to fulfill a feature request by hbons:
Richard Laager <rlaager@pidgin.im>
parents:
16263
diff
changeset
|
118 | /* get the current savedstatus */ |
|
c15974a4ff5d
Patch from charkins in ticket #198 to fulfill a feature request by hbons:
Richard Laager <rlaager@pidgin.im>
parents:
16263
diff
changeset
|
119 | saved_status = purple_savedstatus_get_current(); |
|
c15974a4ff5d
Patch from charkins in ticket #198 to fulfill a feature request by hbons:
Richard Laager <rlaager@pidgin.im>
parents:
16263
diff
changeset
|
120 | |
| 14743 | 121 | /* determine if any ims have unseen messages */ |
| 122 | convs = get_pending_list(DOCKLET_TOOLTIP_LINE_LIMIT); | |
| 123 | ||
|
19215
7a4ee0715da8
reverting the show docklet preference the correct way
Ka-Hing Cheung <khc@pidgin.im>
parents:
19129
diff
changeset
|
124 | if (!strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/docklet/show"), "pending")) { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
125 | if (convs && ui_ops->create && !visible) { |
|
15075
2bd60dbd8877
[gaim-migrate @ 17794]
Daniel Atallah <datallah@pidgin.im>
parents:
14954
diff
changeset
|
126 | g_list_free(convs); |
|
2bd60dbd8877
[gaim-migrate @ 17794]
Daniel Atallah <datallah@pidgin.im>
parents:
14954
diff
changeset
|
127 | ui_ops->create(); |
|
2bd60dbd8877
[gaim-migrate @ 17794]
Daniel Atallah <datallah@pidgin.im>
parents:
14954
diff
changeset
|
128 | return FALSE; |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
129 | } else if (!convs && ui_ops->destroy && visible) { |
|
15075
2bd60dbd8877
[gaim-migrate @ 17794]
Daniel Atallah <datallah@pidgin.im>
parents:
14954
diff
changeset
|
130 | ui_ops->destroy(); |
|
2bd60dbd8877
[gaim-migrate @ 17794]
Daniel Atallah <datallah@pidgin.im>
parents:
14954
diff
changeset
|
131 | return FALSE; |
| 14935 | 132 | } |
| 133 | } | |
| 134 | ||
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
135 | if (!visible) { |
|
15075
2bd60dbd8877
[gaim-migrate @ 17794]
Daniel Atallah <datallah@pidgin.im>
parents:
14954
diff
changeset
|
136 | g_list_free(convs); |
| 14947 | 137 | return FALSE; |
|
15075
2bd60dbd8877
[gaim-migrate @ 17794]
Daniel Atallah <datallah@pidgin.im>
parents:
14954
diff
changeset
|
138 | } |
| 14947 | 139 | |
| 14743 | 140 | if (convs != NULL) { |
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
141 | newpending = TRUE; |
| 14743 | 142 | |
| 143 | /* set tooltip if messages are pending */ | |
| 144 | if (ui_ops->set_tooltip) { | |
| 145 | GString *tooltip_text = g_string_new(""); | |
| 146 | for (l = convs, count = 0 ; l != NULL ; l = l->next, count++) { | |
|
15692
ecda27df58b9
Some more pidgininfication
Daniel Atallah <datallah@pidgin.im>
parents:
15670
diff
changeset
|
147 | if (PIDGIN_IS_PIDGIN_CONVERSATION(l->data)) { |
| 15884 | 148 | PidginConversation *gtkconv = PIDGIN_CONVERSATION((PurpleConversation *)l->data); |
| 14743 | 149 | if (count == DOCKLET_TOOLTIP_LINE_LIMIT - 1) |
| 150 | g_string_append(tooltip_text, _("Right-click for more unread messages...\n")); | |
| 151 | else | |
| 152 | g_string_append_printf(tooltip_text, | |
| 153 | ngettext("%d unread message from %s\n", "%d unread messages from %s\n", gtkconv->unseen_count), | |
| 154 | gtkconv->unseen_count, | |
| 155 | gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
| 156 | } | |
| 157 | } | |
| 158 | ||
| 159 | /* get rid of the last newline */ | |
| 160 | if (tooltip_text->len > 0) | |
| 161 | tooltip_text = g_string_truncate(tooltip_text, tooltip_text->len - 1); | |
| 162 | ||
| 163 | ui_ops->set_tooltip(tooltip_text->str); | |
| 164 | ||
| 165 | g_string_free(tooltip_text, TRUE); | |
| 166 | } | |
| 167 | ||
| 168 | g_list_free(convs); | |
| 169 | ||
| 170 | } else if (ui_ops->set_tooltip) { | |
|
16977
c9cb49bea66d
Change the PIDGIN_NAME stuff to allow translators to transliterate the
Richard Laager <rlaager@pidgin.im>
parents:
16960
diff
changeset
|
171 | char *tooltip_text = g_strconcat(PIDGIN_NAME, " - ", |
|
16681
c15974a4ff5d
Patch from charkins in ticket #198 to fulfill a feature request by hbons:
Richard Laager <rlaager@pidgin.im>
parents:
16263
diff
changeset
|
172 | purple_savedstatus_get_title(saved_status), NULL); |
|
c15974a4ff5d
Patch from charkins in ticket #198 to fulfill a feature request by hbons:
Richard Laager <rlaager@pidgin.im>
parents:
16263
diff
changeset
|
173 | ui_ops->set_tooltip(tooltip_text); |
|
c15974a4ff5d
Patch from charkins in ticket #198 to fulfill a feature request by hbons:
Richard Laager <rlaager@pidgin.im>
parents:
16263
diff
changeset
|
174 | g_free(tooltip_text); |
| 14743 | 175 | } |
| 176 | ||
| 15884 | 177 | for(l = purple_accounts_get_all(); l != NULL; l = l->next) { |
| 14743 | 178 | |
| 15884 | 179 | PurpleAccount *account = (PurpleAccount*)l->data; |
| 180 | PurpleStatus *account_status; | |
| 14743 | 181 | |
| 15884 | 182 | if (!purple_account_get_enabled(account, PIDGIN_UI)) |
| 14743 | 183 | continue; |
| 184 | ||
| 15884 | 185 | if (purple_account_is_disconnected(account)) |
| 14743 | 186 | continue; |
| 187 | ||
| 15884 | 188 | account_status = purple_account_get_active_status(account); |
| 189 | if (purple_account_is_connecting(account)) | |
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
190 | newconnecting = TRUE; |
| 14743 | 191 | } |
|
15765
f281403e98cf
Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents:
15760
diff
changeset
|
192 | |
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
193 | newstatus = purple_savedstatus_get_type(saved_status); |
|
15765
f281403e98cf
Fix win32 docklet. This is pretty ugly - we'll force GTK+ 2.10 at some point and use GtkStatusIcon to avoid converting the stock images to HICONs directly.
Daniel Atallah <datallah@pidgin.im>
parents:
15760
diff
changeset
|
194 | |
| 14743 | 195 | /* update the icon if we changed status */ |
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
196 | if (status != newstatus || pending!=newpending || connecting!=newconnecting) { |
| 14743 | 197 | status = newstatus; |
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
198 | pending = newpending; |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
199 | connecting = newconnecting; |
| 14743 | 200 | |
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
201 | pidgin_docklet_update_icon(); |
| 14743 | 202 | |
| 203 | /* and schedule the blinker function if messages are pending */ | |
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
204 | if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/docklet/blink") |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
205 | && pending && !connecting && docklet_blinking_timer == 0) { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
206 | docklet_blinking_timer = g_timeout_add(500, docklet_blink_icon, NULL); |
| 14743 | 207 | } |
| 208 | } | |
| 209 | ||
| 210 | return FALSE; /* for when we're called by the glib idle handler */ | |
| 211 | } | |
| 212 | ||
| 213 | static gboolean | |
| 214 | online_account_supports_chat() | |
| 215 | { | |
| 216 | GList *c = NULL; | |
| 15884 | 217 | c = purple_connections_get_all(); |
| 14743 | 218 | |
| 219 | while(c != NULL) { | |
| 15884 | 220 | PurpleConnection *gc = c->data; |
| 221 | PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
| 14743 | 222 | if (prpl_info != NULL && prpl_info->chat_info != NULL) |
| 223 | return TRUE; | |
| 224 | c = c->next; | |
| 225 | } | |
| 226 | ||
| 227 | return FALSE; | |
| 228 | } | |
| 229 | ||
| 230 | /************************************************************************** | |
| 231 | * callbacks and signal handlers | |
| 232 | **************************************************************************/ | |
|
14745
d43256e1e6fd
[gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents:
14743
diff
changeset
|
233 | #if 0 |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
234 | static void |
| 15882 | 235 | pidgin_quit_cb() |
| 14743 | 236 | { |
| 237 | /* TODO: confirm quit while pending */ | |
| 238 | } | |
|
14745
d43256e1e6fd
[gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents:
14743
diff
changeset
|
239 | #endif |
| 14743 | 240 | |
| 241 | static void | |
| 242 | docklet_update_status_cb(void *data) | |
| 243 | { | |
| 244 | docklet_update_status(); | |
| 245 | } | |
| 246 | ||
| 247 | static void | |
| 15884 | 248 | docklet_conv_updated_cb(PurpleConversation *conv, PurpleConvUpdateType type) |
| 14743 | 249 | { |
| 15884 | 250 | if (type == PURPLE_CONV_UPDATE_UNSEEN) |
| 14743 | 251 | docklet_update_status(); |
| 252 | } | |
| 253 | ||
| 254 | static void | |
| 15884 | 255 | docklet_signed_on_cb(PurpleConnection *gc) |
| 14743 | 256 | { |
| 257 | if (!enable_join_chat) { | |
| 15884 | 258 | if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) |
| 14743 | 259 | enable_join_chat = TRUE; |
| 260 | } | |
| 261 | docklet_update_status(); | |
| 262 | } | |
| 263 | ||
| 264 | static void | |
| 15884 | 265 | docklet_signed_off_cb(PurpleConnection *gc) |
| 14743 | 266 | { |
| 267 | if (enable_join_chat) { | |
| 15884 | 268 | if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) |
| 14743 | 269 | enable_join_chat = online_account_supports_chat(); |
| 270 | } | |
| 271 | docklet_update_status(); | |
| 272 | } | |
| 273 | ||
| 14947 | 274 | static void |
| 15884 | 275 | docklet_show_pref_changed_cb(const char *name, PurplePrefType type, |
| 14947 | 276 | gconstpointer value, gpointer data) |
| 277 | { | |
| 278 | const char *val = value; | |
| 279 | if (!strcmp(val, "always")) { | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
280 | if (ui_ops->create) { |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
281 | if (!visible) |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
282 | ui_ops->create(); |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
283 | else if (!visibility_manager) { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
284 | pidgin_blist_visibility_manager_add(); |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
285 | visibility_manager = TRUE; |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
286 | } |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
287 | } |
| 14947 | 288 | } else if (!strcmp(val, "never")) { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
289 | if (visible && ui_ops->destroy) |
| 14947 | 290 | ui_ops->destroy(); |
| 291 | } else { | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
292 | if (visibility_manager) { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
293 | pidgin_blist_visibility_manager_remove(); |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
294 | visibility_manager = FALSE; |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
295 | } |
| 14947 | 296 | docklet_update_status(); |
| 297 | } | |
|
15075
2bd60dbd8877
[gaim-migrate @ 17794]
Daniel Atallah <datallah@pidgin.im>
parents:
14954
diff
changeset
|
298 | |
| 14947 | 299 | } |
| 300 | ||
| 14743 | 301 | /************************************************************************** |
| 302 | * docklet pop-up menu | |
| 303 | **************************************************************************/ | |
| 304 | static void | |
| 305 | docklet_toggle_mute(GtkWidget *toggle, void *data) | |
| 306 | { | |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
307 | purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/sound/mute", GTK_CHECK_MENU_ITEM(toggle)->active); |
| 14743 | 308 | } |
| 309 | ||
| 310 | static void | |
| 14875 | 311 | docklet_toggle_blink(GtkWidget *toggle, void *data) |
| 312 | { | |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
313 | purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/docklet/blink", GTK_CHECK_MENU_ITEM(toggle)->active); |
| 14875 | 314 | } |
| 315 | ||
| 316 | static void | |
| 14743 | 317 | docklet_toggle_blist(GtkWidget *toggle, void *data) |
| 318 | { | |
| 15884 | 319 | purple_blist_set_visible(GTK_CHECK_MENU_ITEM(toggle)->active); |
| 14743 | 320 | } |
| 321 | ||
| 322 | #ifdef _WIN32 | |
| 323 | /* This is a workaround for a bug in windows GTK+. Clicking outside of the | |
| 324 | menu does not get rid of it, so instead we get rid of it as soon as the | |
| 325 | pointer leaves the menu. */ | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
326 | static gboolean |
| 14743 | 327 | hide_docklet_menu(gpointer data) |
| 328 | { | |
| 329 | if (data != NULL) { | |
| 330 | gtk_menu_popdown(GTK_MENU(data)); | |
| 331 | } | |
| 332 | return FALSE; | |
| 333 | } | |
| 334 | ||
| 335 | static gboolean | |
| 336 | docklet_menu_leave_enter(GtkWidget *menu, GdkEventCrossing *event, void *data) | |
| 337 | { | |
| 338 | static guint hide_docklet_timer = 0; | |
| 339 | if (event->type == GDK_LEAVE_NOTIFY && event->detail == GDK_NOTIFY_ANCESTOR) { | |
| 15884 | 340 | purple_debug(PURPLE_DEBUG_INFO, "docklet", "menu leave-notify-event\n"); |
| 14743 | 341 | /* Add some slop so that the menu doesn't annoyingly disappear when mousing around */ |
| 342 | if (hide_docklet_timer == 0) { | |
| 15884 | 343 | hide_docklet_timer = purple_timeout_add(500, |
| 14743 | 344 | hide_docklet_menu, menu); |
| 345 | } | |
| 346 | } else if (event->type == GDK_ENTER_NOTIFY && event->detail == GDK_NOTIFY_ANCESTOR) { | |
| 15884 | 347 | purple_debug(PURPLE_DEBUG_INFO, "docklet", "menu enter-notify-event\n"); |
| 14743 | 348 | if (hide_docklet_timer != 0) { |
| 349 | /* Cancel the hiding if we reenter */ | |
| 350 | ||
| 15884 | 351 | purple_timeout_remove(hide_docklet_timer); |
| 14743 | 352 | hide_docklet_timer = 0; |
| 353 | } | |
| 354 | } | |
| 355 | return FALSE; | |
| 356 | } | |
| 357 | #endif | |
| 358 | ||
| 359 | static void | |
| 360 | show_custom_status_editor_cb(GtkMenuItem *menuitem, gpointer user_data) | |
| 361 | { | |
| 15884 | 362 | PurpleSavedStatus *saved_status; |
| 363 | saved_status = purple_savedstatus_get_current(); | |
|
16179
bdf68342e1ce
sf patch #1622581, from Greg Taeger
Mark Doliner <markdoliner@pidgin.im>
parents:
16129
diff
changeset
|
364 | |
|
bdf68342e1ce
sf patch #1622581, from Greg Taeger
Mark Doliner <markdoliner@pidgin.im>
parents:
16129
diff
changeset
|
365 | if (purple_savedstatus_get_type(saved_status) == PURPLE_STATUS_AVAILABLE) |
|
bdf68342e1ce
sf patch #1622581, from Greg Taeger
Mark Doliner <markdoliner@pidgin.im>
parents:
16129
diff
changeset
|
366 | saved_status = purple_savedstatus_new(NULL, PURPLE_STATUS_AWAY); |
|
bdf68342e1ce
sf patch #1622581, from Greg Taeger
Mark Doliner <markdoliner@pidgin.im>
parents:
16129
diff
changeset
|
367 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
368 | pidgin_status_editor_show(FALSE, |
| 15884 | 369 | purple_savedstatus_is_transient(saved_status) ? saved_status : NULL); |
| 14743 | 370 | } |
| 371 | ||
| 372 | static void | |
| 373 | activate_status_primitive_cb(GtkMenuItem *menuitem, gpointer user_data) | |
| 374 | { | |
| 15884 | 375 | PurpleStatusPrimitive primitive; |
| 376 | PurpleSavedStatus *saved_status; | |
| 14743 | 377 | |
| 378 | primitive = GPOINTER_TO_INT(user_data); | |
| 379 | ||
| 380 | /* Try to lookup an already existing transient saved status */ | |
| 15884 | 381 | saved_status = purple_savedstatus_find_transient_by_type_and_message(primitive, NULL); |
| 14743 | 382 | |
| 383 | /* Create a new transient saved status if we weren't able to find one */ | |
| 384 | if (saved_status == NULL) | |
| 15884 | 385 | saved_status = purple_savedstatus_new(NULL, primitive); |
| 14743 | 386 | |
| 387 | /* Set the status for each account */ | |
| 15884 | 388 | purple_savedstatus_activate(saved_status); |
| 14743 | 389 | } |
| 390 | ||
| 391 | static void | |
| 392 | activate_saved_status_cb(GtkMenuItem *menuitem, gpointer user_data) | |
| 393 | { | |
| 394 | time_t creation_time; | |
| 15884 | 395 | PurpleSavedStatus *saved_status; |
| 14743 | 396 | |
| 397 | creation_time = GPOINTER_TO_INT(user_data); | |
| 15884 | 398 | saved_status = purple_savedstatus_find_by_creation_time(creation_time); |
| 14743 | 399 | if (saved_status != NULL) |
| 15884 | 400 | purple_savedstatus_activate(saved_status); |
| 14743 | 401 | } |
| 402 | ||
| 403 | static GtkWidget * | |
| 15884 | 404 | new_menu_item_with_status_icon(GtkWidget *menu, const char *str, PurpleStatusPrimitive primitive, GtkSignalFunc sf, gpointer data, guint accel_key, guint accel_mods, char *mod) |
| 14743 | 405 | { |
| 406 | GtkWidget *menuitem; | |
| 407 | GdkPixbuf *pixbuf; | |
| 408 | GtkWidget *image; | |
| 409 | ||
|
20953
e39a56e1b461
Patch from QuLogic to not use underscores in saved-statuses as mnemonics
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20380
diff
changeset
|
410 | menuitem = gtk_image_menu_item_new_with_label(str); |
| 14743 | 411 | |
| 412 | if (menu) | |
| 413 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 414 | ||
| 415 | if (sf) | |
| 416 | g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); | |
| 417 | ||
|
15799
ba7af742a0d1
Change some old, busted status icon stuff to use the new hotness
Sean Egan <seanegan@pidgin.im>
parents:
15766
diff
changeset
|
418 | pixbuf = pidgin_create_status_icon(primitive, menu, PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); |
| 14743 | 419 | image = gtk_image_new_from_pixbuf(pixbuf); |
| 420 | g_object_unref(pixbuf); | |
| 421 | gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | |
| 422 | ||
| 423 | gtk_widget_show_all(menuitem); | |
| 424 | ||
| 425 | return menuitem; | |
| 426 | } | |
| 427 | ||
| 428 | static GtkWidget * | |
| 429 | docklet_status_submenu() | |
| 430 | { | |
| 431 | GtkWidget *submenu, *menuitem; | |
| 432 | GList *popular_statuses, *cur; | |
| 433 | ||
| 434 | submenu = gtk_menu_new(); | |
| 435 | menuitem = gtk_menu_item_new_with_label(_("Change Status")); | |
| 436 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
| 437 | ||
| 15882 | 438 | new_menu_item_with_status_icon(submenu, _("Available"), |
| 15884 | 439 | PURPLE_STATUS_AVAILABLE, G_CALLBACK(activate_status_primitive_cb), |
| 440 | GINT_TO_POINTER(PURPLE_STATUS_AVAILABLE), 0, 0, NULL); | |
| 14743 | 441 | |
| 15882 | 442 | new_menu_item_with_status_icon(submenu, _("Away"), |
| 15884 | 443 | PURPLE_STATUS_AWAY, G_CALLBACK(activate_status_primitive_cb), |
| 444 | GINT_TO_POINTER(PURPLE_STATUS_AWAY), 0, 0, NULL); | |
| 14743 | 445 | |
| 15882 | 446 | new_menu_item_with_status_icon(submenu, _("Invisible"), |
| 15884 | 447 | PURPLE_STATUS_INVISIBLE, G_CALLBACK(activate_status_primitive_cb), |
| 448 | GINT_TO_POINTER(PURPLE_STATUS_INVISIBLE), 0, 0, NULL); | |
| 14743 | 449 | |
| 15882 | 450 | new_menu_item_with_status_icon(submenu, _("Offline"), |
| 15884 | 451 | PURPLE_STATUS_OFFLINE, G_CALLBACK(activate_status_primitive_cb), |
| 452 | GINT_TO_POINTER(PURPLE_STATUS_OFFLINE), 0, 0, NULL); | |
| 14743 | 453 | |
| 15884 | 454 | popular_statuses = purple_savedstatuses_get_popular(6); |
| 14743 | 455 | if (popular_statuses != NULL) |
| 15568 | 456 | pidgin_separator(submenu); |
| 14743 | 457 | for (cur = popular_statuses; cur != NULL; cur = cur->next) |
| 458 | { | |
| 15884 | 459 | PurpleSavedStatus *saved_status = cur->data; |
| 460 | time_t creation_time = purple_savedstatus_get_creation_time(saved_status); | |
| 15882 | 461 | new_menu_item_with_status_icon(submenu, |
| 15884 | 462 | purple_savedstatus_get_title(saved_status), |
| 463 | purple_savedstatus_get_type(saved_status), G_CALLBACK(activate_saved_status_cb), | |
| 14743 | 464 | GINT_TO_POINTER(creation_time), 0, 0, NULL); |
| 465 | } | |
| 466 | g_list_free(popular_statuses); | |
| 467 | ||
| 15568 | 468 | pidgin_separator(submenu); |
| 14743 | 469 | |
|
16960
6d97980fed84
Telcontar on #pidgin-win32 pointed out that the "New..." and "Saved..."
Casey Harkins <charkins@pidgin.im>
parents:
16918
diff
changeset
|
470 | pidgin_new_item_from_stock(submenu, _("New..."), NULL, G_CALLBACK(show_custom_status_editor_cb), NULL, 0, 0, NULL); |
|
6d97980fed84
Telcontar on #pidgin-win32 pointed out that the "New..." and "Saved..."
Casey Harkins <charkins@pidgin.im>
parents:
16918
diff
changeset
|
471 | pidgin_new_item_from_stock(submenu, _("Saved..."), NULL, G_CALLBACK(pidgin_status_window_show), NULL, 0, 0, NULL); |
| 14743 | 472 | |
| 473 | return menuitem; | |
| 474 | } | |
| 475 | ||
| 476 | static void | |
| 477 | docklet_menu() { | |
| 478 | static GtkWidget *menu = NULL; | |
| 479 | GtkWidget *menuitem; | |
| 480 | ||
| 481 | if (menu) { | |
| 482 | gtk_widget_destroy(menu); | |
| 483 | } | |
| 484 | ||
| 485 | menu = gtk_menu_new(); | |
| 486 | ||
| 487 | menuitem = gtk_check_menu_item_new_with_label(_("Show Buddy List")); | |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
488 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/list_visible")); |
| 14743 | 489 | g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_blist), NULL); |
| 490 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 491 | ||
| 492 | menuitem = gtk_menu_item_new_with_label(_("Unread Messages")); | |
| 493 | ||
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
494 | if (pending) { |
| 14743 | 495 | GtkWidget *submenu = gtk_menu_new(); |
| 496 | GList *l = get_pending_list(0); | |
| 497 | if (l == NULL) { | |
| 498 | gtk_widget_set_sensitive(menuitem, FALSE); | |
| 15884 | 499 | purple_debug_warning("docklet", |
| 14743 | 500 | "status indicates messages pending, but no conversations with unseen messages were found."); |
| 501 | } else { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
502 | pidgin_conversations_fill_menu(submenu, l); |
| 14743 | 503 | g_list_free(l); |
| 504 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
| 505 | } | |
| 506 | } else { | |
| 507 | gtk_widget_set_sensitive(menuitem, FALSE); | |
| 508 | } | |
| 509 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 510 | ||
| 15568 | 511 | pidgin_separator(menu); |
| 14743 | 512 | |
|
16263
27e0ef0f38e6
Word on the street is that we don't want things named pidginfoo_bar(), but
Richard Laager <rlaager@pidgin.im>
parents:
16179
diff
changeset
|
513 | menuitem = pidgin_new_item_from_stock(menu, _("New Message..."), PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW, G_CALLBACK(pidgin_dialogs_im), NULL, 0, 0, NULL); |
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
514 | if (status == PURPLE_STATUS_OFFLINE) |
| 14743 | 515 | gtk_widget_set_sensitive(menuitem, FALSE); |
| 516 | ||
| 517 | menuitem = docklet_status_submenu(); | |
| 518 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 519 | ||
| 15568 | 520 | pidgin_separator(menu); |
| 14743 | 521 | |
|
15623
bf485c598199
toolbar/menu icons. reduce the imhtmltoolbar spacing. more gaimstock pruning
Sean Egan <seanegan@pidgin.im>
parents:
15577
diff
changeset
|
522 | pidgin_new_item_from_stock(menu, _("Accounts"), NULL, G_CALLBACK(pidgin_accounts_window_show), NULL, 0, 0, NULL); |
|
15766
271f5a57657b
Add plugins stock icon to docklet menu
Daniel Atallah <datallah@pidgin.im>
parents:
15765
diff
changeset
|
523 | pidgin_new_item_from_stock(menu, _("Plugins"), PIDGIN_STOCK_TOOLBAR_PLUGINS, G_CALLBACK(pidgin_plugin_dialog_show), NULL, 0, 0, NULL); |
| 15568 | 524 | pidgin_new_item_from_stock(menu, _("Preferences"), GTK_STOCK_PREFERENCES, G_CALLBACK(pidgin_prefs_show), NULL, 0, 0, NULL); |
| 14743 | 525 | |
| 15568 | 526 | pidgin_separator(menu); |
| 14743 | 527 | |
| 528 | menuitem = gtk_check_menu_item_new_with_label(_("Mute Sounds")); | |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
529 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/sound/mute")); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
530 | if (!strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"), "none")) |
| 14743 | 531 | gtk_widget_set_sensitive(GTK_WIDGET(menuitem), FALSE); |
| 532 | g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_mute), NULL); | |
| 533 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
534 | |
|
20380
ff0e8127e272
(10:23:40 PM) khc: charkins: shouldn't "on" be lower case?
Casey Harkins <charkins@pidgin.im>
parents:
20363
diff
changeset
|
535 | menuitem = gtk_check_menu_item_new_with_label(_("Blink on New Message")); |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
536 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/docklet/blink")); |
| 14875 | 537 | g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_blink), NULL); |
| 538 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 14743 | 539 | |
| 15568 | 540 | pidgin_separator(menu); |
| 14743 | 541 | |
| 15884 | 542 | pidgin_new_item_from_stock(menu, _("Quit"), GTK_STOCK_QUIT, G_CALLBACK(purple_core_quit), NULL, 0, 0, NULL); |
| 14743 | 543 | |
| 544 | #ifdef _WIN32 | |
| 545 | g_signal_connect(menu, "leave-notify-event", G_CALLBACK(docklet_menu_leave_enter), NULL); | |
| 546 | g_signal_connect(menu, "enter-notify-event", G_CALLBACK(docklet_menu_leave_enter), NULL); | |
| 547 | #endif | |
| 548 | gtk_widget_show_all(menu); | |
| 549 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
550 | ui_ops->position_menu, |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
551 | NULL, 0, gtk_get_current_event_time()); |
| 14743 | 552 | } |
| 553 | ||
| 554 | /************************************************************************** | |
| 555 | * public api for ui_ops | |
| 556 | **************************************************************************/ | |
| 557 | void | |
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
558 | pidgin_docklet_update_icon() |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
559 | { |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
560 | if (ui_ops && ui_ops->update_icon) |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
561 | ui_ops->update_icon(status, connecting, pending); |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
562 | } |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
563 | |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
564 | void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
565 | pidgin_docklet_clicked(int button_type) |
| 14743 | 566 | { |
| 567 | switch (button_type) { | |
| 568 | case 1: | |
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
569 | if (pending) { |
| 14743 | 570 | GList *l = get_pending_list(1); |
| 571 | if (l != NULL) { | |
| 15884 | 572 | purple_conversation_present((PurpleConversation *)l->data); |
| 14743 | 573 | g_list_free(l); |
| 574 | } | |
| 575 | } else { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
576 | pidgin_blist_toggle_visibility(); |
| 14743 | 577 | } |
| 578 | break; | |
| 579 | case 3: | |
| 580 | docklet_menu(); | |
| 581 | break; | |
| 582 | } | |
| 583 | } | |
| 584 | ||
| 585 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
586 | pidgin_docklet_embedded() |
| 14743 | 587 | { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
588 | if (!visibility_manager |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
589 | && strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/docklet/show"), "pending")) { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
590 | pidgin_blist_visibility_manager_add(); |
| 14743 | 591 | visibility_manager = TRUE; |
| 592 | } | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
593 | visible = TRUE; |
| 14743 | 594 | docklet_update_status(); |
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
595 | pidgin_docklet_update_icon(); |
| 14743 | 596 | } |
| 597 | ||
| 598 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
599 | pidgin_docklet_remove() |
| 14743 | 600 | { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
601 | if (visible) { |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
602 | if (visibility_manager) { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
603 | pidgin_blist_visibility_manager_remove(); |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
604 | visibility_manager = FALSE; |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
605 | } |
| 14935 | 606 | if (docklet_blinking_timer) { |
| 607 | g_source_remove(docklet_blinking_timer); | |
| 608 | docklet_blinking_timer = 0; | |
| 609 | } | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
610 | visible = FALSE; |
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
611 | status = PURPLE_STATUS_OFFLINE; |
| 14743 | 612 | } |
| 613 | } | |
| 614 | ||
| 615 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
616 | pidgin_docklet_set_ui_ops(struct docklet_ui_ops *ops) |
| 14743 | 617 | { |
| 618 | ui_ops = ops; | |
| 619 | } | |
| 620 | ||
| 621 | void* | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
622 | pidgin_docklet_get_handle() |
| 14743 | 623 | { |
| 624 | static int i; | |
| 625 | return &i; | |
| 626 | } | |
| 627 | ||
|
14745
d43256e1e6fd
[gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents:
14743
diff
changeset
|
628 | void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
629 | pidgin_docklet_init() |
| 14743 | 630 | { |
| 15884 | 631 | void *conn_handle = purple_connections_get_handle(); |
| 632 | void *conv_handle = purple_conversations_get_handle(); | |
| 633 | void *accounts_handle = purple_accounts_get_handle(); | |
|
16918
d395c2be4cb1
Docklet icon is now tied to the saved status, so listen to the
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
634 | void *status_handle = purple_savedstatuses_get_handle(); |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
635 | void *docklet_handle = pidgin_docklet_get_handle(); |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
636 | |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
637 | purple_prefs_add_none(PIDGIN_PREFS_ROOT "/docklet"); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
638 | purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/docklet/blink", FALSE); |
|
19215
7a4ee0715da8
reverting the show docklet preference the correct way
Ka-Hing Cheung <khc@pidgin.im>
parents:
19129
diff
changeset
|
639 | purple_prefs_add_string(PIDGIN_PREFS_ROOT "/docklet/show", "always"); |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
640 | purple_prefs_connect_callback(docklet_handle, PIDGIN_PREFS_ROOT "/docklet/show", |
| 14947 | 641 | docklet_show_pref_changed_cb, NULL); |
| 14743 | 642 | |
| 643 | docklet_ui_init(); | |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
644 | if (!strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/docklet/show"), "always") && ui_ops && ui_ops->create) |
| 14743 | 645 | ui_ops->create(); |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
646 | |
| 15884 | 647 | purple_signal_connect(conn_handle, "signed-on", |
| 648 | docklet_handle, PURPLE_CALLBACK(docklet_signed_on_cb), NULL); | |
| 649 | purple_signal_connect(conn_handle, "signed-off", | |
| 650 | docklet_handle, PURPLE_CALLBACK(docklet_signed_off_cb), NULL); | |
|
16918
d395c2be4cb1
Docklet icon is now tied to the saved status, so listen to the
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
651 | purple_signal_connect(accounts_handle, "account-connecting", |
| 15884 | 652 | docklet_handle, PURPLE_CALLBACK(docklet_update_status_cb), NULL); |
| 653 | purple_signal_connect(conv_handle, "received-im-msg", | |
| 654 | docklet_handle, PURPLE_CALLBACK(docklet_update_status_cb), NULL); | |
| 655 | purple_signal_connect(conv_handle, "conversation-created", | |
| 656 | docklet_handle, PURPLE_CALLBACK(docklet_update_status_cb), NULL); | |
| 657 | purple_signal_connect(conv_handle, "deleting-conversation", | |
| 658 | docklet_handle, PURPLE_CALLBACK(docklet_update_status_cb), NULL); | |
| 659 | purple_signal_connect(conv_handle, "conversation-updated", | |
| 660 | docklet_handle, PURPLE_CALLBACK(docklet_conv_updated_cb), NULL); | |
|
16918
d395c2be4cb1
Docklet icon is now tied to the saved status, so listen to the
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
661 | purple_signal_connect(status_handle, "savedstatus-changed", |
|
d395c2be4cb1
Docklet icon is now tied to the saved status, so listen to the
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
662 | docklet_handle, PURPLE_CALLBACK(docklet_update_status_cb), NULL); |
|
14745
d43256e1e6fd
[gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents:
14743
diff
changeset
|
663 | #if 0 |
| 15884 | 664 | purple_signal_connect(purple_get_core(), "quitting", |
| 665 | docklet_handle, PURPLE_CALLBACK(purple_quit_cb), NULL); | |
|
14745
d43256e1e6fd
[gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents:
14743
diff
changeset
|
666 | #endif |
| 14743 | 667 | |
| 668 | enable_join_chat = online_account_supports_chat(); | |
| 669 | } | |
| 670 | ||
| 671 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
672 | pidgin_docklet_uninit() |
| 14743 | 673 | { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
674 | if (visible && ui_ops && ui_ops->destroy) |
| 14743 | 675 | ui_ops->destroy(); |
| 676 | } |