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