annotate plugins/docklet/eggtrayicon.c @ 11692:969fb599cc1b

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