annotate gtk/gtkdocklet.c @ 15006:56a12557520e

[gaim-migrate @ 17785] SF Patch 1571670, Patch 2 "I already have Welker Zsombor in the COPYRIGHTS file, but that should be Zsombor Welker... The patch I added is also needed to make the patch work under windows." committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Sun, 19 Nov 2006 20:40:34 +0000
parents 621e798f435c
children b188da596c46
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * System tray icon (aka docklet) plugin for Gaim
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * Copyright (C) 2002-3 Robert McQueen <robot101@debian.org>
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2003 Herman Bloggs <hermanator12002@yahoo.com>
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * Inspired by a similar plugin by:
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * John (J5) Palmieri <johnp@martianrock.com>
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 *
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * modify it under the terms of the GNU General Public License as
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * published by the Free Software Foundation; either version 2 of the
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * License, or (at your option) any later version.
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 *
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * General Public License for more details.
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 *
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 * 02111-1307, USA.
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 #include "internal.h"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include "gtkgaim.h"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "core.h"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "conversation.h"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "debug.h"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "prefs.h"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "signals.h"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "sound.h"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include "gtkaccount.h"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #include "gtkblist.h"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 #include "gtkconv.h"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 #include "gtkplugin.h"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 #include "gtkprefs.h"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 #include "gtksavedstatuses.h"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 #include "gtksound.h"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 #include "gtkutils.h"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 #include "gaimstock.h"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 #include "gtkdocklet.h"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 #include "gtkdialogs.h"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 #ifndef DOCKLET_TOOLTIP_LINE_LIMIT
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 #define DOCKLET_TOOLTIP_LINE_LIMIT 5
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 #endif
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 /* globals */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 static struct docklet_ui_ops *ui_ops = NULL;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 static DockletStatus status = DOCKLET_STATUS_OFFLINE;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 static gboolean enable_join_chat = FALSE;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 static guint docklet_blinking_timer = 0;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 static gboolean visibility_manager = FALSE;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 /**************************************************************************
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 * docklet status and utility functions
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 **************************************************************************/
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 static gboolean
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 docklet_blink_icon()
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 static gboolean blinked = FALSE;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 gboolean ret = FALSE; /* by default, don't keep blinking */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 blinked = !blinked;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 switch (status) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 case DOCKLET_STATUS_ONLINE_PENDING:
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 case DOCKLET_STATUS_AWAY_PENDING:
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 if (blinked) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 if (ui_ops && ui_ops->blank_icon)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 ui_ops->blank_icon();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 } else {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 if (ui_ops && ui_ops->update_icon)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 ui_ops->update_icon(status);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 ret = TRUE; /* keep blinking */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 break;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 default:
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 docklet_blinking_timer = 0;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 blinked = FALSE;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 break;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 return ret;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 static GList *
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 get_pending_list(guint max)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 GList *l_im = NULL;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 GList *l_chat = NULL;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94
14751
510da3975938 [gaim-migrate @ 17508]
Sean Egan <seanegan@gmail.com>
parents: 14683
diff changeset
95 l_im = gaim_gtk_conversations_find_unseen_list(GAIM_CONV_TYPE_IM,
510da3975938 [gaim-migrate @ 17508]
Sean Egan <seanegan@gmail.com>
parents: 14683
diff changeset
96 GAIM_UNSEEN_TEXT,
510da3975938 [gaim-migrate @ 17508]
Sean Egan <seanegan@gmail.com>
parents: 14683
diff changeset
97 FALSE, max);
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98
14751
510da3975938 [gaim-migrate @ 17508]
Sean Egan <seanegan@gmail.com>
parents: 14683
diff changeset
99 l_chat = gaim_gtk_conversations_find_unseen_list(GAIM_CONV_TYPE_CHAT,
510da3975938 [gaim-migrate @ 17508]
Sean Egan <seanegan@gmail.com>
parents: 14683
diff changeset
100 GAIM_UNSEEN_NICK,
510da3975938 [gaim-migrate @ 17508]
Sean Egan <seanegan@gmail.com>
parents: 14683
diff changeset
101 FALSE, max);
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 if (l_im != NULL && l_chat != NULL)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 return g_list_concat(l_im, l_chat);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 else if (l_im != NULL)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 return l_im;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 else
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 return l_chat;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 static gboolean
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 docklet_update_status()
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 {
14813
dd000ac4d148 [gaim-migrate @ 17579]
Sean Egan <seanegan@gmail.com>
parents: 14751
diff changeset
114 GList *convs = NULL;
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 GList *l;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 int count;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 DockletStatus newstatus = DOCKLET_STATUS_OFFLINE;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 gboolean pending = FALSE;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 /* determine if any ims have unseen messages */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 convs = get_pending_list(DOCKLET_TOOLTIP_LINE_LIMIT);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122
14873
3a23706f9f4b [gaim-migrate @ 17642]
Sean Egan <seanegan@gmail.com>
parents: 14813
diff changeset
123 if (!strcmp(gaim_prefs_get_string("/gaim/gtk/docklet/show"), "pending")) {
3a23706f9f4b [gaim-migrate @ 17642]
Sean Egan <seanegan@gmail.com>
parents: 14813
diff changeset
124 if (convs && ui_ops->create && !visibility_manager) {
3a23706f9f4b [gaim-migrate @ 17642]
Sean Egan <seanegan@gmail.com>
parents: 14813
diff changeset
125 ui_ops->create();
3a23706f9f4b [gaim-migrate @ 17642]
Sean Egan <seanegan@gmail.com>
parents: 14813
diff changeset
126 return FALSE;
3a23706f9f4b [gaim-migrate @ 17642]
Sean Egan <seanegan@gmail.com>
parents: 14813
diff changeset
127 } else if (!convs && ui_ops->destroy && visibility_manager) {
3a23706f9f4b [gaim-migrate @ 17642]
Sean Egan <seanegan@gmail.com>
parents: 14813
diff changeset
128 ui_ops->destroy();
3a23706f9f4b [gaim-migrate @ 17642]
Sean Egan <seanegan@gmail.com>
parents: 14813
diff changeset
129 return FALSE;
3a23706f9f4b [gaim-migrate @ 17642]
Sean Egan <seanegan@gmail.com>
parents: 14813
diff changeset
130 }
3a23706f9f4b [gaim-migrate @ 17642]
Sean Egan <seanegan@gmail.com>
parents: 14813
diff changeset
131 }
3a23706f9f4b [gaim-migrate @ 17642]
Sean Egan <seanegan@gmail.com>
parents: 14813
diff changeset
132
14885
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
133 if (!visibility_manager)
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
134 return FALSE;
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
135
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 if (convs != NULL) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 pending = TRUE;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 /* set tooltip if messages are pending */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 if (ui_ops->set_tooltip) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 GString *tooltip_text = g_string_new("");
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 for (l = convs, count = 0 ; l != NULL ; l = l->next, count++) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 if (GAIM_IS_GTK_CONVERSATION(l->data)) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION((GaimConversation *)l->data);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 if (count == DOCKLET_TOOLTIP_LINE_LIMIT - 1)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 g_string_append(tooltip_text, _("Right-click for more unread messages...\n"));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 else
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 g_string_append_printf(tooltip_text,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 ngettext("%d unread message from %s\n", "%d unread messages from %s\n", gtkconv->unseen_count),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 gtkconv->unseen_count,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 /* get rid of the last newline */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 if (tooltip_text->len > 0)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 tooltip_text = g_string_truncate(tooltip_text, tooltip_text->len - 1);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 ui_ops->set_tooltip(tooltip_text->str);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 g_string_free(tooltip_text, TRUE);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 g_list_free(convs);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 } else if (ui_ops->set_tooltip) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 ui_ops->set_tooltip(NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 /* iterate through all accounts and determine which
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 * status to show in the tray icon based on the following
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 * ranks (highest encountered rank will be used):
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 *
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 * 1) OFFLINE
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 * 2) ONLINE
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 * 3) ONLINE_PENDING
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 * 4) AWAY
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 * 5) AWAY_PENDING
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 * 6) CONNECTING
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 for(l = gaim_accounts_get_all(); l != NULL; l = l->next) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 DockletStatus tmpstatus = DOCKLET_STATUS_OFFLINE;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 GaimAccount *account = (GaimAccount*)l->data;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 GaimStatus *account_status;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 if (!gaim_account_get_enabled(account, GAIM_GTK_UI))
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 continue;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 if (gaim_account_is_disconnected(account))
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 continue;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 account_status = gaim_account_get_active_status(account);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 if (gaim_account_is_connecting(account)) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 tmpstatus = DOCKLET_STATUS_CONNECTING;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 } else if (gaim_status_is_online(account_status)) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 if (!gaim_status_is_available(account_status)) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 if (pending)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 tmpstatus = DOCKLET_STATUS_AWAY_PENDING;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 else
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 tmpstatus = DOCKLET_STATUS_AWAY;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 else {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 if (pending)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 tmpstatus = DOCKLET_STATUS_ONLINE_PENDING;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 else
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 tmpstatus = DOCKLET_STATUS_ONLINE;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 if (tmpstatus > newstatus)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 newstatus = tmpstatus;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 /* update the icon if we changed status */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 if (status != newstatus) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 status = newstatus;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 if (ui_ops && ui_ops->update_icon)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 ui_ops->update_icon(status);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 /* and schedule the blinker function if messages are pending */
14813
dd000ac4d148 [gaim-migrate @ 17579]
Sean Egan <seanegan@gmail.com>
parents: 14751
diff changeset
224 if (gaim_prefs_get_bool("/gaim/gtk/docklet/blink") &&
dd000ac4d148 [gaim-migrate @ 17579]
Sean Egan <seanegan@gmail.com>
parents: 14751
diff changeset
225 (status == DOCKLET_STATUS_ONLINE_PENDING
dd000ac4d148 [gaim-migrate @ 17579]
Sean Egan <seanegan@gmail.com>
parents: 14751
diff changeset
226 || status == DOCKLET_STATUS_AWAY_PENDING)
dd000ac4d148 [gaim-migrate @ 17579]
Sean Egan <seanegan@gmail.com>
parents: 14751
diff changeset
227 && docklet_blinking_timer == 0) {
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 docklet_blinking_timer = g_timeout_add(500, docklet_blink_icon, NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 return FALSE; /* for when we're called by the glib idle handler */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 static gboolean
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 online_account_supports_chat()
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 GList *c = NULL;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 c = gaim_connections_get_all();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 while(c != NULL) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 GaimConnection *gc = c->data;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 GaimPluginProtocolInfo *prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 if (prpl_info != NULL && prpl_info->chat_info != NULL)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 return TRUE;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 c = c->next;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 return FALSE;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 /**************************************************************************
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 * callbacks and signal handlers
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 **************************************************************************/
14683
a8c2af13b96d [gaim-migrate @ 17435]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14681
diff changeset
255 #if 0
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 gaim_quit_cb()
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 /* TODO: confirm quit while pending */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 }
14683
a8c2af13b96d [gaim-migrate @ 17435]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14681
diff changeset
261 #endif
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 docklet_update_status_cb(void *data)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 docklet_update_status();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 docklet_conv_updated_cb(GaimConversation *conv, GaimConvUpdateType type)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 if (type == GAIM_CONV_UPDATE_UNSEEN)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 docklet_update_status();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 docklet_signed_on_cb(GaimConnection *gc)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 if (!enable_join_chat) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 enable_join_chat = TRUE;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 docklet_update_status();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 docklet_signed_off_cb(GaimConnection *gc)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 if (enable_join_chat) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info != NULL)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291 enable_join_chat = online_account_supports_chat();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 docklet_update_status();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295
14885
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
296 static void
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
297 docklet_show_pref_changed_cb(const char *name, GaimPrefType type,
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
298 gconstpointer value, gpointer data)
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
299 {
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
300 const char *val = value;
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
301 if (!strcmp(val, "always")) {
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
302 if (!visibility_manager && ui_ops->create)
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
303 ui_ops->create();
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
304 } else if (!strcmp(val, "never")) {
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
305 if (visibility_manager && ui_ops->destroy)
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
306 ui_ops->destroy();
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
307 } else {
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
308 docklet_update_status();
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
309 }
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
310
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
311 }
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
312
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 /**************************************************************************
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314 * docklet pop-up menu
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 **************************************************************************/
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317 docklet_toggle_mute(GtkWidget *toggle, void *data)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 gaim_prefs_set_bool("/gaim/gtk/sound/mute", GTK_CHECK_MENU_ITEM(toggle)->active);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322 static void
14813
dd000ac4d148 [gaim-migrate @ 17579]
Sean Egan <seanegan@gmail.com>
parents: 14751
diff changeset
323 docklet_toggle_blink(GtkWidget *toggle, void *data)
dd000ac4d148 [gaim-migrate @ 17579]
Sean Egan <seanegan@gmail.com>
parents: 14751
diff changeset
324 {
dd000ac4d148 [gaim-migrate @ 17579]
Sean Egan <seanegan@gmail.com>
parents: 14751
diff changeset
325 gaim_prefs_set_bool("/gaim/gtk/docklet/blink", GTK_CHECK_MENU_ITEM(toggle)->active);
dd000ac4d148 [gaim-migrate @ 17579]
Sean Egan <seanegan@gmail.com>
parents: 14751
diff changeset
326 }
dd000ac4d148 [gaim-migrate @ 17579]
Sean Egan <seanegan@gmail.com>
parents: 14751
diff changeset
327
dd000ac4d148 [gaim-migrate @ 17579]
Sean Egan <seanegan@gmail.com>
parents: 14751
diff changeset
328 static void
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 docklet_toggle_blist(GtkWidget *toggle, void *data)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331 gaim_blist_set_visible(GTK_CHECK_MENU_ITEM(toggle)->active);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 #ifdef _WIN32
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 /* This is a workaround for a bug in windows GTK+. Clicking outside of the
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336 menu does not get rid of it, so instead we get rid of it as soon as the
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 pointer leaves the menu. */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 static gboolean
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 hide_docklet_menu(gpointer data)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 if (data != NULL) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 gtk_menu_popdown(GTK_MENU(data));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344 return FALSE;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 static gboolean
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 docklet_menu_leave_enter(GtkWidget *menu, GdkEventCrossing *event, void *data)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 static guint hide_docklet_timer = 0;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 if (event->type == GDK_LEAVE_NOTIFY && event->detail == GDK_NOTIFY_ANCESTOR) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 gaim_debug(GAIM_DEBUG_INFO, "docklet", "menu leave-notify-event\n");
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 /* Add some slop so that the menu doesn't annoyingly disappear when mousing around */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354 if (hide_docklet_timer == 0) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355 hide_docklet_timer = gaim_timeout_add(500,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 hide_docklet_menu, menu);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 } else if (event->type == GDK_ENTER_NOTIFY && event->detail == GDK_NOTIFY_ANCESTOR) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 gaim_debug(GAIM_DEBUG_INFO, "docklet", "menu enter-notify-event\n");
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360 if (hide_docklet_timer != 0) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 /* Cancel the hiding if we reenter */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 gaim_timeout_remove(hide_docklet_timer);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 hide_docklet_timer = 0;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 return FALSE;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 #endif
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372 show_custom_status_editor_cb(GtkMenuItem *menuitem, gpointer user_data)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 GaimSavedStatus *saved_status;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 saved_status = gaim_savedstatus_get_current();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376 gaim_gtk_status_editor_show(FALSE,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377 gaim_savedstatus_is_transient(saved_status) ? saved_status : NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381 activate_status_primitive_cb(GtkMenuItem *menuitem, gpointer user_data)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383 GaimStatusPrimitive primitive;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384 GaimSavedStatus *saved_status;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 primitive = GPOINTER_TO_INT(user_data);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388 /* Try to lookup an already existing transient saved status */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389 saved_status = gaim_savedstatus_find_transient_by_type_and_message(primitive, NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391 /* Create a new transient saved status if we weren't able to find one */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 if (saved_status == NULL)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393 saved_status = gaim_savedstatus_new(NULL, primitive);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 /* Set the status for each account */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 gaim_savedstatus_activate(saved_status);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 activate_saved_status_cb(GtkMenuItem *menuitem, gpointer user_data)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402 time_t creation_time;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403 GaimSavedStatus *saved_status;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
404
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
405 creation_time = GPOINTER_TO_INT(user_data);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406 saved_status = gaim_savedstatus_find_by_creation_time(creation_time);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407 if (saved_status != NULL)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408 gaim_savedstatus_activate(saved_status);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
410
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
411 static GtkWidget *
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
412 new_menu_item_with_gaim_icon(GtkWidget *menu, const char *str, GaimStatusPrimitive primitive, GtkSignalFunc sf, gpointer data, guint accel_key, guint accel_mods, char *mod)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 GtkWidget *menuitem;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415 GdkPixbuf *pixbuf;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416 GtkWidget *image;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418 menuitem = gtk_image_menu_item_new_with_mnemonic(str);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 if (menu)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423 if (sf)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424 g_signal_connect(G_OBJECT(menuitem), "activate", sf, data);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426 pixbuf = gaim_gtk_create_gaim_icon_with_status(primitive, 0.5);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
427 image = gtk_image_new_from_pixbuf(pixbuf);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
428 g_object_unref(pixbuf);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431 gtk_widget_show_all(menuitem);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
432
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433 return menuitem;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
434 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
435
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
436 static GtkWidget *
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437 docklet_status_submenu()
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
438 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439 GtkWidget *submenu, *menuitem;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440 GList *popular_statuses, *cur;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
441
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
442 submenu = gtk_menu_new();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
443 menuitem = gtk_menu_item_new_with_label(_("Change Status"));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
446 new_menu_item_with_gaim_icon(submenu, _("Available"),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447 GAIM_STATUS_AVAILABLE, G_CALLBACK(activate_status_primitive_cb),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
448 GINT_TO_POINTER(GAIM_STATUS_AVAILABLE), 0, 0, NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450 new_menu_item_with_gaim_icon(submenu, _("Away"),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
451 GAIM_STATUS_AWAY, G_CALLBACK(activate_status_primitive_cb),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452 GINT_TO_POINTER(GAIM_STATUS_AWAY), 0, 0, NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
453
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
454 new_menu_item_with_gaim_icon(submenu, _("Invisible"),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455 GAIM_STATUS_INVISIBLE, G_CALLBACK(activate_status_primitive_cb),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
456 GINT_TO_POINTER(GAIM_STATUS_INVISIBLE), 0, 0, NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458 new_menu_item_with_gaim_icon(submenu, _("Offline"),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 GAIM_STATUS_OFFLINE, G_CALLBACK(activate_status_primitive_cb),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
460 GINT_TO_POINTER(GAIM_STATUS_OFFLINE), 0, 0, NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
461
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
462 popular_statuses = gaim_savedstatuses_get_popular(6);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
463 if (popular_statuses != NULL)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
464 gaim_separator(submenu);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
465 for (cur = popular_statuses; cur != NULL; cur = cur->next)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
466 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
467 GaimSavedStatus *saved_status = cur->data;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
468 time_t creation_time = gaim_savedstatus_get_creation_time(saved_status);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
469 new_menu_item_with_gaim_icon(submenu,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470 gaim_savedstatus_get_title(saved_status),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471 gaim_savedstatus_get_type(saved_status), G_CALLBACK(activate_saved_status_cb),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
472 GINT_TO_POINTER(creation_time), 0, 0, NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
473 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
474 g_list_free(popular_statuses);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
476 gaim_separator(submenu);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
477
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478 new_menu_item_with_gaim_icon(submenu, _("New..."), GAIM_STATUS_AVAILABLE, G_CALLBACK(show_custom_status_editor_cb), NULL, 0, 0, NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
479 new_menu_item_with_gaim_icon(submenu, _("Saved..."), GAIM_STATUS_AVAILABLE, G_CALLBACK(gaim_gtk_status_window_show), NULL, 0, 0, NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 return menuitem;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
484 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
485 docklet_menu() {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
486 static GtkWidget *menu = NULL;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
487 GtkWidget *menuitem;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
488
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489 if (menu) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490 gtk_widget_destroy(menu);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
491 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
492
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493 menu = gtk_menu_new();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495 menuitem = gtk_check_menu_item_new_with_label(_("Show Buddy List"));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
496 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), gaim_prefs_get_bool("/gaim/gtk/blist/list_visible"));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
497 g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_blist), NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
498 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
500 menuitem = gtk_menu_item_new_with_label(_("Unread Messages"));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
502 if (status == DOCKLET_STATUS_ONLINE_PENDING || status == DOCKLET_STATUS_AWAY_PENDING) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
503 GtkWidget *submenu = gtk_menu_new();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504 GList *l = get_pending_list(0);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
505 if (l == NULL) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
506 gtk_widget_set_sensitive(menuitem, FALSE);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507 gaim_debug_warning("docklet",
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508 "status indicates messages pending, but no conversations with unseen messages were found.");
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509 } else {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
510 gaim_gtk_conversations_fill_menu(submenu, l);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511 g_list_free(l);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
512 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), submenu);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
513 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
514 } else {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
515 gtk_widget_set_sensitive(menuitem, FALSE);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
516 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
517 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
518
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
519 gaim_separator(menu);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
520
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
521 menuitem = gaim_new_item_from_stock(menu, _("New Message..."), GAIM_STOCK_IM, G_CALLBACK(gaim_gtkdialogs_im), NULL, 0, 0, NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
522 if (status == DOCKLET_STATUS_OFFLINE)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
523 gtk_widget_set_sensitive(menuitem, FALSE);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
524
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525 menuitem = docklet_status_submenu();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
526 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
528 gaim_separator(menu);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530 gaim_new_item_from_stock(menu, _("Accounts"), GAIM_STOCK_ACCOUNTS, G_CALLBACK(gaim_gtk_accounts_window_show), NULL, 0, 0, NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531 gaim_new_item_from_stock(menu, _("Plugins"), GAIM_STOCK_PLUGIN, G_CALLBACK(gaim_gtk_plugin_dialog_show), NULL, 0, 0, NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
532 gaim_new_item_from_stock(menu, _("Preferences"), GTK_STOCK_PREFERENCES, G_CALLBACK(gaim_gtk_prefs_show), NULL, 0, 0, NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
534 gaim_separator(menu);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
535
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
536 menuitem = gtk_check_menu_item_new_with_label(_("Mute Sounds"));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
537 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), gaim_prefs_get_bool("/gaim/gtk/sound/mute"));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
538 if (!strcmp(gaim_prefs_get_string("/gaim/gtk/sound/method"), "none"))
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
539 gtk_widget_set_sensitive(GTK_WIDGET(menuitem), FALSE);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
540 g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_mute), NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
541 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
14813
dd000ac4d148 [gaim-migrate @ 17579]
Sean Egan <seanegan@gmail.com>
parents: 14751
diff changeset
542
dd000ac4d148 [gaim-migrate @ 17579]
Sean Egan <seanegan@gmail.com>
parents: 14751
diff changeset
543 menuitem = gtk_check_menu_item_new_with_label(_("Blink on new message"));
dd000ac4d148 [gaim-migrate @ 17579]
Sean Egan <seanegan@gmail.com>
parents: 14751
diff changeset
544 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), gaim_prefs_get_bool("/gaim/gtk/docklet/blink"));
dd000ac4d148 [gaim-migrate @ 17579]
Sean Egan <seanegan@gmail.com>
parents: 14751
diff changeset
545 g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_blink), NULL);
dd000ac4d148 [gaim-migrate @ 17579]
Sean Egan <seanegan@gmail.com>
parents: 14751
diff changeset
546 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548 gaim_separator(menu);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
549
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
550 /* TODO: need a submenu to change status, this needs to "link"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
551 * to the status in the buddy list gtkstatusbox
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
552 */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
553
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
554 gaim_new_item_from_stock(menu, _("Quit"), GTK_STOCK_QUIT, G_CALLBACK(gaim_core_quit), NULL, 0, 0, NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
555
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
556 #ifdef _WIN32
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
557 g_signal_connect(menu, "leave-notify-event", G_CALLBACK(docklet_menu_leave_enter), NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
558 g_signal_connect(menu, "enter-notify-event", G_CALLBACK(docklet_menu_leave_enter), NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
559 #endif
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
560 gtk_widget_show_all(menu);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
561 gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
562 ui_ops->position_menu,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
563 NULL, 0, gtk_get_current_event_time());
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
564 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
566 /**************************************************************************
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
567 * public api for ui_ops
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
568 **************************************************************************/
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
569 void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
570 gaim_gtk_docklet_clicked(int button_type)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
571 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
572 switch (button_type) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
573 case 1:
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
574 if (status == DOCKLET_STATUS_ONLINE_PENDING || status == DOCKLET_STATUS_AWAY_PENDING) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
575 GList *l = get_pending_list(1);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
576 if (l != NULL) {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
577 gaim_gtkconv_present_conversation((GaimConversation *)l->data);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
578 g_list_free(l);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
579 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
580 } else {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
581 gaim_gtk_blist_toggle_visibility();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
582 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
583 break;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
584 case 3:
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
585 docklet_menu();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
586 break;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
587 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
588 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
589
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
590 void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
591 gaim_gtk_docklet_embedded()
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
592 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
593 if (!visibility_manager) {
14873
3a23706f9f4b [gaim-migrate @ 17642]
Sean Egan <seanegan@gmail.com>
parents: 14813
diff changeset
594 if (strcmp(gaim_prefs_get_string("/gaim/gtk/docklet/show"),"pending"))
3a23706f9f4b [gaim-migrate @ 17642]
Sean Egan <seanegan@gmail.com>
parents: 14813
diff changeset
595 gaim_gtk_blist_visibility_manager_add();
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
596 visibility_manager = TRUE;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
597 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
598 docklet_update_status();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
599 if (ui_ops && ui_ops->update_icon)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
600 ui_ops->update_icon(status);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
601 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
602
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
603 void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
604 gaim_gtk_docklet_remove()
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
605 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
606 if (visibility_manager) {
14892
621e798f435c [gaim-migrate @ 17664]
Sean Egan <seanegan@gmail.com>
parents: 14885
diff changeset
607 if (strcmp(gaim_prefs_get_string("/gaim/gtk/docklet/show"),"pending"))
621e798f435c [gaim-migrate @ 17664]
Sean Egan <seanegan@gmail.com>
parents: 14885
diff changeset
608 gaim_gtk_blist_visibility_manager_remove();
14873
3a23706f9f4b [gaim-migrate @ 17642]
Sean Egan <seanegan@gmail.com>
parents: 14813
diff changeset
609 if (docklet_blinking_timer) {
3a23706f9f4b [gaim-migrate @ 17642]
Sean Egan <seanegan@gmail.com>
parents: 14813
diff changeset
610 g_source_remove(docklet_blinking_timer);
3a23706f9f4b [gaim-migrate @ 17642]
Sean Egan <seanegan@gmail.com>
parents: 14813
diff changeset
611 docklet_blinking_timer = 0;
3a23706f9f4b [gaim-migrate @ 17642]
Sean Egan <seanegan@gmail.com>
parents: 14813
diff changeset
612 }
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
613 visibility_manager = FALSE;
14873
3a23706f9f4b [gaim-migrate @ 17642]
Sean Egan <seanegan@gmail.com>
parents: 14813
diff changeset
614 status = DOCKLET_STATUS_OFFLINE;
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
615 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
616 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
617
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
618 void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
619 gaim_gtk_docklet_set_ui_ops(struct docklet_ui_ops *ops)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
620 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
621 ui_ops = ops;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
622 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
623
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
624 void*
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
625 gaim_gtk_docklet_get_handle()
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
626 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
627 static int i;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
628 return &i;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
629 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
630
14683
a8c2af13b96d [gaim-migrate @ 17435]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14681
diff changeset
631 void
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
632 gaim_gtk_docklet_init()
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
633 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
634 void *conn_handle = gaim_connections_get_handle();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
635 void *conv_handle = gaim_conversations_get_handle();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
636 void *accounts_handle = gaim_accounts_get_handle();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
637 void *docklet_handle = gaim_gtk_docklet_get_handle();
14813
dd000ac4d148 [gaim-migrate @ 17579]
Sean Egan <seanegan@gmail.com>
parents: 14751
diff changeset
638
dd000ac4d148 [gaim-migrate @ 17579]
Sean Egan <seanegan@gmail.com>
parents: 14751
diff changeset
639 gaim_prefs_add_none("/gaim/gtk/docklet");
dd000ac4d148 [gaim-migrate @ 17579]
Sean Egan <seanegan@gmail.com>
parents: 14751
diff changeset
640 gaim_prefs_add_bool("/gaim/gtk/docklet/blink", FALSE);
dd000ac4d148 [gaim-migrate @ 17579]
Sean Egan <seanegan@gmail.com>
parents: 14751
diff changeset
641 gaim_prefs_add_string("/gaim/gtk/docklet/show", "always");
14885
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
642 gaim_prefs_connect_callback(docklet_handle, "/gaim/gtk/docklet/show",
51c51d89c114 [gaim-migrate @ 17654]
Sean Egan <seanegan@gmail.com>
parents: 14873
diff changeset
643 docklet_show_pref_changed_cb, NULL);
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
644
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
645 docklet_ui_init();
14873
3a23706f9f4b [gaim-migrate @ 17642]
Sean Egan <seanegan@gmail.com>
parents: 14813
diff changeset
646 if (!strcmp(gaim_prefs_get_string("/gaim/gtk/docklet/show"), "always") && ui_ops && ui_ops->create)
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
647 ui_ops->create();
14873
3a23706f9f4b [gaim-migrate @ 17642]
Sean Egan <seanegan@gmail.com>
parents: 14813
diff changeset
648
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
649 gaim_signal_connect(conn_handle, "signed-on",
14683
a8c2af13b96d [gaim-migrate @ 17435]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14681
diff changeset
650 docklet_handle, GAIM_CALLBACK(docklet_signed_on_cb), NULL);
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
651 gaim_signal_connect(conn_handle, "signed-off",
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
652 docklet_handle, GAIM_CALLBACK(docklet_signed_off_cb), NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
653 gaim_signal_connect(accounts_handle, "account-status-changed",
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
654 docklet_handle, GAIM_CALLBACK(docklet_update_status_cb), NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
655 gaim_signal_connect(conv_handle, "received-im-msg",
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
656 docklet_handle, GAIM_CALLBACK(docklet_update_status_cb), NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
657 gaim_signal_connect(conv_handle, "conversation-created",
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
658 docklet_handle, GAIM_CALLBACK(docklet_update_status_cb), NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
659 gaim_signal_connect(conv_handle, "deleting-conversation",
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
660 docklet_handle, GAIM_CALLBACK(docklet_update_status_cb), NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
661 gaim_signal_connect(conv_handle, "conversation-updated",
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
662 docklet_handle, GAIM_CALLBACK(docklet_conv_updated_cb), NULL);
14683
a8c2af13b96d [gaim-migrate @ 17435]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14681
diff changeset
663 #if 0
a8c2af13b96d [gaim-migrate @ 17435]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14681
diff changeset
664 gaim_signal_connect(gaim_get_core(), "quitting",
a8c2af13b96d [gaim-migrate @ 17435]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14681
diff changeset
665 docklet_handle, GAIM_CALLBACK(gaim_quit_cb), NULL);
a8c2af13b96d [gaim-migrate @ 17435]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14681
diff changeset
666 #endif
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
667
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
668 enable_join_chat = online_account_supports_chat();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
669 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
670
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
671 void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
672 gaim_gtk_docklet_uninit()
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
673 {
14873
3a23706f9f4b [gaim-migrate @ 17642]
Sean Egan <seanegan@gmail.com>
parents: 14813
diff changeset
674 if (visibility_manager && ui_ops && ui_ops->destroy)
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
675 ui_ops->destroy();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
676 }