annotate src/statusicon/gtktrayicon-x11.c @ 3052:95b34f46a231

Comment out MPEG2/MPEG4 determination using the variable id. It is not used anywhere. Code analysis run, unique ID 6nYoHM.
author Tony Vroon <chainsaw@gentoo.org>
date Sat, 18 Apr 2009 19:06:20 +0100
parents 3134a0987162
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
1 /* gtktrayicon.c
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
2 * Copyright (C) 2002 Anders Carlsson <andersca@gnu.org>
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
3 *
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
4 * Adapted by Giacomo Lozito for Audacious Status Icon Plugin
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
5 *
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
6 * This library is free software; you can redistribute it and/or
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
8 * License as published by the Free Software Foundation; either
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
9 * version 2 of the License, or (at your option) any later version.
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
10 *
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
11 * This library is distributed in the hope that it will be useful,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
14 * Lesser General Public License for more details.
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
15 *
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
17 * License along with this library; if not, write to the
2835
f1b6f1b2cdb3 fixed FSF address
Andrew O. Shadoura <bugzilla@tut.by>
parents: 886
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
f1b6f1b2cdb3 fixed FSF address
Andrew O. Shadoura <bugzilla@tut.by>
parents: 886
diff changeset
19 * Boston, MA 02110-1301, USA.
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
20 */
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
21
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
22 /*
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
23 * This is an implementation of the freedesktop.org "system tray" spec,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
24 * http://www.freedesktop.org/wiki/Standards/systemtray-spec
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
25 */
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
26
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
27 #include "si_common.h"
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
28 #include <string.h>
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
29 #include <glib.h>
2971
3134a0987162 - changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2835
diff changeset
30 #include <audlegacy/i18n.h>
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
31
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
32 #include <gtk/gtkprivate.h>
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
33 #include "gtktrayicon.h"
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
34
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
35 #include <gdk/gdkx.h>
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
36 #include <X11/Xatom.h>
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
37
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
38 #define SYSTEM_TRAY_REQUEST_DOCK 0
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
39 #define SYSTEM_TRAY_BEGIN_MESSAGE 1
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
40 #define SYSTEM_TRAY_CANCEL_MESSAGE 2
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
41
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
42 #define SYSTEM_TRAY_ORIENTATION_HORZ 0
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
43 #define SYSTEM_TRAY_ORIENTATION_VERT 1
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
44
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
45 enum {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
46 PROP_0,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
47 PROP_ORIENTATION
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
48 };
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
49
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
50 struct _AudGtkTrayIconPrivate
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
51 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
52 guint stamp;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
53
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
54 Atom selection_atom;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
55 Atom manager_atom;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
56 Atom system_tray_opcode_atom;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
57 Atom orientation_atom;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
58 Window manager_window;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
59
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
60 GtkOrientation orientation;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
61 };
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
62
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
63 static void aud_gtk_tray_icon_get_property (GObject *object,
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
64 guint prop_id,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
65 GValue *value,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
66 GParamSpec *pspec);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
67
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
68 static void aud_gtk_tray_icon_realize (GtkWidget *widget);
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
69 static void aud_gtk_tray_icon_unrealize (GtkWidget *widget);
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
70 static gboolean aud_gtk_tray_icon_delete (GtkWidget *widget,
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
71 GdkEventAny *event);
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
72 static gboolean aud_gtk_tray_icon_expose (GtkWidget *widget,
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
73 GdkEventExpose *event);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
74
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
75 static void aud_gtk_tray_icon_update_manager_window (AudGtkTrayIcon *icon,
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
76 gboolean dock_if_realized);
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
77 static void aud_gtk_tray_icon_manager_window_destroyed (AudGtkTrayIcon *icon);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
78
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
79 static void aud_gtk_tray_icon_init (AudGtkTrayIcon *self);
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
80 static void aud_gtk_tray_icon_class_init (AudGtkTrayIconClass *klass);
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
81 static gpointer aud_gtk_tray_icon_parent_class = NULL;
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
82 static void aud_gtk_tray_icon_class_intern_init (gpointer klass)
876
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
83 {
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
84 aud_gtk_tray_icon_parent_class = g_type_class_peek_parent (klass);
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
85 aud_gtk_tray_icon_class_init ((AudGtkTrayIconClass*) klass);
876
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
86 }
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
87
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
88 GType
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
89 aud_gtk_tray_icon_get_type (void)
876
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
90 {
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
91 static GType g_define_type_id = 0;
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
92 g_define_type_id = g_type_from_name( "AudGtkTrayIcon" );
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
93 if (G_UNLIKELY (g_define_type_id == 0))
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
94 {
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
95 static const GTypeInfo g_define_type_info = {
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
96 sizeof (AudGtkTrayIconClass),
876
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
97 (GBaseInitFunc) NULL,
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
98 (GBaseFinalizeFunc) NULL,
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
99 (GClassInitFunc) aud_gtk_tray_icon_class_intern_init,
876
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
100 (GClassFinalizeFunc) NULL,
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
101 NULL, /* class_data */
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
102 sizeof (AudGtkTrayIcon),
876
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
103 0, /* n_preallocs */
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
104 (GInstanceInitFunc) aud_gtk_tray_icon_init,
876
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
105 };
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
106 g_define_type_id = g_type_register_static (GTK_TYPE_PLUG, "AudGtkTrayIcon", &g_define_type_info, 0);
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
107 }
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
108 else if ( aud_gtk_tray_icon_parent_class == NULL )
876
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
109 {
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
110 gpointer klass = g_type_class_peek( g_define_type_id );
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
111 aud_gtk_tray_icon_parent_class = g_type_class_peek_parent(klass);
876
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
112 }
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
113 return g_define_type_id;
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
114 }
04a56ecc9442 [svn] statusicon: do not behave strangely (or crash) when the plugin is loaded/unloaded multiple times
giacomo
parents: 528
diff changeset
115
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
116
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
117 static void
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
118 aud_gtk_tray_icon_class_init (AudGtkTrayIconClass *class)
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
119 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
120 GObjectClass *gobject_class = (GObjectClass *)class;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
121 GtkWidgetClass *widget_class = (GtkWidgetClass *)class;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
122
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
123 gobject_class->get_property = aud_gtk_tray_icon_get_property;
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
124
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
125 widget_class->realize = aud_gtk_tray_icon_realize;
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
126 widget_class->unrealize = aud_gtk_tray_icon_unrealize;
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
127 widget_class->delete_event = aud_gtk_tray_icon_delete;
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
128 widget_class->expose_event = aud_gtk_tray_icon_expose;
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
129
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
130 g_object_class_install_property (gobject_class,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
131 PROP_ORIENTATION,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
132 g_param_spec_enum ("orientation",
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
133 _("Orientation"),
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
134 _("The orientation of the tray"),
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
135 GTK_TYPE_ORIENTATION,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
136 GTK_ORIENTATION_HORIZONTAL,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
137 GTK_PARAM_READABLE));
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
138
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
139 g_type_class_add_private (class, sizeof (AudGtkTrayIconPrivate));
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
140 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
141
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
142 static void
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
143 aud_gtk_tray_icon_init (AudGtkTrayIcon *icon)
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
144 {
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
145 icon->priv = G_TYPE_INSTANCE_GET_PRIVATE (icon, AUD_GTK_TYPE_TRAY_ICON,
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
146 AudGtkTrayIconPrivate);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
147
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
148 icon->priv->stamp = 1;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
149 icon->priv->orientation = GTK_ORIENTATION_HORIZONTAL;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
150
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
151 gtk_widget_set_app_paintable (GTK_WIDGET (icon), TRUE);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
152 gtk_widget_set_double_buffered (GTK_WIDGET (icon), FALSE);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
153 gtk_widget_add_events (GTK_WIDGET (icon), GDK_PROPERTY_CHANGE_MASK);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
154 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
155
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
156 static void
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
157 aud_gtk_tray_icon_get_property (GObject *object,
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
158 guint prop_id,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
159 GValue *value,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
160 GParamSpec *pspec)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
161 {
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
162 AudGtkTrayIcon *icon = AUD_GTK_TRAY_ICON (object);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
163
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
164 switch (prop_id)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
165 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
166 case PROP_ORIENTATION:
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
167 g_value_set_enum (value, icon->priv->orientation);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
168 break;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
169 default:
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
170 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
171 break;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
172 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
173 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
174
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
175 static gboolean
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
176 aud_gtk_tray_icon_expose (GtkWidget *widget,
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
177 GdkEventExpose *event)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
178 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
179 gdk_window_clear_area (widget->window, event->area.x, event->area.y,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
180 event->area.width, event->area.height);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
181
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
182 if (GTK_WIDGET_CLASS (aud_gtk_tray_icon_parent_class)->expose_event)
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
183 return GTK_WIDGET_CLASS (aud_gtk_tray_icon_parent_class)->expose_event (widget, event);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
184
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
185 return FALSE;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
186 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
187
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
188 static void
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
189 aud_gtk_tray_icon_get_orientation_property (AudGtkTrayIcon *icon)
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
190 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
191 Display *xdisplay;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
192 Atom type;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
193 int format;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
194 union {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
195 gulong *prop;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
196 guchar *prop_ch;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
197 } prop = { NULL };
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
198 gulong nitems;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
199 gulong bytes_after;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
200 int error, result;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
201
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
202 g_assert (icon->priv->manager_window != None);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
203
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
204 xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
205
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
206 gdk_error_trap_push ();
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
207 type = None;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
208 result = XGetWindowProperty (xdisplay,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
209 icon->priv->manager_window,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
210 icon->priv->orientation_atom,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
211 0, G_MAXLONG, FALSE,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
212 XA_CARDINAL,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
213 &type, &format, &nitems,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
214 &bytes_after, &(prop.prop_ch));
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
215 error = gdk_error_trap_pop ();
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
216
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
217 if (error || result != Success)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
218 return;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
219
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
220 if (type == XA_CARDINAL)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
221 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
222 GtkOrientation orientation;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
223
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
224 orientation = (prop.prop [0] == SYSTEM_TRAY_ORIENTATION_HORZ) ?
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
225 GTK_ORIENTATION_HORIZONTAL :
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
226 GTK_ORIENTATION_VERTICAL;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
227
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
228 if (icon->priv->orientation != orientation)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
229 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
230 icon->priv->orientation = orientation;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
231
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
232 g_object_notify (G_OBJECT (icon), "orientation");
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
233 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
234 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
235
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
236 if (prop.prop)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
237 XFree (prop.prop);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
238 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
239
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
240 static GdkFilterReturn
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
241 aud_gtk_tray_icon_manager_filter (GdkXEvent *xevent,
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
242 GdkEvent *event,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
243 gpointer user_data)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
244 {
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
245 AudGtkTrayIcon *icon = user_data;
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
246 XEvent *xev = (XEvent *)xevent;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
247
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
248 if (xev->xany.type == ClientMessage &&
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
249 xev->xclient.message_type == icon->priv->manager_atom &&
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
250 xev->xclient.data.l[1] == icon->priv->selection_atom)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
251 {
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
252 aud_gtk_tray_icon_update_manager_window (icon, TRUE);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
253 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
254 else if (xev->xany.window == icon->priv->manager_window)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
255 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
256 if (xev->xany.type == PropertyNotify &&
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
257 xev->xproperty.atom == icon->priv->orientation_atom)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
258 {
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
259 aud_gtk_tray_icon_get_orientation_property (icon);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
260 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
261 if (xev->xany.type == DestroyNotify)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
262 {
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
263 aud_gtk_tray_icon_manager_window_destroyed (icon);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
264 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
265 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
266
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
267 return GDK_FILTER_CONTINUE;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
268 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
269
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
270 static void
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
271 aud_gtk_tray_icon_unrealize (GtkWidget *widget)
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
272 {
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
273 AudGtkTrayIcon *icon = AUD_GTK_TRAY_ICON (widget);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
274 GdkWindow *root_window;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
275
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
276 if (icon->priv->manager_window != None)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
277 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
278 GdkWindow *gdkwin;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
279
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
280 gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget),
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
281 icon->priv->manager_window);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
282
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
283 gdk_window_remove_filter (gdkwin, aud_gtk_tray_icon_manager_filter, icon);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
284 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
285
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
286 root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
287
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
288 gdk_window_remove_filter (root_window, aud_gtk_tray_icon_manager_filter, icon);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
289
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
290 if (GTK_WIDGET_CLASS (aud_gtk_tray_icon_parent_class)->unrealize)
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
291 (* GTK_WIDGET_CLASS (aud_gtk_tray_icon_parent_class)->unrealize) (widget);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
292 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
293
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
294 static void
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
295 aud_gtk_tray_icon_send_manager_message (AudGtkTrayIcon *icon,
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
296 long message,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
297 Window window,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
298 long data1,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
299 long data2,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
300 long data3)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
301 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
302 XClientMessageEvent ev;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
303 Display *display;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
304
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
305 memset (&ev, 0, sizeof (ev));
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
306 ev.type = ClientMessage;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
307 ev.window = window;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
308 ev.message_type = icon->priv->system_tray_opcode_atom;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
309 ev.format = 32;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
310 ev.data.l[0] = gdk_x11_get_server_time (GTK_WIDGET (icon)->window);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
311 ev.data.l[1] = message;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
312 ev.data.l[2] = data1;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
313 ev.data.l[3] = data2;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
314 ev.data.l[4] = data3;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
315
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
316 display = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
317
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
318 gdk_error_trap_push ();
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
319 XSendEvent (display,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
320 icon->priv->manager_window, False, NoEventMask, (XEvent *)&ev);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
321 XSync (display, False);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
322 gdk_error_trap_pop ();
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
323 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
324
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
325 static void
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
326 aud_gtk_tray_icon_send_dock_request (AudGtkTrayIcon *icon)
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
327 {
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
328 aud_gtk_tray_icon_send_manager_message (icon,
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
329 SYSTEM_TRAY_REQUEST_DOCK,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
330 icon->priv->manager_window,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
331 gtk_plug_get_id (GTK_PLUG (icon)),
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
332 0, 0);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
333 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
334
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
335 static void
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
336 aud_gtk_tray_icon_update_manager_window (AudGtkTrayIcon *icon,
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
337 gboolean dock_if_realized)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
338 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
339 Display *xdisplay;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
340
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
341 if (icon->priv->manager_window != None)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
342 return;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
343
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
344 xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
345
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
346 XGrabServer (xdisplay);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
347
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
348 icon->priv->manager_window = XGetSelectionOwner (xdisplay,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
349 icon->priv->selection_atom);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
350
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
351 if (icon->priv->manager_window != None)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
352 XSelectInput (xdisplay,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
353 icon->priv->manager_window, StructureNotifyMask|PropertyChangeMask);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
354
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
355 XUngrabServer (xdisplay);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
356 XFlush (xdisplay);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
357
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
358 if (icon->priv->manager_window != None)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
359 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
360 GdkWindow *gdkwin;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
361
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
362 gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
363 icon->priv->manager_window);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
364
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
365 gdk_window_add_filter (gdkwin, aud_gtk_tray_icon_manager_filter, icon);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
366
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
367 if (dock_if_realized && GTK_WIDGET_REALIZED (icon))
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
368 aud_gtk_tray_icon_send_dock_request (icon);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
369
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
370 aud_gtk_tray_icon_get_orientation_property (icon);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
371 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
372 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
373
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
374 static void
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
375 aud_gtk_tray_icon_manager_window_destroyed (AudGtkTrayIcon *icon)
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
376 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
377 GdkWindow *gdkwin;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
378
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
379 g_return_if_fail (icon->priv->manager_window != None);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
380
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
381 gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
382 icon->priv->manager_window);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
383
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
384 gdk_window_remove_filter (gdkwin, aud_gtk_tray_icon_manager_filter, icon);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
385
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
386 icon->priv->manager_window = None;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
387
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
388 aud_gtk_tray_icon_update_manager_window (icon, TRUE);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
389 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
390
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
391 static gboolean
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
392 aud_gtk_tray_icon_delete (GtkWidget *widget,
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
393 GdkEventAny *event)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
394 {
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
395 AudGtkTrayIcon *icon = AUD_GTK_TRAY_ICON (widget);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
396 GdkWindow *gdkwin;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
397
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
398 if (icon->priv->manager_window != None)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
399 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
400 gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
401 icon->priv->manager_window);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
402
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
403 gdk_window_remove_filter (gdkwin, aud_gtk_tray_icon_manager_filter, icon);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
404
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
405 icon->priv->manager_window = None;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
406 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
407
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
408 aud_gtk_tray_icon_update_manager_window (icon, TRUE);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
409
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
410 return TRUE;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
411 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
412
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
413 static void
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
414 aud_gtk_tray_icon_realize (GtkWidget *widget)
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
415 {
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
416 AudGtkTrayIcon *icon = AUD_GTK_TRAY_ICON (widget);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
417 GdkScreen *screen;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
418 GdkDisplay *display;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
419 Display *xdisplay;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
420 char buffer[256];
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
421 GdkWindow *root_window;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
422
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
423 if (GTK_WIDGET_CLASS (aud_gtk_tray_icon_parent_class)->realize)
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
424 GTK_WIDGET_CLASS (aud_gtk_tray_icon_parent_class)->realize (widget);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
425
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
426 screen = gtk_widget_get_screen (widget);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
427 display = gdk_screen_get_display (screen);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
428 xdisplay = gdk_x11_display_get_xdisplay (display);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
429
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
430 /* Now see if there's a manager window around */
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
431 g_snprintf (buffer, sizeof (buffer),
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
432 "_NET_SYSTEM_TRAY_S%d",
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
433 gdk_screen_get_number (screen));
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
434
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
435 icon->priv->selection_atom = XInternAtom (xdisplay, buffer, False);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
436
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
437 icon->priv->manager_atom = XInternAtom (xdisplay, "MANAGER", False);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
438
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
439 icon->priv->system_tray_opcode_atom = XInternAtom (xdisplay,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
440 "_NET_SYSTEM_TRAY_OPCODE",
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
441 False);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
442
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
443 icon->priv->orientation_atom = XInternAtom (xdisplay,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
444 "_NET_SYSTEM_TRAY_ORIENTATION",
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
445 False);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
446
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
447 aud_gtk_tray_icon_update_manager_window (icon, FALSE);
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
448 aud_gtk_tray_icon_send_dock_request (icon);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
449
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
450 root_window = gdk_screen_get_root_window (screen);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
451
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
452 /* Add a root window filter so that we get changes on MANAGER */
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
453 gdk_window_add_filter (root_window,
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
454 aud_gtk_tray_icon_manager_filter, icon);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
455 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
456
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
457 guint
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
458 _aud_gtk_tray_icon_send_message (AudGtkTrayIcon *icon,
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
459 gint timeout,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
460 const gchar *message,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
461 gint len)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
462 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
463 guint stamp;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
464
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
465 g_return_val_if_fail (AUD_GTK_IS_TRAY_ICON (icon), 0);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
466 g_return_val_if_fail (timeout >= 0, 0);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
467 g_return_val_if_fail (message != NULL, 0);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
468
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
469 if (icon->priv->manager_window == None)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
470 return 0;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
471
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
472 if (len < 0)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
473 len = strlen (message);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
474
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
475 stamp = icon->priv->stamp++;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
476
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
477 /* Get ready to send the message */
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
478 aud_gtk_tray_icon_send_manager_message (icon, SYSTEM_TRAY_BEGIN_MESSAGE,
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
479 (Window)gtk_plug_get_id (GTK_PLUG (icon)),
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
480 timeout, len, stamp);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
481
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
482 /* Now to send the actual message */
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
483 gdk_error_trap_push ();
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
484 while (len > 0)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
485 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
486 XClientMessageEvent ev;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
487 Display *xdisplay;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
488
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
489 xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
490
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
491 memset (&ev, 0, sizeof (ev));
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
492 ev.type = ClientMessage;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
493 ev.window = (Window)gtk_plug_get_id (GTK_PLUG (icon));
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
494 ev.format = 8;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
495 ev.message_type = XInternAtom (xdisplay,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
496 "_NET_SYSTEM_TRAY_MESSAGE_DATA", False);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
497 if (len > 20)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
498 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
499 memcpy (&ev.data, message, 20);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
500 len -= 20;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
501 message += 20;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
502 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
503 else
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
504 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
505 memcpy (&ev.data, message, len);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
506 len = 0;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
507 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
508
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
509 XSendEvent (xdisplay,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
510 icon->priv->manager_window, False,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
511 StructureNotifyMask, (XEvent *)&ev);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
512 XSync (xdisplay, False);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
513 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
514
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
515 gdk_error_trap_pop ();
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
516
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
517 return stamp;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
518 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
519
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
520 void
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
521 _aud_gtk_tray_icon_cancel_message (AudGtkTrayIcon *icon,
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
522 guint id)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
523 {
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
524 g_return_if_fail (AUD_GTK_IS_TRAY_ICON (icon));
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
525 g_return_if_fail (id > 0);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
526
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
527 aud_gtk_tray_icon_send_manager_message (icon, SYSTEM_TRAY_CANCEL_MESSAGE,
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
528 (Window)gtk_plug_get_id (GTK_PLUG (icon)),
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
529 id, 0, 0);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
530 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
531
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
532 AudGtkTrayIcon *
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
533 _aud_gtk_tray_icon_new_for_screen (GdkScreen *screen,
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
534 const gchar *name)
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
535 {
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
536 g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
537
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
538 return g_object_new (AUD_GTK_TYPE_TRAY_ICON,
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
539 "screen", screen,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
540 "title", name,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
541 NULL);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
542 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
543
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
544 AudGtkTrayIcon *
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
545 _aud_gtk_tray_icon_new (const gchar *name)
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
546 {
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
547 return g_object_new (AUD_GTK_TYPE_TRAY_ICON,
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
548 "title", name,
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
549 NULL);
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
550 }
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
551
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
552 GtkOrientation
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
553 _aud_gtk_tray_icon_get_orientation (AudGtkTrayIcon *icon)
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
554 {
886
f2fde7b4dccd [svn] - statusicon: use function/define names that do not collide with gtk >= 2.10 internals (paranoia)
giacomo
parents: 876
diff changeset
555 g_return_val_if_fail (AUD_GTK_IS_TRAY_ICON (icon), GTK_ORIENTATION_HORIZONTAL);
433
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
556
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
557 return icon->priv->orientation;
38fe08dff5cd [svn] - added status icon plugin (written from scratch, with code from gtk 2.10)
giacomo
parents:
diff changeset
558 }