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