pidgin/gtkdocklet-x11.c

Fri, 19 Feb 2010 07:07:09 +0000

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Fri, 19 Feb 2010 07:07:09 +0000
branch
cpw.qulogic.gtk3
changeset 32375
9ccb07c70f2a
parent 29706
230f2f5eca1e
parent 27439
482df00eccd3
permissions
-rw-r--r--

propagate from branch 'im.pidgin.pidgin' (head 0adc09e12a5af1953f61d0d274eabae3859ef423)
to branch 'im.pidgin.cpw.qulogic.gtk3' (head 8e8d5cdb6f623976a605baf4c03a1e6a834be217)

6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
1 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
2 * System tray icon (aka docklet) plugin for Purple
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
3 *
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
4 * Copyright (C) 2002-3 Robert McQueen <robot101@debian.org>
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
5 * Copyright (C) 2003 Herman Bloggs <hermanator12002@yahoo.com>
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
6 * Inspired by a similar plugin by:
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
7 * John (J5) Palmieri <johnp@martianrock.com>
25888
d0fdd378a635 Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents: 24036
diff changeset
8 *
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
10 * modify it under the terms of the GNU General Public License as
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
11 * published by the Free Software Foundation; either version 2 of the
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
12 * License, or (at your option) any later version.
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
13 *
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
17 * General Public License for more details.
25888
d0fdd378a635 Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents: 24036
diff changeset
18 *
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
19859
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 17756
diff changeset
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
71d37b57eff2 The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 17756
diff changeset
22 * 02111-1301, USA.
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
23 */
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
24
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
25 #include "internal.h"
15577
b8129373f65e More pidgin changes
Sean Egan <seanegan@pidgin.im>
parents: 15570
diff changeset
26 #include "pidgin.h"
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
27 #include "debug.h"
16621
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
28 #include "prefs.h"
15883
969b74a3e27a According to etags, pidgin/ should be completely clean of references to 'gaim' as a client
Sean Egan <seanegan@pidgin.im>
parents: 15836
diff changeset
29 #include "pidginstock.h"
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
30
9709
2e73f176cc80 [gaim-migrate @ 10570]
Mark Doliner <markdoliner@pidgin.im>
parents: 9229
diff changeset
31 #include "gtkdialogs.h"
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
32
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
33 #include "eggtrayicon.h"
14743
2324d3eee038 [gaim-migrate @ 17433]
Sean Egan <seanegan@pidgin.im>
parents: 14253
diff changeset
34 #include "gtkdocklet.h"
27326
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
35 #include <gdk/gdkkeysyms.h>
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
36
29641
e54552cf87d8 Use GtkStatusIcon on GTK+ 2.10+. That's actually the required version for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29500
diff changeset
37 #if !GTK_CHECK_VERSION(2,10,0)
e54552cf87d8 Use GtkStatusIcon on GTK+ 2.10+. That's actually the required version for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29500
diff changeset
38
16621
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
39 #define SHORT_EMBED_TIMEOUT 5000
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
40 #define LONG_EMBED_TIMEOUT 15000
10491
d796f5b823d5 [gaim-migrate @ 11781]
Sean Egan <seanegan@pidgin.im>
parents: 10297
diff changeset
41
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
42 /* globals */
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
43 static EggTrayIcon *docklet = NULL;
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
44 static GtkWidget *image = NULL;
26929
2a8ade936729 Replace GtkTooltips code with GtkTooltip on GTK+ 2.12+.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
45 #if !GTK_CHECK_VERSION(2,12,0)
12471
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12397
diff changeset
46 static GtkTooltips *tooltips = NULL;
26929
2a8ade936729 Replace GtkTooltips code with GtkTooltip on GTK+ 2.12+.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
47 #endif
6894
8c6e286b079d [gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents: 6371
diff changeset
48 static GdkPixbuf *blank_icon = NULL;
10491
d796f5b823d5 [gaim-migrate @ 11781]
Sean Egan <seanegan@pidgin.im>
parents: 10297
diff changeset
49 static int embed_timeout = 0;
15836
b9b71b7b73a0 change icon on resize
Sean Egan <seanegan@pidgin.im>
parents: 15835
diff changeset
50 static int docklet_height = 0;
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
51
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
52 /* protos */
16621
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
53 static void docklet_x11_create(gboolean);
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
54
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
55 static gboolean
22108
cb9819851163 Squash some compiler warnings, some from my -Wstrict-prototypes fixing.
Richard Laager <rlaager@pidgin.im>
parents: 22104
diff changeset
56 docklet_x11_recreate_cb(gpointer data)
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
57 {
16621
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
58 docklet_x11_create(TRUE);
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
59
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
60 return FALSE; /* for when we're called by the glib idle handler */
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
61 }
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
62
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
63 static void
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
64 docklet_x11_embedded_cb(GtkWidget *widget, void *data)
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
65 {
29706
230f2f5eca1e Make it slightly clearer which docklet is in use.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29641
diff changeset
66 purple_debug(PURPLE_DEBUG_INFO, "docklet", "X11 embedded\n");
25888
d0fdd378a635 Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents: 24036
diff changeset
67
10491
d796f5b823d5 [gaim-migrate @ 11781]
Sean Egan <seanegan@pidgin.im>
parents: 10297
diff changeset
68 g_source_remove(embed_timeout);
d796f5b823d5 [gaim-migrate @ 11781]
Sean Egan <seanegan@pidgin.im>
parents: 10297
diff changeset
69 embed_timeout = 0;
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15499
diff changeset
70 pidgin_docklet_embedded();
16621
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
71 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/docklet/x11/embedded", FALSE);
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
72 }
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
73
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
74 static void
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
75 docklet_x11_destroyed_cb(GtkWidget *widget, void *data)
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
76 {
29706
230f2f5eca1e Make it slightly clearer which docklet is in use.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29641
diff changeset
77 purple_debug(PURPLE_DEBUG_INFO, "docklet", "X11 destroyed\n");
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
78
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15499
diff changeset
79 pidgin_docklet_remove();
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
80
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
81 g_object_unref(G_OBJECT(docklet));
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
82 docklet = NULL;
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
83
16628
8fc264ea344f Charkins renamed the callback function, but missed the g_idle_add
Kevin Stange <kstange@pidgin.im>
parents: 16621
diff changeset
84 g_idle_add(docklet_x11_recreate_cb, NULL);
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
85 }
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
86
22032
8136dd5eeda3 Make some more event handlers return appropriate gboolean values. This turns
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20962
diff changeset
87 static gboolean
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
88 docklet_x11_clicked_cb(GtkWidget *button, GdkEventButton *event, void *data)
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
89 {
24036
d9cd43ec8a1b Make docklet menu appear on button press instead of release to match
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 22108
diff changeset
90 if (event->type != GDK_BUTTON_PRESS)
22032
8136dd5eeda3 Make some more event handlers return appropriate gboolean values. This turns
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20962
diff changeset
91 return FALSE;
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
92
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15499
diff changeset
93 pidgin_docklet_clicked(event->button);
22032
8136dd5eeda3 Make some more event handlers return appropriate gboolean values. This turns
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 20962
diff changeset
94 return TRUE;
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
95 }
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
96
27326
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
97 static gboolean
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
98 docklet_x11_pressed_cb(GtkWidget *button, GdkEventKey *event)
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
99 {
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
100 guint state, keyval;
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
101
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
102 state = event->state & gtk_accelerator_get_default_mod_mask();
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
103 keyval = event->keyval;
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
104 if (state == 0 &&
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
105 (keyval == GDK_Return ||
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
106 keyval == GDK_KP_Enter ||
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
107 keyval == GDK_ISO_Enter ||
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
108 keyval == GDK_space ||
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
109 keyval == GDK_KP_Space))
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
110 {
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
111 pidgin_docklet_clicked(1);
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
112 return TRUE;
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
113 }
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
114
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
115 return FALSE;
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
116 }
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
117
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
118 static void
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
119 docklet_x11_popup_cb(GtkWidget *button)
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
120 {
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
121 pidgin_docklet_clicked(3);
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
122 }
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
123
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
124 static void
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
125 docklet_x11_update_icon(PurpleStatusPrimitive status, gboolean connecting, gboolean pending)
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
126 {
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
127 const gchar *icon_name = NULL;
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
128
10504
eae130eefbfe [gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10491
diff changeset
129 g_return_if_fail(image != NULL);
eae130eefbfe [gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10491
diff changeset
130
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
131 switch (status) {
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
132 case PURPLE_STATUS_OFFLINE:
15731
3819e5d5eeae docklet update
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
133 icon_name = PIDGIN_STOCK_TRAY_OFFLINE;
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
134 break;
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
135 case PURPLE_STATUS_AWAY:
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
136 icon_name = PIDGIN_STOCK_TRAY_AWAY;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
137 break;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
138 case PURPLE_STATUS_UNAVAILABLE:
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
139 icon_name = PIDGIN_STOCK_TRAY_BUSY;
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
140 break;
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
141 case PURPLE_STATUS_EXTENDED_AWAY:
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
142 icon_name = PIDGIN_STOCK_TRAY_XA;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
143 break;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
144 case PURPLE_STATUS_INVISIBLE:
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
145 icon_name = PIDGIN_STOCK_TRAY_INVISIBLE;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
146 break;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
147 default:
15731
3819e5d5eeae docklet update
Sean Egan <seanegan@pidgin.im>
parents: 15577
diff changeset
148 icon_name = PIDGIN_STOCK_TRAY_AVAILABLE;
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
149 break;
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
150 }
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
151
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
152 if (pending)
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
153 icon_name = PIDGIN_STOCK_TRAY_PENDING;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
154 if (connecting)
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
155 icon_name = PIDGIN_STOCK_TRAY_CONNECT;
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
156
15834
ba09306a7b0a 16px tray icons. These are used if the tray is shorter than 22px, and in Windows where all tray icons are 16x16. I still need to attach to a resizing signal to make them automatically update when the tray resizes.
Sean Egan <seanegan@pidgin.im>
parents: 15774
diff changeset
157 if(icon_name) {
ba09306a7b0a 16px tray icons. These are used if the tray is shorter than 22px, and in Windows where all tray icons are 16x16. I still need to attach to a resizing signal to make them automatically update when the tray resizes.
Sean Egan <seanegan@pidgin.im>
parents: 15774
diff changeset
158 int icon_size;
15836
b9b71b7b73a0 change icon on resize
Sean Egan <seanegan@pidgin.im>
parents: 15835
diff changeset
159 if (docklet_height < 22)
15834
ba09306a7b0a 16px tray icons. These are used if the tray is shorter than 22px, and in Windows where all tray icons are 16x16. I still need to attach to a resizing signal to make them automatically update when the tray resizes.
Sean Egan <seanegan@pidgin.im>
parents: 15774
diff changeset
160 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL);
17704
d795d29d11e0 Icon updates from Hylke, including tray icons in 2 more sizes
Sean Egan <seanegan@pidgin.im>
parents: 17645
diff changeset
161 else if (docklet_height < 32)
d795d29d11e0 Icon updates from Hylke, including tray icons in 2 more sizes
Sean Egan <seanegan@pidgin.im>
parents: 17645
diff changeset
162 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_SMALL);
d795d29d11e0 Icon updates from Hylke, including tray icons in 2 more sizes
Sean Egan <seanegan@pidgin.im>
parents: 17645
diff changeset
163 else if (docklet_height < 48)
d795d29d11e0 Icon updates from Hylke, including tray icons in 2 more sizes
Sean Egan <seanegan@pidgin.im>
parents: 17645
diff changeset
164 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_MEDIUM);
15834
ba09306a7b0a 16px tray icons. These are used if the tray is shorter than 22px, and in Windows where all tray icons are 16x16. I still need to attach to a resizing signal to make them automatically update when the tray resizes.
Sean Egan <seanegan@pidgin.im>
parents: 15774
diff changeset
165 else
17704
d795d29d11e0 Icon updates from Hylke, including tray icons in 2 more sizes
Sean Egan <seanegan@pidgin.im>
parents: 17645
diff changeset
166 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_LARGE);
15836
b9b71b7b73a0 change icon on resize
Sean Egan <seanegan@pidgin.im>
parents: 15835
diff changeset
167
15834
ba09306a7b0a 16px tray icons. These are used if the tray is shorter than 22px, and in Windows where all tray icons are 16x16. I still need to attach to a resizing signal to make them automatically update when the tray resizes.
Sean Egan <seanegan@pidgin.im>
parents: 15774
diff changeset
168 gtk_image_set_from_stock(GTK_IMAGE(image), icon_name, icon_size);
10765
aca333747801 [gaim-migrate @ 12370]
Tim Ringenbach <marv@pidgin.im>
parents: 10574
diff changeset
169 }
15836
b9b71b7b73a0 change icon on resize
Sean Egan <seanegan@pidgin.im>
parents: 15835
diff changeset
170 }
b9b71b7b73a0 change icon on resize
Sean Egan <seanegan@pidgin.im>
parents: 15835
diff changeset
171
b9b71b7b73a0 change icon on resize
Sean Egan <seanegan@pidgin.im>
parents: 15835
diff changeset
172 static void
b9b71b7b73a0 change icon on resize
Sean Egan <seanegan@pidgin.im>
parents: 15835
diff changeset
173 docklet_x11_resize_icon(GtkWidget *widget)
b9b71b7b73a0 change icon on resize
Sean Egan <seanegan@pidgin.im>
parents: 15835
diff changeset
174 {
17756
0eb3eae720fb Instead of sizing the docklet icon to the height available, size it to the minimum of the height or width. Fixes #1721 in which the icon may get cut off in vertically aligned panels
Sean Egan <seanegan@pidgin.im>
parents: 17704
diff changeset
175 if (docklet_height == MIN(widget->allocation.height, widget->allocation.width))
15836
b9b71b7b73a0 change icon on resize
Sean Egan <seanegan@pidgin.im>
parents: 15835
diff changeset
176 return;
17756
0eb3eae720fb Instead of sizing the docklet icon to the height available, size it to the minimum of the height or width. Fixes #1721 in which the icon may get cut off in vertically aligned panels
Sean Egan <seanegan@pidgin.im>
parents: 17704
diff changeset
177 docklet_height = MIN(widget->allocation.height, widget->allocation.width);
16996
749cb2af2e40 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16808
diff changeset
178 pidgin_docklet_update_icon();
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
179 }
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
180
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
181 static void
22104
56970903b8e9 Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents: 22032
diff changeset
182 docklet_x11_blank_icon(void)
6894
8c6e286b079d [gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents: 6371
diff changeset
183 {
8c6e286b079d [gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents: 6371
diff changeset
184 if (!blank_icon) {
16422
2a36f5d04f5b Make sure the blinking docklet has the same size. Fixes #174.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15884
diff changeset
185 GtkIconSize size = GTK_ICON_SIZE_LARGE_TOOLBAR;
6894
8c6e286b079d [gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents: 6371
diff changeset
186 gint width, height;
16422
2a36f5d04f5b Make sure the blinking docklet has the same size. Fixes #174.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15884
diff changeset
187 g_object_get(G_OBJECT(image), "icon-size", &size, NULL);
2a36f5d04f5b Make sure the blinking docklet has the same size. Fixes #174.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents: 15884
diff changeset
188 gtk_icon_size_lookup(size, &width, &height);
6894
8c6e286b079d [gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents: 6371
diff changeset
189 blank_icon = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
8c6e286b079d [gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents: 6371
diff changeset
190 gdk_pixbuf_fill(blank_icon, 0);
8c6e286b079d [gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents: 6371
diff changeset
191 }
8c6e286b079d [gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents: 6371
diff changeset
192
8c6e286b079d [gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents: 6371
diff changeset
193 gtk_image_set_from_pixbuf(GTK_IMAGE(image), blank_icon);
8c6e286b079d [gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents: 6371
diff changeset
194 }
8c6e286b079d [gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents: 6371
diff changeset
195
12471
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12397
diff changeset
196 static void
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12397
diff changeset
197 docklet_x11_set_tooltip(gchar *tooltip)
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12397
diff changeset
198 {
26929
2a8ade936729 Replace GtkTooltips code with GtkTooltip on GTK+ 2.12+.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
199 #if GTK_CHECK_VERSION(2,12,0)
2a8ade936729 Replace GtkTooltips code with GtkTooltip on GTK+ 2.12+.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
200 if (tooltip) {
2a8ade936729 Replace GtkTooltips code with GtkTooltip on GTK+ 2.12+.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
201 gtk_widget_set_tooltip_text(image->parent, tooltip);
2a8ade936729 Replace GtkTooltips code with GtkTooltip on GTK+ 2.12+.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
202 } else {
2a8ade936729 Replace GtkTooltips code with GtkTooltip on GTK+ 2.12+.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
203 gtk_widget_set_tooltip_text(image->parent, ""); /* NULL? */
2a8ade936729 Replace GtkTooltips code with GtkTooltip on GTK+ 2.12+.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
204 }
2a8ade936729 Replace GtkTooltips code with GtkTooltip on GTK+ 2.12+.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
205 #else
12471
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12397
diff changeset
206 if (!tooltips)
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12397
diff changeset
207 tooltips = gtk_tooltips_new();
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12397
diff changeset
208
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12397
diff changeset
209 /* image->parent is a GtkEventBox */
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12397
diff changeset
210 if (tooltip) {
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12397
diff changeset
211 gtk_tooltips_enable(tooltips);
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12397
diff changeset
212 gtk_tooltips_set_tip(tooltips, image->parent, tooltip, NULL);
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12397
diff changeset
213 } else {
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12397
diff changeset
214 gtk_tooltips_set_tip(tooltips, image->parent, "", NULL);
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12397
diff changeset
215 gtk_tooltips_disable(tooltips);
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12397
diff changeset
216 }
26929
2a8ade936729 Replace GtkTooltips code with GtkTooltip on GTK+ 2.12+.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
217 #endif
12471
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12397
diff changeset
218 }
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12397
diff changeset
219
6894
8c6e286b079d [gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents: 6371
diff changeset
220 static void
10268
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
221 docklet_x11_position_menu(GtkMenu *menu, int *x, int *y, gboolean *push_in,
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
222 gpointer user_data)
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
223 {
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
224 GtkWidget *widget = GTK_WIDGET(docklet);
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
225 GtkRequisition req;
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
226 gint menu_xpos, menu_ypos;
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
227
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
228 gtk_widget_size_request(GTK_WIDGET(menu), &req);
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
229 gdk_window_get_origin(widget->window, &menu_xpos, &menu_ypos);
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
230
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
231 menu_xpos += widget->allocation.x;
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
232 menu_ypos += widget->allocation.y;
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
233
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
234 if (menu_ypos > gdk_screen_get_height(gtk_widget_get_screen(widget)) / 2)
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
235 menu_ypos -= req.height;
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
236 else
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
237 menu_ypos += widget->allocation.height;
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
238
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
239 *x = menu_xpos;
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
240 *y = menu_ypos;
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
241
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
242 *push_in = TRUE;
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
243 }
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
244
10504
eae130eefbfe [gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10491
diff changeset
245 static void
22104
56970903b8e9 Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents: 22032
diff changeset
246 docklet_x11_destroy(void)
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
247 {
10504
eae130eefbfe [gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10491
diff changeset
248 g_return_if_fail(docklet != NULL);
eae130eefbfe [gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10491
diff changeset
249
14935
9a69bd67236d [gaim-migrate @ 17642]
Sean Egan <seanegan@pidgin.im>
parents: 14813
diff changeset
250 if (embed_timeout)
9a69bd67236d [gaim-migrate @ 17642]
Sean Egan <seanegan@pidgin.im>
parents: 14813
diff changeset
251 g_source_remove(embed_timeout);
25888
d0fdd378a635 Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents: 24036
diff changeset
252
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15499
diff changeset
253 pidgin_docklet_remove();
25888
d0fdd378a635 Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents: 24036
diff changeset
254
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
255 g_signal_handlers_disconnect_by_func(G_OBJECT(docklet), G_CALLBACK(docklet_x11_destroyed_cb), NULL);
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
256 gtk_widget_destroy(GTK_WIDGET(docklet));
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
257
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
258 g_object_unref(G_OBJECT(docklet));
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
259 docklet = NULL;
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
260
6894
8c6e286b079d [gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents: 6371
diff changeset
261 if (blank_icon)
8c6e286b079d [gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents: 6371
diff changeset
262 g_object_unref(G_OBJECT(blank_icon));
8c6e286b079d [gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents: 6371
diff changeset
263 blank_icon = NULL;
8c6e286b079d [gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents: 6371
diff changeset
264
10504
eae130eefbfe [gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10491
diff changeset
265 image = NULL;
eae130eefbfe [gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10491
diff changeset
266
29706
230f2f5eca1e Make it slightly clearer which docklet is in use.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29641
diff changeset
267 purple_debug(PURPLE_DEBUG_INFO, "docklet", "X11 destroyed\n");
10504
eae130eefbfe [gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10491
diff changeset
268 }
eae130eefbfe [gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10491
diff changeset
269
eae130eefbfe [gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10491
diff changeset
270 static gboolean
22108
cb9819851163 Squash some compiler warnings, some from my -Wstrict-prototypes fixing.
Richard Laager <rlaager@pidgin.im>
parents: 22104
diff changeset
271 docklet_x11_embed_timeout_cb(gpointer data)
10504
eae130eefbfe [gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents: 10491
diff changeset
272 {
12498
93591c1f68f1 [gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents: 12471
diff changeset
273 /* The docklet was not embedded within the timeout.
93591c1f68f1 [gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents: 12471
diff changeset
274 * Remove it as a visibility manager, but leave the plugin
93591c1f68f1 [gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents: 12471
diff changeset
275 * loaded so that it can embed automatically if/when a notification
93591c1f68f1 [gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents: 12471
diff changeset
276 * area becomes available.
93591c1f68f1 [gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents: 12471
diff changeset
277 */
29706
230f2f5eca1e Make it slightly clearer which docklet is in use.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29641
diff changeset
278 purple_debug_info("docklet", "X11 failed to embed within timeout\n");
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15499
diff changeset
279 pidgin_docklet_remove();
25888
d0fdd378a635 Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents: 24036
diff changeset
280
10491
d796f5b823d5 [gaim-migrate @ 11781]
Sean Egan <seanegan@pidgin.im>
parents: 10297
diff changeset
281 return FALSE;
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
282 }
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
283
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
284 static void
16621
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
285 docklet_x11_create(gboolean recreate)
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
286 {
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
287 GtkWidget *box;
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
288
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
289 if (docklet) {
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
290 /* if this is being called when a tray icon exists, it's because
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
291 something messed up. try destroying it before we proceed,
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
292 although docklet_refcount may be all hosed. hopefully won't happen. */
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15883
diff changeset
293 purple_debug(PURPLE_DEBUG_WARNING, "docklet", "trying to create icon but it already exists?\n");
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
294 docklet_x11_destroy();
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
295 }
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
296
15499
9550c30eb265 A few non-gettextized strings
Sean Egan <seanegan@pidgin.im>
parents: 15435
diff changeset
297 docklet = egg_tray_icon_new(PIDGIN_NAME);
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
298 box = gtk_event_box_new();
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
299 image = gtk_image_new();
27326
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
300 GTK_WIDGET_SET_FLAGS (image, GTK_CAN_FOCUS);
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
301
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
302 g_signal_connect(G_OBJECT(docklet), "embedded", G_CALLBACK(docklet_x11_embedded_cb), NULL);
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
303 g_signal_connect(G_OBJECT(docklet), "destroy", G_CALLBACK(docklet_x11_destroyed_cb), NULL);
15836
b9b71b7b73a0 change icon on resize
Sean Egan <seanegan@pidgin.im>
parents: 15835
diff changeset
304 g_signal_connect(G_OBJECT(docklet), "size-allocate", G_CALLBACK(docklet_x11_resize_icon), NULL);
24036
d9cd43ec8a1b Make docklet menu appear on button press instead of release to match
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 22108
diff changeset
305 g_signal_connect(G_OBJECT(box), "button-press-event", G_CALLBACK(docklet_x11_clicked_cb), NULL);
27326
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
306 g_signal_connect(G_OBJECT(box), "key-press-event", G_CALLBACK(docklet_x11_pressed_cb), NULL);
83f1f6b8986d Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25888
diff changeset
307 g_signal_connect(G_OBJECT(box), "popup-menu", G_CALLBACK(docklet_x11_popup_cb), NULL);
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
308 gtk_container_add(GTK_CONTAINER(box), image);
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
309 gtk_container_add(GTK_CONTAINER(docklet), box);
9229
fba36c506c60 [gaim-migrate @ 10025]
Tim Ringenbach <marv@pidgin.im>
parents: 6894
diff changeset
310
12471
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12397
diff changeset
311 if (!gtk_check_version(2,4,0))
9229
fba36c506c60 [gaim-migrate @ 10025]
Tim Ringenbach <marv@pidgin.im>
parents: 6894
diff changeset
312 g_object_set(G_OBJECT(box), "visible-window", FALSE, NULL);
fba36c506c60 [gaim-migrate @ 10025]
Tim Ringenbach <marv@pidgin.im>
parents: 6894
diff changeset
313
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
314 gtk_widget_show_all(GTK_WIDGET(docklet));
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
315
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
316 /* ref the docklet before we bandy it about the place */
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
317 g_object_ref(G_OBJECT(docklet));
12498
93591c1f68f1 [gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents: 12471
diff changeset
318
93591c1f68f1 [gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents: 12471
diff changeset
319 /* This is a hack to avoid a race condition between the docklet getting
93591c1f68f1 [gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents: 12471
diff changeset
320 * embedded in the notification area and the gtkblist restoring its
93591c1f68f1 [gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents: 12471
diff changeset
321 * previous visibility state. If the docklet does not get embedded within
93591c1f68f1 [gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents: 12471
diff changeset
322 * the timeout, it will be removed as a visibility manager until it does
93591c1f68f1 [gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents: 12471
diff changeset
323 * get embedded. Ideally, we would only call docklet_embedded() when the
16621
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
324 * icon was actually embedded. This only happens when the docklet is first
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
325 * created, not when being recreated.
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
326 *
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
327 * The x11 docklet tracks whether it successfully embedded in a pref and
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
328 * allows for a longer timeout period if it successfully embedded the last
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
329 * time it was run. This should hopefully solve problems with the buddy
17645
32a0fe7965b7 Get rid of 'Gaim' in a few more places
Mark Doliner <markdoliner@pidgin.im>
parents: 16996
diff changeset
330 * list not properly starting hidden when Pidgin is started on login.
12498
93591c1f68f1 [gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents: 12471
diff changeset
331 */
16621
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
332 if(!recreate) {
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
333 pidgin_docklet_embedded();
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
334 if(purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/docklet/x11/embedded")) {
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
335 embed_timeout = g_timeout_add(LONG_EMBED_TIMEOUT, docklet_x11_embed_timeout_cb, NULL);
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
336 } else {
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
337 embed_timeout = g_timeout_add(SHORT_EMBED_TIMEOUT, docklet_x11_embed_timeout_cb, NULL);
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
338 }
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
339 }
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
340
29706
230f2f5eca1e Make it slightly clearer which docklet is in use.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29641
diff changeset
341 purple_debug(PURPLE_DEBUG_INFO, "docklet", "X11 created\n");
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
342 }
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
343
16621
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
344 static void
22104
56970903b8e9 Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents: 22032
diff changeset
345 docklet_x11_create_ui_op(void)
16621
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
346 {
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
347 docklet_x11_create(FALSE);
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
348 }
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
349
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
350 static struct docklet_ui_ops ui_ops =
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
351 {
16621
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
352 docklet_x11_create_ui_op,
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
353 docklet_x11_destroy,
6894
8c6e286b079d [gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents: 6371
diff changeset
354 docklet_x11_update_icon,
10268
862ed5d3f227 [gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents: 9791
diff changeset
355 docklet_x11_blank_icon,
12471
5d7c12d525ed [gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents: 12397
diff changeset
356 docklet_x11_set_tooltip,
20962
bca687215ee8 disapproval of revision 'f69b1356bb5514053201a1c11ce435bd7b0d83a7'
Casey Harkins <charkins@pidgin.im>
parents: 20961
diff changeset
357 docklet_x11_position_menu
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
358 };
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
359
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
360 void
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
361 docklet_ui_init()
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
362 {
15562
8c8249fe5e3c gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents: 15499
diff changeset
363 pidgin_docklet_set_ui_ops(&ui_ops);
16621
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
364 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/docklet/x11");
616dc666cfb8 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16422
diff changeset
365 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/docklet/x11/embedded", FALSE);
6209
995a43192bb0 [gaim-migrate @ 6695]
Herman Bloggs <herman@bluedigits.com>
parents:
diff changeset
366 }
29641
e54552cf87d8 Use GtkStatusIcon on GTK+ 2.10+. That's actually the required version for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29500
diff changeset
367
e54552cf87d8 Use GtkStatusIcon on GTK+ 2.10+. That's actually the required version for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29500
diff changeset
368 #endif /* !GTK_CHECK_VERSION(2,10,0) */
e54552cf87d8 Use GtkStatusIcon on GTK+ 2.10+. That's actually the required version for
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29500
diff changeset
369

mercurial