[gnome-panel/bonobo-less] [libpanel-applet-bonobo] Add a module to load bonobo applets
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/bonobo-less] [libpanel-applet-bonobo] Add a module to load bonobo applets
- Date: Wed, 26 May 2010 13:13:46 +0000 (UTC)
commit cacf025a7ac48fa4c2279a13d4c3c2905af38842
Author: Vincent Untz <vuntz gnome org>
Date: Wed May 26 15:11:37 2010 +0200
[libpanel-applet-bonobo] Add a module to load bonobo applets
So I'm adding back a temporary bonobo dependency (optional) because it's
easier to test things this way -- in the long term, all the
bonobo-related code will move to a separate module.
We can load both dbus and bonobo applets now. There are a few bugs to
fix, though.
Makefile.am | 4 +
bonobo/Makefile.am | 3 +
bonobo/idl/GNOME_Panel.idl | 51 +
bonobo/idl/Makefile.am | 7 +
.../GNOME_Panel_TestApplet.server.in | 31 +
bonobo/libpanel-applet/Makefile.am | 133 ++
bonobo/libpanel-applet/TODO | 14 +
.../libpanelapplet-2.0-uninstalled.pc.in | 11 +
bonobo/libpanel-applet/libpanelapplet-2.0.pc.in | 11 +
bonobo/libpanel-applet/panel-applet-gconf.c | 458 +++++
bonobo/libpanel-applet/panel-applet-gconf.h | 86 +
bonobo/libpanel-applet/panel-applet-marshal.list | 5 +
bonobo/libpanel-applet/panel-applet-private.h | 36 +
bonobo/libpanel-applet/panel-applet-shell.c | 105 ++
bonobo/libpanel-applet/panel-applet-shell.h | 62 +
bonobo/libpanel-applet/panel-applet.c | 1866 ++++++++++++++++++++
bonobo/libpanel-applet/panel-applet.h | 254 +++
bonobo/libpanel-applet/panel-test-applets-bonobo.c | 349 ++++
.../libpanel-applet/panel-test-applets-bonobo.ui | 203 +++
bonobo/libpanel-applet/test-bonobo-applet.c | 202 +++
bonobo/panel-module/GNOME_Panel_Popup.xml | 20 +
bonobo/panel-module/Makefile.am | 56 +
bonobo/panel-module/panel-applet-frame-bonobo.c | 748 ++++++++
bonobo/panel-module/panel-applet-frame-bonobo.h | 61 +
bonobo/panel-module/panel-applets-bonobo-module.c | 48 +
bonobo/panel-module/panel-applets-manager-bonobo.c | 248 +++
bonobo/panel-module/panel-applets-manager-bonobo.h | 55 +
configure.in | 59 +
.../panel-applets-manager-dbus.c | 2 +-
gnome-panel/panel-applet-info.c | 14 +-
30 files changed, 5195 insertions(+), 7 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 0e8f899..a582876 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,6 +8,10 @@ SUBDIRS = \
doc \
man
+if HAVE_BONOBO
+SUBDIRS += bonobo
+endif
+
ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST = \
diff --git a/bonobo/Makefile.am b/bonobo/Makefile.am
new file mode 100644
index 0000000..1baf844
--- /dev/null
+++ b/bonobo/Makefile.am
@@ -0,0 +1,3 @@
+SUBDIRS = idl libpanel-applet panel-module
+
+-include $(top_srcdir)/git.mk
diff --git a/bonobo/idl/GNOME_Panel.idl b/bonobo/idl/GNOME_Panel.idl
new file mode 100644
index 0000000..07a8e9d
--- /dev/null
+++ b/bonobo/idl/GNOME_Panel.idl
@@ -0,0 +1,51 @@
+#ifndef GNOME_PANEL_IDL
+#define GNOME_PANEL_IDL
+
+#include <Bonobo_Unknown.idl>
+
+module GNOME {
+ module Vertigo {
+
+ /*
+ * The panel's orientation.
+ */
+ typedef unsigned short PanelOrient;
+
+ const PanelOrient PANEL_ORIENT_UP = 0;
+ const PanelOrient PANEL_ORIENT_DOWN = 1;
+ const PanelOrient PANEL_ORIENT_LEFT = 2;
+ const PanelOrient PANEL_ORIENT_RIGHT = 3;
+
+ /*
+ * The panel's width or height, depending
+ * on its orientation.
+ */
+ typedef unsigned short PanelSize;
+
+ const PanelSize PANEL_XX_SMALL = 12;
+ const PanelSize PANEL_X_SMALL = 24;
+ const PanelSize PANEL_SMALL = 36;
+ const PanelSize PANEL_MEDIUM = 48;
+ const PanelSize PANEL_LARGE = 64;
+ const PanelSize PANEL_X_LARGE = 80;
+ const PanelSize PANEL_XX_LARGE = 128;
+
+ /* Used for the size hints list */
+ typedef sequence<long> SizeHintList;
+
+ /*
+ * GNOME::PanelBackground Format:
+ * o "none:" - no background.
+ * o "colour:xxxxxx' - rgb colour value.
+ * o "pixmap:XID,x,y" - the pixmap XID, and the applets offsets into
+ * that pixmap.
+ */
+ typedef string PanelBackground;
+
+ interface PanelAppletShell : Bonobo::Unknown {
+ oneway void popup_menu (in long button, in long time);
+ };
+ };
+};
+
+#endif /* GNOME_PANEL_IDL */
diff --git a/bonobo/idl/Makefile.am b/bonobo/idl/Makefile.am
new file mode 100644
index 0000000..7c18d30
--- /dev/null
+++ b/bonobo/idl/Makefile.am
@@ -0,0 +1,7 @@
+idldir = $(datadir)/idl/gnome-panel-2.0
+
+idl_DATA = GNOME_Panel.idl
+
+EXTRA_DIST = $(idl_DATA)
+
+-include $(top_srcdir)/git.mk
diff --git a/bonobo/libpanel-applet/GNOME_Panel_TestApplet.server.in b/bonobo/libpanel-applet/GNOME_Panel_TestApplet.server.in
new file mode 100644
index 0000000..4254dcd
--- /dev/null
+++ b/bonobo/libpanel-applet/GNOME_Panel_TestApplet.server.in
@@ -0,0 +1,31 @@
+<oaf_info>
+
+<oaf_server iid="OAFIID:GNOME_Panel_TestBonoboApplet_Factory"
+ type="exe"
+ location="test-bonobo-applet">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:Bonobo/GenericFactory:1.0"/>
+ <item value="IDL:Bonobo/Unknown:1.0"/>
+ </oaf_attribute>
+ <oaf_attribute name="name" type="string" _value="Test Bonobo Applet Factory"/>
+ <oaf_attribute name="description" type="string" _value="Test Bonobo Applet Factory"/>
+
+</oaf_server>
+
+<oaf_server iid="OAFIID:GNOME_Panel_TestBonoboApplet"
+ type="factory"
+ location="OAFIID:GNOME_Panel_TestBonoboApplet_Factory">
+
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:GNOME/Vertigo/PanelAppletShell:1.0"/>
+ <item value="IDL:Bonobo/Control:1.0"/>
+ <item value="IDL:Bonobo/Unknown:1.0"/>
+ </oaf_attribute>
+ <oaf_attribute name="name" type="string" _value="Test Bonobo Applet"/>
+ <oaf_attribute name="description" type="string" _value="A simple applet for testing the GNOME-2.0 panel"/>
+ <oaf_attribute name="panel:icon" type="string" value="gnome-gegl.png"/>
+
+</oaf_server>
+
+</oaf_info>
diff --git a/bonobo/libpanel-applet/Makefile.am b/bonobo/libpanel-applet/Makefile.am
new file mode 100644
index 0000000..82def38
--- /dev/null
+++ b/bonobo/libpanel-applet/Makefile.am
@@ -0,0 +1,133 @@
+INCLUDES = \
+ -I$(top_builddir)/bonobo/libpanel-applet \
+ -DPANEL_APPLET_DATADIR=\""$(datadir)"\" \
+ -DPANEL_APPLET_BUILDERDIR=\""$(uidir)"\" \
+ -DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
+ $(LIBPANEL_APPLET_BONOBO_CFLAGS) \
+ $(DISABLE_DEPRECATED_CFLAGS) \
+ $(WARN_CFLAGS)
+
+lib_LTLIBRARIES = libpanel-applet-2.la
+
+libpanel_applet_2_la_SOURCES = \
+ panel-applet.h \
+ panel-applet.c \
+ panel-applet-gconf.c \
+ panel-applet-gconf.h \
+ panel-applet-shell.c \
+ panel-applet-shell.h \
+ panel-applet-private.h \
+ panel-applet-marshal.c \
+ panel-applet-marshal.h \
+ panel-applet-enums.c \
+ panel-applet-enums.h \
+ $(CORBA_SRCLIST)
+
+libpanel_applet_2_la_LDFLAGS = \
+ -version-info $(LIB_PANEL_APPLET_BONOBO_LT_VERSION) \
+ -no-undefined
+libpanel_applet_2_la_LIBADD = \
+ $(LIBPANEL_APPLET_BONOBO_LIBS) \
+ $(X_LIBS)
+
+libpanel_appletincludedir = $(includedir)/panel-2.0
+
+libpanel_appletinclude_HEADERS = \
+ panel-applet.h \
+ panel-applet-gconf.h \
+ panel-applet-enums.h \
+ GNOME_Panel.h
+
+CORBA_SRCLIST = \
+ GNOME_Panel-stubs.c \
+ GNOME_Panel-skels.c \
+ GNOME_Panel-common.c \
+ GNOME_Panel.h
+
+$(CORBA_SRCLIST): $(top_srcdir)/bonobo/idl/GNOME_Panel.idl $(ORBIT_IDL)
+ $(AM_V_GEN)$(ORBIT_IDL) -I $(BONOBO_IDLDIR) -I $(BONOBO_ACT_IDLDIR) $(top_srcdir)/bonobo/idl/GNOME_Panel.idl
+
+noinst_PROGRAMS = test-bonobo-applet
+
+bin_PROGRAMS = panel-test-applets-bonobo
+
+panel_test_applets_bonobo_LDFLAGS = -export-dynamic
+panel_test_applets_bonobo_LDADD = \
+ $(LIBPANEL_APPLET_BONOBO_LIBS) \
+ libpanel-applet-2.la
+
+test_bonobo_applet_LDADD = \
+ $(LIBPANEL_APPLET_BONOBO_LIBS) \
+ libpanel-applet-2.la
+
+BUILT_SOURCES = \
+ $(CORBA_SRCLIST) \
+ panel-applet-enums.c \
+ panel-applet-enums.h \
+ panel-applet-marshal.c \
+ panel-applet-marshal.h
+
+$(libpanel_applet_2_la_OBJECTS) $(test_bonobo_applet_bonobo_OBJECTS): $(BUILT_SOURCES)
+
+EXTRA_DIST = \
+ GNOME_Panel_TestApplet.server.in \
+ panel-applet-marshal.list \
+ libpanelapplet-2.0.pc.in \
+ libpanelapplet-2.0-uninstalled.pc.in \
+ panel-test-applets-bonobo.ui
+
+panel-applet-marshal.h: panel-applet-marshal.list $(GLIB_GENMARSHAL)
+ $(AM_V_GEN)$(GLIB_GENMARSHAL) $< --header --prefix=panel_applet_marshal > $@
+
+panel-applet-marshal.c: panel-applet-marshal.list $(GLIB_GENMARSHAL)
+ $(AM_V_GEN)echo "#include \"panel-applet-marshal.h\"" > $@ && \
+ $(GLIB_GENMARSHAL) $< --body --prefix=panel_applet_marshal >> $@
+
+panel_applet_enum_headers = $(top_srcdir)/libpanel-applet/panel-applet.h
+
+panel-applet-enums.c: @REBUILD@ $(panel_applet_enum_headers)
+ $(AM_V_GEN)glib-mkenums \
+ --fhead "#include <glib-object.h>\n" \
+ --fhead "#include \"panel-applet-enums.h\"\n\n" \
+ --fprod "\n/* enumerations from \"@filename \" */" \
+ --fprod "\n#include \"@filename \"\n" \
+ --vhead "static const G Type@Value _ enum_name@_values[] = {" \
+ --vprod " { @VALUENAME@, \"@VALUENAME \", \"@valuenick \" }," \
+ --vtail " { 0, NULL, NULL }\n};\n\n" \
+ --vtail "GType\n enum_name@_get_type (void)\n{\n" \
+ --vtail " static GType type = 0;\n\n" \
+ --vtail " if (!type)\n" \
+ --vtail " type = g_ type@_register_static (\"@EnumName \", _ enum_name@_values);\n\n" \
+ --vtail " return type;\n}\n\n" \
+ $(panel_applet_enum_headers) > $@
+
+panel-applet-enums.h: @REBUILD@ $(panel_applet_enum_headers)
+ $(AM_V_GEN)glib-mkenums \
+ --fhead "#ifndef __PANEL_APPLET_ENUMS_H__\n" \
+ --fhead "#define __PANEL_APPLET_ENUMS_H__\n\n" \
+ --fhead "G_BEGIN_DECLS\n\n" \
+ --ftail "G_END_DECLS\n\n" \
+ --ftail "#endif /* __PANEL_APPLET_ENUMS_H__ */\n" \
+ --fprod "\n/* --- @filename@ --- */" \
+ --eprod "#define PANEL_TYPE_ ENUMNAME@ @enum_name _get_type()\n" \
+ --eprod "GType @enum_name _get_type (void);\n" \
+ $(panel_applet_enum_headers) > $@
+
+uidir = $(datadir)/gnome-panel/ui
+ui_DATA = panel-test-applets-bonobo.ui
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libpanelapplet-2.0.pc
+
+CLEANFILES = $(BUILT_SOURCES) $(noinst_DATA)
+
+serverdir = $(libdir)/bonobo/servers
+server_in_files = GNOME_Panel_TestApplet.server.in
+noinst_DATA = $(server_in_files:.server.in=.server)
+
+ INTLTOOL_SERVER_RULE@
+
+dist-hook:
+ cd $(distdir) ; rm -f $(CLEANFILES)
+
+-include $(top_srcdir)/git.mk
diff --git a/bonobo/libpanel-applet/TODO b/bonobo/libpanel-applet/TODO
new file mode 100644
index 0000000..2cc2a72
--- /dev/null
+++ b/bonobo/libpanel-applet/TODO
@@ -0,0 +1,14 @@
+libpanel-applet todo list
+=========================
+
+ Things that need to be finished before this library can be considered
+anyway complete.
+
+ * Size negotiation. Basically make sure this works. It should be no
+ different than the usual GtkWidget size request/allocation. The
+ applets shouldn't be allowed to be any bigger than the panel. The
+ other issue is with applets that want to expand to fill the available
+ space on the panel. At the moment this is solved with getExpandFlags,
+ but this ends up with some freaky stuff going on when you're moving
+ applets. Maybe we should consider having a re-sizable flag which would
+ make the applets have grabs for re-sizing.
diff --git a/bonobo/libpanel-applet/libpanelapplet-2.0-uninstalled.pc.in b/bonobo/libpanel-applet/libpanelapplet-2.0-uninstalled.pc.in
new file mode 100644
index 0000000..4173cc8
--- /dev/null
+++ b/bonobo/libpanel-applet/libpanelapplet-2.0-uninstalled.pc.in
@@ -0,0 +1,11 @@
+prefix= prefix@
+exec_prefix= exec_prefix@
+libdir= libdir@
+includedir= includedir@
+
+Name: libpanel-applet-2
+Description: libpanel-applet-2
+Requires: gconf-2.0 gtk+-2.0 libbonoboui-2.0
+Version: @VERSION@
+Libs: ${pc_top_builddir}/${pcfiledir}/libpanel-applet-2.la
+Cflags: -I${pc_top_builddir}/${pcfiledir}
diff --git a/bonobo/libpanel-applet/libpanelapplet-2.0.pc.in b/bonobo/libpanel-applet/libpanelapplet-2.0.pc.in
new file mode 100644
index 0000000..b55e893
--- /dev/null
+++ b/bonobo/libpanel-applet/libpanelapplet-2.0.pc.in
@@ -0,0 +1,11 @@
+prefix= prefix@
+exec_prefix= exec_prefix@
+libdir= libdir@
+includedir= includedir@
+
+Name: libpanel-applet-2
+Description: libpanel-applet-2
+Requires: gconf-2.0 gtk+-2.0 libbonoboui-2.0
+Version: @VERSION@
+Libs: -L${libdir} -lpanel-applet-2
+Cflags: -I${includedir}/panel-2.0
diff --git a/bonobo/libpanel-applet/panel-applet-gconf.c b/bonobo/libpanel-applet/panel-applet-gconf.c
new file mode 100644
index 0000000..1a37790
--- /dev/null
+++ b/bonobo/libpanel-applet/panel-applet-gconf.c
@@ -0,0 +1,458 @@
+/*
+ * panel-applet-gconf.c: panel applet preferences handling.
+ *
+ * Copyright (C) 2001-2003 Sun Microsystems, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Mark McLoughlin <mark skynet ie>
+ */
+
+#include <gconf/gconf-client.h>
+
+#include "panel-applet-gconf.h"
+#include "panel-applet-private.h"
+
+static GConfClient *
+panel_applet_gconf_get_client (void)
+{
+ static GConfClient *client = NULL;
+
+ if (!client)
+ client = gconf_client_get_default ();
+
+ return client;
+}
+
+gchar *
+panel_applet_gconf_get_full_key (PanelApplet *applet,
+ const gchar *key)
+{
+ gchar *prefs_key;
+ gchar *full_key;
+
+ g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
+
+ if (!key)
+ return NULL;
+
+ prefs_key = panel_applet_get_preferences_key (applet);
+
+ full_key = g_strdup_printf ("%s/%s", prefs_key, key);
+
+ g_free (prefs_key);
+
+ return full_key;
+}
+
+void
+panel_applet_gconf_set_bool (PanelApplet *applet,
+ const gchar *key,
+ gboolean the_bool,
+ GError **opt_error)
+{
+ GConfClient *client;
+ gchar *full_key;
+ GError **error = NULL;
+ GError *our_error = NULL;
+
+ g_return_if_fail (PANEL_IS_APPLET (applet));
+
+ if (opt_error)
+ error = opt_error;
+ else
+ error = &our_error;
+
+ full_key = panel_applet_gconf_get_full_key (applet, key);
+
+ client = panel_applet_gconf_get_client ();
+
+ gconf_client_set_bool (client, full_key, the_bool, error);
+
+ g_free (full_key);
+
+ if (!opt_error && our_error) {
+ g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
+ g_error_free (our_error);
+ }
+}
+
+void
+panel_applet_gconf_set_int (PanelApplet *applet,
+ const gchar *key,
+ gint the_int,
+ GError **opt_error)
+{
+ GConfClient *client;
+ gchar *full_key;
+ GError **error = NULL;
+ GError *our_error = NULL;
+
+ g_return_if_fail (PANEL_IS_APPLET (applet));
+
+ if (opt_error)
+ error = opt_error;
+ else
+ error = &our_error;
+
+ full_key = panel_applet_gconf_get_full_key (applet, key);
+
+ client = panel_applet_gconf_get_client ();
+
+ gconf_client_set_int (client, full_key, the_int, error);
+
+ g_free (full_key);
+
+ if (!opt_error && our_error) {
+ g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
+ g_error_free (our_error);
+ }
+}
+
+void
+panel_applet_gconf_set_string (PanelApplet *applet,
+ const gchar *key,
+ const gchar *the_string,
+ GError **opt_error)
+{
+ GConfClient *client;
+ gchar *full_key;
+ GError **error = NULL;
+ GError *our_error = NULL;
+
+ g_return_if_fail (PANEL_IS_APPLET (applet));
+
+ if (opt_error)
+ error = opt_error;
+ else
+ error = &our_error;
+
+ full_key = panel_applet_gconf_get_full_key (applet, key);
+
+ client = panel_applet_gconf_get_client ();
+
+ gconf_client_set_string (client, full_key, the_string, error);
+
+ g_free (full_key);
+
+ if (!opt_error && our_error) {
+ g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
+ g_error_free (our_error);
+ }
+}
+
+void
+panel_applet_gconf_set_float (PanelApplet *applet,
+ const gchar *key,
+ gdouble the_float,
+ GError **opt_error)
+{
+ GConfClient *client;
+ gchar *full_key;
+ GError **error = NULL;
+ GError *our_error = NULL;
+
+ g_return_if_fail (PANEL_IS_APPLET (applet));
+
+ if (opt_error)
+ error = opt_error;
+ else
+ error = &our_error;
+
+ full_key = panel_applet_gconf_get_full_key (applet, key);
+
+ client = panel_applet_gconf_get_client ();
+
+ gconf_client_set_float (client, full_key, the_float, error);
+
+ g_free (full_key);
+
+ if (!opt_error && our_error) {
+ g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
+ g_error_free (our_error);
+ }
+}
+
+void
+panel_applet_gconf_set_list (PanelApplet *applet,
+ const gchar *key,
+ GConfValueType list_type,
+ GSList *list,
+ GError **opt_error)
+{
+ GConfClient *client;
+ gchar *full_key;
+ GError **error = NULL;
+ GError *our_error = NULL;
+
+ g_return_if_fail (PANEL_IS_APPLET (applet));
+
+ if (opt_error)
+ error = opt_error;
+ else
+ error = &our_error;
+
+ full_key = panel_applet_gconf_get_full_key (applet, key);
+
+ client = panel_applet_gconf_get_client ();
+
+ gconf_client_set_list (client, full_key, list_type, list, error);
+
+ g_free (full_key);
+
+ if (!opt_error && our_error) {
+ g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
+ g_error_free (our_error);
+ }
+}
+
+void
+panel_applet_gconf_set_value (PanelApplet *applet,
+ const gchar *key,
+ GConfValue *value,
+ GError **opt_error)
+{
+ GConfClient *client;
+ gchar *full_key;
+ GError **error = NULL;
+ GError *our_error = NULL;
+
+ g_return_if_fail (PANEL_IS_APPLET (applet));
+
+ if (opt_error)
+ error = opt_error;
+ else
+ error = &our_error;
+
+ full_key = panel_applet_gconf_get_full_key (applet, key);
+
+ client = panel_applet_gconf_get_client ();
+
+ gconf_client_set (client, full_key, value, error);
+
+ g_free (full_key);
+
+ if (!opt_error && our_error) {
+ g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
+ g_error_free (our_error);
+ }
+}
+
+gboolean
+panel_applet_gconf_get_bool (PanelApplet *applet,
+ const gchar *key,
+ GError **opt_error)
+{
+ GConfClient *client;
+ gchar *full_key;
+ gboolean retval;
+ GError **error = NULL;
+ GError *our_error = NULL;
+
+ g_return_val_if_fail (PANEL_IS_APPLET (applet), FALSE);
+
+ if (opt_error)
+ error = opt_error;
+ else
+ error = &our_error;
+
+ full_key = panel_applet_gconf_get_full_key (applet, key);
+
+ client = panel_applet_gconf_get_client ();
+
+ retval = gconf_client_get_bool (client, full_key, error);
+
+ g_free (full_key);
+
+ if (!opt_error && our_error) {
+ g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
+ g_error_free (our_error);
+ }
+
+ return retval;
+}
+
+gint
+panel_applet_gconf_get_int (PanelApplet *applet,
+ const gchar *key,
+ GError **opt_error)
+{
+ GConfClient *client;
+ gchar *full_key;
+ gint retval;
+ GError **error = NULL;
+ GError *our_error = NULL;
+
+ g_return_val_if_fail (PANEL_IS_APPLET (applet), -1);
+
+ if (opt_error)
+ error = opt_error;
+ else
+ error = &our_error;
+
+ full_key = panel_applet_gconf_get_full_key (applet, key);
+
+ client = panel_applet_gconf_get_client ();
+
+ retval = gconf_client_get_int (client, full_key, error);
+
+ g_free (full_key);
+
+ if (!opt_error && our_error) {
+ g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
+ g_error_free (our_error);
+ }
+
+ return retval;
+}
+
+gchar *
+panel_applet_gconf_get_string (PanelApplet *applet,
+ const gchar *key,
+ GError **opt_error)
+{
+ GConfClient *client;
+ gchar *full_key;
+ gchar *retval;
+ GError **error = NULL;
+ GError *our_error = NULL;
+
+ g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
+
+ if (opt_error)
+ error = opt_error;
+ else
+ error = &our_error;
+
+ full_key = panel_applet_gconf_get_full_key (applet, key);
+
+ client = panel_applet_gconf_get_client ();
+
+ retval = gconf_client_get_string (client, full_key, error);
+
+ g_free (full_key);
+
+ if (!opt_error && our_error) {
+ g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
+ g_error_free (our_error);
+ }
+
+ return retval;
+}
+
+gdouble
+panel_applet_gconf_get_float (PanelApplet *applet,
+ const gchar *key,
+ GError **opt_error)
+{
+ GConfClient *client;
+ gchar *full_key;
+ gdouble retval;
+ GError **error = NULL;
+ GError *our_error = NULL;
+
+ g_return_val_if_fail (PANEL_IS_APPLET (applet), 0.0);
+
+ if (opt_error)
+ error = opt_error;
+ else
+ error = &our_error;
+
+ full_key = panel_applet_gconf_get_full_key (applet, key);
+
+ client = panel_applet_gconf_get_client ();
+
+ retval = gconf_client_get_float (client, full_key, error);
+
+ g_free (full_key);
+
+ if (!opt_error && our_error) {
+ g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
+ g_error_free (our_error);
+ }
+
+ return retval;
+}
+
+GConfValue *
+panel_applet_gconf_get_value (PanelApplet *applet,
+ const gchar *key,
+ GError **opt_error)
+{
+ GConfClient *client;
+ gchar *full_key;
+ GConfValue *retval;
+ GError **error = NULL;
+ GError *our_error = NULL;
+
+ g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
+
+ if (opt_error)
+ error = opt_error;
+ else
+ error = &our_error;
+
+ full_key = panel_applet_gconf_get_full_key (applet, key);
+
+ client = panel_applet_gconf_get_client ();
+
+ retval = gconf_client_get (client, full_key, error);
+
+ g_free (full_key);
+
+ if (!opt_error && our_error) {
+ g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
+ g_error_free (our_error);
+ }
+
+ return retval;
+}
+
+GSList *
+panel_applet_gconf_get_list (PanelApplet *applet,
+ const gchar *key,
+ GConfValueType list_type,
+ GError **opt_error)
+{
+ GConfClient *client;
+ gchar *full_key;
+ GSList *retval;
+ GError **error = NULL;
+ GError *our_error = NULL;
+
+ g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
+
+ if (opt_error)
+ error = opt_error;
+ else
+ error = &our_error;
+
+ full_key = panel_applet_gconf_get_full_key (applet, key);
+
+ client = panel_applet_gconf_get_client ();
+
+ retval = gconf_client_get_list (client, full_key, list_type, error);
+
+ g_free (full_key);
+
+ if (!opt_error && our_error) {
+ g_warning (G_STRLOC ": gconf error : '%s'", our_error->message);
+ g_error_free (our_error);
+ }
+
+ return retval;
+}
diff --git a/bonobo/libpanel-applet/panel-applet-gconf.h b/bonobo/libpanel-applet/panel-applet-gconf.h
new file mode 100644
index 0000000..e0431b2
--- /dev/null
+++ b/bonobo/libpanel-applet/panel-applet-gconf.h
@@ -0,0 +1,86 @@
+/*
+ * panel-applet-gconf.h: panel applet preferences handling.
+ *
+ * Copyright (C) 2001-2003 Sun Microsystems, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Mark McLoughlin <mark skynet ie>
+ */
+
+#ifndef __PANEL_APPLET_GCONF_H__
+#define __PANEL_APPLET_GCONF_H__
+
+#include <glib.h>
+#include <gconf/gconf-value.h>
+
+#include <panel-applet.h>
+
+G_BEGIN_DECLS
+
+gchar *panel_applet_gconf_get_full_key (PanelApplet *applet,
+ const gchar *key);
+
+void panel_applet_gconf_set_bool (PanelApplet *applet,
+ const gchar *key,
+ gboolean the_bool,
+ GError **opt_error);
+void panel_applet_gconf_set_int (PanelApplet *applet,
+ const gchar *key,
+ gint the_int,
+ GError **opt_error);
+void panel_applet_gconf_set_string (PanelApplet *applet,
+ const gchar *key,
+ const gchar *the_string,
+ GError **opt_error);
+void panel_applet_gconf_set_float (PanelApplet *applet,
+ const gchar *key,
+ gdouble the_float,
+ GError **opt_error);
+void panel_applet_gconf_set_list (PanelApplet *applet,
+ const gchar *key,
+ GConfValueType list_type,
+ GSList *list,
+ GError **opt_error);
+void panel_applet_gconf_set_value (PanelApplet *applet,
+ const gchar *key,
+ GConfValue *value,
+ GError **opt_error);
+
+gboolean panel_applet_gconf_get_bool (PanelApplet *applet,
+ const gchar *key,
+ GError **opt_error);
+gint panel_applet_gconf_get_int (PanelApplet *applet,
+ const gchar *key,
+ GError **opt_error);
+gchar *panel_applet_gconf_get_string (PanelApplet *applet,
+ const gchar *key,
+ GError **opt_error);
+gdouble panel_applet_gconf_get_float (PanelApplet *applet,
+ const gchar *key,
+ GError **opt_error);
+GSList *panel_applet_gconf_get_list (PanelApplet *applet,
+ const gchar *key,
+ GConfValueType list_type,
+ GError **opt_error);
+GConfValue *panel_applet_gconf_get_value (PanelApplet *applet,
+ const gchar *key,
+ GError **opt_error);
+
+G_END_DECLS
+
+#endif /* __PANEL_APPLET_GCONF_H__ */
diff --git a/bonobo/libpanel-applet/panel-applet-marshal.list b/bonobo/libpanel-applet/panel-applet-marshal.list
new file mode 100644
index 0000000..1693a57
--- /dev/null
+++ b/bonobo/libpanel-applet/panel-applet-marshal.list
@@ -0,0 +1,5 @@
+VOID:ENUM,BOXED,OBJECT
+VOID:INT
+VOID:UINT
+VOID:ENUM
+BOOLEAN:STRING
diff --git a/bonobo/libpanel-applet/panel-applet-private.h b/bonobo/libpanel-applet/panel-applet-private.h
new file mode 100644
index 0000000..43b829f
--- /dev/null
+++ b/bonobo/libpanel-applet/panel-applet-private.h
@@ -0,0 +1,36 @@
+/*
+ * panel-applet-private.h:
+ *
+ * Copyright (C) 2001 Sun Microsystems, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Mark McLoughlin <mark skynet ie>
+ */
+
+#ifndef __PANEL_APPLET_PRIVATE_H__
+#define __PANEL_APPLET_PRIVATE_H__
+
+#include "panel-applet.h"
+
+G_BEGIN_DECLS
+
+gboolean _panel_applet_popup_menu (PanelApplet *applet, guint button, guint32 time);
+
+G_END_DECLS
+
+#endif /* __PANEL_APPLET_PRIVATE_H__ */
diff --git a/bonobo/libpanel-applet/panel-applet-shell.c b/bonobo/libpanel-applet/panel-applet-shell.c
new file mode 100644
index 0000000..874b3a2
--- /dev/null
+++ b/bonobo/libpanel-applet/panel-applet-shell.c
@@ -0,0 +1,105 @@
+/*
+ * panel-applet-shell.c: the panel's interface to the applet.
+ *
+ * Copyright (C) 2001 Sun Microsystems, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Mark McLoughlin <mark skynet ie>
+ */
+
+#include <config.h>
+
+#include "panel-applet-shell.h"
+#include "panel-applet.h"
+#include "panel-applet-private.h"
+
+struct _PanelAppletShellPrivate {
+ PanelApplet *applet;
+};
+
+static GObjectClass *parent_class = NULL;
+
+static void
+impl_PanelAppletShell_popup_menu (PortableServer_Servant servant,
+ CORBA_long button,
+ CORBA_long time,
+ CORBA_Environment *ev)
+{
+ PanelAppletShell *applet_shell;
+
+ applet_shell = PANEL_APPLET_SHELL (bonobo_object (servant));
+
+ _panel_applet_popup_menu (applet_shell->priv->applet, button, time);
+}
+
+static void
+panel_applet_shell_finalize (GObject *object)
+{
+ PanelAppletShell *shell = PANEL_APPLET_SHELL (object);
+
+ if (shell->priv) {
+ g_free (shell->priv);
+ shell->priv = NULL;
+ }
+
+ parent_class->finalize (object);
+}
+
+static void
+panel_applet_shell_class_init (PanelAppletShellClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ klass->epv.popup_menu = impl_PanelAppletShell_popup_menu;
+
+ object_class->finalize = panel_applet_shell_finalize;
+
+ parent_class = g_type_class_peek_parent (klass);
+}
+
+static void
+panel_applet_shell_init (PanelAppletShell *shell)
+{
+ shell->priv = g_new0 (PanelAppletShellPrivate, 1);
+
+ shell->priv->applet = NULL;
+}
+
+BONOBO_TYPE_FUNC_FULL (PanelAppletShell,
+ GNOME_Vertigo_PanelAppletShell,
+ BONOBO_OBJECT_TYPE,
+ panel_applet_shell)
+
+void
+panel_applet_shell_construct (PanelAppletShell *shell,
+ PanelApplet *applet)
+{
+ shell->priv->applet = applet;
+}
+
+PanelAppletShell *
+panel_applet_shell_new (PanelApplet *applet)
+{
+ PanelAppletShell *shell;
+
+ shell = g_object_new (PANEL_APPLET_SHELL_TYPE, NULL);
+
+ panel_applet_shell_construct (shell, applet);
+
+ return shell;
+}
diff --git a/bonobo/libpanel-applet/panel-applet-shell.h b/bonobo/libpanel-applet/panel-applet-shell.h
new file mode 100644
index 0000000..868c950
--- /dev/null
+++ b/bonobo/libpanel-applet/panel-applet-shell.h
@@ -0,0 +1,62 @@
+/*
+ * panel-applet-shell.h: the panel's interface to the applet.
+ *
+ * Copyright (C) 2001 Sun Microsystems, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Mark McLoughlin <mark skynet ie>
+ */
+
+#ifndef __PANEL_APPLET_SHELL_H__
+#define __PANEL_APPLET_SHELL_H__
+
+#include <bonobo/bonobo-object.h>
+
+#include <panel-applet.h>
+#include <GNOME_Panel.h>
+
+#define PANEL_APPLET_SHELL_TYPE (panel_applet_shell_get_type ())
+#define PANEL_APPLET_SHELL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PANEL_APPLET_SHELL_TYPE, PanelAppletShell))
+#define PANEL_APPLET_SHELL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), PANEL_APPLET_SHELL_TYPE, PanelAppletShellClass))
+#define PANEL_IS_APPLET_SHELL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PANEL_APPLET_SHELL_TYPE))
+#define PANEL_IS_APPLET_SHELL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PANEL_APPLET_SHELL_TYPE))
+
+typedef struct _PanelAppletShellPrivate PanelAppletShellPrivate;
+
+typedef struct {
+ BonoboObject base;
+
+ PanelAppletShellPrivate *priv;
+} PanelAppletShell;
+
+typedef struct {
+ BonoboObjectClass base_class;
+
+ POA_GNOME_Vertigo_PanelAppletShell__epv epv;
+} PanelAppletShellClass;
+
+
+GType panel_applet_shell_get_type (void) G_GNUC_CONST;
+
+void panel_applet_shell_construct (PanelAppletShell *shell,
+ PanelApplet *applet);
+
+PanelAppletShell *panel_applet_shell_new (PanelApplet *applet);
+
+
+#endif /* PANEL_APPLET_SHELL_H */
diff --git a/bonobo/libpanel-applet/panel-applet.c b/bonobo/libpanel-applet/panel-applet.c
new file mode 100644
index 0000000..4ab6bbc
--- /dev/null
+++ b/bonobo/libpanel-applet/panel-applet.c
@@ -0,0 +1,1866 @@
+/*
+ * panel-applet.c: panel applet writing library.
+ *
+ * Copyright (C) 2001 Sun Microsystems, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Mark McLoughlin <mark skynet ie>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <cairo.h>
+#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtk.h>
+#include <bonobo/bonobo-ui-util.h>
+#include <bonobo/bonobo-main.h>
+#include <bonobo/bonobo-types.h>
+#include <bonobo/bonobo-property-bag.h>
+#include <bonobo/bonobo-item-handler.h>
+#include <bonobo/bonobo-shlib-factory.h>
+#include <bonobo/bonobo-property-bag-client.h>
+#include <gconf/gconf.h>
+#include <gconf/gconf-client.h>
+#include <X11/Xatom.h>
+
+#include "panel-applet.h"
+#include "panel-applet-private.h"
+#include "panel-applet-shell.h"
+#include "panel-applet-marshal.h"
+#include "panel-applet-enums.h"
+
+#define PANEL_APPLET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_APPLET, PanelAppletPrivate))
+
+struct _PanelAppletPrivate {
+ PanelAppletShell *shell;
+ BonoboControl *control;
+ BonoboPropertyBag *prop_sack;
+ BonoboItemHandler *item_handler;
+ GConfClient *client;
+
+ char *iid;
+ GClosure *closure;
+ gboolean bound;
+ char *prefs_key;
+
+ PanelAppletFlags flags;
+ PanelAppletOrient orient;
+ guint size;
+ char *background;
+ GtkWidget *background_widget;
+
+ int previous_width;
+ int previous_height;
+
+ int *size_hints;
+ int size_hints_len;
+
+ gboolean moving_focus_out;
+
+ gboolean locked_down;
+};
+
+enum {
+ CHANGE_ORIENT,
+ CHANGE_SIZE,
+ CHANGE_BACKGROUND,
+ MOVE_FOCUS_OUT_OF_APPLET,
+ SAVE_YOURSELF,
+ LAST_SIGNAL
+};
+
+static guint panel_applet_signals [LAST_SIGNAL];
+
+#define PROPERTY_ORIENT "panel-applet-orient"
+#define PROPERTY_SIZE "panel-applet-size"
+#define PROPERTY_BACKGROUND "panel-applet-background"
+#define PROPERTY_FLAGS "panel-applet-flags"
+#define PROPERTY_SIZE_HINTS "panel-applet-size-hints"
+#define PROPERTY_LOCKED_DOWN "panel-applet-locked-down"
+
+enum {
+ PROPERTY_ORIENT_IDX,
+ PROPERTY_SIZE_IDX,
+ PROPERTY_BACKGROUND_IDX,
+ PROPERTY_FLAGS_IDX,
+ PROPERTY_SIZE_HINTS_IDX,
+ PROPERTY_LOCKED_DOWN_IDX
+};
+
+G_DEFINE_TYPE (PanelApplet, panel_applet, GTK_TYPE_EVENT_BOX)
+
+static void panel_applet_handle_background (PanelApplet *applet);
+static void panel_applet_setup (PanelApplet *applet);
+
+static void
+panel_applet_associate_schemas_in_dir (GConfClient *client,
+ const gchar *prefs_key,
+ const gchar *schema_dir,
+ GError **error)
+{
+ GSList *list, *l;
+
+ list = gconf_client_all_entries (client, schema_dir, error);
+
+ if (*error != NULL)
+ return;
+
+ for (l = list; l; l = l->next) {
+ GConfEntry *entry = l->data;
+ const gchar *schema_key;
+ GConfEntry *applet_entry;
+ const gchar *applet_schema_key;
+ gchar *key;
+ gchar *tmp;
+
+ schema_key = gconf_entry_get_key (entry);
+ tmp = g_path_get_basename (schema_key);
+
+ if (strchr (tmp, '-'))
+ g_warning ("Applet key '%s' contains a hyphen. Please "
+ "use underscores in gconf keys\n", tmp);
+
+ key = g_strdup_printf ("%s/%s", prefs_key, tmp);
+ g_free (tmp);
+
+ /* Associating a schema is potentially expensive, so let's try
+ * to avoid this by doing it only when needed. So we check if
+ * the key is already correctly associated. */
+
+ applet_entry = gconf_client_get_entry (client, key,
+ NULL, TRUE, NULL);
+ if (applet_entry)
+ applet_schema_key = gconf_entry_get_schema_name (applet_entry);
+ else
+ applet_schema_key = NULL;
+
+ if (g_strcmp0 (schema_key, applet_schema_key) != 0) {
+ gconf_engine_associate_schema (client->engine,
+ key, schema_key, error);
+
+ if (applet_entry == NULL ||
+ gconf_entry_get_value (applet_entry) == NULL ||
+ gconf_entry_get_is_default (applet_entry)) {
+ /* unset the key: gconf_client_get_entry()
+ * brought an invalid entry in the client
+ * cache, and we want to fix this */
+ gconf_client_unset (client, key, NULL);
+ }
+ }
+
+ g_free (key);
+
+ if (applet_entry)
+ gconf_entry_unref (applet_entry);
+ gconf_entry_unref (entry);
+
+ if (*error) {
+ g_slist_free (list);
+ return;
+ }
+ }
+
+ g_slist_free (list);
+
+ list = gconf_client_all_dirs (client, schema_dir, error);
+
+ for (l = list; l; l = l->next) {
+ gchar *subdir = l->data;
+ gchar *prefs_subdir;
+ gchar *schema_subdir;
+ gchar *tmp;
+
+ tmp = g_path_get_basename (subdir);
+
+ prefs_subdir = g_strdup_printf ("%s/%s", prefs_key, tmp);
+ schema_subdir = g_strdup_printf ("%s/%s", schema_dir, tmp);
+
+ panel_applet_associate_schemas_in_dir (client,
+ prefs_subdir,
+ schema_subdir,
+ error);
+
+ g_free (prefs_subdir);
+ g_free (schema_subdir);
+ g_free (subdir);
+ g_free (tmp);
+
+ if (*error) {
+ g_slist_free (list);
+ return;
+ }
+ }
+
+ g_slist_free (list);
+}
+
+void
+panel_applet_add_preferences (PanelApplet *applet,
+ const gchar *schema_dir,
+ GError **opt_error)
+{
+ GError **error = NULL;
+ GError *our_error = NULL;
+
+ g_return_if_fail (PANEL_IS_APPLET (applet));
+ g_return_if_fail (schema_dir != NULL);
+
+ if (!applet->priv->prefs_key)
+ return;
+
+ if (opt_error)
+ error = opt_error;
+ else
+ error = &our_error;
+
+ panel_applet_associate_schemas_in_dir (applet->priv->client,
+ applet->priv->prefs_key,
+ schema_dir,
+ error);
+
+ if (!opt_error && our_error) {
+ g_warning (G_STRLOC ": failed to add preferences from '%s' : '%s'",
+ schema_dir, our_error->message);
+ g_error_free (our_error);
+ }
+}
+
+char *
+panel_applet_get_preferences_key (PanelApplet *applet)
+{
+ g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
+
+ if (!applet->priv->prefs_key)
+ return NULL;
+
+ return g_strdup (applet->priv->prefs_key);
+}
+
+static void
+panel_applet_set_preferences_key (PanelApplet *applet,
+ const char *prefs_key)
+{
+ g_return_if_fail (PANEL_IS_APPLET (applet));
+
+ if (applet->priv->prefs_key) {
+ gconf_client_remove_dir (applet->priv->client,
+ applet->priv->prefs_key,
+ NULL);
+
+ g_free (applet->priv->prefs_key);
+ applet->priv->prefs_key = NULL;
+ }
+
+ if (prefs_key) {
+ applet->priv->prefs_key = g_strdup (prefs_key);
+
+ gconf_client_add_dir (applet->priv->client,
+ applet->priv->prefs_key,
+ GCONF_CLIENT_PRELOAD_RECURSIVE,
+ NULL);
+ }
+}
+
+PanelAppletFlags
+panel_applet_get_flags (PanelApplet *applet)
+{
+ g_return_val_if_fail (PANEL_IS_APPLET (applet), PANEL_APPLET_FLAGS_NONE);
+
+ return applet->priv->flags;
+}
+
+void
+panel_applet_set_flags (PanelApplet *applet,
+ PanelAppletFlags flags)
+{
+ g_return_if_fail (PANEL_IS_APPLET (applet));
+
+ if (applet->priv->prop_sack != NULL)
+ bonobo_pbclient_set_short (BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_FLAGS, flags, NULL);
+ else
+ applet->priv->flags = flags;
+}
+
+void
+panel_applet_set_size_hints (PanelApplet *applet,
+ const int *size_hints,
+ int n_elements,
+ int base_size)
+{
+ CORBA_sequence_CORBA_long *seq;
+ CORBA_Environment env;
+ CORBA_any any;
+ int i;
+
+ CORBA_exception_init (&env);
+
+ seq = CORBA_sequence_CORBA_long__alloc ();
+ seq->_length = seq->_maximum = n_elements;
+ seq->_release = CORBA_TRUE;
+ seq->_buffer = CORBA_sequence_CORBA_long_allocbuf (seq->_length);
+
+ for (i = 0; i < n_elements; i++)
+ seq->_buffer [i] = size_hints [i] + base_size;
+
+ any._type = TC_CORBA_sequence_CORBA_long;
+ any._release = CORBA_FALSE;
+ any._value = seq;
+
+ Bonobo_PropertyBag_setValue (BONOBO_OBJREF (applet->priv->prop_sack),
+ PROPERTY_SIZE_HINTS,
+ &any,
+ &env);
+
+ CORBA_free (seq);
+
+ CORBA_exception_free (&env);
+}
+
+guint
+panel_applet_get_size (PanelApplet *applet)
+{
+ g_return_val_if_fail (PANEL_IS_APPLET (applet), 0);
+
+ return applet->priv->size;
+}
+
+PanelAppletOrient
+panel_applet_get_orient (PanelApplet *applet)
+{
+ g_return_val_if_fail (PANEL_IS_APPLET (applet), 0);
+
+ return applet->priv->orient;
+}
+
+gboolean
+panel_applet_get_locked_down (PanelApplet *applet)
+{
+ g_return_val_if_fail (PANEL_IS_APPLET (applet), FALSE);
+
+ return applet->priv->locked_down;
+}
+
+static Atom _net_wm_window_type = None;
+static Atom _net_wm_window_type_dock = None;
+static Atom _net_active_window = None;
+
+static void
+panel_applet_init_atoms (Display *xdisplay)
+{
+ if (_net_wm_window_type == None)
+ _net_wm_window_type = XInternAtom (xdisplay,
+ "_NET_WM_WINDOW_TYPE",
+ False);
+
+ if (_net_wm_window_type_dock == None)
+ _net_wm_window_type_dock = XInternAtom (xdisplay,
+ "_NET_WM_WINDOW_TYPE_DOCK",
+ False);
+
+ if (_net_active_window == None)
+ _net_active_window = XInternAtom (xdisplay,
+ "_NET_ACTIVE_WINDOW",
+ False);
+}
+
+static Window
+panel_applet_find_toplevel_dock_window (PanelApplet *applet,
+ Display *xdisplay)
+{
+ GtkWidget *toplevel;
+ Window xwin;
+ Window root, parent, *child;
+ int num_children;
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (applet));
+ if (!gtk_widget_get_realized (toplevel))
+ return None;
+
+ xwin = GDK_WINDOW_XID (toplevel->window);
+
+ child = NULL;
+ parent = root = None;
+ do {
+ Atom type_return;
+ Atom window_type;
+ int format_return;
+ gulong number_return, bytes_after_return;
+ guchar *data_return;
+
+ XGetWindowProperty (xdisplay,
+ xwin,
+ _net_wm_window_type,
+ 0, 1, False,
+ XA_ATOM,
+ &type_return, &format_return,
+ &number_return,
+ &bytes_after_return,
+ &data_return);
+
+ if (type_return == XA_ATOM) {
+ window_type = *(Atom *) data_return;
+
+ XFree (data_return);
+ data_return = NULL;
+
+ if (window_type == _net_wm_window_type_dock)
+ return xwin;
+ }
+
+ if (!XQueryTree (xdisplay,
+ xwin,
+ &root, &parent, &child,
+ (guint *) &num_children)) {
+ return None;
+ }
+
+ if (child && num_children > 0)
+ XFree (child);
+
+ xwin = parent;
+
+ } while (xwin != None && xwin != root);
+
+ return None;
+}
+
+/* This function
+ * 1) Gets the window id of the panel that contains the applet
+ * using XQueryTree and XGetWindowProperty to find an ancestor
+ * window with the _NET_WM_WINDOW_TYPE_DOCK window type.
+ * 2) Sends a _NET_ACTIVE_WINDOW message to get that panel focused
+ */
+void
+panel_applet_request_focus (PanelApplet *applet,
+ guint32 timestamp)
+{
+ GdkScreen *screen;
+ GdkWindow *root;
+ GdkDisplay *display;
+ Display *xdisplay;
+ Window dock_xwindow;
+ Window xroot;
+ XEvent xev;
+
+ g_return_if_fail (PANEL_IS_APPLET (applet));
+
+ screen = gtk_widget_get_screen (GTK_WIDGET (applet));
+ root = gdk_screen_get_root_window (screen);
+ display = gdk_screen_get_display (screen);
+
+ xdisplay = GDK_DISPLAY_XDISPLAY (display);
+ xroot = GDK_WINDOW_XWINDOW (root);
+
+ panel_applet_init_atoms (xdisplay);
+
+ dock_xwindow = panel_applet_find_toplevel_dock_window (applet, xdisplay);
+ if (dock_xwindow == None)
+ return;
+
+ xev.xclient.type = ClientMessage;
+ xev.xclient.serial = 0;
+ xev.xclient.send_event = True;
+ xev.xclient.window = dock_xwindow;
+ xev.xclient.message_type = _net_active_window;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = 1; /* requestor type; we're an app, I guess */
+ xev.xclient.data.l[1] = timestamp;
+ xev.xclient.data.l[2] = None; /* "currently active window", supposedly */
+ xev.xclient.data.l[3] = 0;
+ xev.xclient.data.l[4] = 0;
+
+ XSendEvent (xdisplay,
+ xroot, False,
+ SubstructureRedirectMask | SubstructureNotifyMask,
+ &xev);
+}
+
+void
+panel_applet_setup_menu (PanelApplet *applet,
+ const gchar *xml,
+ const BonoboUIVerb *verb_list,
+ gpointer user_data)
+{
+ BonoboUIComponent *popup_component;
+
+ g_return_if_fail (PANEL_IS_APPLET (applet));
+ g_return_if_fail (xml != NULL && verb_list != NULL);
+
+ popup_component = panel_applet_get_popup_component (applet);
+
+ bonobo_ui_component_set (popup_component, "/", "<popups/>", NULL);
+
+ bonobo_ui_component_set_translate (popup_component, "/popups", xml, NULL);
+
+ bonobo_ui_component_add_verb_list_with_data (popup_component, verb_list, user_data);
+}
+
+void
+panel_applet_setup_menu_from_file (PanelApplet *applet,
+ const gchar *opt_datadir,
+ const gchar *file,
+ const gchar *opt_app_name,
+ const BonoboUIVerb *verb_list,
+ gpointer user_data)
+{
+ BonoboUIComponent *popup_component;
+ gchar *app_name = NULL;
+
+ g_return_if_fail (PANEL_IS_APPLET (applet));
+ g_return_if_fail (file != NULL && verb_list != NULL);
+
+ if (!opt_datadir)
+ opt_datadir = PANEL_APPLET_DATADIR;
+
+ if (!opt_app_name)
+ opt_app_name = app_name = g_strdup_printf ("%lu",
+ (unsigned long) getpid ());
+
+ popup_component = panel_applet_get_popup_component (applet);
+
+ bonobo_ui_util_set_ui (popup_component, opt_datadir, file, opt_app_name, NULL);
+
+ bonobo_ui_component_add_verb_list_with_data (popup_component, verb_list, user_data);
+
+ if (app_name)
+ g_free (app_name);
+}
+
+BonoboControl *
+panel_applet_get_control (PanelApplet *applet)
+{
+ g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
+
+ return applet->priv->control;
+}
+
+BonoboUIComponent *
+panel_applet_get_popup_component (PanelApplet *applet)
+{
+ g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
+
+ return bonobo_control_get_popup_ui_component (applet->priv->control);
+}
+
+static void
+panel_applet_finalize (GObject *object)
+{
+ PanelApplet *applet = PANEL_APPLET (object);
+
+ panel_applet_set_preferences_key (applet, NULL);
+
+ if (applet->priv->client)
+ g_object_unref (applet->priv->client);
+ applet->priv->client = NULL;
+
+ if (applet->priv->prop_sack)
+ bonobo_object_unref (
+ BONOBO_OBJECT (applet->priv->prop_sack));
+ applet->priv->prop_sack = NULL;
+
+ g_free (applet->priv->size_hints);
+ g_free (applet->priv->prefs_key);
+ g_free (applet->priv->background);
+ g_free (applet->priv->iid);
+
+ if (applet->priv->closure)
+ g_closure_unref (applet->priv->closure);
+ applet->priv->closure = NULL;
+
+ G_OBJECT_CLASS (panel_applet_parent_class)->finalize (object);
+}
+
+static gboolean
+container_has_focusable_child (GtkContainer *container)
+{
+ GtkWidget *child;
+ GList *list;
+ GList *t;
+ gboolean retval = FALSE;
+
+ list = gtk_container_get_children (container);
+
+ for (t = list; t; t = t->next) {
+ child = GTK_WIDGET (t->data);
+ if (gtk_widget_get_can_focus (child)) {
+ retval = TRUE;
+ break;
+ } else if (GTK_IS_CONTAINER (child)) {
+ retval = container_has_focusable_child (GTK_CONTAINER (child));
+ if (retval)
+ break;
+ }
+ }
+ g_list_free (list);
+ return retval;
+}
+
+static void
+panel_applet_position_menu (GtkMenu *menu,
+ int *x,
+ int *y,
+ gboolean *push_in,
+ GtkWidget *widget)
+{
+ PanelApplet *applet;
+ GtkRequisition requisition;
+ GdkScreen *screen;
+ int menu_x = 0;
+ int menu_y = 0;
+ int pointer_x;
+ int pointer_y;
+
+ g_return_if_fail (PANEL_IS_APPLET (widget));
+
+ applet = PANEL_APPLET (widget);
+
+ screen = gtk_widget_get_screen (widget);
+
+ gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
+
+ gdk_window_get_origin (widget->window, &menu_x, &menu_y);
+ gtk_widget_get_pointer (widget, &pointer_x, &pointer_y);
+
+ menu_x += widget->allocation.x;
+ menu_y += widget->allocation.y;
+
+ if (applet->priv->orient == PANEL_APPLET_ORIENT_UP ||
+ applet->priv->orient == PANEL_APPLET_ORIENT_DOWN) {
+ if (gtk_widget_get_direction (GTK_WIDGET (menu)) != GTK_TEXT_DIR_RTL) {
+ if (pointer_x < widget->allocation.width &&
+ requisition.width < pointer_x)
+ menu_x += MIN (pointer_x,
+ widget->allocation.width - requisition.width);
+ } else {
+ menu_x += widget->allocation.width - requisition.width;
+ if (pointer_x > 0 && pointer_x < widget->allocation.width &&
+ pointer_x < widget->allocation.width - requisition.width) {
+ menu_x -= MIN (widget->allocation.width - pointer_x,
+ widget->allocation.width - requisition.width);
+ }
+ }
+ menu_x = MIN (menu_x, gdk_screen_get_width (screen) - requisition.width);
+
+ if (menu_y > gdk_screen_get_height (screen) / 2)
+ menu_y -= requisition.height;
+ else
+ menu_y += widget->allocation.height;
+ } else {
+ if (pointer_y < widget->allocation.height &&
+ requisition.height < pointer_y)
+ menu_y += MIN (pointer_y, widget->allocation.height - requisition.height);
+ menu_y = MIN (menu_y, gdk_screen_get_height (screen) - requisition.height);
+
+ if (menu_x > gdk_screen_get_width (screen) / 2)
+ menu_x -= requisition.width;
+ else
+ menu_x += widget->allocation.width;
+
+ }
+
+ *x = menu_x;
+ *y = menu_y;
+ *push_in = TRUE;
+}
+
+static gboolean
+panel_applet_can_focus (GtkWidget *widget)
+{
+ /*
+ * A PanelApplet widget can focus if it has a tooltip or it does
+ * not have any focusable children.
+ */
+ if (gtk_widget_get_has_tooltip (widget))
+ return TRUE;
+
+ if (!PANEL_IS_APPLET (widget))
+ return FALSE;
+
+ return !container_has_focusable_child (GTK_CONTAINER (widget));
+}
+
+static gboolean
+panel_applet_button_press (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ PanelApplet *applet = PANEL_APPLET (widget);
+
+ if (!container_has_focusable_child (GTK_CONTAINER (applet))) {
+ if (!gtk_widget_has_focus (widget)) {
+ GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
+ gtk_widget_grab_focus (widget);
+ }
+ }
+
+ if (event->button == 1)
+ return TRUE;
+ else if (event->button == 3) {
+ bonobo_control_do_popup_full (
+ applet->priv->control,
+ NULL, NULL,
+ (GtkMenuPositionFunc) panel_applet_position_menu,
+ applet,
+ event->button,
+ event->time);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+gboolean
+_panel_applet_popup_menu (PanelApplet *applet,
+ guint button,
+ guint32 time)
+{
+ bonobo_control_do_popup_full (applet->priv->control, NULL, NULL,
+ (GtkMenuPositionFunc) panel_applet_position_menu,
+ applet, button, time);
+ return TRUE;
+}
+
+static gboolean
+panel_applet_popup_menu (PanelApplet *applet)
+{
+ return _panel_applet_popup_menu (applet, 3, GDK_CURRENT_TIME);
+}
+
+static void
+panel_applet_size_request (GtkWidget *widget, GtkRequisition *requisition)
+{
+ int focus_width = 0;
+
+ GTK_WIDGET_CLASS (panel_applet_parent_class)->size_request (widget,
+ requisition);
+
+ if (!panel_applet_can_focus (widget))
+ return;
+
+ /*
+ * We are deliberately ignoring focus-padding here to
+ * save valuable panel real estate.
+ */
+ gtk_widget_style_get (widget,
+ "focus-line-width", &focus_width,
+ NULL);
+
+ requisition->width += 2 * focus_width;
+ requisition->height += 2 * focus_width;
+}
+
+static void
+panel_applet_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ GtkAllocation child_allocation;
+ GtkBin *bin;
+ int border_width;
+ int focus_width = 0;
+ PanelApplet *applet;
+
+ if (!panel_applet_can_focus (widget)) {
+ GTK_WIDGET_CLASS (panel_applet_parent_class)->size_allocate (widget, allocation);
+ } else {
+ /*
+ * We are deliberately ignoring focus-padding here to
+ * save valuable panel real estate.
+ */
+ gtk_widget_style_get (widget,
+ "focus-line-width", &focus_width,
+ NULL);
+
+ border_width = GTK_CONTAINER (widget)->border_width;
+
+ widget->allocation = *allocation;
+ bin = GTK_BIN (widget);
+
+ child_allocation.x = focus_width;
+ child_allocation.y = focus_width;
+
+ child_allocation.width = MAX (allocation->width - border_width * 2, 0);
+ child_allocation.height = MAX (allocation->height - border_width * 2, 0);
+
+ if (gtk_widget_get_realized (widget))
+ gdk_window_move_resize (widget->window,
+ allocation->x + GTK_CONTAINER (widget)->border_width,
+ allocation->y + GTK_CONTAINER (widget)->border_width,
+ child_allocation.width,
+ child_allocation.height);
+
+ child_allocation.width = MAX (child_allocation.width - 2 * focus_width, 0);
+ child_allocation.height = MAX (child_allocation.height - 2 * focus_width, 0);
+
+ if (bin->child)
+ gtk_widget_size_allocate (bin->child, &child_allocation);
+ }
+
+ applet = PANEL_APPLET (widget);
+
+ if (applet->priv->previous_height != allocation->height ||
+ applet->priv->previous_width != allocation->width) {
+ applet->priv->previous_height = allocation->height;
+ applet->priv->previous_width = allocation->width;
+
+ panel_applet_handle_background (applet);
+ }
+}
+
+static gboolean
+panel_applet_expose (GtkWidget *widget,
+ GdkEventExpose *event)
+{
+ int border_width;
+ int focus_width = 0;
+ int x, y, width, height;
+
+ g_return_val_if_fail (PANEL_IS_APPLET (widget), FALSE);
+ g_return_val_if_fail (event != NULL, FALSE);
+
+ GTK_WIDGET_CLASS (panel_applet_parent_class)->expose_event (widget,
+ event);
+
+ if (!gtk_widget_has_focus (widget))
+ return FALSE;
+
+ /*
+ * We are deliberately ignoring focus-padding here to
+ * save valuable panel real estate.
+ */
+ gtk_widget_style_get (widget,
+ "focus-line-width", &focus_width,
+ NULL);
+
+ border_width = GTK_CONTAINER (widget)->border_width;
+
+ x = widget->allocation.x;
+ y = widget->allocation.y;
+
+ width = widget->allocation.width - 2 * border_width;
+ height = widget->allocation.height - 2 * border_width;
+
+ gtk_paint_focus (widget->style, widget->window,
+ GTK_WIDGET_STATE (widget),
+ &event->area, widget, "panel_applet",
+ x, y, width, height);
+
+ return FALSE;
+}
+
+static gboolean
+panel_applet_focus (GtkWidget *widget,
+ GtkDirectionType dir)
+{
+ gboolean ret;
+ GtkWidget *previous_focus_child;
+ PanelApplet *applet;
+
+ g_return_val_if_fail (PANEL_IS_APPLET (widget), FALSE);
+
+ applet = PANEL_APPLET (widget);
+ if (applet->priv->moving_focus_out) {
+ /*
+ * Applet will retain focus if there is nothing else on the
+ * panel to get focus
+ */
+ applet->priv->moving_focus_out = FALSE;
+ return FALSE;
+ }
+
+ previous_focus_child = GTK_CONTAINER (widget)->focus_child;
+ if (!previous_focus_child && !gtk_widget_has_focus (widget)) {
+ if (gtk_widget_get_has_tooltip (widget)) {
+ GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
+ gtk_widget_grab_focus (widget);
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
+ return TRUE;
+ }
+ }
+ ret = GTK_WIDGET_CLASS (panel_applet_parent_class)->focus (widget, dir);
+
+ if (!ret && !previous_focus_child) {
+ if (!gtk_widget_has_focus (widget)) {
+ /*
+ * Applet does not have a widget which can focus so set
+ * the focus on the applet unless it already had focus
+ * because it had a tooltip.
+ */
+ GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
+ gtk_widget_grab_focus (widget);
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
+ ret = TRUE;
+ }
+ }
+
+ return ret;
+}
+
+static gboolean
+panel_applet_parse_color (const gchar *color_str,
+ GdkColor *color)
+{
+ int r, g, b;
+
+ g_assert (color_str && color);
+
+ if (sscanf (color_str, "%4x%4x%4x", &r, &g, &b) != 3)
+ return FALSE;
+
+ color->red = r;
+ color->green = g;
+ color->blue = b;
+
+ return TRUE;
+}
+
+static gboolean
+panel_applet_parse_pixmap_str (const char *str,
+ GdkNativeWindow *xid,
+ int *x,
+ int *y)
+{
+ char **elements;
+ char *tmp;
+
+ g_return_val_if_fail (str != NULL, FALSE);
+ g_return_val_if_fail (xid != NULL, FALSE);
+ g_return_val_if_fail (x != NULL, FALSE);
+ g_return_val_if_fail (y != NULL, FALSE);
+
+ elements = g_strsplit (str, ",", -1);
+
+ if (!elements)
+ return FALSE;
+
+ if (!elements [0] || !*elements [0] ||
+ !elements [1] || !*elements [1] ||
+ !elements [2] || !*elements [2])
+ goto ERROR_AND_FREE;
+
+ *xid = strtol (elements [0], &tmp, 10);
+ if (tmp == elements [0])
+ goto ERROR_AND_FREE;
+
+ *x = strtol (elements [1], &tmp, 10);
+ if (tmp == elements [1])
+ goto ERROR_AND_FREE;
+
+ *y = strtol (elements [2], &tmp, 10);
+ if (tmp == elements [2])
+ goto ERROR_AND_FREE;
+
+ g_strfreev (elements);
+ return TRUE;
+
+ ERROR_AND_FREE:
+ g_strfreev (elements);
+ return FALSE;
+}
+
+static GdkPixmap *
+panel_applet_get_pixmap (PanelApplet *applet,
+ GdkNativeWindow xid,
+ int x,
+ int y)
+{
+ gboolean display_grabbed;
+ GdkPixmap *pixmap;
+ GdkDisplay *display;
+ GdkPixmap *retval;
+ int width;
+ int height;
+ cairo_t *cr;
+ cairo_pattern_t *pattern;
+
+ g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
+
+ if (!gtk_widget_get_realized (GTK_WIDGET (applet)))
+ return NULL;
+
+ display = gdk_display_get_default ();
+ display_grabbed = FALSE;
+
+ pixmap = gdk_pixmap_lookup_for_display (display, xid);
+ if (pixmap)
+ g_object_ref (pixmap);
+ else {
+ display_grabbed = TRUE;
+ gdk_x11_display_grab (display);
+ pixmap = gdk_pixmap_foreign_new_for_display (display, xid);
+ }
+
+ /* This can happen if the user changes the background very fast.
+ * We'll get the next update, so it's not a big deal. */
+ if (pixmap == NULL) {
+ if (display_grabbed)
+ gdk_x11_display_ungrab (display);
+ return NULL;
+ }
+
+ gdk_drawable_get_size (GDK_DRAWABLE (GTK_WIDGET (applet)->window),
+ &width, &height);
+ retval = gdk_pixmap_new (GTK_WIDGET (applet)->window,
+ width, height, -1);
+
+ /* the pixmap has no colormap, and we need one */
+ gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap),
+ gdk_drawable_get_colormap (GTK_WIDGET (applet)->window));
+
+ cr = gdk_cairo_create (GDK_DRAWABLE (retval));
+ gdk_cairo_set_source_pixmap (cr, pixmap, -x, -y);
+ pattern = cairo_get_source (cr);
+ cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
+
+ cairo_rectangle (cr, 0, 0, width, height);
+ cairo_fill (cr);
+
+ cairo_destroy (cr);
+
+ g_object_unref (pixmap);
+
+ if (display_grabbed)
+ gdk_x11_display_ungrab (display);
+
+ return retval;
+}
+
+static PanelAppletBackgroundType
+panel_applet_handle_background_string (PanelApplet *applet,
+ GdkColor *color,
+ GdkPixmap **pixmap)
+{
+ PanelAppletBackgroundType retval;
+ char **elements;
+
+ retval = PANEL_NO_BACKGROUND;
+
+ if (!gtk_widget_get_realized (GTK_WIDGET (applet)) || !applet->priv->background)
+ return retval;
+
+ elements = g_strsplit (applet->priv->background, ":", -1);
+
+ if (elements [0] && !strcmp (elements [0], "none" )) {
+ retval = PANEL_NO_BACKGROUND;
+
+ } else if (elements [0] && !strcmp (elements [0], "color")) {
+ g_return_val_if_fail (color != NULL, PANEL_NO_BACKGROUND);
+
+ if (!elements [1] || !panel_applet_parse_color (elements [1], color)) {
+
+ g_warning ("Incomplete '%s' background type received", elements [0]);
+ g_strfreev (elements);
+ return PANEL_NO_BACKGROUND;
+ }
+
+ retval = PANEL_COLOR_BACKGROUND;
+
+ } else if (elements [0] && !strcmp (elements [0], "pixmap")) {
+ GdkNativeWindow pixmap_id;
+ int x, y;
+
+ g_return_val_if_fail (pixmap != NULL, PANEL_NO_BACKGROUND);
+
+ if (!panel_applet_parse_pixmap_str (elements [1], &pixmap_id, &x, &y)) {
+ g_warning ("Incomplete '%s' background type received: %s",
+ elements [0], elements [1]);
+
+ g_strfreev (elements);
+ return PANEL_NO_BACKGROUND;
+ }
+
+ *pixmap = panel_applet_get_pixmap (applet, pixmap_id, x, y);
+ if (!*pixmap) {
+ g_warning ("Failed to get pixmap %s", elements [1]);
+ g_strfreev (elements);
+ return PANEL_NO_BACKGROUND;
+ }
+
+ retval = PANEL_PIXMAP_BACKGROUND;
+ } else
+ g_warning ("Unknown background type received");
+
+ g_strfreev (elements);
+
+ return retval;
+}
+
+PanelAppletBackgroundType
+panel_applet_get_background (PanelApplet *applet,
+ GdkColor *color,
+ GdkPixmap **pixmap)
+{
+ g_return_val_if_fail (PANEL_IS_APPLET (applet), PANEL_NO_BACKGROUND);
+
+ /* initial sanity */
+ if (pixmap != NULL)
+ *pixmap = NULL;
+ if (color != NULL)
+ memset (color, 0, sizeof (GdkColor));
+
+ return panel_applet_handle_background_string (applet, color, pixmap);
+}
+
+static void
+panel_applet_get_prop (BonoboPropertyBag *sack,
+ BonoboArg *arg,
+ guint arg_id,
+ CORBA_Environment *ev,
+ gpointer user_data)
+{
+ PanelApplet *applet = PANEL_APPLET (user_data);
+
+ switch (arg_id) {
+ case PROPERTY_ORIENT_IDX:
+ BONOBO_ARG_SET_SHORT (arg, applet->priv->orient);
+ break;
+ case PROPERTY_SIZE_IDX:
+ BONOBO_ARG_SET_SHORT (arg, applet->priv->size);
+ break;
+ case PROPERTY_BACKGROUND_IDX:
+ BONOBO_ARG_SET_STRING (arg, applet->priv->background);
+ break;
+ case PROPERTY_FLAGS_IDX:
+ BONOBO_ARG_SET_SHORT (arg, applet->priv->flags);
+ break;
+ case PROPERTY_SIZE_HINTS_IDX: {
+ CORBA_sequence_CORBA_long *seq;
+ int i;
+
+ seq = arg->_value;
+
+ seq->_length = seq->_maximum = applet->priv->size_hints_len;
+ seq->_buffer = CORBA_sequence_CORBA_long_allocbuf (seq->_length);
+ seq->_release = CORBA_TRUE;
+
+ for (i = 0; i < applet->priv->size_hints_len; i++)
+ seq->_buffer [i] = applet->priv->size_hints [i];
+ }
+ break;
+ case PROPERTY_LOCKED_DOWN_IDX:
+ BONOBO_ARG_SET_BOOLEAN (arg, applet->priv->locked_down);
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
+
+static void
+panel_applet_update_background_for_widget (GtkWidget *widget,
+ PanelAppletBackgroundType type,
+ GdkColor *color,
+ GdkPixmap *pixmap)
+{
+ GtkRcStyle *rc_style;
+ GtkStyle *style;
+
+ /* reset style */
+ gtk_widget_set_style (widget, NULL);
+ rc_style = gtk_rc_style_new ();
+ gtk_widget_modify_style (widget, rc_style);
+ g_object_unref (rc_style);
+
+ switch (type) {
+ case PANEL_NO_BACKGROUND:
+ break;
+ case PANEL_COLOR_BACKGROUND:
+ gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, color);
+ break;
+ case PANEL_PIXMAP_BACKGROUND:
+ style = gtk_style_copy (widget->style);
+ if (style->bg_pixmap[GTK_STATE_NORMAL])
+ g_object_unref (style->bg_pixmap[GTK_STATE_NORMAL]);
+ style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref (pixmap);
+ gtk_widget_set_style (widget, style);
+ g_object_unref (style);
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
+
+static void
+panel_applet_handle_background (PanelApplet *applet)
+{
+ PanelAppletBackgroundType type;
+ GdkColor color;
+ GdkPixmap *pixmap;
+
+ type = panel_applet_get_background (applet, &color, &pixmap);
+
+ if (applet->priv->background_widget)
+ panel_applet_update_background_for_widget (applet->priv->background_widget,
+ type, &color, pixmap);
+
+ switch (type) {
+ case PANEL_NO_BACKGROUND:
+ g_signal_emit (G_OBJECT (applet),
+ panel_applet_signals [CHANGE_BACKGROUND],
+ 0, PANEL_NO_BACKGROUND, NULL, NULL);
+ break;
+ case PANEL_COLOR_BACKGROUND:
+ g_signal_emit (G_OBJECT (applet),
+ panel_applet_signals [CHANGE_BACKGROUND],
+ 0, PANEL_COLOR_BACKGROUND, &color, NULL);
+ break;
+ case PANEL_PIXMAP_BACKGROUND:
+ g_signal_emit (G_OBJECT (applet),
+ panel_applet_signals [CHANGE_BACKGROUND],
+ 0, PANEL_PIXMAP_BACKGROUND, NULL, pixmap);
+
+ g_object_unref (pixmap);
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
+
+static void
+panel_applet_set_prop (BonoboPropertyBag *sack,
+ const BonoboArg *arg,
+ guint arg_id,
+ CORBA_Environment *ev,
+ gpointer user_data)
+{
+ PanelApplet *applet = PANEL_APPLET (user_data);
+
+ switch (arg_id) {
+ case PROPERTY_ORIENT_IDX: {
+ PanelAppletOrient orient;
+
+ orient = BONOBO_ARG_GET_SHORT (arg);
+
+ if (applet->priv->orient != orient) {
+ applet->priv->orient = orient;
+
+ g_signal_emit (G_OBJECT (applet),
+ panel_applet_signals [CHANGE_ORIENT],
+ 0, orient);
+ }
+ }
+ break;
+ case PROPERTY_SIZE_IDX: {
+ guint size;
+
+ size = BONOBO_ARG_GET_SHORT (arg);
+
+ if (applet->priv->size != size) {
+ applet->priv->size = size;
+
+ g_signal_emit (G_OBJECT (applet),
+ panel_applet_signals [CHANGE_SIZE],
+ 0, size);
+ }
+ }
+ break;
+ case PROPERTY_BACKGROUND_IDX:
+ if (applet->priv->background)
+ g_free (applet->priv->background);
+
+ applet->priv->background = g_strdup (BONOBO_ARG_GET_STRING (arg));
+
+ panel_applet_handle_background (applet);
+ break;
+ case PROPERTY_FLAGS_IDX:
+ applet->priv->flags = BONOBO_ARG_GET_SHORT (arg);
+ break;
+ case PROPERTY_SIZE_HINTS_IDX: {
+ CORBA_sequence_CORBA_long *seq = arg->_value;
+ int i;
+
+ applet->priv->size_hints = g_realloc (applet->priv->size_hints,
+ seq->_length * sizeof (int));
+ for (i = 0; i < seq->_length; i++)
+ applet->priv->size_hints [i] = seq->_buffer [i];
+
+ applet->priv->size_hints_len = seq->_length;;
+ }
+ break;
+ case PROPERTY_LOCKED_DOWN_IDX:
+ applet->priv->locked_down = BONOBO_ARG_GET_BOOLEAN (arg);
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
+
+static BonoboPropertyBag *
+panel_applet_property_bag (PanelApplet *applet)
+{
+ BonoboPropertyBag *sack;
+
+ sack = bonobo_property_bag_new (panel_applet_get_prop,
+ panel_applet_set_prop,
+ applet);
+
+ bonobo_property_bag_add (sack,
+ PROPERTY_ORIENT,
+ PROPERTY_ORIENT_IDX,
+ BONOBO_ARG_SHORT,
+ NULL,
+ "The Applet's containing Panel's orientation",
+ Bonobo_PROPERTY_READABLE | Bonobo_PROPERTY_WRITEABLE);
+
+ bonobo_property_bag_add (sack,
+ PROPERTY_SIZE,
+ PROPERTY_SIZE_IDX,
+ BONOBO_ARG_SHORT,
+ NULL,
+ "The Applet's containing Panel's size in pixels",
+ Bonobo_PROPERTY_READABLE | Bonobo_PROPERTY_WRITEABLE);
+
+ bonobo_property_bag_add (sack,
+ PROPERTY_BACKGROUND,
+ PROPERTY_BACKGROUND_IDX,
+ BONOBO_ARG_STRING,
+ NULL,
+ "The Applet's containing Panel's background color or pixmap",
+ Bonobo_PROPERTY_READABLE | Bonobo_PROPERTY_WRITEABLE);
+
+ bonobo_property_bag_add (sack,
+ PROPERTY_FLAGS,
+ PROPERTY_FLAGS_IDX,
+ BONOBO_ARG_SHORT,
+ NULL,
+ "The Applet's flags",
+ Bonobo_PROPERTY_READABLE);
+
+ bonobo_property_bag_add (sack,
+ PROPERTY_SIZE_HINTS,
+ PROPERTY_SIZE_HINTS_IDX,
+ TC_CORBA_sequence_CORBA_long,
+ NULL,
+ "Ranges that hint what sizes are acceptable for the applet",
+ Bonobo_PROPERTY_READABLE);
+
+ bonobo_property_bag_add (sack,
+ PROPERTY_LOCKED_DOWN,
+ PROPERTY_LOCKED_DOWN_IDX,
+ BONOBO_ARG_BOOLEAN,
+ NULL,
+ "The Applet's containing Panel is locked down",
+ Bonobo_PROPERTY_READABLE | Bonobo_PROPERTY_WRITEABLE);
+
+ return sack;
+}
+
+static void
+panel_applet_realize (GtkWidget *widget)
+{
+ GTK_WIDGET_CLASS (panel_applet_parent_class)->realize (widget);
+
+ if (PANEL_APPLET (widget)->priv->background)
+ panel_applet_handle_background (PANEL_APPLET (widget));
+}
+
+static void
+panel_applet_control_bound (BonoboControl *control,
+ PanelApplet *applet)
+{
+ gboolean ret;
+
+ g_return_if_fail (PANEL_IS_APPLET (applet));
+ g_return_if_fail (applet->priv->iid != NULL &&
+ applet->priv->closure != NULL);
+
+ if (applet->priv->bound)
+ return;
+
+ bonobo_closure_invoke (applet->priv->closure,
+ G_TYPE_BOOLEAN, &ret,
+ PANEL_TYPE_APPLET, applet,
+ G_TYPE_STRING, applet->priv->iid,
+ NULL);
+
+
+ if (!ret) { /* FIXME */
+ g_warning ("need to free the control here");
+
+ return;
+ }
+
+ applet->priv->bound = TRUE;
+}
+
+static Bonobo_Unknown
+panel_applet_item_handler_get_object (BonoboItemHandler *handler,
+ const char *item_name,
+ gboolean only_if_exists,
+ gpointer user_data,
+ CORBA_Environment *ev)
+{
+ PanelApplet *applet = user_data;
+ GSList *options;
+ GSList *l;
+
+ g_return_val_if_fail (PANEL_IS_APPLET (applet), CORBA_OBJECT_NIL);
+
+ options = bonobo_item_option_parse (item_name);
+
+ for (l = options; l; l = l->next) {
+ BonoboItemOption *option = l->data;
+
+ if (!option->value || !option->value [0])
+ continue;
+
+ if (!strcmp (option->key, "prefs_key") && !applet->priv->prefs_key)
+ panel_applet_set_preferences_key (applet, option->value);
+
+ else if (!strcmp (option->key, "background"))
+ bonobo_pbclient_set_string (BONOBO_OBJREF (applet->priv->prop_sack),
+ PROPERTY_BACKGROUND, option->value, NULL);
+
+ else if (!strcmp (option->key, "orient")) {
+ if (!strcmp (option->value, "up"))
+ bonobo_pbclient_set_short (
+ BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_ORIENT,
+ PANEL_APPLET_ORIENT_UP, NULL);
+
+ else if (!strcmp (option->value, "down"))
+ bonobo_pbclient_set_short (
+ BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_ORIENT,
+ PANEL_APPLET_ORIENT_DOWN, NULL);
+
+ else if (!strcmp (option->value, "left"))
+ bonobo_pbclient_set_short (
+ BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_ORIENT,
+ PANEL_APPLET_ORIENT_LEFT, NULL);
+
+ else if (!strcmp (option->value, "right"))
+ bonobo_pbclient_set_short (
+ BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_ORIENT,
+ PANEL_APPLET_ORIENT_RIGHT, NULL);
+
+ } else if (!strcmp (option->key, "size")) {
+ if (!strcmp (option->value, "xx-small"))
+ bonobo_pbclient_set_short (
+ BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE,
+ GNOME_Vertigo_PANEL_XX_SMALL, NULL);
+
+ else if (!strcmp (option->value, "x-small"))
+ bonobo_pbclient_set_short (
+ BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE,
+ GNOME_Vertigo_PANEL_X_SMALL, NULL);
+
+ else if (!strcmp (option->value, "small"))
+ bonobo_pbclient_set_short (
+ BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE,
+ GNOME_Vertigo_PANEL_SMALL, NULL);
+
+ else if (!strcmp (option->value, "medium"))
+ bonobo_pbclient_set_short (
+ BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE,
+ GNOME_Vertigo_PANEL_MEDIUM, NULL);
+
+ else if (!strcmp (option->value, "large"))
+ bonobo_pbclient_set_short (
+ BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE,
+ GNOME_Vertigo_PANEL_LARGE, NULL);
+
+ else if (!strcmp (option->value, "x-large"))
+ bonobo_pbclient_set_short (
+ BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE,
+ GNOME_Vertigo_PANEL_X_LARGE, NULL);
+
+ else if (!strcmp (option->value, "xx-large"))
+ bonobo_pbclient_set_short (
+ BONOBO_OBJREF (applet->priv->prop_sack), PROPERTY_SIZE,
+ GNOME_Vertigo_PANEL_XX_LARGE, NULL);
+ } else if (!strcmp (option->key, "locked_down")) {
+ gboolean val = FALSE;
+ if (option->value[0] == 'T' ||
+ option->value[0] == 't' ||
+ option->value[0] == 'Y' ||
+ option->value[0] == 'y' ||
+ atoi (option->value) != 0)
+ val = TRUE;
+ bonobo_pbclient_set_boolean (BONOBO_OBJREF (applet->priv->prop_sack),
+ PROPERTY_LOCKED_DOWN, val, NULL);
+ }
+ }
+
+ bonobo_item_options_free (options);
+
+ return bonobo_object_dup_ref (BONOBO_OBJREF (applet->priv->control), ev);
+}
+
+static void
+panel_applet_move_focus_out_of_applet (PanelApplet *applet,
+ GtkDirectionType dir)
+{
+ GtkWidget *toplevel;
+
+ applet->priv->moving_focus_out = TRUE;
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (applet));
+ g_return_if_fail (toplevel);
+
+ gtk_widget_child_focus (toplevel, dir);
+ applet->priv->moving_focus_out = FALSE;
+}
+
+static void
+add_tab_bindings (GtkBindingSet *binding_set,
+ GdkModifierType modifiers,
+ GtkDirectionType direction)
+{
+ gtk_binding_entry_add_signal (binding_set, GDK_Tab, modifiers,
+ "move_focus_out_of_applet", 1,
+ GTK_TYPE_DIRECTION_TYPE, direction);
+ gtk_binding_entry_add_signal (binding_set, GDK_KP_Tab, modifiers,
+ "move_focus_out_of_applet", 1,
+ GTK_TYPE_DIRECTION_TYPE, direction);
+}
+
+static GObject *
+panel_applet_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_properties)
+{
+ GObject *obj;
+ PanelApplet *applet;
+
+ obj = G_OBJECT_CLASS (panel_applet_parent_class)->constructor (type,
+ n_construct_properties,
+ construct_properties);
+
+ applet = PANEL_APPLET (obj);
+
+ panel_applet_setup (applet);
+
+ return obj;
+}
+
+static void
+panel_applet_class_init (PanelAppletClass *klass)
+{
+ GObjectClass *gobject_class = (GObjectClass *) klass;
+ GtkObjectClass *object_class = (GtkObjectClass *) klass;
+ GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
+ GtkBindingSet *binding_set;
+
+ gobject_class->constructor = panel_applet_constructor;
+ klass->move_focus_out_of_applet = panel_applet_move_focus_out_of_applet;
+
+ widget_class->button_press_event = panel_applet_button_press;
+ widget_class->size_request = panel_applet_size_request;
+ widget_class->size_allocate = panel_applet_size_allocate;
+ widget_class->expose_event = panel_applet_expose;
+ widget_class->focus = panel_applet_focus;
+ widget_class->realize = panel_applet_realize;
+
+ gobject_class->finalize = panel_applet_finalize;
+
+ g_type_class_add_private (klass, sizeof (PanelAppletPrivate));
+
+ panel_applet_signals [CHANGE_ORIENT] =
+ g_signal_new ("change_orient",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PanelAppletClass, change_orient),
+ NULL,
+ NULL,
+ panel_applet_marshal_VOID__UINT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_UINT);
+
+ panel_applet_signals [CHANGE_SIZE] =
+ g_signal_new ("change_size",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PanelAppletClass, change_size),
+ NULL,
+ NULL,
+ panel_applet_marshal_VOID__INT,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_INT);
+
+ panel_applet_signals [CHANGE_BACKGROUND] =
+ g_signal_new ("change_background",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PanelAppletClass, change_background),
+ NULL,
+ NULL,
+ panel_applet_marshal_VOID__ENUM_BOXED_OBJECT,
+ G_TYPE_NONE,
+ 3,
+ PANEL_TYPE_PANEL_APPLET_BACKGROUND_TYPE,
+ GDK_TYPE_COLOR,
+ GDK_TYPE_PIXMAP);
+
+ panel_applet_signals [MOVE_FOCUS_OUT_OF_APPLET] =
+ g_signal_new ("move_focus_out_of_applet",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (PanelAppletClass, move_focus_out_of_applet),
+ NULL,
+ NULL,
+ panel_applet_marshal_VOID__ENUM,
+ G_TYPE_NONE,
+ 1,
+ GTK_TYPE_DIRECTION_TYPE);
+
+ binding_set = gtk_binding_set_by_class (object_class);
+ add_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD);
+ add_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
+ add_tab_bindings (binding_set, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD);
+ add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD);
+}
+
+static void
+panel_applet_init (PanelApplet *applet)
+{
+ applet->priv = PANEL_APPLET_GET_PRIVATE (applet);
+
+ applet->priv->client = gconf_client_get_default ();
+
+ applet->priv->bound = FALSE;
+ applet->priv->flags = PANEL_APPLET_FLAGS_NONE;
+ applet->priv->orient = PANEL_APPLET_ORIENT_UP;
+ applet->priv->size = GNOME_Vertigo_PANEL_MEDIUM;
+
+ applet->priv->moving_focus_out = FALSE;
+
+ gtk_widget_set_events (GTK_WIDGET (applet),
+ GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
+}
+
+static void
+panel_applet_setup (PanelApplet *applet)
+{
+ PanelAppletPrivate *priv;
+
+ priv = applet->priv;
+
+ priv->control = bonobo_control_new (GTK_WIDGET (applet));
+
+ g_signal_connect (priv->control, "set_frame",
+ G_CALLBACK (panel_applet_control_bound),
+ applet);
+
+ priv->prop_sack = panel_applet_property_bag (applet);
+
+ bonobo_control_set_properties (
+ priv->control, BONOBO_OBJREF (priv->prop_sack), NULL);
+
+ priv->shell = panel_applet_shell_new (applet);
+
+ bonobo_object_add_interface (BONOBO_OBJECT (priv->control),
+ BONOBO_OBJECT (priv->shell));
+
+ priv->item_handler =
+ bonobo_item_handler_new (
+ NULL, panel_applet_item_handler_get_object, applet);
+
+ bonobo_object_add_interface (BONOBO_OBJECT (priv->control),
+ BONOBO_OBJECT (priv->item_handler));
+
+ g_signal_connect (applet, "popup_menu",
+ G_CALLBACK (panel_applet_popup_menu), NULL);
+}
+
+GtkWidget *
+panel_applet_new (void)
+{
+ PanelApplet *applet;
+
+ applet = g_object_new (PANEL_TYPE_APPLET, NULL);
+
+ return GTK_WIDGET (applet);
+}
+
+typedef struct {
+ GType applet_type;
+ GClosure *closure;
+} PanelAppletCallBackData;
+
+static PanelAppletCallBackData *
+panel_applet_callback_data_new (GType applet_type,
+ GClosure *closure)
+{
+ PanelAppletCallBackData *retval;
+
+ retval = g_new0 (PanelAppletCallBackData, 1);
+
+ retval->applet_type = applet_type;
+ retval->closure = closure;
+
+ return retval;
+}
+
+static void
+panel_applet_callback_data_free (PanelAppletCallBackData *data)
+{
+ g_closure_unref (data->closure);
+ g_free (data);
+}
+
+static BonoboObject *
+panel_applet_factory_callback (BonoboGenericFactory *factory,
+ const char *iid,
+ PanelAppletCallBackData *data)
+{
+ PanelApplet *applet;
+
+ applet = g_object_new (data->applet_type, NULL);
+
+ applet->priv->iid = g_strdup (iid);
+ applet->priv->closure = g_closure_ref (data->closure);
+
+ bonobo_control_life_instrument (applet->priv->control);
+
+ return BONOBO_OBJECT (applet->priv->control);
+}
+
+static void
+panel_applet_all_controls_dead (void)
+{
+ if (!bonobo_control_life_get_count())
+ bonobo_main_quit ();
+}
+
+int
+panel_applet_factory_main_closure (const gchar *iid,
+ GType applet_type,
+ GClosure *closure)
+{
+ int retval;
+ char *display_iid;
+ PanelAppletCallBackData *data;
+
+ g_return_val_if_fail (iid != NULL, 1);
+ g_return_val_if_fail (closure != NULL, 1);
+
+ g_assert (g_type_is_a (applet_type, PANEL_TYPE_APPLET));
+
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+
+ bonobo_control_life_set_callback (panel_applet_all_controls_dead);
+
+ closure = bonobo_closure_store (closure, panel_applet_marshal_BOOLEAN__STRING);
+
+ data = panel_applet_callback_data_new (applet_type, closure);
+
+ display_iid = bonobo_activation_make_registration_id (
+ iid, DisplayString (gdk_display));
+ retval = bonobo_generic_factory_main (
+ display_iid,
+ (BonoboFactoryCallback) panel_applet_factory_callback,
+ data);
+ g_free (display_iid);
+
+ panel_applet_callback_data_free (data);
+
+ return retval;
+}
+
+int
+panel_applet_factory_main (const gchar *iid,
+ GType applet_type,
+ PanelAppletFactoryCallback callback,
+ gpointer data)
+{
+ GClosure *closure;
+
+ g_return_val_if_fail (iid != NULL, 1);
+ g_return_val_if_fail (callback != NULL, 1);
+
+ closure = g_cclosure_new (G_CALLBACK (callback), data, NULL);
+
+ return panel_applet_factory_main_closure (iid, applet_type, closure);
+}
+
+Bonobo_Unknown
+panel_applet_shlib_factory_closure (const char *iid,
+ GType applet_type,
+ PortableServer_POA poa,
+ gpointer impl_ptr,
+ GClosure *closure,
+ CORBA_Environment *ev)
+{
+ BonoboShlibFactory *factory;
+
+ g_return_val_if_fail (iid != NULL, CORBA_OBJECT_NIL);
+ g_return_val_if_fail (closure != NULL, CORBA_OBJECT_NIL);
+
+ g_assert (g_type_is_a (applet_type, PANEL_TYPE_APPLET));
+
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+
+ closure = bonobo_closure_store (closure, panel_applet_marshal_BOOLEAN__STRING);
+
+ factory = bonobo_shlib_factory_new_closure (
+ iid, poa, impl_ptr,
+ g_cclosure_new (G_CALLBACK (panel_applet_factory_callback),
+ panel_applet_callback_data_new (applet_type, closure),
+ (GClosureNotify) panel_applet_callback_data_free));
+
+ return CORBA_Object_duplicate (BONOBO_OBJREF (factory), ev);
+}
+
+Bonobo_Unknown
+panel_applet_shlib_factory (const char *iid,
+ GType applet_type,
+ PortableServer_POA poa,
+ gpointer impl_ptr,
+ PanelAppletFactoryCallback callback,
+ gpointer user_data,
+ CORBA_Environment *ev)
+{
+ g_return_val_if_fail (iid != NULL, CORBA_OBJECT_NIL);
+ g_return_val_if_fail (callback != NULL, CORBA_OBJECT_NIL);
+
+ return panel_applet_shlib_factory_closure (
+ iid, applet_type, poa, impl_ptr,
+ g_cclosure_new (G_CALLBACK (callback),
+ user_data, NULL),
+ ev);
+}
+
+void
+panel_applet_set_background_widget (PanelApplet *applet,
+ GtkWidget *widget)
+{
+ applet->priv->background_widget = widget;
+
+ if (widget) {
+ PanelAppletBackgroundType type;
+ GdkColor color;
+ GdkPixmap *pixmap;
+
+ type = panel_applet_get_background (applet, &color, &pixmap);
+ panel_applet_update_background_for_widget (widget, type,
+ &color, pixmap);
+ if (type == PANEL_PIXMAP_BACKGROUND)
+ g_object_unref (pixmap);
+ }
+}
diff --git a/bonobo/libpanel-applet/panel-applet.h b/bonobo/libpanel-applet/panel-applet.h
new file mode 100644
index 0000000..7cd65b9
--- /dev/null
+++ b/bonobo/libpanel-applet/panel-applet.h
@@ -0,0 +1,254 @@
+/*
+ * panel-applet.h: panel applet writing API.
+ *
+ * Copyright (C) 2001 Sun Microsystems, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ * Mark McLoughlin <mark skynet ie>
+ */
+
+#ifndef __PANEL_APPLET_H__
+#define __PANEL_APPLET_H__
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <bonobo/bonobo-control.h>
+#include <bonobo/bonobo-main.h>
+#include <bonobo/bonobo-ui-component.h>
+#include <bonobo/bonobo-generic-factory.h>
+
+#include <GNOME_Panel.h>
+
+G_BEGIN_DECLS
+
+typedef GNOME_Vertigo_PanelOrient PanelAppletOrient;
+
+#define PANEL_APPLET_ORIENT_UP GNOME_Vertigo_PANEL_ORIENT_UP
+#define PANEL_APPLET_ORIENT_DOWN GNOME_Vertigo_PANEL_ORIENT_DOWN
+#define PANEL_APPLET_ORIENT_LEFT GNOME_Vertigo_PANEL_ORIENT_LEFT
+#define PANEL_APPLET_ORIENT_RIGHT GNOME_Vertigo_PANEL_ORIENT_RIGHT
+
+
+#define PANEL_TYPE_APPLET (panel_applet_get_type ())
+#define PANEL_APPLET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PANEL_TYPE_APPLET, PanelApplet))
+#define PANEL_APPLET_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PANEL_TYPE_APPLET, PanelAppletClass))
+#define PANEL_IS_APPLET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PANEL_TYPE_APPLET))
+#define PANEL_IS_APPLET_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PANEL_TYPE_APPLET))
+#define PANEL_APPLET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PANEL_TYPE_APPLET, PanelAppletClass))
+
+typedef enum {
+ PANEL_NO_BACKGROUND,
+ PANEL_COLOR_BACKGROUND,
+ PANEL_PIXMAP_BACKGROUND
+} PanelAppletBackgroundType;
+
+typedef enum {
+ PANEL_APPLET_FLAGS_NONE = 0,
+ PANEL_APPLET_EXPAND_MAJOR = 1 << 0,
+ PANEL_APPLET_EXPAND_MINOR = 1 << 1,
+ PANEL_APPLET_HAS_HANDLE = 1 << 2
+} PanelAppletFlags;
+
+typedef struct _PanelApplet PanelApplet;
+typedef struct _PanelAppletClass PanelAppletClass;
+typedef struct _PanelAppletPrivate PanelAppletPrivate;
+
+typedef gboolean (*PanelAppletFactoryCallback) (PanelApplet *applet,
+ const gchar *iid,
+ gpointer user_data);
+
+struct _PanelApplet {
+ GtkEventBox event_box;
+
+ PanelAppletPrivate *priv;
+};
+
+struct _PanelAppletClass {
+ GtkEventBoxClass event_box_class;
+
+ void (*change_orient) (PanelApplet *applet,
+ PanelAppletOrient orient);
+
+ void (*change_size) (PanelApplet *applet,
+ guint size);
+
+ void (*change_background) (PanelApplet *applet,
+ PanelAppletBackgroundType type,
+ GdkColor *color,
+ GdkPixmap *pixmap);
+ void (*move_focus_out_of_applet) (PanelApplet *frame,
+ GtkDirectionType direction);
+};
+
+GType panel_applet_get_type (void) G_GNUC_CONST;
+
+GtkWidget *panel_applet_new (void);
+
+PanelAppletOrient panel_applet_get_orient (PanelApplet *applet);
+
+guint panel_applet_get_size (PanelApplet *applet);
+
+PanelAppletBackgroundType
+ panel_applet_get_background (PanelApplet *applet,
+ /* return values */
+ GdkColor *color,
+ GdkPixmap **pixmap);
+
+void panel_applet_set_background_widget (PanelApplet *applet,
+ GtkWidget *widget);
+
+gchar *panel_applet_get_preferences_key (PanelApplet *applet);
+
+void panel_applet_add_preferences (PanelApplet *applet,
+ const gchar *schema_dir,
+ GError **opt_error);
+
+PanelAppletFlags panel_applet_get_flags (PanelApplet *applet);
+void panel_applet_set_flags (PanelApplet *applet,
+ PanelAppletFlags flags);
+
+void panel_applet_set_size_hints (PanelApplet *applet,
+ const int *size_hints,
+ int n_elements,
+ int base_size);
+
+gboolean panel_applet_get_locked_down (PanelApplet *applet);
+
+void panel_applet_request_focus (PanelApplet *applet,
+ guint32 timestamp);
+
+BonoboControl *panel_applet_get_control (PanelApplet *applet);
+BonoboUIComponent *panel_applet_get_popup_component (PanelApplet *applet);
+
+void panel_applet_setup_menu (PanelApplet *applet,
+ const gchar *xml,
+ const BonoboUIVerb *verb_list,
+ gpointer user_data);
+
+void panel_applet_setup_menu_from_file (PanelApplet *applet,
+ const gchar *opt_datadir,
+ const gchar *file,
+ const gchar *opt_app_name,
+ const BonoboUIVerb *verb_list,
+ gpointer user_data);
+
+
+int panel_applet_factory_main (const gchar *iid,
+ GType applet_type,
+ PanelAppletFactoryCallback callback,
+ gpointer data);
+
+int panel_applet_factory_main_closure (const gchar *iid,
+ GType applet_type,
+ GClosure *closure);
+
+Bonobo_Unknown panel_applet_shlib_factory (const char *iid,
+ GType applet_type,
+ PortableServer_POA poa,
+ gpointer impl_ptr,
+ PanelAppletFactoryCallback callback,
+ gpointer user_data,
+ CORBA_Environment *ev);
+
+Bonobo_Unknown panel_applet_shlib_factory_closure (const char *iid,
+ GType applet_type,
+ PortableServer_POA poa,
+ gpointer impl_ptr,
+ GClosure *closure,
+ CORBA_Environment *ev);
+
+/*
+ * These macros are getting a bit unwieldy.
+ *
+ * Things to define for these:
+ * + required if Native Language Support is enabled (ENABLE_NLS):
+ * GETTEXT_PACKAGE and GNOMELOCALEDIR
+ */
+
+#if !defined(ENABLE_NLS)
+#define _PANEL_APPLET_SETUP_GETTEXT(call_textdomain) \
+ do { } while (0)
+#else /* defined(ENABLE_NLS) */
+#include <libintl.h>
+#define _PANEL_APPLET_SETUP_GETTEXT(call_textdomain) \
+ do { \
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); \
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); \
+ if (call_textdomain) \
+ textdomain (GETTEXT_PACKAGE); \
+ } while (0)
+#endif /* !defined(ENABLE_NLS) */
+
+#define PANEL_APPLET_BONOBO_FACTORY(iid, type, name, version, callback, data) \
+int main (int argc, char *argv []) \
+{ \
+ GOptionContext *context; \
+ GError *error; \
+ int retval; \
+ \
+ _PANEL_APPLET_SETUP_GETTEXT (TRUE); \
+ \
+ context = g_option_context_new (""); \
+ g_option_context_add_group (context, gtk_get_option_group (TRUE)); \
+ g_option_context_add_group (context, \
+ bonobo_activation_get_goption_group ()); \
+ \
+ error = NULL; \
+ if (!g_option_context_parse (context, &argc, &argv, &error)) { \
+ if (error) { \
+ g_printerr ("Cannot parse arguments: %s.\n", \
+ error->message); \
+ g_error_free (error); \
+ } else \
+ g_printerr ("Cannot parse arguments.\n"); \
+ g_option_context_free (context); \
+ return 1; \
+ } \
+ \
+ gtk_init (&argc, &argv); \
+ if (!bonobo_init (&argc, argv)) { \
+ g_printerr ("Cannot initialize bonobo.\n"); \
+ return 1; \
+ } \
+ \
+ retval = panel_applet_factory_main (iid, type, callback, data); \
+ g_option_context_free (context); \
+ \
+ return retval; \
+}
+
+#define PANEL_APPLET_BONOBO_SHLIB_FACTORY(iid, type, descr, callback, data) \
+static Bonobo_Unknown \
+__panel_applet_shlib_factory (PortableServer_POA poa, \
+ const char *oafiid, \
+ gpointer impl_ptr, \
+ CORBA_Environment *ev) \
+{ \
+ _PANEL_APPLET_SETUP_GETTEXT (FALSE); \
+ return panel_applet_shlib_factory ((iid), (type), poa, impl_ptr, \
+ (callback), (data), ev); \
+} \
+static BonoboActivationPluginObject plugin_list[] = { \
+ { (iid), __panel_applet_shlib_factory }, \
+ { NULL } \
+}; \
+const BonoboActivationPlugin Bonobo_Plugin_info = { plugin_list, (descr) };
+
+G_END_DECLS
+
+#endif /* __PANEL_APPLET_H__ */
diff --git a/bonobo/libpanel-applet/panel-test-applets-bonobo.c b/bonobo/libpanel-applet/panel-test-applets-bonobo.c
new file mode 100644
index 0000000..bbc5581
--- /dev/null
+++ b/bonobo/libpanel-applet/panel-test-applets-bonobo.c
@@ -0,0 +1,349 @@
+/*
+ * panel-test-applets.c:
+ *
+ * Authors:
+ * Mark McLoughlin <mark skynet ie>
+ *
+ * Copyright 2002 Sun Microsystems, Inc.
+ */
+
+#include <config.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <bonobo/bonobo-exception.h>
+#include <bonobo/bonobo-main.h>
+#include <bonobo/bonobo-widget.h>
+#include <gconf/gconf.h>
+
+#include "panel-applet.h"
+
+G_GNUC_UNUSED void on_execute_button_clicked (GtkButton *button, gpointer dummy);
+
+static GtkWidget *win = NULL;
+static GtkWidget *applet_combo = NULL;
+static GtkWidget *prefs_dir_entry = NULL;
+static GtkWidget *orient_combo = NULL;
+static GtkWidget *size_combo = NULL;
+
+static char *cli_iid = NULL;
+static char *cli_prefs_dir = NULL;
+static char *cli_size = NULL;
+static char *cli_orient = NULL;
+
+static const GOptionEntry options [] = {
+ { "iid", 0, 0, G_OPTION_ARG_STRING, &cli_iid, N_("Specify an applet IID to load"), NULL},
+ { "prefs-dir", 0, 0, G_OPTION_ARG_STRING, &cli_prefs_dir, N_("Specify a gconf location in which the applet preferences should be stored"), NULL},
+ { "size", 0, 0, G_OPTION_ARG_STRING, &cli_size, N_("Specify the initial size of the applet (xx-small, medium, large etc.)"), NULL},
+ { "orient", 0, 0, G_OPTION_ARG_STRING, &cli_orient, N_("Specify the initial orientation of the applet (top, bottom, left or right)"), NULL},
+ { NULL}
+};
+
+enum {
+ COLUMN_TEXT,
+ COLUMN_ITEM,
+ NUMBER_COLUMNS
+};
+
+typedef struct {
+ const char *name;
+ const char *value;
+} ComboItem;
+
+static ComboItem orient_items [] = {
+ { NC_("Orientation", "Top"), "top" },
+ { NC_("Orientation", "Bottom"), "bottom" },
+ { NC_("Orientation", "Left"), "left" },
+ { NC_("Orientation", "Right"), "right" }
+};
+
+
+static ComboItem size_items [] = {
+ { NC_("Size", "XX Small"), "xx-small" },
+ { NC_("Size", "X Small"), "x-small" },
+ { NC_("Size", "Small"), "small" },
+ { NC_("Size", "Medium"), "medium" },
+ { NC_("Size", "Large"), "large" },
+ { NC_("Size", "X Large"), "x-large" },
+ { NC_("Size", "XX Large"), "xx-large" }
+};
+
+static char *
+get_combo_value (GtkWidget *combo_box)
+{
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ char *value;
+
+ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_box), &iter))
+ return NULL;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
+ gtk_tree_model_get (model, &iter, COLUMN_ITEM, &value, -1);
+
+ return value;
+}
+
+static char *
+construct_moniker (void)
+{
+ const char *prefs_key;
+ char *iid;
+ char *size;
+ char *orient;
+ char *ret_value;
+
+ iid = get_combo_value (applet_combo);
+ g_assert (iid != NULL);
+ size = get_combo_value (size_combo);
+ g_assert (size != NULL);
+ orient = get_combo_value (orient_combo);
+ g_assert (orient != NULL);
+
+ prefs_key = gtk_entry_get_text (GTK_ENTRY (prefs_dir_entry));
+
+ ret_value= g_strdup_printf ("%s!prefs_key=%s;size=%s;orient=%s",
+ iid, prefs_key, size, orient);
+ g_free (iid);
+ g_free (size);
+ g_free (orient);
+
+ return ret_value;
+}
+
+static void
+load_applet_into_window (const char *moniker,
+ const char *title)
+{
+ GtkWidget *applet_window;
+ GtkWidget *applet;
+
+ applet = bonobo_widget_new_control (moniker, NULL);
+
+ if (!applet) {
+ GtkWidget *dialog;
+
+ dialog = gtk_message_dialog_new (win ? GTK_WINDOW (win) : NULL,
+ GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("Failed to load applet %s"),
+ title);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ return;
+ }
+
+ applet_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ gtk_widget_show (applet);
+
+ gtk_container_add (GTK_CONTAINER (applet_window), applet);
+
+ //FIXME: we could set the window icon with the applet icon
+ gtk_window_set_title (GTK_WINDOW (applet_window), title);
+ gtk_widget_show (applet_window);
+}
+
+static void
+load_applet_from_command_line (void)
+{
+ GString *str;
+
+ g_assert (cli_iid != NULL);
+
+ str = g_string_new (cli_iid);
+
+ if (cli_prefs_dir || cli_size || cli_orient) {
+ g_string_append_c (str, '!');
+
+ if (cli_prefs_dir)
+ g_string_append_printf (str, "prefs_key=%s", cli_prefs_dir);
+
+ g_string_append_c (str, ';');
+
+ if (cli_size)
+ g_string_append_printf (str, "size=%s", cli_size);
+
+ g_string_append_c (str, ';');
+
+ if (cli_orient)
+ g_string_append_printf (str, "orient=%s", cli_orient);
+ }
+
+ g_print ("Loading %s\n", str->str);
+
+ load_applet_into_window (str->str, cli_iid);
+
+ g_string_free (str, TRUE);
+}
+
+G_GNUC_UNUSED void
+on_execute_button_clicked (GtkButton *button,
+ gpointer dummy)
+{
+ char *moniker;
+ char *title;
+
+ moniker = construct_moniker ();
+ title = get_combo_value (applet_combo);
+ load_applet_into_window (moniker, title);
+ g_free (moniker);
+ g_free (title);
+}
+
+static void
+setup_combo (GtkWidget *combo_box,
+ ComboItem *items,
+ const char *context,
+ int nb_items,
+ gboolean dynamic)
+{
+ GtkListStore *model;
+ GtkTreeIter iter;
+ GtkCellRenderer *renderer;
+ int i;
+
+ model = gtk_list_store_new (NUMBER_COLUMNS,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
+
+ gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box),
+ GTK_TREE_MODEL (model));
+
+
+ for (i = 0; i < nb_items; i++) {
+ gtk_list_store_append (model, &iter);
+ gtk_list_store_set (model, &iter,
+ COLUMN_TEXT, dynamic ? g_strdup (items [i].name) : g_dpgettext2 (NULL, context, items [i].name),
+ COLUMN_ITEM, dynamic ? g_strdup (items [i].value) : items [i].value,
+ -1);
+ }
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box),
+ renderer, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box),
+ renderer, "text", COLUMN_TEXT, NULL);
+
+ gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0);
+}
+
+static void
+setup_options (void)
+{
+ Bonobo_ServerInfoList *applets;
+ CORBA_Environment env;
+ int i;
+ char *prefs_dir;
+ char *unique_key;
+ ComboItem *applet_items;
+ int applet_nb;
+
+ CORBA_exception_init (&env);
+
+ applets = bonobo_activation_query (
+ "has (repo_ids, 'IDL:GNOME/Vertigo/PanelAppletShell:1.0')",
+ NULL, &env);
+
+ if (BONOBO_EX (&env))
+ g_error (_("query returned exception %s\n"), BONOBO_EX_REPOID (&env));
+
+ CORBA_exception_free (&env);
+
+ applet_nb = applets->_length;
+ applet_items = g_new0 (ComboItem, applet_nb);
+
+ for (i = 0; i < applet_nb; i++) {
+ Bonobo_ServerInfo *info;
+
+ info = &applets->_buffer [i];
+
+ applet_items[i].name = info->iid;
+ applet_items[i].value = info->iid;
+ }
+
+ setup_combo (applet_combo, applet_items, NULL, applet_nb, TRUE);
+ g_free (applet_items);
+ CORBA_free (applets);
+
+ setup_combo (size_combo, size_items, "Size",
+ G_N_ELEMENTS (size_items), FALSE);
+ setup_combo (orient_combo, orient_items, "Orientation",
+ G_N_ELEMENTS (orient_items), FALSE);
+
+ unique_key = gconf_unique_key ();
+ prefs_dir = g_strdup_printf ("/tmp/%s", unique_key);
+ g_free (unique_key);
+ gtk_entry_set_text (GTK_ENTRY (prefs_dir_entry), prefs_dir);
+ g_free (prefs_dir);
+}
+
+int
+main (int argc, char **argv)
+{
+ GtkBuilder *builder;
+ char *uifile;
+ GError *error;
+
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
+ error = NULL;
+ if (!gtk_init_with_args (&argc, &argv,
+ "", (GOptionEntry *) options, GETTEXT_PACKAGE,
+ &error)) {
+ if (error) {
+ g_printerr ("%s\n", error->message);
+ g_error_free (error);
+ } else
+ g_printerr ("Cannot initiliaze GTK+.\n");
+
+ return 1;
+ }
+
+ if (!bonobo_init (&argc, argv)) {
+ g_printerr ("Cannot initialize bonobo.\n");
+ return 1;
+ }
+
+ if (cli_iid) {
+ load_applet_from_command_line ();
+ gtk_main ();
+ return 0;
+ }
+
+ builder = gtk_builder_new ();
+ gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
+
+ uifile = PANEL_APPLET_BUILDERDIR "/panel-test-applets.ui";
+ gtk_builder_add_from_file (builder, uifile, &error);
+
+ if (error) {
+ g_warning ("Error loading \"%s\": %s", uifile, error->message);
+ g_error_free (error);
+ return 1;
+ }
+
+ gtk_builder_connect_signals (builder, NULL);
+
+ win = GTK_WIDGET (gtk_builder_get_object (builder,
+ "toplevel"));
+ applet_combo = GTK_WIDGET (gtk_builder_get_object (builder,
+ "applet-combo"));
+ prefs_dir_entry = GTK_WIDGET (gtk_builder_get_object (builder,
+ "prefs-dir-entry"));
+ orient_combo = GTK_WIDGET (gtk_builder_get_object (builder,
+ "orient-combo"));
+ size_combo = GTK_WIDGET (gtk_builder_get_object (builder,
+ "size-combo"));
+ g_object_unref (builder);
+
+ setup_options ();
+
+ gtk_widget_show (win);
+
+ gtk_main ();
+
+ return 0;
+}
diff --git a/bonobo/libpanel-applet/panel-test-applets-bonobo.ui b/bonobo/libpanel-applet/panel-test-applets-bonobo.ui
new file mode 100644
index 0000000..05916cf
--- /dev/null
+++ b/bonobo/libpanel-applet/panel-test-applets-bonobo.ui
@@ -0,0 +1,203 @@
+<?xml version="1.0"?>
+<interface>
+ <!-- interface-requires gtk+ 2.6 -->
+ <!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkDialog" id="toplevel">
+ <property name="visible">True</property>
+ <property name="title" translatable="yes" comments="This is an utility to easily test various applets">Test applet utility</property>
+ <property name="resizable">False</property>
+ <property name="type_hint">dialog</property>
+ <property name="has_separator">False</property>
+ <signal name="destroy" handler="gtk_main_quit"/>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox1">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">8</property>
+ <child>
+ <object class="GtkTable" id="table2">
+ <property name="visible">True</property>
+ <property name="border_width">2</property>
+ <property name="n_rows">5</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">4</property>
+ <property name="row_spacing">4</property>
+ <child>
+ <object class="GtkLabel" id="size-label">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">_Size:</property>
+ <property name="use_underline">True</property>
+ <property name="justify">center</property>
+ <property name="mnemonic_widget">size-combo</property>
+ </object>
+ <packing>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="applet-label">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">_Applet:</property>
+ <property name="use_underline">True</property>
+ <property name="justify">center</property>
+ <property name="mnemonic_widget">applet-combo</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="orient-label">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">_Orientation:</property>
+ <property name="use_underline">True</property>
+ <property name="justify">center</property>
+ <property name="mnemonic_widget">orient-combo</property>
+ </object>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="prefs-label">
+ <property name="visible">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">_Prefs Dir:</property>
+ <property name="use_underline">True</property>
+ <property name="justify">center</property>
+ <property name="mnemonic_widget">prefs-dir-entry</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="prefs-dir-entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="applet-combo">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="orient-combo">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="size-combo">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHSeparator" id="hseparator2">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox" id="dialog-action_area1">
+ <property name="visible">True</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="ok-button">
+ <property name="label">gtk-execute</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="on_execute_button_clicked"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button1">
+ <property name="label">gtk-close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="gtk_main_quit"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="0">ok-button</action-widget>
+ <action-widget response="-7">button1</action-widget>
+ </action-widgets>
+ </object>
+</interface>
diff --git a/bonobo/libpanel-applet/test-bonobo-applet.c b/bonobo/libpanel-applet/test-bonobo-applet.c
new file mode 100644
index 0000000..9ddb2bc
--- /dev/null
+++ b/bonobo/libpanel-applet/test-bonobo-applet.c
@@ -0,0 +1,202 @@
+/*
+ * test-bonobo-applet.c:
+ *
+ * Authors:
+ * Mark McLoughlin <mark skynet ie>
+ *
+ * Copyright 2001 Sun Microsystems, Inc.
+ */
+
+#include <config.h>
+#include <string.h>
+
+#include <libbonoboui.h>
+
+#include "panel-applet.h"
+
+static void
+test_applet_on_do (BonoboUIComponent *uic,
+ gpointer user_data,
+ const gchar *verbname)
+{
+ g_message ("%s called\n", verbname);
+}
+
+static const BonoboUIVerb test_applet_menu_verbs [] = {
+ BONOBO_UI_VERB ("TestAppletDo1", test_applet_on_do),
+ BONOBO_UI_VERB ("TestAppletDo2", test_applet_on_do),
+ BONOBO_UI_VERB ("TestAppletDo3", test_applet_on_do),
+
+ BONOBO_UI_VERB_END
+};
+
+static const char test_applet_menu_xml [] =
+ "<popup name=\"button3\">\n"
+ " <menuitem name=\"Test Item 1\" verb=\"TestAppletDo1\" _label=\"Test This One\"/>\n"
+ " <menuitem name=\"Test Item 2\" verb=\"TestAppletDo2\" _label=\"Test This Two\"/>\n"
+ " <menuitem name=\"Test Item 3\" verb=\"TestAppletDo3\" _label=\"Test This Three\"/>\n"
+ "</popup>\n";
+
+typedef struct {
+ PanelApplet base;
+ GtkWidget *label;
+} TestApplet;
+
+static GType
+test_applet_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ static const GTypeInfo info = {
+ sizeof (PanelAppletClass),
+ NULL, NULL, NULL, NULL, NULL,
+ sizeof (TestApplet),
+ 0, NULL, NULL
+ };
+
+ type = g_type_register_static (
+ PANEL_TYPE_APPLET, "TestApplet", &info, 0);
+ }
+
+ return type;
+}
+
+static void
+test_applet_handle_orient_change (TestApplet *applet,
+ PanelAppletOrient orient,
+ gpointer dummy)
+{
+ gchar *text;
+
+ text = g_strdup (gtk_label_get_text (GTK_LABEL (applet->label)));
+
+ g_strreverse (text);
+
+ gtk_label_set_text (GTK_LABEL (applet->label), text);
+
+ g_free (text);
+}
+
+static void
+test_applet_handle_size_change (TestApplet *applet,
+ gint size,
+ gpointer dummy)
+{
+ switch (size) {
+ case GNOME_Vertigo_PANEL_XX_SMALL:
+ gtk_label_set_markup (
+ GTK_LABEL (applet->label), "<span size=\"xx-small\">Hello</span>");
+ break;
+ case GNOME_Vertigo_PANEL_X_SMALL:
+ gtk_label_set_markup (
+ GTK_LABEL (applet->label), "<span size=\"x-small\">Hello</span>");
+ break;
+ case GNOME_Vertigo_PANEL_SMALL:
+ gtk_label_set_markup (
+ GTK_LABEL (applet->label), "<span size=\"small\">Hello</span>");
+ break;
+ case GNOME_Vertigo_PANEL_MEDIUM:
+ gtk_label_set_markup (
+ GTK_LABEL (applet->label), "<span size=\"medium\">Hello</span>");
+ break;
+ case GNOME_Vertigo_PANEL_LARGE:
+ gtk_label_set_markup (
+ GTK_LABEL (applet->label), "<span size=\"large\">Hello</span>");
+ break;
+ case GNOME_Vertigo_PANEL_X_LARGE:
+ gtk_label_set_markup (
+ GTK_LABEL (applet->label), "<span size=\"x-large\">Hello</span>");
+ break;
+ case GNOME_Vertigo_PANEL_XX_LARGE:
+ gtk_label_set_markup (
+ GTK_LABEL (applet->label), "<span size=\"xx-large\">Hello</span>");
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
+
+static void
+test_applet_handle_background_change (TestApplet *applet,
+ PanelAppletBackgroundType type,
+ GdkColor *color,
+ GdkPixmap *pixmap,
+ gpointer dummy)
+{
+ switch (type) {
+ case PANEL_NO_BACKGROUND:
+ g_message ("Setting background to default");
+ gdk_window_set_back_pixmap (applet->label->window, NULL, FALSE);
+ break;
+ case PANEL_COLOR_BACKGROUND:
+ g_message ("Setting background to #%2x%2x%2x",
+ color->red, color->green, color->blue);
+ gdk_window_set_back_pixmap (applet->label->window, NULL, FALSE);
+ break;
+ case PANEL_PIXMAP_BACKGROUND:
+ g_message ("Setting background to '%p'", pixmap);
+ gdk_window_set_back_pixmap (applet->label->window, pixmap, FALSE);
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
+
+static gboolean
+test_applet_fill (TestApplet *applet)
+{
+ applet->label = gtk_label_new (NULL);
+
+ gtk_container_add (GTK_CONTAINER (applet), applet->label);
+
+ gtk_widget_show_all (GTK_WIDGET (applet));
+
+ test_applet_handle_size_change (applet, GNOME_Vertigo_PANEL_MEDIUM, NULL);
+
+ panel_applet_setup_menu (
+ PANEL_APPLET (applet), test_applet_menu_xml, test_applet_menu_verbs, NULL);
+
+ gtk_widget_set_tooltip_text (GTK_WIDGET (applet), "Hello Tip");
+
+ panel_applet_set_flags (PANEL_APPLET (applet), PANEL_APPLET_HAS_HANDLE);
+
+ g_signal_connect (G_OBJECT (applet),
+ "change_orient",
+ G_CALLBACK (test_applet_handle_orient_change),
+ NULL);
+
+ g_signal_connect (G_OBJECT (applet),
+ "change_size",
+ G_CALLBACK (test_applet_handle_size_change),
+ NULL);
+
+ g_signal_connect (G_OBJECT (applet),
+ "change_background",
+ G_CALLBACK (test_applet_handle_background_change),
+ NULL);
+
+ return TRUE;
+}
+
+static gboolean
+test_applet_factory (TestApplet *applet,
+ const gchar *iid,
+ gpointer data)
+{
+ gboolean retval = FALSE;
+
+ if (!strcmp (iid, "OAFIID:GNOME_Panel_TestBonoboApplet"))
+ retval = test_applet_fill (applet);
+
+ return retval;
+}
+
+PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_Panel_TestBonoboApplet_Factory",
+ test_applet_get_type (),
+ "A Test Applet for the GNOME-2.0 Panel",
+ "0",
+ (PanelAppletFactoryCallback) test_applet_factory,
+ NULL)
diff --git a/bonobo/panel-module/GNOME_Panel_Popup.xml b/bonobo/panel-module/GNOME_Panel_Popup.xml
new file mode 100644
index 0000000..9956f2e
--- /dev/null
+++ b/bonobo/panel-module/GNOME_Panel_Popup.xml
@@ -0,0 +1,20 @@
+<Root>
+ <popups>
+ <popup name="button3">
+
+ <placeholder delimit="top">
+
+ <menuitem name="remove" verb="RemoveAppletFromPanel" _label="_Remove From Panel"
+ pixtype="stock" pixname="gtk-remove"/>
+
+ <menuitem name="move" verb="MoveApplet" _label="_Move"/>
+
+ <separator verb="LockSeparator"/>
+
+ <menuitem name="lock" verb="LockAppletToPanel" _label="Loc_k To Panel"
+ type="toggle"/>
+
+ </placeholder>
+ </popup>
+ </popups>
+</Root>
diff --git a/bonobo/panel-module/Makefile.am b/bonobo/panel-module/Makefile.am
new file mode 100644
index 0000000..2664ab6
--- /dev/null
+++ b/bonobo/panel-module/Makefile.am
@@ -0,0 +1,56 @@
+NULL =
+
+module_flags = -export_dynamic -avoid-version -module -no-undefined -export-symbols-regex '^g_io_module_(load|unload|query)'
+
+panelmodule_LTLIBRARIES = libpanel-applets-bonobo.la
+panelmoduledir = $(modulesdir)
+
+CORBA_SRCLIST = \
+ GNOME_Panel-stubs.c \
+ GNOME_Panel-skels.c \
+ GNOME_Panel-common.c \
+ GNOME_Panel.h \
+ $(NULL)
+
+$(CORBA_SRCLIST): $(top_srcdir)/bonobo/idl/GNOME_Panel.idl $(ORBIT_IDL)
+ $(AM_V_GEN)$(ORBIT_IDL) -I $(BONOBO_IDLDIR) -I $(BONOBO_ACT_IDLDIR) $(top_srcdir)/bonobo/idl/GNOME_Panel.idl
+
+BUILT_SOURCES = \
+ $(CORBA_SRCLIST)
+
+libpanel_applets_bonobo_la_SOURCES = \
+ $(CORBA_SRCLIST) \
+ panel-applets-bonobo-module.c \
+ panel-applets-manager-bonobo.c \
+ panel-applets-manager-bonobo.h \
+ panel-applet-frame-bonobo.c \
+ panel-applet-frame-bonobo.h \
+ $(NULL)
+
+libpanel_applets_bonobo_la_CFLAGS = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/gnome-panel \
+ -I$(top_builddir) \
+ -DDATADIR=\""$(datadir)"\" \
+ $(BONOBO_CFLAGS)
+
+libpanel_applets_bonobo_la_LDFLAGS = \
+ $(module_flags) \
+ $(NULL)
+
+libpanel_applets_bonobo_la_LIBADD = \
+ $(BONOBO_LIBS) \
+ $(NULL)
+
+xmluidir = $(datadir)/gnome-2.0/ui
+xmlui_DATA = GNOME_Panel_Popup.xml
+
+install-data-hook:
+ if test -z "$(DESTDIR)" -a "$(GIO_QUERYMODULES)" != "no" ; then \
+ $(GIO_QUERYMODULES) $(modulesdir) ; \
+ fi
+
+EXTRA_DIST = \
+ $(xmlui_DATA)
+
+-include $(top_srcdir)/git.mk
diff --git a/bonobo/panel-module/panel-applet-frame-bonobo.c b/bonobo/panel-module/panel-applet-frame-bonobo.c
new file mode 100644
index 0000000..d2e38db
--- /dev/null
+++ b/bonobo/panel-module/panel-applet-frame-bonobo.c
@@ -0,0 +1,748 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * panel-applet-frame-bonobo.c: panel side container for applets
+ *
+ * Copyright (C) 2001 - 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2010 Vincent Untz <vuntz gnome org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Authors:
+ * Mark McLoughlin <mark skynet ie>
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <libbonoboui.h>
+
+#include <panel-applet-frame.h>
+#include <panel-applets-manager.h>
+
+#include "GNOME_Panel.h"
+
+#include "panel-applet-frame-bonobo.h"
+
+G_DEFINE_TYPE (PanelAppletFrameBonobo,
+ panel_applet_frame_bonobo,
+ PANEL_TYPE_APPLET_FRAME)
+
+struct _PanelAppletFrameBonoboPrivate
+{
+ GNOME_Vertigo_PanelAppletShell applet_shell;
+ CORBA_Object control;
+ Bonobo_PropertyBag property_bag;
+ BonoboUIComponent *ui_component;
+};
+
+#define PROPERTY_ORIENT "panel-applet-orient"
+#define PROPERTY_SIZE "panel-applet-size"
+#define PROPERTY_BACKGROUND "panel-applet-background"
+#define PROPERTY_FLAGS "panel-applet-flags"
+#define PROPERTY_SIZE_HINTS "panel-applet-size-hints"
+#define PROPERTY_LOCKED_DOWN "panel-applet-locked-down"
+
+typedef enum {
+ PANEL_SIZE_XX_SMALL = GNOME_Vertigo_PANEL_XX_SMALL,
+ PANEL_SIZE_X_SMALL = GNOME_Vertigo_PANEL_X_SMALL,
+ PANEL_SIZE_SMALL = GNOME_Vertigo_PANEL_SMALL,
+ PANEL_SIZE_MEDIUM = GNOME_Vertigo_PANEL_MEDIUM,
+ PANEL_SIZE_LARGE = GNOME_Vertigo_PANEL_LARGE,
+ PANEL_SIZE_X_LARGE = GNOME_Vertigo_PANEL_X_LARGE,
+ PANEL_SIZE_XX_LARGE = GNOME_Vertigo_PANEL_XX_LARGE
+} PanelSize;
+
+/* Keep in sync with panel-applet.h. Uggh. */
+typedef enum {
+ APPLET_FLAGS_NONE = 0,
+ APPLET_EXPAND_MAJOR = 1 << 0,
+ APPLET_EXPAND_MINOR = 1 << 1,
+ APPLET_HAS_HANDLE = 1 << 2
+} PanelAppletFlags;
+
+GQuark
+panel_applet_frame_bonobo_error_quark (void)
+{
+ static GQuark ret = 0;
+
+ if (ret == 0) {
+ ret = g_quark_from_static_string ("panel_applet_frame_bonobo_error");
+ }
+
+ return ret;
+}
+
+static guint
+get_panel_applet_orient (PanelOrientation orientation)
+{
+ /* For some reason libpanel-applet and panel use a different logic for
+ * orientation, so we need to convert it. We should fix this. */
+ switch (orientation) {
+ case PANEL_ORIENTATION_TOP:
+ return 1;
+ case PANEL_ORIENTATION_BOTTOM:
+ return 0;
+ case PANEL_ORIENTATION_LEFT:
+ return 3;
+ case PANEL_ORIENTATION_RIGHT:
+ return 2;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
+
+static void
+panel_applet_frame_bonobo_update_flags (PanelAppletFrame *frame,
+ const CORBA_any *any)
+{
+ int flags;
+ gboolean major;
+ gboolean minor;
+ gboolean has_handle;
+
+ flags = BONOBO_ARG_GET_SHORT (any);
+
+ major = (flags & APPLET_EXPAND_MAJOR) != 0;
+ minor = (flags & APPLET_EXPAND_MINOR) != 0;
+ has_handle = (flags & APPLET_HAS_HANDLE) != 0;
+
+ _panel_applet_frame_update_flags (frame, major, minor, has_handle);
+}
+
+static void
+panel_applet_frame_bonobo_update_size_hints (PanelAppletFrame *frame,
+ const CORBA_any *any)
+{
+ CORBA_sequence_CORBA_long *seq;
+
+ seq = any->_value;
+
+ _panel_applet_frame_update_size_hints (frame, seq->_buffer, seq->_length);
+}
+
+static void
+panel_applet_frame_bonobo_init_properties (PanelAppletFrame *frame)
+{
+ PanelAppletFrameBonobo *bonobo_frame = PANEL_APPLET_FRAME_BONOBO (frame);
+ CORBA_any *any;
+
+ any = bonobo_pbclient_get_value (bonobo_frame->priv->property_bag,
+ PROPERTY_FLAGS,
+ BONOBO_ARG_SHORT,
+ NULL);
+ if (any) {
+ panel_applet_frame_bonobo_update_flags (frame, any);
+ CORBA_free (any);
+ }
+
+ any = bonobo_pbclient_get_value (bonobo_frame->priv->property_bag,
+ PROPERTY_SIZE_HINTS,
+ TC_CORBA_sequence_CORBA_long,
+ NULL);
+ if (any) {
+ panel_applet_frame_bonobo_update_size_hints (frame, any);
+ CORBA_free (any);
+ }
+}
+
+static void
+panel_applet_frame_bonobo_sync_menu_state (PanelAppletFrame *frame,
+ gboolean movable,
+ gboolean removable,
+ gboolean lockable,
+ gboolean locked,
+ gboolean locked_down)
+{
+ PanelAppletFrameBonobo *bonobo_frame = PANEL_APPLET_FRAME_BONOBO (frame);
+
+ bonobo_ui_component_set_prop (bonobo_frame->priv->ui_component,
+ "/commands/LockAppletToPanel",
+ "state",
+ locked ? "1" : "0",
+ NULL);
+
+ /* First sensitivity */
+ bonobo_ui_component_set_prop (bonobo_frame->priv->ui_component,
+ "/commands/LockAppletToPanel",
+ "sensitive",
+ lockable ? "1" : "0",
+ NULL);
+
+ bonobo_ui_component_set_prop (bonobo_frame->priv->ui_component,
+ "/commands/RemoveAppletFromPanel",
+ "sensitive",
+ (locked && !lockable) ? "0" : (removable ? "1" : "0"),
+ NULL);
+
+ bonobo_ui_component_set_prop (bonobo_frame->priv->ui_component,
+ "/commands/MoveApplet",
+ "sensitive",
+ locked ? "0" : (movable ? "1" : "0"),
+ NULL);
+
+ bonobo_ui_component_set_prop (bonobo_frame->priv->ui_component,
+ "/commands/LockAppletToPanel",
+ "hidden",
+ locked_down ? "1" : "0",
+ NULL);
+
+ bonobo_ui_component_set_prop (bonobo_frame->priv->ui_component,
+ "/commands/LockSeparator",
+ "hidden",
+ locked_down ? "1" : "0",
+ NULL);
+
+ bonobo_ui_component_set_prop (bonobo_frame->priv->ui_component,
+ "/commands/RemoveAppletFromPanel",
+ "hidden",
+ locked_down ? "1" : "0",
+ NULL);
+
+ bonobo_ui_component_set_prop (bonobo_frame->priv->ui_component,
+ "/commands/MoveApplet",
+ "hidden",
+ locked_down ? "1" : "0",
+ NULL);
+}
+
+static void
+panel_applet_frame_bonobo_popup_menu (PanelAppletFrame *frame,
+ guint button,
+ guint32 timestamp)
+{
+ PanelAppletFrameBonobo *bonobo_frame = PANEL_APPLET_FRAME_BONOBO (frame);
+ CORBA_Environment env;
+
+ CORBA_exception_init (&env);
+
+ GNOME_Vertigo_PanelAppletShell_popup_menu (bonobo_frame->priv->applet_shell,
+ button, timestamp, &env);
+ if (BONOBO_EX (&env))
+ g_warning ("Exception from popup_menu '%s'\n", env._id);
+
+ CORBA_exception_free (&env);
+}
+
+static void
+panel_applet_frame_bonobo_change_orientation (PanelAppletFrame *frame,
+ PanelOrientation orientation)
+{
+ PanelAppletFrameBonobo *bonobo_frame = PANEL_APPLET_FRAME_BONOBO (frame);
+ CORBA_unsigned_short orient = 0;
+
+ switch (orientation) {
+ case PANEL_ORIENTATION_TOP:
+ orient = GNOME_Vertigo_PANEL_ORIENT_DOWN;
+ break;
+ case PANEL_ORIENTATION_BOTTOM:
+ orient = GNOME_Vertigo_PANEL_ORIENT_UP;
+ break;
+ case PANEL_ORIENTATION_LEFT:
+ orient = GNOME_Vertigo_PANEL_ORIENT_RIGHT;
+ break;
+ case PANEL_ORIENTATION_RIGHT:
+ orient = GNOME_Vertigo_PANEL_ORIENT_LEFT;
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ bonobo_pbclient_set_short (bonobo_frame->priv->property_bag,
+ PROPERTY_ORIENT,
+ orient,
+ NULL);
+
+ gtk_widget_queue_resize (GTK_WIDGET (frame));
+}
+
+static void
+panel_applet_frame_bonobo_change_size (PanelAppletFrame *frame,
+ guint size)
+{
+ PanelAppletFrameBonobo *bonobo_frame = PANEL_APPLET_FRAME_BONOBO (frame);
+
+ /* Normalise the size to the constants defined in the IDL. */
+ size = size <= PANEL_SIZE_XX_SMALL ? PANEL_SIZE_XX_SMALL :
+ size <= PANEL_SIZE_X_SMALL ? PANEL_SIZE_X_SMALL :
+ size <= PANEL_SIZE_SMALL ? PANEL_SIZE_SMALL :
+ size <= PANEL_SIZE_MEDIUM ? PANEL_SIZE_MEDIUM :
+ size <= PANEL_SIZE_LARGE ? PANEL_SIZE_LARGE :
+ size <= PANEL_SIZE_X_LARGE ? PANEL_SIZE_X_LARGE : PANEL_SIZE_XX_LARGE;
+
+ bonobo_pbclient_set_short (bonobo_frame->priv->property_bag,
+ PROPERTY_SIZE,
+ size,
+ NULL);
+}
+
+static void
+panel_applet_frame_bonobo_change_background (PanelAppletFrame *frame,
+ PanelBackgroundType type)
+{
+ PanelAppletFrameBonobo *bonobo_frame = PANEL_APPLET_FRAME_BONOBO (frame);
+ char *bg_str;
+
+ bg_str = _panel_applet_frame_get_background_string (
+ frame, PANEL_WIDGET (GTK_WIDGET (frame)->parent), type);
+
+ if (bg_str != NULL) {
+ bonobo_pbclient_set_string (bonobo_frame->priv->property_bag,
+ PROPERTY_BACKGROUND,
+ bg_str, NULL);
+
+ g_free (bg_str);
+ }
+}
+
+static void
+panel_applet_frame_bonobo_applet_broken (ORBitConnection *cnx,
+ PanelAppletFrame *frame)
+{
+ _panel_applet_frame_applet_broken (frame);
+}
+
+static void
+popup_handle_remove (BonoboUIComponent *uic,
+ PanelAppletFrame *frame,
+ const gchar *verbname)
+{
+ _panel_applet_frame_applet_remove (frame);
+}
+
+static void
+popup_handle_move (BonoboUIComponent *uic,
+ PanelAppletFrame *frame,
+ const gchar *verbname)
+{
+ _panel_applet_frame_applet_move (frame);
+}
+
+static void
+listener_popup_handle_lock (BonoboUIComponent *uic,
+ const char *path,
+ Bonobo_UIComponent_EventType type,
+ const char *state,
+ gpointer data)
+{
+ PanelAppletFrame *frame;
+ gboolean locked;
+
+ g_assert (!strcmp (path, "LockAppletToPanel"));
+
+ if (type != Bonobo_UIComponent_STATE_CHANGED)
+ return;
+
+ if (!state)
+ return;
+
+ frame = (PanelAppletFrame *) data;
+ locked = (strcmp (state, "1") == 0);
+
+ _panel_applet_frame_applet_lock (frame, locked);
+
+ panel_applet_frame_sync_menu_state (frame);
+}
+
+static BonoboUIVerb popup_verbs [] = {
+ BONOBO_UI_UNSAFE_VERB ("RemoveAppletFromPanel", popup_handle_remove),
+ BONOBO_UI_UNSAFE_VERB ("MoveApplet", popup_handle_move),
+
+ BONOBO_UI_VERB_END
+};
+
+
+static void
+panel_applet_frame_bonobo_finalize (GObject *object)
+{
+ PanelAppletFrameBonobo *frame = PANEL_APPLET_FRAME_BONOBO (object);
+
+ if (frame->priv->control) {
+ /* do this before unref'ing every bonobo stuff since it looks
+ * like we can receive some events when unref'ing them */
+ ORBit_small_unlisten_for_broken (frame->priv->control,
+ G_CALLBACK (panel_applet_frame_bonobo_applet_broken));
+ bonobo_object_release_unref (frame->priv->control, NULL);
+ frame->priv->control = CORBA_OBJECT_NIL;
+ }
+
+ if (frame->priv->property_bag)
+ bonobo_object_release_unref (
+ frame->priv->property_bag, NULL);
+
+ if (frame->priv->applet_shell)
+ bonobo_object_release_unref (
+ frame->priv->applet_shell, NULL);
+
+ if (frame->priv->ui_component)
+ bonobo_object_unref (
+ BONOBO_OBJECT (frame->priv->ui_component));
+
+ G_OBJECT_CLASS (panel_applet_frame_bonobo_parent_class)->finalize (object);
+}
+
+static void
+panel_applet_frame_bonobo_init (PanelAppletFrameBonobo *frame)
+{
+ GtkWidget *container;
+
+ frame->priv = G_TYPE_INSTANCE_GET_PRIVATE (frame,
+ PANEL_TYPE_APPLET_FRAME_BONOBO,
+ PanelAppletFrameBonoboPrivate);
+
+ frame->priv->applet_shell = CORBA_OBJECT_NIL;
+ frame->priv->control = CORBA_OBJECT_NIL;
+ frame->priv->property_bag = CORBA_OBJECT_NIL;
+ frame->priv->ui_component = NULL;
+}
+
+static void
+panel_applet_frame_bonobo_class_init (PanelAppletFrameBonoboClass *class)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+ PanelAppletFrameClass *frame_class = PANEL_APPLET_FRAME_CLASS (class);
+
+ gobject_class->finalize = panel_applet_frame_bonobo_finalize;
+
+ frame_class->init_properties = panel_applet_frame_bonobo_init_properties;
+ frame_class->sync_menu_state = panel_applet_frame_bonobo_sync_menu_state;
+ frame_class->popup_menu = panel_applet_frame_bonobo_popup_menu;
+ frame_class->change_orientation = panel_applet_frame_bonobo_change_orientation;
+ frame_class->change_size = panel_applet_frame_bonobo_change_size;
+ frame_class->change_background = panel_applet_frame_bonobo_change_background;
+
+ g_type_class_add_private (class, sizeof (PanelAppletFrameBonoboPrivate));
+}
+
+static GNOME_Vertigo_PanelAppletShell
+panel_applet_frame_get_applet_shell (Bonobo_Control control)
+{
+ CORBA_Environment env;
+ GNOME_Vertigo_PanelAppletShell retval;
+
+ CORBA_exception_init (&env);
+
+ retval = Bonobo_Unknown_queryInterface (control,
+ "IDL:GNOME/Vertigo/PanelAppletShell:1.0",
+ &env);
+ if (BONOBO_EX (&env)) {
+ g_warning (_("Unable to obtain AppletShell interface from control\n"));
+
+ retval = CORBA_OBJECT_NIL;
+ }
+
+ CORBA_exception_free (&env);
+
+ return retval;
+}
+
+static G_CONST_RETURN char *
+panel_applet_frame_get_orient_string (PanelAppletFrame *frame,
+ PanelAppletFrameActivating *frame_act)
+{
+ PanelOrientation orientation;
+ const char *retval = NULL;
+
+ orientation = panel_applet_frame_activating_get_orientation (frame_act);
+
+ switch (orientation) {
+ case PANEL_ORIENTATION_TOP:
+ retval = "down";
+ break;
+ case PANEL_ORIENTATION_BOTTOM:
+ retval = "up";
+ break;
+ case PANEL_ORIENTATION_LEFT:
+ retval = "right";
+ break;
+ case PANEL_ORIENTATION_RIGHT:
+ retval = "left";
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ return retval;
+}
+
+static G_CONST_RETURN char *
+panel_applet_frame_get_size_string (PanelAppletFrame *frame,
+ PanelAppletFrameActivating *frame_act)
+{
+ const char *retval = NULL;
+ guint32 size;
+
+ size = panel_applet_frame_activating_get_size (frame_act);
+
+ if (size <= PANEL_SIZE_XX_SMALL)
+ retval = "xx-small";
+ else if (size <= PANEL_SIZE_X_SMALL)
+ retval = "x-small";
+ else if (size <= PANEL_SIZE_SMALL)
+ retval = "small";
+ else if (size <= PANEL_SIZE_MEDIUM)
+ retval = "medium";
+ else if (size <= PANEL_SIZE_LARGE)
+ retval = "large";
+ else if (size <= PANEL_SIZE_X_LARGE)
+ retval = "x-large";
+ else
+ retval = "xx-large";
+
+ return retval;
+}
+
+static char *
+panel_applet_frame_construct_item (PanelAppletFrame *frame,
+ PanelAppletFrameActivating *frame_act)
+{
+ char *retval;
+ char *conf_path = NULL;
+ char *bg_str = NULL;
+ gboolean locked_down;
+
+ conf_path = panel_applet_frame_activating_get_conf_path (frame_act);
+ //FIXME vuntz
+#if 0
+ bg_str = _panel_applet_frame_get_background_string (
+ frame, panel, panel->background.type);
+#endif
+
+ if (bg_str == NULL)
+ bg_str = g_strdup ("");
+
+ locked_down = panel_applet_frame_activating_get_locked_down (frame_act);
+
+ retval = g_strdup_printf (
+ "prefs_key=%s;"
+ "background=%s;orient=%s;size=%s;locked_down=%s",
+ conf_path, bg_str,
+ panel_applet_frame_get_orient_string (frame, frame_act),
+ panel_applet_frame_get_size_string (frame, frame_act),
+ locked_down ? "true" : "false");
+
+ g_free (conf_path);
+ g_free (bg_str);
+
+ return retval;
+}
+
+static void
+panel_applet_frame_event_listener (BonoboListener *listener,
+ const char *event,
+ const CORBA_any *any,
+ CORBA_Environment *ev,
+ PanelAppletFrame *frame)
+{
+ if (!strcmp (event, "Bonobo/Property:change:" PROPERTY_FLAGS))
+ panel_applet_frame_bonobo_update_flags (frame, any);
+
+ else if (!strcmp (event, "Bonobo/Property:change:" PROPERTY_SIZE_HINTS))
+ panel_applet_frame_bonobo_update_size_hints (frame, any);
+}
+
+static void
+panel_applet_frame_bonobo_activated (CORBA_Object object,
+ const char *error_reason,
+ gpointer data)
+{
+ PanelAppletFrameActivating *frame_act;
+ PanelAppletFrameBonobo *bonobo_frame;
+ PanelAppletFrame *frame;
+ GtkWidget *widget;
+ BonoboControlFrame *control_frame;
+ Bonobo_Control control;
+ Bonobo_ItemContainer container;
+ CORBA_Environment corba_ev;
+ AppletInfo *info;
+ char *error;
+ char *item_name;
+ GError *gerror = NULL;
+
+ widget = NULL;
+ bonobo_frame = PANEL_APPLET_FRAME_BONOBO (data);
+ frame = PANEL_APPLET_FRAME (data);
+ frame_act = g_object_get_data (G_OBJECT (frame), "panel-applet-frame-activating");
+ g_object_set_data (G_OBJECT (frame), "panel-applet-frame-activating", NULL);
+
+ /* according to the source of bonobo control == NULL && no
+ exception can happen, so handle it */
+ if (error_reason != NULL || object == CORBA_OBJECT_NIL) {
+ gerror = g_error_new_literal (panel_applet_frame_bonobo_error_quark (), 0, error_reason);
+ goto error_out;
+ }
+
+ CORBA_exception_init (&corba_ev);
+
+ item_name = panel_applet_frame_construct_item (frame,
+ frame_act);
+
+ bonobo_frame->priv->control = CORBA_OBJECT_NIL;
+ container = Bonobo_Unknown_queryInterface (object,
+ "IDL:Bonobo/ItemContainer:1.0",
+ &corba_ev);
+ if (!BONOBO_EX (&corba_ev) && container != CORBA_OBJECT_NIL) {
+ Bonobo_Unknown containee;
+
+ containee = Bonobo_ItemContainer_getObjectByName (container,
+ item_name,
+ TRUE,
+ &corba_ev);
+ bonobo_object_release_unref (container, NULL);
+
+ if (!BONOBO_EX (&corba_ev) && containee != CORBA_OBJECT_NIL) {
+ bonobo_frame->priv->control =
+ Bonobo_Unknown_queryInterface (containee,
+ "IDL:Bonobo/Control:1.0",
+ &corba_ev);
+
+ bonobo_object_release_unref (containee, NULL);
+ }
+ }
+ g_free (item_name);
+
+ if (bonobo_frame->priv->control == CORBA_OBJECT_NIL) {
+ error = bonobo_exception_get_text (&corba_ev);
+ gerror = g_error_new (panel_applet_frame_bonobo_error_quark (), 0, "failed to get Bonobo/Control interface:\n", error);
+ CORBA_exception_free (&corba_ev);
+ bonobo_object_release_unref (object, NULL);
+ g_free (error);
+ goto error_out;
+ }
+
+ widget = bonobo_widget_new_control_from_objref (bonobo_frame->priv->control,
+ CORBA_OBJECT_NIL);
+
+ CORBA_exception_free (&corba_ev);
+ bonobo_object_release_unref (object, NULL);
+
+ if (!widget) {
+ gerror = g_error_new_literal (panel_applet_frame_bonobo_error_quark (), 0, "no widget created");
+ goto error_out;
+ }
+
+ control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (widget));
+ if (control_frame == NULL) {
+ gerror = g_error_new_literal (panel_applet_frame_bonobo_error_quark (), 0, "cannot get control frame");
+ goto error_out;
+ }
+
+ bonobo_frame->priv->property_bag =
+ bonobo_control_frame_get_control_property_bag (control_frame,
+ &corba_ev);
+ if (bonobo_frame->priv->property_bag == NULL || BONOBO_EX (&corba_ev)) {
+ error = bonobo_exception_get_text (&corba_ev);
+ CORBA_exception_free (&corba_ev);
+ gerror = g_error_new (panel_applet_frame_bonobo_error_quark (), 0, "cannot get property bag frame:\n%s", error);
+ g_free (error);
+ goto error_out;
+ }
+
+ bonobo_event_source_client_add_listener (bonobo_frame->priv->property_bag,
+ (BonoboListenerCallbackFn) panel_applet_frame_event_listener,
+ "Bonobo/Property:change:panel-applet",
+ NULL,
+ frame);
+
+ bonobo_frame->priv->ui_component =
+ bonobo_control_frame_get_popup_component (control_frame,
+ &corba_ev);
+ if (bonobo_frame->priv->ui_component == NULL || BONOBO_EX (&corba_ev)) {
+ error = bonobo_exception_get_text (&corba_ev);
+ CORBA_exception_free (&corba_ev);
+ gerror = g_error_new (panel_applet_frame_bonobo_error_quark (), 0, "cannot get popup component:\n%s", error);
+ g_free (error);
+ goto error_out;
+ }
+
+ bonobo_ui_util_set_ui (bonobo_frame->priv->ui_component, DATADIR,
+ "GNOME_Panel_Popup.xml", "panel", NULL);
+
+ bonobo_ui_component_add_listener (bonobo_frame->priv->ui_component,
+ "LockAppletToPanel",
+ listener_popup_handle_lock,
+ frame);
+
+ bonobo_ui_component_add_verb_list_with_data (
+ bonobo_frame->priv->ui_component, popup_verbs, frame);
+
+ control = bonobo_control_frame_get_control (control_frame);
+ if (!control) {
+ CORBA_exception_free (&corba_ev);
+ gerror = g_error_new_literal (panel_applet_frame_bonobo_error_quark (), 0, "cannot get control");
+ goto error_out;
+ }
+
+ bonobo_frame->priv->applet_shell = panel_applet_frame_get_applet_shell (control);
+ if (bonobo_frame->priv->applet_shell == CORBA_OBJECT_NIL) {
+ CORBA_exception_free (&corba_ev);
+ gerror = g_error_new_literal (panel_applet_frame_bonobo_error_quark (), 0, "cannot get applet shell");
+ goto error_out;
+ }
+
+ CORBA_exception_free (&corba_ev);
+
+ ORBit_small_listen_for_broken (object,
+ G_CALLBACK (panel_applet_frame_bonobo_applet_broken),
+ frame);
+
+ gtk_container_add (GTK_CONTAINER (frame), widget);
+
+ goto out;
+
+error_out:
+ if (widget)
+ g_object_unref (widget);
+ if (!gerror)
+ gerror = g_error_new_literal (panel_applet_frame_bonobo_error_quark (), 0, "unknown error");
+
+out:
+ _panel_applet_frame_activated (frame, frame_act, gerror);
+}
+
+gboolean
+panel_applet_frame_bonobo_load (const gchar *iid,
+ PanelAppletFrameActivating *frame_act)
+{
+ PanelAppletFrameBonobo *bonobo_frame;
+ PanelAppletFrame *frame;
+ CORBA_Environment ev;
+
+ g_return_val_if_fail (iid != NULL, FALSE);
+ g_return_val_if_fail (frame_act != NULL, FALSE);
+
+ if (!panel_applets_manager_factory_activate (iid))
+ return FALSE;
+
+ bonobo_frame = g_object_new (PANEL_TYPE_APPLET_FRAME_BONOBO, NULL);
+ frame = PANEL_APPLET_FRAME (bonobo_frame);
+ _panel_applet_frame_set_iid (frame, iid);
+
+ g_object_set_data (G_OBJECT (frame), "panel-applet-frame-activating", frame_act);
+
+ CORBA_exception_init (&ev);
+
+ bonobo_activation_activate_from_id_async ((gchar *) iid, 0,
+ (BonoboActivationCallback) panel_applet_frame_bonobo_activated,
+ frame, &ev);
+
+ CORBA_exception_free (&ev);
+
+ return TRUE;
+}
diff --git a/bonobo/panel-module/panel-applet-frame-bonobo.h b/bonobo/panel-module/panel-applet-frame-bonobo.h
new file mode 100644
index 0000000..457c4e2
--- /dev/null
+++ b/bonobo/panel-module/panel-applet-frame-bonobo.h
@@ -0,0 +1,61 @@
+/*
+ * panel-applet-frame-bonobo.h: panel side container for applets
+ *
+ * Copyright (C) 2001 - 2003 Sun Microsystems, Inc.
+ * Copyright (C) 2010 Vincent Untz <vuntz gnome org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Authors:
+ * Mark McLoughlin <mark skynet ie>
+ */
+
+#ifndef __PANEL_APPLET_FRAME_BONOBO_H__
+#define __PANEL_APPLET_FRAME_BONOBO_H__
+
+#include <panel-applet-frame.h>
+
+G_BEGIN_DECLS
+
+#define PANEL_TYPE_APPLET_FRAME_BONOBO (panel_applet_frame_bonobo_get_type ())
+#define PANEL_APPLET_FRAME_BONOBO(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PANEL_TYPE_APPLET_FRAME_BONOBO, PanelAppletFrameBonobo))
+#define PANEL_APPLET_FRAME_BONOBO_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PANEL_TYPE_APPLET_FRAME_BONOBO, PanelAppletFrameBonoboClass))
+#define PANEL_IS_APPLET_FRAME_BONOBO(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PANEL_TYPE_APPLET_FRAME_BONOBO))
+#define PANEL_IS_APPLET_FRAME_BONOBO_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PANEL_TYPE_APPLET_FRAME_BONOBO))
+#define PANEL_APPLET_FRAME_BONOBO_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PANEL_TYPE_APPLET_FRAME_BONOBO, PanelAppletFrameBonoboClass))
+
+typedef struct _PanelAppletFrameBonobo PanelAppletFrameBonobo;
+typedef struct _PanelAppletFrameBonoboClass PanelAppletFrameBonoboClass;
+typedef struct _PanelAppletFrameBonoboPrivate PanelAppletFrameBonoboPrivate;
+
+struct _PanelAppletFrameBonoboClass {
+ PanelAppletFrameClass parent_class;
+};
+
+struct _PanelAppletFrameBonobo{
+ PanelAppletFrame parent;
+
+ PanelAppletFrameBonoboPrivate *priv;
+};
+
+GType panel_applet_frame_bonobo_get_type (void) G_GNUC_CONST;
+
+gboolean panel_applet_frame_bonobo_load (const gchar *iid,
+ PanelAppletFrameActivating *frame_act);
+
+G_END_DECLS
+
+#endif /* __PANEL_APPLET_FRAME_BONOBO_H__ */
diff --git a/bonobo/panel-module/panel-applets-bonobo-module.c b/bonobo/panel-module/panel-applets-bonobo-module.c
new file mode 100644
index 0000000..74365cf
--- /dev/null
+++ b/bonobo/panel-module/panel-applets-bonobo-module.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 Novell, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Author: Vincent Untz <vuntz gnome org>
+ */
+
+#include "config.h"
+
+#include <gio/gio.h>
+
+#include <panel-applets-manager.h>
+#include "panel-applets-manager-bonobo.h"
+
+void
+g_io_module_load (GIOModule *module)
+{
+ panel_applets_manager_bonobo_register (module);
+}
+
+void
+g_io_module_unload (GIOModule *module)
+{
+}
+
+char **
+g_io_module_query (void)
+{
+ char *eps[] = {
+ PANEL_APPLETS_MANAGER_EXTENSION_POINT_NAME,
+ NULL
+ };
+ return g_strdupv (eps);
+}
diff --git a/bonobo/panel-module/panel-applets-manager-bonobo.c b/bonobo/panel-module/panel-applets-manager-bonobo.c
new file mode 100644
index 0000000..c101fbe
--- /dev/null
+++ b/bonobo/panel-module/panel-applets-manager-bonobo.c
@@ -0,0 +1,248 @@
+/*
+ * panel-applets-manager-bonobo.c
+ *
+ * Copyright (C) 2010 Vincent Untz <vuntz gnome org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+#include <libbonobo.h>
+
+#include <panel-applets-manager.h>
+
+#include "panel-applet-frame-bonobo.h"
+
+#include "panel-applets-manager-bonobo.h"
+
+G_DEFINE_DYNAMIC_TYPE (PanelAppletsManagerBonobo, panel_applets_manager_bonobo, PANEL_TYPE_APPLETS_MANAGER);
+
+struct _PanelAppletsManagerBonoboPrivate
+{
+ GHashTable *applets;
+};
+
+static const char applet_requirements [] =
+ "has_all (repo_ids, ['IDL:Bonobo/Control:1.0',"
+ " 'IDL:GNOME/Vertigo/PanelAppletShell:1.0']) && "
+ "defined (panel:icon)";
+
+static char *applet_sort_criteria [] = {
+ "name",
+ NULL
+ };
+
+static void
+panel_applets_manager_bonobo_load_applet_infos (PanelAppletsManagerBonobo *manager)
+{
+ Bonobo_ServerInfoList *applet_list;
+ CORBA_Environment env;
+ const char * const *langs;
+ GSList *langs_gslist;
+ int i;
+
+ CORBA_exception_init (&env);
+
+ applet_list = bonobo_activation_query (applet_requirements,
+ applet_sort_criteria,
+ &env);
+ if (BONOBO_EX (&env)) {
+ g_warning ("Bonobo query returned exception %s\n",
+ BONOBO_EX_REPOID (&env));
+
+ CORBA_exception_free (&env);
+ CORBA_free (applet_list);
+
+ return;
+ }
+
+ CORBA_exception_free (&env);
+
+ langs = g_get_language_names ();
+
+ langs_gslist = NULL;
+ for (i = 0; langs[i]; i++)
+ langs_gslist = g_slist_prepend (langs_gslist, (char *) langs[i]);
+
+ langs_gslist = g_slist_reverse (langs_gslist);
+
+ for (i = 0; i < applet_list->_length; i++) {
+ Bonobo_ServerInfo *info;
+ const char *name, *description, *icon;
+ PanelAppletInfo *applet_info;
+
+ info = &applet_list->_buffer[i];
+
+ name = bonobo_server_info_prop_lookup (info,
+ "name",
+ langs_gslist);
+ description = bonobo_server_info_prop_lookup (info,
+ "description",
+ langs_gslist);
+ icon = bonobo_server_info_prop_lookup (info,
+ "panel:icon",
+ NULL);
+
+ applet_info = panel_applet_info_new (info->iid, name, description, icon, NULL);
+
+ g_hash_table_insert (manager->priv->applets, g_strdup (info->iid), applet_info);
+ }
+
+ g_slist_free (langs_gslist);
+ CORBA_free (applet_list);
+}
+
+static GList *
+panel_applets_manager_bonobo_get_applets (PanelAppletsManager *manager)
+{
+ PanelAppletsManagerBonobo *bonobo_manager = PANEL_APPLETS_MANAGER_BONOBO (manager);
+
+ GHashTableIter iter;
+ gpointer key, value;
+ GList *retval = NULL;
+
+ g_hash_table_iter_init (&iter, bonobo_manager->priv->applets);
+ while (g_hash_table_iter_next (&iter, &key, &value))
+ retval = g_list_prepend (retval, value);
+
+ return g_list_reverse (retval);;
+}
+
+static gboolean
+panel_applets_manager_bonobo_factory_activate (PanelAppletsManager *manager,
+ const gchar *iid)
+{
+ PanelAppletsManagerBonobo *bonobo_manager = PANEL_APPLETS_MANAGER_BONOBO (manager);
+ PanelAppletInfo *info;
+
+ /* we let bonobo deal with that, but we need to return the right value */
+
+ info = g_hash_table_lookup (bonobo_manager->priv->applets, iid);
+
+ return (info != NULL);
+}
+
+static gboolean
+panel_applets_manager_bonobo_factory_deactivate (PanelAppletsManager *manager,
+ const gchar *iid)
+{
+ PanelAppletsManagerBonobo *bonobo_manager = PANEL_APPLETS_MANAGER_BONOBO (manager);
+ PanelAppletInfo *info;
+
+ /* we let bonobo deal with that, but we need to return the right value */
+
+ info = g_hash_table_lookup (bonobo_manager->priv->applets, iid);
+
+ return (info != NULL);
+}
+
+static PanelAppletInfo *
+panel_applets_manager_bonobo_get_applet_info (PanelAppletsManager *manager,
+ const gchar *iid)
+{
+ PanelAppletsManagerBonobo *bonobo_manager = PANEL_APPLETS_MANAGER_BONOBO (manager);
+
+ return g_hash_table_lookup (bonobo_manager->priv->applets, iid);
+}
+
+static PanelAppletInfo *
+panel_applets_manager_bonobo_get_applet_info_from_old_id (PanelAppletsManager *manager,
+ const gchar *iid)
+{
+ return NULL;
+}
+
+static gboolean
+panel_applets_manager_bonobo_load_applet (PanelAppletsManager *manager,
+ const gchar *iid,
+ PanelAppletFrameActivating *frame_act)
+{
+ return panel_applet_frame_bonobo_load (iid, frame_act);
+}
+
+static void
+panel_applets_manager_bonobo_finalize (GObject *object)
+{
+ PanelAppletsManagerBonobo *manager = PANEL_APPLETS_MANAGER_BONOBO (object);
+
+ if (manager->priv->applets) {
+ g_hash_table_destroy (manager->priv->applets);
+ manager->priv->applets = NULL;
+ }
+
+ G_OBJECT_CLASS (panel_applets_manager_bonobo_parent_class)->finalize (object);
+}
+
+static void
+panel_applets_manager_bonobo_init (PanelAppletsManagerBonobo *manager)
+{
+ manager->priv = G_TYPE_INSTANCE_GET_PRIVATE (manager,
+ PANEL_TYPE_APPLETS_MANAGER_BONOBO,
+ PanelAppletsManagerBonoboPrivate);
+
+ manager->priv->applets = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) panel_applet_info_free);
+
+ panel_applets_manager_bonobo_load_applet_infos (manager);
+}
+
+static void
+panel_applets_manager_bonobo_class_finalize (PanelAppletsManagerBonoboClass *class)
+{
+}
+
+static void
+panel_applets_manager_bonobo_class_init (PanelAppletsManagerBonoboClass *class)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+ PanelAppletsManagerClass *manager_class = PANEL_APPLETS_MANAGER_CLASS (class);
+
+ /* This is a horrible hack: we shouldn't call bonobo_init() here, but
+ * in g_io_module_load() or even
+ * panel_applets_manager_bonobo_register(). However, it looks like if
+ * there's no giomodule.cache file, the module gets unloaded, and
+ * bonobo_init() gets called twice, which makes everythings goes wrong:
+ * bonobo has been unloaded so believes it has to get initialized, but
+ * the types are already registered in the GType system. And bam. */
+
+ bonobo_init (NULL, NULL);
+
+ gobject_class->finalize = panel_applets_manager_bonobo_finalize;
+
+ manager_class->get_applets = panel_applets_manager_bonobo_get_applets;
+ manager_class->factory_activate = panel_applets_manager_bonobo_factory_activate;
+ manager_class->factory_deactivate = panel_applets_manager_bonobo_factory_deactivate;
+ manager_class->get_applet_info = panel_applets_manager_bonobo_get_applet_info;
+ manager_class->get_applet_info_from_old_id = panel_applets_manager_bonobo_get_applet_info_from_old_id;
+ manager_class->load_applet = panel_applets_manager_bonobo_load_applet;
+
+ g_type_class_add_private (class, sizeof (PanelAppletsManagerBonoboPrivate));
+}
+
+
+void
+panel_applets_manager_bonobo_register (GIOModule *module)
+{
+ panel_applets_manager_bonobo_register_type (G_TYPE_MODULE (module));
+ g_io_extension_point_implement (PANEL_APPLETS_MANAGER_EXTENSION_POINT_NAME,
+ PANEL_TYPE_APPLETS_MANAGER_BONOBO,
+ "bonobo",
+ 10);
+}
diff --git a/bonobo/panel-module/panel-applets-manager-bonobo.h b/bonobo/panel-module/panel-applets-manager-bonobo.h
new file mode 100644
index 0000000..6403f99
--- /dev/null
+++ b/bonobo/panel-module/panel-applets-manager-bonobo.h
@@ -0,0 +1,55 @@
+/*
+ * panel-applets-manager-bonobo.h
+ *
+ * Copyright (C) 2010 Vincent Untz <vuntz gnome org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef __PANEL_APPLETS_MANAGER_BONOBO_H__
+#define __PANEL_APPLETS_MANAGER_BONOBO_H__
+
+#include <panel-applets-manager.h>
+
+G_BEGIN_DECLS
+
+#define PANEL_TYPE_APPLETS_MANAGER_BONOBO (panel_applets_manager_bonobo_get_type ())
+#define PANEL_APPLETS_MANAGER_BONOBO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PANEL_TYPE_APPLETS_MANAGER_BONOBO, PanelAppletsManagerBonobo))
+#define PANEL_APPLETS_MANAGER_BONOBO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANEL_TYPE_APPLETS_MANAGER_BONOBO, PanelAppletsManagerBonoboClass))
+#define PANEL_IS_APPLETS_MANAGER_BONOBO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PANEL_TYPE_APPLETS_MANAGER_BONOBO))
+#define PANEL_IS_APPLETS_MANAGER_BONOBO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANEL_TYPE_APPLETS_MANAGER_BONOBO))
+#define PANEL_APPLETS_MANAGER_BONOBO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PANEL_TYPE_APPLETS_MANAGER_BONOBO, PanelAppletsManagerBonoboClass))
+
+typedef struct _PanelAppletsManagerBonobo PanelAppletsManagerBonobo;
+typedef struct _PanelAppletsManagerBonoboClass PanelAppletsManagerBonoboClass;
+typedef struct _PanelAppletsManagerBonoboPrivate PanelAppletsManagerBonoboPrivate;
+
+struct _PanelAppletsManagerBonoboClass {
+ PanelAppletsManagerClass parent_class;
+};
+
+struct _PanelAppletsManagerBonobo {
+ PanelAppletsManager parent;
+
+ /*< private > */
+ PanelAppletsManagerBonoboPrivate *priv;
+};
+
+GType panel_applets_manager_bonobo_get_type (void);
+
+G_END_DECLS
+
+#endif /* __PANEL_APPLETS_MANAGER_BONOBO_H__ */
diff --git a/configure.in b/configure.in
index 806c8e4..b490a8d 100644
--- a/configure.in
+++ b/configure.in
@@ -273,6 +273,59 @@ AC_SUBST([modulesdir],"\$(libdir)/gnome-panel/modules")
dnl Applets dir
AC_SUBST([appletsdir],"\$(datadir)/gnome-panel/applets")
+dnl
+dnl Temporary bonobo checks here
+dnl
+
+LIB_PANEL_APPLET_BONOBO_LT_VERSION=2:67:2
+AC_SUBST(LIB_PANEL_APPLET_BONOBO_LT_VERSION)
+
+LIBBONOBOUI_REQUIRED=2.1.1
+ORBIT_REQUIRED=2.4.0
+
+AC_ARG_ENABLE(bonobo,
+ AS_HELP_STRING([--enable-bonobo],[Enable Bonobo compatibility modules (auto)]),
+ enable_bonobo=$enableval,
+ enable_bonobo=auto)
+
+BONOBO_CFLAGS=
+BONOBO_LIBS=
+LIBPANEL_APPLET_BONOBO_CFLAGS=
+LIBPANEL_APPLET_BONOBO_LIBS=
+ORBIT_IDL=
+BONOBO_IDLDIR=
+BONOBO_ACT_IDLDIR=
+
+if test "x$enable_bonobo" = "xno" ; then
+ HAVE_BONOBO=no
+else
+ HAVE_BONOBO=no
+ PKG_CHECK_MODULES(BONOBO, ORBit-2.0 >= $ORBIT_REQUIRED libbonoboui-2.0 >= $LIBBONOBOUI_REQUIRED, HAVE_BONOBO=yes, HAVE_BONOBO=no)
+
+ if test "x$enable_bonobo" = "xyes" -a "x$HAVE_BONOBO" = "xno" ; then
+ AC_MSG_ERROR(Bonobo compatibility modules explicity enabled but not available)
+ fi
+
+ PKG_CHECK_MODULES(PANEL_MODULE_BONOBO, ORBit-2.0 >= $ORBIT_REQUIRED libbonoboui-2.0 >= $LIBBONOBOUI_REQUIRED)
+ PKG_CHECK_MODULES(LIBPANEL_APPLET_BONOBO, ORBit-2.0 >= $ORBIT_REQUIRED gtk+-2.0 >= $GTK_REQUIRED libbonoboui-2.0 >= $LIBBONOBOUI_REQUIRED gconf-2.0 >= $GCONF_REQUIRED)
+
+ dnl IDL directories
+ ORBIT_IDL="`$PKG_CONFIG --variable=orbit_idl ORBit-2.0`"
+ BONOBO_IDLDIR="`$PKG_CONFIG --variable=idldir libbonobo-2.0`"
+ BONOBO_ACT_IDLDIR="`$PKG_CONFIG --variable=idldir bonobo-activation-2.0`"
+
+ AC_PATH_PROG(GIO_QUERYMODULES, gio-querymodules, no)
+fi
+
+AM_CONDITIONAL(HAVE_BONOBO, test "x$HAVE_BONOBO" = "xyes")
+AC_SUBST(BONOBO_CFLAGS)
+AC_SUBST(BONOBO_LIBS)
+AC_SUBST(LIBPANEL_APPLET_BONOBO_CFLAGS)
+AC_SUBST(LIBPANEL_APPLET_BONOBO_LIBS)
+AC_SUBST(ORBIT_IDL)
+AC_SUBST(BONOBO_IDLDIR)
+AC_SUBST(BONOBO_ACT_IDLDIR)
+
dnl Language Support
GETTEXT_PACKAGE=gnome-panel-2.0
@@ -346,6 +399,12 @@ help/Makefile
help/clock/Makefile
help/fish/Makefile
man/Makefile
+bonobo/Makefile
+bonobo/idl/Makefile
+bonobo/libpanel-applet/libpanelapplet-2.0.pc
+bonobo/libpanel-applet/libpanelapplet-2.0-uninstalled.pc
+bonobo/libpanel-applet/Makefile
+bonobo/panel-module/Makefile
])
if echo foo | xgettext --from-code=UTF-8 -LC -o - - 2>/dev/null ; then
diff --git a/gnome-panel/libpanel-applet-private/panel-applets-manager-dbus.c b/gnome-panel/libpanel-applet-private/panel-applets-manager-dbus.c
index 6f3e208..e97b6ad 100644
--- a/gnome-panel/libpanel-applet-private/panel-applets-manager-dbus.c
+++ b/gnome-panel/libpanel-applet-private/panel-applets-manager-dbus.c
@@ -38,7 +38,7 @@ G_DEFINE_TYPE_WITH_CODE (PanelAppletsManagerDBus,
g_io_extension_point_implement (PANEL_APPLETS_MANAGER_EXTENSION_POINT_NAME,
g_define_type_id,
"dbus",
- 5))
+ 10))
struct _PanelAppletsManagerDBusPrivate
{
diff --git a/gnome-panel/panel-applet-info.c b/gnome-panel/panel-applet-info.c
index 4c376d9..2d8dc6d 100644
--- a/gnome-panel/panel-applet-info.c
+++ b/gnome-panel/panel-applet-info.c
@@ -52,14 +52,16 @@ panel_applet_info_new (const gchar *iid,
info->icon = g_strdup (icon);
/* Bonobo compatibility */
- len = g_strv_length ((gchar **) old_ids);
- if (len > 0) {
- int i;
+ if (old_ids != NULL) {
+ len = g_strv_length ((gchar **) old_ids);
+ if (len > 0) {
+ int i;
- info->old_ids = g_new0 (gchar *, len + 1);
+ info->old_ids = g_new0 (gchar *, len + 1);
- for (i = 0; i < len; i++)
- info->old_ids[i] = g_strdup (old_ids[i]);
+ for (i = 0; i < len; i++)
+ info->old_ids[i] = g_strdup (old_ids[i]);
+ }
}
return info;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]