annotate plugins/docklet/eggtrayicon.c @ 13346:e614c46936ba

[gaim-migrate @ 15716] Javier Fern??ndez-Sanguino Pe??a sent me these a while back, before we were using intltool committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 28 Feb 2006 05:54:28 +0000
parents e856f985a0b9
children 4687f862a56b
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 */
12600
e856f985a0b9 [gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents: 11291
diff changeset
82 (GInstanceInitFunc) egg_tray_icon_init,
e856f985a0b9 [gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents: 11291
diff changeset
83 NULL /* value_table */
3510
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
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 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
87 }
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
88 else if (parent_class == NULL)
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
89 {
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
90 /* 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
91 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
92 }
3510
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
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 return our_type;
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
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 static void
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 egg_tray_icon_init (EggTrayIcon *icon)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 icon->stamp = 1;
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
102 icon->orientation = GTK_ORIENTATION_HORIZONTAL;
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 gtk_widget_add_events (GTK_WIDGET (icon), GDK_PROPERTY_CHANGE_MASK);
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
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 static void
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 egg_tray_icon_class_init (EggTrayIconClass *klass)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 {
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
110 GObjectClass *gobject_class = (GObjectClass *)klass;
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
111 GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
112
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 parent_class = g_type_class_peek_parent (klass);
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
114
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
115 gobject_class->get_property = egg_tray_icon_get_property;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
116
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
117 widget_class->realize = egg_tray_icon_realize;
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
118 widget_class->unrealize = egg_tray_icon_unrealize;
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
119
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
120 g_object_class_install_property (gobject_class,
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
121 PROP_ORIENTATION,
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
122 g_param_spec_enum ("orientation",
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
123 _("Orientation"),
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
124 _("The orientation of the tray."),
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
125 GTK_TYPE_ORIENTATION,
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
126 GTK_ORIENTATION_HORIZONTAL,
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
127 G_PARAM_READABLE));
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
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
130 static void
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
131 egg_tray_icon_get_property (GObject *object,
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
132 guint prop_id,
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
133 GValue *value,
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
134 GParamSpec *pspec)
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
135 {
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
136 EggTrayIcon *icon = EGG_TRAY_ICON (object);
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
137
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
138 switch (prop_id)
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
139 {
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
140 case PROP_ORIENTATION:
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
141 g_value_set_enum (value, icon->orientation);
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
142 break;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
143 default:
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
144 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
145 break;
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
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
149 static void
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
150 egg_tray_icon_get_orientation_property (EggTrayIcon *icon)
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
151 {
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
152 Display *xdisplay;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
153 Atom type;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
154 int format;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
155 union {
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
156 gulong *prop;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
157 guchar *prop_ch;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
158 } prop = { NULL };
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
159 gulong nitems;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
160 gulong bytes_after;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
161 int error, result;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
162
11291
57fccea36e36 [gaim-migrate @ 13491]
Mark Doliner <mark@kingant.net>
parents: 10779
diff changeset
163 g_return_if_fail(icon->manager_window != None);
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
164
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
165 #if GTK_CHECK_VERSION(2,1,0)
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
166 xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
167 #else
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
168 xdisplay = gdk_display;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
169 #endif
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
170
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
171 gdk_error_trap_push ();
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
172 type = None;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
173 result = XGetWindowProperty (xdisplay,
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
174 icon->manager_window,
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
175 icon->orientation_atom,
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
176 0, G_MAXLONG, FALSE,
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
177 XA_CARDINAL,
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
178 &type, &format, &nitems,
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
179 &bytes_after, &(prop.prop_ch));
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
180 error = gdk_error_trap_pop ();
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
181
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
182 if (error || result != Success)
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
183 return;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
184
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
185 if (type == XA_CARDINAL)
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
186 {
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
187 GtkOrientation orientation;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
188
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
189 orientation = (prop.prop [0] == SYSTEM_TRAY_ORIENTATION_HORZ) ?
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
190 GTK_ORIENTATION_HORIZONTAL :
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
191 GTK_ORIENTATION_VERTICAL;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
192
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
193 if (icon->orientation != orientation)
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
194 {
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
195 icon->orientation = orientation;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
196
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
197 g_object_notify (G_OBJECT (icon), "orientation");
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
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
201 if (prop.prop)
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
202 XFree (prop.prop);
3510
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
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 static GdkFilterReturn
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 egg_tray_icon_manager_filter (GdkXEvent *xevent, GdkEvent *event, gpointer user_data)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 EggTrayIcon *icon = user_data;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 XEvent *xev = (XEvent *)xevent;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 if (xev->xany.type == ClientMessage &&
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 xev->xclient.message_type == icon->manager_atom &&
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 xev->xclient.data.l[1] == icon->selection_atom)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 {
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
215 egg_tray_icon_update_manager_window (icon, TRUE);
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 else if (xev->xany.window == icon->manager_window)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 {
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
219 if (xev->xany.type == PropertyNotify &&
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
220 xev->xproperty.atom == icon->orientation_atom)
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
221 {
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
222 egg_tray_icon_get_orientation_property (icon);
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
223 }
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 if (xev->xany.type == DestroyNotify)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 {
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
226 egg_tray_icon_manager_window_destroyed (icon);
3510
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
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 return GDK_FILTER_CONTINUE;
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
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 static void
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
234 egg_tray_icon_unrealize (GtkWidget *widget)
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
235 {
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
236 EggTrayIcon *icon = EGG_TRAY_ICON (widget);
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
237 GdkWindow *root_window;
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
238
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
239 if (icon->manager_window != None)
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
240 {
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
241 GdkWindow *gdkwin;
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
242
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
243 #if GTK_CHECK_VERSION(2,1,0)
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
244 gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget),
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
245 icon->manager_window);
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
246 #else
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
247 gdkwin = gdk_window_lookup (icon->manager_window);
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
248 #endif
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
249
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
250 gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
251 }
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
252
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
253 #if GTK_CHECK_VERSION(2,1,0)
4261
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
254 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
255 #else
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
256 root_window = gdk_window_lookup (gdk_x11_get_default_root_xwindow ());
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
257 #endif
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
258
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
259 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
260
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
261 if (GTK_WIDGET_CLASS (parent_class)->unrealize)
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
262 (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
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
e252238f99df [gaim-migrate @ 4512]
Christian Hammond <chipx86@chipx86.com>
parents: 3510
diff changeset
265 static void
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 egg_tray_icon_send_manager_message (EggTrayIcon *icon,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 long message,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 Window window,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 long data1,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 long data2,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 long data3)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 XClientMessageEvent ev;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 Display *display;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 ev.type = ClientMessage;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 ev.window = window;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 ev.message_type = icon->system_tray_opcode_atom;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 ev.format = 32;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 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
281 ev.data.l[1] = message;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 ev.data.l[2] = data1;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 ev.data.l[3] = data2;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 ev.data.l[4] = data3;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
286 #if GTK_CHECK_VERSION(2,1,0)
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 display = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 #else
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 display = gdk_display;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 #endif
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
291
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 gdk_error_trap_push ();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 XSendEvent (display,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 icon->manager_window, False, NoEventMask, (XEvent *)&ev);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 XSync (display, False);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 gdk_error_trap_pop ();
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
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 static void
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 egg_tray_icon_send_dock_request (EggTrayIcon *icon)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301 {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302 egg_tray_icon_send_manager_message (icon,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 SYSTEM_TRAY_REQUEST_DOCK,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 icon->manager_window,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305 gtk_plug_get_id (GTK_PLUG (icon)),
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 0, 0);
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
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309 static void
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
310 egg_tray_icon_update_manager_window (EggTrayIcon *icon,
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
311 gboolean dock_if_realized)
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 Display *xdisplay;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
315 if (icon->manager_window != None)
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
316 return;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
317
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
318 #if GTK_CHECK_VERSION(2,1,0)
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 #else
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321 xdisplay = gdk_display;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322 #endif
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 XGrabServer (xdisplay);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 icon->manager_window = XGetSelectionOwner (xdisplay,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 icon->selection_atom);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 if (icon->manager_window != None)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 XSelectInput (xdisplay,
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
331 icon->manager_window, StructureNotifyMask|PropertyChangeMask);
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 XUngrabServer (xdisplay);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 XFlush (xdisplay);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336 if (icon->manager_window != None)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 GdkWindow *gdkwin;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
340 #if GTK_CHECK_VERSION(2,1,0)
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 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
342 icon->manager_window);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 #else
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344 gdkwin = gdk_window_lookup (icon->manager_window);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 #endif
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
346
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 gdk_window_add_filter (gdkwin, egg_tray_icon_manager_filter, icon);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
349 if (dock_if_realized && GTK_WIDGET_REALIZED (icon))
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
350 egg_tray_icon_send_dock_request (icon);
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
351
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
352 egg_tray_icon_get_orientation_property (icon);
3510
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 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
356 static void
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
357 egg_tray_icon_manager_window_destroyed (EggTrayIcon *icon)
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 {
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
359 GdkWindow *gdkwin;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
360
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
361 g_return_if_fail (icon->manager_window != None);
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
362
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
363 #if GTK_CHECK_VERSION(2,1,0)
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
364 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
365 icon->manager_window);
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
366 #else
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
367 gdkwin = gdk_window_lookup (icon->manager_window);
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
368 #endif
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
369
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
370 gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
371
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
372 icon->manager_window = None;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
373
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
374 egg_tray_icon_update_manager_window (icon, TRUE);
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
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
377 static void
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
378 egg_tray_icon_realize (GtkWidget *widget)
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
379 {
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
380 EggTrayIcon *icon = EGG_TRAY_ICON (widget);
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
381 gint screen;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
382 Display *xdisplay;
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383 char buffer[256];
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384 GdkWindow *root_window;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
386 if (GTK_WIDGET_CLASS (parent_class)->realize)
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
387 GTK_WIDGET_CLASS (parent_class)->realize (widget);
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
389 #if GTK_CHECK_VERSION(2,1,0)
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
390 screen = gdk_screen_get_number (gtk_widget_get_screen (widget));
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
391 xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (widget));
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 #else
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
393 screen = XScreenNumberOfScreen (DefaultScreenOfDisplay (gdk_display));
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
394 xdisplay = gdk_display;
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 #endif
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397 /* Now see if there's a manager window around */
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 g_snprintf (buffer, sizeof (buffer),
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399 "_NET_SYSTEM_TRAY_S%d",
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
400 screen);
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
401
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
402 icon->selection_atom = XInternAtom (xdisplay, buffer, False);
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
404 icon->manager_atom = XInternAtom (xdisplay, "MANAGER", False);
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
405
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
406 icon->system_tray_opcode_atom = XInternAtom (xdisplay,
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
407 "_NET_SYSTEM_TRAY_OPCODE",
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
408 False);
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
410 icon->orientation_atom = XInternAtom (xdisplay,
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
411 "_NET_SYSTEM_TRAY_ORIENTATION",
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
412 False);
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
414 egg_tray_icon_update_manager_window (icon, FALSE);
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
415 egg_tray_icon_send_dock_request (icon);
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
416
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
417 #if GTK_CHECK_VERSION(2,1,0)
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
418 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
419 #else
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420 root_window = gdk_window_lookup (gdk_x11_get_default_root_xwindow ());
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 #endif
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
422
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423 /* Add a root window filter so that we get changes on MANAGER */
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424 gdk_window_add_filter (root_window,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425 egg_tray_icon_manager_filter, icon);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
427
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
428 #if GTK_CHECK_VERSION(2,1,0)
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429 EggTrayIcon *
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430 egg_tray_icon_new_for_screen (GdkScreen *screen, const char *name)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431 {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
432 g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
434 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
435 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
436 #endif
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
438 EggTrayIcon*
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439 egg_tray_icon_new (const gchar *name)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440 {
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
441 return g_object_new (EGG_TYPE_TRAY_ICON, "title", name, NULL);
3510
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
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444 guint
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 egg_tray_icon_send_message (EggTrayIcon *icon,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
446 gint timeout,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447 const gchar *message,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
448 gint len)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449 {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450 guint stamp;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
451
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452 g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), 0);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
453 g_return_val_if_fail (timeout >= 0, 0);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
454 g_return_val_if_fail (message != NULL, 0);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
456 if (icon->manager_window == None)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457 return 0;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 if (len < 0)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
460 len = strlen (message);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
461
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
462 stamp = icon->stamp++;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
463
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
464 /* Get ready to send the message */
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
465 egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_BEGIN_MESSAGE,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
466 (Window)gtk_plug_get_id (GTK_PLUG (icon)),
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
467 timeout, len, stamp);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
468
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
469 /* Now to send the actual message */
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470 gdk_error_trap_push ();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471 while (len > 0)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
472 {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
473 XClientMessageEvent ev;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
474 Display *xdisplay;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
476 #if GTK_CHECK_VERSION(2,1,0)
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
477 xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478 #else
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
479 xdisplay = gdk_display;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
480 #endif
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
481
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482 ev.type = ClientMessage;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483 ev.window = (Window)gtk_plug_get_id (GTK_PLUG (icon));
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
484 ev.format = 8;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
485 ev.message_type = XInternAtom (xdisplay,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
486 "_NET_SYSTEM_TRAY_MESSAGE_DATA", False);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
487 if (len > 20)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
488 {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489 memcpy (&ev.data, message, 20);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490 len -= 20;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
491 message += 20;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
492 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493 else
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494 {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495 memcpy (&ev.data, message, len);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
496 len = 0;
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
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499 XSendEvent (xdisplay,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
500 icon->manager_window, False, StructureNotifyMask, (XEvent *)&ev);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
501 XSync (xdisplay, False);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
502 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
503 gdk_error_trap_pop ();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
505 return stamp;
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
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508 void
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
509 egg_tray_icon_cancel_message (EggTrayIcon *icon,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
510 guint id)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511 {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
512 g_return_if_fail (EGG_IS_TRAY_ICON (icon));
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
513 g_return_if_fail (id > 0);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
514
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
515 egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_CANCEL_MESSAGE,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
516 (Window)gtk_plug_get_id (GTK_PLUG (icon)),
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
517 id, 0, 0);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
518 }
10779
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
519
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
520 GtkOrientation
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
521 egg_tray_icon_get_orientation (EggTrayIcon *icon)
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
522 {
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
523 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
524
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
525 return icon->orientation;
777e42930797 [gaim-migrate @ 12402]
Luke Schierer <lschiere@pidgin.im>
parents: 8735
diff changeset
526 }