annotate pidgin/gtkdocklet-gtk.c @ 30517:26c1c5069c28

GtkStatusIcon only exposes a single button press on a Mac for whatever reason, so we'll have to make do with only showing the menu, and not toggling the buddy list visibility. Refs #2629.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Wed, 26 May 2010 07:23:29 +0000
parents 23dbe381eb7a
children 3ed54142386f 7fb5e60fd919
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29627
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
1 /*
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
2 * System tray icon (aka docklet) plugin for Purple
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
3 *
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
4 * Copyright (C) 2007 Anders Hasselqvist
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
5 *
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
8 * published by the Free Software Foundation; either version 2 of the
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
9 * License, or (at your option) any later version.
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
10 *
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful, but
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
14 * General Public License for more details.
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
15 *
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
19 * 02111-1307, USA.
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
20 */
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
21
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
22 #include "internal.h"
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
23 #include "pidgin.h"
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
24 #include "debug.h"
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
25 #include "prefs.h"
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
26 #include "pidginstock.h"
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
27 #include "gtkdocklet.h"
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
28
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
29 /* globals */
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
30 GtkStatusIcon *docklet = NULL;
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
31
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
32 static void
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
33 docklet_gtk_status_activated_cb(GtkStatusIcon *status_icon, gpointer user_data)
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
34 {
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
35 pidgin_docklet_clicked(1);
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
36 }
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
37
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
38 static void
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
39 docklet_gtk_status_clicked_cb(GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data)
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
40 {
30517
26c1c5069c28 GtkStatusIcon only exposes a single button press on a Mac for whatever
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30381
diff changeset
41 purple_debug_info("docklet", "The button is %u\n", button);
26c1c5069c28 GtkStatusIcon only exposes a single button press on a Mac for whatever
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30381
diff changeset
42 #ifdef GDK_WINDOWING_QUARTZ
26c1c5069c28 GtkStatusIcon only exposes a single button press on a Mac for whatever
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30381
diff changeset
43 /* You can only click left mouse button on MacOSX native GTK. Let that be the menu */
26c1c5069c28 GtkStatusIcon only exposes a single button press on a Mac for whatever
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30381
diff changeset
44 pidgin_docklet_clicked(3);
26c1c5069c28 GtkStatusIcon only exposes a single button press on a Mac for whatever
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30381
diff changeset
45 #else
26c1c5069c28 GtkStatusIcon only exposes a single button press on a Mac for whatever
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30381
diff changeset
46 pidgin_docklet_clicked(button);
26c1c5069c28 GtkStatusIcon only exposes a single button press on a Mac for whatever
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30381
diff changeset
47 #endif
29627
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
48 }
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
49
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
50 static void
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
51 docklet_gtk_status_update_icon(PurpleStatusPrimitive status, gboolean connecting, gboolean pending)
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
52 {
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
53 const gchar *icon_name = NULL;
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
54
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
55 switch (status) {
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
56 case PURPLE_STATUS_OFFLINE:
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
57 icon_name = PIDGIN_STOCK_TRAY_OFFLINE;
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
58 break;
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
59 case PURPLE_STATUS_AWAY:
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
60 icon_name = PIDGIN_STOCK_TRAY_AWAY;
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
61 break;
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
62 case PURPLE_STATUS_UNAVAILABLE:
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
63 icon_name = PIDGIN_STOCK_TRAY_BUSY;
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
64 break;
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
65 case PURPLE_STATUS_EXTENDED_AWAY:
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
66 icon_name = PIDGIN_STOCK_TRAY_XA;
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
67 break;
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
68 case PURPLE_STATUS_INVISIBLE:
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
69 icon_name = PIDGIN_STOCK_TRAY_INVISIBLE;
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
70 break;
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
71 default:
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
72 icon_name = PIDGIN_STOCK_TRAY_AVAILABLE;
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
73 break;
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
74 }
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
75
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
76 if (pending)
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
77 icon_name = PIDGIN_STOCK_TRAY_PENDING;
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
78 if (connecting)
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
79 icon_name = PIDGIN_STOCK_TRAY_CONNECT;
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
80
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
81 if (icon_name) {
29717
87e124c52a47 Change lookup of docklet icons to use an 'icon name' instead of a stock
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29627
diff changeset
82 gtk_status_icon_set_from_icon_name(docklet, icon_name);
29627
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
83 }
30372
fb0245b8c177 pidgin: Add charkins's patch for gtkstatusicon blinking. Fixes #11855
Paul Aurich <paul@darkrain42.org>
parents: 29802
diff changeset
84
fb0245b8c177 pidgin: Add charkins's patch for gtkstatusicon blinking. Fixes #11855
Paul Aurich <paul@darkrain42.org>
parents: 29802
diff changeset
85 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/docklet/blink")) {
fb0245b8c177 pidgin: Add charkins's patch for gtkstatusicon blinking. Fixes #11855
Paul Aurich <paul@darkrain42.org>
parents: 29802
diff changeset
86 gtk_status_icon_set_blinking(docklet, (pending && !connecting));
fb0245b8c177 pidgin: Add charkins's patch for gtkstatusicon blinking. Fixes #11855
Paul Aurich <paul@darkrain42.org>
parents: 29802
diff changeset
87 } else if (gtk_status_icon_get_blinking(docklet)) {
fb0245b8c177 pidgin: Add charkins's patch for gtkstatusicon blinking. Fixes #11855
Paul Aurich <paul@darkrain42.org>
parents: 29802
diff changeset
88 gtk_status_icon_set_blinking(docklet, FALSE);
fb0245b8c177 pidgin: Add charkins's patch for gtkstatusicon blinking. Fixes #11855
Paul Aurich <paul@darkrain42.org>
parents: 29802
diff changeset
89 }
29627
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
90 }
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
91
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
92 static void
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
93 docklet_gtk_status_set_tooltip(gchar *tooltip)
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
94 {
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
95 if (tooltip) {
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
96 gtk_status_icon_set_tooltip(docklet, tooltip);
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
97 } else {
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
98 gtk_status_icon_set_tooltip(docklet, NULL);
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
99 }
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
100 }
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
101
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
102 static void
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
103 docklet_gtk_status_position_menu(GtkMenu *menu,
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
104 int *x, int *y, gboolean *push_in,
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
105 gpointer user_data)
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
106 {
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
107 gtk_status_icon_position_menu(menu, x, y, push_in, docklet);
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
108 }
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
109
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
110 static void
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
111 docklet_gtk_status_destroy(void)
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
112 {
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
113 g_return_if_fail(docklet != NULL);
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
114
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
115 pidgin_docklet_remove();
30381
23dbe381eb7a Set the GtkTrayIcon invisible before unref'ing it, or else it will leave
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30372
diff changeset
116
23dbe381eb7a Set the GtkTrayIcon invisible before unref'ing it, or else it will leave
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 30372
diff changeset
117 gtk_status_icon_set_visible(docklet, FALSE);
29627
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
118 g_object_unref(G_OBJECT(docklet));
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
119 docklet = NULL;
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
120
29762
5a6c66d4de94 Make it slightly clearer which docklet is in use.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29717
diff changeset
121 purple_debug_info("docklet", "GTK+ destroyed\n");
29627
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
122 }
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
123
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
124 static void
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
125 docklet_gtk_status_create(gboolean recreate)
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
126 {
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
127 if (docklet) {
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
128 /* if this is being called when a tray icon exists, it's because
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
129 something messed up. try destroying it before we proceed,
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
130 although docklet_refcount may be all hosed. hopefully won't happen. */
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
131 purple_debug_warning("docklet", "trying to create icon but it already exists?\n");
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
132 docklet_gtk_status_destroy();
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
133 }
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
134
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
135 docklet = gtk_status_icon_new();
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
136 g_return_if_fail(docklet != NULL);
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
137
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
138 g_signal_connect(G_OBJECT(docklet), "activate", G_CALLBACK(docklet_gtk_status_activated_cb), NULL);
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
139 g_signal_connect(G_OBJECT(docklet), "popup-menu", G_CALLBACK(docklet_gtk_status_clicked_cb), NULL);
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
140
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
141 pidgin_docklet_embedded();
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
142 gtk_status_icon_set_visible(docklet, TRUE);
29762
5a6c66d4de94 Make it slightly clearer which docklet is in use.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29717
diff changeset
143 purple_debug_info("docklet", "GTK+ created\n");
29627
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
144 }
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
145
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
146 static void
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
147 docklet_gtk_status_create_ui_op(void)
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
148 {
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
149 docklet_gtk_status_create(FALSE);
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
150 }
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
151
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
152 static struct docklet_ui_ops ui_ops =
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
153 {
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
154 docklet_gtk_status_create_ui_op,
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
155 docklet_gtk_status_destroy,
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
156 docklet_gtk_status_update_icon,
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
157 NULL,
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
158 docklet_gtk_status_set_tooltip,
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
159 docklet_gtk_status_position_menu
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
160 };
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
161
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
162 void
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
163 docklet_ui_init(void)
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
164 {
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
165 pidgin_docklet_set_ui_ops(&ui_ops);
29717
87e124c52a47 Change lookup of docklet icons to use an 'icon name' instead of a stock
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29627
diff changeset
166 gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(),
87e124c52a47 Change lookup of docklet icons to use an 'icon name' instead of a stock
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 29627
diff changeset
167 DATADIR G_DIR_SEPARATOR_S "pixmaps" G_DIR_SEPARATOR_S "pidgin" G_DIR_SEPARATOR_S "tray");
29627
6652fdb8baf5 Apparently, I only just imagined adding this file.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff changeset
168 }