+2010-10-02 [colin] 3.7.6cvs45
+
+ * src/plugins/trayicon/Makefile.am
+ * src/plugins/trayicon/trayicon.c
+ * src/plugins/trayicon/libeggtrayicon/.cvsignore
+ * src/plugins/trayicon/libeggtrayicon/Makefile.am
+ * src/plugins/trayicon/libeggtrayicon/eggtrayicon.c
+ * src/plugins/trayicon/libeggtrayicon/eggtrayicon.h
+ * src/plugins/trayicon/libeggtrayicon/gtk2-funcs.c
+ * src/plugins/trayicon/libeggtrayicon/gtk2-funcs.h
+ * src/plugins/trayicon/libeggtrayicon/gtkplugxembed.c
+ * src/plugins/trayicon/libeggtrayicon/gtkplugxembed.h
+ * src/plugins/trayicon/libeggtrayicon/xembed.h
+ Finally get rid of Eggtrayicon, use GtkStatusIcon
+ instead (which can be done safely now that we
+ require GTK+ 2.10).
+
2010-10-02 [colin] 3.7.6cvs44
* src/action.c
( cvs diff -u -r 1.105.2.160 -r 1.105.2.161 src/prefs_account.c; cvs diff -u -r 1.1.4.63 -r 1.1.4.64 src/prefs_filtering_action.c; cvs diff -u -r 1.43.2.84 -r 1.43.2.85 src/prefs_matcher.c; ) > 3.7.6cvs42.patchset
( cvs diff -u -r 1.654.2.4111 -r 1.654.2.4112 configure.ac; ) > 3.7.6cvs43.patchset
( cvs diff -u -r 1.12.2.59 -r 1.12.2.60 src/action.c; cvs diff -u -r 1.27.2.47 -r 1.27.2.48 src/addr_compl.c; cvs diff -u -r 1.60.2.137 -r 1.60.2.138 src/addressbook.c; cvs diff -u -r 1.5.10.31 -r 1.5.10.32 src/addrgather.c; cvs diff -u -r 1.17.2.40 -r 1.17.2.41 src/alertpanel.c; cvs diff -u -r 1.14.2.56 -r 1.14.2.57 src/editaddress.c; cvs diff -u -r 1.1.2.9 -r 1.1.2.10 src/editaddress_other_attributes_ldap.c; cvs diff -u -r 1.11.2.24 -r 1.11.2.25 src/editgroup.c; cvs diff -u -r 1.207.2.216 -r 1.207.2.217 src/folderview.c; cvs diff -u -r 1.14.2.26 -r 1.14.2.27 src/grouplistdialog.c; cvs diff -u -r 1.8.2.31 -r 1.8.2.32 src/headerview.c; cvs diff -u -r 1.1.2.27 -r 1.1.2.28 src/image_viewer.c; cvs diff -u -r 1.14.2.24 -r 1.14.2.25 src/importldif.c; cvs diff -u -r 1.115.2.229 -r 1.115.2.230 src/main.c; cvs diff -u -r 1.274.2.317 -r 1.274.2.318 src/mainwindow.c; cvs diff -u -r 1.3.12.33 -r 1.3.12.34 src/message_search.c; cvs diff -u -r 1.83.2.163 -r 1.83.2.164 src/mimeview.c; cvs diff -u -r 1.3.2.64 -r 1.3.2.65 src/prefs_themes.c; cvs diff -u -r 1.15.2.58 -r 1.15.2.59 src/summary_search.c; cvs diff -u -r 1.395.2.424 -r 1.395.2.425 src/summaryview.c; cvs diff -u -r 1.43.2.119 -r 1.43.2.120 src/toolbar.c; cvs diff -u -r 1.1.4.111 -r 1.1.4.112 src/etpan/imap-thread.c; cvs diff -u -r 1.1.2.68 -r 1.1.2.69 src/gtk/authors.h; cvs diff -u -r 1.1.2.13 -r 1.1.2.14 src/gtk/gtkcmclist.c; cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/gtk/gtkcmoptionmenu.c; cvs diff -u -r 1.5.2.90 -r 1.5.2.91 src/gtk/gtkutils.c; cvs diff -u -r 1.4.2.49 -r 1.4.2.50 src/gtk/gtkutils.h; cvs diff -u -r 1.5.2.19 -r 1.5.2.20 src/gtk/gtkvscrollbutton.c; cvs diff -u -r 1.1.2.27 -r 1.1.2.28 src/plugins/pgpcore/select-keys.c; cvs diff -u -r 1.1.4.11 -r 1.1.4.12 src/plugins/trayicon/libeggtrayicon/eggtrayicon.c; ) > 3.7.6cvs44.patchset
+( cvs diff -u -r 1.4.2.13 -r 1.4.2.14 src/plugins/trayicon/Makefile.am; cvs diff -u -r 1.14.2.71 -r 1.14.2.72 src/plugins/trayicon/trayicon.c; cvs diff -u -r -1.1 -r -1.2 src/plugins/trayicon/libeggtrayicon/.cvsignore; cvs diff -u -r -1.2.2.3 -r -1.2.2.4 src/plugins/trayicon/libeggtrayicon/Makefile.am; cvs diff -u -r -1.1.4.12 -r -1.1.4.13 src/plugins/trayicon/libeggtrayicon/eggtrayicon.c; cvs diff -u -r -1.1.4.3 -r -1.1.4.4 src/plugins/trayicon/libeggtrayicon/eggtrayicon.h; cvs diff -u -r -1.1.4.1 -r -1.1.4.2 src/plugins/trayicon/libeggtrayicon/gtk2-funcs.c; cvs diff -u -r -1.1.4.1 -r -1.1.4.2 src/plugins/trayicon/libeggtrayicon/gtk2-funcs.h; cvs diff -u -r -1.1.4.5 -r -1.1.4.6 src/plugins/trayicon/libeggtrayicon/gtkplugxembed.c; cvs diff -u -r -1.1.4.2 -r -1.1.4.3 src/plugins/trayicon/libeggtrayicon/gtkplugxembed.h; cvs diff -u -r -1.1 -r -1.2 src/plugins/trayicon/libeggtrayicon/xembed.h; ) > 3.7.6cvs45.patchset
MICRO_VERSION=6
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=44
+EXTRA_VERSION=45
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
-SUBDIRS = libeggtrayicon
-
plugindir = $(pkglibdir)/plugins
plugin_LTLIBRARIES = trayicon.la
trayicon_la_LDFLAGS = \
-avoid-version -module -no-undefined
-trayicon_la_LIBADD = libeggtrayicon/libeggtrayicon.la \
+trayicon_la_LIBADD = \
$(cygwin_export_lib) \
$(GTK_LIBS) \
-L/usr/X11R6/lib -lX11 \
INCLUDES = \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/common \
- -I$(top_srcdir)/src/gtk \
- -I$(srcdir)/libeggtrayicon
+ -I$(top_srcdir)/src/gtk
AM_CPPFLAGS = \
$(GLIB_CFLAGS) \
+++ /dev/null
-.libs
-.deps
-Makefile
-Makefile.in
-*.lo
-*.la
+++ /dev/null
-noinst_LTLIBRARIES = libeggtrayicon.la
-
-libeggtrayicon_la_SOURCES = \
- eggtrayicon.c eggtrayicon.h
-
-INCLUDES = \
- -I../../../ \
- -I../../../common \
- -I../../../gtk
-
-AM_CPPFLAGS = \
- $(GTK_CFLAGS)
-
-libeggtrayicon_la_LIBADD = \
- $(GTK_LIBS)
-
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* eggtrayicon.c
- * Copyright (C) 2002 Anders Carlsson <andersca@gnu.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <time.h>
-#include <glib.h>
-#include <glib/gi18n.h>
-#include <gtk/gtk.h>
-
-#include <string.h>
-#include "eggtrayicon.h"
-#include "gtkutils.h"
-
-#include <gdk/gdkx.h>
-#include <X11/Xatom.h>
-#define SYSTEM_TRAY_REQUEST_DOCK 0
-#define SYSTEM_TRAY_BEGIN_MESSAGE 1
-#define SYSTEM_TRAY_CANCEL_MESSAGE 2
-
-#define SYSTEM_TRAY_ORIENTATION_HORZ 0
-#define SYSTEM_TRAY_ORIENTATION_VERT 1
-
-enum {
- PROP_0,
- PROP_ORIENTATION
-};
-
-static GtkPlugClass *parent_class = NULL;
-
-static void egg_tray_icon_init (EggTrayIcon *icon);
-static void egg_tray_icon_class_init (EggTrayIconClass *klass);
-
-static void egg_tray_icon_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static void egg_tray_icon_realize (GtkWidget *widget);
-static void egg_tray_icon_unrealize (GtkWidget *widget);
-
-static void egg_tray_icon_add (GtkContainer *container,
- GtkWidget *widget);
-
-static void egg_tray_icon_update_manager_window (EggTrayIcon *icon,
- gboolean dock_if_realized);
-static void egg_tray_icon_manager_window_destroyed (EggTrayIcon *icon);
-
-GType
-egg_tray_icon_get_type (void)
-{
- static GType our_type = 0;
-
- if (our_type == 0)
- {
- gchar *type_name = g_strdup_printf("EggTrayIcon%d", (int)time(NULL));
- static const GTypeInfo our_info =
- {
- sizeof (EggTrayIconClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) egg_tray_icon_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (EggTrayIcon),
- 0, /* n_preallocs */
- (GInstanceInitFunc) egg_tray_icon_init
- };
-
- our_type = g_type_register_static (GTK_TYPE_PLUG, type_name,
- &our_info, 0);
- g_free(type_name);
- }
-
- return our_type;
-}
-
-static void
-egg_tray_icon_init (EggTrayIcon *icon)
-{
- icon->stamp = 1;
- icon->orientation = GTK_ORIENTATION_HORIZONTAL;
-
- gtk_widget_add_events (GTK_WIDGET (icon), GDK_PROPERTY_CHANGE_MASK);
-}
-
-static void
-egg_tray_icon_class_init (EggTrayIconClass *klass)
-{
- GObjectClass *gobject_class = (GObjectClass *)klass;
- GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
- GtkContainerClass *container_class = (GtkContainerClass *)klass;
-
- parent_class = g_type_class_peek_parent (klass);
-
- gobject_class->get_property = egg_tray_icon_get_property;
-
- widget_class->realize = egg_tray_icon_realize;
- widget_class->unrealize = egg_tray_icon_unrealize;
- container_class->add = egg_tray_icon_add;
-
- g_object_class_install_property (gobject_class,
- PROP_ORIENTATION,
- g_param_spec_enum ("orientation",
- _("Orientation"),
- _("The orientation of the tray."),
- GTK_TYPE_ORIENTATION,
- GTK_ORIENTATION_HORIZONTAL,
- G_PARAM_READABLE));
-}
-
-static void
-egg_tray_icon_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EggTrayIcon *icon = EGG_TRAY_ICON (object);
-
- switch (prop_id)
- {
- case PROP_ORIENTATION:
- g_value_set_enum (value, icon->orientation);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-egg_tray_icon_get_orientation_property (EggTrayIcon *icon)
-{
- Display *xdisplay;
- Atom type;
- int format;
- union {
- gulong *prop;
- guchar *prop_ch;
- } prop = { NULL };
- gulong nitems;
- gulong bytes_after;
- int error, result;
-
- g_return_if_fail (icon->manager_window != None);
-
-#ifndef GDK_MULTIHEAD_SAFE
- xdisplay = gdk_display_get_default();
-#else
- xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
-#endif
-
- gdk_error_trap_push ();
- type = None;
- result = XGetWindowProperty (xdisplay,
- icon->manager_window,
- icon->orientation_atom,
- 0, G_MAXLONG, FALSE,
- XA_CARDINAL,
- &type, &format, &nitems,
- &bytes_after, &(prop.prop_ch));
- error = gdk_error_trap_pop ();
-
- if (error || result != Success)
- return;
-
- if (type == XA_CARDINAL)
- {
- GtkOrientation orientation;
-
- orientation = (prop.prop [0] == SYSTEM_TRAY_ORIENTATION_HORZ) ?
- GTK_ORIENTATION_HORIZONTAL :
- GTK_ORIENTATION_VERTICAL;
-
- if (icon->orientation != orientation)
- {
- icon->orientation = orientation;
-
- g_object_notify (G_OBJECT (icon), "orientation");
- }
- }
-
- if (prop.prop)
- XFree (prop.prop);
-}
-
-static GdkFilterReturn
-egg_tray_icon_manager_filter (GdkXEvent *xevent, GdkEvent *event, gpointer user_data)
-{
- EggTrayIcon *icon = user_data;
- XEvent *xev = (XEvent *)xevent;
-
- if (xev->xany.type == ClientMessage &&
- xev->xclient.message_type == icon->manager_atom &&
- xev->xclient.data.l[1] == icon->selection_atom)
- {
- egg_tray_icon_update_manager_window (icon, TRUE);
- }
- else if (xev->xany.window == icon->manager_window)
- {
- if (xev->xany.type == PropertyNotify &&
- xev->xproperty.atom == icon->orientation_atom)
- {
- egg_tray_icon_get_orientation_property (icon);
- }
- if (xev->xany.type == DestroyNotify)
- {
- egg_tray_icon_manager_window_destroyed (icon);
- }
- }
-
- return GDK_FILTER_CONTINUE;
-}
-
-static void
-egg_tray_icon_unrealize (GtkWidget *widget)
-{
- EggTrayIcon *icon = EGG_TRAY_ICON (widget);
- GdkWindow *root_window;
-
- if (icon->manager_window != None)
- {
- GdkWindow *gdkwin;
-
-#ifndef GDK_MULTIHEAD_SAFE
- gdkwin = gdk_window_lookup (icon->manager_window);
-#else
- gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget),
- icon->manager_window);
-#endif
-
- gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
- }
-
- root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
-
- gdk_window_remove_filter (root_window, egg_tray_icon_manager_filter, icon);
-
- if (GTK_WIDGET_CLASS (parent_class)->unrealize)
- (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
-}
-
-static void
-egg_tray_icon_send_manager_message (EggTrayIcon *icon,
- long message,
- Window window,
- long data1,
- long data2,
- long data3)
-{
- XClientMessageEvent ev;
- Display *display;
-
- ev.type = ClientMessage;
- ev.window = window;
- ev.message_type = icon->system_tray_opcode_atom;
- ev.format = 32;
- ev.data.l[0] = gdk_x11_get_server_time (GTK_WIDGET (icon)->window);
- ev.data.l[1] = message;
- ev.data.l[2] = data1;
- ev.data.l[3] = data2;
- ev.data.l[4] = data3;
-
-#ifndef GDK_MULTIHEAD_SAFE
- display = gdk_display_get_default();
-#else
- display = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
-#endif
-
- gdk_error_trap_push ();
- XSendEvent (display,
- icon->manager_window, False, NoEventMask, (XEvent *)&ev);
- XSync (display, False);
- gdk_error_trap_pop ();
-}
-
-static void
-egg_tray_icon_send_dock_request (EggTrayIcon *icon)
-{
- egg_tray_icon_send_manager_message (icon,
- SYSTEM_TRAY_REQUEST_DOCK,
- icon->manager_window,
- gtk_plug_get_id (GTK_PLUG (icon)),
- 0, 0);
-}
-
-static void
-egg_tray_icon_update_manager_window (EggTrayIcon *icon, gboolean dock_if_realized)
-{
- Display *xdisplay;
-
-#ifndef GDK_MULTIHEAD_SAFE
- xdisplay = gdk_display_get_default();
-#else
- xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
-#endif
-
- if (icon->manager_window != None)
- {
- GdkWindow *gdkwin;
-
-#ifndef GDK_MULTIHEAD_SAFE
- gdkwin = gdk_window_lookup (icon->manager_window);
-#else
- gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
- icon->manager_window);
-#endif
-
- gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
- }
-
- XGrabServer (xdisplay);
-
- icon->manager_window = XGetSelectionOwner (xdisplay,
- icon->selection_atom);
-
- if (icon->manager_window != None)
- XSelectInput (xdisplay,
- icon->manager_window, StructureNotifyMask|PropertyChangeMask);
-
- XUngrabServer (xdisplay);
- XFlush (xdisplay);
-
- if (icon->manager_window != None)
- {
- GdkWindow *gdkwin;
-
-#ifndef GDK_MULTIHEAD_SAFE
- gdkwin = gdk_window_lookup (icon->manager_window);
-#else
- gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
- icon->manager_window);
-#endif
-
- gdk_window_add_filter (gdkwin, egg_tray_icon_manager_filter, icon);
-
- if (dock_if_realized && gtkut_widget_get_realized (GTK_WIDGET(icon)))
- egg_tray_icon_send_dock_request (icon);
-
- egg_tray_icon_get_orientation_property (icon);
- }
-}
-
-static gboolean
-transparent_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
-{
- gdk_window_clear_area (widget->window, event->area.x, event->area.y,
- event->area.width, event->area.height);
- return FALSE;
-}
-
-static void
-make_transparent_again (GtkWidget *widget, GtkStyle *previous_style,
- gpointer user_data)
-{
- gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
-}
-
-static void
-make_transparent (GtkWidget *widget, gpointer user_data)
-{
- if (!gtkut_widget_get_has_window (widget) || gtkut_widget_get_app_paintable (widget))
- return;
-
- gtk_widget_set_app_paintable (widget, TRUE);
- gtk_widget_set_double_buffered (widget, FALSE);
- gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
- g_signal_connect (widget, "expose_event",
- G_CALLBACK (transparent_expose_event), NULL);
- g_signal_connect_after (widget, "style_set",
- G_CALLBACK (make_transparent_again), NULL);
-}
-
-static void
-egg_tray_icon_add (GtkContainer *container, GtkWidget *widget)
-{
- g_signal_connect (widget, "realize",
- G_CALLBACK (make_transparent), NULL);
- GTK_CONTAINER_CLASS (parent_class)->add (container, widget);
-}
-
-static void
-egg_tray_icon_manager_window_destroyed (EggTrayIcon *icon)
-{
- GdkWindow *gdkwin;
-
- g_return_if_fail (icon->manager_window != None);
-
- gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
- icon->manager_window);
-
- gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
-
- icon->manager_window = None;
-
- egg_tray_icon_update_manager_window (icon, TRUE);
-}
-
-static void
-egg_tray_icon_realize (GtkWidget *widget)
-{
- EggTrayIcon *icon = EGG_TRAY_ICON (widget);
- GdkScreen *screen;
- GdkDisplay *display;
- Display *xdisplay;
- char buffer[256];
- GdkWindow *root_window;
-
- if (GTK_WIDGET_CLASS (parent_class)->realize)
- GTK_WIDGET_CLASS (parent_class)->realize (widget);
-
- make_transparent (widget, NULL);
- screen = gtk_widget_get_screen (widget);
- display = gdk_screen_get_display (screen);
- xdisplay = gdk_x11_display_get_xdisplay (display);
-
- /* Now see if there's a manager window around */
- g_snprintf (buffer, sizeof (buffer),
- "_NET_SYSTEM_TRAY_S%d",
- gdk_screen_get_number (screen));
-
- icon->selection_atom = XInternAtom (xdisplay, buffer, False);
-
- icon->manager_atom = XInternAtom (xdisplay, "MANAGER", False);
-
- icon->system_tray_opcode_atom = XInternAtom (xdisplay,
- "_NET_SYSTEM_TRAY_OPCODE",
- False);
-
- icon->orientation_atom = XInternAtom (xdisplay,
- "_NET_SYSTEM_TRAY_ORIENTATION",
- False);
-
- egg_tray_icon_update_manager_window (icon, FALSE);
- egg_tray_icon_send_dock_request (icon);
-
- root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
-
- /* Add a root window filter so that we get changes on MANAGER */
- gdk_window_add_filter (root_window,
- egg_tray_icon_manager_filter, icon);
-}
-
-EggTrayIcon *
-egg_tray_icon_new_for_screen (GdkScreen *screen, const char *name)
-{
- g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
-
- return g_object_new (EGG_TYPE_TRAY_ICON, "screen", screen, "title", name, NULL);
-}
-
-EggTrayIcon*
-egg_tray_icon_new (const gchar *name)
-{
- return g_object_new (EGG_TYPE_TRAY_ICON, "title", name, NULL);
-}
-
-guint
-egg_tray_icon_send_message (EggTrayIcon *icon,
- gint timeout,
- const gchar *message,
- gint len)
-{
- guint stamp;
-
- g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), 0);
- g_return_val_if_fail (timeout >= 0, 0);
- g_return_val_if_fail (message != NULL, 0);
-
- if (icon->manager_window == None)
- return 0;
-
- if (len < 0)
- len = strlen (message);
-
- stamp = icon->stamp++;
-
- /* Get ready to send the message */
- egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_BEGIN_MESSAGE,
- (Window)gtk_plug_get_id (GTK_PLUG (icon)),
- timeout, len, stamp);
-
- /* Now to send the actual message */
- gdk_error_trap_push ();
- while (len > 0)
- {
- XClientMessageEvent ev;
- Display *xdisplay;
-
-#ifndef GDK_MULTIHEAD_SAFE
- xdisplay = gdk_display_get_default();
-#else
- xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
-#endif
-
- ev.type = ClientMessage;
- ev.window = (Window)gtk_plug_get_id (GTK_PLUG (icon));
- ev.format = 8;
- ev.message_type = XInternAtom (xdisplay,
- "_NET_SYSTEM_TRAY_MESSAGE_DATA", False);
- if (len > 20)
- {
- memcpy (&ev.data, message, 20);
- len -= 20;
- message += 20;
- }
- else
- {
- memcpy (&ev.data, message, len);
- len = 0;
- }
-
- XSendEvent (xdisplay,
- icon->manager_window, False, StructureNotifyMask, (XEvent *)&ev);
- XSync (xdisplay, False);
- }
- gdk_error_trap_pop ();
-
- return stamp;
-}
-
-void
-egg_tray_icon_cancel_message (EggTrayIcon *icon,
- guint id)
-{
- g_return_if_fail (EGG_IS_TRAY_ICON (icon));
- g_return_if_fail (id > 0);
-
- egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_CANCEL_MESSAGE,
- (Window)gtk_plug_get_id (GTK_PLUG (icon)),
- id, 0, 0);
-}
-
-GtkOrientation
-egg_tray_icon_get_orientation (EggTrayIcon *icon)
-{
- g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), GTK_ORIENTATION_HORIZONTAL);
-
- return icon->orientation;
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* eggtrayicon.h
- * Copyright (C) 2002 Anders Carlsson <andersca@gnu.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __EGG_TRAY_ICON_H__
-#define __EGG_TRAY_ICON_H__
-
-#include <gdk/gdkx.h>
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define EGG_TYPE_TRAY_ICON (egg_tray_icon_get_type ())
-#define EGG_TRAY_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TRAY_ICON, EggTrayIcon))
-#define EGG_TRAY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_TRAY_ICON, EggTrayIconClass))
-#define EGG_IS_TRAY_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TRAY_ICON))
-#define EGG_IS_TRAY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_TRAY_ICON))
-#define EGG_TRAY_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_TRAY_ICON, EggTrayIconClass))
-
-typedef struct _EggTrayIcon EggTrayIcon;
-typedef struct _EggTrayIconClass EggTrayIconClass;
-
-struct _EggTrayIcon
-{
- GtkPlug parent_instance;
-
- guint stamp;
-
- Atom selection_atom;
- Atom manager_atom;
- Atom system_tray_opcode_atom;
- Atom orientation_atom;
- Window manager_window;
-
- GtkOrientation orientation;
-};
-
-struct _EggTrayIconClass
-{
- GtkPlugClass parent_class;
-};
-
-GType egg_tray_icon_get_type (void);
-
-EggTrayIcon *egg_tray_icon_new_for_screen (GdkScreen *screen,
- const gchar *name);
-
-EggTrayIcon *egg_tray_icon_new (const gchar *name);
-
-guint egg_tray_icon_send_message (EggTrayIcon *icon,
- gint timeout,
- const char *message,
- gint len);
-void egg_tray_icon_cancel_message (EggTrayIcon *icon,
- guint id);
-
-GtkOrientation egg_tray_icon_get_orientation (EggTrayIcon *icon);
-
-G_END_DECLS
-
-#endif /* __EGG_TRAY_ICON_H__ */
+++ /dev/null
-#include <gtk/gtk.h>
-
-#include <gdk/gdkkeysyms.h>
-#include <gdk/gdkx.h>
-
-#include "gtk2-funcs.h"
-
-extern guint32 gtk2_get_current_event_time (void);
-
-guint32
-gtk2_get_current_event_time (void)
-{
- GdkEvent *ev = gtk_get_current_event();
- if ( ev ) {
- guint32 result;
- result = gdk_event_get_time(ev);
- gdk_event_free(ev);
- return result;
- } else {
- return GDK_CURRENT_TIME;
- }
-
-}
-
+++ /dev/null
-/* GTK - The GIMP Toolkit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#ifndef __GTK2_FUNCS_H__
-#define __GTK2_FUNCS_H__
-
-#include <glib.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-extern guint32 gtk2_get_current_event_time (void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __GTK2_FUNCS_H__ */
+++ /dev/null
-/* GTK - The GIMP Toolkit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/* By Owen Taylor <otaylor@gtk.org> 98/4/4 */
-
-/*
- * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#include <gtk/gtk.h>
-#include "gtkplugxembed.h"
-
-#include <gdk/gdkkeysyms.h>
-#include <gdk/gdkx.h>
-
-#include "xembed.h"
-#include "gtk2-funcs.h"
-#include "gtkutils.h"
-
-static void gtk_plug_xembed_class_init (GtkPlugXEmbedClass *klass);
-static void gtk_plug_xembed_init (GtkPlugXEmbed *plug);
-static void gtk_plug_xembed_finalize (GtkObject *object);
-static void gtk_plug_xembed_realize (GtkWidget *widget);
-static void gtk_plug_xembed_unrealize (GtkWidget *widget);
-static void gtk_plug_xembed_show (GtkWidget *widget);
-static void gtk_plug_xembed_hide (GtkWidget *widget);
-static void gtk_plug_xembed_map (GtkWidget *widget);
-static void gtk_plug_xembed_unmap (GtkWidget *widget);
-static void gtk_plug_xembed_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static void gtk_plug_xembed_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static gboolean gtk_plug_xembed_key_press_event (GtkWidget *widget,
- GdkEventKey *event);
-static gboolean gtk_plug_xembed_focus_event (GtkWidget *widget,
- GdkEventFocus *event);
-static void gtk_plug_xembed_set_focus (GtkWindow *window,
- GtkWidget *focus);
-#ifdef PORT_COMPLETE
-static gboolean gtk_plug_xembed_focus (GtkWidget *widget,
- GtkDirectionType direction);
-#endif
-static void gtk_plug_xembed_check_resize (GtkContainer *container);
-#ifdef PORT_COMPLETE
-static void gtk_plug_xembed_keys_changed (GtkWindow *window);
-#endif
-static GdkFilterReturn gtk_plug_xembed_filter_func (GdkXEvent *gdk_xevent,
- GdkEvent *event,
- gpointer data);
-
-static void handle_modality_off (GtkPlugXEmbed *plug);
-static void send_xembed_message (GtkPlugXEmbed *plug,
- glong message,
- glong detail,
- glong data1,
- glong data2,
- guint32 time);
-static void xembed_set_info (GdkWindow *window,
- unsigned long flags);
-
-
-/* From Tk */
-#define EMBEDDED_APP_WANTS_FOCUS NotifyNormal+20
-
-static GtkWindowClass *parent_class = NULL;
-static GtkBinClass *bin_class = NULL;
-
-enum {
- EMBEDDED,
- LAST_SIGNAL
-};
-
-static guint plug_signals[LAST_SIGNAL] = { 0 };
-
-GtkType
-gtk_plug_xembed_get_type ()
-{
- static GtkType plug_type = 0;
-
- if (!plug_type)
- {
- static const GtkTypeInfo plug_info =
- {
- "GtkPlugXEmbed",
- sizeof (GtkPlugXEmbed),
- sizeof (GtkPlugXEmbedClass),
- (GtkClassInitFunc) gtk_plug_xembed_class_init,
- (GtkObjectInitFunc) gtk_plug_xembed_init,
- NULL,
- NULL,
- NULL
- };
-
- plug_type = gtk_type_unique (GTK_TYPE_WINDOW, &plug_info);
- }
-
- return plug_type;
-}
-
-static void
-gtk_plug_xembed_class_init (GtkPlugXEmbedClass *class)
-{
- GtkObjectClass *gtk_object_class = (GtkObjectClass *)class;
- GtkWidgetClass *widget_class = (GtkWidgetClass *)class;
- GtkWindowClass *window_class = (GtkWindowClass *)class;
- GtkContainerClass *container_class = (GtkContainerClass *)class;
-
- parent_class = gtk_type_class (GTK_TYPE_WINDOW);
- bin_class = gtk_type_class (GTK_TYPE_BIN);
-
- gtk_object_class->finalize = gtk_plug_xembed_finalize;
-
- widget_class->realize = gtk_plug_xembed_realize;
- widget_class->unrealize = gtk_plug_xembed_unrealize;
- widget_class->key_press_event = gtk_plug_xembed_key_press_event;
- widget_class->focus_in_event = gtk_plug_xembed_focus_event;
- widget_class->focus_out_event = gtk_plug_xembed_focus_event;
-
- widget_class->show = gtk_plug_xembed_show;
- widget_class->hide = gtk_plug_xembed_hide;
- widget_class->map = gtk_plug_xembed_map;
- widget_class->unmap = gtk_plug_xembed_unmap;
- widget_class->size_allocate = gtk_plug_xembed_size_allocate;
- widget_class->size_request = gtk_plug_xembed_size_request;
-
-#ifdef PORT_COMPLETE
- widget_class->focus = gtk_plug_xembed_focus;
-#endif
-
- container_class->check_resize = gtk_plug_xembed_check_resize;
-
- window_class->set_focus = gtk_plug_xembed_set_focus;
-#ifdef PORT_COMPLETE
- window_class->keys_changed = gtk_plug_xembed_keys_changed;
-#endif
-
- plug_signals[EMBEDDED] =
- g_signal_new ("embedded",
- GTK_RUN_LAST,
- G_OBJECT_CLASS (class)->type,
- GTK_STRUCT_OFFSET (GtkPlugXEmbedClass, embedded),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-}
-
-static void
-gtk_plug_xembed_init (GtkPlugXEmbed *plug)
-{
- GtkWindow *window;
-
- window = GTK_WINDOW (plug);
-
- window->type = GTK_WINDOW_TOPLEVEL;
-}
-
-#ifdef PORT_COMPLETE
-static void
-gtk_plug_xembed_set_is_child (GtkPlugXEmbed *plug,
- gboolean is_child)
-{
- g_assert (!GTK_WIDGET (plug)->parent);
-
- if (is_child)
- {
-#if PORT_COMPLETE
- if (plug->modality_window)
- handle_modality_off (plug);
-
- if (plug->modality_group)
- {
- gtk_window_group_remove_window (plug->modality_group, GTK_WINDOW (plug));
- g_object_unref (plug->modality_group);
- plug->modality_group = NULL;
- }
-#endif
-
- /* As a toplevel, the MAPPED flag doesn't correspond
- * to whether the widget->window is mapped; we unmap
- * here, but don't bother remapping -- we will get mapped
- * by gtk_widget_set_parent ().
- */
- if (gtkut_widget_get_mapped (plug))
- gtk_widget_unmap (GTK_WIDGET (plug));
-
- GTK_WIDGET_UNSET_FLAGS (plug, GTK_TOPLEVEL);
- gtk_container_set_resize_mode (GTK_CONTAINER (plug), GTK_RESIZE_PARENT);
-
-#ifdef PORT_COMPLETE
- _gtk_widget_propagate_hierarchy_changed (GTK_WIDGET (plug), GTK_WIDGET (plug));
-#endif
- }
- else
- {
- if (GTK_WINDOW (plug)->focus_widget)
- gtk_window_set_focus (GTK_WINDOW (plug), NULL);
- if (GTK_WINDOW (plug)->default_widget)
- gtk_window_set_default (GTK_WINDOW (plug), NULL);
-
-#ifdef PORT_COMPLETE
- plug->modality_group = gtk_window_group_new ();
- gtk_window_group_add_window (plug->modality_group, GTK_WINDOW (plug));
-#endif
-
- GTK_WIDGET_SET_FLAGS (plug, GTK_TOPLEVEL);
- gtk_container_set_resize_mode (GTK_CONTAINER (plug), GTK_RESIZE_QUEUE);
-
-#ifdef PORT_COMPLETE
- _gtk_widget_propagate_hierarchy_changed (GTK_WIDGET (plug), NULL);
-#endif
- }
-}
-#endif
-
-/**
- * _gtk_plug_xembed_add_to_socket:
- * @plug: a #GtkPlugXEmbed
- * @socket: a #GtkSocket
- *
- * Adds a plug to a socket within the same application.
- **/
-void
-_gtk_plug_xembed_add_to_socket (GtkPlugXEmbed *plug,
- GtkSocket *socket)
-{
-#ifdef PORT_COMPLETE /* Only foreign sockets for now */
- GtkWidget *widget;
- gint w, h;
-
- g_return_if_fail (GTK_IS_PLUG_XEMBED (plug));
- g_return_if_fail (GTK_IS_SOCKET (socket));
- g_return_if_fail (gtkut_widget_get_realized (socket));
-
- widget = GTK_WIDGET (plug);
-
- gtk_plug_xembed_set_is_child (plug, TRUE);
- plug->same_app = TRUE;
- socket->same_app = TRUE;
- socket->plug_widget = widget;
-
- plug->socket_window = GTK_WIDGET (socket)->window;
-
- if (gtkut_widget_get_realized (widget))
- {
- gdk_drawable_get_size (GDK_DRAWABLE (widget->window), &w, &h);
- gdk_window_reparent (widget->window, plug->socket_window, -w, -h);
- }
-
- gtk_widget_set_parent (widget, GTK_WIDGET (socket));
-
- g_signal_emit_by_name (G_OBJECT (socket), "plug_added", 0);
-#endif
-}
-
-/**
- * _gtk_plug_xembed_remove_from_socket:
- * @plug: a #GtkPlugXEmbed
- * @socket: a #GtkSocket
- *
- * Removes a plug from a socket within the same application.
- **/
-void
-_gtk_plug_xembed_remove_from_socket (GtkPlugXEmbed *plug,
- GtkSocket *socket)
-{
-#ifdef PORT_COMPLETE /* Only foreign sockets for now */
- GtkWidget *widget;
- GdkEvent event;
- gboolean result;
- gboolean widget_was_visible;
-
- g_return_if_fail (GTK_IS_PLUG_XEMBED (plug));
- g_return_if_fail (GTK_IS_SOCKET (socket));
- g_return_if_fail (gtkut_widget_get_realized (plug));
-
- widget = GTK_WIDGET (plug);
-
- g_object_ref (plug);
- g_object_ref (socket);
-
- widget_was_visible = gtkut_widget_get_visible (plug);
-
- gdk_window_hide (widget->window);
- gdk_window_reparent (widget->window, GDK_ROOT_PARENT (), 0, 0);
-
- GTK_PRIVATE_SET_FLAG (plug, GTK_IN_REPARENT);
- gtk_widget_unparent (GTK_WIDGET (plug));
- GTK_PRIVATE_UNSET_FLAG (plug, GTK_IN_REPARENT);
-
- socket->plug_widget = NULL;
- gdk_window_unref (socket->plug_window);
- socket->plug_window = NULL;
-
- socket->same_app = FALSE;
-
- plug->same_app = FALSE;
- plug->socket_window = NULL;
-
- gtk_plug_xembed_set_is_child (plug, FALSE);
-
- g_signal_emit_by_name (G_OBJECT (socket), "plug_removed", &result);
- if (!result)
- gtk_widget_destroy (GTK_WIDGET (socket));
-
- event.any.type = GDK_DELETE;
- event.any.window = gdk_window_ref (widget->window);
- event.any.send_event = FALSE;
-
- if (!gtk_widget_event (widget, &event))
- gtk_widget_destroy (widget);
-
- gdk_window_unref (event.any.window);
- g_object_unref (plug);
-
- if (widget_was_visible && gtkut_widget_get_visible (socket))
- gtk_widget_queue_resize (GTK_WIDGET (socket));
-
- g_object_unref (socket);
-#endif
-}
-
-void
-gtk_plug_xembed_construct (GtkPlugXEmbed *plug,
- GtkPlugXEmbedNativeWindow socket_id)
-{
- if (socket_id)
- {
-#ifdef PORT_COMPLETE /* Only foreign windows for now */
- gpointer user_data = NULL;
-
- plug->socket_window = gdk_window_lookup (socket_id);
-
- if (plug->socket_window)
- gdk_window_get_user_data (plug->socket_window, &user_data);
- else
- plug->socket_window = gdk_window_foreign_new (socket_id);
-
- if (user_data)
- {
- if (GTK_IS_SOCKET (user_data))
- _gtk_plug_xembed_add_to_socket (plug, user_data);
- else
- {
- g_warning (/*G_STRLOC*/ "Can't create GtkPlugXEmbed as child of non-GtkSocket");
- plug->socket_window = NULL;
- }
- }
-
- if (plug->socket_window)
- g_signal_emit (G_OBJECT (plug), plug_signals[EMBEDDED], 0);
-#else
- plug->socket_window = gdk_window_foreign_new (socket_id);
-#endif
-
- }
-}
-
-GtkWidget*
-gtk_plug_xembed_new (GtkPlugXEmbedNativeWindow socket_id)
-{
- GtkPlugXEmbed *plug;
-
- plug = GTK_PLUG_XEMBED (gtk_type_new (GTK_TYPE_PLUG_XEMBED));
- gtk_plug_xembed_construct (plug, socket_id);
- return GTK_WIDGET (plug);
-}
-
-/**
- * gtk_plug_xembed_get_id:
- * @plug: a #GtkPlugXEmbed.
- *
- * Gets the window ID of a #GtkPlugXEmbed widget, which can then
- * be used to embed this window inside another window, for
- * instance with gtk_socket_add_id().
- *
- * Return value: the window ID for the plug
- **/
-GtkPlugXEmbedNativeWindow
-gtk_plug_xembed_get_id (GtkPlugXEmbed *plug)
-{
- g_return_val_if_fail (GTK_IS_PLUG_XEMBED (plug), 0);
-
- if (!gtkut_widget_get_realized (plug))
- gtk_widget_realize (GTK_WIDGET (plug));
-
- return GDK_WINDOW_XWINDOW (GTK_WIDGET (plug)->window);
-}
-
-static void
-gtk_plug_xembed_finalize (GtkObject *object)
-{
- GtkPlugXEmbed *plug = GTK_PLUG_XEMBED (object);
-
- if (plug->grabbed_keys)
- {
- g_hash_table_destroy (plug->grabbed_keys);
- plug->grabbed_keys = NULL;
- }
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-gtk_plug_xembed_unrealize (GtkWidget *widget)
-{
- GtkPlugXEmbed *plug;
-
- g_return_if_fail (GTK_IS_PLUG_XEMBED (widget));
-
- plug = GTK_PLUG_XEMBED (widget);
-
- if (plug->socket_window != NULL)
- {
- gdk_window_set_user_data (plug->socket_window, NULL);
- gdk_window_unref (plug->socket_window);
- plug->socket_window = NULL;
- }
-
-#ifdef PORT_COMPLETE
- if (!plug->same_app)
- {
- if (plug->modality_window)
- handle_modality_off (plug);
-
- gtk_window_group_remove_window (plug->modality_group, GTK_WINDOW (plug));
- g_object_unref (plug->modality_group);
- }
-#endif
-
- if (GTK_WIDGET_CLASS (parent_class)->unrealize)
- (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
-}
-
-static void
-gtk_plug_xembed_realize (GtkWidget *widget)
-{
- GtkWindow *window;
- GtkPlugXEmbed *plug;
- GdkWindowAttr attributes;
- gint attributes_mask;
-
- g_return_if_fail (GTK_IS_PLUG_XEMBED (widget));
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
- window = GTK_WINDOW (widget);
- plug = GTK_PLUG_XEMBED (widget);
-
- attributes.window_type = GDK_WINDOW_CHILD; /* XXX GDK_WINDOW_PLUG ? */
- attributes.title = window->title;
- attributes.wmclass_name = window->wmclass_name;
- attributes.wmclass_class = window->wmclass_class;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
- attributes.wclass = GDK_INPUT_OUTPUT;
-
- /* this isn't right - we should match our parent's visual/colormap.
- * though that will require handling "foreign" colormaps */
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = gtk_widget_get_events (widget);
- attributes.event_mask |= (GDK_EXPOSURE_MASK |
- GDK_KEY_PRESS_MASK |
- GDK_KEY_RELEASE_MASK |
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK |
- GDK_FOCUS_CHANGE_MASK |
- GDK_STRUCTURE_MASK);
-
- attributes_mask = GDK_WA_VISUAL | GDK_WA_COLORMAP;
- attributes_mask |= (window->title ? GDK_WA_TITLE : 0);
- attributes_mask |= (window->wmclass_name ? GDK_WA_WMCLASS : 0);
-
- if (GTK_WIDGET_TOPLEVEL (widget))
- {
- attributes.window_type = GDK_WINDOW_TOPLEVEL;
-
- gdk_error_trap_push ();
- widget->window = gdk_window_new (plug->socket_window,
- &attributes, attributes_mask);
- gdk_flush ();
- if (gdk_error_trap_pop ()) /* Uh-oh */
- {
- gdk_error_trap_push ();
- gdk_window_destroy (widget->window);
- gdk_flush ();
- gdk_error_trap_pop ();
- widget->window = gdk_window_new (NULL, &attributes, attributes_mask);
- }
-
- gdk_window_add_filter (widget->window, gtk_plug_xembed_filter_func, widget);
-
-#ifdef PORT_COMPLETE
- plug->modality_group = gtk_window_group_new ();
- gtk_window_group_add_window (plug->modality_group, window);
-#endif
-
- xembed_set_info (widget->window, 0);
- }
- else
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
-
- gdk_window_set_user_data (widget->window, window);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
-}
-
-static void
-gtk_plug_xembed_show (GtkWidget *widget)
-{
- if (GTK_WIDGET_TOPLEVEL (widget))
- GTK_WIDGET_CLASS (parent_class)->show (widget);
- else
- GTK_WIDGET_CLASS (bin_class)->show (widget);
-}
-
-static void
-gtk_plug_xembed_hide (GtkWidget *widget)
-{
- if (GTK_WIDGET_TOPLEVEL (widget))
- GTK_WIDGET_CLASS (parent_class)->hide (widget);
- else
- GTK_WIDGET_CLASS (bin_class)->hide (widget);
-}
-
-static void
-gtk_plug_xembed_map (GtkWidget *widget)
-{
- if (GTK_WIDGET_TOPLEVEL (widget)) {
- GtkBin *bin = GTK_BIN (widget);
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
-
- if (bin->child &&
- gtkut_widget_get_visible (bin->child) &&
- !gtkut_widget_get_mapped (bin->child))
- gtk_widget_map (bin->child);
- xembed_set_info (widget->window, XEMBED_MAPPED);
- if (!GTK_WIDGET_NO_WINDOW (widget))
- gdk_window_show (widget->window);
-
-#ifdef PORT_COMPLETE
- gdk_synthesize_window_state (widget->window,
- GDK_WINDOW_STATE_WITHDRAWN,
- 0);
-#endif
- } else {
- GTK_WIDGET_CLASS (bin_class)->map (widget);
- }
-}
-
-static void
-gtk_plug_xembed_unmap (GtkWidget *widget)
-{
- if (GTK_WIDGET_TOPLEVEL (widget))
- {
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
-
- gdk_window_hide (widget->window);
- xembed_set_info (widget->window, 0);
-
-#ifdef PORT_COMPLETE
- gdk_synthesize_window_state (widget->window,
- 0,
- GDK_WINDOW_STATE_WITHDRAWN);
-#endif
- }
- else
- GTK_WIDGET_CLASS (bin_class)->unmap (widget);
-}
-
-static void
-gtk_plug_xembed_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- requisition->width = 22;
- requisition->height = 22;
-}
-
-static void
-gtk_plug_xembed_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- if (GTK_WIDGET_TOPLEVEL (widget))
- GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
- else
- {
- GtkBin *bin = GTK_BIN (widget);
-
- widget->allocation = *allocation;
-
- if (gtkut_widget_get_realized (widget))
- gdk_window_move_resize (widget->window,
- allocation->x, allocation->y,
- allocation->width, allocation->height);
-
- if (bin->child && gtkut_widget_get_visible (bin->child))
- {
- GtkAllocation child_allocation;
-
- child_allocation.x = child_allocation.y = GTK_CONTAINER (widget)->border_width;
- child_allocation.width =
- MAX (1, (gint)allocation->width - child_allocation.x * 2);
- child_allocation.height =
- MAX (1, (gint)allocation->height - child_allocation.y * 2);
-
- gtk_widget_size_allocate (bin->child, &child_allocation);
- }
-
- }
-}
-
-static gboolean
-gtk_plug_xembed_key_press_event (GtkWidget *widget,
- GdkEventKey *event)
-{
- if (GTK_WIDGET_TOPLEVEL (widget))
- return GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event);
- else
- return FALSE;
-}
-
-static gboolean
-gtk_plug_xembed_focus_event (GtkWidget *widget,
- GdkEventFocus *event)
-{
- /* We eat focus-in events and focus-out events, since they
- * can be generated by something like a keyboard grab on
- * a child of the plug.
- */
- return FALSE;
-}
-
-static void
-gtk_plug_xembed_set_focus (GtkWindow *window,
- GtkWidget *focus)
-{
- GtkPlugXEmbed *plug = GTK_PLUG_XEMBED (window);
-
- GTK_WINDOW_CLASS (parent_class)->set_focus (window, focus);
-
- /* Ask for focus from embedder
- */
-
- if (focus && !window->window_has_focus)
- {
- send_xembed_message (plug, XEMBED_REQUEST_FOCUS, 0, 0, 0,
- gtk2_get_current_event_time ());
- }
-}
-
-#ifdef PORT_COMPLETE
-typedef struct
-{
- guint accelerator_key;
- GdkModifierType accelerator_mods;
-} GrabbedKey;
-
-static guint
-grabbed_key_hash (gconstpointer a)
-{
- const GrabbedKey *key = a;
- guint h;
-
- h = key->accelerator_key << 16;
- h ^= key->accelerator_key >> 16;
- h ^= key->accelerator_mods;
-
- return h;
-}
-
-static gboolean
-grabbed_key_equal (gconstpointer a, gconstpointer b)
-{
- const GrabbedKey *keya = a;
- const GrabbedKey *keyb = b;
-
- return (keya->accelerator_key == keyb->accelerator_key &&
- keya->accelerator_mods == keyb->accelerator_mods);
-}
-
-static void
-add_grabbed_key (gpointer key, gpointer val, gpointer data)
-{
- GrabbedKey *grabbed_key = key;
- GtkPlugXEmbed *plug = data;
-
- if (!plug->grabbed_keys ||
- !g_hash_table_lookup (plug->grabbed_keys, grabbed_key))
- {
- send_xembed_message (plug, XEMBED_GTK_GRAB_KEY, 0,
- grabbed_key->accelerator_key, grabbed_key->accelerator_mods,
- gtk_get_current_event_time ());
- }
-}
-
-static void
-add_grabbed_key_always (gpointer key, gpointer val, gpointer data)
-{
- GrabbedKey *grabbed_key = key;
- GtkPlugXEmbed *plug = data;
-
- send_xembed_message (plug, XEMBED_GTK_GRAB_KEY, 0,
- grabbed_key->accelerator_key, grabbed_key->accelerator_mods,
- gtk_get_current_event_time ());
-}
-
-static void
-remove_grabbed_key (gpointer key, gpointer val, gpointer data)
-{
- GrabbedKey *grabbed_key = key;
- GtkPlugXEmbed *plug = data;
-
- if (!plug->grabbed_keys ||
- !g_hash_table_lookup (plug->grabbed_keys, grabbed_key))
- {
- send_xembed_message (plug, XEMBED_GTK_UNGRAB_KEY, 0,
- grabbed_key->accelerator_key, grabbed_key->accelerator_mods,
- gtk_get_current_event_time ());
- }
-}
-
-static void
-keys_foreach (GtkWindow *window,
- guint keyval,
- GdkModifierType modifiers,
- gboolean is_mnemonic,
- gpointer data)
-{
- GHashTable *new_grabbed_keys = data;
- GrabbedKey *key = g_new (GrabbedKey, 1);
-
- key->accelerator_key = keyval;
- key->accelerator_mods = modifiers;
-
- g_hash_table_replace (new_grabbed_keys, key, key);
-}
-
-#ifdef PORT_COMPLETE
-static void
-gtk_plug_xembed_keys_changed (GtkWindow *window)
-{
- GHashTable *new_grabbed_keys, *old_grabbed_keys;
- GtkPlugXEmbed *plug = GTK_PLUG_XEMBED (window);
-
- new_grabbed_keys = g_hash_table_new_full (grabbed_key_hash, grabbed_key_equal, (GDestroyNotify)g_free, NULL);
- _gtk_window_keys_foreach (window, keys_foreach, new_grabbed_keys);
-
- if (plug->socket_window)
- g_hash_table_foreach (new_grabbed_keys, add_grabbed_key, plug);
-
- old_grabbed_keys = plug->grabbed_keys;
- plug->grabbed_keys = new_grabbed_keys;
-
- if (old_grabbed_keys)
- {
- if (plug->socket_window)
- g_hash_table_foreach (old_grabbed_keys, remove_grabbed_key, plug);
- g_hash_table_destroy (old_grabbed_keys);
- }
-}
-#endif
-#endif
-
-#ifdef PORT_COMPLETE
-static gboolean
-gtk_plug_xembed_focus (GtkWidget *widget,
- GtkDirectionType direction)
-{
- GtkBin *bin = GTK_BIN (widget);
- GtkPlugXEmbed *plug = GTK_PLUG_XEMBED (widget);
- GtkWindow *window = GTK_WINDOW (widget);
- GtkContainer *container = GTK_CONTAINER (widget);
- GtkWidget *old_focus_child = container->focus_child;
- GtkWidget *parent;
-
- /* We override GtkWindow's behavior, since we don't want wrapping here.
- */
- if (old_focus_child)
- {
- if (gtk_widget_child_focus (old_focus_child, direction))
- return TRUE;
-
- if (window->focus_widget)
- {
- /* Wrapped off the end, clear the focus setting for the toplevel */
- parent = window->focus_widget->parent;
- while (parent)
- {
- gtk_container_set_focus_child (GTK_CONTAINER (parent), NULL);
- parent = GTK_WIDGET (parent)->parent;
- }
-
- gtk_window_set_focus (GTK_WINDOW (container), NULL);
-
- if (!GTK_CONTAINER (window)->focus_child)
- {
- gint message = -1;
-
- switch (direction)
- {
- case GTK_DIR_UP:
- case GTK_DIR_LEFT:
- case GTK_DIR_TAB_BACKWARD:
- message = XEMBED_FOCUS_PREV;
- break;
- case GTK_DIR_DOWN:
- case GTK_DIR_RIGHT:
- case GTK_DIR_TAB_FORWARD:
- message = XEMBED_FOCUS_NEXT;
- break;
- }
-
- send_xembed_message (plug, message, 0, 0, 0,
- gtk_get_current_event_time ());
- }
- }
-
- return FALSE;
- }
- else
- {
- /* Try to focus the first widget in the window */
-
- if (bin->child && gtk_widget_child_focus (bin->child, direction))
- return TRUE;
- }
-
- return FALSE;
-}
-#endif
-
-static void
-gtk_plug_xembed_check_resize (GtkContainer *container)
-{
- if (GTK_WIDGET_TOPLEVEL (container))
- GTK_CONTAINER_CLASS (parent_class)->check_resize (container);
- else
- GTK_CONTAINER_CLASS (bin_class)->check_resize (container);
-}
-
-static void
-send_xembed_message (GtkPlugXEmbed *plug,
- glong message,
- glong detail,
- glong data1,
- glong data2,
- guint32 time)
-{
- if (plug->socket_window)
- {
- XEvent xevent;
-
- GTK_NOTE(PLUGSOCKET,
- g_message ("GtkPlugXEmbed: Sending XEMBED message of type %ld", message));
-
- xevent.xclient.window = GDK_WINDOW_XWINDOW (plug->socket_window);
- xevent.xclient.type = ClientMessage;
- xevent.xclient.message_type = (Atom)gdk_atom_intern ("_XEMBED", FALSE);
- xevent.xclient.format = 32;
- xevent.xclient.data.l[0] = time;
- xevent.xclient.data.l[1] = message;
- xevent.xclient.data.l[2] = detail;
- xevent.xclient.data.l[3] = data1;
- xevent.xclient.data.l[4] = data2;
-
- gdk_error_trap_push ();
- XSendEvent (GDK_DISPLAY (),
- GDK_WINDOW_XWINDOW (plug->socket_window),
- False, NoEventMask, &xevent);
- gdk_flush ();
- gdk_error_trap_pop ();
- }
-}
-
-static void
-focus_first_last (GtkPlugXEmbed *plug,
- GtkDirectionType direction)
-{
- GtkWindow *window = GTK_WINDOW (plug);
- GtkWidget *parent;
-
- if (window->focus_widget)
- {
- parent = window->focus_widget->parent;
- while (parent)
- {
- gtk_container_set_focus_child (GTK_CONTAINER (parent), NULL);
- parent = GTK_WIDGET (parent)->parent;
- }
-
- gtk_window_set_focus (GTK_WINDOW (plug), NULL);
- }
-
-#ifdef PORT_COMPLETE
- gtk_widget_child_focus (GTK_WIDGET (plug), direction);
-#endif
-}
-
-static void
-handle_modality_on (GtkPlugXEmbed *plug)
-{
-#ifdef PORT_COMPLETE
- if (!plug->modality_window)
- {
- plug->modality_window = gtk_window_new (GTK_WINDOW_POPUP);
- gtk_widget_realize (plug->modality_window);
- gtk_window_group_add_window (plug->modality_group, GTK_WINDOW (plug->modality_window));
- gtk_grab_add (plug->modality_window);
- }
-#else
- /* g_print("Modality On for plug %p\n", plug); */
-#endif
-}
-
-static void
-handle_modality_off (GtkPlugXEmbed *plug)
-{
-#ifdef PORT_COMPLETE
- if (plug->modality_window)
- {
- gtk_widget_destroy (plug->modality_window);
- plug->modality_window = NULL;
- }
-#else
- /* g_print("Modality Off for plug %p\n", plug); */
-#endif
-}
-
-static void
-xembed_set_info (GdkWindow *gdk_window,
- unsigned long flags)
-{
- Display *display = GDK_WINDOW_XDISPLAY (gdk_window);
- Window window = GDK_WINDOW_XWINDOW (gdk_window);
- unsigned long buffer[2];
-
- Atom xembed_info_atom = (Atom)gdk_atom_intern ("_XEMBED_INFO", FALSE);
-
- buffer[1] = 0; /* Protocol version */
- buffer[1] = flags;
-
- XChangeProperty (display, window,
- xembed_info_atom, xembed_info_atom, 32,
- PropModeReplace,
- (unsigned char *)buffer, 2);
-}
-
-static void
-handle_xembed_message (GtkPlugXEmbed *plug,
- glong message,
- glong detail,
- glong data1,
- glong data2,
- guint32 time)
-{
- GTK_NOTE (PLUGSOCKET,
- g_message ("GtkPlugXEmbed: Message of type %ld received\n", message));
-
- switch (message)
- {
- case XEMBED_EMBEDDED_NOTIFY:
- break;
- case XEMBED_WINDOW_ACTIVATE:
- GTK_NOTE(PLUGSOCKET,
- g_message ("GtkPlugXEmbed: ACTIVATE received"));
- break;
- case XEMBED_WINDOW_DEACTIVATE:
- GTK_NOTE(PLUGSOCKET,
- g_message ("GtkPlugXEmbed: DEACTIVATE received"));
- break;
-
- case XEMBED_MODALITY_ON:
- handle_modality_on (plug);
- break;
- case XEMBED_MODALITY_OFF:
- handle_modality_off (plug);
- break;
-
- case XEMBED_FOCUS_IN:
- switch (detail)
- {
- case XEMBED_FOCUS_FIRST:
- focus_first_last (plug, GTK_DIR_TAB_FORWARD);
- break;
- case XEMBED_FOCUS_LAST:
- focus_first_last (plug, GTK_DIR_TAB_BACKWARD);
- break;
- case XEMBED_FOCUS_CURRENT:
- /* fall through */;
- }
-
- case XEMBED_FOCUS_OUT:
- {
- GtkWidget *widget = GTK_WIDGET (plug);
- GdkEvent event;
-
- event.focus_change.type = GDK_FOCUS_CHANGE;
- event.focus_change.window = widget->window;
- event.focus_change.send_event = TRUE;
-
- if (message == XEMBED_FOCUS_IN)
- {
- event.focus_change.in = TRUE;
- GTK_WIDGET_CLASS (parent_class)->focus_in_event (widget, (GdkEventFocus *)&event);
- }
- else
- {
- event.focus_change.in = FALSE;
- GTK_WIDGET_CLASS (parent_class)->focus_out_event (widget, (GdkEventFocus *)&event);
- }
-
- break;
- }
-
- case XEMBED_GRAB_KEY:
- case XEMBED_UNGRAB_KEY:
- case XEMBED_GTK_GRAB_KEY:
- case XEMBED_GTK_UNGRAB_KEY:
- case XEMBED_REQUEST_FOCUS:
- case XEMBED_FOCUS_NEXT:
- case XEMBED_FOCUS_PREV:
- g_warning ("GtkPlugXEmbed: Invalid _XEMBED message of type %ld received", message);
- break;
-
- default:
- GTK_NOTE(PLUGSOCKET,
- g_message ("GtkPlugXEmbed: Ignoring unknown _XEMBED message of type %ld", message));
- break;
- }
-}
-
-static GdkFilterReturn
-gtk_plug_xembed_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)
-{
- GtkPlugXEmbed *plug = GTK_PLUG_XEMBED (data);
- XEvent *xevent = (XEvent *)gdk_xevent;
-
- GdkFilterReturn return_val;
-
- return_val = GDK_FILTER_CONTINUE;
-
- switch (xevent->type)
- {
- case ClientMessage:
- if (xevent->xclient.message_type == (Atom)gdk_atom_intern ("_XEMBED", FALSE))
- {
- handle_xembed_message (plug,
- xevent->xclient.data.l[1],
- xevent->xclient.data.l[2],
- xevent->xclient.data.l[3],
- xevent->xclient.data.l[4],
- xevent->xclient.data.l[0]);
-
-
- return GDK_FILTER_REMOVE;
- }
- else if (xevent->xclient.message_type == (Atom)gdk_atom_intern ("WM_DELETE_WINDOW", FALSE))
- {
- /* We filter these out because we take being reparented back to the
- * root window as the reliable end of the embedding protocol
- */
-
- return GDK_FILTER_REMOVE;
- }
- break;
- case ReparentNotify:
- {
- XReparentEvent *xre = &xevent->xreparent;
- gboolean was_embedded = plug->socket_window != NULL;
-
- return_val = GDK_FILTER_REMOVE;
-
- g_object_ref (G_OBJECT(plug));
-
- if (was_embedded)
- {
- /* End of embedding protocol for previous socket */
-
- /* FIXME: race if we remove from another socket and
- * then add to a local window before we get notification
- * Probably need check in _gtk_plug_xembed_add_to_socket
- */
-
- if (xre->parent != GDK_WINDOW_XWINDOW (plug->socket_window))
- {
- GtkWidget *widget = GTK_WIDGET (plug);
-
- gdk_window_set_user_data (plug->socket_window, NULL);
- gdk_window_unref (plug->socket_window);
- plug->socket_window = NULL;
-
- /* Emit a delete window, as if the user attempted
- * to close the toplevel. Simple as to how we
- * handle WM_DELETE_WINDOW, if it isn't handled
- * we destroy the widget. BUt only do this if
- * we are being reparented to the root window.
- * Moving from one embedder to another should
- * be invisible to the app.
- */
-
- if (xre->parent == GDK_ROOT_WINDOW())
- {
- GdkEvent event;
-
- event.any.type = GDK_DELETE;
- event.any.window = gdk_window_ref (widget->window);
- event.any.send_event = FALSE;
-
- if (!gtk_widget_event (widget, &event))
- gtk_widget_destroy (widget);
-
- gdk_window_unref (event.any.window);
- }
- }
- else
- goto done;
- }
-
- if (xre->parent != GDK_ROOT_WINDOW ())
- {
- /* Start of embedding protocol */
-
- plug->socket_window = gdk_window_lookup (xre->parent);
- if (plug->socket_window)
- {
- gpointer user_data = NULL;
- gdk_window_get_user_data (plug->socket_window, &user_data);
-
- if (user_data)
- {
- g_warning (/*G_STRLOC*/ "Plug reparented unexpectedly into window in the same process");
- plug->socket_window = NULL;
- break;
- }
-
- gdk_window_ref (plug->socket_window);
- }
- else
- {
- plug->socket_window = gdk_window_foreign_new (xre->parent);
- if (!plug->socket_window) /* Already gone */
- break;
- }
-
-#ifdef PORT_COMPLETE
- if (plug->grabbed_keys)
- g_hash_table_foreach (plug->grabbed_keys, add_grabbed_key_always, plug);
-#endif
-
- if (!was_embedded)
- g_signal_emit (G_OBJECT (plug), plug_signals[EMBEDDED], 0);
- }
-
- done:
- g_object_unref (G_OBJECT(plug));
-
- break;
- }
- }
-
- return GDK_FILTER_CONTINUE;
-}
+++ /dev/null
-/* GTK - The GIMP Toolkit
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GTK+ Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#ifndef __GTK_PLUG_XEMBED_H__
-#define __GTK_PLUG_XEMBED_H__
-
-
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-
-#define GTK_TYPE_PLUG_XEMBED (gtk_plug_xembed_get_type ())
-#define GTK_PLUG_XEMBED(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_PLUG_XEMBED, GtkPlugXEmbed))
-#define GTK_PLUG_XEMBED_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_PLUG_XEMBED, GtkPlugXEmbedClass))
-#define GTK_IS_PLUG_XEMBED(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_PLUG_XEMBED))
-#define GTK_IS_PLUG_XEMBED_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PLUG_XEMBED))
-#define GTK_PLUG_XEMBED_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_PLUG_XEMBED, GtkPlugXEmbedClass))
-
-
-typedef struct _GtkPlugXEmbed GtkPlugXEmbed;
-typedef struct _GtkPlugXEmbedClass GtkPlugXEmbedClass;
-
-typedef guint32 GtkPlugXEmbedNativeWindow;
-
-struct _GtkPlugXEmbed
-{
- GtkWindow window;
-
- GdkWindow *socket_window;
-#ifdef PORT_COMPLETE
- GtkWidget *modality_window;
- GtkWindowGroup *modality_group;
-#endif
- GHashTable *grabbed_keys;
-
- guint same_app : 1;
-};
-
-struct _GtkPlugXEmbedClass
-{
- GtkWindowClass parent_class;
-
- void (*embedded) (GtkPlugXEmbed *plug);
-
- /* Padding for future expansion */
- void (*_gtk_reserved1) (void);
- void (*_gtk_reserved2) (void);
- void (*_gtk_reserved3) (void);
- void (*_gtk_reserved4) (void);
-};
-
-
-GtkType gtk_plug_xembed_get_type (void) G_GNUC_CONST;
-void gtk_plug_xembed_construct (GtkPlugXEmbed *plug, GtkPlugXEmbedNativeWindow socket_id);
-
-GtkWidget* gtk_plug_xembed_new (GtkPlugXEmbedNativeWindow socket_id);
-GtkPlugXEmbedNativeWindow gtk_plug_xembed_get_id (GtkPlugXEmbed *plug);
-
-void _gtk_plug_xembed_add_to_socket (GtkPlugXEmbed *plug,
- GtkSocket *socket);
-void _gtk_plug_xembed_remove_from_socket (GtkPlugXEmbed *plug,
- GtkSocket *socket);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __GTK_PLUG_XEMBED_H__ */
+++ /dev/null
-/* XEMBED messages */
-#define XEMBED_EMBEDDED_NOTIFY 0
-#define XEMBED_WINDOW_ACTIVATE 1
-#define XEMBED_WINDOW_DEACTIVATE 2
-#define XEMBED_REQUEST_FOCUS 3
-#define XEMBED_FOCUS_IN 4
-#define XEMBED_FOCUS_OUT 5
-#define XEMBED_FOCUS_NEXT 6
-#define XEMBED_FOCUS_PREV 7
-#define XEMBED_GRAB_KEY 8
-#define XEMBED_UNGRAB_KEY 9
-#define XEMBED_MODALITY_ON 10
-#define XEMBED_MODALITY_OFF 11
-
-/* Non standard messages*/
-#define XEMBED_GTK_GRAB_KEY 108
-#define XEMBED_GTK_UNGRAB_KEY 109
-
-/* Details for XEMBED_FOCUS_IN: */
-#define XEMBED_FOCUS_CURRENT 0
-#define XEMBED_FOCUS_FIRST 1
-#define XEMBED_FOCUS_LAST 2
-
-
-/* Flags for _XEMBED_INFO */
-#define XEMBED_MAPPED (1 << 0)
#include "account.h"
#include "gtk/manage_window.h"
-#include "eggtrayicon.h"
-
#include "trayicon_prefs.h"
#include "stock_pixmap.h"
static guint iconified_hook_id;
static guint theme_hook_id;
-static GdkPixbuf *newmail_pixmap[2] = {NULL, NULL};
-static GdkPixbuf *unreadmail_pixmap[2] = {NULL, NULL};
-static GdkPixbuf *newmarkedmail_pixmap[2] = {NULL, NULL};
-static GdkPixbuf *unreadmarkedmail_pixmap[2] = {NULL, NULL};
-static GdkPixbuf *nomail_pixmap[2] = {NULL, NULL};
+static GdkPixbuf *newmail_pixbuf[2] = {NULL, NULL};
+static GdkPixbuf *unreadmail_pixbuf[2] = {NULL, NULL};
+static GdkPixbuf *newmarkedmail_pixbuf[2] = {NULL, NULL};
+static GdkPixbuf *unreadmarkedmail_pixbuf[2] = {NULL, NULL};
+static GdkPixbuf *nomail_pixbuf[2] = {NULL, NULL};
-static EggTrayIcon *trayicon;
-static GtkWidget *eventbox;
+static GtkStatusIcon *trayicon;
static GtkWidget *image = NULL;
static GtkWidget *focused_widget = NULL;
-#if !(GTK_CHECK_VERSION(2,12,0))
-static GtkTooltips *tooltips;
-#endif
static GtkWidget *traymenu_popup;
static gboolean updating_menu = FALSE;
static void trayicon_addressbook_cb (GtkAction *action, gpointer data);
static void trayicon_exit_cb (GtkAction *action, gpointer data);
static void trayicon_toggle_offline_cb (GtkAction *action, gpointer data);
-static void resize_cb (GtkWidget *widget, GtkRequisition *req, gpointer user_data);
static GtkActionEntry trayicon_popup_menu_entries[] =
{
return FALSE;
}
-static void set_trayicon_pixmap(TrayIconType icontype)
+static void set_trayicon_pixbuf(TrayIconType icontype)
{
- GdkPixbuf *pixmap = NULL;
- static GdkPixbuf *last_pixmap = NULL;
+ GdkPixbuf *pixbuf = NULL;
+ static GdkPixbuf *last_pixbuf = NULL;
switch(icontype) {
case TRAYICON_NEW:
- pixmap = newmail_pixmap[prefs_common.work_offline];
+ pixbuf = newmail_pixbuf[prefs_common.work_offline];
break;
case TRAYICON_NEWMARKED:
- pixmap = newmarkedmail_pixmap[prefs_common.work_offline];
+ pixbuf = newmarkedmail_pixbuf[prefs_common.work_offline];
break;
case TRAYICON_UNREAD:
- pixmap = unreadmail_pixmap[prefs_common.work_offline];
+ pixbuf = unreadmail_pixbuf[prefs_common.work_offline];
break;
case TRAYICON_UNREADMARKED:
- pixmap = unreadmarkedmail_pixmap[prefs_common.work_offline];
+ pixbuf = unreadmarkedmail_pixbuf[prefs_common.work_offline];
break;
default:
- pixmap = nomail_pixmap[prefs_common.work_offline];
+ pixbuf = nomail_pixbuf[prefs_common.work_offline];
break;
}
- if (pixmap == last_pixmap) {
+ if (pixbuf == last_pixbuf) {
return;
}
- gtk_image_set_from_pixbuf(GTK_IMAGE(image), pixmap);
+ gtk_status_icon_set_from_pixbuf(GTK_STATUS_ICON(trayicon), pixbuf);
- last_pixmap = pixmap;
+ last_pixbuf = pixbuf;
}
static void update(FolderItem *removed_item)
buf = g_strdup_printf(_("New %d, Unread: %d, Total: %d"), new, unread, total);
-#if !(GTK_CHECK_VERSION(2,12,0))
- gtk_tooltips_set_tip(tooltips, eventbox, buf, "");
+#if !(GTK_CHECK_VERSION(2,16,0))
+ gtk_status_icon_set_tooltip(trayicon, buf);
#else
- gtk_widget_set_tooltip_text(eventbox, buf);
+ gtk_status_icon_set_tooltip_text(trayicon, buf);
#endif
g_free(buf);
icontype = TRAYICON_UNREAD;
}
- set_trayicon_pixmap(icontype);
+ set_trayicon_pixbuf(icontype);
}
static gboolean folder_item_update_hook(gpointer source, gpointer data)
return FALSE;
}
-static void resize_cb(GtkWidget *widget, GtkRequisition *req,
- gpointer user_data)
-{
- update(NULL);
-}
-
static void fix_folderview_scroll(MainWindow *mainwin)
{
static gboolean fix_done = FALSE;
static void create_trayicon(void);
-static void destroy_cb(GtkWidget *widget, gpointer *data)
-{
- debug_print("Widget destroyed\n");
-
- create_trayicon();
-}
-
static gboolean trayicon_update_theme(gpointer source, gpointer data)
{
- stock_pixbuf_gdk(GTK_WIDGET(trayicon), STOCK_PIXMAP_TRAY_NOMAIL, &nomail_pixmap[0]);
- stock_pixbuf_gdk(GTK_WIDGET(trayicon), STOCK_PIXMAP_TRAY_UNREADMAIL, &unreadmail_pixmap[0]);
- stock_pixbuf_gdk(GTK_WIDGET(trayicon), STOCK_PIXMAP_TRAY_NEWMAIL, &newmail_pixmap[0]);
- stock_pixbuf_gdk(GTK_WIDGET(trayicon), STOCK_PIXMAP_TRAY_UNREADMARKEDMAIL, &unreadmarkedmail_pixmap[0]);
- stock_pixbuf_gdk(GTK_WIDGET(trayicon), STOCK_PIXMAP_TRAY_NEWMARKEDMAIL, &newmarkedmail_pixmap[0]);
-
- stock_pixbuf_gdk(GTK_WIDGET(trayicon), STOCK_PIXMAP_TRAY_NOMAIL_OFFLINE, &nomail_pixmap[1]);
- stock_pixbuf_gdk(GTK_WIDGET(trayicon), STOCK_PIXMAP_TRAY_UNREADMAIL_OFFLINE, &unreadmail_pixmap[1]);
- stock_pixbuf_gdk(GTK_WIDGET(trayicon), STOCK_PIXMAP_TRAY_NEWMAIL_OFFLINE, &newmail_pixmap[1]);
- stock_pixbuf_gdk(GTK_WIDGET(trayicon), STOCK_PIXMAP_TRAY_UNREADMARKEDMAIL_OFFLINE, &unreadmarkedmail_pixmap[1]);
- stock_pixbuf_gdk(GTK_WIDGET(trayicon), STOCK_PIXMAP_TRAY_NEWMARKEDMAIL_OFFLINE, &newmarkedmail_pixmap[1]);
+ MainWindow *mainwin = mainwindow_get_mainwindow();
+ stock_pixbuf_gdk(GTK_WIDGET(mainwin->window), STOCK_PIXMAP_TRAY_NOMAIL, &nomail_pixbuf[0]);
+ stock_pixbuf_gdk(GTK_WIDGET(mainwin->window), STOCK_PIXMAP_TRAY_UNREADMAIL, &unreadmail_pixbuf[0]);
+ stock_pixbuf_gdk(GTK_WIDGET(mainwin->window), STOCK_PIXMAP_TRAY_NEWMAIL, &newmail_pixbuf[0]);
+ stock_pixbuf_gdk(GTK_WIDGET(mainwin->window), STOCK_PIXMAP_TRAY_UNREADMARKEDMAIL, &unreadmarkedmail_pixbuf[0]);
+ stock_pixbuf_gdk(GTK_WIDGET(mainwin->window), STOCK_PIXMAP_TRAY_NEWMARKEDMAIL, &newmarkedmail_pixbuf[0]);
+
+ stock_pixbuf_gdk(GTK_WIDGET(mainwin->window), STOCK_PIXMAP_TRAY_NOMAIL_OFFLINE, &nomail_pixbuf[1]);
+ stock_pixbuf_gdk(GTK_WIDGET(mainwin->window), STOCK_PIXMAP_TRAY_UNREADMAIL_OFFLINE, &unreadmail_pixbuf[1]);
+ stock_pixbuf_gdk(GTK_WIDGET(mainwin->window), STOCK_PIXMAP_TRAY_NEWMAIL_OFFLINE, &newmail_pixbuf[1]);
+ stock_pixbuf_gdk(GTK_WIDGET(mainwin->window), STOCK_PIXMAP_TRAY_UNREADMARKEDMAIL_OFFLINE, &unreadmarkedmail_pixbuf[1]);
+ stock_pixbuf_gdk(GTK_WIDGET(mainwin->window), STOCK_PIXMAP_TRAY_NEWMARKEDMAIL_OFFLINE, &newmarkedmail_pixbuf[1]);
if (image != NULL)
update(NULL);
static void create_trayicon()
{
GtkActionGroup *action_group;
- trayicon = egg_tray_icon_new("Claws Mail");
- gtk_widget_realize(GTK_WIDGET(trayicon));
- gtk_window_set_default_size(GTK_WINDOW(trayicon), 16, 16);
- gtk_container_set_border_width(GTK_CONTAINER(trayicon), 0);
-
+ trayicon = gtk_status_icon_new();
+#if GTK_CHECK_VERSION(2,14,0)
+ gtk_status_icon_set_title(GTK_STATUS_ICON(trayicon), _("Claws Mail"));
+#endif
trayicon_update_theme(NULL, NULL);
- eventbox = gtk_event_box_new();
- gtk_container_set_border_width(GTK_CONTAINER(eventbox), 0);
- gtk_container_add(GTK_CONTAINER(trayicon), GTK_WIDGET(eventbox));
-
- image = gtk_image_new_from_pixbuf(nomail_pixmap[0]);
- gtk_container_add(GTK_CONTAINER(eventbox), image);
+ gtk_status_icon_set_from_pixbuf(GTK_STATUS_ICON(trayicon), nomail_pixbuf[0]);
destroy_signal_id =
- g_signal_connect(G_OBJECT(trayicon), "destroy",
- G_CALLBACK(destroy_cb), NULL);
- g_signal_connect(G_OBJECT(trayicon), "size-request",
- G_CALLBACK(resize_cb), NULL);
- g_signal_connect(G_OBJECT(eventbox), "button-press-event",
+ g_signal_connect(G_OBJECT(trayicon), "button-press-event",
G_CALLBACK(click_cb), NULL);
-#if !(GTK_CHECK_VERSION(2,12,0))
- tooltips = gtk_tooltips_new();
- gtk_tooltips_enable(tooltips);
-#endif
-
action_group = cm_menu_create_action_group("TrayiconPopup", trayicon_popup_menu_entries,
G_N_ELEMENTS(trayicon_popup_menu_entries), (gpointer)NULL);
gtk_action_group_add_toggle_actions(action_group, trayicon_popup_toggle_menu_entries,
traymenu_popup = gtk_menu_item_get_submenu(GTK_MENU_ITEM(
gtk_ui_manager_get_widget(gtkut_ui_manager(), "/Menus/TrayiconPopup")) );
- gtk_widget_show_all(GTK_WIDGET(trayicon));
-
update(NULL);
}
g_signal_handler_disconnect(G_OBJECT(trayicon), destroy_signal_id);
- gtk_widget_destroy(GTK_WIDGET(trayicon));
+ g_object_unref(G_OBJECT(trayicon));
+ trayicon = NULL;
while (gtk_events_pending()) {
gtk_main_iteration();