Sun, 28 Oct 2007 17:08:46 +0000
merge of 'd5476c3d62e8401deb9f05463379a6546fb1b8f6'
and '19466559b62c951a554d05a7a719956a96f51b5c'
| 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 | ||
| 410 | menuitem = gtk_image_menu_item_new_with_mnemonic(str); | |
| 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 | ||
|
20959
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
476 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
477 | static void |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
478 | plugin_act(GtkObject *obj, PurplePluginAction *pam) |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
479 | { |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
480 | if (pam && pam->callback) |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
481 | pam->callback(pam); |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
482 | } |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
483 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
484 | static void |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
485 | build_plugin_actions(GtkWidget *menu, PurplePlugin *plugin, |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
486 | gpointer context) |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
487 | { |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
488 | GtkWidget *menuitem; |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
489 | PurplePluginAction *action = NULL; |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
490 | GList *actions, *l; |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
491 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
492 | actions = PURPLE_PLUGIN_ACTIONS(plugin, context); |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
493 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
494 | for (l = actions; l != NULL; l = l->next) |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
495 | { |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
496 | if (l->data) |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
497 | { |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
498 | action = (PurplePluginAction *) l->data; |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
499 | action->plugin = plugin; |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
500 | action->context = context; |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
501 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
502 | menuitem = gtk_menu_item_new_with_label(action->label); |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
503 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
504 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
505 | g_signal_connect(G_OBJECT(menuitem), "activate", |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
506 | G_CALLBACK(plugin_act), action); |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
507 | g_object_set_data_full(G_OBJECT(menuitem), "plugin_action", |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
508 | action, |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
509 | (GDestroyNotify)purple_plugin_action_free); |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
510 | gtk_widget_show(menuitem); |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
511 | } |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
512 | else |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
513 | pidgin_separator(menu); |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
514 | } |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
515 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
516 | g_list_free(actions); |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
517 | } |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
518 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
519 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
520 | static void |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
521 | docklet_plugin_actions(GtkWidget *menu) |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
522 | { |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
523 | GtkWidget *menuitem, *submenu; |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
524 | PurplePlugin *plugin = NULL; |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
525 | GList *l; |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
526 | int c = 0; |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
527 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
528 | g_return_if_fail(menu != NULL); |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
529 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
530 | /* Add a submenu for each plugin with custom actions */ |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
531 | for (l = purple_plugins_get_loaded(); l; l = l->next) { |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
532 | plugin = (PurplePlugin *) l->data; |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
533 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
534 | if (PURPLE_IS_PROTOCOL_PLUGIN(plugin)) |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
535 | continue; |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
536 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
537 | if (!PURPLE_PLUGIN_HAS_ACTIONS(plugin)) |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
538 | continue; |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
539 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
540 | menuitem = gtk_image_menu_item_new_with_label(_(plugin->info->name)); |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
541 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
542 | gtk_widget_show(menuitem); |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
543 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
544 | submenu = gtk_menu_new(); |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
545 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
546 | gtk_widget_show(submenu); |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
547 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
548 | build_plugin_actions(submenu, plugin, NULL); |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
549 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
550 | c++; |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
551 | } |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
552 | if(c>0) |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
553 | pidgin_separator(menu); |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
554 | } |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
555 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
556 | |
| 14743 | 557 | static void |
| 558 | docklet_menu() { | |
| 559 | static GtkWidget *menu = NULL; | |
| 560 | GtkWidget *menuitem; | |
| 561 | ||
| 562 | if (menu) { | |
| 563 | gtk_widget_destroy(menu); | |
| 564 | } | |
| 565 | ||
| 566 | menu = gtk_menu_new(); | |
| 567 | ||
| 568 | 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
|
569 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/list_visible")); |
| 14743 | 570 | g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_blist), NULL); |
| 571 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 572 | ||
| 573 | menuitem = gtk_menu_item_new_with_label(_("Unread Messages")); | |
| 574 | ||
|
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
|
575 | if (pending) { |
| 14743 | 576 | GtkWidget *submenu = gtk_menu_new(); |
| 577 | GList *l = get_pending_list(0); | |
| 578 | if (l == NULL) { | |
| 579 | gtk_widget_set_sensitive(menuitem, FALSE); | |
| 15884 | 580 | purple_debug_warning("docklet", |
| 14743 | 581 | "status indicates messages pending, but no conversations with unseen messages were found."); |
| 582 | } else { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
583 | pidgin_conversations_fill_menu(submenu, l); |
| 14743 | 584 | g_list_free(l); |
| 585 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
| 586 | } | |
| 587 | } else { | |
| 588 | gtk_widget_set_sensitive(menuitem, FALSE); | |
| 589 | } | |
| 590 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 591 | ||
| 15568 | 592 | pidgin_separator(menu); |
| 14743 | 593 | |
|
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
|
594 | 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
|
595 | if (status == PURPLE_STATUS_OFFLINE) |
| 14743 | 596 | gtk_widget_set_sensitive(menuitem, FALSE); |
| 597 | ||
| 598 | menuitem = docklet_status_submenu(); | |
| 599 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 600 | ||
| 15568 | 601 | pidgin_separator(menu); |
| 14743 | 602 | |
|
15623
bf485c598199
toolbar/menu icons. reduce the imhtmltoolbar spacing. more gaimstock pruning
Sean Egan <seanegan@pidgin.im>
parents:
15577
diff
changeset
|
603 | 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
|
604 | pidgin_new_item_from_stock(menu, _("Plugins"), PIDGIN_STOCK_TOOLBAR_PLUGINS, G_CALLBACK(pidgin_plugin_dialog_show), NULL, 0, 0, NULL); |
| 15568 | 605 | pidgin_new_item_from_stock(menu, _("Preferences"), GTK_STOCK_PREFERENCES, G_CALLBACK(pidgin_prefs_show), NULL, 0, 0, NULL); |
| 14743 | 606 | |
| 15568 | 607 | pidgin_separator(menu); |
| 14743 | 608 | |
| 609 | 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
|
610 | 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
|
611 | if (!strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"), "none")) |
| 14743 | 612 | gtk_widget_set_sensitive(GTK_WIDGET(menuitem), FALSE); |
| 613 | g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_mute), NULL); | |
| 614 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
615 | |
|
20380
ff0e8127e272
(10:23:40 PM) khc: charkins: shouldn't "on" be lower case?
Casey Harkins <charkins@pidgin.im>
parents:
20363
diff
changeset
|
616 | 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
|
617 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/docklet/blink")); |
| 14875 | 618 | g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_blink), NULL); |
| 619 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 14743 | 620 | |
| 15568 | 621 | pidgin_separator(menu); |
| 14743 | 622 | |
|
20959
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
623 | /* add plugin actions */ |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
624 | docklet_plugin_actions(menu); |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
625 | |
| 15884 | 626 | pidgin_new_item_from_stock(menu, _("Quit"), GTK_STOCK_QUIT, G_CALLBACK(purple_core_quit), NULL, 0, 0, NULL); |
| 14743 | 627 | |
| 628 | #ifdef _WIN32 | |
| 629 | g_signal_connect(menu, "leave-notify-event", G_CALLBACK(docklet_menu_leave_enter), NULL); | |
| 630 | g_signal_connect(menu, "enter-notify-event", G_CALLBACK(docklet_menu_leave_enter), NULL); | |
| 631 | #endif | |
| 632 | gtk_widget_show_all(menu); | |
| 633 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
634 | ui_ops->position_menu, |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
635 | NULL, 0, gtk_get_current_event_time()); |
| 14743 | 636 | } |
| 637 | ||
| 638 | /************************************************************************** | |
| 639 | * public api for ui_ops | |
| 640 | **************************************************************************/ | |
| 641 | 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
|
642 | 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
|
643 | { |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
644 | 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
|
645 | 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
|
646 | } |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
647 | |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
648 | void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
649 | pidgin_docklet_clicked(int button_type) |
| 14743 | 650 | { |
| 651 | switch (button_type) { | |
| 652 | 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
|
653 | if (pending) { |
| 14743 | 654 | GList *l = get_pending_list(1); |
| 655 | if (l != NULL) { | |
| 15884 | 656 | purple_conversation_present((PurpleConversation *)l->data); |
| 14743 | 657 | g_list_free(l); |
| 658 | } | |
| 659 | } else { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
660 | pidgin_blist_toggle_visibility(); |
| 14743 | 661 | } |
| 662 | break; | |
| 663 | case 3: | |
| 664 | docklet_menu(); | |
| 665 | break; | |
| 666 | } | |
| 667 | } | |
| 668 | ||
| 669 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
670 | pidgin_docklet_embedded() |
| 14743 | 671 | { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
672 | 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
|
673 | && 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
|
674 | pidgin_blist_visibility_manager_add(); |
| 14743 | 675 | visibility_manager = TRUE; |
| 676 | } | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
677 | visible = TRUE; |
| 14743 | 678 | 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
|
679 | pidgin_docklet_update_icon(); |
| 14743 | 680 | } |
| 681 | ||
| 682 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
683 | pidgin_docklet_remove() |
| 14743 | 684 | { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
685 | if (visible) { |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
686 | if (visibility_manager) { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
687 | pidgin_blist_visibility_manager_remove(); |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
688 | visibility_manager = FALSE; |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
689 | } |
| 14935 | 690 | if (docklet_blinking_timer) { |
| 691 | g_source_remove(docklet_blinking_timer); | |
| 692 | docklet_blinking_timer = 0; | |
| 693 | } | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
694 | 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
|
695 | status = PURPLE_STATUS_OFFLINE; |
| 14743 | 696 | } |
| 697 | } | |
| 698 | ||
| 699 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
700 | pidgin_docklet_set_ui_ops(struct docklet_ui_ops *ops) |
| 14743 | 701 | { |
| 702 | ui_ops = ops; | |
| 703 | } | |
| 704 | ||
| 705 | void* | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
706 | pidgin_docklet_get_handle() |
| 14743 | 707 | { |
| 708 | static int i; | |
| 709 | return &i; | |
| 710 | } | |
| 711 | ||
|
20961
f69b1356bb55
Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents:
20959
diff
changeset
|
712 | gboolean |
|
f69b1356bb55
Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents:
20959
diff
changeset
|
713 | pidgin_docklet_get_geometry(gint *x, gint *y, gint *w, gint *h) |
|
f69b1356bb55
Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents:
20959
diff
changeset
|
714 | { |
|
20964
19466559b62c
disapproval of revision '85fa773ffa364b07fa35a9accfc8f5f9e8527cc8'
Casey Harkins <charkins@pidgin.im>
parents:
20963
diff
changeset
|
715 | if(!visible) return FALSE; |
|
19466559b62c
disapproval of revision '85fa773ffa364b07fa35a9accfc8f5f9e8527cc8'
Casey Harkins <charkins@pidgin.im>
parents:
20963
diff
changeset
|
716 | if(ui_ops && ui_ops->get_geometry) return ui_ops->get_geometry(x, y, w, h); |
|
20961
f69b1356bb55
Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents:
20959
diff
changeset
|
717 | return FALSE; |
|
f69b1356bb55
Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents:
20959
diff
changeset
|
718 | } |
|
f69b1356bb55
Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents:
20959
diff
changeset
|
719 | |
|
f69b1356bb55
Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents:
20959
diff
changeset
|
720 | GObject * |
|
f69b1356bb55
Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents:
20959
diff
changeset
|
721 | pidgin_docklet_get_gdk_screen() |
|
f69b1356bb55
Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents:
20959
diff
changeset
|
722 | { |
|
20964
19466559b62c
disapproval of revision '85fa773ffa364b07fa35a9accfc8f5f9e8527cc8'
Casey Harkins <charkins@pidgin.im>
parents:
20963
diff
changeset
|
723 | if(!visible) return NULL; |
|
19466559b62c
disapproval of revision '85fa773ffa364b07fa35a9accfc8f5f9e8527cc8'
Casey Harkins <charkins@pidgin.im>
parents:
20963
diff
changeset
|
724 | if(ui_ops && ui_ops->get_gdk_screen) return ui_ops->get_gdk_screen(); |
|
20961
f69b1356bb55
Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents:
20959
diff
changeset
|
725 | return NULL; |
|
f69b1356bb55
Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents:
20959
diff
changeset
|
726 | } |
|
f69b1356bb55
Add new API to the docklet for retrieving the geometry (x,y,w,h) and the
Casey Harkins <charkins@pidgin.im>
parents:
20959
diff
changeset
|
727 | |
|
14745
d43256e1e6fd
[gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents:
14743
diff
changeset
|
728 | void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
729 | pidgin_docklet_init() |
| 14743 | 730 | { |
| 15884 | 731 | void *conn_handle = purple_connections_get_handle(); |
| 732 | void *conv_handle = purple_conversations_get_handle(); | |
| 733 | 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
|
734 | void *status_handle = purple_savedstatuses_get_handle(); |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
735 | void *docklet_handle = pidgin_docklet_get_handle(); |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
736 | |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
737 | 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
|
738 | 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
|
739 | 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
|
740 | purple_prefs_connect_callback(docklet_handle, PIDGIN_PREFS_ROOT "/docklet/show", |
| 14947 | 741 | docklet_show_pref_changed_cb, NULL); |
| 14743 | 742 | |
| 743 | 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
|
744 | if (!strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/docklet/show"), "always") && ui_ops && ui_ops->create) |
| 14743 | 745 | ui_ops->create(); |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
746 | |
| 15884 | 747 | purple_signal_connect(conn_handle, "signed-on", |
| 748 | docklet_handle, PURPLE_CALLBACK(docklet_signed_on_cb), NULL); | |
| 749 | purple_signal_connect(conn_handle, "signed-off", | |
| 750 | 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
|
751 | purple_signal_connect(accounts_handle, "account-connecting", |
| 15884 | 752 | docklet_handle, PURPLE_CALLBACK(docklet_update_status_cb), NULL); |
| 753 | purple_signal_connect(conv_handle, "received-im-msg", | |
| 754 | docklet_handle, PURPLE_CALLBACK(docklet_update_status_cb), NULL); | |
| 755 | purple_signal_connect(conv_handle, "conversation-created", | |
| 756 | docklet_handle, PURPLE_CALLBACK(docklet_update_status_cb), NULL); | |
| 757 | purple_signal_connect(conv_handle, "deleting-conversation", | |
| 758 | docklet_handle, PURPLE_CALLBACK(docklet_update_status_cb), NULL); | |
| 759 | purple_signal_connect(conv_handle, "conversation-updated", | |
| 760 | 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
|
761 | 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
|
762 | docklet_handle, PURPLE_CALLBACK(docklet_update_status_cb), NULL); |
|
14745
d43256e1e6fd
[gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents:
14743
diff
changeset
|
763 | #if 0 |
| 15884 | 764 | purple_signal_connect(purple_get_core(), "quitting", |
| 765 | docklet_handle, PURPLE_CALLBACK(purple_quit_cb), NULL); | |
|
14745
d43256e1e6fd
[gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents:
14743
diff
changeset
|
766 | #endif |
| 14743 | 767 | |
| 768 | enable_join_chat = online_account_supports_chat(); | |
| 769 | } | |
| 770 | ||
| 771 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
772 | pidgin_docklet_uninit() |
| 14743 | 773 | { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
774 | if (visible && ui_ops && ui_ops->destroy) |
| 14743 | 775 | ui_ops->destroy(); |
| 776 | } |