annotate plugins/docklet/docklet.c @ 5920:7d385de2f9cd

[gaim-migrate @ 6360] Sean likes to make fun of me because I had static vars that had __ prepended, which is a violation of ANSI standards apparently. So, that's fixed. Oh, and Sean.. *I* broke 0.64! Nyaa! committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Wed, 18 Jun 2003 06:01:15 +0000
parents dbe2a2174be9
children 5239a3b4ab33
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4093
987624dcece4 [gaim-migrate @ 4308]
Luke Schierer <lschiere@pidgin.im>
parents: 3939
diff changeset
1 /* System tray icon (aka docklet) plugin for Gaim
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * Copyright (C) 2002 Robert McQueen <robot101@debian.org>
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 * Inspired by a similar plugin by:
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * John (J5) Palmieri <johnp@martianrock.com>
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation; either version 2 of the
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 *
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful, but
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * General Public License for more details.
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 *
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * 02111-1307, USA.
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 */
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 /* todo (in order of importance):
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
23 - unify the queue so we can have a global away without the dialog
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
24 - handle and update tooltips to show your current accounts/queued messages?
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
25 - show a count of queued messages in the unified queue
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 - dernyi's account status menu in the right click
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
27 - optional pop up notices when GNOME2's system-tray-applet supports it */
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 /* includes */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
30 #include "internal.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
31
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
32 #include "debug.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
33 #include "prefs.h"
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4491
diff changeset
34 #include "sound.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
35
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
36 #include "gtkaccount.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
37 #include "gtkblist.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
38 #include "gtkft.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
39 #include "gtkplugin.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
40 #include "gtkprefs.h"
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5669
diff changeset
41 #include "gtksound.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
42 #include "gtkutils.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
43 #include "stock.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
44
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 #include "eggtrayicon.h"
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
47 #include "gaim.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
48 #include "ui.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
49
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
50 #define DOCKLET_PLUGIN_ID "gtk-docklet"
3867
43e396e94095 [gaim-migrate @ 4019]
Rob Flynn <gaim@robflynn.com>
parents: 3773
diff changeset
51
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 /* types */
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 enum docklet_status {
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
54 offline,
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
55 offline_connecting,
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 online,
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
57 online_connecting,
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
58 online_pending,
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 away,
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
60 away_pending
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 };
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 /* functions */
4093
987624dcece4 [gaim-migrate @ 4308]
Luke Schierer <lschiere@pidgin.im>
parents: 3939
diff changeset
64 static gboolean docklet_create();
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
65 static gboolean docklet_update_status();
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
66 static gboolean plugin_unload(GaimPlugin *plugin);
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 /* globals */
3513
ab939e746bdd [gaim-migrate @ 3585]
Luke Schierer <lschiere@pidgin.im>
parents: 3512
diff changeset
69 static EggTrayIcon *docklet = NULL;
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
70 static GtkWidget *image = NULL;
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 static enum docklet_status status;
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
72 static enum docklet_status icon;
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73
3554
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
74 static void docklet_toggle_mute(GtkWidget *toggle, void *data) {
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5669
diff changeset
75 gaim_gtk_sound_set_mute(GTK_CHECK_MENU_ITEM(toggle)->active);
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77
5554
7b36d02031a2 [gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents: 5530
diff changeset
78 static void docklet_set_bool(GtkWidget *widget, const char *key) {
7b36d02031a2 [gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents: 5530
diff changeset
79 gaim_prefs_set_bool(key, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)));
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 }
3570
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
81
5905
dbe2a2174be9 [gaim-migrate @ 6337]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
82 static void docklet_auto_login() {
dbe2a2174be9 [gaim-migrate @ 6337]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
83 gaim_accounts_auto_login(GAIM_GTK_UI);
dbe2a2174be9 [gaim-migrate @ 6337]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
84 }
dbe2a2174be9 [gaim-migrate @ 6337]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
85
3554
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
86 static void docklet_flush_queue() {
3570
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
87 if (unread_message_queue) {
4274
906f61f27479 [gaim-migrate @ 4525]
Luke Schierer <lschiere@pidgin.im>
parents: 4261
diff changeset
88 purge_away_queue(&unread_message_queue);
3570
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
89 }
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 static void docklet_menu(GdkEventButton *event) {
3513
ab939e746bdd [gaim-migrate @ 3585]
Luke Schierer <lschiere@pidgin.im>
parents: 3512
diff changeset
93 static GtkWidget *menu = NULL;
3512
1ea341091de8 [gaim-migrate @ 3584]
Luke Schierer <lschiere@pidgin.im>
parents: 3510
diff changeset
94 GtkWidget *entry;
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 if (menu) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 gtk_widget_destroy(menu);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 menu = gtk_menu_new();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
102 switch (status) {
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
103 case offline:
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
104 case offline_connecting:
5905
dbe2a2174be9 [gaim-migrate @ 6337]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
105 gaim_new_item_from_stock(menu, _("Auto-login"), GAIM_STOCK_SIGN_ON, G_CALLBACK(docklet_auto_login), NULL, 0, 0, NULL);
4567
493f050dc11a [gaim-migrate @ 4848]
Sean Egan <seanegan@gmail.com>
parents: 4561
diff changeset
106 break;
493f050dc11a [gaim-migrate @ 4848]
Sean Egan <seanegan@gmail.com>
parents: 4561
diff changeset
107 default:
5024
8e55a4d362a3 [gaim-migrate @ 5361]
Sean Egan <seanegan@gmail.com>
parents: 4840
diff changeset
108 gaim_new_item_from_stock(menu, _("New Message.."), GAIM_STOCK_IM, G_CALLBACK(show_im_dialog), NULL, 0, 0, NULL);
8e55a4d362a3 [gaim-migrate @ 5361]
Sean Egan <seanegan@gmail.com>
parents: 4840
diff changeset
109 gaim_new_item_from_stock(menu, _("Join A Chat..."), GAIM_STOCK_CHAT, G_CALLBACK(join_chat), NULL, 0, 0, NULL);
4567
493f050dc11a [gaim-migrate @ 4848]
Sean Egan <seanegan@gmail.com>
parents: 4561
diff changeset
110 break;
493f050dc11a [gaim-migrate @ 4848]
Sean Egan <seanegan@gmail.com>
parents: 4561
diff changeset
111 }
493f050dc11a [gaim-migrate @ 4848]
Sean Egan <seanegan@gmail.com>
parents: 4561
diff changeset
112
493f050dc11a [gaim-migrate @ 4848]
Sean Egan <seanegan@gmail.com>
parents: 4561
diff changeset
113 switch (status) {
493f050dc11a [gaim-migrate @ 4848]
Sean Egan <seanegan@gmail.com>
parents: 4561
diff changeset
114 case offline:
493f050dc11a [gaim-migrate @ 4848]
Sean Egan <seanegan@gmail.com>
parents: 4561
diff changeset
115 case offline_connecting:
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
116 break;
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
117 case online:
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
118 case online_connecting:
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
119 case online_pending: {
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 GtkWidget *docklet_awaymenu;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 GSList *awy = NULL;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 struct away_message *a = NULL;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 docklet_awaymenu = gtk_menu_new();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 awy = away_messages;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 while (awy) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 a = (struct away_message *)awy->data;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 entry = gtk_menu_item_new_with_label(a->name);
3554
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
131 g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(do_away_message), a);
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4606
diff changeset
132 gtk_menu_shell_append(GTK_MENU_SHELL(docklet_awaymenu), entry);
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 awy = g_slist_next(awy);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
137 if (away_messages)
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
138 gaim_separator(docklet_awaymenu);
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 entry = gtk_menu_item_new_with_label(_("New..."));
3554
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
141 g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(create_away_mess), NULL);
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4606
diff changeset
142 gtk_menu_shell_append(GTK_MENU_SHELL(docklet_awaymenu), entry);
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 entry = gtk_menu_item_new_with_label(_("Away"));
3512
1ea341091de8 [gaim-migrate @ 3584]
Luke Schierer <lschiere@pidgin.im>
parents: 3510
diff changeset
145 gtk_menu_item_set_submenu(GTK_MENU_ITEM(entry), docklet_awaymenu);
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4606
diff changeset
146 gtk_menu_shell_append(GTK_MENU_SHELL(menu), entry);
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
147 } break;
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
148 case away:
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
149 case away_pending:
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 entry = gtk_menu_item_new_with_label(_("Back"));
3554
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
151 g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(do_im_back), NULL);
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4606
diff changeset
152 gtk_menu_shell_append(GTK_MENU_SHELL(menu), entry);
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
153 break;
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155
4567
493f050dc11a [gaim-migrate @ 4848]
Sean Egan <seanegan@gmail.com>
parents: 4561
diff changeset
156 gaim_separator(menu);
493f050dc11a [gaim-migrate @ 4848]
Sean Egan <seanegan@gmail.com>
parents: 4561
diff changeset
157
493f050dc11a [gaim-migrate @ 4848]
Sean Egan <seanegan@gmail.com>
parents: 4561
diff changeset
158 entry = gtk_check_menu_item_new_with_label(_("Mute Sounds"));
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5669
diff changeset
159 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(entry), gaim_gtk_sound_get_mute());
4567
493f050dc11a [gaim-migrate @ 4848]
Sean Egan <seanegan@gmail.com>
parents: 4561
diff changeset
160 g_signal_connect(G_OBJECT(entry), "toggled", G_CALLBACK(docklet_toggle_mute), NULL);
4635
42d53c416bb9 [gaim-migrate @ 4942]
Nathan Walp <nwalp@pidgin.im>
parents: 4606
diff changeset
161 gtk_menu_shell_append(GTK_MENU_SHELL(menu), entry);
4567
493f050dc11a [gaim-migrate @ 4848]
Sean Egan <seanegan@gmail.com>
parents: 4561
diff changeset
162
5669
9e7f8ffb0404 [gaim-migrate @ 6086]
Sean Egan <seanegan@gmail.com>
parents: 5609
diff changeset
163 gaim_new_item_from_stock(menu, _("File Transfers"), GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(gaim_show_xfer_dialog), NULL, 0, 0, NULL);
9e7f8ffb0404 [gaim-migrate @ 6086]
Sean Egan <seanegan@gmail.com>
parents: 5609
diff changeset
164 gaim_new_item_from_stock(menu, _("Accounts"), GAIM_STOCK_ACCOUNTS, G_CALLBACK(gaim_gtk_account_dialog_show), NULL, 0, 0, NULL);
9e7f8ffb0404 [gaim-migrate @ 6086]
Sean Egan <seanegan@gmail.com>
parents: 5609
diff changeset
165 gaim_new_item_from_stock(menu, _("Preferences"), GTK_STOCK_PREFERENCES, G_CALLBACK(gaim_gtk_prefs_show), NULL, 0, 0, NULL);
4567
493f050dc11a [gaim-migrate @ 4848]
Sean Egan <seanegan@gmail.com>
parents: 4561
diff changeset
166
493f050dc11a [gaim-migrate @ 4848]
Sean Egan <seanegan@gmail.com>
parents: 4561
diff changeset
167 gaim_separator(menu);
493f050dc11a [gaim-migrate @ 4848]
Sean Egan <seanegan@gmail.com>
parents: 4561
diff changeset
168
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
169 switch (status) {
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
170 case offline:
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
171 case offline_connecting:
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
172 break;
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
173 default:
5607
eeba9205dd0f [gaim-migrate @ 6011]
Nathan Walp <nwalp@pidgin.im>
parents: 5584
diff changeset
174 gaim_new_item_from_stock(menu, _("Signoff"), GTK_STOCK_CLOSE, G_CALLBACK(gaim_connections_disconnect_all), NULL, 0, 0, 0);
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
175 break;
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
176 }
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
177
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
178 gaim_new_item_from_stock(menu, _("Quit"), GTK_STOCK_QUIT, G_CALLBACK(do_quit), NULL, 0, 0, 0);
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 gtk_widget_show_all(menu);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button, event->time);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 static void docklet_clicked(GtkWidget *button, GdkEventButton *event, void *data) {
3939
49d42b275a68 [gaim-migrate @ 4115]
Luke Schierer <lschiere@pidgin.im>
parents: 3867
diff changeset
185 if (event->type != GDK_BUTTON_PRESS)
49d42b275a68 [gaim-migrate @ 4115]
Luke Schierer <lschiere@pidgin.im>
parents: 3867
diff changeset
186 return;
49d42b275a68 [gaim-migrate @ 4115]
Luke Schierer <lschiere@pidgin.im>
parents: 3867
diff changeset
187
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 switch (event->button) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 case 1:
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3514
diff changeset
190 if (unread_message_queue) {
3570
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
191 docklet_flush_queue();
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3514
diff changeset
192 docklet_update_status();
3570
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
193 } else {
4698
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
194 gaim_gtk_blist_docklet_toggle();
3554
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
195 }
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 break;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 case 2:
5905
dbe2a2174be9 [gaim-migrate @ 6337]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
198 switch (status) {
dbe2a2174be9 [gaim-migrate @ 6337]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
199 case offline:
dbe2a2174be9 [gaim-migrate @ 6337]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
200 case offline_connecting:
dbe2a2174be9 [gaim-migrate @ 6337]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
201 docklet_auto_login();
dbe2a2174be9 [gaim-migrate @ 6337]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
202 break;
dbe2a2174be9 [gaim-migrate @ 6337]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
203 default:
dbe2a2174be9 [gaim-migrate @ 6337]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
204 break;
dbe2a2174be9 [gaim-migrate @ 6337]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
205 }
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 break;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 case 3:
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 docklet_menu(event);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 break;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
213 static void docklet_update_icon() {
4250
3b884e35e6b5 [gaim-migrate @ 4500]
Christian Hammond <chipx86@chipx86.com>
parents: 4157
diff changeset
214 const gchar *icon_name = NULL;
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
216 switch (icon) {
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
217 case offline:
5024
8e55a4d362a3 [gaim-migrate @ 5361]
Sean Egan <seanegan@gmail.com>
parents: 4840
diff changeset
218 icon_name = GAIM_STOCK_ICON_OFFLINE;
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
219 break;
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
220 case offline_connecting:
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
221 case online_connecting:
5024
8e55a4d362a3 [gaim-migrate @ 5361]
Sean Egan <seanegan@gmail.com>
parents: 4840
diff changeset
222 icon_name = GAIM_STOCK_ICON_CONNECT;
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
223 break;
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 case online:
5024
8e55a4d362a3 [gaim-migrate @ 5361]
Sean Egan <seanegan@gmail.com>
parents: 4840
diff changeset
225 icon_name = GAIM_STOCK_ICON_ONLINE;
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 break;
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
227 case online_pending:
5024
8e55a4d362a3 [gaim-migrate @ 5361]
Sean Egan <seanegan@gmail.com>
parents: 4840
diff changeset
228 icon_name = GAIM_STOCK_ICON_ONLINE_MSG;
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
229 break;
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 case away:
5024
8e55a4d362a3 [gaim-migrate @ 5361]
Sean Egan <seanegan@gmail.com>
parents: 4840
diff changeset
231 icon_name = GAIM_STOCK_ICON_AWAY;
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 break;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 case away_pending:
5024
8e55a4d362a3 [gaim-migrate @ 5361]
Sean Egan <seanegan@gmail.com>
parents: 4840
diff changeset
234 icon_name = GAIM_STOCK_ICON_AWAY_MSG;
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 break;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
238 gtk_image_set_from_stock(GTK_IMAGE(image), icon_name, GTK_ICON_SIZE_LARGE_TOOLBAR);
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
239 }
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
241 static gboolean docklet_blink_icon() {
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
242 if (status == online_pending) {
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
243 if (status == icon) {
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
244 /* last icon was the right one... let's change it */
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
245 icon = online;
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
246 } else {
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
247 /* last icon was the wrong one, change it back */
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
248 icon = online_pending;
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
249 }
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
250 } else if (status == away_pending) {
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
251 if (status == icon) {
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
252 /* last icon was the right one... let's change it */
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
253 icon = away;
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
254 } else {
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
255 /* last icon was the wrong one, change it back */
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
256 icon = away_pending;
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
257 }
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
258 } else {
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
259 /* no messages, stop blinking */
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
260 return FALSE;
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
261 }
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
262
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
263 docklet_update_icon();
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
264
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
265 return TRUE; /* keep blinking */
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
268 static gboolean docklet_update_status() {
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 enum docklet_status oldstatus;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 oldstatus = status;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272
5584
cade2082f760 [gaim-migrate @ 5988]
Luke Schierer <lschiere@pidgin.im>
parents: 5554
diff changeset
273 if (gaim_connections_get_all()) {
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3514
diff changeset
274 if (unread_message_queue) {
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
275 status = online_pending;
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3514
diff changeset
276 } else if (awaymessage) {
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 if (message_queue) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 status = away_pending;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 } else {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 status = away;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 }
5905
dbe2a2174be9 [gaim-migrate @ 6337]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
282 } else if (gaim_connections_get_connecting()) {
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
283 status = online_connecting;
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 } else {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 status = online;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 } else {
5905
dbe2a2174be9 [gaim-migrate @ 6337]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
288 if (gaim_connections_get_connecting()) {
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
289 status = offline_connecting;
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3514
diff changeset
290 } else {
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3514
diff changeset
291 status = offline;
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3514
diff changeset
292 }
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
295 /* update the icon if we changed status */
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 if (status != oldstatus) {
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
297 icon = status;
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 docklet_update_icon();
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
299
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
300 /* and schedule the blinker function if messages are pending */
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
301 if (status == online_pending || status == away_pending) {
4274
906f61f27479 [gaim-migrate @ 4525]
Luke Schierer <lschiere@pidgin.im>
parents: 4261
diff changeset
302 g_timeout_add(500, docklet_blink_icon, &docklet);
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
303 }
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 }
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
305
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
306 return FALSE; /* for when we're called by the glib idle handler */
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308
3554
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
309 static void docklet_embedded(GtkWidget *widget, void *data) {
5227
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
310 gaim_debug(GAIM_DEBUG_INFO, "docklet", "Tray Icon: embedded\n");
4698
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
311 gaim_gtk_blist_docklet_add();
3554
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
312 }
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
313
4274
906f61f27479 [gaim-migrate @ 4525]
Luke Schierer <lschiere@pidgin.im>
parents: 4261
diff changeset
314 static void docklet_remove_callbacks() {
5227
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
315 gaim_debug(GAIM_DEBUG_INFO, "docklet", "Tray Icon: removing callbacks");
4274
906f61f27479 [gaim-migrate @ 4525]
Luke Schierer <lschiere@pidgin.im>
parents: 4261
diff changeset
316
906f61f27479 [gaim-migrate @ 4525]
Luke Schierer <lschiere@pidgin.im>
parents: 4261
diff changeset
317 while (g_source_remove_by_user_data(&docklet)) {
5227
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
318 gaim_debug(GAIM_DEBUG_INFO, NULL, ".");
4274
906f61f27479 [gaim-migrate @ 4525]
Luke Schierer <lschiere@pidgin.im>
parents: 4261
diff changeset
319 }
906f61f27479 [gaim-migrate @ 4525]
Luke Schierer <lschiere@pidgin.im>
parents: 4261
diff changeset
320
5227
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
321 gaim_debug(GAIM_DEBUG_INFO, NULL, "\n");
4274
906f61f27479 [gaim-migrate @ 4525]
Luke Schierer <lschiere@pidgin.im>
parents: 4261
diff changeset
322 }
906f61f27479 [gaim-migrate @ 4525]
Luke Schierer <lschiere@pidgin.im>
parents: 4261
diff changeset
323
3554
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
324 static void docklet_destroyed(GtkWidget *widget, void *data) {
5227
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
325 gaim_debug(GAIM_DEBUG_INFO, "docklet", "Tray Icon: destroyed\n");
4093
987624dcece4 [gaim-migrate @ 4308]
Luke Schierer <lschiere@pidgin.im>
parents: 3939
diff changeset
326
4698
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
327 gaim_gtk_blist_docklet_remove();
4093
987624dcece4 [gaim-migrate @ 4308]
Luke Schierer <lschiere@pidgin.im>
parents: 3939
diff changeset
328
3570
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
329 docklet_flush_queue();
4093
987624dcece4 [gaim-migrate @ 4308]
Luke Schierer <lschiere@pidgin.im>
parents: 3939
diff changeset
330
4274
906f61f27479 [gaim-migrate @ 4525]
Luke Schierer <lschiere@pidgin.im>
parents: 4261
diff changeset
331 docklet_remove_callbacks();
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
332
4093
987624dcece4 [gaim-migrate @ 4308]
Luke Schierer <lschiere@pidgin.im>
parents: 3939
diff changeset
333 g_object_unref(G_OBJECT(docklet));
987624dcece4 [gaim-migrate @ 4308]
Luke Schierer <lschiere@pidgin.im>
parents: 3939
diff changeset
334 docklet = NULL;
987624dcece4 [gaim-migrate @ 4308]
Luke Schierer <lschiere@pidgin.im>
parents: 3939
diff changeset
335
4274
906f61f27479 [gaim-migrate @ 4525]
Luke Schierer <lschiere@pidgin.im>
parents: 4261
diff changeset
336 g_idle_add(docklet_create, &docklet);
3554
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
337 }
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
338
4274
906f61f27479 [gaim-migrate @ 4525]
Luke Schierer <lschiere@pidgin.im>
parents: 4261
diff changeset
339 static gboolean docklet_create() {
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340 GtkWidget *box;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341
3570
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
342 if (docklet) {
4093
987624dcece4 [gaim-migrate @ 4308]
Luke Schierer <lschiere@pidgin.im>
parents: 3939
diff changeset
343 /* if this is being called when a tray icon exists, it's because
987624dcece4 [gaim-migrate @ 4308]
Luke Schierer <lschiere@pidgin.im>
parents: 3939
diff changeset
344 something messed up. try destroying it before we proceed,
987624dcece4 [gaim-migrate @ 4308]
Luke Schierer <lschiere@pidgin.im>
parents: 3939
diff changeset
345 although docklet_refcount may be all hosed. hopefully won't happen. */
5227
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
346 gaim_debug(GAIM_DEBUG_WARNING, "docklet",
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
347 "Tray Icon: trying to create icon but it already exists?\n");
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
348 plugin_unload(NULL);
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 docklet = egg_tray_icon_new("Gaim");
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 box = gtk_event_box_new();
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
353 image = gtk_image_new();
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354
3554
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
355 g_signal_connect(G_OBJECT(docklet), "embedded", G_CALLBACK(docklet_embedded), NULL);
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
356 g_signal_connect(G_OBJECT(docklet), "destroy", G_CALLBACK(docklet_destroyed), NULL);
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
357 g_signal_connect(G_OBJECT(box), "button-press-event", G_CALLBACK(docklet_clicked), NULL);
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
359 gtk_container_add(GTK_CONTAINER(box), image);
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360 gtk_container_add(GTK_CONTAINER(docklet), box);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 gtk_widget_show_all(GTK_WIDGET(docklet));
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362
3554
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
363 /* ref the docklet before we bandy it about the place */
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
364 g_object_ref(G_OBJECT(docklet));
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365 docklet_update_status();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 docklet_update_icon();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367
5227
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
368 gaim_debug(GAIM_DEBUG_INFO, "docklet", "Tray Icon: created\n");
4093
987624dcece4 [gaim-migrate @ 4308]
Luke Schierer <lschiere@pidgin.im>
parents: 3939
diff changeset
369
987624dcece4 [gaim-migrate @ 4308]
Luke Schierer <lschiere@pidgin.im>
parents: 3939
diff changeset
370 return FALSE; /* for when we're called by the glib idle handler */
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372
5584
cade2082f760 [gaim-migrate @ 5988]
Luke Schierer <lschiere@pidgin.im>
parents: 5554
diff changeset
373 static void gaim_signon(GaimConnection *gc, void *data) {
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 docklet_update_status();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376
5584
cade2082f760 [gaim-migrate @ 5988]
Luke Schierer <lschiere@pidgin.im>
parents: 5554
diff changeset
377 static void gaim_signoff(GaimConnection *gc, void *data) {
4157
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
378 /* do this when idle so that if the prpl was connecting
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
379 and was cancelled, we register that connecting_count
9c31ddae80a1 [gaim-migrate @ 4385]
Rob Flynn <gaim@robflynn.com>
parents: 4108
diff changeset
380 has returned to 0 */
5905
dbe2a2174be9 [gaim-migrate @ 6337]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
381 /* no longer necessary because Chip decided that us plugins
dbe2a2174be9 [gaim-migrate @ 6337]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
382 * didn't need to know if an account was connecting or not
dbe2a2174be9 [gaim-migrate @ 6337]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
383 * g_idle_add(docklet_update_status, &docklet); */
dbe2a2174be9 [gaim-migrate @ 6337]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
384 docklet_update_status();
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386
5584
cade2082f760 [gaim-migrate @ 5988]
Luke Schierer <lschiere@pidgin.im>
parents: 5554
diff changeset
387 static void gaim_connecting(GaimAccount *account, void *data) {
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388 docklet_update_status();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390
5584
cade2082f760 [gaim-migrate @ 5988]
Luke Schierer <lschiere@pidgin.im>
parents: 5554
diff changeset
391 static void gaim_away(GaimConnection *gc, char *state, char *message, void *data) {
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 /* we only support global away. this is the way it is, ok? */
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393 docklet_update_status();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395
5584
cade2082f760 [gaim-migrate @ 5988]
Luke Schierer <lschiere@pidgin.im>
parents: 5554
diff changeset
396 static void gaim_im_recv(GaimConnection *gc, char **who, char **what, void *data) {
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397 /* if message queuing while away is enabled, this event could be the first
4274
906f61f27479 [gaim-migrate @ 4525]
Luke Schierer <lschiere@pidgin.im>
parents: 4261
diff changeset
398 message so we need to see if the status (and hence icon) needs changing.
906f61f27479 [gaim-migrate @ 4525]
Luke Schierer <lschiere@pidgin.im>
parents: 4261
diff changeset
399 do this when idle so that all message processing is completed, queuing
906f61f27479 [gaim-migrate @ 4525]
Luke Schierer <lschiere@pidgin.im>
parents: 4261
diff changeset
400 etc, before we run. */
906f61f27479 [gaim-migrate @ 4525]
Luke Schierer <lschiere@pidgin.im>
parents: 4261
diff changeset
401 g_idle_add(docklet_update_status, &docklet);
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403
5584
cade2082f760 [gaim-migrate @ 5988]
Luke Schierer <lschiere@pidgin.im>
parents: 5554
diff changeset
404 /* static void gaim_buddy_signon(GaimConnection *gc, char *who, void *data) {
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
405 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406
5584
cade2082f760 [gaim-migrate @ 5988]
Luke Schierer <lschiere@pidgin.im>
parents: 5554
diff changeset
407 static void gaim_buddy_signoff(GaimConnection *gc, char *who, void *data) {
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409
5584
cade2082f760 [gaim-migrate @ 5988]
Luke Schierer <lschiere@pidgin.im>
parents: 5554
diff changeset
410 static void gaim_buddy_away(GaimConnection *gc, char *who, void *data) {
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
411 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
412
5584
cade2082f760 [gaim-migrate @ 5988]
Luke Schierer <lschiere@pidgin.im>
parents: 5554
diff changeset
413 static void gaim_buddy_back(GaimConnection *gc, char *who, void *data) {
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416 static void gaim_new_conversation(char *who, void *data) {
3570
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
417 } */
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
419 static gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
420 plugin_load(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
421 {
5554
7b36d02031a2 [gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents: 5530
diff changeset
422 gaim_prefs_add_none("/plugins/gtk/docklet");
7b36d02031a2 [gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents: 5530
diff changeset
423 gaim_prefs_add_bool("/plugins/gtk/docklet/queue_messages", FALSE);
7b36d02031a2 [gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents: 5530
diff changeset
424
4093
987624dcece4 [gaim-migrate @ 4308]
Luke Schierer <lschiere@pidgin.im>
parents: 3939
diff changeset
425 docklet_create(NULL);
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
427 gaim_signal_connect(plugin, event_signon, gaim_signon, NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
428 gaim_signal_connect(plugin, event_signoff, gaim_signoff, NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
429 gaim_signal_connect(plugin, event_connecting, gaim_connecting, NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
430 gaim_signal_connect(plugin, event_away, gaim_away, NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
431 gaim_signal_connect(plugin, event_im_recv, gaim_im_recv, NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
432 /* gaim_signal_connect(plugin, event_buddy_signon, gaim_buddy_signon, NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
433 gaim_signal_connect(plugin, event_buddy_signoff, gaim_buddy_signoff, NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
434 gaim_signal_connect(plugin, event_buddy_away, gaim_buddy_away, NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
435 gaim_signal_connect(plugin, event_buddy_back, gaim_buddy_back, NULL);
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
436 gaim_signal_connect(plugin, event_new_conversation, gaim_new_conversation, NULL); */
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
438 return TRUE;
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
441 static gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
442 plugin_unload(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
443 {
3570
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
444 if (GTK_WIDGET_VISIBLE(docklet)) {
4698
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
445 gaim_gtk_blist_docklet_remove();
3570
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
446 }
3554
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
447
3570
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
448 docklet_flush_queue();
3554
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
449
4274
906f61f27479 [gaim-migrate @ 4525]
Luke Schierer <lschiere@pidgin.im>
parents: 4261
diff changeset
450 docklet_remove_callbacks();
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 4250
diff changeset
451
3570
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
452 g_signal_handlers_disconnect_by_func(G_OBJECT(docklet), G_CALLBACK(docklet_destroyed), NULL);
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
453 gtk_widget_destroy(GTK_WIDGET(docklet));
3554
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
454
4093
987624dcece4 [gaim-migrate @ 4308]
Luke Schierer <lschiere@pidgin.im>
parents: 3939
diff changeset
455 g_object_unref(G_OBJECT(docklet));
987624dcece4 [gaim-migrate @ 4308]
Luke Schierer <lschiere@pidgin.im>
parents: 3939
diff changeset
456 docklet = NULL;
987624dcece4 [gaim-migrate @ 4308]
Luke Schierer <lschiere@pidgin.im>
parents: 3939
diff changeset
457
5905
dbe2a2174be9 [gaim-migrate @ 6337]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
458 /* XXX: do this while gaim has no other way to toggle the global mute */
5684
b61520e71679 [gaim-migrate @ 6104]
Nathan Walp <nwalp@pidgin.im>
parents: 5669
diff changeset
459 gaim_gtk_sound_set_mute(FALSE);
4567
493f050dc11a [gaim-migrate @ 4848]
Sean Egan <seanegan@gmail.com>
parents: 4561
diff changeset
460
5227
6d1707dc8c3d [gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
461 gaim_debug(GAIM_DEBUG_INFO, "docklet", "Tray Icon: removed\n");
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
462
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
463 return TRUE;
3554
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
464 }
cf00549c53d7 [gaim-migrate @ 3644]
Sean Egan <seanegan@gmail.com>
parents: 3551
diff changeset
465
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
466 static GtkWidget *
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
467 get_config_frame(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
468 {
3570
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
469 GtkWidget *frame;
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
470 GtkWidget *vbox, *hbox;
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
471 GtkWidget *toggle;
5554
7b36d02031a2 [gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents: 5530
diff changeset
472 static const char *qmpref = "/plugins/gtk/docklet/queue_messages";
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3514
diff changeset
473
3570
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
474 frame = gtk_vbox_new(FALSE, 18);
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
475 gtk_container_set_border_width(GTK_CONTAINER(frame), 12);
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
476
5530
2c4c975620f0 [gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents: 5234
diff changeset
477 vbox = gaim_gtk_make_frame(frame, _("Tray Icon Configuration"));
3570
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
478 hbox = gtk_hbox_new(FALSE, 18);
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
479 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3514
diff changeset
480
4093
987624dcece4 [gaim-migrate @ 4308]
Luke Schierer <lschiere@pidgin.im>
parents: 3939
diff changeset
481 toggle = gtk_check_button_new_with_mnemonic(_("_Hide new messages until tray icon is clicked"));
5554
7b36d02031a2 [gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents: 5530
diff changeset
482 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), gaim_prefs_get_bool(qmpref));
7b36d02031a2 [gaim-migrate @ 5955]
Christian Hammond <chipx86@chipx86.com>
parents: 5530
diff changeset
483 g_signal_connect(G_OBJECT(toggle), "clicked", G_CALLBACK(docklet_set_bool), (void *)qmpref);
3570
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
484 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0);
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
485
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
486 gtk_widget_show_all(frame);
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
487 return frame;
3517
6b0cb60162f4 [gaim-migrate @ 3590]
Sean Egan <seanegan@gmail.com>
parents: 3514
diff changeset
488 }
3570
b791019b2492 [gaim-migrate @ 3666]
Sean Egan <seanegan@gmail.com>
parents: 3554
diff changeset
489
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
490 static GaimGtkPluginUiInfo ui_info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
491 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
492 get_config_frame
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
493 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
494
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
495 static GaimPluginInfo info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
496 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
497 2, /**< api_version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
498 GAIM_PLUGIN_STANDARD, /**< type */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
499 GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
500 0, /**< flags */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
501 NULL, /**< dependencies */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
502 GAIM_PRIORITY_DEFAULT, /**< priority */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
503
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
504 DOCKLET_PLUGIN_ID, /**< id */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
505 N_("System Tray Icon"), /**< name */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
506 VERSION, /**< version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
507 /** summary */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
508 N_("Displays an icon for Gaim in the system tray."),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
509 /** description */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
510 N_("Interacts with a Notification Area applet (in GNOME or KDE, "
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
511 "for example) to display the current status of Gaim, allow fast "
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
512 "access to commonly used functions, and to toggle display of the "
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
513 "buddy list or login window. Also allows messages to be queued "
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
514 "until the icon is clicked, similar to ICQ."),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
515 "Robert McQueen <robot101@debian.org>", /**< author */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
516 WEBSITE, /**< homepage */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
517
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
518 plugin_load, /**< load */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
519 plugin_unload, /**< unload */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
520 NULL, /**< destroy */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
521
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
522 &ui_info, /**< ui_info */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
523 NULL /**< extra_info */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
524 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
525
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
526 static void
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5905
diff changeset
527 init_plugin(GaimPlugin *plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5024
diff changeset
528 {
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3550
diff changeset
529 }
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5905
diff changeset
531 GAIM_INIT_PLUGIN(docklet, init_plugin, info);