annotate pidgin/gtkdocklet-x11.c @ 28829:380c77dad7b4

Fix a leak on status updates from federated buddies on yahoo.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 28 Oct 2009 00:33:52 +0000
parents 211b59ac6345
children 48ea900ee72a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15822
diff changeset
2 * System tray icon (aka docklet) plugin for Purple
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * Copyright (C) 2002-3 Robert McQueen <robot101@debian.org>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2003 Herman Bloggs <hermanator12002@yahoo.com>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * Inspired by a similar plugin by:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * John (J5) Palmieri <johnp@martianrock.com>
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 23767
diff changeset
8 *
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * modify it under the terms of the GNU General Public License as
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * published by the Free Software Foundation; either version 2 of the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * License, or (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * General Public License for more details.
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 23767
diff changeset
18 *
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 17887
diff changeset
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 17887
diff changeset
22 * 02111-1301, USA.
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include "internal.h"
15514
535f002e7b0f More pidgin changes
Sean Egan <seanegan@gmail.com>
parents: 15509
diff changeset
26 #include "pidgin.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "debug.h"
16560
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
28 #include "prefs.h"
15822
84b0f9b23ede According to etags, pidgin/ should be completely clean of references to 'gaim' as a client
Sean Egan <seanegan@gmail.com>
parents: 15775
diff changeset
29 #include "pidginstock.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "gtkdialogs.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "eggtrayicon.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include "gtkdocklet.h"
27177
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
35 #include <gdk/gdkkeysyms.h>
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36
16560
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
37 #define SHORT_EMBED_TIMEOUT 5000
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
38 #define LONG_EMBED_TIMEOUT 15000
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 /* globals */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 static EggTrayIcon *docklet = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 static GtkWidget *image = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 static GtkTooltips *tooltips = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 static GdkPixbuf *blank_icon = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 static int embed_timeout = 0;
15775
f3ebd1c17c7b change icon on resize
Sean Egan <seanegan@gmail.com>
parents: 15774
diff changeset
46 static int docklet_height = 0;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 /* protos */
16560
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
49 static void docklet_x11_create(gboolean);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 static gboolean
22011
76e0463db3aa Squash some compiler warnings, some from my -Wstrict-prototypes fixing.
Richard Laager <rlaager@wiktel.com>
parents: 22007
diff changeset
52 docklet_x11_recreate_cb(gpointer data)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 {
16560
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
54 docklet_x11_create(TRUE);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 return FALSE; /* for when we're called by the glib idle handler */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 docklet_x11_embedded_cb(GtkWidget *widget, void *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15822
diff changeset
62 purple_debug(PURPLE_DEBUG_INFO, "docklet", "embedded\n");
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 23767
diff changeset
63
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 g_source_remove(embed_timeout);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 embed_timeout = 0;
15501
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15438
diff changeset
66 pidgin_docklet_embedded();
16560
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
67 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/docklet/x11/embedded", FALSE);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 docklet_x11_destroyed_cb(GtkWidget *widget, void *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 {
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15822
diff changeset
73 purple_debug(PURPLE_DEBUG_INFO, "docklet", "destroyed\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74
15501
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15438
diff changeset
75 pidgin_docklet_remove();
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 g_object_unref(G_OBJECT(docklet));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 docklet = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79
16570
6592432bbf91 Charkins renamed the callback function, but missed the g_idle_add
Kevin Stange <kevin@simguy.net>
parents: 16560
diff changeset
80 g_idle_add(docklet_x11_recreate_cb, NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82
21913
2a591a5b3322 Make some more event handlers return appropriate gboolean values. This turns
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20888
diff changeset
83 static gboolean
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 docklet_x11_clicked_cb(GtkWidget *button, GdkEventButton *event, void *data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 {
23767
7c58107415bc Make docklet menu appear on button press instead of release to match
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 22011
diff changeset
86 if (event->type != GDK_BUTTON_PRESS)
21913
2a591a5b3322 Make some more event handlers return appropriate gboolean values. This turns
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20888
diff changeset
87 return FALSE;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88
15501
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15438
diff changeset
89 pidgin_docklet_clicked(event->button);
21913
2a591a5b3322 Make some more event handlers return appropriate gboolean values. This turns
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 20888
diff changeset
90 return TRUE;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92
27177
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
93 static gboolean
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
94 docklet_x11_pressed_cb(GtkWidget *button, GdkEventKey *event)
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
95 {
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
96 guint state, keyval;
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
97
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
98 state = event->state & gtk_accelerator_get_default_mod_mask();
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
99 keyval = event->keyval;
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
100 if (state == 0 &&
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
101 (keyval == GDK_Return ||
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
102 keyval == GDK_KP_Enter ||
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
103 keyval == GDK_ISO_Enter ||
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
104 keyval == GDK_space ||
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
105 keyval == GDK_KP_Space))
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
106 {
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
107 pidgin_docklet_clicked(1);
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
108 return TRUE;
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
109 }
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
110
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
111 return FALSE;
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
112 }
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
113
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
114 static void
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
115 docklet_x11_popup_cb(GtkWidget *button)
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
116 {
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
117 pidgin_docklet_clicked(3);
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
118 }
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
119
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 static void
16949
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
121 docklet_x11_update_icon(PurpleStatusPrimitive status, gboolean connecting, gboolean pending)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 const gchar *icon_name = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 g_return_if_fail(image != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126
16949
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
127 switch (status) {
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
128 case PURPLE_STATUS_OFFLINE:
15670
878b1f5f64a6 docklet update
Sean Egan <seanegan@gmail.com>
parents: 15514
diff changeset
129 icon_name = PIDGIN_STOCK_TRAY_OFFLINE;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 break;
16949
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
131 case PURPLE_STATUS_AWAY:
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
132 icon_name = PIDGIN_STOCK_TRAY_AWAY;
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
133 break;
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
134 case PURPLE_STATUS_UNAVAILABLE:
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
135 icon_name = PIDGIN_STOCK_TRAY_BUSY;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 break;
16949
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
137 case PURPLE_STATUS_EXTENDED_AWAY:
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
138 icon_name = PIDGIN_STOCK_TRAY_XA;
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
139 break;
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
140 case PURPLE_STATUS_INVISIBLE:
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
141 icon_name = PIDGIN_STOCK_TRAY_INVISIBLE;
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
142 break;
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
143 default:
15670
878b1f5f64a6 docklet update
Sean Egan <seanegan@gmail.com>
parents: 15514
diff changeset
144 icon_name = PIDGIN_STOCK_TRAY_AVAILABLE;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147
16949
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
148 if (pending)
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
149 icon_name = PIDGIN_STOCK_TRAY_PENDING;
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
150 if (connecting)
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
151 icon_name = PIDGIN_STOCK_TRAY_CONNECT;
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
152
15773
79144a15ea78 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@gmail.com>
parents: 15715
diff changeset
153 if(icon_name) {
79144a15ea78 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@gmail.com>
parents: 15715
diff changeset
154 int icon_size;
15775
f3ebd1c17c7b change icon on resize
Sean Egan <seanegan@gmail.com>
parents: 15774
diff changeset
155 if (docklet_height < 22)
15773
79144a15ea78 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@gmail.com>
parents: 15715
diff changeset
156 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL);
17842
c7df0c2d8eef Icon updates from Hylke, including tray icons in 2 more sizes
Sean Egan <seanegan@gmail.com>
parents: 17772
diff changeset
157 else if (docklet_height < 32)
c7df0c2d8eef Icon updates from Hylke, including tray icons in 2 more sizes
Sean Egan <seanegan@gmail.com>
parents: 17772
diff changeset
158 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_SMALL);
c7df0c2d8eef Icon updates from Hylke, including tray icons in 2 more sizes
Sean Egan <seanegan@gmail.com>
parents: 17772
diff changeset
159 else if (docklet_height < 48)
c7df0c2d8eef Icon updates from Hylke, including tray icons in 2 more sizes
Sean Egan <seanegan@gmail.com>
parents: 17772
diff changeset
160 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_MEDIUM);
15773
79144a15ea78 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@gmail.com>
parents: 15715
diff changeset
161 else
17842
c7df0c2d8eef Icon updates from Hylke, including tray icons in 2 more sizes
Sean Egan <seanegan@gmail.com>
parents: 17772
diff changeset
162 icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_LARGE);
15775
f3ebd1c17c7b change icon on resize
Sean Egan <seanegan@gmail.com>
parents: 15774
diff changeset
163
15773
79144a15ea78 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@gmail.com>
parents: 15715
diff changeset
164 gtk_image_set_from_stock(GTK_IMAGE(image), icon_name, icon_size);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 }
15775
f3ebd1c17c7b change icon on resize
Sean Egan <seanegan@gmail.com>
parents: 15774
diff changeset
166 }
f3ebd1c17c7b change icon on resize
Sean Egan <seanegan@gmail.com>
parents: 15774
diff changeset
167
f3ebd1c17c7b change icon on resize
Sean Egan <seanegan@gmail.com>
parents: 15774
diff changeset
168 static void
f3ebd1c17c7b change icon on resize
Sean Egan <seanegan@gmail.com>
parents: 15774
diff changeset
169 docklet_x11_resize_icon(GtkWidget *widget)
f3ebd1c17c7b change icon on resize
Sean Egan <seanegan@gmail.com>
parents: 15774
diff changeset
170 {
17887
474283509a2a 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@gmail.com>
parents: 17842
diff changeset
171 if (docklet_height == MIN(widget->allocation.height, widget->allocation.width))
15775
f3ebd1c17c7b change icon on resize
Sean Egan <seanegan@gmail.com>
parents: 15774
diff changeset
172 return;
17887
474283509a2a 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@gmail.com>
parents: 17842
diff changeset
173 docklet_height = MIN(widget->allocation.height, widget->allocation.width);
16949
06f6768b6e29 Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents: 16763
diff changeset
174 pidgin_docklet_update_icon();
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 static void
22007
c38d72677c8a Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents: 21913
diff changeset
178 docklet_x11_blank_icon(void)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 if (!blank_icon) {
16325
ca75eccdca3d Make sure the blinking docklet has the same size. Fixes #174.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15823
diff changeset
181 GtkIconSize size = GTK_ICON_SIZE_LARGE_TOOLBAR;
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 gint width, height;
16325
ca75eccdca3d Make sure the blinking docklet has the same size. Fixes #174.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15823
diff changeset
183 g_object_get(G_OBJECT(image), "icon-size", &size, NULL);
ca75eccdca3d Make sure the blinking docklet has the same size. Fixes #174.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 15823
diff changeset
184 gtk_icon_size_lookup(size, &width, &height);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 blank_icon = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 gdk_pixbuf_fill(blank_icon, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 gtk_image_set_from_pixbuf(GTK_IMAGE(image), blank_icon);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 docklet_x11_set_tooltip(gchar *tooltip)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 if (!tooltips)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 tooltips = gtk_tooltips_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 /* image->parent is a GtkEventBox */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 if (tooltip) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 gtk_tooltips_enable(tooltips);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 gtk_tooltips_set_tip(tooltips, image->parent, tooltip, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 gtk_tooltips_set_tip(tooltips, image->parent, "", NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 gtk_tooltips_disable(tooltips);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 #if GTK_CHECK_VERSION(2,2,0)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 static void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 docklet_x11_position_menu(GtkMenu *menu, int *x, int *y, gboolean *push_in,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 gpointer user_data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 GtkWidget *widget = GTK_WIDGET(docklet);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 GtkRequisition req;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 gint menu_xpos, menu_ypos;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 gtk_widget_size_request(GTK_WIDGET(menu), &req);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 gdk_window_get_origin(widget->window, &menu_xpos, &menu_ypos);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 menu_xpos += widget->allocation.x;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 menu_ypos += widget->allocation.y;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 if (menu_ypos > gdk_screen_get_height(gtk_widget_get_screen(widget)) / 2)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 menu_ypos -= req.height;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 menu_ypos += widget->allocation.height;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 *x = menu_xpos;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 *y = menu_ypos;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 *push_in = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 static void
22007
c38d72677c8a Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents: 21913
diff changeset
236 docklet_x11_destroy(void)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 g_return_if_fail(docklet != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 if (embed_timeout)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 g_source_remove(embed_timeout);
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 23767
diff changeset
242
15501
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15438
diff changeset
243 pidgin_docklet_remove();
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 23767
diff changeset
244
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 g_signal_handlers_disconnect_by_func(G_OBJECT(docklet), G_CALLBACK(docklet_x11_destroyed_cb), NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 gtk_widget_destroy(GTK_WIDGET(docklet));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 g_object_unref(G_OBJECT(docklet));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 docklet = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 if (blank_icon)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 g_object_unref(G_OBJECT(blank_icon));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 blank_icon = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255 image = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15822
diff changeset
257 purple_debug(PURPLE_DEBUG_INFO, "docklet", "destroyed\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 static gboolean
22011
76e0463db3aa Squash some compiler warnings, some from my -Wstrict-prototypes fixing.
Richard Laager <rlaager@wiktel.com>
parents: 22007
diff changeset
261 docklet_x11_embed_timeout_cb(gpointer data)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 /* The docklet was not embedded within the timeout.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 * Remove it as a visibility manager, but leave the plugin
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 * loaded so that it can embed automatically if/when a notification
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 * area becomes available.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15822
diff changeset
268 purple_debug_info("docklet", "failed to embed within timeout\n");
15501
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15438
diff changeset
269 pidgin_docklet_remove();
25415
584063555949 Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents: 23767
diff changeset
270
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 return FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 static void
16560
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
275 docklet_x11_create(gboolean recreate)
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 GtkWidget *box;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 if (docklet) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 /* if this is being called when a tray icon exists, it's because
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 something messed up. try destroying it before we proceed,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 although docklet_refcount may be all hosed. hopefully won't happen. */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15822
diff changeset
283 purple_debug(PURPLE_DEBUG_WARNING, "docklet", "trying to create icon but it already exists?\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 docklet_x11_destroy();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286
15438
ea9ec8c3a3b8 A few non-gettextized strings
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
287 docklet = egg_tray_icon_new(PIDGIN_NAME);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 box = gtk_event_box_new();
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 image = gtk_image_new();
27177
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
290 GTK_WIDGET_SET_FLAGS (image, GTK_CAN_FOCUS);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 g_signal_connect(G_OBJECT(docklet), "embedded", G_CALLBACK(docklet_x11_embedded_cb), NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 g_signal_connect(G_OBJECT(docklet), "destroy", G_CALLBACK(docklet_x11_destroyed_cb), NULL);
15775
f3ebd1c17c7b change icon on resize
Sean Egan <seanegan@gmail.com>
parents: 15774
diff changeset
294 g_signal_connect(G_OBJECT(docklet), "size-allocate", G_CALLBACK(docklet_x11_resize_icon), NULL);
23767
7c58107415bc Make docklet menu appear on button press instead of release to match
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 22011
diff changeset
295 g_signal_connect(G_OBJECT(box), "button-press-event", G_CALLBACK(docklet_x11_clicked_cb), NULL);
27177
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
296 g_signal_connect(G_OBJECT(box), "key-press-event", G_CALLBACK(docklet_x11_pressed_cb), NULL);
211b59ac6345 Apply patch that adds support for keyboard navigation for the status icon.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25415
diff changeset
297 g_signal_connect(G_OBJECT(box), "popup-menu", G_CALLBACK(docklet_x11_popup_cb), NULL);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 gtk_container_add(GTK_CONTAINER(box), image);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 gtk_container_add(GTK_CONTAINER(docklet), box);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301 if (!gtk_check_version(2,4,0))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302 g_object_set(G_OBJECT(box), "visible-window", FALSE, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 gtk_widget_show_all(GTK_WIDGET(docklet));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 /* ref the docklet before we bandy it about the place */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 g_object_ref(G_OBJECT(docklet));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309 /* This is a hack to avoid a race condition between the docklet getting
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310 * embedded in the notification area and the gtkblist restoring its
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 * previous visibility state. If the docklet does not get embedded within
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 * the timeout, it will be removed as a visibility manager until it does
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 * get embedded. Ideally, we would only call docklet_embedded() when the
16560
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
314 * icon was actually embedded. This only happens when the docklet is first
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
315 * created, not when being recreated.
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
316 *
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
317 * The x11 docklet tracks whether it successfully embedded in a pref and
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
318 * allows for a longer timeout period if it successfully embedded the last
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
319 * time it was run. This should hopefully solve problems with the buddy
17772
a8d6f071eb6d Get rid of 'Gaim' in a few more places
Mark Doliner <mark@kingant.net>
parents: 16949
diff changeset
320 * list not properly starting hidden when Pidgin is started on login.
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321 */
16560
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
322 if(!recreate) {
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
323 pidgin_docklet_embedded();
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
324 if(purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/docklet/x11/embedded")) {
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
325 embed_timeout = g_timeout_add(LONG_EMBED_TIMEOUT, docklet_x11_embed_timeout_cb, NULL);
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
326 } else {
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
327 embed_timeout = g_timeout_add(SHORT_EMBED_TIMEOUT, docklet_x11_embed_timeout_cb, NULL);
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
328 }
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
329 }
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15822
diff changeset
331 purple_debug(PURPLE_DEBUG_INFO, "docklet", "created\n");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333
16560
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
334 static void
22007
c38d72677c8a Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents: 21913
diff changeset
335 docklet_x11_create_ui_op(void)
16560
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
336 {
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
337 docklet_x11_create(FALSE);
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
338 }
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
339
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340 static struct docklet_ui_ops ui_ops =
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 {
16560
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
342 docklet_x11_create_ui_op,
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 docklet_x11_destroy,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344 docklet_x11_update_icon,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 docklet_x11_blank_icon,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 docklet_x11_set_tooltip,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 #if GTK_CHECK_VERSION(2,2,0)
20888
d3e0eb05ac94 disapproval of revision '03054fd9afde1bcdafb721ed7712638568c3a3e1'
Casey Harkins <charkins@pidgin.im>
parents: 20882
diff changeset
348 docklet_x11_position_menu
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 #else
20888
d3e0eb05ac94 disapproval of revision '03054fd9afde1bcdafb721ed7712638568c3a3e1'
Casey Harkins <charkins@pidgin.im>
parents: 20882
diff changeset
350 NULL
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354 void
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355 docklet_ui_init()
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 {
15501
d75099d2567e gaim_gtk to pidgin. I hope
Sean Egan <seanegan@gmail.com>
parents: 15438
diff changeset
357 pidgin_docklet_set_ui_ops(&ui_ops);
16560
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
358 purple_prefs_add_none(PIDGIN_PREFS_ROOT "/docklet/x11");
17ac25319a77 Quoth Charkins:
Luke Schierer <lschiere@pidgin.im>
parents: 16325
diff changeset
359 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/docklet/x11/embedded", FALSE);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360 }