annotate gtk/eggtrayicon.c @ 14816:c538d7df38d6

[gaim-migrate @ 17582] Unleak committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Wed, 25 Oct 2006 12:53:41 +0000
parents 2c1781ea074c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14681
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 /* eggtrayicon.c
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2002 Anders Carlsson <andersca@gnu.org>
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 *
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 *
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * Lesser General Public License for more details.
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 *
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * License along with this library; if not, write to the
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * Boston, MA 02111-1307, USA.
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 #include <config.h>
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 #include <string.h>
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 #include "eggtrayicon.h"
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include <gdk/gdkx.h>
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include <X11/Xatom.h>
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #define _(x) x
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #define N_(x) x
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #define SYSTEM_TRAY_REQUEST_DOCK 0
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #define SYSTEM_TRAY_BEGIN_MESSAGE 1
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #define SYSTEM_TRAY_CANCEL_MESSAGE 2
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 #define SYSTEM_TRAY_ORIENTATION_HORZ 0
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 #define SYSTEM_TRAY_ORIENTATION_VERT 1
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 enum {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 PROP_0,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 PROP_ORIENTATION
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 };
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 static GtkPlugClass *parent_class = NULL;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 static void egg_tray_icon_init (EggTrayIcon *icon);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 static void egg_tray_icon_class_init (EggTrayIconClass *klass);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 static void egg_tray_icon_get_property (GObject *object,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 guint prop_id,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 GValue *value,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 GParamSpec *pspec);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 static void egg_tray_icon_realize (GtkWidget *widget);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 static void egg_tray_icon_unrealize (GtkWidget *widget);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 static void egg_tray_icon_add (GtkContainer *container,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 GtkWidget *widget);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 static void egg_tray_icon_update_manager_window (EggTrayIcon *icon,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 gboolean dock_if_realized);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 static void egg_tray_icon_manager_window_destroyed (EggTrayIcon *icon);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 GType
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 egg_tray_icon_get_type (void)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 static GType our_type = 0;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 if (our_type == 0)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 our_type = g_type_from_name("EggTrayIcon");
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 if (our_type == 0)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 static const GTypeInfo our_info =
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 sizeof (EggTrayIconClass),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 (GBaseInitFunc) NULL,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 (GBaseFinalizeFunc) NULL,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 (GClassInitFunc) egg_tray_icon_class_init,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 NULL, /* class_finalize */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 NULL, /* class_data */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 sizeof (EggTrayIcon),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 0, /* n_preallocs */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 (GInstanceInitFunc) egg_tray_icon_init,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 NULL /* value_table */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 };
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 our_type = g_type_register_static (GTK_TYPE_PLUG, "EggTrayIcon", &our_info, 0);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 else if (parent_class == NULL)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 /* we're reheating the old class from a previous instance - engage ugly hack =( */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 egg_tray_icon_class_init((EggTrayIconClass *)g_type_class_peek(our_type));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 return our_type;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 egg_tray_icon_init (EggTrayIcon *icon)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 icon->stamp = 1;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 icon->orientation = GTK_ORIENTATION_HORIZONTAL;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 gtk_widget_add_events (GTK_WIDGET (icon), GDK_PROPERTY_CHANGE_MASK);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 egg_tray_icon_class_init (EggTrayIconClass *klass)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 GObjectClass *gobject_class = (GObjectClass *)klass;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 GtkContainerClass *container_class = (GtkContainerClass *)klass;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 parent_class = g_type_class_peek_parent (klass);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 gobject_class->get_property = egg_tray_icon_get_property;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 widget_class->realize = egg_tray_icon_realize;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 widget_class->unrealize = egg_tray_icon_unrealize;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 container_class->add = egg_tray_icon_add;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 g_object_class_install_property (gobject_class,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 PROP_ORIENTATION,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 g_param_spec_enum ("orientation",
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 _("Orientation"),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 _("The orientation of the tray."),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 GTK_TYPE_ORIENTATION,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 GTK_ORIENTATION_HORIZONTAL,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 G_PARAM_READABLE));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 egg_tray_icon_get_property (GObject *object,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 guint prop_id,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 GValue *value,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 GParamSpec *pspec)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 EggTrayIcon *icon = EGG_TRAY_ICON (object);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 switch (prop_id)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 case PROP_ORIENTATION:
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 g_value_set_enum (value, icon->orientation);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 break;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 default:
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 break;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 egg_tray_icon_get_orientation_property (EggTrayIcon *icon)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 Display *xdisplay;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 Atom type;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 int format;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 union {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 gulong *prop;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 guchar *prop_ch;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 } prop = { NULL };
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 gulong nitems;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 gulong bytes_after;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 int error, result;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 g_return_if_fail(icon->manager_window != None);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 #if GTK_CHECK_VERSION(2,1,0)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 #else
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 xdisplay = gdk_display;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 #endif
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 gdk_error_trap_push ();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 type = None;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 result = XGetWindowProperty (xdisplay,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 icon->manager_window,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 icon->orientation_atom,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 0, G_MAXLONG, FALSE,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 XA_CARDINAL,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 &type, &format, &nitems,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 &bytes_after, &(prop.prop_ch));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 error = gdk_error_trap_pop ();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 if (error || result != Success)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 return;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 if (type == XA_CARDINAL)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 GtkOrientation orientation;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 orientation = (prop.prop [0] == SYSTEM_TRAY_ORIENTATION_HORZ) ?
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 GTK_ORIENTATION_HORIZONTAL :
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 GTK_ORIENTATION_VERTICAL;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 if (icon->orientation != orientation)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 icon->orientation = orientation;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 g_object_notify (G_OBJECT (icon), "orientation");
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 if (prop.prop)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 XFree (prop.prop);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 static GdkFilterReturn
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 egg_tray_icon_manager_filter (GdkXEvent *xevent, GdkEvent *event, gpointer user_data)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 EggTrayIcon *icon = user_data;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 XEvent *xev = (XEvent *)xevent;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 if (xev->xany.type == ClientMessage &&
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 xev->xclient.message_type == icon->manager_atom &&
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 xev->xclient.data.l[1] == icon->selection_atom)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 egg_tray_icon_update_manager_window (icon, TRUE);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 else if (xev->xany.window == icon->manager_window)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 if (xev->xany.type == PropertyNotify &&
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 xev->xproperty.atom == icon->orientation_atom)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 egg_tray_icon_get_orientation_property (icon);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 if (xev->xany.type == DestroyNotify)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 egg_tray_icon_manager_window_destroyed (icon);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 return GDK_FILTER_CONTINUE;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 egg_tray_icon_unrealize (GtkWidget *widget)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 EggTrayIcon *icon = EGG_TRAY_ICON (widget);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 GdkWindow *root_window;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 if (icon->manager_window != None)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 GdkWindow *gdkwin;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 #if GTK_CHECK_VERSION(2,1,0)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 icon->manager_window);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 #else
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 gdkwin = gdk_window_lookup (icon->manager_window);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 #endif
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 #if GTK_CHECK_VERSION(2,1,0)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 #else
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 root_window = gdk_window_lookup (gdk_x11_get_default_root_xwindow ());
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 #endif
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 gdk_window_remove_filter (root_window, egg_tray_icon_manager_filter, icon);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 if (GTK_WIDGET_CLASS (parent_class)->unrealize)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 egg_tray_icon_send_manager_message (EggTrayIcon *icon,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 long message,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 Window window,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 long data1,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 long data2,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 long data3)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 XClientMessageEvent ev;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 Display *display;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 ev.type = ClientMessage;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 ev.window = window;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 ev.message_type = icon->system_tray_opcode_atom;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 ev.format = 32;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 ev.data.l[0] = gdk_x11_get_server_time (GTK_WIDGET (icon)->window);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 ev.data.l[1] = message;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 ev.data.l[2] = data1;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 ev.data.l[3] = data2;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 ev.data.l[4] = data3;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 #if GTK_CHECK_VERSION(2,1,0)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 display = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 #else
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 display = gdk_display;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 #endif
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 gdk_error_trap_push ();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 XSendEvent (display,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 icon->manager_window, False, NoEventMask, (XEvent *)&ev);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301 XSync (display, False);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302 gdk_error_trap_pop ();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 egg_tray_icon_send_dock_request (EggTrayIcon *icon)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 egg_tray_icon_send_manager_message (icon,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309 SYSTEM_TRAY_REQUEST_DOCK,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310 icon->manager_window,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 gtk_plug_get_id (GTK_PLUG (icon)),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 0, 0);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316 egg_tray_icon_update_manager_window (EggTrayIcon *icon,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317 gboolean dock_if_realized)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 Display *xdisplay;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321 if (icon->manager_window != None)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322 return;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 #if GTK_CHECK_VERSION(2,1,0)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325 xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 #else
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 xdisplay = gdk_display;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 #endif
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 XGrabServer (xdisplay);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 icon->manager_window = XGetSelectionOwner (xdisplay,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 icon->selection_atom);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 if (icon->manager_window != None)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336 XSelectInput (xdisplay,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 icon->manager_window, StructureNotifyMask|PropertyChangeMask);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 XUngrabServer (xdisplay);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340 XFlush (xdisplay);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 if (icon->manager_window != None)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344 GdkWindow *gdkwin;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 #if GTK_CHECK_VERSION(2,1,0)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 icon->manager_window);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 #else
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 gdkwin = gdk_window_lookup (icon->manager_window);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 #endif
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 gdk_window_add_filter (gdkwin, egg_tray_icon_manager_filter, icon);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355 if (dock_if_realized && GTK_WIDGET_REALIZED (icon))
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 egg_tray_icon_send_dock_request (icon);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 egg_tray_icon_get_orientation_property (icon);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 egg_tray_icon_manager_window_destroyed (EggTrayIcon *icon)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365 GdkWindow *gdkwin;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 g_return_if_fail (icon->manager_window != None);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 #if GTK_CHECK_VERSION(2,1,0)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 icon->manager_window);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372 #else
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 gdkwin = gdk_window_lookup (icon->manager_window);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 #endif
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376 gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378 icon->manager_window = None;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 egg_tray_icon_update_manager_window (icon, TRUE);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383 static gboolean
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384 transparent_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 gdk_window_clear_area (widget->window, event->area.x, event->area.y,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387 event->area.width, event->area.height);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388 return FALSE;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 make_transparent_again (GtkWidget *widget, GtkStyle *previous_style,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393 gpointer user_data)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 gdk_window_set_back_pixmap(widget->window, NULL, TRUE);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399 make_transparent (GtkWidget *widget, gpointer user_data)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401 if (GTK_WIDGET_NO_WINDOW (widget) || GTK_WIDGET_APP_PAINTABLE (widget))
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402 return;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
404 gtk_widget_set_app_paintable (widget, TRUE);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
405 gtk_widget_set_double_buffered (widget, FALSE);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
406 gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407 g_signal_connect (widget, "expose_event",
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408 G_CALLBACK (transparent_expose_event), NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409 g_signal_connect_after (widget, "style_set",
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
410 G_CALLBACK (make_transparent_again), NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
411 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
412
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 egg_tray_icon_realize (GtkWidget *widget)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416 EggTrayIcon *icon = EGG_TRAY_ICON (widget);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417 gint screen;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418 Display *xdisplay;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419 char buffer[256];
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 GdkWindow *root_window;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422 if (GTK_WIDGET_CLASS (parent_class)->realize)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423 GTK_WIDGET_CLASS (parent_class)->realize (widget);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425 make_transparent (widget, NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
427 #if GTK_CHECK_VERSION(2,1,0)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
428 screen = gdk_screen_get_number (gtk_widget_get_screen (widget));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429 xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (widget));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430 #else
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431 screen = XScreenNumberOfScreen (DefaultScreenOfDisplay (gdk_display));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
432 xdisplay = gdk_display;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433 #endif
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
434
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
435 /* Now see if there's a manager window around */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
436 g_snprintf (buffer, sizeof (buffer),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437 "_NET_SYSTEM_TRAY_S%d",
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
438 screen);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440 icon->selection_atom = XInternAtom (xdisplay, buffer, False);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
441
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
442 icon->manager_atom = XInternAtom (xdisplay, "MANAGER", False);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
443
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444 icon->system_tray_opcode_atom = XInternAtom (xdisplay,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 "_NET_SYSTEM_TRAY_OPCODE",
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
446 False);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
448 icon->orientation_atom = XInternAtom (xdisplay,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449 "_NET_SYSTEM_TRAY_ORIENTATION",
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450 False);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
451
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452 egg_tray_icon_update_manager_window (icon, FALSE);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
453 egg_tray_icon_send_dock_request (icon);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
454
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455 #if GTK_CHECK_VERSION(2,1,0)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
456 root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457 #else
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458 root_window = gdk_window_lookup (gdk_x11_get_default_root_xwindow ());
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 #endif
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
460
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
461 /* Add a root window filter so that we get changes on MANAGER */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
462 gdk_window_add_filter (root_window,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
463 egg_tray_icon_manager_filter, icon);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
464 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
465
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
466 static void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
467 egg_tray_icon_add (GtkContainer *container, GtkWidget *widget)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
468 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
469 g_signal_connect (widget, "realize",
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470 G_CALLBACK (make_transparent), NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471 GTK_CONTAINER_CLASS (parent_class)->add (container, widget);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
472 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
473
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
474 #if GTK_CHECK_VERSION(2,1,0)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475 EggTrayIcon *
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
476 egg_tray_icon_new_for_screen (GdkScreen *screen, const char *name)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
477 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478 g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
479
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480 return g_object_new (EGG_TYPE_TRAY_ICON, "screen", screen, "title", name, NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482 #endif
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
484 EggTrayIcon*
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
485 egg_tray_icon_new (const gchar *name)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
486 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
487 return g_object_new (EGG_TYPE_TRAY_ICON, "title", name, NULL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
488 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490 guint
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
491 egg_tray_icon_send_message (EggTrayIcon *icon,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
492 gint timeout,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493 const gchar *message,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494 gint len)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
496 guint stamp;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
497
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
498 g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), 0);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499 g_return_val_if_fail (timeout >= 0, 0);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
500 g_return_val_if_fail (message != NULL, 0);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
502 if (icon->manager_window == None)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
503 return 0;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
505 if (len < 0)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
506 len = strlen (message);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508 stamp = icon->stamp++;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
510 /* Get ready to send the message */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511 egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_BEGIN_MESSAGE,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
512 (Window)gtk_plug_get_id (GTK_PLUG (icon)),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
513 timeout, len, stamp);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
514
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
515 /* Now to send the actual message */
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
516 gdk_error_trap_push ();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
517 while (len > 0)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
518 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
519 XClientMessageEvent ev;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
520 Display *xdisplay;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
521
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
522 #if GTK_CHECK_VERSION(2,1,0)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
523 xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
524 #else
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525 xdisplay = gdk_display;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
526 #endif
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
528 ev.type = ClientMessage;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529 ev.window = (Window)gtk_plug_get_id (GTK_PLUG (icon));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530 ev.format = 8;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531 ev.message_type = XInternAtom (xdisplay,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
532 "_NET_SYSTEM_TRAY_MESSAGE_DATA", False);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533 if (len > 20)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
534 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
535 memcpy (&ev.data, message, 20);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
536 len -= 20;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
537 message += 20;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
538 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
539 else
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
540 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
541 memcpy (&ev.data, message, len);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
542 len = 0;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
543 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
544
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
545 XSendEvent (xdisplay,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
546 icon->manager_window, False, StructureNotifyMask, (XEvent *)&ev);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547 XSync (xdisplay, False);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
548 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
549 gdk_error_trap_pop ();
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
550
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
551 return stamp;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
552 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
553
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
554 void
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
555 egg_tray_icon_cancel_message (EggTrayIcon *icon,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
556 guint id)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
557 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
558 g_return_if_fail (EGG_IS_TRAY_ICON (icon));
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
559 g_return_if_fail (id > 0);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
560
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
561 egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_CANCEL_MESSAGE,
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
562 (Window)gtk_plug_get_id (GTK_PLUG (icon)),
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
563 id, 0, 0);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
564 }
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
566 GtkOrientation
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
567 egg_tray_icon_get_orientation (EggTrayIcon *icon)
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
568 {
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
569 g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), GTK_ORIENTATION_HORIZONTAL);
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
570
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
571 return icon->orientation;
2c1781ea074c [gaim-migrate @ 17433]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
572 }