Wed, 29 Nov 2017 21:13:54 +0100
Use gtk_status_icon_get_icon_name instead of a new boolean variable
| 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" | |
|
21011
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
41 | #include "gtkstatusbox.h" |
| 14743 | 42 | #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
|
43 | #include "pidginstock.h" |
| 14743 | 44 | #include "gtkdocklet.h" |
| 45 | #include "gtkdialogs.h" | |
| 46 | ||
| 47 | #ifndef DOCKLET_TOOLTIP_LINE_LIMIT | |
| 48 | #define DOCKLET_TOOLTIP_LINE_LIMIT 5 | |
| 49 | #endif | |
| 50 | ||
| 51 | /* globals */ | |
| 52 | 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
|
53 | 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
|
54 | 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
|
55 | static gboolean connecting = FALSE; |
| 14743 | 56 | static gboolean enable_join_chat = FALSE; |
| 57 | static guint docklet_blinking_timer = 0; | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
58 | static gboolean visible = FALSE; |
| 14743 | 59 | static gboolean visibility_manager = FALSE; |
| 60 | ||
| 61 | /************************************************************************** | |
| 62 | * docklet status and utility functions | |
| 63 | **************************************************************************/ | |
| 64 | static gboolean | |
|
22108
cb9819851163
Squash some compiler warnings, some from my -Wstrict-prototypes fixing.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
65 | docklet_blink_icon(gpointer data) |
| 14743 | 66 | { |
| 67 | static gboolean blinked = FALSE; | |
| 68 | gboolean ret = FALSE; /* by default, don't keep blinking */ | |
| 69 | ||
| 70 | blinked = !blinked; | |
| 71 | ||
|
38821
329cf2453fb8
Rework tray icon blinking
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
38259
diff
changeset
|
72 | if (pending) { |
|
329cf2453fb8
Rework tray icon blinking
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
38259
diff
changeset
|
73 | if (ui_ops && ui_ops->blank_icon) { |
|
329cf2453fb8
Rework tray icon blinking
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
38259
diff
changeset
|
74 | if (blinked) { |
|
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
|
75 | ui_ops->blank_icon(); |
|
38821
329cf2453fb8
Rework tray icon blinking
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
38259
diff
changeset
|
76 | } else { |
|
38823
0839fbcfb9b4
Use gtk_status_icon_get_icon_name instead of a new boolean variable
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
38821
diff
changeset
|
77 | pidgin_docklet_update_icon(); |
|
38821
329cf2453fb8
Rework tray icon blinking
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
38259
diff
changeset
|
78 | } |
|
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
|
79 | } else { |
|
38823
0839fbcfb9b4
Use gtk_status_icon_get_icon_name instead of a new boolean variable
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
38821
diff
changeset
|
80 | pidgin_docklet_update_icon(); |
|
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
|
81 | } |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
82 | 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
|
83 | } 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
|
84 | 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
|
85 | blinked = FALSE; |
|
38823
0839fbcfb9b4
Use gtk_status_icon_get_icon_name instead of a new boolean variable
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
38821
diff
changeset
|
86 | pidgin_docklet_update_icon(); |
| 14743 | 87 | } |
| 88 | ||
| 89 | return ret; | |
| 90 | } | |
| 91 | ||
| 92 | static GList * | |
| 93 | get_pending_list(guint max) | |
| 94 | { | |
|
25585
694a25f1eaf4
This small optimization has been sitting in my tree for a long time.
Daniel Atallah <datallah@pidgin.im>
parents:
25584
diff
changeset
|
95 | GList *l_im, *l_chat; |
| 14743 | 96 | |
| 15884 | 97 | 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
|
98 | PIDGIN_UNSEEN_TEXT, |
|
14813
c24dda7fb69e
[gaim-migrate @ 17508]
Casey Harkins <charkins@pidgin.im>
parents:
14745
diff
changeset
|
99 | FALSE, max); |
| 14743 | 100 | |
|
25585
694a25f1eaf4
This small optimization has been sitting in my tree for a long time.
Daniel Atallah <datallah@pidgin.im>
parents:
25584
diff
changeset
|
101 | /* Short circuit if we have our information already */ |
|
694a25f1eaf4
This small optimization has been sitting in my tree for a long time.
Daniel Atallah <datallah@pidgin.im>
parents:
25584
diff
changeset
|
102 | if (max == 1 && l_im != NULL) |
|
694a25f1eaf4
This small optimization has been sitting in my tree for a long time.
Daniel Atallah <datallah@pidgin.im>
parents:
25584
diff
changeset
|
103 | return l_im; |
|
694a25f1eaf4
This small optimization has been sitting in my tree for a long time.
Daniel Atallah <datallah@pidgin.im>
parents:
25584
diff
changeset
|
104 | |
| 15884 | 105 | 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
|
106 | PIDGIN_UNSEEN_NICK, |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
107 | FALSE, max); |
| 14743 | 108 | |
| 109 | if (l_im != NULL && l_chat != NULL) | |
| 110 | return g_list_concat(l_im, l_chat); | |
| 111 | else if (l_im != NULL) | |
| 112 | return l_im; | |
| 113 | else | |
| 114 | return l_chat; | |
| 115 | } | |
| 116 | ||
| 117 | static gboolean | |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
21453
diff
changeset
|
118 | docklet_update_status(void) |
| 14743 | 119 | { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
120 | GList *convs, *l; |
| 14743 | 121 | int count; |
| 15884 | 122 | 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
|
123 | 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
|
124 | gboolean newpending = FALSE, newconnecting = FALSE; |
| 14743 | 125 | |
|
16681
c15974a4ff5d
Patch from charkins in ticket #198 to fulfill a feature request by hbons:
Richard Laager <rlaager@pidgin.im>
parents:
16263
diff
changeset
|
126 | /* 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
|
127 | 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
|
128 | |
| 14743 | 129 | /* determine if any ims have unseen messages */ |
| 130 | convs = get_pending_list(DOCKLET_TOOLTIP_LINE_LIMIT); | |
| 131 | ||
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
33782
diff
changeset
|
132 | if (purple_strequal(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/docklet/show"), "pending")) { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
133 | if (convs && ui_ops->create && !visible) { |
|
15075
2bd60dbd8877
[gaim-migrate @ 17794]
Daniel Atallah <datallah@pidgin.im>
parents:
14954
diff
changeset
|
134 | g_list_free(convs); |
|
2bd60dbd8877
[gaim-migrate @ 17794]
Daniel Atallah <datallah@pidgin.im>
parents:
14954
diff
changeset
|
135 | ui_ops->create(); |
|
2bd60dbd8877
[gaim-migrate @ 17794]
Daniel Atallah <datallah@pidgin.im>
parents:
14954
diff
changeset
|
136 | return FALSE; |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
137 | } else if (!convs && ui_ops->destroy && visible) { |
|
15075
2bd60dbd8877
[gaim-migrate @ 17794]
Daniel Atallah <datallah@pidgin.im>
parents:
14954
diff
changeset
|
138 | ui_ops->destroy(); |
|
2bd60dbd8877
[gaim-migrate @ 17794]
Daniel Atallah <datallah@pidgin.im>
parents:
14954
diff
changeset
|
139 | return FALSE; |
| 14935 | 140 | } |
| 141 | } | |
| 142 | ||
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
143 | if (!visible) { |
|
15075
2bd60dbd8877
[gaim-migrate @ 17794]
Daniel Atallah <datallah@pidgin.im>
parents:
14954
diff
changeset
|
144 | g_list_free(convs); |
| 14947 | 145 | return FALSE; |
|
15075
2bd60dbd8877
[gaim-migrate @ 17794]
Daniel Atallah <datallah@pidgin.im>
parents:
14954
diff
changeset
|
146 | } |
| 14947 | 147 | |
| 14743 | 148 | 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
|
149 | newpending = TRUE; |
| 14743 | 150 | |
| 151 | /* set tooltip if messages are pending */ | |
| 152 | if (ui_ops->set_tooltip) { | |
| 153 | GString *tooltip_text = g_string_new(""); | |
| 154 | for (l = convs, count = 0 ; l != NULL ; l = l->next, count++) { | |
|
21022
eb7d727949e7
Handle unattached conversations appropriately when drawing tooltip for
Casey Harkins <charkins@pidgin.im>
parents:
21014
diff
changeset
|
155 | PurpleConversation *conv = (PurpleConversation *)l->data; |
|
eb7d727949e7
Handle unattached conversations appropriately when drawing tooltip for
Casey Harkins <charkins@pidgin.im>
parents:
21014
diff
changeset
|
156 | PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); |
|
eb7d727949e7
Handle unattached conversations appropriately when drawing tooltip for
Casey Harkins <charkins@pidgin.im>
parents:
21014
diff
changeset
|
157 | |
|
eb7d727949e7
Handle unattached conversations appropriately when drawing tooltip for
Casey Harkins <charkins@pidgin.im>
parents:
21014
diff
changeset
|
158 | if (count == DOCKLET_TOOLTIP_LINE_LIMIT - 1) { |
|
eb7d727949e7
Handle unattached conversations appropriately when drawing tooltip for
Casey Harkins <charkins@pidgin.im>
parents:
21014
diff
changeset
|
159 | g_string_append(tooltip_text, _("Right-click for more unread messages...\n")); |
|
eb7d727949e7
Handle unattached conversations appropriately when drawing tooltip for
Casey Harkins <charkins@pidgin.im>
parents:
21014
diff
changeset
|
160 | } else if(gtkconv) { |
|
eb7d727949e7
Handle unattached conversations appropriately when drawing tooltip for
Casey Harkins <charkins@pidgin.im>
parents:
21014
diff
changeset
|
161 | g_string_append_printf(tooltip_text, |
|
eb7d727949e7
Handle unattached conversations appropriately when drawing tooltip for
Casey Harkins <charkins@pidgin.im>
parents:
21014
diff
changeset
|
162 | ngettext("%d unread message from %s\n", "%d unread messages from %s\n", gtkconv->unseen_count), |
|
eb7d727949e7
Handle unattached conversations appropriately when drawing tooltip for
Casey Harkins <charkins@pidgin.im>
parents:
21014
diff
changeset
|
163 | gtkconv->unseen_count, |
|
21056
356b2a5f4d21
Use the conversation title for unread message tooltips. Fixes #3557.
Casey Harkins <charkins@pidgin.im>
parents:
21022
diff
changeset
|
164 | purple_conversation_get_title(conv)); |
|
21022
eb7d727949e7
Handle unattached conversations appropriately when drawing tooltip for
Casey Harkins <charkins@pidgin.im>
parents:
21014
diff
changeset
|
165 | } else { |
|
eb7d727949e7
Handle unattached conversations appropriately when drawing tooltip for
Casey Harkins <charkins@pidgin.im>
parents:
21014
diff
changeset
|
166 | g_string_append_printf(tooltip_text, |
|
eb7d727949e7
Handle unattached conversations appropriately when drawing tooltip for
Casey Harkins <charkins@pidgin.im>
parents:
21014
diff
changeset
|
167 | ngettext("%d unread message from %s\n", "%d unread messages from %s\n", |
|
eb7d727949e7
Handle unattached conversations appropriately when drawing tooltip for
Casey Harkins <charkins@pidgin.im>
parents:
21014
diff
changeset
|
168 | GPOINTER_TO_INT(purple_conversation_get_data(conv, "unseen-count"))), |
|
eb7d727949e7
Handle unattached conversations appropriately when drawing tooltip for
Casey Harkins <charkins@pidgin.im>
parents:
21014
diff
changeset
|
169 | GPOINTER_TO_INT(purple_conversation_get_data(conv, "unseen-count")), |
|
21056
356b2a5f4d21
Use the conversation title for unread message tooltips. Fixes #3557.
Casey Harkins <charkins@pidgin.im>
parents:
21022
diff
changeset
|
170 | purple_conversation_get_title(conv)); |
| 14743 | 171 | } |
| 172 | } | |
| 173 | ||
| 174 | /* get rid of the last newline */ | |
| 175 | if (tooltip_text->len > 0) | |
| 176 | tooltip_text = g_string_truncate(tooltip_text, tooltip_text->len - 1); | |
| 177 | ||
| 178 | ui_ops->set_tooltip(tooltip_text->str); | |
| 179 | ||
| 180 | g_string_free(tooltip_text, TRUE); | |
| 181 | } | |
| 182 | ||
| 183 | g_list_free(convs); | |
| 184 | ||
| 185 | } 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
|
186 | 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
|
187 | 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
|
188 | 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
|
189 | g_free(tooltip_text); |
| 14743 | 190 | } |
| 191 | ||
| 15884 | 192 | for(l = purple_accounts_get_all(); l != NULL; l = l->next) { |
| 14743 | 193 | |
| 15884 | 194 | PurpleAccount *account = (PurpleAccount*)l->data; |
| 14743 | 195 | |
| 15884 | 196 | if (!purple_account_get_enabled(account, PIDGIN_UI)) |
| 14743 | 197 | continue; |
| 198 | ||
| 15884 | 199 | if (purple_account_is_disconnected(account)) |
| 14743 | 200 | continue; |
| 201 | ||
| 15884 | 202 | 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
|
203 | newconnecting = TRUE; |
| 14743 | 204 | } |
|
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
|
205 | |
|
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
|
206 | 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
|
207 | |
| 14743 | 208 | /* 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
|
209 | if (status != newstatus || pending!=newpending || connecting!=newconnecting) { |
| 14743 | 210 | 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
|
211 | 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
|
212 | connecting = newconnecting; |
| 14743 | 213 | |
|
38823
0839fbcfb9b4
Use gtk_status_icon_get_icon_name instead of a new boolean variable
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
38821
diff
changeset
|
214 | pidgin_docklet_update_icon(); |
| 14743 | 215 | |
| 216 | /* 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
|
217 | 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
|
218 | && pending && !connecting && docklet_blinking_timer == 0) { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
219 | docklet_blinking_timer = g_timeout_add(500, docklet_blink_icon, NULL); |
| 14743 | 220 | } |
| 221 | } | |
| 222 | ||
| 223 | return FALSE; /* for when we're called by the glib idle handler */ | |
| 224 | } | |
| 225 | ||
| 226 | static gboolean | |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
21453
diff
changeset
|
227 | online_account_supports_chat(void) |
| 14743 | 228 | { |
| 229 | GList *c = NULL; | |
| 15884 | 230 | c = purple_connections_get_all(); |
| 14743 | 231 | |
| 232 | while(c != NULL) { | |
| 15884 | 233 | PurpleConnection *gc = c->data; |
| 234 | PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
| 14743 | 235 | if (prpl_info != NULL && prpl_info->chat_info != NULL) |
| 236 | return TRUE; | |
| 237 | c = c->next; | |
| 238 | } | |
| 239 | ||
| 240 | return FALSE; | |
| 241 | } | |
| 242 | ||
| 243 | /************************************************************************** | |
| 244 | * callbacks and signal handlers | |
| 245 | **************************************************************************/ | |
|
14745
d43256e1e6fd
[gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents:
14743
diff
changeset
|
246 | #if 0 |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
247 | static void |
| 15882 | 248 | pidgin_quit_cb() |
| 14743 | 249 | { |
| 250 | /* TODO: confirm quit while pending */ | |
| 251 | } | |
|
14745
d43256e1e6fd
[gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents:
14743
diff
changeset
|
252 | #endif |
| 14743 | 253 | |
| 254 | static void | |
| 255 | docklet_update_status_cb(void *data) | |
| 256 | { | |
| 257 | docklet_update_status(); | |
| 258 | } | |
| 259 | ||
| 260 | static void | |
| 15884 | 261 | docklet_conv_updated_cb(PurpleConversation *conv, PurpleConvUpdateType type) |
| 14743 | 262 | { |
| 15884 | 263 | if (type == PURPLE_CONV_UPDATE_UNSEEN) |
| 14743 | 264 | docklet_update_status(); |
| 265 | } | |
| 266 | ||
| 267 | static void | |
| 15884 | 268 | docklet_signed_on_cb(PurpleConnection *gc) |
| 14743 | 269 | { |
| 270 | if (!enable_join_chat) { | |
| 15884 | 271 | if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) |
| 14743 | 272 | enable_join_chat = TRUE; |
| 273 | } | |
| 274 | docklet_update_status(); | |
| 275 | } | |
| 276 | ||
| 277 | static void | |
| 15884 | 278 | docklet_signed_off_cb(PurpleConnection *gc) |
| 14743 | 279 | { |
| 280 | if (enable_join_chat) { | |
| 15884 | 281 | if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL) |
| 14743 | 282 | enable_join_chat = online_account_supports_chat(); |
| 283 | } | |
| 284 | docklet_update_status(); | |
| 285 | } | |
| 286 | ||
| 14947 | 287 | static void |
| 15884 | 288 | docklet_show_pref_changed_cb(const char *name, PurplePrefType type, |
| 14947 | 289 | gconstpointer value, gpointer data) |
| 290 | { | |
| 291 | const char *val = value; | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
33782
diff
changeset
|
292 | if (purple_strequal(val, "always")) { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
293 | if (ui_ops->create) { |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
294 | if (!visible) |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
295 | ui_ops->create(); |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
296 | else if (!visibility_manager) { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
297 | pidgin_blist_visibility_manager_add(); |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
298 | visibility_manager = TRUE; |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
299 | } |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
300 | } |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
33782
diff
changeset
|
301 | } else if (purple_strequal(val, "never")) { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
302 | if (visible && ui_ops->destroy) |
| 14947 | 303 | ui_ops->destroy(); |
| 304 | } else { | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
305 | if (visibility_manager) { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
306 | pidgin_blist_visibility_manager_remove(); |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
307 | visibility_manager = FALSE; |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
308 | } |
| 14947 | 309 | docklet_update_status(); |
| 310 | } | |
|
15075
2bd60dbd8877
[gaim-migrate @ 17794]
Daniel Atallah <datallah@pidgin.im>
parents:
14954
diff
changeset
|
311 | |
| 14947 | 312 | } |
| 313 | ||
| 14743 | 314 | /************************************************************************** |
| 315 | * docklet pop-up menu | |
| 316 | **************************************************************************/ | |
| 317 | static void | |
| 318 | docklet_toggle_mute(GtkWidget *toggle, void *data) | |
| 319 | { | |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
320 | purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/sound/mute", GTK_CHECK_MENU_ITEM(toggle)->active); |
| 14743 | 321 | } |
| 322 | ||
| 323 | static void | |
| 14875 | 324 | docklet_toggle_blink(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 "/docklet/blink", GTK_CHECK_MENU_ITEM(toggle)->active); |
| 14875 | 327 | } |
| 328 | ||
| 329 | static void | |
| 14743 | 330 | docklet_toggle_blist(GtkWidget *toggle, void *data) |
| 331 | { | |
| 15884 | 332 | purple_blist_set_visible(GTK_CHECK_MENU_ITEM(toggle)->active); |
| 14743 | 333 | } |
| 334 | ||
| 335 | #ifdef _WIN32 | |
| 336 | /* This is a workaround for a bug in windows GTK+. Clicking outside of the | |
| 337 | menu does not get rid of it, so instead we get rid of it as soon as the | |
| 338 | pointer leaves the menu. */ | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
339 | static gboolean |
| 14743 | 340 | hide_docklet_menu(gpointer data) |
| 341 | { | |
| 342 | if (data != NULL) { | |
| 343 | gtk_menu_popdown(GTK_MENU(data)); | |
| 344 | } | |
| 345 | return FALSE; | |
| 346 | } | |
| 347 | ||
| 348 | static gboolean | |
| 349 | docklet_menu_leave_enter(GtkWidget *menu, GdkEventCrossing *event, void *data) | |
| 350 | { | |
| 351 | static guint hide_docklet_timer = 0; | |
|
25584
be42c007cce2
Fix from "oopepe" to make menus more reliably responsive.
Daniel Atallah <datallah@pidgin.im>
parents:
23848
diff
changeset
|
352 | |
|
be42c007cce2
Fix from "oopepe" to make menus more reliably responsive.
Daniel Atallah <datallah@pidgin.im>
parents:
23848
diff
changeset
|
353 | if (event->type == GDK_LEAVE_NOTIFY && (event->detail == GDK_NOTIFY_ANCESTOR || |
|
be42c007cce2
Fix from "oopepe" to make menus more reliably responsive.
Daniel Atallah <datallah@pidgin.im>
parents:
23848
diff
changeset
|
354 | event->detail == GDK_NOTIFY_UNKNOWN)) { |
| 15884 | 355 | purple_debug(PURPLE_DEBUG_INFO, "docklet", "menu leave-notify-event\n"); |
| 14743 | 356 | /* Add some slop so that the menu doesn't annoyingly disappear when mousing around */ |
| 357 | if (hide_docklet_timer == 0) { | |
| 15884 | 358 | hide_docklet_timer = purple_timeout_add(500, |
| 14743 | 359 | hide_docklet_menu, menu); |
| 360 | } | |
| 361 | } else if (event->type == GDK_ENTER_NOTIFY && event->detail == GDK_NOTIFY_ANCESTOR) { | |
| 15884 | 362 | purple_debug(PURPLE_DEBUG_INFO, "docklet", "menu enter-notify-event\n"); |
| 14743 | 363 | if (hide_docklet_timer != 0) { |
| 364 | /* Cancel the hiding if we reenter */ | |
| 365 | ||
| 15884 | 366 | purple_timeout_remove(hide_docklet_timer); |
| 14743 | 367 | hide_docklet_timer = 0; |
| 368 | } | |
| 369 | } | |
| 370 | return FALSE; | |
| 371 | } | |
| 372 | #endif | |
| 373 | ||
|
21011
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
374 | /* There is a lot of code here for handling the status submenu, much of |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
375 | * which is duplicated from the gtkstatusbox. It'd be nice to add API |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
376 | * somewhere to simplify this (either in the statusbox, or in libpurple). |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
377 | */ |
| 14743 | 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 | ||
|
21011
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
391 | static PurpleSavedStatus * |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
392 | create_transient_status(PurpleStatusPrimitive primitive, PurpleStatusType *status_type) |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
393 | { |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
394 | PurpleSavedStatus *saved_status = purple_savedstatus_new(NULL, primitive); |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
395 | |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
396 | if(status_type != NULL) { |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
397 | GList *tmp, *active_accts = purple_accounts_get_all_active(); |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
398 | for (tmp = active_accts; tmp != NULL; tmp = tmp->next) { |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
399 | purple_savedstatus_set_substatus(saved_status, |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
400 | (PurpleAccount*) tmp->data, status_type, NULL); |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
401 | } |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
402 | g_list_free(active_accts); |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
403 | } |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
404 | |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
405 | return saved_status; |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
406 | } |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
407 | |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
408 | static void |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
409 | activate_status_account_cb(GtkMenuItem *menuitem, gpointer user_data) |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
410 | { |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
411 | PurpleStatusType *status_type; |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
412 | PurpleStatusPrimitive primitive; |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
413 | PurpleSavedStatus *saved_status = NULL; |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
414 | GList *iter = purple_savedstatuses_get_all(); |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
415 | GList *tmp, *active_accts = purple_accounts_get_all_active(); |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
416 | |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
417 | status_type = (PurpleStatusType *)user_data; |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
418 | primitive = purple_status_type_get_primitive(status_type); |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
419 | |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
420 | for (; iter != NULL; iter = iter->next) { |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
421 | PurpleSavedStatus *ss = iter->data; |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
422 | if ((purple_savedstatus_get_type(ss) == primitive) && purple_savedstatus_is_transient(ss) && |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
423 | purple_savedstatus_has_substatuses(ss)) |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
424 | { |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
425 | gboolean found = FALSE; |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
426 | /* The currently enabled accounts must have substatuses for all the active accts */ |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
427 | for(tmp = active_accts; tmp != NULL; tmp = tmp->next) { |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
428 | PurpleAccount *acct = tmp->data; |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
429 | PurpleSavedStatusSub *sub = purple_savedstatus_get_substatus(ss, acct); |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
430 | if (sub) { |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
431 | const PurpleStatusType *sub_type = purple_savedstatus_substatus_get_type(sub); |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
432 | const char *subtype_status_id = purple_status_type_get_id(sub_type); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
33782
diff
changeset
|
433 | if (subtype_status_id && purple_strequal(subtype_status_id, |
|
21011
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
434 | purple_status_type_get_id(status_type))) |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
435 | found = TRUE; |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
436 | } |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
437 | } |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
438 | if (!found) |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
439 | continue; |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
440 | saved_status = ss; |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
441 | break; |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
442 | } |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
443 | } |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
444 | |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
445 | g_list_free(active_accts); |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
446 | |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
447 | /* Create a new transient saved status if we weren't able to find one */ |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
448 | if (saved_status == NULL) |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
449 | saved_status = create_transient_status(primitive, status_type); |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
450 | |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
451 | /* Set the status for each account */ |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
452 | purple_savedstatus_activate(saved_status); |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
453 | } |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
454 | |
| 14743 | 455 | static void |
| 456 | activate_status_primitive_cb(GtkMenuItem *menuitem, gpointer user_data) | |
| 457 | { | |
| 15884 | 458 | PurpleStatusPrimitive primitive; |
| 459 | PurpleSavedStatus *saved_status; | |
| 14743 | 460 | |
| 461 | primitive = GPOINTER_TO_INT(user_data); | |
| 462 | ||
| 463 | /* Try to lookup an already existing transient saved status */ | |
| 15884 | 464 | saved_status = purple_savedstatus_find_transient_by_type_and_message(primitive, NULL); |
| 14743 | 465 | |
| 466 | /* Create a new transient saved status if we weren't able to find one */ | |
| 467 | if (saved_status == NULL) | |
|
21011
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
468 | saved_status = create_transient_status(primitive, NULL); |
| 14743 | 469 | |
| 470 | /* Set the status for each account */ | |
| 15884 | 471 | purple_savedstatus_activate(saved_status); |
| 14743 | 472 | } |
| 473 | ||
| 474 | static void | |
| 475 | activate_saved_status_cb(GtkMenuItem *menuitem, gpointer user_data) | |
| 476 | { | |
| 477 | time_t creation_time; | |
| 15884 | 478 | PurpleSavedStatus *saved_status; |
| 14743 | 479 | |
| 480 | creation_time = GPOINTER_TO_INT(user_data); | |
| 15884 | 481 | saved_status = purple_savedstatus_find_by_creation_time(creation_time); |
| 14743 | 482 | if (saved_status != NULL) |
| 15884 | 483 | purple_savedstatus_activate(saved_status); |
| 14743 | 484 | } |
| 485 | ||
| 486 | static GtkWidget * | |
|
26821
ad2ea323d0f2
Replace the deprecated GtkSignalFunc and GTK_SIGNAL_FUNC with GCallback and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25585
diff
changeset
|
487 | new_menu_item_with_status_icon(GtkWidget *menu, const char *str, PurpleStatusPrimitive primitive, GCallback cb, gpointer data, guint accel_key, guint accel_mods, char *mod) |
| 14743 | 488 | { |
| 489 | GtkWidget *menuitem; | |
| 490 | GdkPixbuf *pixbuf; | |
| 491 | GtkWidget *image; | |
| 492 | ||
|
20953
e39a56e1b461
Patch from QuLogic to not use underscores in saved-statuses as mnemonics
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
20380
diff
changeset
|
493 | menuitem = gtk_image_menu_item_new_with_label(str); |
| 14743 | 494 | |
| 495 | if (menu) | |
| 496 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 497 | ||
|
26821
ad2ea323d0f2
Replace the deprecated GtkSignalFunc and GTK_SIGNAL_FUNC with GCallback and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25585
diff
changeset
|
498 | if (cb) |
|
ad2ea323d0f2
Replace the deprecated GtkSignalFunc and GTK_SIGNAL_FUNC with GCallback and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25585
diff
changeset
|
499 | g_signal_connect(G_OBJECT(menuitem), "activate", cb, data); |
| 14743 | 500 | |
|
15799
ba7af742a0d1
Change some old, busted status icon stuff to use the new hotness
Sean Egan <seanegan@pidgin.im>
parents:
15766
diff
changeset
|
501 | pixbuf = pidgin_create_status_icon(primitive, menu, PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); |
| 14743 | 502 | image = gtk_image_new_from_pixbuf(pixbuf); |
| 503 | g_object_unref(pixbuf); | |
| 504 | gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); | |
| 505 | ||
| 506 | gtk_widget_show_all(menuitem); | |
| 507 | ||
| 508 | return menuitem; | |
| 509 | } | |
| 510 | ||
|
21011
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
511 | static void |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
512 | add_account_statuses(GtkWidget *menu, PurpleAccount *account) |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
513 | { |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
514 | GList *l; |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
515 | |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
516 | for (l = purple_account_get_status_types(account); l != NULL; l = l->next) { |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
517 | PurpleStatusType *status_type = (PurpleStatusType *)l->data; |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
518 | PurpleStatusPrimitive prim; |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
519 | |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
520 | if (!purple_status_type_is_user_settable(status_type)) |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
521 | continue; |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
522 | |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
523 | prim = purple_status_type_get_primitive(status_type); |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
524 | |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
525 | new_menu_item_with_status_icon(menu, |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
526 | purple_status_type_get_name(status_type), |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
527 | prim, G_CALLBACK(activate_status_account_cb), |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
528 | status_type, 0, 0, NULL); |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
529 | } |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
530 | } |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
531 | |
| 14743 | 532 | static GtkWidget * |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
21453
diff
changeset
|
533 | docklet_status_submenu(void) |
| 14743 | 534 | { |
| 535 | GtkWidget *submenu, *menuitem; | |
| 536 | GList *popular_statuses, *cur; | |
|
21011
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
537 | PidginStatusBox *statusbox = NULL; |
| 14743 | 538 | |
| 539 | submenu = gtk_menu_new(); | |
|
23343
397c4abd815a
A patch from Kevin Wu Won to add mnemonics to the docklet menu.
Kevin Wu Won <exclipy@gmail.com>
parents:
22108
diff
changeset
|
540 | menuitem = gtk_menu_item_new_with_mnemonic(_("_Change Status")); |
| 14743 | 541 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); |
| 542 | ||
|
21011
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
543 | if(pidgin_blist_get_default_gtk_blist() != NULL) { |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
544 | statusbox = PIDGIN_STATUS_BOX(pidgin_blist_get_default_gtk_blist()->statusbox); |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
545 | } |
| 14743 | 546 | |
|
21011
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
547 | if(statusbox && statusbox->account != NULL) { |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
548 | add_account_statuses(submenu, statusbox->account); |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
549 | } else if(statusbox && statusbox->token_status_account != NULL) { |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
550 | add_account_statuses(submenu, statusbox->token_status_account); |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
551 | } else { |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
552 | new_menu_item_with_status_icon(submenu, _("Available"), |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
553 | PURPLE_STATUS_AVAILABLE, G_CALLBACK(activate_status_primitive_cb), |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
554 | GINT_TO_POINTER(PURPLE_STATUS_AVAILABLE), 0, 0, NULL); |
| 14743 | 555 | |
|
21011
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
556 | new_menu_item_with_status_icon(submenu, _("Away"), |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
557 | PURPLE_STATUS_AWAY, G_CALLBACK(activate_status_primitive_cb), |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
558 | GINT_TO_POINTER(PURPLE_STATUS_AWAY), 0, 0, NULL); |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
559 | |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
560 | new_menu_item_with_status_icon(submenu, _("Do not disturb"), |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
561 | PURPLE_STATUS_UNAVAILABLE, G_CALLBACK(activate_status_primitive_cb), |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
562 | GINT_TO_POINTER(PURPLE_STATUS_UNAVAILABLE), 0, 0, NULL); |
| 14743 | 563 | |
|
21011
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
564 | new_menu_item_with_status_icon(submenu, _("Invisible"), |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
565 | PURPLE_STATUS_INVISIBLE, G_CALLBACK(activate_status_primitive_cb), |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
566 | GINT_TO_POINTER(PURPLE_STATUS_INVISIBLE), 0, 0, NULL); |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
567 | |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
568 | new_menu_item_with_status_icon(submenu, _("Offline"), |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
569 | PURPLE_STATUS_OFFLINE, G_CALLBACK(activate_status_primitive_cb), |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
570 | GINT_TO_POINTER(PURPLE_STATUS_OFFLINE), 0, 0, NULL); |
|
0b21b3224a68
Make sure that the "Change Status" submenu in the docklet context menu
Casey Harkins <charkins@pidgin.im>
parents:
20960
diff
changeset
|
571 | } |
| 14743 | 572 | |
| 15884 | 573 | popular_statuses = purple_savedstatuses_get_popular(6); |
| 14743 | 574 | if (popular_statuses != NULL) |
| 15568 | 575 | pidgin_separator(submenu); |
| 14743 | 576 | for (cur = popular_statuses; cur != NULL; cur = cur->next) |
| 577 | { | |
| 15884 | 578 | PurpleSavedStatus *saved_status = cur->data; |
| 579 | time_t creation_time = purple_savedstatus_get_creation_time(saved_status); | |
| 15882 | 580 | new_menu_item_with_status_icon(submenu, |
| 15884 | 581 | purple_savedstatus_get_title(saved_status), |
| 582 | purple_savedstatus_get_type(saved_status), G_CALLBACK(activate_saved_status_cb), | |
| 14743 | 583 | GINT_TO_POINTER(creation_time), 0, 0, NULL); |
| 584 | } | |
| 585 | g_list_free(popular_statuses); | |
| 586 | ||
| 15568 | 587 | pidgin_separator(submenu); |
| 14743 | 588 | |
|
16960
6d97980fed84
Telcontar on #pidgin-win32 pointed out that the "New..." and "Saved..."
Casey Harkins <charkins@pidgin.im>
parents:
16918
diff
changeset
|
589 | 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
|
590 | pidgin_new_item_from_stock(submenu, _("Saved..."), NULL, G_CALLBACK(pidgin_status_window_show), NULL, 0, 0, NULL); |
| 14743 | 591 | |
| 592 | return menuitem; | |
| 593 | } | |
| 594 | ||
|
20959
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
595 | |
|
20960
b0c77b970912
merge of 'e39a56e1b46110397f5043f21bb86f8cd920012d'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
diff
changeset
|
596 | |
|
20959
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
597 | 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
|
598 | 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
|
599 | { |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
600 | 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
|
601 | 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
|
602 | } |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
603 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
604 | 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
|
605 | 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
|
606 | 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
|
607 | { |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
608 | 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
|
609 | 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
|
610 | 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
|
611 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
612 | 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
|
613 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
614 | 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
|
615 | { |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
616 | 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
|
617 | { |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
618 | 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
|
619 | 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
|
620 | 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
|
621 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
622 | 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
|
623 | 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
|
624 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
625 | 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
|
626 | 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
|
627 | 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
|
628 | action, |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
629 | (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
|
630 | 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
|
631 | } |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
632 | else |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
633 | 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
|
634 | } |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
635 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
636 | 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
|
637 | } |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
638 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
639 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
640 | 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
|
641 | 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
|
642 | { |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
643 | 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
|
644 | 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
|
645 | 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
|
646 | 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
|
647 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
648 | 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
|
649 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
650 | /* 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
|
651 | 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
|
652 | 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
|
653 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
654 | 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
|
655 | continue; |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
656 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
657 | 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
|
658 | continue; |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
659 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
660 | 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
|
661 | 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
|
662 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
663 | 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
|
664 | 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
|
665 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
666 | 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
|
667 | |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
668 | c++; |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
669 | } |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
670 | 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
|
671 | 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
|
672 | } |
|
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
673 | |
| 14743 | 674 | static void |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
21453
diff
changeset
|
675 | docklet_menu(void) |
|
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
21453
diff
changeset
|
676 | { |
| 14743 | 677 | static GtkWidget *menu = NULL; |
| 678 | GtkWidget *menuitem; | |
| 679 | ||
| 680 | if (menu) { | |
| 681 | gtk_widget_destroy(menu); | |
| 682 | } | |
| 683 | ||
| 684 | menu = gtk_menu_new(); | |
| 685 | ||
|
23344
edd0045bf715
Changes to the docklet mnemonics patch to make them more consistent with
Richard Laager <rlaager@pidgin.im>
parents:
23343
diff
changeset
|
686 | menuitem = gtk_check_menu_item_new_with_mnemonic(_("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
|
687 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/list_visible")); |
| 14743 | 688 | g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_blist), NULL); |
| 689 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 690 | ||
|
23343
397c4abd815a
A patch from Kevin Wu Won to add mnemonics to the docklet menu.
Kevin Wu Won <exclipy@gmail.com>
parents:
22108
diff
changeset
|
691 | menuitem = gtk_menu_item_new_with_mnemonic(_("_Unread Messages")); |
| 14743 | 692 | |
|
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
|
693 | if (pending) { |
| 14743 | 694 | GtkWidget *submenu = gtk_menu_new(); |
| 695 | GList *l = get_pending_list(0); | |
| 696 | if (l == NULL) { | |
| 697 | gtk_widget_set_sensitive(menuitem, FALSE); | |
| 15884 | 698 | purple_debug_warning("docklet", |
| 14743 | 699 | "status indicates messages pending, but no conversations with unseen messages were found."); |
| 700 | } else { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
701 | pidgin_conversations_fill_menu(submenu, l); |
| 14743 | 702 | g_list_free(l); |
| 703 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu); | |
| 704 | } | |
| 705 | } else { | |
| 706 | gtk_widget_set_sensitive(menuitem, FALSE); | |
| 707 | } | |
| 708 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 709 | ||
| 15568 | 710 | pidgin_separator(menu); |
| 14743 | 711 | |
|
23344
edd0045bf715
Changes to the docklet mnemonics patch to make them more consistent with
Richard Laager <rlaager@pidgin.im>
parents:
23343
diff
changeset
|
712 | 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
|
713 | if (status == PURPLE_STATUS_OFFLINE) |
| 14743 | 714 | gtk_widget_set_sensitive(menuitem, FALSE); |
| 715 | ||
|
23848
d017d45e3dcf
Add menuitem for 'join chat' in the docklet menu. Closes #3623.
Balwinder S Dheeman <bsd@rubyforge.org>
parents:
23344
diff
changeset
|
716 | menuitem = pidgin_new_item_from_stock(menu, _("Join Chat..."), PIDGIN_STOCK_CHAT, |
|
d017d45e3dcf
Add menuitem for 'join chat' in the docklet menu. Closes #3623.
Balwinder S Dheeman <bsd@rubyforge.org>
parents:
23344
diff
changeset
|
717 | G_CALLBACK(pidgin_blist_joinchat_show), NULL, 0, 0, NULL); |
|
d017d45e3dcf
Add menuitem for 'join chat' in the docklet menu. Closes #3623.
Balwinder S Dheeman <bsd@rubyforge.org>
parents:
23344
diff
changeset
|
718 | if (status == PURPLE_STATUS_OFFLINE) |
|
d017d45e3dcf
Add menuitem for 'join chat' in the docklet menu. Closes #3623.
Balwinder S Dheeman <bsd@rubyforge.org>
parents:
23344
diff
changeset
|
719 | gtk_widget_set_sensitive(menuitem, FALSE); |
|
d017d45e3dcf
Add menuitem for 'join chat' in the docklet menu. Closes #3623.
Balwinder S Dheeman <bsd@rubyforge.org>
parents:
23344
diff
changeset
|
720 | |
| 14743 | 721 | menuitem = docklet_status_submenu(); |
| 722 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 723 | ||
| 15568 | 724 | pidgin_separator(menu); |
| 14743 | 725 | |
|
23343
397c4abd815a
A patch from Kevin Wu Won to add mnemonics to the docklet menu.
Kevin Wu Won <exclipy@gmail.com>
parents:
22108
diff
changeset
|
726 | pidgin_new_item_from_stock(menu, _("_Accounts"), NULL, G_CALLBACK(pidgin_accounts_window_show), NULL, 0, 0, NULL); |
|
397c4abd815a
A patch from Kevin Wu Won to add mnemonics to the docklet menu.
Kevin Wu Won <exclipy@gmail.com>
parents:
22108
diff
changeset
|
727 | pidgin_new_item_from_stock(menu, _("Plu_gins"), PIDGIN_STOCK_TOOLBAR_PLUGINS, G_CALLBACK(pidgin_plugin_dialog_show), NULL, 0, 0, NULL); |
|
23344
edd0045bf715
Changes to the docklet mnemonics patch to make them more consistent with
Richard Laager <rlaager@pidgin.im>
parents:
23343
diff
changeset
|
728 | pidgin_new_item_from_stock(menu, _("Pr_eferences"), GTK_STOCK_PREFERENCES, G_CALLBACK(pidgin_prefs_show), NULL, 0, 0, NULL); |
| 14743 | 729 | |
| 15568 | 730 | pidgin_separator(menu); |
| 14743 | 731 | |
|
23344
edd0045bf715
Changes to the docklet mnemonics patch to make them more consistent with
Richard Laager <rlaager@pidgin.im>
parents:
23343
diff
changeset
|
732 | menuitem = gtk_check_menu_item_new_with_mnemonic(_("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
|
733 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/sound/mute")); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
33782
diff
changeset
|
734 | if (purple_strequal(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/sound/method"), "none")) |
| 14743 | 735 | gtk_widget_set_sensitive(GTK_WIDGET(menuitem), FALSE); |
| 736 | g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_mute), NULL); | |
| 737 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
738 | |
|
23343
397c4abd815a
A patch from Kevin Wu Won to add mnemonics to the docklet menu.
Kevin Wu Won <exclipy@gmail.com>
parents:
22108
diff
changeset
|
739 | menuitem = gtk_check_menu_item_new_with_mnemonic(_("_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
|
740 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/docklet/blink")); |
| 14875 | 741 | g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_blink), NULL); |
| 742 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 14743 | 743 | |
| 15568 | 744 | pidgin_separator(menu); |
| 14743 | 745 | |
|
20959
8ccaaaec1b01
Add plugin actions to the docklet context menu. These are the same actions
Casey Harkins <charkins@pidgin.im>
parents:
20380
diff
changeset
|
746 | /* 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
|
747 | 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
|
748 | |
|
23343
397c4abd815a
A patch from Kevin Wu Won to add mnemonics to the docklet menu.
Kevin Wu Won <exclipy@gmail.com>
parents:
22108
diff
changeset
|
749 | pidgin_new_item_from_stock(menu, _("_Quit"), GTK_STOCK_QUIT, G_CALLBACK(purple_core_quit), NULL, 0, 0, NULL); |
| 14743 | 750 | |
| 751 | #ifdef _WIN32 | |
| 752 | g_signal_connect(menu, "leave-notify-event", G_CALLBACK(docklet_menu_leave_enter), NULL); | |
| 753 | g_signal_connect(menu, "enter-notify-event", G_CALLBACK(docklet_menu_leave_enter), NULL); | |
| 754 | #endif | |
| 755 | gtk_widget_show_all(menu); | |
| 756 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
757 | ui_ops->position_menu, |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
758 | NULL, 0, gtk_get_current_event_time()); |
| 14743 | 759 | } |
| 760 | ||
| 761 | /************************************************************************** | |
| 762 | * public api for ui_ops | |
| 763 | **************************************************************************/ | |
| 764 | void | |
|
38823
0839fbcfb9b4
Use gtk_status_icon_get_icon_name instead of a new boolean variable
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
38821
diff
changeset
|
765 | pidgin_docklet_update_icon() |
|
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
|
766 | { |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
767 | if (ui_ops && ui_ops->update_icon) |
|
38823
0839fbcfb9b4
Use gtk_status_icon_get_icon_name instead of a new boolean variable
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
38821
diff
changeset
|
768 | ui_ops->update_icon(status, connecting, 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
|
769 | } |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
770 | |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16977
diff
changeset
|
771 | void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
772 | pidgin_docklet_clicked(int button_type) |
| 14743 | 773 | { |
| 774 | switch (button_type) { | |
| 775 | 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
|
776 | if (pending) { |
| 14743 | 777 | GList *l = get_pending_list(1); |
| 778 | if (l != NULL) { | |
|
21022
eb7d727949e7
Handle unattached conversations appropriately when drawing tooltip for
Casey Harkins <charkins@pidgin.im>
parents:
21014
diff
changeset
|
779 | pidgin_conv_present_conversation((PurpleConversation *)l->data); |
| 14743 | 780 | g_list_free(l); |
| 781 | } | |
| 782 | } else { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
783 | pidgin_blist_toggle_visibility(); |
| 14743 | 784 | } |
| 785 | break; | |
| 786 | case 3: | |
| 787 | docklet_menu(); | |
| 788 | break; | |
| 789 | } | |
| 790 | } | |
| 791 | ||
| 792 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
793 | pidgin_docklet_embedded() |
| 14743 | 794 | { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
795 | if (!visibility_manager |
|
38259
c593fc9f5438
Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
38258
diff
changeset
|
796 | && !purple_strequal(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
|
797 | pidgin_blist_visibility_manager_add(); |
| 14743 | 798 | visibility_manager = TRUE; |
| 799 | } | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
800 | visible = TRUE; |
| 14743 | 801 | docklet_update_status(); |
|
38823
0839fbcfb9b4
Use gtk_status_icon_get_icon_name instead of a new boolean variable
Daniel Kamil Kozar <dkk089@gmail.com>
parents:
38821
diff
changeset
|
802 | pidgin_docklet_update_icon(); |
| 14743 | 803 | } |
| 804 | ||
| 805 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
806 | pidgin_docklet_remove() |
| 14743 | 807 | { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
808 | if (visible) { |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
809 | if (visibility_manager) { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
810 | pidgin_blist_visibility_manager_remove(); |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
811 | visibility_manager = FALSE; |
|
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
812 | } |
| 14935 | 813 | if (docklet_blinking_timer) { |
| 814 | g_source_remove(docklet_blinking_timer); | |
| 815 | docklet_blinking_timer = 0; | |
| 816 | } | |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
817 | 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
|
818 | status = PURPLE_STATUS_OFFLINE; |
| 14743 | 819 | } |
| 820 | } | |
| 821 | ||
| 822 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
823 | pidgin_docklet_set_ui_ops(struct docklet_ui_ops *ops) |
| 14743 | 824 | { |
| 825 | ui_ops = ops; | |
| 826 | } | |
| 827 | ||
| 828 | void* | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
829 | pidgin_docklet_get_handle() |
| 14743 | 830 | { |
| 831 | static int i; | |
| 832 | return &i; | |
| 833 | } | |
| 834 | ||
|
14745
d43256e1e6fd
[gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents:
14743
diff
changeset
|
835 | void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
836 | pidgin_docklet_init() |
| 14743 | 837 | { |
| 15884 | 838 | void *conn_handle = purple_connections_get_handle(); |
| 839 | void *conv_handle = purple_conversations_get_handle(); | |
| 840 | 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
|
841 | void *status_handle = purple_savedstatuses_get_handle(); |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
842 | void *docklet_handle = pidgin_docklet_get_handle(); |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
843 | |
|
16123
8b98683319e7
Rename /purple/gtk preferences back to /gaim/gtk to allow for smooth upgrades
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
844 | 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
|
845 | 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
|
846 | 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
|
847 | purple_prefs_connect_callback(docklet_handle, PIDGIN_PREFS_ROOT "/docklet/show", |
| 14947 | 848 | docklet_show_pref_changed_cb, NULL); |
| 14743 | 849 | |
| 850 | docklet_ui_init(); | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
33782
diff
changeset
|
851 | if (purple_strequal(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/docklet/show"), "always") && ui_ops && ui_ops->create) |
| 14743 | 852 | ui_ops->create(); |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
853 | |
| 15884 | 854 | purple_signal_connect(conn_handle, "signed-on", |
| 855 | docklet_handle, PURPLE_CALLBACK(docklet_signed_on_cb), NULL); | |
| 856 | purple_signal_connect(conn_handle, "signed-off", | |
| 857 | 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
|
858 | purple_signal_connect(accounts_handle, "account-connecting", |
| 15884 | 859 | docklet_handle, PURPLE_CALLBACK(docklet_update_status_cb), NULL); |
| 860 | purple_signal_connect(conv_handle, "received-im-msg", | |
| 861 | docklet_handle, PURPLE_CALLBACK(docklet_update_status_cb), NULL); | |
| 862 | purple_signal_connect(conv_handle, "conversation-created", | |
| 863 | docklet_handle, PURPLE_CALLBACK(docklet_update_status_cb), NULL); | |
| 864 | purple_signal_connect(conv_handle, "deleting-conversation", | |
| 865 | docklet_handle, PURPLE_CALLBACK(docklet_update_status_cb), NULL); | |
| 866 | purple_signal_connect(conv_handle, "conversation-updated", | |
| 867 | 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
|
868 | 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
|
869 | docklet_handle, PURPLE_CALLBACK(docklet_update_status_cb), NULL); |
|
14745
d43256e1e6fd
[gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents:
14743
diff
changeset
|
870 | #if 0 |
| 15884 | 871 | purple_signal_connect(purple_get_core(), "quitting", |
| 872 | docklet_handle, PURPLE_CALLBACK(purple_quit_cb), NULL); | |
|
14745
d43256e1e6fd
[gaim-migrate @ 17435]
Daniel Atallah <datallah@pidgin.im>
parents:
14743
diff
changeset
|
873 | #endif |
| 14743 | 874 | |
| 875 | enable_join_chat = online_account_supports_chat(); | |
| 876 | } | |
| 877 | ||
| 878 | void | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
879 | pidgin_docklet_uninit() |
| 14743 | 880 | { |
|
15077
38a44f14dd35
[gaim-migrate @ 17797]
Daniel Atallah <datallah@pidgin.im>
parents:
15075
diff
changeset
|
881 | if (visible && ui_ops && ui_ops->destroy) |
| 14743 | 882 | ui_ops->destroy(); |
| 883 | } |