Tue, 24 Apr 2007 03:57:07 +0000
Rework the buddy icon subsystem to use the imgstore subsystem, and modify the
imgstore subsystem to not require IDs for everything.
| 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 | |
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
| 22 | * 02111-1307, USA. | |
| 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; | |
| 52 | static DockletStatus status = DOCKLET_STATUS_OFFLINE; | |
| 53 | static gboolean enable_join_chat = FALSE; | |
| 54 | static guint docklet_blinking_timer = 0; | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
55 | static gboolean visible = FALSE; |
| 14743 | 56 | static gboolean visibility_manager = FALSE; |
| 57 | ||
| 58 | /************************************************************************** | |
| 59 | * docklet status and utility functions | |
| 60 | **************************************************************************/ | |
| 61 | static gboolean | |
| 62 | docklet_blink_icon() | |
| 63 | { | |
| 64 | static gboolean blinked = FALSE; | |
| 65 | gboolean ret = FALSE; /* by default, don't keep blinking */ | |
| 66 | ||
| 67 | blinked = !blinked; | |
| 68 | ||
| 69 | switch (status) { | |
| 15731 | 70 | case DOCKLET_STATUS_PENDING: |
| 14743 | 71 | if (blinked) { |
| 72 | if (ui_ops && ui_ops->blank_icon) | |
| 73 | ui_ops->blank_icon(); | |
| 74 | } else { | |
| 75 | if (ui_ops && ui_ops->update_icon) | |
| 76 | ui_ops->update_icon(status); | |
| 77 | } | |
| 78 | ret = TRUE; /* keep blinking */ | |
| 79 | break; | |
| 80 | default: | |
| 81 | docklet_blinking_timer = 0; | |
| 82 | blinked = FALSE; | |
| 83 | break; | |
| 84 | } | |
| 85 | ||
| 86 | return ret; | |
| 87 | } | |
| 88 | ||
| 89 | static GList * | |
| 90 | get_pending_list(guint max) | |
| 91 | { | |
| 92 | GList *l_im = NULL; | |
| 93 | GList *l_chat = NULL; | |
| 94 | ||
| 15884 | 95 | 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
|
96 | PIDGIN_UNSEEN_TEXT, |
|
14813
c24dda7fb69e
[gaim-migrate @ 17508]
Casey Harkins <charkins@pidgin.im>
parents:
14745
diff
changeset
|
97 | FALSE, max); |
| 14743 | 98 | |
| 15884 | 99 | 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
|
100 | PIDGIN_UNSEEN_NICK, |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
101 | FALSE, max); |
| 14743 | 102 | |
| 103 | if (l_im != NULL && l_chat != NULL) | |
| 104 | return g_list_concat(l_im, l_chat); | |
| 105 | else if (l_im != NULL) | |
| 106 | return l_im; | |
| 107 | else | |
| 108 | return l_chat; | |
| 109 | } | |
| 110 | ||
| 111 | static gboolean | |
| 112 | docklet_update_status() | |
| 113 | { | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
114 | GList *convs, *l; |
| 14743 | 115 | int count; |
| 15884 | 116 | PurpleSavedStatus *saved_status; |
| 117 | PurpleStatusPrimitive prim; | |
| 14743 | 118 | DockletStatus newstatus = DOCKLET_STATUS_OFFLINE; |
| 15731 | 119 | gboolean pending = FALSE, connecting = FALSE; |
| 14743 | 120 | |
| 121 | /* determine if any ims have unseen messages */ | |
| 122 | convs = get_pending_list(DOCKLET_TOOLTIP_LINE_LIMIT); | |
| 123 | ||
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
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) { |
| 141 | pending = TRUE; | |
| 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) { | |
|
16091
53dfc6ca98c1
Had this hanging around. Put Pidgin in the docklet tooltip
Sean Egan <seanegan@pidgin.im>
parents:
15884
diff
changeset
|
171 | ui_ops->set_tooltip(PIDGIN_NAME); |
| 14743 | 172 | } |
| 173 | ||
| 15884 | 174 | for(l = purple_accounts_get_all(); l != NULL; l = l->next) { |
| 14743 | 175 | |
| 15884 | 176 | PurpleAccount *account = (PurpleAccount*)l->data; |
| 177 | PurpleStatus *account_status; | |
| 14743 | 178 | |
| 15884 | 179 | if (!purple_account_get_enabled(account, PIDGIN_UI)) |
| 14743 | 180 | continue; |
| 181 | ||
| 15884 | 182 | if (purple_account_is_disconnected(account)) |
| 14743 | 183 | continue; |
| 184 | ||
| 15884 | 185 | account_status = purple_account_get_active_status(account); |
| 186 | if (purple_account_is_connecting(account)) | |
| 15731 | 187 | connecting = TRUE; |
| 14743 | 188 | } |
|
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
|
189 | |
| 15884 | 190 | saved_status = purple_savedstatus_get_current(); |
| 191 | prim = purple_savedstatus_get_type(saved_status); | |
| 15760 | 192 | if (pending) |
|
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
|
193 | newstatus = DOCKLET_STATUS_PENDING; |
| 15760 | 194 | else if (connecting) |
| 15731 | 195 | newstatus = DOCKLET_STATUS_CONNECTING; |
| 15884 | 196 | else if (prim == PURPLE_STATUS_UNAVAILABLE) |
| 15731 | 197 | newstatus = DOCKLET_STATUS_BUSY; |
| 15884 | 198 | else if (prim == PURPLE_STATUS_AWAY) |
| 15731 | 199 | newstatus = DOCKLET_STATUS_AWAY; |
| 15884 | 200 | else if (prim == PURPLE_STATUS_EXTENDED_AWAY) |
|
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
|
201 | newstatus = DOCKLET_STATUS_XA; |
| 15884 | 202 | else if (prim == PURPLE_STATUS_OFFLINE) |
|
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
|
203 | newstatus = DOCKLET_STATUS_OFFLINE; |
| 15731 | 204 | else |
| 205 | newstatus = DOCKLET_STATUS_AVAILABLE; | |
|
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
|
206 | |
| 14743 | 207 | /* update the icon if we changed status */ |
| 208 | if (status != newstatus) { | |
| 209 | status = newstatus; | |
| 210 | ||
| 211 | if (ui_ops && ui_ops->update_icon) | |
| 212 | ui_ops->update_icon(status); | |
| 213 | ||
| 214 | /* and schedule the blinker function if messages are pending */ | |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
215 | if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/docklet/blink") && |
| 15731 | 216 | status == DOCKLET_STATUS_PENDING |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
217 | && docklet_blinking_timer == 0) { |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
218 | docklet_blinking_timer = g_timeout_add(500, docklet_blink_icon, NULL); |
| 14743 | 219 | } |
| 220 | } | |
| 221 | ||
| 222 | return FALSE; /* for when we're called by the glib idle handler */ | |
| 223 | } | |
| 224 | ||
| 225 | static gboolean | |
| 226 | online_account_supports_chat() | |
| 227 | { | |
| 228 | GList *c = NULL; | |
| 15884 | 229 | c = purple_connections_get_all(); |
| 14743 | 230 | |
| 231 | while(c != NULL) { | |
| 15884 | 232 | PurpleConnection *gc = c->data; |
| 233 | PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
| 14743 | 234 | if (prpl_info != NULL && prpl_info->chat_info != NULL) |
| 235 | return TRUE; | |
| 236 | c = c->next; | |
| 237 | } | |
| 238 | ||
| 239 | return FALSE; | |
| 240 | } | |
| 241 | ||
| 242 | /************************************************************************** | |
| 243 | * callbacks and signal handlers | |
| 244 | **************************************************************************/ | |
|
14745
d43256e1e6fd
[gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents:
14743
diff
changeset
|
245 | #if 0 |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
246 | static void |
| 15882 | 247 | pidgin_quit_cb() |
| 14743 | 248 | { |
| 249 | /* TODO: confirm quit while pending */ | |
| 250 | } | |
|
14745
d43256e1e6fd
[gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents:
14743
diff
changeset
|
251 | #endif |
| 14743 | 252 | |
| 253 | static void | |
| 254 | docklet_update_status_cb(void *data) | |
| 255 | { | |
| 256 | docklet_update_status(); | |
| 257 | } | |
| 258 | ||
| 259 | static void | |
| 15884 | 260 | docklet_conv_updated_cb(PurpleConversation *conv, PurpleConvUpdateType type) |
| 14743 | 261 | { |
| 15884 | 262 | if (type == PURPLE_CONV_UPDATE_UNSEEN) |
| 14743 | 263 | docklet_update_status(); |
| 264 | } | |
| 265 | ||
| 266 | static void | |
| 15884 | 267 | docklet_signed_on_cb(PurpleConnection *gc) |
| 14743 | 268 | { |
| 269 | if (!enable_join_chat) { | |
| 15884 | 270 | if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) |
| 14743 | 271 | enable_join_chat = TRUE; |
| 272 | } | |
| 273 | docklet_update_status(); | |
| 274 | } | |
| 275 | ||
| 276 | static void | |
| 15884 | 277 | docklet_signed_off_cb(PurpleConnection *gc) |
| 14743 | 278 | { |
| 279 | if (enable_join_chat) { | |
| 15884 | 280 | if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) |
| 14743 | 281 | enable_join_chat = online_account_supports_chat(); |
| 282 | } | |
| 283 | docklet_update_status(); | |
| 284 | } | |
| 285 | ||
| 14947 | 286 | static void |
| 15884 | 287 | docklet_show_pref_changed_cb(const char *name, PurplePrefType type, |
| 14947 | 288 | gconstpointer value, gpointer data) |
| 289 | { | |
| 290 | const char *val = value; | |
| 291 | if (!strcmp(val, "always")) { | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
292 | if (ui_ops->create) { |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
293 | if (!visible) |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
294 | ui_ops->create(); |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
295 | else if (!visibility_manager) { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
296 | pidgin_blist_visibility_manager_add(); |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
297 | visibility_manager = TRUE; |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
298 | } |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
299 | } |
| 14947 | 300 | } else if (!strcmp(val, "never")) { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
301 | if (visible && ui_ops->destroy) |
| 14947 | 302 | ui_ops->destroy(); |
| 303 | } else { | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
304 | if (visibility_manager) { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
305 | pidgin_blist_visibility_manager_remove(); |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
306 | visibility_manager = FALSE; |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
307 | } |
| 14947 | 308 | docklet_update_status(); |
| 309 | } | |
|
15075
2bd60dbd8877
[gaim-migrate @ 17794]
Daniel Atallah <datallah@pidgin.im>
parents:
14954
diff
changeset
|
310 | |
| 14947 | 311 | } |
| 312 | ||
| 14743 | 313 | /************************************************************************** |
| 314 | * docklet pop-up menu | |
| 315 | **************************************************************************/ | |
| 316 | static void | |
| 317 | docklet_toggle_mute(GtkWidget *toggle, void *data) | |
| 318 | { | |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
319 | purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/sound/mute", GTK_CHECK_MENU_ITEM(toggle)->active); |
| 14743 | 320 | } |
| 321 | ||
| 322 | static void | |
| 14875 | 323 | docklet_toggle_blink(GtkWidget *toggle, void *data) |
| 324 | { | |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
325 | purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/docklet/blink", GTK_CHECK_MENU_ITEM(toggle)->active); |
| 14875 | 326 | } |
| 327 | ||
| 328 | static void | |
| 14743 | 329 | docklet_toggle_blist(GtkWidget *toggle, void *data) |
| 330 | { | |
| 15884 | 331 | purple_blist_set_visible(GTK_CHECK_MENU_ITEM(toggle)->active); |
| 14743 | 332 | } |
| 333 | ||
| 334 | #ifdef _WIN32 | |
| 335 | /* This is a workaround for a bug in windows GTK+. Clicking outside of the | |
| 336 | menu does not get rid of it, so instead we get rid of it as soon as the | |
| 337 | pointer leaves the menu. */ | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
338 | static gboolean |
| 14743 | 339 | hide_docklet_menu(gpointer data) |
| 340 | { | |
| 341 | if (data != NULL) { | |
| 342 | gtk_menu_popdown(GTK_MENU(data)); | |
| 343 | } | |
| 344 | return FALSE; | |
| 345 | } | |
| 346 | ||
| 347 | static gboolean | |
| 348 | docklet_menu_leave_enter(GtkWidget *menu, GdkEventCrossing *event, void *data) | |
| 349 | { | |
| 350 | static guint hide_docklet_timer = 0; | |
| 351 | if (event->type == GDK_LEAVE_NOTIFY && event->detail == GDK_NOTIFY_ANCESTOR) { | |
| 15884 | 352 | purple_debug(PURPLE_DEBUG_INFO, "docklet", "menu leave-notify-event\n"); |
| 14743 | 353 | /* Add some slop so that the menu doesn't annoyingly disappear when mousing around */ |
| 354 | if (hide_docklet_timer == 0) { | |
| 15884 | 355 | hide_docklet_timer = purple_timeout_add(500, |
| 14743 | 356 | hide_docklet_menu, menu); |
| 357 | } | |
| 358 | } else if (event->type == GDK_ENTER_NOTIFY && event->detail == GDK_NOTIFY_ANCESTOR) { | |
| 15884 | 359 | purple_debug(PURPLE_DEBUG_INFO, "docklet", "menu enter-notify-event\n"); |
| 14743 | 360 | if (hide_docklet_timer != 0) { |
| 361 | /* Cancel the hiding if we reenter */ | |
| 362 | ||
| 15884 | 363 | purple_timeout_remove(hide_docklet_timer); |
| 14743 | 364 | hide_docklet_timer = 0; |
| 365 | } | |
| 366 | } | |
| 367 | return FALSE; | |
| 368 | } | |
| 369 | #endif | |
| 370 | ||
| 371 | static void | |
| 372 | show_custom_status_editor_cb(GtkMenuItem *menuitem, gpointer user_data) | |
| 373 | { | |
| 15884 | 374 | PurpleSavedStatus *saved_status; |
| 375 | saved_status = purple_savedstatus_get_current(); | |
|
16179
bdf68342e1ce
sf patch #1622581, from Greg Taeger
Mark Doliner <markdoliner@pidgin.im>
parents:
16129
diff
changeset
|
376 | |
|
bdf68342e1ce
sf patch #1622581, from Greg Taeger
Mark Doliner <markdoliner@pidgin.im>
parents:
16129
diff
changeset
|
377 | 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
|
378 | 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
|
379 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
380 | pidgin_status_editor_show(FALSE, |
| 15884 | 381 | purple_savedstatus_is_transient(saved_status) ? saved_status : NULL); |
| 14743 | 382 | } |
| 383 | ||
| 384 | static void | |
| 385 | activate_status_primitive_cb(GtkMenuItem *menuitem, gpointer user_data) | |
| 386 | { | |
| 15884 | 387 | PurpleStatusPrimitive primitive; |
| 388 | PurpleSavedStatus *saved_status; | |
| 14743 | 389 | |
| 390 | primitive = GPOINTER_TO_INT(user_data); | |
| 391 | ||
| 392 | /* Try to lookup an already existing transient saved status */ | |
| 15884 | 393 | saved_status = purple_savedstatus_find_transient_by_type_and_message(primitive, NULL); |
| 14743 | 394 | |
| 395 | /* Create a new transient saved status if we weren't able to find one */ | |
| 396 | if (saved_status == NULL) | |
| 15884 | 397 | saved_status = purple_savedstatus_new(NULL, primitive); |
| 14743 | 398 | |
| 399 | /* Set the status for each account */ | |
| 15884 | 400 | purple_savedstatus_activate(saved_status); |
| 14743 | 401 | } |
| 402 | ||
| 403 | static void | |
| 404 | activate_saved_status_cb(GtkMenuItem *menuitem, gpointer user_data) | |
| 405 | { | |
| 406 | time_t creation_time; | |
| 15884 | 407 | PurpleSavedStatus *saved_status; |
| 14743 | 408 | |
| 409 | creation_time = GPOINTER_TO_INT(user_data); | |
| 15884 | 410 | saved_status = purple_savedstatus_find_by_creation_time(creation_time); |
| 14743 | 411 | if (saved_status != NULL) |
| 15884 | 412 | purple_savedstatus_activate(saved_status); |
| 14743 | 413 | } |
| 414 | ||
| 415 | static GtkWidget * | |
| 15884 | 416 | 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 | 417 | { |
| 418 | GtkWidget *menuitem; | |
| 419 | GdkPixbuf *pixbuf; | |
| 420 | GtkWidget *image; | |
| 421 | ||
| 422 | menuitem = gtk_image_menu_item_new_with_mnemonic(str); | |
| 423 | ||
| 424 | if (menu) | |
| 425 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 426 | ||
| 427 | if (sf) | |
| 428 | g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); | |
| 429 | ||
|
15799
ba7af742a0d1
Change some old, busted status icon stuff to use the new hotness
Sean Egan <seanegan@pidgin.im>
parents:
15766
diff
changeset
|
430 | pixbuf = pidgin_create_status_icon(primitive, menu, PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); |
| 14743 | 431 | image = gtk_image_new_from_pixbuf(pixbuf); |
| 432 | g_object_unref(pixbuf); | |
| 433 | gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | |
| 434 | ||
| 435 | gtk_widget_show_all(menuitem); | |
| 436 | ||
| 437 | return menuitem; | |
| 438 | } | |
| 439 | ||
| 440 | static GtkWidget * | |
| 441 | docklet_status_submenu() | |
| 442 | { | |
| 443 | GtkWidget *submenu, *menuitem; | |
| 444 | GList *popular_statuses, *cur; | |
| 445 | ||
| 446 | submenu = gtk_menu_new(); | |
| 447 | menuitem = gtk_menu_item_new_with_label(_("Change Status")); | |
| 448 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
| 449 | ||
| 15882 | 450 | new_menu_item_with_status_icon(submenu, _("Available"), |
| 15884 | 451 | PURPLE_STATUS_AVAILABLE, G_CALLBACK(activate_status_primitive_cb), |
| 452 | GINT_TO_POINTER(PURPLE_STATUS_AVAILABLE), 0, 0, NULL); | |
| 14743 | 453 | |
| 15882 | 454 | new_menu_item_with_status_icon(submenu, _("Away"), |
| 15884 | 455 | PURPLE_STATUS_AWAY, G_CALLBACK(activate_status_primitive_cb), |
| 456 | GINT_TO_POINTER(PURPLE_STATUS_AWAY), 0, 0, NULL); | |
| 14743 | 457 | |
| 15882 | 458 | new_menu_item_with_status_icon(submenu, _("Invisible"), |
| 15884 | 459 | PURPLE_STATUS_INVISIBLE, G_CALLBACK(activate_status_primitive_cb), |
| 460 | GINT_TO_POINTER(PURPLE_STATUS_INVISIBLE), 0, 0, NULL); | |
| 14743 | 461 | |
| 15882 | 462 | new_menu_item_with_status_icon(submenu, _("Offline"), |
| 15884 | 463 | PURPLE_STATUS_OFFLINE, G_CALLBACK(activate_status_primitive_cb), |
| 464 | GINT_TO_POINTER(PURPLE_STATUS_OFFLINE), 0, 0, NULL); | |
| 14743 | 465 | |
| 15884 | 466 | popular_statuses = purple_savedstatuses_get_popular(6); |
| 14743 | 467 | if (popular_statuses != NULL) |
| 15568 | 468 | pidgin_separator(submenu); |
| 14743 | 469 | for (cur = popular_statuses; cur != NULL; cur = cur->next) |
| 470 | { | |
| 15884 | 471 | PurpleSavedStatus *saved_status = cur->data; |
| 472 | time_t creation_time = purple_savedstatus_get_creation_time(saved_status); | |
| 15882 | 473 | new_menu_item_with_status_icon(submenu, |
| 15884 | 474 | purple_savedstatus_get_title(saved_status), |
| 475 | purple_savedstatus_get_type(saved_status), G_CALLBACK(activate_saved_status_cb), | |
| 14743 | 476 | GINT_TO_POINTER(creation_time), 0, 0, NULL); |
| 477 | } | |
| 478 | g_list_free(popular_statuses); | |
| 479 | ||
| 15568 | 480 | pidgin_separator(submenu); |
| 14743 | 481 | |
| 15884 | 482 | new_menu_item_with_status_icon(submenu, _("New..."), PURPLE_STATUS_AVAILABLE, G_CALLBACK(show_custom_status_editor_cb), NULL, 0, 0, NULL); |
| 483 | new_menu_item_with_status_icon(submenu, _("Saved..."), PURPLE_STATUS_AVAILABLE, G_CALLBACK(pidgin_status_window_show), NULL, 0, 0, NULL); | |
| 14743 | 484 | |
| 485 | return menuitem; | |
| 486 | } | |
| 487 | ||
| 488 | static void | |
| 489 | docklet_menu() { | |
| 490 | static GtkWidget *menu = NULL; | |
| 491 | GtkWidget *menuitem; | |
| 492 | ||
| 493 | if (menu) { | |
| 494 | gtk_widget_destroy(menu); | |
| 495 | } | |
| 496 | ||
| 497 | menu = gtk_menu_new(); | |
| 498 | ||
| 499 | 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
|
500 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/list_visible")); |
| 14743 | 501 | g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_blist), NULL); |
| 502 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 503 | ||
| 504 | menuitem = gtk_menu_item_new_with_label(_("Unread Messages")); | |
| 505 | ||
| 15731 | 506 | if (status == DOCKLET_STATUS_PENDING) { |
| 14743 | 507 | GtkWidget *submenu = gtk_menu_new(); |
| 508 | GList *l = get_pending_list(0); | |
| 509 | if (l == NULL) { | |
| 510 | gtk_widget_set_sensitive(menuitem, FALSE); | |
| 15884 | 511 | purple_debug_warning("docklet", |
| 14743 | 512 | "status indicates messages pending, but no conversations with unseen messages were found."); |
| 513 | } else { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
514 | pidgin_conversations_fill_menu(submenu, l); |
| 14743 | 515 | g_list_free(l); |
| 516 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
| 517 | } | |
| 518 | } else { | |
| 519 | gtk_widget_set_sensitive(menuitem, FALSE); | |
| 520 | } | |
| 521 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 522 | ||
| 15568 | 523 | pidgin_separator(menu); |
| 14743 | 524 | |
|
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
|
525 | menuitem = pidgin_new_item_from_stock(menu, _("New Message..."), PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW, G_CALLBACK(pidgin_dialogs_im), NULL, 0, 0, NULL); |
| 14743 | 526 | if (status == DOCKLET_STATUS_OFFLINE) |
| 527 | gtk_widget_set_sensitive(menuitem, FALSE); | |
| 528 | ||
| 529 | menuitem = docklet_status_submenu(); | |
| 530 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 531 | ||
| 15568 | 532 | pidgin_separator(menu); |
| 14743 | 533 | |
|
15623
bf485c598199
toolbar/menu icons. reduce the imhtmltoolbar spacing. more gaimstock pruning
Sean Egan <seanegan@pidgin.im>
parents:
15577
diff
changeset
|
534 | 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
|
535 | pidgin_new_item_from_stock(menu, _("Plugins"), PIDGIN_STOCK_TOOLBAR_PLUGINS, G_CALLBACK(pidgin_plugin_dialog_show), NULL, 0, 0, NULL); |
| 15568 | 536 | pidgin_new_item_from_stock(menu, _("Preferences"), GTK_STOCK_PREFERENCES, G_CALLBACK(pidgin_prefs_show), NULL, 0, 0, NULL); |
| 14743 | 537 | |
| 15568 | 538 | pidgin_separator(menu); |
| 14743 | 539 | |
| 540 | 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
|
541 | 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
|
542 | if (!strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"), "none")) |
| 14743 | 543 | gtk_widget_set_sensitive(GTK_WIDGET(menuitem), FALSE); |
| 544 | g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_mute), NULL); | |
| 545 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
546 | |
| 14875 | 547 | 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
|
548 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/docklet/blink")); |
| 14875 | 549 | g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_blink), NULL); |
| 550 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 14743 | 551 | |
| 15568 | 552 | pidgin_separator(menu); |
| 14743 | 553 | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
554 | /* TODO: need a submenu to change status, this needs to "link" |
| 14743 | 555 | * to the status in the buddy list gtkstatusbox |
| 556 | */ | |
| 557 | ||
| 15884 | 558 | pidgin_new_item_from_stock(menu, _("Quit"), GTK_STOCK_QUIT, G_CALLBACK(purple_core_quit), NULL, 0, 0, NULL); |
| 14743 | 559 | |
| 560 | #ifdef _WIN32 | |
| 561 | g_signal_connect(menu, "leave-notify-event", G_CALLBACK(docklet_menu_leave_enter), NULL); | |
| 562 | g_signal_connect(menu, "enter-notify-event", G_CALLBACK(docklet_menu_leave_enter), NULL); | |
| 563 | #endif | |
| 564 | gtk_widget_show_all(menu); | |
| 565 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
566 | ui_ops->position_menu, |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
567 | NULL, 0, gtk_get_current_event_time()); |
| 14743 | 568 | } |
| 569 | ||
| 570 | /************************************************************************** | |
| 571 | * public api for ui_ops | |
| 572 | **************************************************************************/ | |
| 573 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
574 | pidgin_docklet_clicked(int button_type) |
| 14743 | 575 | { |
| 576 | switch (button_type) { | |
| 577 | case 1: | |
| 15731 | 578 | if (status == DOCKLET_STATUS_PENDING) { |
| 14743 | 579 | GList *l = get_pending_list(1); |
| 580 | if (l != NULL) { | |
| 15884 | 581 | purple_conversation_present((PurpleConversation *)l->data); |
| 14743 | 582 | g_list_free(l); |
| 583 | } | |
| 584 | } else { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
585 | pidgin_blist_toggle_visibility(); |
| 14743 | 586 | } |
| 587 | break; | |
| 588 | case 3: | |
| 589 | docklet_menu(); | |
| 590 | break; | |
| 591 | } | |
| 592 | } | |
| 593 | ||
| 594 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
595 | pidgin_docklet_embedded() |
| 14743 | 596 | { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
597 | 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
|
598 | && 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
|
599 | pidgin_blist_visibility_manager_add(); |
| 14743 | 600 | visibility_manager = TRUE; |
| 601 | } | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
602 | visible = TRUE; |
| 14743 | 603 | docklet_update_status(); |
| 604 | if (ui_ops && ui_ops->update_icon) | |
| 605 | ui_ops->update_icon(status); | |
| 606 | } | |
| 607 | ||
| 608 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
609 | pidgin_docklet_remove() |
| 14743 | 610 | { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
611 | if (visible) { |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
612 | if (visibility_manager) { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
613 | pidgin_blist_visibility_manager_remove(); |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
614 | visibility_manager = FALSE; |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
615 | } |
| 14935 | 616 | if (docklet_blinking_timer) { |
| 617 | g_source_remove(docklet_blinking_timer); | |
| 618 | docklet_blinking_timer = 0; | |
| 619 | } | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
620 | visible = FALSE; |
| 14935 | 621 | status = DOCKLET_STATUS_OFFLINE; |
| 14743 | 622 | } |
| 623 | } | |
| 624 | ||
| 625 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
626 | pidgin_docklet_set_ui_ops(struct docklet_ui_ops *ops) |
| 14743 | 627 | { |
| 628 | ui_ops = ops; | |
| 629 | } | |
| 630 | ||
| 631 | void* | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
632 | pidgin_docklet_get_handle() |
| 14743 | 633 | { |
| 634 | static int i; | |
| 635 | return &i; | |
| 636 | } | |
| 637 | ||
|
14745
d43256e1e6fd
[gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents:
14743
diff
changeset
|
638 | void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
639 | pidgin_docklet_init() |
| 14743 | 640 | { |
| 15884 | 641 | void *conn_handle = purple_connections_get_handle(); |
| 642 | void *conv_handle = purple_conversations_get_handle(); | |
| 643 | void *accounts_handle = purple_accounts_get_handle(); | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
644 | void *docklet_handle = pidgin_docklet_get_handle(); |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
645 | |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
646 | 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
|
647 | purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/docklet/blink", FALSE); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
648 | purple_prefs_add_string(PIDGIN_PREFS_ROOT "/docklet/show", "always"); |
|
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
649 | purple_prefs_connect_callback(docklet_handle, PIDGIN_PREFS_ROOT "/docklet/show", |
| 14947 | 650 | docklet_show_pref_changed_cb, NULL); |
| 14743 | 651 | |
| 652 | 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
|
653 | if (!strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/docklet/show"), "always") && ui_ops && ui_ops->create) |
| 14743 | 654 | ui_ops->create(); |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
655 | |
| 15884 | 656 | purple_signal_connect(conn_handle, "signed-on", |
| 657 | docklet_handle, PURPLE_CALLBACK(docklet_signed_on_cb), NULL); | |
| 658 | purple_signal_connect(conn_handle, "signed-off", | |
| 659 | docklet_handle, PURPLE_CALLBACK(docklet_signed_off_cb), NULL); | |
| 660 | purple_signal_connect(accounts_handle, "account-status-changed", | |
| 661 | docklet_handle, PURPLE_CALLBACK(docklet_update_status_cb), NULL); | |
| 662 | purple_signal_connect(conv_handle, "received-im-msg", | |
| 663 | docklet_handle, PURPLE_CALLBACK(docklet_update_status_cb), NULL); | |
| 664 | purple_signal_connect(conv_handle, "conversation-created", | |
| 665 | docklet_handle, PURPLE_CALLBACK(docklet_update_status_cb), NULL); | |
| 666 | purple_signal_connect(conv_handle, "deleting-conversation", | |
| 667 | docklet_handle, PURPLE_CALLBACK(docklet_update_status_cb), NULL); | |
| 668 | purple_signal_connect(conv_handle, "conversation-updated", | |
| 669 | docklet_handle, PURPLE_CALLBACK(docklet_conv_updated_cb), NULL); | |
|
14745
d43256e1e6fd
[gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents:
14743
diff
changeset
|
670 | #if 0 |
| 15884 | 671 | purple_signal_connect(purple_get_core(), "quitting", |
| 672 | docklet_handle, PURPLE_CALLBACK(purple_quit_cb), NULL); | |
|
14745
d43256e1e6fd
[gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents:
14743
diff
changeset
|
673 | #endif |
| 14743 | 674 | |
| 675 | enable_join_chat = online_account_supports_chat(); | |
| 676 | } | |
| 677 | ||
| 678 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
679 | pidgin_docklet_uninit() |
| 14743 | 680 | { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
681 | if (visible && ui_ops && ui_ops->destroy) |
| 14743 | 682 | ui_ops->destroy(); |
| 683 | } |