[gnome-panel/bonobo-less] Remove bonobo dependency
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/bonobo-less] Remove bonobo dependency
- Date: Mon, 22 Feb 2010 13:45:51 +0000 (UTC)
commit 060e36388809aa4a6ce35bd602ab865c47d3b529
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Sat Feb 20 10:31:28 2010 +0100
Remove bonobo dependency
Libpanel-applet and gnome-panel have been ported to dbus and the applets
have been migrated to the new libpanel-applet API.
See bug #572131.
Makefile.am | 2 +-
applets/clock/GNOME_ClockApplet.panel-applet.in.in | 18 +
applets/clock/GNOME_ClockApplet.xml | 28 +-
.../clock/GNOME_ClockApplet_Factory.server.in.in | 35 -
applets/clock/Makefile.am | 44 +-
applets/clock/clock.c | 149 ++--
...nome.panel.applet.ClockAppletFactory.service.in | 3 +
applets/fish/GNOME_FishApplet.panel-applet.in.in | 17 +
applets/fish/GNOME_FishApplet.xml | 16 +-
applets/fish/GNOME_FishApplet_Factory.server.in.in | 36 -
applets/fish/Makefile.am | 35 +-
applets/fish/fish.c | 83 +-
...gnome.panel.applet.FishAppletFactory.service.in | 3 +
...GNOME_NotificationAreaApplet.panel-applet.in.in | 17 +
.../GNOME_NotificationAreaApplet.server.in.in | 56 -
.../GNOME_NotificationAreaApplet.xml | 13 +-
applets/notification_area/Makefile.am | 48 +-
applets/notification_area/main.c | 73 +-
...applet.NotificationAreaAppletFactory.service.in | 3 +
applets/wncklet/GNOME_ShowDesktopApplet.xml | 13 +-
applets/wncklet/GNOME_WindowListApplet.xml | 18 +-
applets/wncklet/GNOME_WindowMenuApplet.xml | 13 +-
applets/wncklet/GNOME_Wncklet.panel-applet.in.in | 50 +
applets/wncklet/GNOME_Wncklet_Factory.server.in.in | 134 --
applets/wncklet/GNOME_WorkspaceSwitcherApplet.xml | 16 +-
applets/wncklet/Makefile.am | 43 +-
...rg.gnome.panel.applet.WnckletFactory.service.in | 3 +
applets/wncklet/showdesktop.c | 50 +-
applets/wncklet/window-list.c | 74 +-
applets/wncklet/window-menu.c | 37 +-
applets/wncklet/wncklet.c | 33 +-
applets/wncklet/workspace-switcher.c | 77 +-
configure.in | 25 +-
data/Makefile.am | 3 +
data/panel-applet.xml | 35 +
gnome-panel/GNOME_Panel_Popup.xml | 20 -
gnome-panel/Makefile.am | 48 +-
gnome-panel/main.c | 10 +-
gnome-panel/panel-addto.c | 73 +-
gnome-panel/panel-applet-container.c | 1172 +++++++++++++++++
gnome-panel/panel-applet-container.h | 191 +++
gnome-panel/panel-applet-frame.c | 1089 ++++++-----------
gnome-panel/panel-applet-frame.h | 39 +-
gnome-panel/panel-applets-manager.c | 548 ++++++++
gnome-panel/panel-applets-manager.h | 49 +
gnome-panel/panel-compatibility.c | 49 +-
gnome-panel/panel-compatibility.h | 2 +
gnome-panel/panel-object.schemas.in | 15 +
gnome-panel/panel-types.h | 11 -
gnome-panel/xstuff.c | 21 +
idl/ChangeLog.pre-git | 497 --------
idl/GNOME_Panel.idl | 51 -
idl/Makefile.am | 7 -
.../GNOME_Panel_TestApplet.panel-applet.in | 10 +
libpanel-applet/GNOME_Panel_TestApplet.server.in | 31 -
libpanel-applet/Makefile.am | 92 +-
.../libpanelapplet-2.0-uninstalled.pc.in | 2 +-
libpanel-applet/libpanelapplet-2.0.pc.in | 2 +-
libpanel-applet/panel-applet-factory.c | 228 ++++
libpanel-applet/panel-applet-factory.h | 45 +
libpanel-applet/panel-applet-factory.xml | 14 +
libpanel-applet/panel-applet-gconf.c | 1 -
libpanel-applet/panel-applet-private.h | 36 -
libpanel-applet/panel-applet-shell.c | 105 --
libpanel-applet/panel-applet-shell.h | 62 -
libpanel-applet/panel-applet.c | 1333 +++++++++++---------
libpanel-applet/panel-applet.h | 104 +--
libpanel-applet/panel-test-applets.c | 266 +++--
.../{test-bonobo-applet.c => test-dbus-applet.c} | 139 ++-
po/POTFILES.in | 18 +-
70 files changed, 4404 insertions(+), 3279 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index ac41bbb..ebeb1c8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
SUBDIRS = \
po \
- idl \
+ data \
icons \
gnome-panel \
libpanel-applet \
diff --git a/applets/clock/GNOME_ClockApplet.panel-applet.in.in b/applets/clock/GNOME_ClockApplet.panel-applet.in.in
new file mode 100644
index 0000000..6840054
--- /dev/null
+++ b/applets/clock/GNOME_ClockApplet.panel-applet.in.in
@@ -0,0 +1,18 @@
+[Applet Factory]
+Id=ClockAppletFactory
+InProcess= IN_PROCESS@
+Location= LOCATION@
+_Name=Clock Applet Factory
+_Description=Factory for creating clock applets.
+
+[ClockApplet]
+_Name=Clock
+_Description=Get the current time and date
+Icon=gnome-panel-clock
+BonoboId=OAFIID:GNOME_ClockApplet
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=gnome-panel
+X-GNOME-Bugzilla-Component=clock
+X-GNOME-Bugzilla-Version= VERSION@
+X-GNOME-Bugzilla-OtherBinaries=clock-applet
+
diff --git a/applets/clock/GNOME_ClockApplet.xml b/applets/clock/GNOME_ClockApplet.xml
index 73fd314..abe0e07 100644
--- a/applets/clock/GNOME_ClockApplet.xml
+++ b/applets/clock/GNOME_ClockApplet.xml
@@ -1,20 +1,8 @@
-<Root>
- <popups>
- <popup name="button3">
- <menuitem name="Clock Copy Time Item" verb="ClockCopyTime" _label="Copy _Time"
- pixtype="stock" pixname="gtk-copy"/>
- <menuitem name="Clock Copy Date Item" verb="ClockCopyDate" _label="Copy _Date"
- pixtype="stock" pixname="gtk-copy"/>
- <separator/>
- <menuitem name="Clock Configure Item" verb="ClockConfig"
- _label="Ad_just Date & Time"
- pixtype="stock" pixname="gtk-preferences"/>
- <menuitem name="Clock Preferences Item" verb="ClockPreferences" _label="_Preferences"
- pixtype="stock" pixname="gtk-properties"/>
- <menuitem name="Clock Help Item" verb="ClockHelp" _label="_Help"
- pixtype="stock" pixname="gtk-help"/>
- <menuitem name="Clock About Item" verb="ClockAbout" _label="_About"
- pixtype="stock" pixname="gtk-about"/>
- </popup>
- </popups>
-</Root>
+<menuitem name="Clock Copy Time Item" action="ClockCopyTime" />
+<menuitem name="Clock Copy Date Item" action="ClockCopyDate" />
+<separator/>
+<menuitem name="Clock Configure Item" action="ClockConfig" />
+<menuitem name="Clock Preferences Item" action="ClockPreferences" />
+<menuitem name="Clock Help Item" action="ClockHelp" />
+<menuitem name="Clock About Item" action="ClockAbout" />
+
diff --git a/applets/clock/Makefile.am b/applets/clock/Makefile.am
index 7a6b931..6e940ff 100644
--- a/applets/clock/Makefile.am
+++ b/applets/clock/Makefile.am
@@ -11,6 +11,7 @@ INCLUDES = \
$(LIBPANEL_APPLET_CFLAGS) \
-DDATADIR=\""$(datadir)"\" \
-DBUILDERDIR=\""$(uidir)"\" \
+ -DCLOCK_MENU_UI_DIR=\""$(xmluidir)"\" \
-DICONDIR=\""$(datadir)/gnome-panel/pixmaps"\" \
-DLIBDIR=\""$(libdir)"\" \
-DSYSCONFDIR=\""$(sysconfdir)"\" \
@@ -137,8 +138,8 @@ gnome_clock_applet_mechanism_LDADD = \
$(POLKIT_LIBS)
if CLOCK_INPROCESS
-APPLET_TYPE = shlib
-APPLET_LOCATION = $(pkglibdir)/libclock-applet.so
+APPLET_IN_PROCESS = true
+APPLET_LOCATION = $(pkglibdir)/libclock-applet.so
clock_appletlibdir = $(pkglibdir)
clock_appletlib_LTLIBRARIES = libclock-applet.la
@@ -150,7 +151,7 @@ $(libclock_applet_la_OBJECTS): $(BUILT_SOURCES)
libexec_PROGRAMS =
else
-APPLET_TYPE = exe
+APPLET_IN_PROCESS = false
APPLET_LOCATION = $(libexecdir)/clock-applet
libexec_PROGRAMS = clock-applet
@@ -170,18 +171,29 @@ ui_DATA = clock.ui
xmluidir = $(datadir)/gnome-2.0/ui
xmlui_DATA = GNOME_ClockApplet.xml
-serverdir = $(libdir)/bonobo/servers
-server_in_files = GNOME_ClockApplet_Factory.server.in
-server_DATA = $(server_in_files:.server.in=.server)
+appletdir = $(datadir)/gnome-panel/applets
+applet_in_files = GNOME_ClockApplet.panel-applet.in
+applet_DATA = $(applet_in_files:.panel-applet.in=.panel-applet)
-$(server_in_files): $(server_in_files).in Makefile
+$(applet_in_files): $(applet_in_files).in Makefile
$(AM_V_GEN)sed \
- -e "s|\ LOCATION\@|$(APPLET_LOCATION)|" \
- -e "s|\ TYPE\@|$(APPLET_TYPE)|" \
- -e "s|\ VERSION\@|$(PACKAGE_VERSION)|" \
- $< > $@
+ -e "s|\ LOCATION\@|$(APPLET_LOCATION)|" \
+ -e "s|\ IN_PROCESS\@|$(APPLET_IN_PROCESS)|" \
+ -e "s|\ VERSION\@|$(PACKAGE_VERSION)|" \
+ $< > $@
- INTLTOOL_SERVER_RULE@
+ PANEL_INTLTOOL_PANEL_APPLET_RULE@
+
+if !CLOCK_INPROCESS
+servicedir = $(datadir)/dbus-1/services
+service_in_files = org.gnome.panel.applet.ClockAppletFactory.service.in
+service_DATA = $(service_in_files:.service.in=.service)
+
+org.gnome.panel.applet.ClockAppletFactory.service: $(service_in_files)
+ $(AM_V_GEN)sed \
+ -e "s|\ LOCATION\@|$(APPLET_LOCATION)|" \
+ $< > $@
+endif
schemasdir = $(GCONF_SCHEMA_FILE_DIR)
schemas_in_files = clock.schemas.in
@@ -238,11 +250,12 @@ test_system_timezone_LDADD = \
$(NULL)
EXTRA_DIST = \
- GNOME_ClockApplet_Factory.server.in.in \
+ GNOME_ClockApplet.panel-applet.in.in \
$(schemas_in_files) \
$(xmlui_DATA) \
$(ui_DATA) \
clock-marshallers.list \
+ $(service_in_files) \
$(dbus_services_in_files) \
org.gnome.ClockApplet.Mechanism.conf \
$(polkit_in_files) \
@@ -250,8 +263,9 @@ EXTRA_DIST = \
CLEANFILES = \
$(BUILT_SOURCES) \
- $(server_in_files) \
- $(server_DATA) \
+ $(applet_DATA) \
+ $(applet_DATA).in \
+ $(service_DATA) \
$(schemas_DATA) \
$(polkit_DATA) \
$(dbus_services_DATA)
diff --git a/applets/clock/clock.c b/applets/clock/clock.c
index 84f456f..a20cb22 100644
--- a/applets/clock/clock.c
+++ b/applets/clock/clock.c
@@ -211,19 +211,16 @@ static float get_itime (time_t current_time);
static void set_atk_name_description (GtkWidget *widget,
const char *name,
const char *desc);
-static void verb_display_properties_dialog (BonoboUIComponent *uic,
- ClockData *cd,
- const gchar *verbname);
-
-static void display_properties_dialog (ClockData *cd,
- gboolean start_in_locations_page);
-static void display_help_dialog (BonoboUIComponent *uic,
- ClockData *cd,
- const gchar *verbname);
-static void display_about_dialog (BonoboUIComponent *uic,
- ClockData *cd,
- const gchar *verbname);
-static void position_calendar_popup (ClockData *cd);
+static void verb_display_properties_dialog (GtkAction *action,
+ ClockData *cd);
+
+static void display_properties_dialog (ClockData *cd,
+ gboolean start_in_locations_page);
+static void display_help_dialog (GtkAction *action,
+ ClockData *cd);
+static void display_about_dialog (GtkAction *action,
+ ClockData *cd);
+static void position_calendar_popup (ClockData *cd);
static void update_orient (ClockData *cd);
static void applet_change_orient (PanelApplet *applet,
PanelAppletOrient orient,
@@ -1532,9 +1529,8 @@ panel_button_change_pixel_size (GtkWidget *widget,
}
static void
-copy_time (BonoboUIComponent *uic,
- ClockData *cd,
- const gchar *verbname)
+copy_time (GtkAction *action,
+ ClockData *cd)
{
char string[256];
char *utf8;
@@ -1606,9 +1602,8 @@ copy_time (BonoboUIComponent *uic,
}
static void
-copy_date (BonoboUIComponent *uic,
- ClockData *cd,
- const gchar *verbname)
+copy_date (GtkAction *action,
+ ClockData *cd)
{
struct tm *tm;
char string[256];
@@ -1856,22 +1851,32 @@ run_time_settings (GtkWidget *unused, ClockData *cd)
}
static void
-config_date (BonoboUIComponent *uic,
- ClockData *cd,
- const char *verbname)
+config_date (GtkAction *action,
+ ClockData *cd)
{
run_time_settings (NULL, cd);
}
/* current timestamp */
-static const BonoboUIVerb clock_menu_verbs [] = {
- BONOBO_UI_UNSAFE_VERB ("ClockPreferences", verb_display_properties_dialog),
- BONOBO_UI_UNSAFE_VERB ("ClockHelp", display_help_dialog),
- BONOBO_UI_UNSAFE_VERB ("ClockAbout", display_about_dialog),
- BONOBO_UI_UNSAFE_VERB ("ClockCopyTime", copy_time),
- BONOBO_UI_UNSAFE_VERB ("ClockCopyDate", copy_date),
- BONOBO_UI_UNSAFE_VERB ("ClockConfig", config_date),
- BONOBO_UI_VERB_END
+static const GtkActionEntry clock_menu_actions [] = {
+ { "ClockPreferences", GTK_STOCK_PROPERTIES, N_("_Preferences"),
+ NULL, NULL,
+ G_CALLBACK (verb_display_properties_dialog) },
+ { "ClockHelp", GTK_STOCK_HELP, N_("_Help"),
+ NULL, NULL,
+ G_CALLBACK (display_help_dialog) },
+ { "ClockAbout", GTK_STOCK_ABOUT, N_("_About"),
+ NULL, NULL,
+ G_CALLBACK (display_about_dialog) },
+ { "ClockCopyTime", GTK_STOCK_COPY, N_("Copy _Time"),
+ NULL, NULL,
+ G_CALLBACK (copy_time) },
+ { "ClockCopyDate", GTK_STOCK_COPY, N_("Copy _Date"),
+ NULL, NULL,
+ G_CALLBACK (copy_date) },
+ { "ClockConfig", GTK_STOCK_PREFERENCES, N_("Ad_just Date & Time"),
+ NULL, NULL,
+ G_CALLBACK (config_date) }
};
static void
@@ -2569,10 +2574,12 @@ load_gconf_settings (ClockData *cd)
static gboolean
fill_clock_applet (PanelApplet *applet)
{
- ClockData *cd;
- BonoboUIComponent *popup_component;
- char *filename;
- GError *error;
+ ClockData *cd;
+ GtkActionGroup *action_group;
+ GtkAction *action;
+ gchar *ui_path;
+ char *filename;
+ GError *error;
panel_applet_add_preferences (applet, CLOCK_SCHEMA_DIR, NULL);
panel_applet_set_flags (applet, PANEL_APPLET_EXPAND_MINOR);
@@ -2624,34 +2631,32 @@ fill_clock_applet (PanelApplet *applet)
panel_applet_set_background_widget (PANEL_APPLET (cd->applet),
GTK_WIDGET (cd->applet));
+ action_group = gtk_action_group_new ("ClockApplet Menu Actions");
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (action_group,
+ clock_menu_actions,
+ G_N_ELEMENTS (clock_menu_actions),
+ cd);
+ ui_path = g_build_filename (CLOCK_MENU_UI_DIR, "GNOME_ClockApplet.xml", NULL);
panel_applet_setup_menu_from_file (PANEL_APPLET (cd->applet),
- NULL,
- "GNOME_ClockApplet.xml",
- NULL,
- clock_menu_verbs,
- cd);
-
- popup_component = panel_applet_get_popup_component (PANEL_APPLET (cd->applet));
+ ui_path, action_group);
+ g_free (ui_path);
if (panel_applet_get_locked_down (PANEL_APPLET (cd->applet))) {
- bonobo_ui_component_set_prop (popup_component,
- "/commands/ClockPreferences",
- "hidden", "1",
- NULL);
- bonobo_ui_component_set_prop (popup_component,
- "/commands/ClockConfig",
- "hidden", "1",
- NULL);
+ action = gtk_action_group_get_action (action_group, "ClockPreferences");
+ gtk_action_set_visible (action, FALSE);
+
+ action = gtk_action_group_get_action (action_group, "ClockConfig");
+ gtk_action_set_visible (action, FALSE);
}
cd->systz = system_timezone_new ();
g_signal_connect (cd->systz, "changed",
G_CALLBACK (clock_timezone_changed), cd);
- bonobo_ui_component_set_prop (popup_component,
- "/commands/ClockConfig",
- "hidden", can_set_system_time () ? "0" : "1",
- NULL);
+ action = gtk_action_group_get_action (action_group, "ClockConfig");
+ gtk_action_set_visible (action, can_set_system_time ());
+ g_object_unref (action_group);
return TRUE;
}
@@ -3624,25 +3629,22 @@ display_properties_dialog (ClockData *cd, gboolean start_in_locations_page)
}
static void
-verb_display_properties_dialog (BonoboUIComponent *uic,
- ClockData *cd,
- const gchar *verbname)
+verb_display_properties_dialog (GtkAction *action,
+ ClockData *cd)
{
display_properties_dialog (cd, FALSE);
}
static void
-display_help_dialog (BonoboUIComponent *uic,
- ClockData *cd,
- const gchar *verbname)
+display_help_dialog (GtkAction *action,
+ ClockData *cd)
{
clock_utils_display_help (cd->applet, "clock", NULL);
}
static void
-display_about_dialog (BonoboUIComponent *uic,
- ClockData *cd,
- const gchar *verbname)
+display_about_dialog (GtkAction *action,
+ ClockData *cd)
{
static const gchar *authors[] =
{
@@ -3697,23 +3699,22 @@ clock_factory (PanelApplet *applet,
{
gboolean retval = FALSE;
- if (!strcmp (iid, "OAFIID:GNOME_ClockApplet"))
+ if (!strcmp (iid, "ClockApplet"))
retval = fill_clock_applet (applet);
return retval;
}
#ifdef CLOCK_INPROCESS
-PANEL_APPLET_BONOBO_SHLIB_FACTORY ("OAFIID:GNOME_ClockApplet_Factory",
- PANEL_TYPE_APPLET,
- "ClockApplet",
- clock_factory,
- NULL)
+PANEL_APPLET_IN_PROCESS_FACTORY ("ClockAppletFactory",
+ PANEL_TYPE_APPLET,
+ "ClockApplet",
+ clock_factory,
+ NULL)
#else
-PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_ClockApplet_Factory",
- PANEL_TYPE_APPLET,
- "ClockApplet",
- "0",
- clock_factory,
- NULL)
+PANEL_APPLET_OUT_PROCESS_FACTORY ("ClockAppletFactory",
+ PANEL_TYPE_APPLET,
+ "ClockApplet",
+ clock_factory,
+ NULL)
#endif
diff --git a/applets/clock/org.gnome.panel.applet.ClockAppletFactory.service.in b/applets/clock/org.gnome.panel.applet.ClockAppletFactory.service.in
new file mode 100644
index 0000000..a3c01ea
--- /dev/null
+++ b/applets/clock/org.gnome.panel.applet.ClockAppletFactory.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.panel.applet.ClockAppletFactory
+Exec= LOCATION@
diff --git a/applets/fish/GNOME_FishApplet.panel-applet.in.in b/applets/fish/GNOME_FishApplet.panel-applet.in.in
new file mode 100644
index 0000000..561c89b
--- /dev/null
+++ b/applets/fish/GNOME_FishApplet.panel-applet.in.in
@@ -0,0 +1,17 @@
+[Applet Factory]
+Id=FishAppletFactory
+InProcess= IN_PROCESS@
+Location= LOCATION@
+_Name=Wanda Factory
+_Description=From Whence That Stupid Fish Came
+
+[FishApplet]
+_Name=Fish
+_Description=Display a swimming fish or another animated creature
+Icon=gnome-panel-fish
+BonoboId=OAFIID:GNOME_FishApplet
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=gnome-panel
+X-GNOME-Bugzilla-Component=fish
+X-GNOME-Bugzilla-Version= VERSION@
+X-GNOME-Bugzilla-OtherBinaries=fish-applet-2
diff --git a/applets/fish/GNOME_FishApplet.xml b/applets/fish/GNOME_FishApplet.xml
index 7b73077..914f92e 100644
--- a/applets/fish/GNOME_FishApplet.xml
+++ b/applets/fish/GNOME_FishApplet.xml
@@ -1,12 +1,4 @@
-<Root>
- <popups>
- <popup name="button3">
- <menuitem name="Fish Preferences Item" verb="FishPreferences" _label="_Preferences"
- pixtype="stock" pixname="gtk-properties"/>
- <menuitem name="Fish Help Item" verb="FishHelp" _label="_Help"
- pixtype="stock" pixname="gtk-help"/>
- <menuitem name="Fish About Item" verb="FishAbout" _label="_About"
- pixtype="stock" pixname="gtk-about"/>
- </popup>
- </popups>
-</Root>
+<menuitem name="Fish Preferences Item" action="FishPreferences"/>
+<menuitem name="Fish Help Item" action="FishHelp"/>
+<menuitem name="Fish About Item" action="FishAbout"/>
+
diff --git a/applets/fish/Makefile.am b/applets/fish/Makefile.am
index f99b3e4..34c7140 100644
--- a/applets/fish/Makefile.am
+++ b/applets/fish/Makefile.am
@@ -5,6 +5,7 @@ INCLUDES = \
-DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
-DFISH_ICONDIR=\""$(fishbitmapsdir)"\" \
-DFISH_BUILDERDIR=\""$(uidir)"\" \
+ -DFISH_MENU_UI_DIR=\""$(xmluidir)"\" \
$(WARN_CFLAGS) \
$(DISABLE_DEPRECATED_CFLAGS) \
$(FISH_CFLAGS) \
@@ -18,8 +19,8 @@ FISH_LDADD = \
$(LIBPANEL_APPLET_LIBS)
if FISH_INPROCESS
-APPLET_TYPE = shlib
-APPLET_LOCATION = $(pkglibdir)/libfish-applet-2.so
+APPLET_IN_PROCESS = true
+APPLET_LOCATION = $(pkglibdir)/libfish-applet-2.so
fish_applet_2libdir = $(pkglibdir)
fish_applet_2lib_LTLIBRARIES = libfish-applet-2.la
@@ -28,7 +29,7 @@ libfish_applet_2_la_LIBADD = $(FISH_LDADD)
libfish_applet_2_la_LDFLAGS = -module -avoid-version
libfish_applet_2_la_CFLAGS =
else
-APPLET_TYPE = exe
+APPLET_IN_PROCESS = false
APPLET_LOCATION = $(libexecdir)/fish-applet-2
libexec_PROGRAMS = fish-applet-2
@@ -47,7 +48,8 @@ FISH_BITMAPS = \
EXTRA_DIST = \
wanda.svg \
$(FISH_BITMAPS) \
- GNOME_FishApplet_Factory.server.in.in \
+ GNOME_FishApplet.panel-applet.in.in \
+ $(service_in_files) \
fish.schemas.in \
$(ui_DATA) \
$(xmlui_DATA)
@@ -61,20 +63,31 @@ fishbitmaps_DATA = $(FISH_BITMAPS)
xmluidir = $(datadir)/gnome-2.0/ui
xmlui_DATA = GNOME_FishApplet.xml
-serverdir = $(libdir)/bonobo/servers
-server_in_files = GNOME_FishApplet_Factory.server.in
-server_DATA = $(server_in_files:.server.in=.server)
+CLEANFILES = $(schemas_DATA) $(applet_DATA) $(applet_DATA).in $(service_DATA)
-$(server_in_files): $(server_in_files).in Makefile
+appletdir = $(datadir)/gnome-panel/applets
+applet_in_files = GNOME_FishApplet.panel-applet.in
+applet_DATA = $(applet_in_files:.panel-applet.in=.panel-applet)
+
+$(applet_in_files): $(applet_in_files).in Makefile
$(AM_V_GEN)sed \
-e "s|\ LOCATION\@|$(APPLET_LOCATION)|" \
- -e "s|\ TYPE\@|$(APPLET_TYPE)|" \
+ -e "s|\ IN_PROCESS\@|$(APPLET_IN_PROCESS)|" \
-e "s|\ VERSION\@|$(PACKAGE_VERSION)|" \
$< > $@
-CLEANFILES = $(server_DATA) $(server_DATA).in $(schemas_DATA)
+ PANEL_INTLTOOL_PANEL_APPLET_RULE@
+
+if !FISH_INPROCESS
+servicedir = $(datadir)/dbus-1/services
+service_in_files = org.gnome.panel.applet.FishAppletFactory.service.in
+service_DATA = $(service_in_files:.service.in=.service)
- INTLTOOL_SERVER_RULE@
+org.gnome.panel.applet.FishAppletFactory.service: $(service_in_files)
+ $(AM_V_GEN)sed \
+ -e "s|\ LOCATION\@|$(APPLET_LOCATION)|" \
+ $< > $@
+endif
schemasdir = $(GCONF_SCHEMA_FILE_DIR)
schemas_in_files = fish.schemas.in
diff --git a/applets/fish/fish.c b/applets/fish/fish.c
index 2fbfdcf..f7933d3 100644
--- a/applets/fish/fish.c
+++ b/applets/fish/fish.c
@@ -408,9 +408,8 @@ chooser_preview_update (GtkFileChooser *file_chooser,
}
static void
-display_preferences_dialog (BonoboUIComponent *uic,
- FishApplet *fish,
- const char *verbname)
+display_preferences_dialog (GtkAction *action,
+ FishApplet *fish)
{
GtkBuilder *builder;
GError *error;
@@ -570,17 +569,15 @@ display_preferences_dialog (BonoboUIComponent *uic,
}
static void
-display_help_dialog (BonoboUIComponent *uic,
- FishApplet *fish,
- const char *verbname)
+display_help_dialog (GtkAction *action,
+ FishApplet *fish)
{
show_help (fish, NULL);
}
static void
-display_about_dialog (BonoboUIComponent *uic,
- FishApplet *fish,
- const char *verbname)
+display_about_dialog (GtkAction *action,
+ FishApplet *fish)
{
const char *author_format = _("%s the Fish");
const char *about_format = _("%s has no use what-so-ever. "
@@ -1804,12 +1801,16 @@ setup_fish_widget (FishApplet *fish)
gtk_widget_show_all (widget);
}
-static const BonoboUIVerb fish_menu_verbs [] = {
- BONOBO_UI_UNSAFE_VERB ("FishPreferences", display_preferences_dialog),
- BONOBO_UI_UNSAFE_VERB ("FishHelp", display_help_dialog),
- BONOBO_UI_UNSAFE_VERB ("FishAbout", display_about_dialog),
-
- BONOBO_UI_VERB_END
+static const GtkActionEntry fish_menu_verbs [] = {
+ { "FishPreferences", GTK_STOCK_PROPERTIES, N_("_Preferences"),
+ NULL, NULL,
+ G_CALLBACK (display_preferences_dialog) },
+ { "FishHelp", GTK_STOCK_HELP, N_("_Help"),
+ NULL, NULL,
+ G_CALLBACK (display_help_dialog) },
+ { "FishAbout", GTK_STOCK_ABOUT, N_("_About"),
+ NULL, NULL,
+ G_CALLBACK (display_about_dialog) }
};
static void
@@ -1831,8 +1832,10 @@ fish_migrate_to_210 (FishApplet *fish)
static gboolean
fish_applet_fill (FishApplet *fish)
{
- PanelApplet *applet = (PanelApplet *) fish;
- GError *error = NULL;
+ PanelApplet *applet = (PanelApplet *) fish;
+ GtkActionGroup *action_group;
+ gchar *ui_path;
+ GError *error = NULL;
fish->orientation = panel_applet_get_orient (applet);
@@ -1896,20 +1899,23 @@ fish_applet_fill (FishApplet *fish)
fish->rotate = FALSE; /* Fallback */
}
- panel_applet_setup_menu_from_file (
- applet, NULL, "GNOME_FishApplet.xml",
- NULL, fish_menu_verbs, fish);
+ action_group = gtk_action_group_new ("Fish Applet Actions");
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (action_group,
+ fish_menu_verbs,
+ G_N_ELEMENTS (fish_menu_verbs),
+ fish);
+ ui_path = g_build_filename (FISH_MENU_UI_DIR, "GNOME_FishApplet.xml", NULL);
+ panel_applet_setup_menu_from_file (applet, ui_path, action_group);
+ g_free (ui_path);
if (panel_applet_get_locked_down (applet)) {
- BonoboUIComponent *popup_component;
-
- popup_component = panel_applet_get_popup_component (applet);
+ GtkAction *action;
- bonobo_ui_component_set_prop (popup_component,
- "/commands/FishPreferences",
- "hidden", "1",
- NULL);
+ action = gtk_action_group_get_action (action_group, "FishPreferences");
+ gtk_action_set_visible (action, FALSE);
}
+ g_object_unref (action_group);
#ifndef FISH_INPROCESS
gtk_window_set_default_icon_name (FISH_ICON);
@@ -1926,7 +1932,7 @@ fishy_factory (PanelApplet *applet,
{
gboolean retval = FALSE;
- if (!strcmp (iid, "OAFIID:GNOME_FishApplet"))
+ if (!strcmp (iid, "FishApplet"))
retval = fish_applet_fill (FISH_APPLET (applet));
return retval;
@@ -2098,17 +2104,16 @@ fish_applet_get_type (void)
}
#ifdef FISH_INPROCESS
-PANEL_APPLET_BONOBO_SHLIB_FACTORY ("OAFIID:GNOME_FishApplet_Factory",
- fish_applet_get_type (),
- "That-stupid-fish",
- fishy_factory,
- NULL)
+PANEL_APPLET_IN_PROCESS_FACTORY ("FishAppletFactory",
+ fish_applet_get_type (),
+ "That-stupid-fish",
+ fishy_factory,
+ NULL)
#else
-PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_FishApplet_Factory",
- fish_applet_get_type (),
- "That-stupid-fish",
- "0",
- fishy_factory,
- NULL)
+PANEL_APPLET_OUT_PROCESS_FACTORY ("FishAppletFactory",
+ fish_applet_get_type (),
+ "That-stupid-fish",
+ fishy_factory,
+ NULL)
#endif
diff --git a/applets/fish/org.gnome.panel.applet.FishAppletFactory.service.in b/applets/fish/org.gnome.panel.applet.FishAppletFactory.service.in
new file mode 100644
index 0000000..ffa15cb
--- /dev/null
+++ b/applets/fish/org.gnome.panel.applet.FishAppletFactory.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.panel.applet.FishAppletFactory
+Exec= LOCATION@
diff --git a/applets/notification_area/GNOME_NotificationAreaApplet.panel-applet.in.in b/applets/notification_area/GNOME_NotificationAreaApplet.panel-applet.in.in
new file mode 100644
index 0000000..21a0d71
--- /dev/null
+++ b/applets/notification_area/GNOME_NotificationAreaApplet.panel-applet.in.in
@@ -0,0 +1,17 @@
+[Applet Factory]
+Id=NotificationAreaAppletFactory
+InProcess= IN_PROCESS@
+Location= LOCATION@
+_Name=Notification Area Factory
+_Description=Notification Area Factory
+
+[NotificationArea]
+_Name=Notification Area
+_Description=Area where notification icons appear
+Icon=gnome-panel-notification-area
+BonoboId=OAFIID:GNOME_NotificationAreaApplet;OAFIID:GNOME_SystemTrayApplet
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=gnome-panel
+X-GNOME-Bugzilla-Component=notification area
+X-GNOME-Bugzilla-Version= VERSION@
+X-GNOME-Bugzilla-OtherBinaries=notification-area-applet
diff --git a/applets/notification_area/GNOME_NotificationAreaApplet.xml b/applets/notification_area/GNOME_NotificationAreaApplet.xml
index 7b69928..fdbcc83 100644
--- a/applets/notification_area/GNOME_NotificationAreaApplet.xml
+++ b/applets/notification_area/GNOME_NotificationAreaApplet.xml
@@ -1,10 +1,3 @@
-<Root>
- <popups>
- <popup name="button3">
- <menuitem name="Notification Area Help Item" verb="SystemTrayHelp" _label="_Help"
- pixtype="stock" pixname="gtk-help"/>
- <menuitem name="Notification Area About Item" verb="SystemTrayAbout" _label="_About"
- pixtype="stock" pixname="gtk-about"/>
- </popup>
- </popups>
-</Root>
+<menuitem name="Notification Area Help Item" action="SystemTrayHelp" />
+<menuitem name="Notification Area About Item" action="SystemTrayAbout" />
+
diff --git a/applets/notification_area/Makefile.am b/applets/notification_area/Makefile.am
index 9bfdcdb..91938fe 100644
--- a/applets/notification_area/Makefile.am
+++ b/applets/notification_area/Makefile.am
@@ -12,7 +12,8 @@ INCLUDES = \
-DPREFIX=\"$(prefix)\" \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DDATADIR=\"$(datadir)\" \
- -DLIBDIR=\"$(libdir)\"
+ -DLIBDIR=\"$(libdir)\" \
+ -DNOTIFICATION_AREA_MENU_UI_DIR=\""$(uidir)"\"
NOTIFICATION_AREA_SOURCES = \
fixedtip.h \
@@ -34,8 +35,8 @@ NOTIFICATION_AREA_LDADD = \
$(LIBPANEL_APPLET_LIBS)
if NOTIFICATION_AREA_INPROCESS
-APPLET_TYPE = shlib
-APPLET_LOCATION = $(pkglibdir)/libnotification-area-applet.so
+APPLET_IN_PROCESS = true
+APPLET_LOCATION = $(pkglibdir)/libnotification-area-applet.so
notification_area_appletlibdir = $(pkglibdir)
notification_area_appletlib_LTLIBRARIES = libnotification-area-applet.la
@@ -44,8 +45,8 @@ libnotification_area_applet_la_LIBADD = $(NOTIFICATION_AREA_LDADD)
libnotification_area_applet_la_LDFLAGS = -module -avoid-version
libnotification_area_applet_la_CFLAGS =
else
-APPLET_TYPE = exe
-APPLET_LOCATION = $(libexecdir)/notification-area-applet
+APPLET_IN_PROCESS = false
+APPLET_LOCATION = $(libexecdir)/notification-area-applet
libexec_PROGRAMS = notification-area-applet
notification_area_applet_SOURCES = $(NOTIFICATION_AREA_SOURCES)
@@ -53,32 +54,45 @@ notification_area_applet_LDADD = $(NOTIFICATION_AREA_LDADD)
notification_area_applet_CFLAGS =
endif
-serverdir = $(libdir)/bonobo/servers
-server_in_files = GNOME_NotificationAreaApplet.server.in
-server_DATA = GNOME_NotificationAreaApplet.server
+appletdir = $(datadir)/gnome-panel/applets
+applet_in_files = GNOME_NotificationAreaApplet.panel-applet.in
+applet_DATA = $(applet_in_files:.panel-applet.in=.panel-applet)
-$(server_in_files): $(server_in_files).in Makefile
+$(applet_in_files): $(applet_in_files).in Makefile
$(AM_V_GEN)sed \
- -e "s|\ LOCATION\@|$(APPLET_LOCATION)|" \
- -e "s|\ TYPE\@|$(APPLET_TYPE)|" \
- -e "s|\ VERSION\@|$(PACKAGE_VERSION)|" \
- $< > $@
+ -e "s|\ LOCATION\@|$(APPLET_LOCATION)|" \
+ -e "s|\ IN_PROCESS\@|$(APPLET_IN_PROCESS)|" \
+ -e "s|\ VERSION\@|$(PACKAGE_VERSION)|" \
+ $< > $@
- INTLTOOL_SERVER_RULE@
+ PANEL_INTLTOOL_PANEL_APPLET_RULE@
+
+if !NOTIFICATION_AREA_INPROCESS
+servicedir = $(datadir)/dbus-1/services
+service_in_files = org.gnome.panel.applet.NotificationAreaAppletFactory.service.in
+service_DATA = $(service_in_files:.service.in=.service)
+
+org.gnome.panel.applet.NotificationAreaAppletFactory.service: $(service_in_files)
+ $(AM_V_GEN)sed \
+ -e "s|\ LOCATION\@|$(APPLET_LOCATION)|" \
+ $< > $@
+endif
uidir = $(datadir)/gnome-2.0/ui
ui_DATA = GNOME_NotificationAreaApplet.xml
EXTRA_DIST = \
- GNOME_NotificationAreaApplet.server.in.in \
+ GNOME_NotificationAreaApplet.panel-applet.in.in \
$(ui_DATA) \
+ $(service_in_files) \
na-marshal.list
BUILT_SOURCES = na-marshal.c na-marshal.h
CLEANFILES = \
- GNOME_NotificationAreaApplet.server.in \
- GNOME_NotificationAreaApplet.server
+ $(applet_DATA) \
+ $(applet_DATA).in \
+ $(service_DATA)
na-marshal.h: na-marshal.list $(GLIB_GENMARSHAL)
$(AM_V_GEN)$(GLIB_GENMARSHAL) $< --header --prefix=_na_marshal > $@
diff --git a/applets/notification_area/main.c b/applets/notification_area/main.c
index 69cf7ea..33632f3 100644
--- a/applets/notification_area/main.c
+++ b/applets/notification_area/main.c
@@ -64,9 +64,8 @@ get_orientation_from_applet (PanelApplet *applet)
}
static void
-help_cb (BonoboUIComponent *uic,
- AppletData *data,
- const gchar *verbname)
+help_cb (GtkAction *action,
+ AppletData *data)
{
GError *error = NULL;
char *uri;
@@ -119,9 +118,8 @@ help_cb (BonoboUIComponent *uic,
}
static void
-about_cb (BonoboUIComponent *uic,
- AppletData *data,
- const gchar *verbname)
+about_cb (GtkAction *action,
+ AppletData *data)
{
GdkScreen *screen;
@@ -169,10 +167,13 @@ about_cb (BonoboUIComponent *uic,
gtk_window_present (GTK_WINDOW (data->about_dialog));
}
-static const BonoboUIVerb menu_verbs [] = {
- BONOBO_UI_UNSAFE_VERB ("SystemTrayHelp", help_cb),
- BONOBO_UI_UNSAFE_VERB ("SystemTrayAbout", about_cb),
- BONOBO_UI_VERB_END
+static const GtkActionEntry menu_actions [] = {
+ { "SystemTrayHelp", GTK_STOCK_HELP, N_("_Help"),
+ NULL, NULL,
+ G_CALLBACK (help_cb) },
+ { "SystemTrayAbout", GTK_STOCK_ABOUT, N_("_About"),
+ NULL, NULL,
+ G_CALLBACK (about_cb) }
};
static void
@@ -236,12 +237,14 @@ applet_factory (PanelApplet *applet,
const gchar *iid,
gpointer user_data)
{
- NaTray *tray;
- AppletData *data;
- AtkObject *atko;
-
- if (!(strcmp (iid, "OAFIID:GNOME_NotificationAreaApplet") == 0 ||
- strcmp (iid, "OAFIID:GNOME_SystemTrayApplet") == 0))
+ NaTray *tray;
+ AppletData *data;
+ GtkActionGroup *action_group;
+ gchar *ui_path;
+ AtkObject *atko;
+
+ if (!(strcmp (iid, "NotificationArea") == 0 ||
+ strcmp (iid, "SystemTrayApplet") == 0))
return FALSE;
tray = na_tray_new_for_screen (gtk_widget_get_screen (GTK_WIDGET (applet)),
@@ -280,27 +283,31 @@ applet_factory (PanelApplet *applet,
#endif
gtk_widget_show_all (GTK_WIDGET (applet));
+ action_group = gtk_action_group_new ("ClockApplet Menu Actions");
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (action_group,
+ menu_actions,
+ G_N_ELEMENTS (menu_actions),
+ data);
+ ui_path = g_build_filename (NOTIFICATION_AREA_MENU_UI_DIR, "GNOME_NotificationAreaApplet.xml", NULL);
panel_applet_setup_menu_from_file (applet,
- NULL,
- "GNOME_NotificationAreaApplet.xml",
- NULL,
- menu_verbs,
- data);
-
+ ui_path, action_group);
+ g_free (ui_path);
+ g_object_unref (action_group);
+
return TRUE;
}
#ifdef NOTIFICATION_AREA_INPROCESS
-PANEL_APPLET_BONOBO_SHLIB_FACTORY ("OAFIID:GNOME_NotificationAreaApplet_Factory",
- PANEL_TYPE_APPLET,
- "NotificationArea",
- applet_factory,
- NULL)
+PANEL_APPLET_IN_PROCESS_FACTORY ("NotificationAreaAppletFactory",
+ PANEL_TYPE_APPLET,
+ "NotificationArea",
+ applet_factory,
+ NULL)
#else
-PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_NotificationAreaApplet_Factory",
- PANEL_TYPE_APPLET,
- "NotificationArea",
- "0",
- applet_factory,
- NULL)
+PANEL_APPLET_OUT_PROCESS_FACTORY ("NotificationAreaAppletFactory",
+ PANEL_TYPE_APPLET,
+ "NotificationArea",
+ applet_factory,
+ NULL)
#endif
diff --git a/applets/notification_area/org.gnome.panel.applet.NotificationAreaAppletFactory.service.in b/applets/notification_area/org.gnome.panel.applet.NotificationAreaAppletFactory.service.in
new file mode 100644
index 0000000..0238e84
--- /dev/null
+++ b/applets/notification_area/org.gnome.panel.applet.NotificationAreaAppletFactory.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.panel.applet.NotificationAreaAppletFactory
+Exec= LOCATION@
diff --git a/applets/wncklet/GNOME_ShowDesktopApplet.xml b/applets/wncklet/GNOME_ShowDesktopApplet.xml
index fa8234b..3770f27 100644
--- a/applets/wncklet/GNOME_ShowDesktopApplet.xml
+++ b/applets/wncklet/GNOME_ShowDesktopApplet.xml
@@ -1,10 +1,3 @@
-<Root>
- <popups>
- <popup name="button3">
- <menuitem name="Show Desktop Help Item" verb="ShowDesktopHelp" _label="_Help"
- pixtype="stock" pixname="gtk-help"/>
- <menuitem name="Show Desktop About Item" verb="ShowDesktopAbout" _label="_About"
- pixtype="stock" pixname="gtk-about"/>
- </popup>
- </popups>
-</Root>
+<menuitem name="Show Desktop Help Item" action="ShowDesktopHelp"/>
+<menuitem name="Show Desktop About Item" action="ShowDesktopAbout"/>
+
diff --git a/applets/wncklet/GNOME_WindowListApplet.xml b/applets/wncklet/GNOME_WindowListApplet.xml
index 1862788..008d382 100644
--- a/applets/wncklet/GNOME_WindowListApplet.xml
+++ b/applets/wncklet/GNOME_WindowListApplet.xml
@@ -1,16 +1,4 @@
-<Root>
- <popups>
- <popup name="button3">
- <menuitem name="Tasklist Preferences Item" verb="TasklistPreferences" _label="_Preferences"
- pixtype="stock" pixname="gtk-properties"/>
- <menuitem name="Tasklist Help Item" verb="TasklistHelp" _label="_Help"
- pixtype="stock" pixname="gtk-help"/>
- <menuitem name="Tasklist About Item" verb="TasklistAbout" _label="_About"
- pixtype="stock" pixname="gtk-about"/>
- </popup>
- </popups>
-</Root>
+<menuitem name="Tasklist Preferences Item" action="TasklistPreferences" />
+<menuitem name="Tasklist Help Item" action="TasklistHelp" />
+<menuitem name="Tasklist About Item" action="TasklistAbout" />
-
-
-
diff --git a/applets/wncklet/GNOME_WindowMenuApplet.xml b/applets/wncklet/GNOME_WindowMenuApplet.xml
index 31b576f..2646b2d 100644
--- a/applets/wncklet/GNOME_WindowMenuApplet.xml
+++ b/applets/wncklet/GNOME_WindowMenuApplet.xml
@@ -1,10 +1,3 @@
-<Root>
- <popups>
- <popup name="button3">
- <menuitem name="WindowMenu Help Item" verb="WindowMenuHelp" _label="_Help"
- pixtype="stock" pixname="gtk-help"/>
- <menuitem name="WindowMenu About Item" verb="WindowMenuAbout" _label="_About"
- pixtype="stock" pixname="gtk-about"/>
- </popup>
- </popups>
-</Root>
+<menuitem name="WindowMenu Help Item" action="WindowMenuHelp" />
+<menuitem name="WindowMenu About Item" action="WindowMenuAbout" />
+
diff --git a/applets/wncklet/GNOME_Wncklet.panel-applet.in.in b/applets/wncklet/GNOME_Wncklet.panel-applet.in.in
new file mode 100644
index 0000000..ac84fe8
--- /dev/null
+++ b/applets/wncklet/GNOME_Wncklet.panel-applet.in.in
@@ -0,0 +1,50 @@
+[Applet Factory]
+Id=WnckletFactory
+InProcess= IN_PROCESS@
+Location= LOCATION@
+_Name=Window Navigation Applet Factory
+_Description=Factory for the window navigation related applets
+
+[WindowMenuApplet]
+_Name=Window Selector
+_Description=Switch between open windows using a menu
+Icon=gnome-panel-window-menu
+BonoboId=OAFIID:GNOME_WindowMenuApplet
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=gnome-panel
+X-GNOME-Bugzilla-Component=window selector
+X-GNOME-Bugzilla-Version= VERSION@
+X-GNOME-Bugzilla-OtherBinaries=wnck-applet
+
+[WorkspaceSwitcherApplet]
+_Name=Workspace Switcher
+_Description=Switch between workspaces
+Icon=gnome-panel-workspace-switcher
+BonoboId=OAFIID:GNOME_WorkspaceSwitcherApplet;OAFIID:GNOME_PagerApplet
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=gnome-panel
+X-GNOME-Bugzilla-Component=workspace switcher
+X-GNOME-Bugzilla-Version= VERSION@
+X-GNOME-Bugzilla-OtherBinaries=wnck-applet
+
+[WindowListApplet]
+_Name=Window List
+_Description=Switch between open windows using buttons
+Icon=gnome-panel-window-list
+BonoboId=OAFIID:GNOME_TasklistApplet;OAFIID:GNOME_WindowListApplet
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=gnome-panel
+X-GNOME-Bugzilla-Component=window list
+X-GNOME-Bugzilla-Version= VERSION@
+X-GNOME-Bugzilla-OtherBinaries=wnck-applet
+
+[ShowDesktopApplet]
+_Name=Show Desktop
+_Description=Hide application windows and show the desktop
+Icon=user-desktop
+BonoboId=OAFIID:GNOME_ShowDesktopApplet
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=gnome-panel
+X-GNOME-Bugzilla-Component=Show Desktop Button
+X-GNOME-Bugzilla-Version= VERSION@
+X-GNOME-Bugzilla-OtherBinaries=wnck-applet
diff --git a/applets/wncklet/GNOME_WorkspaceSwitcherApplet.xml b/applets/wncklet/GNOME_WorkspaceSwitcherApplet.xml
index 1568573..d7354eb 100644
--- a/applets/wncklet/GNOME_WorkspaceSwitcherApplet.xml
+++ b/applets/wncklet/GNOME_WorkspaceSwitcherApplet.xml
@@ -1,14 +1,6 @@
-<Root>
- <popups>
- <popup name="button3">
- <menuitem name="Pager Preferences Item" verb="PagerPreferences" _label="_Preferences"
- pixtype="stock" pixname="gtk-properties"/>
- <menuitem name="Pager Help Item" verb="PagerHelp" _label="_Help"
- pixtype="stock" pixname="gtk-help"/>
- <menuitem name="Pager About Item" verb="PagerAbout" _label="_About"
- pixtype="stock" pixname="gtk-about"/>
- </popup>
- </popups>
-</Root>
+<menuitem name="Pager Preferences Item" action="PagerPreferences" />
+<menuitem name="Pager Help Item" action="PagerHelp" />
+<menuitem name="Pager About Item" action="PagerAbout" />
+
diff --git a/applets/wncklet/Makefile.am b/applets/wncklet/Makefile.am
index 522d7c7..65617c1 100644
--- a/applets/wncklet/Makefile.am
+++ b/applets/wncklet/Makefile.am
@@ -10,6 +10,7 @@ INCLUDES = \
-DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
-DPAGER_BUILDERDIR=\""$(uidir)"\" \
-DTASKLIST_BUILDERDIR=\""$(uidir)"\" \
+ -DWNCK_MENU_UI_DIR=\""$(xmluidir)"\" \
-DPREFIX=\"$(prefix)\" \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DDATADIR=\"$(datadir)\" \
@@ -35,8 +36,8 @@ WNCKLET_LDADD = \
$(LIBPANEL_APPLET_LIBS)
if WNCKLET_INPROCESS
-APPLET_TYPE = shlib
-APPLET_LOCATION = $(pkglibdir)/libwnck-applet.so
+APPLET_IN_PROCESS = true
+APPLET_LOCATION = $(pkglibdir)/libwnck-applet.so
wnck_appletlibdir = $(pkglibdir)
wnck_appletlib_LTLIBRARIES = libwnck-applet.la
@@ -45,8 +46,8 @@ libwnck_applet_la_LIBADD = $(WNCKLET_LDADD)
libwnck_applet_la_LDFLAGS = -module -avoid-version
libwnck_applet_la_CFLAGS =
else
-APPLET_TYPE = exe
-APPLET_LOCATION = $(libexecdir)/wnck-applet
+APPLET_IN_PROCESS = false
+APPLET_LOCATION = $(libexecdir)/wnck-applet
libexec_PROGRAMS = wnck-applet
wnck_applet_SOURCES = $(WNCKLET_SOURCES)
@@ -55,25 +56,37 @@ wnck_applet_CFLAGS =
endif
EXTRA_DIST = \
- GNOME_Wncklet_Factory.server.in.in \
+ GNOME_Wncklet.panel-applet.in.in \
+ $(service_in_files) \
$(xmlui_DATA) \
$(schemas_in_files) \
$(ui_DATA)
-serverdir = $(libdir)/bonobo/servers
-server_in_files = GNOME_Wncklet_Factory.server.in
-server_DATA = $(server_in_files:.server.in=.server)
+appletdir = $(datadir)/gnome-panel/applets
+applet_in_files = GNOME_Wncklet.panel-applet.in
+applet_DATA = $(applet_in_files:.panel-applet.in=.panel-applet)
-$(server_in_files): $(server_in_files).in Makefile
+$(applet_in_files): $(applet_in_files).in Makefile
$(AM_V_GEN)sed \
- -e "s|\ LOCATION\@|$(APPLET_LOCATION)|" \
- -e "s|\ TYPE\@|$(APPLET_TYPE)|" \
- -e "s|\ VERSION\@|$(PACKAGE_VERSION)|" \
- $< > $@
+ -e "s|\ LOCATION\@|$(APPLET_LOCATION)|" \
+ -e "s|\ IN_PROCESS\@|$(APPLET_IN_PROCESS)|" \
+ -e "s|\ VERSION\@|$(PACKAGE_VERSION)|" \
+ $< > $@
- INTLTOOL_SERVER_RULE@
+ PANEL_INTLTOOL_PANEL_APPLET_RULE@
-CLEANFILES = $(server_in_files) $(server_DATA) $(BUILT_SOURCES) $(schemas_DATA)
+if !WNCKLET_INPROCESS
+servicedir = $(datadir)/dbus-1/services
+service_in_files = org.gnome.panel.applet.WnckletFactory.service.in
+service_DATA = $(service_in_files:.service.in=.service)
+
+org.gnome.panel.applet.WnckletFactory.service: $(service_in_files)
+ $(AM_V_GEN)sed \
+ -e "s|\ LOCATION\@|$(APPLET_LOCATION)|" \
+ $< > $@
+endif
+
+CLEANFILES = $(BUILT_SOURCES) $(schemas_DATA) $(applet_DATA) $(applet_DATA).in $(service_DATA)
xmluidir = $(datadir)/gnome-2.0/ui
xmlui_DATA = \
diff --git a/applets/wncklet/org.gnome.panel.applet.WnckletFactory.service.in b/applets/wncklet/org.gnome.panel.applet.WnckletFactory.service.in
new file mode 100644
index 0000000..b3800ee
--- /dev/null
+++ b/applets/wncklet/org.gnome.panel.applet.WnckletFactory.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.panel.applet.WnckletFactory
+Exec= LOCATION@
diff --git a/applets/wncklet/showdesktop.c b/applets/wncklet/showdesktop.c
index f92ddb0..e6a46bb 100644
--- a/applets/wncklet/showdesktop.c
+++ b/applets/wncklet/showdesktop.c
@@ -61,12 +61,10 @@ typedef struct {
GtkIconTheme *icon_theme;
} ShowDesktopData;
-static void display_help_dialog (BonoboUIComponent *uic,
- ShowDesktopData *sdd,
- const gchar *verbname);
-static void display_about_dialog (BonoboUIComponent *uic,
- ShowDesktopData *sdd,
- const gchar *verbname);
+static void display_help_dialog (GtkAction *action,
+ ShowDesktopData *sdd);
+static void display_about_dialog (GtkAction *action,
+ ShowDesktopData *sdd);
static void update_icon (ShowDesktopData *sdd);
static void update_button_state (ShowDesktopData *sdd);
@@ -223,10 +221,13 @@ update_icon (ShowDesktopData *sdd)
g_object_unref (icon);
}
-static const BonoboUIVerb show_desktop_menu_verbs [] = {
- BONOBO_UI_UNSAFE_VERB ("ShowDesktopHelp", display_help_dialog),
- BONOBO_UI_UNSAFE_VERB ("ShowDesktopAbout", display_about_dialog),
- BONOBO_UI_VERB_END
+static const GtkActionEntry show_desktop_menu_actions [] = {
+ { "ShowDesktopHelp", GTK_STOCK_HELP, N_("_Help"),
+ NULL, NULL,
+ G_CALLBACK (display_help_dialog) },
+ { "ShowDesktopAbout", GTK_STOCK_ABOUT, N_("_About"),
+ NULL, NULL,
+ G_CALLBACK (display_about_dialog) }
};
/* This updates things that should be consistent with the button's appearance,
@@ -409,6 +410,8 @@ gboolean
show_desktop_applet_fill (PanelApplet *applet)
{
ShowDesktopData *sdd;
+ GtkActionGroup *action_group;
+ gchar *ui_path;
AtkObject *atk_obj;
panel_applet_set_flags (applet, PANEL_APPLET_EXPAND_MINOR);
@@ -478,12 +481,17 @@ show_desktop_applet_fill (PanelApplet *applet)
panel_applet_set_background_widget (PANEL_APPLET (sdd->applet),
GTK_WIDGET (sdd->applet));
- panel_applet_setup_menu_from_file (PANEL_APPLET (sdd->applet),
- NULL,
- "GNOME_ShowDesktopApplet.xml",
- NULL,
- show_desktop_menu_verbs,
- sdd);
+ action_group = gtk_action_group_new ("ShowDesktop Applet Actions");
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (action_group,
+ show_desktop_menu_actions,
+ G_N_ELEMENTS (show_desktop_menu_actions),
+ sdd);
+ ui_path = g_build_filename (WNCK_MENU_UI_DIR, "GNOME_ShowDesktopApplet.xml", NULL);
+ panel_applet_setup_menu_from_file (PANEL_APPLET (sdd->applet),
+ ui_path, action_group);
+ g_free (ui_path);
+ g_object_unref (action_group);
g_signal_connect (G_OBJECT (sdd->applet),
"destroy",
@@ -505,18 +513,16 @@ show_desktop_applet_fill (PanelApplet *applet)
}
static void
-display_help_dialog (BonoboUIComponent *uic,
- ShowDesktopData *sdd,
- const gchar *verbname)
+display_help_dialog (GtkAction *action,
+ ShowDesktopData *sdd)
{
wncklet_display_help (sdd->applet, "user-guide",
"gospanel-564", SHOW_DESKTOP_ICON);
}
static void
-display_about_dialog (BonoboUIComponent *uic,
- ShowDesktopData *sdd,
- const gchar *verbname)
+display_about_dialog (GtkAction *action,
+ ShowDesktopData *sdd)
{
static const gchar *authors[] = {
"Havoc Pennington <hp redhat com>",
diff --git a/applets/wncklet/window-list.c b/applets/wncklet/window-list.c
index 90d9f23..0b713ef 100644
--- a/applets/wncklet/window-list.c
+++ b/applets/wncklet/window-list.c
@@ -59,15 +59,12 @@ typedef struct {
guint listeners [3];
} TasklistData;
-static void display_properties_dialog (BonoboUIComponent *uic,
- TasklistData *tasklist,
- const gchar *verbname);
-static void display_help_dialog (BonoboUIComponent *uic,
- TasklistData *tasklist,
- const gchar *verbname);
-static void display_about_dialog (BonoboUIComponent *uic,
- TasklistData *tasklist,
- const gchar *verbname);
+static void display_properties_dialog (GtkAction *action,
+ TasklistData *tasklist);
+static void display_help_dialog (GtkAction *action,
+ TasklistData *tasklist);
+static void display_about_dialog (GtkAction *action,
+ TasklistData *tasklist);
static void
tasklist_update (TasklistData *tasklist)
@@ -191,11 +188,16 @@ destroy_tasklist(GtkWidget * widget, TasklistData *tasklist)
g_free (tasklist);
}
-static const BonoboUIVerb tasklist_menu_verbs [] = {
- BONOBO_UI_UNSAFE_VERB ("TasklistPreferences", display_properties_dialog),
- BONOBO_UI_UNSAFE_VERB ("TasklistHelp", display_help_dialog),
- BONOBO_UI_UNSAFE_VERB ("TasklistAbout", display_about_dialog),
- BONOBO_UI_VERB_END
+static const GtkActionEntry tasklist_menu_actions [] = {
+ { "TasklistPreferences", GTK_STOCK_PROPERTIES, N_("_Preferences"),
+ NULL, NULL,
+ G_CALLBACK (display_properties_dialog) },
+ { "TasklistHelp", GTK_STOCK_HELP, N_("_Help"),
+ NULL, NULL,
+ G_CALLBACK (display_help_dialog) },
+ { "TasklistAbout", GTK_STOCK_ABOUT, N_("_About"),
+ NULL, NULL,
+ G_CALLBACK (display_about_dialog) }
};
static void
@@ -462,6 +464,8 @@ gboolean
window_list_applet_fill (PanelApplet *applet)
{
TasklistData *tasklist;
+ GtkActionGroup *action_group;
+ gchar *ui_path;
GError *error;
GConfValue *value;
@@ -555,24 +559,25 @@ window_list_applet_fill (PanelApplet *applet)
panel_applet_set_background_widget (PANEL_APPLET (tasklist->applet),
GTK_WIDGET (tasklist->applet));
-
+
+ action_group = gtk_action_group_new ("Tasklist Applet Actions");
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (action_group,
+ tasklist_menu_actions,
+ G_N_ELEMENTS (tasklist_menu_actions),
+ tasklist);
+ ui_path = g_build_filename (WNCK_MENU_UI_DIR, "GNOME_WindowListApplet.xml", NULL);
panel_applet_setup_menu_from_file (PANEL_APPLET (tasklist->applet),
- NULL,
- "GNOME_WindowListApplet.xml",
- NULL,
- tasklist_menu_verbs,
- tasklist);
+ ui_path, action_group);
+ g_free (ui_path);
if (panel_applet_get_locked_down (PANEL_APPLET (tasklist->applet))) {
- BonoboUIComponent *popup_component;
-
- popup_component = panel_applet_get_popup_component (PANEL_APPLET (tasklist->applet));
+ GtkAction *action;
- bonobo_ui_component_set_prop (popup_component,
- "/commands/TasklistPreferences",
- "hidden", "1",
- NULL);
+ action = gtk_action_group_get_action (action_group, "TasklistPreferences");
+ gtk_action_set_visible (action, FALSE);
}
+ g_object_unref (action_group);
gtk_widget_show (tasklist->applet);
@@ -581,18 +586,16 @@ window_list_applet_fill (PanelApplet *applet)
static void
-display_help_dialog (BonoboUIComponent *uic,
- TasklistData *tasklist,
- const gchar *verbname)
+display_help_dialog (GtkAction *action,
+ TasklistData *tasklist)
{
wncklet_display_help (tasklist->applet, "user-guide",
"windowlist", WINDOW_LIST_ICON);
}
static void
-display_about_dialog (BonoboUIComponent *uic,
- TasklistData *tasklist,
- const gchar *verbname)
+display_about_dialog (GtkAction *action,
+ TasklistData *tasklist)
{
static const gchar *authors[] =
{
@@ -766,9 +769,8 @@ setup_dialog (GtkBuilder *builder,
static void
-display_properties_dialog (BonoboUIComponent *uic,
- TasklistData *tasklist,
- const gchar *verbname)
+display_properties_dialog (GtkAction *action,
+ TasklistData *tasklist)
{
if (tasklist->properties_dialog == NULL) {
GtkBuilder *builder;
diff --git a/applets/wncklet/window-menu.c b/applets/wncklet/window-menu.c
index d827540..f6678f9 100644
--- a/applets/wncklet/window-menu.c
+++ b/applets/wncklet/window-menu.c
@@ -53,18 +53,16 @@ typedef struct {
} WindowMenu;
static void
-window_menu_help (BonoboUIComponent *uic,
- WindowMenu *window_menu,
- const char *verb)
+window_menu_help (GtkAction *action,
+ WindowMenu *window_menu)
{
wncklet_display_help (window_menu->applet, "user-guide",
"panel-windowselector", WINDOW_MENU_ICON);
}
static void
-window_menu_about (BonoboUIComponent *uic,
- WindowMenu *window_menu,
- const char *verb)
+window_menu_about (GtkAction *action,
+ WindowMenu *window_menu)
{
static const char *authors[] = {
"Mark McLoughlin <mark skynet ie>",
@@ -92,11 +90,14 @@ window_menu_about (BonoboUIComponent *uic,
"WindowMenu");
}
-static const BonoboUIVerb window_menu_verbs [] =
-{
- BONOBO_UI_UNSAFE_VERB ("WindowMenuHelp", window_menu_help),
- BONOBO_UI_UNSAFE_VERB ("WindowMenuAbout", window_menu_about),
- BONOBO_UI_VERB_END
+static const GtkActionEntry window_menu_actions [] =
+{
+ { "WindowMenuHelp", GTK_STOCK_HELP, N_("_Help"),
+ NULL, NULL,
+ G_CALLBACK (window_menu_help) },
+ { "WindowMenuAbout", GTK_STOCK_ABOUT, N_("_About"),
+ NULL, NULL,
+ G_CALLBACK (window_menu_about) }
};
static void
@@ -236,6 +237,8 @@ gboolean
window_menu_applet_fill (PanelApplet *applet)
{
WindowMenu *window_menu;
+ GtkActionGroup *action_group;
+ gchar *ui_path;
window_menu = g_new0 (WindowMenu, 1);
@@ -250,8 +253,16 @@ window_menu_applet_fill (PanelApplet *applet)
g_signal_connect (window_menu->applet, "destroy",
G_CALLBACK (window_menu_destroy), window_menu);
- panel_applet_setup_menu_from_file (applet, NULL, "GNOME_WindowMenuApplet.xml",
- NULL, window_menu_verbs, window_menu);
+ action_group = gtk_action_group_new ("WindowMenu Applet Actions");
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (action_group,
+ window_menu_actions,
+ G_N_ELEMENTS (window_menu_actions),
+ window_menu);
+ ui_path = g_build_filename (WNCK_MENU_UI_DIR, "GNOME_WindowMenuApplet.xml", NULL);
+ panel_applet_setup_menu_from_file (applet, ui_path, action_group);
+ g_free (ui_path);
+ g_object_unref (action_group);
window_menu->selector = wnck_selector_new ();
gtk_container_add (GTK_CONTAINER (window_menu->applet),
diff --git a/applets/wncklet/wncklet.c b/applets/wncklet/wncklet.c
index 728a01f..0bc37ae 100644
--- a/applets/wncklet/wncklet.c
+++ b/applets/wncklet/wncklet.c
@@ -200,18 +200,18 @@ wncklet_factory (PanelApplet *applet,
type_registered = TRUE;
}
- if (!strcmp (iid, "OAFIID:GNOME_WindowMenuApplet"))
+ if (!strcmp (iid, "WindowMenuApplet"))
retval = window_menu_applet_fill (applet);
- else if (!strcmp (iid, "OAFIID:GNOME_WorkspaceSwitcherApplet")||
- !strcmp (iid, "OAFIID:GNOME_PagerApplet"))
+ else if (!strcmp (iid, "WorkspaceSwitcherApplet")||
+ !strcmp (iid, "PagerApplet"))
retval = workspace_switcher_applet_fill (applet);
- else if (!strcmp (iid, "OAFIID:GNOME_WindowListApplet") ||
- !strcmp (iid, "OAFIID:GNOME_TasklistApplet"))
+ else if (!strcmp (iid, "WindowListApplet") ||
+ !strcmp (iid, "TasklistApplet"))
retval = window_list_applet_fill (applet);
- else if (!strcmp (iid, "OAFIID:GNOME_ShowDesktopApplet"))
+ else if (!strcmp (iid, "ShowDesktopApplet"))
retval = show_desktop_applet_fill (applet);
return retval;
@@ -219,16 +219,15 @@ wncklet_factory (PanelApplet *applet,
#ifdef WNCKLET_INPROCESS
-PANEL_APPLET_BONOBO_SHLIB_FACTORY ("OAFIID:GNOME_Wncklet_Factory",
- PANEL_TYPE_APPLET,
- "WindowNavigationApplets",
- wncklet_factory,
- NULL)
+PANEL_APPLET_IN_PROCESS_FACTORY ("WnckletFactory",
+ PANEL_TYPE_APPLET,
+ "Windo wNavigationApplets",
+ wncklet_factory,
+ NULL)
#else
-PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_Wncklet_Factory",
- PANEL_TYPE_APPLET,
- "WindowNavigationApplets",
- "0",
- wncklet_factory,
- NULL)
+PANEL_APPLET_OUT_PROCESS_FACTORY ("WnckletFactory",
+ PANEL_TYPE_APPLET,
+ "WindowNavigationApplets",
+ wncklet_factory,
+ NULL)
#endif
diff --git a/applets/wncklet/workspace-switcher.c b/applets/wncklet/workspace-switcher.c
index 8e2a08e..537c35e 100644
--- a/applets/wncklet/workspace-switcher.c
+++ b/applets/wncklet/workspace-switcher.c
@@ -79,15 +79,12 @@ typedef struct {
guint listeners [3];
} PagerData;
-static void display_properties_dialog (BonoboUIComponent *uic,
- PagerData *pager,
- const gchar *verbname);
-static void display_help_dialog (BonoboUIComponent *uic,
- PagerData *pager,
- const gchar *verbname);
-static void display_about_dialog (BonoboUIComponent *uic,
- PagerData *pager,
- const gchar *verbname);
+static void display_properties_dialog (GtkAction *action,
+ PagerData *pager);
+static void display_help_dialog (GtkAction *action,
+ PagerData *pager);
+static void display_about_dialog (GtkAction *action,
+ PagerData *pager);
static void
pager_update (PagerData *pager)
@@ -338,11 +335,16 @@ destroy_pager(GtkWidget * widget, PagerData *pager)
g_free (pager);
}
-static const BonoboUIVerb pager_menu_verbs [] = {
- BONOBO_UI_UNSAFE_VERB ("PagerPreferences", display_properties_dialog),
- BONOBO_UI_UNSAFE_VERB ("PagerHelp", display_help_dialog),
- BONOBO_UI_UNSAFE_VERB ("PagerAbout", display_about_dialog),
- BONOBO_UI_VERB_END
+static const GtkActionEntry pager_menu_actions [] = {
+ { "PagerPreferences", GTK_STOCK_PROPERTIES, N_("_Preferences"),
+ NULL, NULL,
+ G_CALLBACK (display_properties_dialog) },
+ { "PagerHelp", GTK_STOCK_HELP, N_("_Help"),
+ NULL, NULL,
+ G_CALLBACK (display_help_dialog) },
+ { "PagerAbout", GTK_STOCK_ABOUT, N_("_About"),
+ NULL, NULL,
+ G_CALLBACK (display_about_dialog) }
};
static void
@@ -469,6 +471,8 @@ gboolean
workspace_switcher_applet_fill (PanelApplet *applet)
{
PagerData *pager;
+ GtkActionGroup *action_group;
+ gchar *ui_path;
GError *error;
gboolean display_names;
@@ -546,8 +550,6 @@ workspace_switcher_applet_fill (PanelApplet *applet)
* environments. See wnck_pager_set_orientation() doc */
pager_update (pager);
- gtk_widget_show (pager->applet);
-
g_signal_connect (G_OBJECT (pager->applet),
"realize",
G_CALLBACK (applet_realized),
@@ -568,45 +570,45 @@ workspace_switcher_applet_fill (PanelApplet *applet)
"change_background",
G_CALLBACK (applet_change_background),
pager);
+ gtk_widget_show (pager->applet);
panel_applet_set_background_widget (PANEL_APPLET (pager->applet),
GTK_WIDGET (pager->applet));
-
+
+ action_group = gtk_action_group_new ("WorkspaceSwitcher Applet Actions");
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (action_group,
+ pager_menu_actions,
+ G_N_ELEMENTS (pager_menu_actions),
+ pager);
+ ui_path = g_build_filename (WNCK_MENU_UI_DIR, "GNOME_WorkspaceSwitcherApplet.xml", NULL);
panel_applet_setup_menu_from_file (PANEL_APPLET (pager->applet),
- NULL,
- "GNOME_WorkspaceSwitcherApplet.xml",
- NULL,
- pager_menu_verbs,
- pager);
+ ui_path, action_group);
+ g_free (ui_path);
if (panel_applet_get_locked_down (PANEL_APPLET (pager->applet))) {
- BonoboUIComponent *popup_component;
-
- popup_component = panel_applet_get_popup_component (PANEL_APPLET (pager->applet));
+ GtkAction *action;
- bonobo_ui_component_set_prop (popup_component,
- "/commands/PagerPreferences",
- "hidden", "1",
- NULL);
+ action = gtk_action_group_get_action (action_group, "PagerPreferences");
+ gtk_action_set_visible (action, FALSE);
}
+ g_object_unref (action_group);
return TRUE;
}
static void
-display_help_dialog (BonoboUIComponent *uic,
- PagerData *pager,
- const gchar *verbname)
+display_help_dialog (GtkAction *action,
+ PagerData *pager)
{
wncklet_display_help (pager->applet, "user-guide",
"overview-workspaces", WORKSPACE_SWITCHER_ICON);
}
static void
-display_about_dialog (BonoboUIComponent *uic,
- PagerData *pager,
- const gchar *verbname)
+display_about_dialog (GtkAction *action,
+ PagerData *pager)
{
static const gchar *authors[] =
{
@@ -1035,9 +1037,8 @@ setup_dialog (GtkBuilder *builder,
}
static void
-display_properties_dialog (BonoboUIComponent *uic,
- PagerData *pager,
- const gchar *verbname)
+display_properties_dialog (GtkAction *action,
+ PagerData *pager)
{
if (pager->properties_dialog == NULL) {
GtkBuilder *builder;
diff --git a/configure.in b/configure.in
index 86c018d..1d9b503 100644
--- a/configure.in
+++ b/configure.in
@@ -37,6 +37,10 @@ AC_PATH_PROG(GCONFTOOL, gconftool-2)
GNOME_COMPILE_WARNINGS(maximum)
+m4_pattern_allow([AM_V_GEN])dnl Make autoconf not complain about the rule below
+PANEL_INTLTOOL_PANEL_APPLET_RULE='%.panel-applet: %.panel-applet.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; $(AM_V_GEN) LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< [$]@'
+AC_SUBST([PANEL_INTLTOOL_PANEL_APPLET_RULE])
+
AC_ARG_ENABLE(deprecations,
[AC_HELP_STRING([--enable-deprecations],
[warn about deprecated usages [default=no]])],,
@@ -55,8 +59,6 @@ GDK_PIXBUF_REQUIRED=2.7.1
PANGO_REQUIRED=1.15.4
GLIB_REQUIRED=2.18.0
GTK_REQUIRED=2.15.1
-LIBBONOBOUI_REQUIRED=2.1.1
-ORBIT_REQUIRED=2.4.0
LIBWNCK_REQUIRED=2.19.5
GCONF_REQUIRED=2.6.1
LIBGNOME_MENU_REQUIRED=2.27.92
@@ -65,17 +67,18 @@ LIBEDATASERVER_REQUIRED=1.2.0
LIBEDATASERVERUI_REQUIRED=1.2.0
CAIRO_REQUIRED=1.0.0
DBUS_GLIB_REQUIRED=0.60
+EGG_DBUS_REQUIRED=0.5
GWEATHER_REQUIRED=2.27.90
dnl pkg-config dependency checks
PKG_CHECK_MODULES(EGG_SMCLIENT, ice sm gtk+-2.0)
-PKG_CHECK_MODULES(PANEL, ORBit-2.0 >= $ORBIT_REQUIRED gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED pango >= $PANGO_REQUIRED gtk+-2.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED gio-unix-2.0 >= $GLIB_REQUIRED libbonoboui-2.0 >= $LIBBONOBOUI_REQUIRED gnome-desktop-2.0 >= $LIBGNOME_DESKTOP_REQUIRED gconf-2.0 >= $GCONF_REQUIRED libgnome-menu >= $LIBGNOME_MENU_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED libcanberra-gtk)
+PKG_CHECK_MODULES(PANEL, gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED pango >= $PANGO_REQUIRED gtk+-2.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED gio-unix-2.0 >= $GLIB_REQUIRED gnome-desktop-2.0 >= $LIBGNOME_DESKTOP_REQUIRED gconf-2.0 >= $GCONF_REQUIRED libgnome-menu >= $LIBGNOME_MENU_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED libcanberra-gtk eggdbus-1 >= $EGG_DBUS_REQUIRED)
AC_SUBST(PANEL_CFLAGS)
AC_SUBST(PANEL_LIBS)
-PKG_CHECK_MODULES(LIBPANEL_APPLET, ORBit-2.0 >= $ORBIT_REQUIRED gtk+-2.0 >= $GTK_REQUIRED libbonoboui-2.0 >= $LIBBONOBOUI_REQUIRED gconf-2.0 >= $GCONF_REQUIRED)
+PKG_CHECK_MODULES(LIBPANEL_APPLET, gtk+-2.0 >= $GTK_REQUIRED gconf-2.0 >= $GCONF_REQUIRED eggdbus-1 >= $EGG_DBUS_REQUIRED)
AC_SUBST(LIBPANEL_APPLET_CFLAGS)
AC_SUBST(LIBPANEL_APPLET_LIBS)
@@ -259,16 +262,8 @@ if $PKG_CONFIG --exists "xrandr >= 1.2.0" ; then
AC_DEFINE(HAVE_RANDR, 1, [Have the Xrandr extension library])
fi
-dnl IDL directories
-
-ORBIT_IDL="`$PKG_CONFIG --variable=orbit_idl ORBit-2.0`"
-AC_SUBST(ORBIT_IDL)
-
-BONOBO_IDLDIR="`$PKG_CONFIG --variable=idldir libbonobo-2.0`"
-AC_SUBST(BONOBO_IDLDIR)
-
-BONOBO_ACT_IDLDIR="`$PKG_CONFIG --variable=idldir bonobo-activation-2.0`"
-AC_SUBST(BONOBO_ACT_IDLDIR)
+dnl Applets dir
+AC_SUBST([appletsdir],"\$(datadir)/gnome-panel/applets")
dnl Language Support
@@ -314,7 +309,7 @@ AC_SUBST(REBUILD)
AC_OUTPUT([
Makefile
-idl/Makefile
+data/Makefile
icons/Makefile
icons/16x16/Makefile
icons/22x22/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
new file mode 100644
index 0000000..824ee7a
--- /dev/null
+++ b/data/Makefile.am
@@ -0,0 +1,3 @@
+EXTRA_DIST = panel-applet.xml
+
+-include $(top_srcdir)/git.mk
diff --git a/data/panel-applet.xml b/data/panel-applet.xml
new file mode 100644
index 0000000..5bd7bad
--- /dev/null
+++ b/data/panel-applet.xml
@@ -0,0 +1,35 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+
+<node>
+
+ <annotation name="org.gtk.EggDBus.DeclareEnum" value="AppletOrient">
+ <annotation name="org.gtk.EggDBus.Enum.Member" value="Up" />
+ <annotation name="org.gtk.EggDBus.Enum.Member" value="Down" />
+ <annotation name="org.gtk.EggDBus.Enum.Member" value="Left" />
+ <annotation name="org.gtk.EggDBus.Enum.Member" value="Right" />
+ </annotation>
+
+ <interface name="org.gnome.panel.applet.Applet">
+ <method name="PopupMenu">
+ <arg name="button" type="u" direction="in"/>
+ <arg name="time" type="u" direction="in"/>
+ </method>
+
+ <property name="PrefsKey" type="s" access="readwrite"/>
+ <property name="Orient" type="u" access="readwrite">
+ <annotation name="org.gtk.EggDBus.Type" value="AppletOrient"/>
+ </property>
+ <property name="Size" type="u" access="readwrite"/>
+ <property name="Background" type="s" access="readwrite"/>
+ <property name="Flags" type="u" access="readwrite"/>
+ <property name="SizeHints" type="ai" access="readwrite"/>
+ <property name="Locked" type="b" access="readwrite"/>
+ <property name="LockedDown" type="b" access="readwrite"/>
+
+ <signal name="Move" />
+ <signal name="RemoveFromPanel" />
+ <signal name="Lock" />
+ <signal name="Unlock" />
+ </interface>
+</node>
diff --git a/gnome-panel/Makefile.am b/gnome-panel/Makefile.am
index 08e18aa..e8b8ec6 100644
--- a/gnome-panel/Makefile.am
+++ b/gnome-panel/Makefile.am
@@ -14,7 +14,9 @@ INCLUDES = \
-DBUILDERDIR=\""$(uidir)"\" \
-DICONDIR=\""$(datadir)/gnome-panel/pixmaps"\" \
-DDATADIR=\""$(datadir)"\" \
+ -DPANEL_APPLETS_DIR=\"$(appletsdir)\" \
-DGMENU_I_KNOW_THIS_IS_UNSTABLE \
+ -DEGG_DBUS_I_KNOW_API_IS_SUBJECT_TO_CHANGE \
$(DISABLE_DEPRECATED_CFLAGS) \
$(PANEL_CFLAGS) \
$(WARN_CFLAGS) \
@@ -34,21 +36,30 @@ bin_PROGRAMS = \
$(gnome_panel_OBJECTS): $(BUILT_SOURCES)
-CORBA_SRCLIST = \
- GNOME_Panel-stubs.c \
- GNOME_Panel-skels.c \
- GNOME_Panel-common.c \
- GNOME_Panel.h \
- $(NULL)
-
-$(CORBA_SRCLIST): $(top_srcdir)/idl/GNOME_Panel.idl $(ORBIT_IDL)
- $(AM_V_GEN)$(ORBIT_IDL) -I $(BONOBO_IDLDIR) -I $(BONOBO_ACT_IDLDIR) $(top_srcdir)/idl/GNOME_Panel.idl
+panel-built-sources.stamp: $(top_srcdir)/data/panel-applet.xml
+ eggdbus-binding-tool \
+ --namespace "_Panel" \
+ --dbus-namespace "org.gnome.panel.applet" \
+ --introspection-xml $(top_srcdir)/data/panel-applet.xml \
+ --stamp-file panel-built-sources.stamp
+
+EGGDBUS_SRCLIST = \
+ _panelbindingstypes.h \
+ _panelbindings.h \
+ _panelbindings.c \
+ _panelbindingsmarshal.h \
+ _panelbindingsmarshal.c \
+ _panelapplet.h \
+ _panelapplet.c \
+ _panelappletorient.h \
+ _panelappletorient.c
BUILT_SOURCES = \
- $(CORBA_SRCLIST) \
- panel-typebuiltins.c \
- panel-typebuiltins.h \
- panel-marshal.c \
+ panel-built-sources.stamp \
+ $(EGGDBUS_SRCLIST) \
+ panel-typebuiltins.c \
+ panel-typebuiltins.h \
+ panel-marshal.c \
panel-marshal.h
panel_sources = \
@@ -74,6 +85,8 @@ panel_sources = \
panel-context-menu.c \
launcher.c \
panel-applet-frame.c \
+ panel-applet-container.c \
+ panel-applets-manager.c \
panel-shell.c \
panel-background.c \
panel-background-monitor.c \
@@ -119,6 +132,8 @@ panel_headers = \
panel-context-menu.h \
launcher.h \
panel-applet-frame.h \
+ panel-applet-container.h \
+ panel-applets-manager.h \
panel-shell.h \
panel-background.h \
panel-background-monitor.h \
@@ -147,7 +162,7 @@ panel_headers = \
$(NULL)
gnome_panel_SOURCES = \
- $(CORBA_SRCLIST) \
+ $(EGGDBUS_SRCLIST) \
$(panel_sources) \
$(panel_headers) \
$(NULL)
@@ -191,7 +206,6 @@ EXTRA_DIST = \
nothing.h \
$(schemas_in_files) \
panel-compatibility.schemas \
- $(xmlui_DATA) \
panel-marshal.list \
gnome-panelrc \
$(entries_DATA) \
@@ -202,8 +216,7 @@ EXTRA_DIST = \
panel_enum_headers = \
$(top_srcdir)/gnome-panel/panel-enums.h \
- $(top_srcdir)/gnome-panel/panel-types.h \
- GNOME_Panel.h
+ $(top_srcdir)/gnome-panel/panel-types.h
panel-marshal.h: panel-marshal.list $(GLIB_GENMARSHAL)
$(AM_V_GEN)$(GLIB_GENMARSHAL) $< --header --prefix=panel_marshal > $@
@@ -240,9 +253,6 @@ panel-typebuiltins.h: @REBUILD@ $(panel_enum_headers)
--eprod "GType @enum_name _get_type (void);\n" \
$(panel_enum_headers) > $@
-xmluidir = $(datadir)/gnome-2.0/ui
-xmlui_DATA = GNOME_Panel_Popup.xml
-
rcdir = $(datadir)
rc_DATA = gnome-panelrc
diff --git a/gnome-panel/main.c b/gnome-panel/main.c
index adfb9eb..e314e1d 100644
--- a/gnome-panel/main.c
+++ b/gnome-panel/main.c
@@ -14,8 +14,6 @@
#include <glib/gi18n.h>
-#include <bonobo/bonobo-main.h>
-
#include <libegg/eggdesktopfile.h>
#include <libegg/eggsmclient.h>
@@ -32,6 +30,7 @@
#include "panel-action-protocol.h"
#include "panel-lockdown.h"
#include "panel-icon-names.h"
+#include "panel-applets-manager.h"
#include "xstuff.h"
#include "nothing.cP"
@@ -80,11 +79,6 @@ main (int argc, char **argv)
gtk_init (&argc, &argv);
- if (!bonobo_init (&argc, argv)) {
- g_printerr ("Cannot initialize bonobo.\n");
- return 1;
- }
-
error = NULL;
if (!g_option_context_parse (context, &argc, &argv, &error)) {
g_printerr ("%s\n", error->message);
@@ -106,6 +100,7 @@ main (int argc, char **argv)
return -1;
}
+ panel_applets_manager_init ();
panel_action_protocol_init ();
panel_multiscreen_init ();
panel_init_stock_icons_and_items ();
@@ -137,6 +132,7 @@ main (int argc, char **argv)
gtk_main ();
panel_lockdown_finalize ();
+ panel_applets_manager_shutdown ();
gconf_client_remove_dir (panel_gconf_get_client (),
"/desktop/gnome/interface",
diff --git a/gnome-panel/panel-addto.c b/gnome-panel/panel-addto.c
index b9b71a4..d28018c 100644
--- a/gnome-panel/panel-addto.c
+++ b/gnome-panel/panel-addto.c
@@ -25,8 +25,6 @@
#include <config.h>
#include <string.h>
-#include <libbonobo.h>
-
#include <glib/gi18n.h>
#include <gmenu-tree.h>
@@ -37,6 +35,7 @@
#include "launcher.h"
#include "panel.h"
#include "drawer.h"
+#include "panel-applets-manager.h"
#include "panel-applet-frame.h"
#include "panel-action-button.h"
#include "panel-menu-bar.h"
@@ -183,16 +182,6 @@ static PanelAddtoItemInfo internal_addto_items [] = {
TRUE }
};
-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
- };
-
enum {
COLUMN_ICON,
COLUMN_TEXT,
@@ -395,56 +384,23 @@ panel_addto_setup_internal_applet_drag (GtkTreeView *tree_view,
static GSList *
panel_addto_query_applets (GSList *list)
{
- 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 (_("query returned exception %s\n"),
- BONOBO_EX_REPOID (&env));
-
- CORBA_exception_free (&env);
- CORBA_free (applet_list);
-
- return NULL;
- }
-
- 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]);
+ GList *applet_list, *l;
- langs_gslist = g_slist_reverse (langs_gslist);
+ applet_list = panel_applets_manager_get_applets ();
- for (i = 0; i < applet_list->_length; i++) {
- Bonobo_ServerInfo *info;
- const char *name, *description, *icon;
+ for (l = applet_list; l; l = g_list_next (l)) {
+ PanelAppletInfo *info;
+ const char *iid, *name, *description, *icon;
PanelAddtoItemInfo *applet;
- info = &applet_list->_buffer[i];
+ info = (PanelAppletInfo *)l->data;
- 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);
+ iid = panel_applet_info_get_iid (info);
+ name = panel_applet_info_get_name (info);
+ description = panel_applet_info_get_description (info);
+ icon = panel_applet_info_get_icon (info);
- if (!name ||
- panel_lockdown_is_applet_disabled (info->iid)) {
+ if (!name || panel_lockdown_is_applet_disabled (iid)) {
continue;
}
@@ -453,14 +409,13 @@ panel_addto_query_applets (GSList *list)
applet->name = g_strdup (name);
applet->description = g_strdup (description);
applet->icon = g_strdup (icon);
- applet->iid = g_strdup (info->iid);
+ applet->iid = g_strdup (iid);
applet->static_data = FALSE;
list = g_slist_prepend (list, applet);
}
- g_slist_free (langs_gslist);
- CORBA_free (applet_list);
+ g_list_free (applet_list);
return list;
}
diff --git a/gnome-panel/panel-applet-container.c b/gnome-panel/panel-applet-container.c
new file mode 100644
index 0000000..75f977a
--- /dev/null
+++ b/gnome-panel/panel-applet-container.c
@@ -0,0 +1,1172 @@
+/*
+ * panel-applet-container.c: a container for applets.
+ *
+ * Copyright (C) 2010 Carlos Garcia Campos <carlosgc gnome org>
+ *
+ * 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.
+ *
+ */
+
+#include <string.h>
+#include <gobject/gvaluecollector.h>
+#include <eggdbus/eggdbus.h>
+#include "panel-applet-container.h"
+#include "_panelapplet.h"
+
+struct _PanelAppletContainerPrivate {
+ EggDBusConnection *connection;
+ EggDBusObjectProxy *applet_proxy;
+ gchar *bus_name;
+
+ GtkWidget *socket;
+
+ GHashTable *pending_ops;
+};
+
+enum {
+ APPLET_BROKEN,
+ APPLET_MOVE,
+ APPLET_REMOVE,
+ APPLET_LOCK,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
+typedef struct {
+ const gchar *name;
+ GType type;
+ const gchar *signature;
+ const gchar *dbus_name;
+} AppletPropertyInfo;
+
+static const AppletPropertyInfo applet_properties [] = {
+ { "prefs-key", G_TYPE_STRING, "s", "PrefsKey" },
+ { "orient", G_TYPE_UINT, "u", "Orient" },
+ { "size", G_TYPE_UINT, "u", "Size" },
+ { "size-hints", G_TYPE_OBJECT, "i", "SizeHints" },
+ { "background", G_TYPE_STRING, "s", "Background" },
+ { "flags", G_TYPE_UINT, "u", "Flags" },
+ { "locked", G_TYPE_BOOLEAN, "b", "Locked" },
+ { "locked-down", G_TYPE_BOOLEAN, "b", "LockedDown" }
+};
+
+#define PANEL_APPLET_CONTAINER_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_APPLET_CONTAINER, PanelAppletContainerPrivate))
+
+#define PANEL_APPLET_BUS_NAME "org.gnome.panel.applet.%s"
+#define PANEL_APPLET_FACTORY_INTERFACE "org.gnome.panel.applet.AppletFactory"
+#define PANEL_APPLET_FACTORY_OBJECT_PATH "/org/gnome/panel/applet/%s"
+#define PANEL_APPLET_INTERFACE "org.gnome.panel.applet.Applet"
+
+static gboolean panel_applet_container_plug_removed (PanelAppletContainer *container);
+
+G_DEFINE_TYPE (PanelAppletContainer, panel_applet_container, GTK_TYPE_EVENT_BOX);
+
+GQuark
+panel_applet_container_error_quark (void)
+{
+ return g_quark_from_static_string ("panel-applet-container-error-quark");
+}
+
+static void
+panel_applet_container_init (PanelAppletContainer *container)
+{
+ container->priv = PANEL_APPLET_CONTAINER_GET_PRIVATE (container);
+
+ container->priv->socket = gtk_socket_new ();
+ g_signal_connect_swapped (container->priv->socket, "plug-removed",
+ G_CALLBACK (panel_applet_container_plug_removed),
+ container);
+
+ container->priv->pending_ops = g_hash_table_new_full (g_direct_hash,
+ g_direct_equal,
+ NULL,
+ (GDestroyNotify)g_object_unref);
+
+ gtk_container_add (GTK_CONTAINER (container),
+ container->priv->socket);
+ gtk_widget_show (container->priv->socket);
+}
+
+static void
+panel_applet_container_cancel_pending_operations (PanelAppletContainer *container)
+{
+ GList *keys, *l;
+
+ if (!container->priv->pending_ops)
+ return;
+
+ keys = g_hash_table_get_keys (container->priv->pending_ops);
+ for (l = keys; l; l = g_list_next (l)) {
+ GCancellable *cancellable;
+
+ cancellable = G_CANCELLABLE (g_hash_table_lookup (container->priv->pending_ops,
+ l->data));
+ g_cancellable_cancel (cancellable);
+ }
+ g_list_free (keys);
+}
+
+static void
+panel_applet_container_dispose (GObject *object)
+{
+ PanelAppletContainer *container = PANEL_APPLET_CONTAINER (object);
+
+ if (container->priv->pending_ops) {
+ panel_applet_container_cancel_pending_operations (container);
+ g_hash_table_destroy (container->priv->pending_ops);
+ container->priv->pending_ops = NULL;
+ }
+
+ if (container->priv->bus_name) {
+ g_free (container->priv->bus_name);
+ container->priv->bus_name = NULL;
+ }
+
+ if (container->priv->applet_proxy) {
+ g_object_unref (container->priv->applet_proxy);
+ container->priv->applet_proxy = NULL;
+ }
+
+ G_OBJECT_CLASS (panel_applet_container_parent_class)->dispose (object);
+}
+
+static void
+panel_applet_container_class_init (PanelAppletContainerClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (PanelAppletContainerPrivate));
+
+ gobject_class->dispose = panel_applet_container_dispose;
+
+ signals[APPLET_BROKEN] =
+ g_signal_new ("applet-broken",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PanelAppletContainerClass, applet_broken),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ signals[APPLET_MOVE] =
+ g_signal_new ("applet-move",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PanelAppletContainerClass, applet_move),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ signals[APPLET_REMOVE] =
+ g_signal_new ("applet-remove",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PanelAppletContainerClass, applet_remove),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+ signals[APPLET_LOCK] =
+ g_signal_new ("applet-lock",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PanelAppletContainerClass, applet_lock),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE,
+ 1, G_TYPE_BOOLEAN);
+}
+
+static _PanelAppletOrient
+get_panel_applet_orient (PanelOrientation orientation)
+{
+ switch (orientation) {
+ case PANEL_ORIENTATION_TOP:
+ return _PANEL_APPLET_ORIENT_DOWN;
+ case PANEL_ORIENTATION_BOTTOM:
+ return _PANEL_APPLET_ORIENT_UP;
+ case PANEL_ORIENTATION_LEFT:
+ return _PANEL_APPLET_ORIENT_RIGHT;
+ case PANEL_ORIENTATION_RIGHT:
+ return _PANEL_APPLET_ORIENT_LEFT;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+}
+
+static const AppletPropertyInfo *
+panel_applet_container_child_property_get_info (const gchar *property_name)
+{
+ gint i;
+
+ g_assert (property_name != NULL);
+
+ for (i = 0; i < G_N_ELEMENTS (applet_properties); i++) {
+ if (g_ascii_strcasecmp (applet_properties[i].name, property_name) == 0)
+ return &applet_properties[i];
+ }
+
+ return NULL;
+}
+
+static void
+set_applet_property_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
+ PanelAppletContainer *container;
+ GError *error = NULL;
+
+ if (!egg_dbus_properties_set_finish (EGG_DBUS_PROPERTIES (source_object), res, &error)) {
+ if (!g_error_matches (error, EGG_DBUS_ERROR, EGG_DBUS_ERROR_CANCELLED))
+ g_warning ("Error setting property: %s\n", error->message);
+ g_simple_async_result_set_from_error (result, error);
+ g_error_free (error);
+ }
+
+ container = PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (result)));
+ g_hash_table_remove (container->priv->pending_ops, result);
+ g_simple_async_result_complete (result);
+ g_object_unref (result);
+
+ /* g_async_result_get_source_object returns new ref */
+ g_object_unref (container);
+}
+
+static void
+panel_applet_container_set_applet_property (PanelAppletContainer *container,
+ const gchar *property_name,
+ EggDBusVariant *variant,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ EggDBusObjectProxy *proxy = container->priv->applet_proxy;
+ GSimpleAsyncResult *result;
+
+ if (!proxy)
+ return;
+
+ result = g_simple_async_result_new (G_OBJECT (container),
+ callback,
+ user_data,
+ panel_applet_container_set_applet_property);
+
+ if (cancellable)
+ g_object_ref (cancellable);
+ else
+ cancellable = g_cancellable_new ();
+ g_hash_table_insert (container->priv->pending_ops, result, cancellable);
+
+ egg_dbus_properties_set (EGG_DBUS_QUERY_INTERFACE_PROPERTIES (proxy),
+ EGG_DBUS_CALL_FLAGS_NONE,
+ PANEL_APPLET_INTERFACE,
+ property_name,
+ variant,
+ cancellable,
+ set_applet_property_cb,
+ result);
+}
+
+static void
+get_applet_property_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
+ PanelAppletContainer *container;
+ EggDBusVariant *variant = NULL;
+ GError *error = NULL;
+
+ if (!egg_dbus_properties_get_finish (EGG_DBUS_PROPERTIES (source_object), &variant, res, &error)) {
+ if (!g_error_matches (error, EGG_DBUS_ERROR, EGG_DBUS_ERROR_CANCELLED))
+ g_warning ("Error getting property: %s\n", error->message);
+ g_simple_async_result_set_from_error (result, error);
+ g_error_free (error);
+ } else {
+ g_simple_async_result_set_op_res_gpointer (result, variant,
+ (GDestroyNotify)g_object_unref);
+ }
+
+ container = PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (result)));
+ g_hash_table_remove (container->priv->pending_ops, result);
+ g_simple_async_result_complete (result);
+ g_object_unref (result);
+
+ /* g_async_result_get_source_object returns new ref */
+ g_object_unref (container);
+}
+
+static void
+panel_applet_container_get_applet_property (PanelAppletContainer *container,
+ const gchar *property_name,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ EggDBusObjectProxy *proxy = container->priv->applet_proxy;
+ GSimpleAsyncResult *result;
+
+ if (!proxy)
+ return;
+
+ result = g_simple_async_result_new (G_OBJECT (container),
+ callback,
+ user_data,
+ panel_applet_container_get_applet_property);
+ if (cancellable)
+ g_object_ref (cancellable);
+ else
+ cancellable = g_cancellable_new ();
+ g_hash_table_insert (container->priv->pending_ops, result, cancellable);
+
+ egg_dbus_properties_get (EGG_DBUS_QUERY_INTERFACE_PROPERTIES (proxy),
+ EGG_DBUS_CALL_FLAGS_NONE,
+ PANEL_APPLET_INTERFACE,
+ property_name,
+ cancellable,
+ get_applet_property_cb,
+ result);
+}
+
+GtkWidget *
+panel_applet_container_new (void)
+{
+ GtkWidget *container;
+
+ container = GTK_WIDGET (g_object_new (PANEL_TYPE_APPLET_CONTAINER, NULL));
+
+ return container;
+}
+
+static void
+panel_applet_container_child_move (_PanelApplet *instance,
+ PanelAppletContainer *container)
+{
+ g_signal_emit_by_name (container, "applet-move");
+}
+
+static void
+panel_applet_container_child_remove (_PanelApplet *instance,
+ PanelAppletContainer *container)
+{
+ g_signal_emit_by_name (container, "applet-remove");
+}
+
+static void
+panel_applet_container_child_lock (_PanelApplet *instance,
+ PanelAppletContainer *container)
+{
+ g_signal_emit_by_name (container, "applet-lock", TRUE);
+}
+
+static void
+panel_applet_container_child_unlock (_PanelApplet *instance,
+ PanelAppletContainer *container)
+{
+ g_signal_emit_by_name (container, "applet-lock", FALSE);
+}
+
+static void
+panel_applet_container_child_size_hints_changed (_PanelApplet *instance,
+ GParamSpec *pscpec,
+ PanelAppletContainer *container)
+{
+ /* FIXME: this is very inefficient, EgDBusChanged already
+ * contains a map with the new prop values, but we don't have
+ * access to that signal. Calling g_object_get() here would
+ * call GetAll synchronously so we emit the prop change and
+ * frame will ask again the value of the prop
+ */
+ g_signal_emit_by_name (container, "child-notify::size-hints", pscpec);
+}
+
+static void
+panel_applet_container_child_flags_changed (_PanelApplet *instance,
+ GParamSpec *pscpec,
+ PanelAppletContainer *container)
+{
+ /* FIXME: this is very inefficient, EgDBusChanged already
+ * contains a map with the new prop values, but we don't have
+ * access to that signal. Calling g_object_get() here would
+ * call GetAll synchronously so we emit the prop change and
+ * frame will ask again the value of the prop
+ */
+ g_signal_emit_by_name (container, "child-notify::flags", pscpec);
+}
+
+static gboolean
+panel_applet_container_plug_removed (PanelAppletContainer *container)
+{
+ if (!container->priv->applet_proxy)
+ return FALSE;
+
+ panel_applet_container_cancel_pending_operations (container);
+ g_object_unref (container->priv->applet_proxy);
+ container->priv->applet_proxy = NULL;
+
+ g_signal_emit (container, signals[APPLET_BROKEN], 0);
+
+ /* Continue destroying, in case of reloading
+ * a new frame widget is created
+ */
+ return FALSE;
+}
+
+static void
+get_applet_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ EggDBusConnection *connection = EGG_DBUS_CONNECTION (source_object);
+ GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
+ PanelAppletContainer *container;
+ EggDBusMessage *reply;
+ guint32 xid = 0;
+ GError *error = NULL;
+
+ container = PANEL_APPLET_CONTAINER (g_async_result_get_source_object (G_ASYNC_RESULT (result)));
+ reply = egg_dbus_connection_send_message_with_reply_finish (connection, res, &error);
+ if (reply) {
+ gchar *applet_path;
+
+ if (egg_dbus_message_extract_object_path (reply, &applet_path, &error)) {
+ container->priv->applet_proxy =
+ egg_dbus_connection_get_object_proxy (container->priv->connection,
+ container->priv->bus_name,
+ applet_path);
+ g_signal_connect (_PANEL_QUERY_INTERFACE_APPLET (container->priv->applet_proxy),
+ "move",
+ G_CALLBACK (panel_applet_container_child_move),
+ container);
+ g_signal_connect (_PANEL_QUERY_INTERFACE_APPLET (container->priv->applet_proxy),
+ "remove-from-panel",
+ G_CALLBACK (panel_applet_container_child_remove),
+ container);
+ g_signal_connect (_PANEL_QUERY_INTERFACE_APPLET (container->priv->applet_proxy),
+ "lock",
+ G_CALLBACK (panel_applet_container_child_lock),
+ container);
+ g_signal_connect (_PANEL_QUERY_INTERFACE_APPLET (container->priv->applet_proxy),
+ "unlock",
+ G_CALLBACK (panel_applet_container_child_unlock),
+ container);
+ /* Frame is only interested in size-hints and flags so
+ * we don't notify any other property changes.
+ * Connecting directly to egg-dbus-changed would be better
+ * but it doesn't work :-(
+ */
+ g_signal_connect (_PANEL_QUERY_INTERFACE_APPLET (container->priv->applet_proxy),
+ "notify::size-hints",
+ G_CALLBACK (panel_applet_container_child_size_hints_changed),
+ container);
+ g_signal_connect (_PANEL_QUERY_INTERFACE_APPLET (container->priv->applet_proxy),
+ "notify::flags",
+ G_CALLBACK (panel_applet_container_child_flags_changed),
+ container);
+ g_free (applet_path);
+ egg_dbus_message_extract_uint (reply, &xid, &error);
+ }
+ g_object_unref (reply);
+ }
+
+ if (error) {
+ g_simple_async_result_set_from_error (result, error);
+ g_error_free (error);
+ }
+
+ g_simple_async_result_complete (result);
+ g_object_unref (result);
+
+ if (xid > 0)
+ gtk_socket_add_id (GTK_SOCKET (container->priv->socket), xid);
+
+ /* g_async_result_get_source_object returns new ref */
+ g_object_unref (container);
+}
+
+static void
+panel_applet_container_get_applet (PanelAppletContainer *container,
+ const gchar *iid,
+ EggDBusHashMap *props,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ EggDBusMessage *message;
+ GSimpleAsyncResult *result;
+ gint screen;
+ gchar *bus_name;
+ gchar *object_path;
+ gchar *factory_id;
+ gchar *applet_id;
+
+ result = g_simple_async_result_new (G_OBJECT (container),
+ callback,
+ user_data,
+ panel_applet_container_get_applet);
+
+ if (!container->priv->connection) {
+ container->priv->connection = egg_dbus_connection_get_for_bus (EGG_DBUS_BUS_TYPE_SESSION);
+ if (!container->priv->connection) {
+ g_simple_async_result_set_error (result,
+ EGG_DBUS_ERROR,
+ EGG_DBUS_ERROR_DBUS_FAILED,
+ "%s", "Failed to connect to the D-BUS daemon");
+ g_simple_async_result_complete (result);
+ g_object_unref (result);
+
+ return;
+ }
+ }
+
+ applet_id = g_strrstr (iid, "::");
+ if (!applet_id) {
+ g_simple_async_result_set_error (result,
+ PANEL_APPLET_CONTAINER_ERROR,
+ PANEL_APPLET_CONTAINER_INVALID_APPLET,
+ "Invalid applet iid: %s", iid);
+ g_simple_async_result_complete (result);
+ g_object_unref (result);
+
+ return;
+ }
+
+ factory_id = g_strndup (iid, strlen (iid) - strlen (applet_id));
+ applet_id += 2;
+
+ screen = gdk_screen_get_number (gtk_widget_get_screen (container->priv->socket));
+
+ object_path = g_strdup_printf (PANEL_APPLET_FACTORY_OBJECT_PATH, factory_id);
+ bus_name = g_strdup_printf (PANEL_APPLET_BUS_NAME, factory_id);
+
+ if (container->priv->bus_name)
+ g_free (container->priv->bus_name);
+ container->priv->bus_name = bus_name;
+
+ message = egg_dbus_connection_new_message_for_method_call (container->priv->connection,
+ NULL,
+ bus_name,
+ object_path,
+ PANEL_APPLET_FACTORY_INTERFACE,
+ "GetApplet");
+ egg_dbus_message_append_string (message, applet_id, NULL);
+ egg_dbus_message_append_int (message, screen, NULL);
+ egg_dbus_message_append_map (message, props, "s", "v", NULL);
+
+ egg_dbus_connection_send_message_with_reply (container->priv->connection,
+ EGG_DBUS_CALL_FLAGS_NONE,
+ message,
+ NULL,
+ cancellable,
+ get_applet_cb,
+ result);
+ g_free (factory_id);
+ g_free (object_path);
+ g_object_unref (message);
+}
+
+static EggDBusHashMap *
+contruct_properties_map (PanelAppletContainer *container,
+ const gchar *first_prop_name,
+ va_list var_args)
+{
+ EggDBusHashMap *map;
+ const gchar *name;
+
+ map = egg_dbus_hash_map_new (G_TYPE_STRING,
+ g_free,
+ EGG_DBUS_TYPE_VARIANT,
+ g_object_unref);
+
+ name = first_prop_name;
+ while (name) {
+ const AppletPropertyInfo *info;
+ EggDBusVariant *variant;
+ GValue *value;
+ gchar *error = NULL;
+
+ info = panel_applet_container_child_property_get_info (name);
+ if (!info) {
+ g_warning ("%s: Applet has no child property named `%s'",
+ G_STRLOC, name);
+ break;
+ }
+
+ value = g_new0 (GValue, 1);
+ g_value_init (value, info->type);
+ G_VALUE_COLLECT (value, var_args, 0, &error);
+ if (error) {
+ g_warning ("%s: %s", G_STRLOC, error);
+ g_free (error);
+ g_value_unset (value);
+ g_free (value);
+
+ break;
+ }
+
+ if (G_VALUE_HOLDS_STRING (value) &&
+ strlen (g_value_get_string (value)) == 0) {
+ name = va_arg (var_args, gchar*);
+ continue;
+ }
+
+ /* For some reason libpanel-applet and panel use
+ * a different logic for orientation, so we need
+ * to convert it. We should fix this.
+ */
+ if (strcmp (name, "orient") == 0) {
+ _PanelAppletOrient orient;
+
+ orient = get_panel_applet_orient (g_value_get_uint (value));
+ g_value_set_uint (value, orient);
+ }
+
+ variant = egg_dbus_variant_new_for_gvalue (value, info->signature);
+ egg_dbus_hash_map_insert (map, g_strdup (name), variant);
+ name = va_arg (var_args, gchar*);
+ }
+
+ return map;
+}
+
+void
+panel_applet_container_add (PanelAppletContainer *container,
+ const gchar *iid,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data,
+ const gchar *first_prop_name,
+ ...)
+{
+ EggDBusHashMap *map;
+ va_list var_args;
+
+ g_return_if_fail (PANEL_IS_APPLET_CONTAINER (container));
+ g_return_if_fail (iid != NULL);
+
+ panel_applet_container_cancel_pending_operations (container);
+
+ va_start (var_args, first_prop_name);
+ map = contruct_properties_map (container, first_prop_name, var_args);
+ va_end (var_args);
+
+ panel_applet_container_get_applet (container, iid, map, cancellable,
+ callback, user_data);
+ g_object_unref (map);
+}
+
+gboolean
+panel_applet_container_add_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error)
+{
+ GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
+
+ g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == panel_applet_container_get_applet);
+
+ return !g_simple_async_result_propagate_error (simple, error);
+}
+
+/* Child Properties */
+void
+panel_applet_container_child_set_property (PanelAppletContainer *container,
+ const gchar *property_name,
+ const GValue *value,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ const AppletPropertyInfo *info;
+ EggDBusVariant *variant;
+
+ info = panel_applet_container_child_property_get_info (property_name);
+ if (!info) {
+ g_simple_async_report_error_in_idle (G_OBJECT (container),
+ callback, user_data,
+ PANEL_APPLET_CONTAINER_ERROR,
+ PANEL_APPLET_CONTAINER_INVALID_CHILD_PROPERTY,
+ "%s: Applet has no child property named `%s'",
+ G_STRLOC, property_name);
+ return;
+ }
+
+ variant = egg_dbus_variant_new_for_gvalue (value, info->signature);
+ panel_applet_container_set_applet_property (container,
+ info->dbus_name,
+ variant,
+ cancellable,
+ callback,
+ user_data);
+ g_object_unref (variant);
+}
+
+gboolean
+panel_applet_container_child_set_property_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error)
+{
+ GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
+
+ g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == panel_applet_container_set_applet_property);
+
+ return !g_simple_async_result_propagate_error (simple, error);
+}
+
+void
+panel_applet_container_child_set_uint (PanelAppletContainer *container,
+ const gchar *property_name,
+ guint value,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ const AppletPropertyInfo *info;
+ EggDBusVariant *variant;
+
+ info = panel_applet_container_child_property_get_info (property_name);
+ if (!info) {
+ g_simple_async_report_error_in_idle (G_OBJECT (container),
+ callback, user_data,
+ PANEL_APPLET_CONTAINER_ERROR,
+ PANEL_APPLET_CONTAINER_INVALID_CHILD_PROPERTY,
+ "%s: Applet has no child property named `%s'",
+ G_STRLOC, property_name);
+ return;
+ }
+
+ variant = egg_dbus_variant_new_for_uint (value);
+ panel_applet_container_set_applet_property (container,
+ info->dbus_name,
+ variant,
+ cancellable,
+ callback,
+ user_data);
+ g_object_unref (variant);
+}
+
+gboolean
+panel_applet_container_child_set_uint_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error)
+{
+ return panel_applet_container_child_set_property_finish (container, result, error);
+}
+
+void
+panel_applet_container_child_set_boolean (PanelAppletContainer *container,
+ const gchar *property_name,
+ gboolean value,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ const AppletPropertyInfo *info;
+ EggDBusVariant *variant;
+
+ info = panel_applet_container_child_property_get_info (property_name);
+ if (!info) {
+ g_simple_async_report_error_in_idle (G_OBJECT (container),
+ callback, user_data,
+ PANEL_APPLET_CONTAINER_ERROR,
+ PANEL_APPLET_CONTAINER_INVALID_CHILD_PROPERTY,
+ "%s: Applet has no child property named `%s'",
+ G_STRLOC, property_name);
+ return;
+ }
+
+ variant = egg_dbus_variant_new_for_boolean (value);
+ panel_applet_container_set_applet_property (container,
+ info->dbus_name,
+ variant,
+ cancellable,
+ callback,
+ user_data);
+ g_object_unref (variant);
+}
+
+gboolean
+panel_applet_container_child_set_boolean_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error)
+{
+ return panel_applet_container_child_set_property_finish (container, result, error);
+}
+
+void
+panel_applet_container_child_set_string (PanelAppletContainer *container,
+ const gchar *property_name,
+ const gchar *value,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ const AppletPropertyInfo *info;
+ EggDBusVariant *variant;
+
+ info = panel_applet_container_child_property_get_info (property_name);
+ if (!info) {
+ g_simple_async_report_error_in_idle (G_OBJECT (container),
+ callback, user_data,
+ PANEL_APPLET_CONTAINER_ERROR,
+ PANEL_APPLET_CONTAINER_INVALID_CHILD_PROPERTY,
+ "%s: Applet has no child property named `%s'",
+ G_STRLOC, property_name);
+ return;
+ }
+
+ variant = egg_dbus_variant_new_for_string (value);
+ panel_applet_container_set_applet_property (container,
+ info->dbus_name,
+ variant,
+ cancellable,
+ callback,
+ user_data);
+ g_object_unref (variant);
+}
+
+gboolean
+panel_applet_container_child_set_string_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error)
+{
+ return panel_applet_container_child_set_property_finish (container, result, error);
+}
+
+void
+panel_applet_container_child_set_size_hints (PanelAppletContainer *container,
+ const gint *size_hints,
+ guint n_hints,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ const AppletPropertyInfo *info;
+ EggDBusVariant *variant;
+ EggDBusArraySeq *seq;
+ gint i;
+
+ info = panel_applet_container_child_property_get_info ("size-hints");
+
+ seq = egg_dbus_array_seq_new (G_TYPE_INT, NULL, NULL, NULL);
+ for (i = 0; i < n_hints; i++)
+ egg_dbus_array_seq_add_fixed (seq, (guint64)size_hints[i]);
+ variant = egg_dbus_variant_new_for_seq (seq, info->signature);
+ g_object_unref (seq);
+ panel_applet_container_set_applet_property (container,
+ info->dbus_name,
+ variant,
+ cancellable,
+ callback,
+ user_data);
+ g_object_unref (variant);
+}
+
+gboolean
+panel_applet_container_child_set_size_hints_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error)
+{
+ return panel_applet_container_child_set_property_finish (container, result, error);
+}
+
+void
+panel_applet_container_child_set_orientation (PanelAppletContainer *container,
+ PanelOrientation orientation,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ panel_applet_container_child_set_uint (container, "orient",
+ get_panel_applet_orient (orientation),
+ cancellable, callback, user_data);
+}
+
+gboolean
+panel_applet_container_child_set_orientation_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error)
+{
+ return panel_applet_container_child_set_property_finish (container, result, error);
+}
+
+
+
+void
+panel_applet_container_child_get_property (PanelAppletContainer *container,
+ const gchar *property_name,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ const AppletPropertyInfo *info;
+
+ info = panel_applet_container_child_property_get_info (property_name);
+ if (!info) {
+ g_simple_async_report_error_in_idle (G_OBJECT (container),
+ callback, user_data,
+ PANEL_APPLET_CONTAINER_ERROR,
+ PANEL_APPLET_CONTAINER_INVALID_CHILD_PROPERTY,
+ "%s: Applet has no child property named `%s'",
+ G_STRLOC, property_name);
+ return;
+ }
+
+ panel_applet_container_get_applet_property (container,
+ info->dbus_name,
+ cancellable,
+ callback,
+ user_data);
+}
+
+gboolean
+panel_applet_container_child_get_property_finish (PanelAppletContainer *container,
+ GValue *value,
+ GAsyncResult *result,
+ GError **error)
+{
+ GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
+ EggDBusVariant *variant;
+
+ if (g_simple_async_result_propagate_error (simple, error))
+ return FALSE;
+
+ variant = EGG_DBUS_VARIANT (g_simple_async_result_get_op_res_gpointer (simple));
+ *value = *egg_dbus_variant_get_gvalue (variant);
+ g_value_copy (egg_dbus_variant_get_gvalue (variant), value);
+
+ return TRUE;
+}
+
+void
+panel_applet_container_child_get_uint (PanelAppletContainer *container,
+ const gchar *property_name,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ panel_applet_container_child_get_property (container,
+ property_name,
+ cancellable,
+ callback,
+ user_data);
+}
+
+gboolean
+panel_applet_container_child_get_uint_finish (PanelAppletContainer *container,
+ guint *value,
+ GAsyncResult *result,
+ GError **error)
+{
+ GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
+ EggDBusVariant *variant;
+
+ if (g_simple_async_result_propagate_error (simple, error))
+ return FALSE;
+
+ variant = EGG_DBUS_VARIANT (g_simple_async_result_get_op_res_gpointer (simple));
+ *value = egg_dbus_variant_get_uint (variant);
+
+ return TRUE;
+}
+
+void
+panel_applet_container_child_get_boolean (PanelAppletContainer *container,
+ const gchar *property_name,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ panel_applet_container_child_get_property (container,
+ property_name,
+ cancellable,
+ callback,
+ user_data);
+}
+
+gboolean
+panel_applet_container_child_get_boolean_finish (PanelAppletContainer *container,
+ gboolean *value,
+ GAsyncResult *result,
+ GError **error)
+{
+ GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
+ EggDBusVariant *variant;
+
+ if (g_simple_async_result_propagate_error (simple, error))
+ return FALSE;
+
+ variant = EGG_DBUS_VARIANT (g_simple_async_result_get_op_res_gpointer (simple));
+ *value = egg_dbus_variant_get_boolean (variant);
+
+ return TRUE;
+}
+
+void
+panel_applet_container_child_get_string (PanelAppletContainer *container,
+ const gchar *property_name,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ panel_applet_container_child_get_property (container,
+ property_name,
+ cancellable,
+ callback,
+ user_data);
+}
+
+gboolean
+panel_applet_container_child_get_string_finish (PanelAppletContainer *container,
+ gchar **value,
+ GAsyncResult *result,
+ GError **error)
+{
+ GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
+ EggDBusVariant *variant;
+
+ if (g_simple_async_result_propagate_error (simple, error))
+ return FALSE;
+
+ variant = EGG_DBUS_VARIANT (g_simple_async_result_get_op_res_gpointer (simple));
+ *value = g_strdup (egg_dbus_variant_get_string (variant));
+
+ return TRUE;
+}
+
+void
+panel_applet_container_child_get_size_hints (PanelAppletContainer *container,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ panel_applet_container_child_get_property (container,
+ "size-hints",
+ cancellable,
+ callback,
+ user_data);
+}
+
+gboolean
+panel_applet_container_child_get_size_hints_finish (PanelAppletContainer *container,
+ gint **size_hints,
+ guint *n_elements,
+ GAsyncResult *result,
+ GError **error)
+{
+ GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
+ EggDBusVariant *variant;
+ EggDBusArraySeq *seq;
+ gint i;
+
+ if (g_simple_async_result_propagate_error (simple, error))
+ return FALSE;
+
+ variant = EGG_DBUS_VARIANT (g_simple_async_result_get_op_res_gpointer (simple));
+ seq = egg_dbus_variant_get_seq (variant);
+ *n_elements = egg_dbus_array_seq_get_size (seq);
+ *size_hints = *n_elements > 0 ? g_new (gint, *n_elements) : NULL;
+ for (i = 0; i < *n_elements; i++) {
+ size_hints[0][i] = egg_dbus_array_seq_get_fixed (seq, i);
+
+ }
+ g_object_unref (seq);
+
+ return TRUE;
+}
+
+static void
+child_popup_menu_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ EggDBusConnection *connection = EGG_DBUS_CONNECTION (source_object);
+ GSimpleAsyncResult *result = G_SIMPLE_ASYNC_RESULT (user_data);
+ EggDBusMessage *reply;
+ GError *error = NULL;
+
+ reply = egg_dbus_connection_send_message_with_reply_finish (connection, res, &error);
+ if (error) {
+ g_simple_async_result_set_from_error (result, error);
+ g_error_free (error);
+ }
+
+ if (reply)
+ g_object_unref (reply);
+
+ g_simple_async_result_complete (result);
+ g_object_unref (result);
+}
+
+void
+panel_applet_container_child_popup_menu (PanelAppletContainer *container,
+ guint button,
+ guint32 timestamp,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ EggDBusMessage *message;
+ GSimpleAsyncResult *result;
+ EggDBusObjectProxy *proxy = container->priv->applet_proxy;
+
+ if (!proxy)
+ return;
+
+ result = g_simple_async_result_new (G_OBJECT (container),
+ callback,
+ user_data,
+ panel_applet_container_child_popup_menu);
+
+ message = egg_dbus_connection_new_message_for_method_call (container->priv->connection,
+ NULL,
+ egg_dbus_object_proxy_get_name (proxy),
+ egg_dbus_object_proxy_get_object_path (proxy),
+ PANEL_APPLET_INTERFACE,
+ "PopupMenu");
+ egg_dbus_message_append_uint (message, button, NULL);
+ egg_dbus_message_append_uint (message, timestamp, NULL);
+
+ egg_dbus_connection_send_message_with_reply (container->priv->connection,
+ EGG_DBUS_CALL_FLAGS_NONE,
+ message,
+ NULL,
+ cancellable,
+ child_popup_menu_cb,
+ result);
+ g_object_unref (message);
+
+}
+
+gboolean
+panel_applet_container_child_popup_menu_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error)
+{
+ GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
+
+ g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == panel_applet_container_child_popup_menu);
+
+ return !g_simple_async_result_propagate_error (simple, error);
+}
diff --git a/gnome-panel/panel-applet-container.h b/gnome-panel/panel-applet-container.h
new file mode 100644
index 0000000..3bd745c
--- /dev/null
+++ b/gnome-panel/panel-applet-container.h
@@ -0,0 +1,191 @@
+/*
+ * panel-applet-container.c: a container for applets.
+ *
+ * Copyright (C) 2010 Carlos Garcia Campos <carlosgc gnome org>
+ *
+ * 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.
+ *
+ */
+
+#ifndef __PANEL_APPLET_CONTAINER_H__
+#define __PANEL_APPLET_CONTAINER_H__
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#include "panel.h"
+
+G_BEGIN_DECLS
+
+#define PANEL_TYPE_APPLET_CONTAINER (panel_applet_container_get_type ())
+#define PANEL_APPLET_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PANEL_TYPE_APPLET_CONTAINER, PanelAppletContainer))
+#define PANEL_APPLET_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PANEL_TYPE_APPLET_CONTAINER, PanelAppletContainerClass))
+#define PANEL_IS_APPLET_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PANEL_TYPE_APPLET_CONTAINER))
+#define PANEL_IS_APPLET_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANEL_TYPE_APPLET_CONTAINER))
+#define PANEL_APPLET_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANEL_TYPE_APPLET_CONTAINER, PanelAppletContainerClass))
+
+#define PANEL_APPLET_CONTAINER_ERROR (panel_applet_container_error_quark())
+
+typedef enum {
+ PANEL_APPLET_CONTAINER_INVALID_APPLET,
+ PANEL_APPLET_CONTAINER_INVALID_CHILD_PROPERTY
+} PanelAppletContainerError;
+
+typedef struct _PanelAppletContainer PanelAppletContainer;
+typedef struct _PanelAppletContainerClass PanelAppletContainerClass;
+typedef struct _PanelAppletContainerPrivate PanelAppletContainerPrivate;
+
+struct _PanelAppletContainer {
+ GtkEventBox parent;
+
+ PanelAppletContainerPrivate *priv;
+};
+
+struct _PanelAppletContainerClass {
+ GtkEventBoxClass parent_class;
+
+ /* Signals */
+ void (*applet_broken) (PanelAppletContainer *container);
+ void (*applet_move) (PanelAppletContainer *container);
+ void (*applet_remove) (PanelAppletContainer *container);
+ void (*applet_lock) (PanelAppletContainer *container,
+ gboolean locked);
+};
+
+GType panel_applet_container_get_type (void) G_GNUC_CONST;
+GQuark panel_applet_container_error_quark (void) G_GNUC_CONST;
+GtkWidget *panel_applet_container_new (void);
+
+
+void panel_applet_container_add (PanelAppletContainer *container,
+ const gchar *iid,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data,
+ const gchar *first_prop_name,
+ ...);
+gboolean panel_applet_container_add_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error);
+void panel_applet_container_child_popup_menu (PanelAppletContainer *container,
+ guint button,
+ guint32 timestamp,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean panel_applet_container_child_popup_menu_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error);
+void panel_applet_container_child_set_property (PanelAppletContainer *container,
+ const gchar *property_name,
+ const GValue *value,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean panel_applet_container_child_set_property_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error);
+void panel_applet_container_child_set_uint (PanelAppletContainer *container,
+ const gchar *property_name,
+ guint value,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean panel_applet_container_child_set_uint_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error);
+void panel_applet_container_child_set_boolean (PanelAppletContainer *container,
+ const gchar *property_name,
+ gboolean value,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean panel_applet_container_child_set_boolean_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error);
+void panel_applet_container_child_set_string (PanelAppletContainer *container,
+ const gchar *property_name,
+ const gchar *value,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean panel_applet_container_child_set_string_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error);
+void panel_applet_container_child_set_size_hints (PanelAppletContainer *container,
+ const gint *size_hints,
+ guint n_hints,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean panel_applet_container_child_set_size_hints_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error);
+void panel_applet_container_child_set_orientation (PanelAppletContainer *container,
+ PanelOrientation orientation,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean panel_applet_container_child_set_orientation_finish (PanelAppletContainer *container,
+ GAsyncResult *result,
+ GError **error);
+void panel_applet_container_child_get_property (PanelAppletContainer *container,
+ const gchar *property_name,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean panel_applet_container_child_get_property_finish (PanelAppletContainer *container,
+ GValue *value,
+ GAsyncResult *result,
+ GError **error);
+void panel_applet_container_child_get_uint (PanelAppletContainer *container,
+ const gchar *property_name,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean panel_applet_container_child_get_uint_finish (PanelAppletContainer *container,
+ guint *value,
+ GAsyncResult *result,
+ GError **error);
+void panel_applet_container_child_get_boolean (PanelAppletContainer *container,
+ const gchar *property_name,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean panel_applet_container_child_get_boolean_finish (PanelAppletContainer *container,
+ gboolean *value,
+ GAsyncResult *result,
+ GError **error);
+void panel_applet_container_child_get_string (PanelAppletContainer *container,
+ const gchar *property_name,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean panel_applet_container_child_get_string_finish (PanelAppletContainer *container,
+ gchar **value,
+ GAsyncResult *result,
+ GError **error);
+void panel_applet_container_child_get_size_hints (PanelAppletContainer *container,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean panel_applet_container_child_get_size_hints_finish (PanelAppletContainer *container,
+ gint **size_hints,
+ guint *n_elements,
+ GAsyncResult *result,
+ GError **error);
+G_END_DECLS
+
+#endif /* __PANEL_APPLET_CONTAINER_H__ */
diff --git a/gnome-panel/panel-applet-frame.c b/gnome-panel/panel-applet-frame.c
index 7e1e0f5..686eb3b 100644
--- a/gnome-panel/panel-applet-frame.c
+++ b/gnome-panel/panel-applet-frame.c
@@ -2,6 +2,7 @@
/*
* panel-applet-frame.c: panel side container for applets
*
+ * Copyright (C) 2010 Carlos Garcia Campos <carlosgc gnome org>
* Copyright (C) 2001 - 2003 Sun Microsystems, Inc.
*
* This program is free software; you can redistribute it and/or
@@ -28,12 +29,12 @@
#include <glib/gi18n.h>
-#include <libbonoboui.h>
#include <gconf/gconf.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include "panel-applet-frame.h"
+#include "panel-applets-manager.h"
#include "panel-profile.h"
#include "panel-util.h"
#include "panel.h"
@@ -43,45 +44,36 @@
#include "panel-lockdown.h"
#include "panel-stock-icons.h"
#include "xstuff.h"
+#include "panel-compatibility.h"
-G_DEFINE_TYPE (PanelAppletFrame, panel_applet_frame, GTK_TYPE_EVENT_BOX)
+G_DEFINE_TYPE (PanelAppletFrame, panel_applet_frame, PANEL_TYPE_APPLET_CONTAINER)
#define PANEL_APPLET_FRAME_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PANEL_TYPE_APPLET_FRAME, PanelAppletFramePrivate))
#define HANDLE_SIZE 10
-
-#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"
-
+#define PANEL_APPLET_PREFS_KEY "/apps/panel/applets/%s/prefs"
struct _PanelAppletFramePrivate {
- GNOME_Vertigo_PanelAppletShell applet_shell;
- CORBA_Object control;
- Bonobo_PropertyBag property_bag;
- BonoboUIComponent *ui_component;
+ PanelWidget *panel;
+ AppletInfo *applet_info;
- PanelWidget *panel;
- AppletInfo *applet_info;
- PanelOrientation orientation;
+ PanelOrientation orientation;
- gchar *iid;
+ gchar *iid;
- GtkAllocation child_allocation;
- GdkRectangle handle_rect;
+ GtkAllocation child_allocation;
+ GdkRectangle handle_rect;
- guint has_handle : 1;
+ guint has_handle : 1;
+
+ GCancellable *bg_cancellable;
};
typedef struct {
- PanelAppletFrame *frame;
- gboolean locked;
- int position;
- gboolean exactpos;
- char *id;
+ gboolean locked;
+ int position;
+ gboolean exactpos;
+ char *id;
} PanelAppletFrameActivating;
/* Keep in sync with panel-applet.h. Uggh.
@@ -95,94 +87,26 @@ typedef enum {
static GSList *no_reload_applets = NULL;
-static void panel_applet_frame_cnx_broken (ORBitConnection *cnx,
- PanelAppletFrame *frame);
-
-static void panel_applet_frame_activated (CORBA_Object object,
- const char *error_reason,
- gpointer data);
-
-void
-panel_applet_frame_sync_menu_state (PanelAppletFrame *frame)
-{
- PanelWidget *panel_widget;
- gboolean locked_down;
- gboolean locked;
- gboolean lockable;
- gboolean movable;
- gboolean removable;
-
- panel_widget = PANEL_WIDGET (GTK_WIDGET (frame)->parent);
-
- lockable = panel_applet_lockable (frame->priv->applet_info);
- movable = panel_applet_can_freely_move (frame->priv->applet_info);
- removable = panel_profile_id_lists_are_writable ();
-
- locked = panel_widget_get_applet_locked (panel_widget, GTK_WIDGET (frame));
-
- bonobo_ui_component_set_prop (frame->priv->ui_component,
- "/commands/LockAppletToPanel",
- "state",
- locked ? "1" : "0",
- NULL);
-
- /* First sensitivity */
- bonobo_ui_component_set_prop (frame->priv->ui_component,
- "/commands/LockAppletToPanel",
- "sensitive",
- lockable ? "1" : "0",
- NULL);
-
- bonobo_ui_component_set_prop (frame->priv->ui_component,
- "/commands/RemoveAppletFromPanel",
- "sensitive",
- (locked && !lockable) ? "0" : (removable ? "1" : "0"),
- NULL);
-
- bonobo_ui_component_set_prop (frame->priv->ui_component,
- "/commands/MoveApplet",
- "sensitive",
- locked ? "0" : (movable ? "1" : "0"),
- NULL);
-
- /* Second visibility */
- locked_down = panel_lockdown_get_locked_down ();
-
- bonobo_ui_component_set_prop (frame->priv->ui_component,
- "/commands/LockAppletToPanel",
- "hidden",
- locked_down ? "1" : "0",
- NULL);
-
- bonobo_ui_component_set_prop (frame->priv->ui_component,
- "/commands/LockSeparator",
- "hidden",
- locked_down ? "1" : "0",
- NULL);
-
- bonobo_ui_component_set_prop (frame->priv->ui_component,
- "/commands/RemoveAppletFromPanel",
- "hidden",
- locked_down ? "1" : "0",
- NULL);
-
- bonobo_ui_component_set_prop (frame->priv->ui_component,
- "/commands/MoveApplet",
- "hidden",
- locked_down ? "1" : "0",
- NULL);
-}
+static char *panel_applet_frame_get_background_string (PanelAppletFrame *frame,
+ PanelWidget *panel,
+ PanelBackgroundType type);
static void
-panel_applet_frame_set_flags_from_any (PanelAppletFrame *frame,
- const CORBA_any *any)
+panel_applet_frame_get_flags_cb (PanelAppletContainer *container,
+ GAsyncResult *res,
+ PanelAppletFrame *frame)
{
gboolean major;
gboolean minor;
gboolean old_has_handle;
- int flags;
-
- flags = BONOBO_ARG_GET_SHORT (any);
+ guint flags;
+ GError *error = NULL;
+
+ if (!panel_applet_container_child_get_uint_finish (container, &flags, res, &error)) {
+ g_warning ("%s\n", error->message);
+ g_error_free (error);
+ return;
+ }
major = flags & APPLET_EXPAND_MAJOR;
minor = flags & APPLET_EXPAND_MINOR;
@@ -204,123 +128,241 @@ panel_applet_frame_set_flags_from_any (PanelAppletFrame *frame,
}
static void
-panel_applet_frame_set_size_hints_from_any (PanelAppletFrame *frame,
- const CORBA_any *any)
+panel_applet_frame_get_size_hints_cb (PanelAppletContainer *container,
+ GAsyncResult *res,
+ PanelAppletFrame *frame)
{
- CORBA_sequence_CORBA_long *seq;
- int *size_hints;
- int extra_size;
- int i;
-
- seq = any->_value;
-
- size_hints = g_new0 (int, seq->_length);
+ gint *size_hints = NULL;
+ guint n_elements;
+ GError *error = NULL;
+
+ if (!panel_applet_container_child_get_size_hints_finish (container, &size_hints,
+ &n_elements, res, &error)) {
+ g_warning ("%s\n", error->message);
+ g_error_free (error);
+ return;
+ }
if (frame->priv->has_handle) {
- extra_size = HANDLE_SIZE + 1;
-
- for (i = 0; i < seq->_length; i++)
- size_hints [i] = seq->_buffer [i] + extra_size;
+ gint extra_size = HANDLE_SIZE + 1;
+ gint i;
+
+ for (i = 0; i < n_elements; i++)
+ size_hints[i] += extra_size;
}
-
+
panel_widget_set_applet_size_hints (frame->priv->panel,
GTK_WIDGET (frame),
size_hints,
- seq->_length);
+ n_elements);
+}
+
+static void
+panel_applet_frame_flags_changed (PanelAppletContainer *container,
+ GParamSpec *pspec,
+ PanelAppletFrame *frame)
+{
+ panel_applet_container_child_get_uint (container, "flags", NULL,
+ (GAsyncReadyCallback)panel_applet_frame_get_flags_cb,
+ frame);
+}
+
+static void
+panel_applet_frame_size_hints_changed (PanelAppletContainer *container,
+ GParamSpec *pspec,
+ PanelAppletFrame *frame)
+{
+ panel_applet_container_child_get_size_hints (container, NULL,
+ (GAsyncReadyCallback)panel_applet_frame_get_size_hints_cb,
+ frame);
}
static void
panel_applet_frame_init_properties (PanelAppletFrame *frame)
{
- CORBA_any *any;
-
- any = bonobo_pbclient_get_value (frame->priv->property_bag,
- PROPERTY_FLAGS,
- BONOBO_ARG_SHORT,
- NULL);
- if (any) {
- panel_applet_frame_set_flags_from_any (frame, any);
- CORBA_free (any);
- }
-
- any = bonobo_pbclient_get_value (frame->priv->property_bag,
- PROPERTY_SIZE_HINTS,
- TC_CORBA_sequence_CORBA_long,
- NULL);
- if (any) {
- panel_applet_frame_set_size_hints_from_any (frame, any);
- CORBA_free (any);
- }
+ PanelAppletContainer *container = PANEL_APPLET_CONTAINER (frame);
+
+ panel_applet_container_child_get_uint (container, "flags", NULL,
+ (GAsyncReadyCallback)panel_applet_frame_get_flags_cb,
+ frame);
+ panel_applet_container_child_get_size_hints (container, NULL,
+ (GAsyncReadyCallback)panel_applet_frame_get_size_hints_cb,
+ frame);
+ g_signal_connect (container, "child-notify::flags",
+ G_CALLBACK (panel_applet_frame_flags_changed),
+ frame);
+ g_signal_connect (container, "child-notify::size-hints",
+ G_CALLBACK (panel_applet_frame_size_hints_changed),
+ frame);
}
+void
+panel_applet_frame_sync_menu_state (PanelAppletFrame *frame)
+{
+ PanelWidget *panel_widget;
+ gboolean locked_down;
+ gboolean locked;
+ gboolean lockable;
+ gboolean movable;
+ gboolean removable;
+
+ panel_widget = PANEL_WIDGET (GTK_WIDGET (frame)->parent);
+
+ lockable = panel_applet_lockable (frame->priv->applet_info);
+ movable = panel_applet_can_freely_move (frame->priv->applet_info);
+ removable = panel_profile_id_lists_are_writable ();
+
+ locked = panel_widget_get_applet_locked (panel_widget, GTK_WIDGET (frame));
+ locked_down = panel_lockdown_get_locked_down ();
+
+ panel_applet_container_child_set_boolean (PANEL_APPLET_CONTAINER (frame),
+ "locked", lockable && locked,
+ NULL, NULL, NULL);
+ panel_applet_container_child_set_boolean (PANEL_APPLET_CONTAINER (frame),
+ "locked-down", locked_down,
+ NULL, NULL, NULL);
+}
+
+enum {
+ LOADING_FAILED_RESPONSE_DONT_DELETE,
+ LOADING_FAILED_RESPONSE_DELETE
+};
+
static void
-popup_handle_remove (BonoboUIComponent *uic,
- PanelAppletFrame *frame,
- const gchar *verbname)
+panel_applet_frame_loading_failed_response (GtkWidget *dialog,
+ guint response,
+ char *id)
{
- AppletInfo *info;
+ gtk_widget_destroy (dialog);
- info = frame->priv->applet_info;
- frame->priv->applet_info = NULL;
+ if (response == LOADING_FAILED_RESPONSE_DELETE &&
+ !panel_lockdown_get_locked_down () &&
+ panel_profile_id_lists_are_writable ()) {
+ GSList *item;
- panel_profile_delete_object (info);
+ item = g_slist_find_custom (no_reload_applets, id,
+ (GCompareFunc) strcmp);
+ if (item) {
+ g_free (item->data);
+ no_reload_applets = g_slist_delete_link (no_reload_applets,
+ item);
+ }
+
+ panel_profile_remove_from_list (PANEL_GCONF_APPLETS, id);
+ }
+
+ g_free (id);
}
static void
-listener_popup_handle_lock (BonoboUIComponent *uic,
- const char *path,
- Bonobo_UIComponent_EventType type,
- const char *state,
- gpointer data)
+panel_applet_frame_loading_failed (PanelAppletFrame *frame,
+ const char *id)
{
- PanelAppletFrame *frame;
- AppletInfo *info;
- gboolean s;
+ GtkWidget *dialog;
+ char *problem_txt;
+ gboolean locked_down;
- g_assert (!strcmp (path, "LockAppletToPanel"));
+ no_reload_applets = g_slist_prepend (no_reload_applets,
+ g_strdup (id));
- if (type != Bonobo_UIComponent_STATE_CHANGED)
- return;
+ locked_down = panel_lockdown_get_locked_down ();
- if (!state)
- return;
+ problem_txt = g_strdup_printf (_("The panel encountered a problem "
+ "while loading \"%s\"."),
+ frame->priv->iid);
- frame = (PanelAppletFrame *) data;
- info = frame->priv->applet_info;
- s = (strcmp (state, "1") == 0);
+ dialog = gtk_message_dialog_new (NULL, 0,
+ locked_down ? GTK_MESSAGE_INFO : GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_NONE,
+ "%s", problem_txt);
+ g_free (problem_txt);
- if (panel_widget_get_applet_locked (PANEL_WIDGET (info->widget->parent),
- info->widget) == s)
- return;
+ if (locked_down) {
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ GTK_STOCK_OK, LOADING_FAILED_RESPONSE_DONT_DELETE,
+ NULL);
+ } else {
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ _("Do you want to delete the applet "
+ "from your configuration?"));
+ gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+ PANEL_STOCK_DONT_DELETE, LOADING_FAILED_RESPONSE_DONT_DELETE,
+ GTK_STOCK_DELETE, LOADING_FAILED_RESPONSE_DELETE,
+ NULL);
+ }
- panel_applet_toggle_locked (frame->priv->applet_info);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+ LOADING_FAILED_RESPONSE_DONT_DELETE);
- panel_applet_frame_sync_menu_state (frame);
+ gtk_window_set_screen (GTK_WINDOW (dialog),
+ gtk_window_get_screen (GTK_WINDOW (frame->priv->panel->toplevel)));
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (panel_applet_frame_loading_failed_response),
+ g_strdup (id));
+
+ panel_widget_register_open_dialog (frame->priv->panel, dialog);
+ gtk_window_set_urgency_hint (GTK_WINDOW (dialog), TRUE);
+ /* FIXME: http://bugzilla.gnome.org/show_bug.cgi?id=165132 */
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Error"));
+
+ gtk_widget_show_all (dialog);
+
+ g_free (frame->priv->iid);
+ frame->priv->iid = NULL;
+
+ gtk_widget_destroy (GTK_WIDGET (frame));
}
static void
-popup_handle_move (BonoboUIComponent *uic,
- PanelAppletFrame *frame,
- const gchar *verbname)
+panel_applet_frame_activated (PanelAppletContainer *container,
+ GAsyncResult *res,
+ PanelAppletFrameActivating *frame_act)
{
- GtkWidget *widget;
+ PanelAppletFrame *frame = PANEL_APPLET_FRAME (container);
+ GtkWidget *widget = NULL;
+ AppletInfo *info;
+ GError *error = NULL;
- g_return_if_fail (GTK_IS_WIDGET (frame));
+ if (!panel_applet_container_add_finish (container, res, &error)) {
+ g_warning (G_STRLOC ": failed to load applet %s:\n%s",
+ frame->priv->iid, error->message);
+ g_error_free (error);
+ goto error_out;
+ }
- widget = GTK_WIDGET (frame);
-
- g_return_if_fail (PANEL_IS_WIDGET (widget->parent));
+ gtk_widget_show_all (GTK_WIDGET (frame));
- panel_widget_applet_drag_start (
- PANEL_WIDGET (widget->parent), widget, PW_DRAG_OFF_CENTER, GDK_CURRENT_TIME);
-}
+ info = panel_applet_register (GTK_WIDGET (frame), GTK_WIDGET (frame),
+ NULL, frame->priv->panel,
+ frame_act->locked, frame_act->position,
+ frame_act->exactpos, PANEL_OBJECT_BONOBO,
+ frame_act->id);
+ frame->priv->applet_info = info;
-static BonoboUIVerb popup_verbs [] = {
- BONOBO_UI_UNSAFE_VERB ("RemoveAppletFromPanel", popup_handle_remove),
- BONOBO_UI_UNSAFE_VERB ("MoveApplet", popup_handle_move),
+ panel_widget_set_applet_size_constrained (frame->priv->panel,
+ GTK_WIDGET (frame), TRUE);
- BONOBO_UI_VERB_END
-};
+ panel_applet_frame_sync_menu_state (frame);
+ panel_applet_frame_init_properties (frame);
+
+ panel_lockdown_notify_add (G_CALLBACK (panel_applet_frame_sync_menu_state),
+ frame);
+
+ panel_applet_stop_loading (frame_act->id);
+ g_free (frame_act->id);
+ g_free (frame_act);
+
+ return;
+
+error_out:
+ panel_applet_frame_loading_failed (frame, frame_act->id);
+ if (widget)
+ g_object_unref (widget);
+ panel_applet_stop_loading (frame_act->id);
+ g_free (frame_act->id);
+ g_free (frame_act);
+}
static void
panel_applet_frame_load (const gchar *iid,
@@ -331,8 +373,9 @@ panel_applet_frame_load (const gchar *iid,
const char *id)
{
PanelAppletFrame *frame;
- CORBA_Environment ev;
PanelAppletFrameActivating *frame_act;
+ gchar *prefs_key;
+ gchar *background;
g_return_if_fail (iid != NULL);
g_return_if_fail (panel != NULL);
@@ -349,20 +392,37 @@ panel_applet_frame_load (const gchar *iid,
frame->priv->panel = panel;
frame->priv->iid = g_strdup (iid);
+ if (!panel_applets_manager_factory_activate (iid)) {
+ panel_applet_frame_loading_failed (frame, id);
+ panel_applet_stop_loading (id);
+
+ return;
+ }
+
frame_act = g_new (PanelAppletFrameActivating, 1);
- frame_act->frame = frame;
frame_act->locked = locked;
frame_act->position = position;
frame_act->exactpos = exactpos;
frame_act->id = g_strdup (id);
- CORBA_exception_init (&ev);
-
- bonobo_activation_activate_from_id_async (frame->priv->iid, 0,
- (BonoboActivationCallback) panel_applet_frame_activated,
- frame_act, &ev);
-
- CORBA_exception_free (&ev);
+ prefs_key = g_strdup_printf (PANEL_APPLET_PREFS_KEY, frame_act->id);
+ background = panel_applet_frame_get_background_string (frame,
+ frame->priv->panel,
+ frame->priv->panel->background.type);
+
+ panel_applet_container_add (PANEL_APPLET_CONTAINER (frame),
+ frame->priv->iid, NULL,
+ (GAsyncReadyCallback)panel_applet_frame_activated,
+ frame_act,
+ "prefs-key", prefs_key,
+ "background", background ? background : "",
+ "orient", panel_widget_get_applet_orientation (frame->priv->panel),
+ "size", frame->priv->panel->sz,
+ "locked", locked,
+ "locked-down", panel_lockdown_get_locked_down (),
+ NULL);
+ g_free (prefs_key);
+ g_free (background);
}
void
@@ -371,17 +431,13 @@ panel_applet_frame_load_from_gconf (PanelWidget *panel_widget,
int position,
const char *id)
{
- const char *key;
- char *applet_iid;
+ gchar *applet_iid;
g_return_if_fail (panel_widget != NULL);
g_return_if_fail (id != NULL);
- key = panel_gconf_full_key (PANEL_GCONF_APPLETS, id, "bonobo_iid");
- applet_iid = gconf_client_get_string (panel_gconf_get_client (),
- key, NULL);
-
- if (!applet_iid || !applet_iid[0])
+ applet_iid = panel_compatiblity_get_applet_iid (id);
+ if (!applet_iid)
return;
panel_applet_frame_load (applet_iid, panel_widget,
@@ -401,11 +457,11 @@ panel_applet_frame_create (PanelToplevel *toplevel,
g_return_if_fail (iid != NULL);
- client = panel_gconf_get_client ();
+ client = panel_gconf_get_client ();
id = panel_profile_prepare_object (PANEL_OBJECT_BONOBO, toplevel, position, FALSE);
- key = panel_gconf_full_key (PANEL_GCONF_APPLETS, id, "bonobo_iid");
+ key = panel_gconf_full_key (PANEL_GCONF_APPLETS, id, "applet_iid");
gconf_client_set_string (client, key, iid, NULL);
panel_profile_add_to_list (PANEL_GCONF_APPLETS, id);
@@ -413,61 +469,43 @@ panel_applet_frame_create (PanelToplevel *toplevel,
g_free (id);
}
+static void
+change_orientation_cb (PanelAppletContainer *container,
+ GAsyncResult *res)
+{
+ GError *error = NULL;
+
+ if (!panel_applet_container_child_set_orientation_finish (container, res, &error)) {
+ g_warning ("%s\n", error->message);
+ g_error_free (error);
+
+ return;
+ }
+
+ gtk_widget_queue_resize (GTK_WIDGET (container));
+}
+
void
panel_applet_frame_change_orientation (PanelAppletFrame *frame,
PanelOrientation orientation)
{
- CORBA_unsigned_short orient = 0;
-
if (orientation == frame->priv->orientation)
return;
frame->priv->orientation = orientation;
-
- 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 (frame->priv->property_bag,
- PROPERTY_ORIENT,
- orient,
- NULL);
-
- gtk_widget_queue_resize (GTK_WIDGET (frame));
+ panel_applet_container_child_set_orientation (PANEL_APPLET_CONTAINER (frame),
+ orientation,
+ NULL,
+ (GAsyncReadyCallback)change_orientation_cb,
+ NULL);
}
void
panel_applet_frame_change_size (PanelAppletFrame *frame,
- PanelSize size)
+ guint size)
{
- /* 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 (frame->priv->property_bag,
- PROPERTY_SIZE,
- size,
- NULL);
+ panel_applet_container_child_set_uint (PANEL_APPLET_CONTAINER (frame),
+ "size", size, NULL, NULL, NULL);
}
static char *
@@ -502,6 +540,20 @@ panel_applet_frame_get_background_string (PanelAppletFrame *frame,
return panel_background_make_string (&panel->background, x, y);
}
+static void
+container_child_background_set (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ PanelAppletContainer *container = PANEL_APPLET_CONTAINER (source_object);
+ PanelAppletFrame *frame = PANEL_APPLET_FRAME (source_object);
+
+ panel_applet_container_child_set_string_finish (container, res, NULL);
+
+ g_object_unref (frame->priv->bg_cancellable);
+ frame->priv->bg_cancellable = NULL;
+}
+
void
panel_applet_frame_change_background (PanelAppletFrame *frame,
PanelBackgroundType type)
@@ -523,10 +575,15 @@ panel_applet_frame_change_background (PanelAppletFrame *frame,
frame, PANEL_WIDGET (GTK_WIDGET (frame)->parent), type);
if (bg_str != NULL) {
- bonobo_pbclient_set_string (frame->priv->property_bag,
- PROPERTY_BACKGROUND,
- bg_str, NULL);
-
+ if (frame->priv->bg_cancellable)
+ g_cancellable_cancel (frame->priv->bg_cancellable);
+ frame->priv->bg_cancellable = g_cancellable_new ();
+
+ panel_applet_container_child_set_string (PANEL_APPLET_CONTAINER (frame),
+ "background", bg_str,
+ frame->priv->bg_cancellable,
+ container_child_background_set,
+ NULL);
g_free (bg_str);
}
}
@@ -536,30 +593,11 @@ panel_applet_frame_finalize (GObject *object)
{
PanelAppletFrame *frame = PANEL_APPLET_FRAME (object);
+ panel_applets_manager_factory_deactivate (frame->priv->iid);
+
panel_lockdown_notify_remove (G_CALLBACK (panel_applet_frame_sync_menu_state),
frame);
- 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_cnx_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_free (frame->priv->iid);
frame->priv->iid = NULL;
@@ -827,26 +865,18 @@ panel_applet_frame_button_changed (GtkWidget *widget,
}
}
break;
- case 3:
+ case 3:
if (event->type == GDK_BUTTON_PRESS ||
event->type == GDK_2BUTTON_PRESS) {
- CORBA_Environment env;
-
- CORBA_exception_init (&env);
+ PanelAppletContainer *container;
+ container = PANEL_APPLET_CONTAINER (frame);
gdk_pointer_ungrab (GDK_CURRENT_TIME);
-
- GNOME_Vertigo_PanelAppletShell_popup_menu (
- frame->priv->applet_shell,
- event->button,
- event->time, &env);
- if (BONOBO_EX (&env))
- g_warning (_("Exception from popup_menu '%s'\n"), env._id);
-
- CORBA_exception_free (&env);
-
+ panel_applet_container_child_popup_menu (container,
+ event->button,
+ event->time,
+ NULL, NULL, NULL);
handled = TRUE;
-
} else if (event->type == GDK_BUTTON_RELEASE)
handled = TRUE;
break;
@@ -909,61 +939,26 @@ panel_applet_frame_reload_response (GtkWidget *dialog,
gtk_widget_destroy (dialog);
}
-static char *
-panel_applet_frame_get_name (char *iid)
-{
- Bonobo_ServerInfoList *list;
- char *query;
- char *retval = NULL;
-
- query = g_strdup_printf ("iid == '%s'", iid);
-
- list = bonobo_activation_query (query, NULL, NULL);
- if (list && list->_length > 0 && list->_buffer) {
- Bonobo_ServerInfo *info = &list->_buffer [0];
- const char * const *langs;
- GSList *langs_gslist;
- int i;
-
- 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);
-
- retval = g_strdup (bonobo_server_info_prop_lookup (
- info, "name", langs_gslist));
-
- g_slist_free (langs_gslist);
- }
-
- g_free (query);
- CORBA_free (list);
-
- return retval;
-}
-
static void
-panel_applet_frame_cnx_broken (ORBitConnection *cnx,
- PanelAppletFrame *frame)
+panel_applet_frame_applet_broken (PanelAppletContainer *container)
{
- GtkWidget *dialog;
- GdkScreen *screen;
- char *applet_name = NULL;
- char *dialog_txt;
-
- g_return_if_fail (PANEL_IS_APPLET_FRAME (frame));
+ PanelAppletFrame *frame = PANEL_APPLET_FRAME (container);
+ GtkWidget *dialog;
+ GdkScreen *screen;
+ const char *applet_name = NULL;
+ char *dialog_txt;
screen = gtk_widget_get_screen (GTK_WIDGET (frame));
if (xstuff_is_display_dead ())
return;
- if (frame->priv->iid)
- applet_name = panel_applet_frame_get_name (frame->priv->iid);
+ if (frame->priv->iid) {
+ PanelAppletInfo *info;
+
+ info = (PanelAppletInfo *)panel_applets_manager_get_applet_info (frame->priv->iid);
+ applet_name = panel_applet_info_get_name (info);
+ }
if (applet_name)
dialog_txt = g_strdup_printf (_("\"%s\" has quit unexpectedly"), applet_name);
@@ -1000,99 +995,49 @@ panel_applet_frame_cnx_broken (ORBitConnection *cnx,
gtk_window_set_title (GTK_WINDOW (dialog), _("Error"));
gtk_widget_show (dialog);
- g_free (applet_name);
g_free (dialog_txt);
}
-enum {
- LOADING_FAILED_RESPONSE_DONT_DELETE,
- LOADING_FAILED_RESPONSE_DELETE
-};
-
static void
-panel_applet_frame_loading_failed_response (GtkWidget *dialog,
- guint response,
- char *id)
+panel_applet_frame_applet_move (PanelAppletContainer *container)
{
- gtk_widget_destroy (dialog);
-
- if (response == LOADING_FAILED_RESPONSE_DELETE &&
- !panel_lockdown_get_locked_down () &&
- panel_profile_id_lists_are_writable ()) {
- GSList *item;
+ GtkWidget *widget = GTK_WIDGET (container);
- item = g_slist_find_custom (no_reload_applets, id,
- (GCompareFunc) strcmp);
- if (item) {
- g_free (item->data);
- no_reload_applets = g_slist_delete_link (no_reload_applets,
- item);
- }
-
- panel_profile_remove_from_list (PANEL_GCONF_APPLETS, id);
- }
+ if (!PANEL_IS_WIDGET (widget->parent))
+ return;
- g_free (id);
+ panel_widget_applet_drag_start (PANEL_WIDGET (widget->parent),
+ widget,
+ PW_DRAG_OFF_CENTER,
+ GDK_CURRENT_TIME);
}
static void
-panel_applet_frame_loading_failed (PanelAppletFrame *frame,
- const char *id)
+panel_applet_frame_applet_remove (PanelAppletContainer *container)
{
- GtkWidget *dialog;
- char *problem_txt;
- gboolean locked_down;
-
- no_reload_applets = g_slist_prepend (no_reload_applets,
- g_strdup (id));
-
- locked_down = panel_lockdown_get_locked_down ();
-
- problem_txt = g_strdup_printf (_("The panel encountered a problem "
- "while loading \"%s\"."),
- frame->priv->iid);
-
- dialog = gtk_message_dialog_new (NULL, 0,
- locked_down ? GTK_MESSAGE_INFO : GTK_MESSAGE_WARNING,
- GTK_BUTTONS_NONE,
- "%s", problem_txt);
- g_free (problem_txt);
-
- if (locked_down) {
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- GTK_STOCK_OK, LOADING_FAILED_RESPONSE_DONT_DELETE,
- NULL);
- } else {
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("Do you want to delete the applet "
- "from your configuration?"));
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- PANEL_STOCK_DONT_DELETE, LOADING_FAILED_RESPONSE_DONT_DELETE,
- GTK_STOCK_DELETE, LOADING_FAILED_RESPONSE_DELETE,
- NULL);
- }
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- LOADING_FAILED_RESPONSE_DONT_DELETE);
+ PanelAppletFrame *frame = PANEL_APPLET_FRAME (container);
+ AppletInfo *info;
- gtk_window_set_screen (GTK_WINDOW (dialog),
- gtk_window_get_screen (GTK_WINDOW (frame->priv->panel->toplevel)));
+ if (!frame->priv->applet_info)
+ return;
- g_signal_connect (dialog, "response",
- G_CALLBACK (panel_applet_frame_loading_failed_response),
- g_strdup (id));
+ info = frame->priv->applet_info;
+ frame->priv->applet_info = NULL;
- panel_widget_register_open_dialog (frame->priv->panel, dialog);
- gtk_window_set_urgency_hint (GTK_WINDOW (dialog), TRUE);
- /* FIXME: http://bugzilla.gnome.org/show_bug.cgi?id=165132 */
- gtk_window_set_title (GTK_WINDOW (dialog), _("Error"));
+ panel_profile_delete_object (info);
+}
- gtk_widget_show_all (dialog);
+static void
+panel_applet_frame_applet_lock (PanelAppletContainer *container,
+ gboolean locked)
+{
+ PanelAppletFrame *frame = PANEL_APPLET_FRAME (container);
+ PanelWidget *panel_widget = PANEL_WIDGET (GTK_WIDGET (frame)->parent);
- g_free (frame->priv->iid);
- frame->priv->iid = NULL;
+ if (panel_widget_get_applet_locked (panel_widget, GTK_WIDGET (frame)) == locked)
+ return;
- gtk_widget_destroy (GTK_WIDGET (frame));
+ panel_applet_toggle_locked (frame->priv->applet_info);
}
static void
@@ -1100,6 +1045,7 @@ panel_applet_frame_class_init (PanelAppletFrameClass *klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
+ PanelAppletContainerClass *container_class = (PanelAppletContainerClass *) klass;
gobject_class->finalize = panel_applet_frame_finalize;
@@ -1109,6 +1055,11 @@ panel_applet_frame_class_init (PanelAppletFrameClass *klass)
widget_class->button_press_event = panel_applet_frame_button_changed;
widget_class->button_release_event = panel_applet_frame_button_changed;
+ container_class->applet_broken = panel_applet_frame_applet_broken;
+ container_class->applet_move = panel_applet_frame_applet_move;
+ container_class->applet_remove = panel_applet_frame_applet_remove;
+ container_class->applet_lock = panel_applet_frame_applet_lock;
+
g_type_class_add_private (klass, sizeof (PanelAppletFramePrivate));
}
@@ -1117,320 +1068,10 @@ panel_applet_frame_init (PanelAppletFrame *frame)
{
frame->priv = PANEL_APPLET_FRAME_GET_PRIVATE (frame);
- frame->priv->applet_shell = CORBA_OBJECT_NIL;
- frame->priv->property_bag = CORBA_OBJECT_NIL;
- frame->priv->ui_component = NULL;
- frame->priv->panel = NULL;
- frame->priv->orientation = PANEL_ORIENTATION_TOP;
- frame->priv->applet_info = NULL;
- frame->priv->has_handle = FALSE;
-}
-
-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,
- PanelWidget *panel)
-{
- PanelOrientation orientation;
- const char *retval = NULL;
-
- orientation = panel_widget_get_applet_orientation (panel);
-
- 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,
- PanelWidget *panel)
-{
- const char *retval = NULL;
-
- if (panel->sz <= PANEL_SIZE_XX_SMALL)
- retval = "xx-small";
- else if (panel->sz <= PANEL_SIZE_X_SMALL)
- retval = "x-small";
- else if (panel->sz <= PANEL_SIZE_SMALL)
- retval = "small";
- else if (panel->sz <= PANEL_SIZE_MEDIUM)
- retval = "medium";
- else if (panel->sz <= PANEL_SIZE_LARGE)
- retval = "large";
- else if (panel->sz <= PANEL_SIZE_X_LARGE)
- retval = "x-large";
- else
- retval = "xx-large";
-
- return retval;
-}
-
-static char *
-panel_applet_frame_construct_item (PanelAppletFrame *frame,
- PanelWidget *panel,
- const char *id)
-{
- char *retval;
- char *bg_str;
- gboolean locked_down;
-
- bg_str = panel_applet_frame_get_background_string (
- frame, panel, panel->background.type);
-
- if (bg_str == NULL)
- bg_str = g_strdup ("");
-
- locked_down = panel_lockdown_get_locked_down ();
-
- retval = g_strdup_printf (
- "prefs_key=/apps/panel/applets/%s/prefs;"
- "background=%s;orient=%s;size=%s;locked_down=%s",
- id, bg_str,
- panel_applet_frame_get_orient_string (frame, panel),
- panel_applet_frame_get_size_string (frame, panel),
- locked_down ? "true" : "false");
-
- 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_set_flags_from_any (frame, any);
-
- else if (!strcmp (event, "Bonobo/Property:change:" PROPERTY_SIZE_HINTS))
- panel_applet_frame_set_size_hints_from_any (frame, any);
-}
-
-static void
-panel_applet_frame_activated (CORBA_Object object,
- const char *error_reason,
- gpointer data)
-{
- PanelAppletFrameActivating *frame_act;
- PanelAppletFrame *frame;
- GtkWidget *widget;
- BonoboControlFrame *control_frame;
- Bonobo_Control control;
- Bonobo_ItemContainer container;
- CORBA_Environment corba_ev;
- AppletInfo *info;
- char *error;
- char *item_name;
-
- widget = NULL;
- frame_act = (PanelAppletFrameActivating *) data;
- frame = frame_act->frame;
-
- /* according to the source of bonobo control == NULL && no
- exception can happen, so handle it */
- if (error_reason != NULL || object == CORBA_OBJECT_NIL) {
- g_warning (G_STRLOC ": failed to load applet %s:\n%s",
- frame->priv->iid, error_reason);
- goto error_out;
- }
-
- CORBA_exception_init (&corba_ev);
-
- item_name = panel_applet_frame_construct_item (frame,
- frame->priv->panel,
- frame_act->id);
-
- 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) {
- 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 (frame->priv->control == CORBA_OBJECT_NIL) {
- error = bonobo_exception_get_text (&corba_ev);
- g_warning (G_STRLOC ": failed to get Bonobo/Control interface on applet %s:\n%s",
- frame->priv->iid, 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 (frame->priv->control,
- CORBA_OBJECT_NIL);
-
- CORBA_exception_free (&corba_ev);
- bonobo_object_release_unref (object, NULL);
-
- if (!widget) {
- g_warning (G_STRLOC ": failed to load applet %s",
- frame->priv->iid);
- goto error_out;
- }
-
- control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (widget));
- if (control_frame == NULL) {
- g_warning (G_STRLOC ": failed to load applet %s "
- "(cannot get control frame)", frame->priv->iid);
- goto error_out;
- }
-
- frame->priv->property_bag =
- bonobo_control_frame_get_control_property_bag (control_frame,
- &corba_ev);
- if (frame->priv->property_bag == NULL || BONOBO_EX (&corba_ev)) {
- error = bonobo_exception_get_text (&corba_ev);
- CORBA_exception_free (&corba_ev);
- g_warning (G_STRLOC ": failed to load applet %s "
- "(cannot get property bag):\n%s",
- frame->priv->iid, error);
- g_free (error);
- goto error_out;
- }
-
- bonobo_event_source_client_add_listener (frame->priv->property_bag,
- (BonoboListenerCallbackFn) panel_applet_frame_event_listener,
- "Bonobo/Property:change:panel-applet",
- NULL,
- frame);
-
- frame->priv->ui_component =
- bonobo_control_frame_get_popup_component (control_frame,
- &corba_ev);
- if (frame->priv->ui_component == NULL || BONOBO_EX (&corba_ev)) {
- error = bonobo_exception_get_text (&corba_ev);
- CORBA_exception_free (&corba_ev);
- g_warning (G_STRLOC ": failed to load applet %s "
- "(cannot get popup component):\n%s",
- frame->priv->iid, error);
- g_free (error);
- goto error_out;
- }
-
- bonobo_ui_util_set_ui (frame->priv->ui_component, DATADIR,
- "GNOME_Panel_Popup.xml", "panel", NULL);
-
- bonobo_ui_component_add_listener (frame->priv->ui_component,
- "LockAppletToPanel",
- listener_popup_handle_lock,
- frame);
-
- bonobo_ui_component_add_verb_list_with_data (
- frame->priv->ui_component, popup_verbs, frame);
-
- control = bonobo_control_frame_get_control (control_frame);
- if (!control) {
- CORBA_exception_free (&corba_ev);
- g_warning (G_STRLOC ": failed to load applet %s "
- "(cannot get control)", frame->priv->iid);
- goto error_out;
- }
-
- frame->priv->applet_shell = panel_applet_frame_get_applet_shell (control);
- if (frame->priv->applet_shell == CORBA_OBJECT_NIL) {
- CORBA_exception_free (&corba_ev);
- g_warning (G_STRLOC ": failed to load applet %s "
- "(cannot get applet shell)", frame->priv->iid);
- goto error_out;
- }
-
- CORBA_exception_free (&corba_ev);
-
- ORBit_small_listen_for_broken (object,
- G_CALLBACK (panel_applet_frame_cnx_broken),
- frame);
-
- gtk_container_add (GTK_CONTAINER (frame), widget);
-
- gtk_widget_show_all (GTK_WIDGET (frame));
-
- info = panel_applet_register (GTK_WIDGET (frame), GTK_WIDGET (frame),
- NULL, frame->priv->panel,
- frame_act->locked, frame_act->position,
- frame_act->exactpos, PANEL_OBJECT_BONOBO,
- frame_act->id);
- frame->priv->applet_info = info;
-
- panel_widget_set_applet_size_constrained (frame->priv->panel,
- GTK_WIDGET (frame), TRUE);
-
- panel_applet_frame_sync_menu_state (frame);
- panel_applet_frame_init_properties (frame);
-
- panel_lockdown_notify_add (G_CALLBACK (panel_applet_frame_sync_menu_state),
- frame);
-
- panel_applet_stop_loading (frame_act->id);
- g_free (frame_act->id);
- g_free (frame_act);
-
- return;
-
-error_out:
- panel_applet_frame_loading_failed (frame, frame_act->id);
- if (widget)
- g_object_unref (widget);
- panel_applet_stop_loading (frame_act->id);
- g_free (frame_act->id);
- g_free (frame_act);
+ frame->priv->panel = NULL;
+ frame->priv->orientation = PANEL_ORIENTATION_TOP;
+ frame->priv->applet_info = NULL;
+ frame->priv->has_handle = FALSE;
}
void
diff --git a/gnome-panel/panel-applet-frame.h b/gnome-panel/panel-applet-frame.h
index f3c5d05..7dc635c 100644
--- a/gnome-panel/panel-applet-frame.h
+++ b/gnome-panel/panel-applet-frame.h
@@ -27,6 +27,7 @@
#include <gtk/gtk.h>
+#include "panel-applet-container.h"
#include "panel-widget.h"
#include "applet.h"
@@ -44,39 +45,39 @@ typedef struct _PanelAppletFrameClass PanelAppletFrameClass;
typedef struct _PanelAppletFramePrivate PanelAppletFramePrivate;
struct _PanelAppletFrame{
- GtkEventBox event_box;
+ PanelAppletContainer container;
PanelAppletFramePrivate *priv;
};
struct _PanelAppletFrameClass {
- GtkEventBoxClass event_box_class;
+ PanelAppletContainerClass container_class;
};
-GType panel_applet_frame_get_type (void) G_GNUC_CONST;
+GType panel_applet_frame_get_type (void) G_GNUC_CONST;
-void panel_applet_frame_create (PanelToplevel *toplevel,
- int position,
- const char *iid);
+void panel_applet_frame_create (PanelToplevel *toplevel,
+ int position,
+ const char *iid);
-void panel_applet_frame_sync_menu_state (PanelAppletFrame *frame);
+void panel_applet_frame_sync_menu_state (PanelAppletFrame *frame);
-void panel_applet_frame_change_orientation (PanelAppletFrame *frame,
- PanelOrientation orientation);
+void panel_applet_frame_change_orientation (PanelAppletFrame *frame,
+ PanelOrientation orientation);
-void panel_applet_frame_change_size (PanelAppletFrame *frame,
- PanelSize size);
+void panel_applet_frame_change_size (PanelAppletFrame *frame,
+ guint size);
-void panel_applet_frame_change_background (PanelAppletFrame *frame,
- PanelBackgroundType type);
+void panel_applet_frame_change_background (PanelAppletFrame *frame,
+ PanelBackgroundType type);
-void panel_applet_frame_load_from_gconf (PanelWidget *panel_widget,
- gboolean locked,
- int position,
- const char *id);
+void panel_applet_frame_load_from_gconf (PanelWidget *panel_widget,
+ gboolean locked,
+ int position,
+ const char *id);
-void panel_applet_frame_set_panel (PanelAppletFrame *frame,
- PanelWidget *panel);
+void panel_applet_frame_set_panel (PanelAppletFrame *frame,
+ PanelWidget *panel);
G_END_DECLS
diff --git a/gnome-panel/panel-applets-manager.c b/gnome-panel/panel-applets-manager.c
new file mode 100644
index 0000000..5e2d985
--- /dev/null
+++ b/gnome-panel/panel-applets-manager.c
@@ -0,0 +1,548 @@
+/*
+ * panel-applets-manmanger.c
+ *
+ * Copyright (C) 2010 Carlos Garcia Campos <carlosgc 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 <gio/gio.h>
+#include <gmodule.h>
+#include <string.h>
+
+#include "panel-applets-manager.h"
+
+static GHashTable *applet_factories;
+static GList *monitors = NULL;
+
+typedef gint (* ActivateAppletFunc) (void);
+
+typedef struct _PanelAppletFactoryInfo {
+ gchar *id;
+ gchar *location;
+ gboolean in_process;
+ GModule *module;
+ ActivateAppletFunc activate_applet;
+ guint n_applets;
+
+ GList *applet_list;
+ gboolean has_old_ids;
+} PanelAppletFactoryInfo;
+
+struct _PanelAppletInfo {
+ gchar *iid;
+
+ gchar *name;
+ gchar *comment;
+ gchar *icon;
+
+ gchar **old_ids;
+};
+
+#define PANEL_APPLET_FACTORY_GROUP "Applet Factory"
+#define PANEL_APPLETS_EXTENSION ".panel-applet"
+
+static void
+panel_applet_info_free (PanelAppletInfo *info)
+{
+ if (!info)
+ return;
+
+ g_free (info->iid);
+ g_free (info->name);
+ g_free (info->comment);
+ g_free (info->icon);
+ g_strfreev (info->old_ids);
+
+ g_slice_free (PanelAppletInfo, info);
+}
+
+static void
+panel_applet_factory_info_free (PanelAppletFactoryInfo *info)
+{
+ if (!info)
+ return;
+
+ g_free (info->id);
+ g_free (info->location);
+ g_list_foreach (info->applet_list,
+ (GFunc)panel_applet_info_free,
+ NULL);
+ g_list_free (info->applet_list);
+ info->applet_list = NULL;
+
+ g_slice_free (PanelAppletFactoryInfo, info);
+}
+
+static PanelAppletInfo *
+_panel_applets_manager_get_applet_info (GKeyFile *applet_file,
+ const gchar *group,
+ const gchar *factory_id)
+{
+ PanelAppletInfo *info;
+
+ info = g_slice_new0 (PanelAppletInfo);
+
+ info->iid = g_strdup_printf ("%s::%s", factory_id, group);
+ info->name = g_key_file_get_locale_string (applet_file, group,
+ "Name", NULL, NULL);
+ info->comment = g_key_file_get_locale_string (applet_file, group,
+ "Description", NULL, NULL);
+ info->icon = g_key_file_get_string (applet_file, group, "Icon", NULL);
+
+ /* Bonobo compatibility */
+ info->old_ids = g_key_file_get_string_list (applet_file, group,
+ "BonoboId", NULL, NULL);
+
+ return info;
+}
+
+static PanelAppletFactoryInfo *
+panel_applets_manager_get_applet_factory_info_from_file (const gchar *filename)
+{
+ PanelAppletFactoryInfo *info;
+ GKeyFile *applet_file;
+ gchar **groups;
+ gsize n_groups;
+ gint i;
+ GError *error = NULL;
+
+ applet_file = g_key_file_new ();
+ if (!g_key_file_load_from_file (applet_file, filename, G_KEY_FILE_NONE, &error)) {
+ g_warning ("Error opening panel applet file %s: %s",
+ filename, error->message);
+ g_error_free (error);
+ g_key_file_free (applet_file);
+
+ return NULL;
+ }
+
+ info = g_slice_new0 (PanelAppletFactoryInfo);
+ info->id = g_key_file_get_string (applet_file, PANEL_APPLET_FACTORY_GROUP, "Id", NULL);
+ if (!info->id) {
+ g_warning ("Bad panel applet file %s: Could not find 'Id' in group '%s'",
+ filename, PANEL_APPLET_FACTORY_GROUP);
+ panel_applet_factory_info_free (info);
+ g_key_file_free (applet_file);
+
+ return NULL;
+ }
+
+ info->in_process = g_key_file_get_boolean (applet_file, PANEL_APPLET_FACTORY_GROUP,
+ "InProcess", NULL);
+ if (info->in_process) {
+ info->location = g_key_file_get_string (applet_file, PANEL_APPLET_FACTORY_GROUP,
+ "Location", NULL);
+ if (!info->location) {
+ g_warning ("Bad panel applet file %s: In-process applet without 'Location'",
+ filename);
+ panel_applet_factory_info_free (info);
+ g_key_file_free (applet_file);
+
+ return NULL;
+ }
+ }
+
+ info->has_old_ids = FALSE;
+
+ groups = g_key_file_get_groups (applet_file, &n_groups);
+ for (i = 0; i < n_groups; i++) {
+ PanelAppletInfo *ainfo;
+
+ if (strcmp (groups[i], PANEL_APPLET_FACTORY_GROUP) == 0)
+ continue;
+
+ ainfo = _panel_applets_manager_get_applet_info (applet_file,
+ groups[i], info->id);
+ if (ainfo->old_ids)
+ info->has_old_ids = TRUE;
+
+ info->applet_list = g_list_prepend (info->applet_list, ainfo);
+ }
+ g_strfreev (groups);
+
+ g_key_file_free (applet_file);
+
+ if (!info->applet_list) {
+ panel_applet_factory_info_free (info);
+ return NULL;
+ }
+
+ return info;
+}
+
+static gchar **
+panel_applets_manager_get_applets_dirs (void)
+{
+ const gchar *dir = NULL;
+
+ dir = g_getenv ("PANEL_APPLETS_DIR");
+
+ if (!dir || g_ascii_strcasecmp (dir, "") == 0)
+ dir = PANEL_APPLETS_DIR;
+
+ return g_strsplit (dir, ":", 0);
+}
+
+static void
+applets_directory_changed (GFileMonitor *monitor,
+ GFile *file,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
+ gpointer user_data)
+{
+ switch (event_type) {
+ case G_FILE_MONITOR_EVENT_CHANGED:
+ case G_FILE_MONITOR_EVENT_CREATED: {
+ PanelAppletFactoryInfo *info;
+ gchar *filename;
+
+ filename = g_file_get_path (file);
+ if (!g_str_has_suffix (filename, PANEL_APPLETS_EXTENSION)) {
+ g_free (filename);
+ return;
+ }
+
+ info = panel_applets_manager_get_applet_factory_info_from_file (filename);
+ g_free (filename);
+
+ if (info)
+ g_hash_table_insert (applet_factories, g_strdup (info->id), info);
+ }
+ break;
+ default:
+ /* Ignore any other change */
+ break;
+ }
+}
+
+static gboolean
+_panel_applets_manager_init (void)
+{
+ gchar **dirs;
+ GDir *dir;
+ const gchar *dirent;
+ gint i = 0;
+ GError *error = NULL;
+ gboolean retval = FALSE;
+
+ dirs = panel_applets_manager_get_applets_dirs ();
+ while (dirs[i]) {
+ GFileMonitor *monitor;
+ GFile *dir_file;
+
+ dir = g_dir_open (dirs[i], 0, &error);
+ if (!dir) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+
+ i++;
+ continue;
+ }
+
+ /* Monitor dir */
+ dir_file = g_file_new_for_path (dirs[i]);
+ monitor = g_file_monitor_directory (dir_file,
+ G_FILE_MONITOR_NONE,
+ NULL, NULL);
+ if (monitor) {
+ g_signal_connect (monitor, "changed",
+ G_CALLBACK (applets_directory_changed),
+ NULL);
+ monitors = g_list_prepend (monitors, monitor);
+ }
+ g_object_unref (dir_file);
+
+ while ((dirent = g_dir_read_name (dir))) {
+ PanelAppletFactoryInfo *info;
+ gchar *file;
+
+ if (!g_str_has_suffix (dirent, PANEL_APPLETS_EXTENSION))
+ continue;
+
+ file = g_build_filename (dirs[i], dirent, NULL);
+ info = panel_applets_manager_get_applet_factory_info_from_file (file);
+ g_free (file);
+
+ if (!info)
+ continue;
+
+ g_hash_table_insert (applet_factories, g_strdup (info->id), info);
+ retval = TRUE;
+ }
+
+ g_dir_close (dir);
+ i++;
+ }
+
+ g_strfreev (dirs);
+
+ return retval;
+}
+
+gboolean
+panel_applets_manager_init (void)
+{
+ if (applet_factories)
+ return TRUE;
+
+ applet_factories = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ (GDestroyNotify)g_free,
+ (GDestroyNotify)panel_applet_factory_info_free);
+
+ return _panel_applets_manager_init ();
+}
+
+void
+panel_applets_manager_shutdown (void)
+{
+ if (monitors) {
+ g_list_foreach (monitors, (GFunc)g_object_unref, NULL);
+ g_list_free (monitors);
+ monitors = NULL;
+ }
+
+ if (applet_factories) {
+ g_hash_table_destroy (applet_factories);
+ applet_factories = NULL;
+ }
+}
+
+GList *
+panel_applets_manager_get_applets (void)
+{
+ GHashTableIter iter;
+ gpointer key, value;
+ GList *retval = NULL;
+
+ g_hash_table_iter_init (&iter, applet_factories);
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ PanelAppletFactoryInfo *info;
+
+ info = (PanelAppletFactoryInfo *)value;
+ retval = g_list_concat (retval, g_list_copy (info->applet_list));
+ }
+
+ return retval;
+}
+
+static PanelAppletFactoryInfo *
+get_applet_factory_info (const gchar *iid)
+{
+ PanelAppletFactoryInfo *info;
+ const gchar *sp;
+ gchar *factory_id;
+
+ if (!applet_factories)
+ return NULL;
+
+ sp = g_strrstr (iid, "::");
+ if (!sp)
+ return NULL;
+
+ factory_id = g_strndup (iid, strlen (iid) - strlen (sp));
+ info = g_hash_table_lookup (applet_factories, factory_id);
+ g_free (factory_id);
+
+ return info;
+}
+
+gboolean
+panel_applets_manager_factory_activate (const gchar *iid)
+{
+ PanelAppletFactoryInfo *info;
+ ActivateAppletFunc activate_applet;
+
+ info = get_applet_factory_info (iid);
+ if (!info)
+ return FALSE;
+
+ /* Out process applets are activated
+ * by the session bus
+ */
+ if (!info->in_process)
+ return TRUE;
+
+ if (info->module) {
+ if (info->n_applets == 0) {
+ if (info->activate_applet () != 0) {
+ g_warning ("Failed to reactivate factory %s\n", iid);
+ return FALSE;
+ }
+ }
+ info->n_applets++;
+
+ return TRUE;
+ }
+
+ info->module = g_module_open (info->location, G_MODULE_BIND_LAZY);
+ if (!info->module) {
+ /* FIXME: use a GError? */
+ g_warning ("Failed to load applet %s: %s\n",
+ iid, g_module_error ());
+ return FALSE;
+ }
+
+ if (!g_module_symbol (info->module, "_panel_applet_shlib_factory", (gpointer *)&activate_applet)) {
+ /* FIXME: use a GError? */
+ g_warning ("Failed to load applet %s: %s\n",
+ iid, g_module_error ());
+ g_module_close (info->module);
+ info->module = NULL;
+
+ return FALSE;
+ }
+
+ /* Activate the applet */
+ if (activate_applet () != 0) {
+ /* FIXME: use a GError? */
+ g_warning ("Failed to load applet %s\n", iid);
+ g_module_close (info->module);
+ info->module = NULL;
+
+ return FALSE;
+ }
+ info->activate_applet = activate_applet;
+
+ info->n_applets = 1;
+
+ return TRUE;
+}
+
+void
+panel_applets_manager_factory_deactivate (const gchar *iid)
+{
+ PanelAppletFactoryInfo *info;
+
+ info = get_applet_factory_info (iid);
+ if (!info)
+ return;
+
+ /* Out process applets are deactivated
+ * by the session bus
+ */
+ if (!info->in_process)
+ return;
+
+ if (!info->module)
+ return;
+
+ if (--info->n_applets == 0) {
+ /* FIXME: we should close the module here,
+ * however applet types are registered static
+ */
+#if 0
+ g_module_close (info->module);
+ info->module = NULL;
+#endif
+ }
+}
+
+gboolean
+panel_applets_manager_is_factory_in_process (const gchar *iid)
+{
+ PanelAppletFactoryInfo *info;
+
+ info = get_applet_factory_info (iid);
+ if (!info)
+ return FALSE;
+
+ return info->in_process;
+}
+
+PanelAppletInfo *
+panel_applets_manager_get_applet_info (const gchar *iid)
+{
+ PanelAppletFactoryInfo *info;
+ GList *l;
+
+ info = get_applet_factory_info (iid);
+ if (!info)
+ return NULL;
+
+ for (l = info->applet_list; l; l = g_list_next (l)) {
+ PanelAppletInfo *ainfo = (PanelAppletInfo *)l->data;
+
+ if (strcmp (ainfo->iid, iid) == 0)
+ return ainfo;
+ }
+
+ return NULL;
+}
+
+PanelAppletInfo *
+panel_applets_manager_get_applet_info_from_old_id (const gchar *iid)
+{
+ GHashTableIter iter;
+ gpointer key, value;
+
+ g_hash_table_iter_init (&iter, applet_factories);
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ PanelAppletFactoryInfo *info;
+ GList *l;
+
+ info = (PanelAppletFactoryInfo *)value;
+ if (!info->has_old_ids)
+ continue;
+
+ for (l = info->applet_list; l; l = g_list_next (l)) {
+ PanelAppletInfo *ainfo;
+ gint i = 0;
+
+ ainfo = (PanelAppletInfo *)l->data;
+
+ if (!ainfo->old_ids)
+ continue;
+
+ while (ainfo->old_ids[i]) {
+ if (strcmp (ainfo->old_ids[i], iid) == 0)
+ return ainfo;
+ i++;
+ }
+ }
+ }
+
+ return NULL;
+}
+
+const gchar *
+panel_applet_info_get_iid (PanelAppletInfo *info)
+{
+ return info->iid;
+}
+
+const gchar *
+panel_applet_info_get_name (PanelAppletInfo *info)
+{
+ return info->name;
+}
+
+const gchar *
+panel_applet_info_get_description (PanelAppletInfo *info)
+{
+ return info->comment;
+}
+
+const gchar *
+panel_applet_info_get_icon (PanelAppletInfo *info)
+{
+ return info->icon;
+}
+
+
diff --git a/gnome-panel/panel-applets-manager.h b/gnome-panel/panel-applets-manager.h
new file mode 100644
index 0000000..235a18c
--- /dev/null
+++ b/gnome-panel/panel-applets-manager.h
@@ -0,0 +1,49 @@
+/*
+ * panel-applets-manmanger.h
+ *
+ * Copyright (C) 2010 Carlos Garcia Campos <carlosgc 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_H__
+#define __PANEL_APPLETS_MANAGER_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+typedef struct _PanelAppletInfo PanelAppletInfo;
+
+gboolean panel_applets_manager_init (void);
+void panel_applets_manager_shutdown (void);
+GList *panel_applets_manager_get_applets (void);
+
+gboolean panel_applets_manager_factory_activate (const gchar *iid);
+void panel_applets_manager_factory_deactivate (const gchar *iid);
+
+gboolean panel_applets_manager_is_factory_in_process (const gchar *iid);
+PanelAppletInfo *panel_applets_manager_get_applet_info (const gchar *iid);
+PanelAppletInfo *panel_applets_manager_get_applet_info_from_old_id (const gchar *iid);
+
+const gchar *panel_applet_info_get_iid (PanelAppletInfo *info);
+const gchar *panel_applet_info_get_name (PanelAppletInfo *info);
+const gchar *panel_applet_info_get_description (PanelAppletInfo *info);
+const gchar *panel_applet_info_get_icon (PanelAppletInfo *info);
+
+G_END_DECLS
+
+#endif /* __PANEL_APPLETS_MANAGER_H__ */
diff --git a/gnome-panel/panel-compatibility.c b/gnome-panel/panel-compatibility.c
index d0dc470..8fdc9e7 100644
--- a/gnome-panel/panel-compatibility.c
+++ b/gnome-panel/panel-compatibility.c
@@ -32,14 +32,15 @@
#include "panel-profile.h"
#include "panel-menu-bar.h"
#include "panel-applet-frame.h"
+#include "panel-applets-manager.h"
#include "panel-globals.h"
#include "panel-util.h"
typedef enum {
- PANEL_ORIENT_UP = GNOME_Vertigo_PANEL_ORIENT_UP,
- PANEL_ORIENT_DOWN = GNOME_Vertigo_PANEL_ORIENT_DOWN,
- PANEL_ORIENT_LEFT = GNOME_Vertigo_PANEL_ORIENT_LEFT,
- PANEL_ORIENT_RIGHT = GNOME_Vertigo_PANEL_ORIENT_RIGHT
+ PANEL_ORIENT_UP,
+ PANEL_ORIENT_DOWN,
+ PANEL_ORIENT_LEFT,
+ PANEL_ORIENT_RIGHT,
} PanelOrient;
static GConfEnumStringPair panel_orient_map [] = {
@@ -167,6 +168,16 @@ panel_compatibility_map_panel_type_string (const char *str,
return TRUE;
}
+enum {
+ PANEL_SIZE_XX_SMALL = 12,
+ PANEL_SIZE_X_SMALL = 24,
+ PANEL_SIZE_SMALL = 36,
+ PANEL_SIZE_MEDIUM = 48,
+ PANEL_SIZE_LARGE = 64,
+ PANEL_SIZE_X_LARGE = 80,
+ PANEL_SIZE_XX_LARGE = 128
+};
+
static GConfEnumStringPair panel_size_map [] = {
{ PANEL_SIZE_XX_SMALL, "panel-size-xx-small" },
{ PANEL_SIZE_X_SMALL, "panel-size-x-small" },
@@ -1089,3 +1100,33 @@ panel_compatiblity_migrate_screenshot_action (GConfClient *client,
panel_profile_add_to_list (PANEL_GCONF_OBJECTS, id);
}
+
+gchar *
+panel_compatiblity_get_applet_iid (const gchar *id)
+{
+ GConfClient *client = panel_gconf_get_client ();
+ PanelAppletInfo *info;
+ const char *key;
+ const char *iid;
+ gchar *applet_iid;
+
+ key = panel_gconf_full_key (PANEL_GCONF_APPLETS, id, "applet_iid");
+ applet_iid = gconf_client_get_string (client, key, NULL);
+ if (applet_iid && applet_iid[0])
+ return applet_iid;
+
+ key = panel_gconf_full_key (PANEL_GCONF_APPLETS, id, "bonobo_iid");
+ applet_iid = gconf_client_get_string (client, key, NULL);
+ if (!applet_iid || !applet_iid[0])
+ return NULL;
+
+ info = panel_applets_manager_get_applet_info_from_old_id (applet_iid);
+ if (!info)
+ return NULL;
+
+ iid = panel_applet_info_get_iid (info);
+ key = panel_gconf_full_key (PANEL_GCONF_APPLETS, id, "applet_iid");
+ gconf_client_set_string (client, key, iid, NULL);
+
+ return g_strdup (iid);
+}
diff --git a/gnome-panel/panel-compatibility.h b/gnome-panel/panel-compatibility.h
index ca3de51..f4fcc07 100644
--- a/gnome-panel/panel-compatibility.h
+++ b/gnome-panel/panel-compatibility.h
@@ -37,6 +37,8 @@ void panel_compatibility_migrate_applications_scheme (GConfClient *client,
void panel_compatiblity_migrate_screenshot_action (GConfClient *client,
const char *id);
+gchar *panel_compatiblity_get_applet_iid (const gchar *id);
+
G_END_DECLS
#endif /* __PANEL_MENU_BAR_H__ */
diff --git a/gnome-panel/panel-object.schemas.in b/gnome-panel/panel-object.schemas.in
index d0e548b..ceb6e4f 100644
--- a/gnome-panel/panel-object.schemas.in
+++ b/gnome-panel/panel-object.schemas.in
@@ -94,6 +94,21 @@
</locale>
</schema>
+ <schema>
+ <key>/schemas/apps/panel/objects/applet_iid</key>
+ <owner>panel</owner>
+ <type>string</type>
+ <default></default>
+ <locale name="C">
+ <short>Applet IID</short>
+ <long>
+ The implementation ID of the applet - e.g.
+ "ClockAppletFactory::ClockApplet". This key is only
+ relevant if the object_type key is "panel-applet".
+ </long>
+ </locale>
+ </schema>
+
<!-- Applies to drawers -->
<schema>
diff --git a/gnome-panel/panel-types.h b/gnome-panel/panel-types.h
index a0f0169..e71549a 100644
--- a/gnome-panel/panel-types.h
+++ b/gnome-panel/panel-types.h
@@ -4,17 +4,6 @@
#include <gdk/gdk.h>
#include <gtk/gtk.h>
-#include "GNOME_Panel.h"
-
-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;
typedef enum {
PANEL_SPEED_SLOW,
diff --git a/gnome-panel/xstuff.c b/gnome-panel/xstuff.c
index 2ac9c44..af45fa9 100644
--- a/gnome-panel/xstuff.c
+++ b/gnome-panel/xstuff.c
@@ -27,6 +27,7 @@
#include "xstuff.h"
static int (* xstuff_old_xio_error_handler) (Display *) = NULL;
+static int (* xstuff_old_x_error_handler) (Display *, XErrorEvent *);
static gboolean xstuff_display_is_dead = FALSE;
static Atom
@@ -708,8 +709,28 @@ xstuff_is_display_dead (void)
return xstuff_display_is_dead;
}
+static int
+xstuff_x_error_handler (Display *display, XErrorEvent *error)
+{
+ if (!error->error_code)
+ return 0;
+
+ /*
+ * If we got a BadDrawable or a BadWindow, we ignore it for
+ * now. FIXME: We need to somehow distinguish real errors
+ * from X-server-induced errors. Keeping a list of windows
+ * for which we will ignore BadDrawables would be a good idea.
+ */
+ if (error->error_code == BadDrawable ||
+ error->error_code == BadWindow)
+ return 0;
+
+ return xstuff_old_x_error_handler (display, error);
+}
+
void
xstuff_init (void)
{
xstuff_old_xio_error_handler = XSetIOErrorHandler (xstuff_xio_error_handler);
+ xstuff_old_x_error_handler = XSetErrorHandler (xstuff_x_error_handler);
}
diff --git a/libpanel-applet/GNOME_Panel_TestApplet.panel-applet.in b/libpanel-applet/GNOME_Panel_TestApplet.panel-applet.in
new file mode 100644
index 0000000..e0641d7
--- /dev/null
+++ b/libpanel-applet/GNOME_Panel_TestApplet.panel-applet.in
@@ -0,0 +1,10 @@
+[Applet Factory]
+Id=TestAppletFactory
+Location=test-dbus-applet
+_Name=Test DBus Applet Factory
+_Description=Test DBus Applet Factory
+
+[TestApplet]
+_Name=Test DBus Applet
+_Description=A simple applet for testing the GNOME-2.0 panel
+Icon=gnome-gegl.png
diff --git a/libpanel-applet/Makefile.am b/libpanel-applet/Makefile.am
index 140ff41..ef3db76 100644
--- a/libpanel-applet/Makefile.am
+++ b/libpanel-applet/Makefile.am
@@ -3,6 +3,7 @@ INCLUDES = \
-DPANEL_APPLET_DATADIR=\""$(datadir)"\" \
-DPANEL_APPLET_BUILDERDIR=\""$(uidir)"\" \
-DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
+ -DEGG_DBUS_I_KNOW_API_IS_SUBJECT_TO_CHANGE \
$(LIBPANEL_APPLET_CFLAGS) \
$(DISABLE_DEPRECATED_CFLAGS) \
$(WARN_CFLAGS)
@@ -10,22 +11,18 @@ INCLUDES = \
lib_LTLIBRARIES = libpanel-applet-2.la
libpanel_applet_2_la_SOURCES = \
+ $(BUILT_SOURCES) \
panel-applet.h \
panel-applet.c \
+ panel-applet-factory.h \
+ panel-applet-factory.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)
+ panel-applet-gconf.h
libpanel_applet_2_la_LDFLAGS = \
- -version-info $(LIB_PANEL_APPLET_LT_VERSION) \
+ -version-info $(LIB_PANEL_APPLET_LT_VERSION) \
-no-undefined
+
libpanel_applet_2_la_LIBADD = \
$(LIBPANEL_APPLET_LIBS) \
$(X_LIBS)
@@ -35,43 +32,72 @@ 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
+ panel-applet-enums.h
+
+libpanel_applet_dbus_xml = \
+ $(top_srcdir)/data/panel-applet.xml \
+ $(top_srcdir)/libpanel-applet/panel-applet-factory.xml
+
+libpanel-applet-built-sources.stamp: $(libpanel_applet_dbus_xml)
+ eggdbus-binding-tool \
+ --namespace "_Panel" \
+ --dbus-namespace "org.gnome.panel.applet" \
+ --introspection-xml $(top_srcdir)/libpanel-applet/panel-applet-factory.xml \
+ --introspection-xml $(top_srcdir)/data/panel-applet.xml \
+ --stamp-file libpanel-applet-built-sources.stamp
+
+EGGDBUS_SRCLIST = \
+ _panelappletfactory.h \
+ _panelappletfactory.c \
+ _panelbindingstypes.h \
+ _panelbindings.h \
+ _panelbindings.c \
+ _panelbindingsmarshal.h \
+ _panelbindingsmarshal.c \
+ _panelapplet.h \
+ _panelapplet.c \
+ _panelappletorient.h \
+ _panelappletorient.c
+
+noinst_PROGRAMS = test-dbus-applet
-$(CORBA_SRCLIST): $(top_srcdir)/idl/GNOME_Panel.idl $(ORBIT_IDL)
- $(AM_V_GEN)$(ORBIT_IDL) -I $(BONOBO_IDLDIR) -I $(BONOBO_ACT_IDLDIR) $(top_srcdir)/idl/GNOME_Panel.idl
+bin_PROGRAMS = panel-test-applets
-noinst_PROGRAMS = test-bonobo-applet
+panel_test_applets_CFLAGS = \
+ -I$(top_srcdir)/gnome-panel \
+ -DPANEL_APPLETS_DIR=\"$(appletsdir)\"
-bin_PROGRAMS = panel-test-applets
+panel_test_applets_SOURCES = \
+ $(top_srcdir)/gnome-panel/panel-applet-container.h \
+ $(top_srcdir)/gnome-panel/panel-applet-container.c \
+ $(top_srcdir)/gnome-panel/panel-applets-manager.h \
+ $(top_srcdir)/gnome-panel/panel-applets-manager.c \
+ panel-test-applets.c
panel_test_applets_LDFLAGS = -export-dynamic
panel_test_applets_LDADD = \
$(LIBPANEL_APPLET_LIBS) \
libpanel-applet-2.la
-test_bonobo_applet_LDADD = \
+test_dbus_applet_LDADD = \
$(LIBPANEL_APPLET_LIBS) \
libpanel-applet-2.la
BUILT_SOURCES = \
- $(CORBA_SRCLIST) \
- panel-applet-enums.c \
- panel-applet-enums.h \
- panel-applet-marshal.c \
+ libpanel-applet-built-sources.stamp \
+ $(EGGDBUS_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_OBJECTS): $(BUILT_SOURCES)
+$(libpanel_applet_2_la_OBJECTS) $(test_dbus_applet_OBJECTS): $(BUILT_SOURCES)
EXTRA_DIST = \
- GNOME_Panel_TestApplet.server.in \
+ GNOME_Panel_TestApplet.panel-applet.in \
+ panel-applet-factory.xml \
panel-applet-marshal.list \
+ _panelbindingsmarshal.list \
libpanelapplet-2.0.pc.in \
libpanelapplet-2.0-uninstalled.pc.in \
panel-test-applets.ui
@@ -121,11 +147,11 @@ 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)
+appletdir = $(datadir)/gnome-panel/applets
+applet_in_files = GNOME_Panel_TestApplet.panel-applet.in
+noinst_DATA = $(applet_in_files:.panel-applet.in=.panel-applet)
- INTLTOOL_SERVER_RULE@
+ PANEL_INTLTOOL_PANEL_APPLET_RULE@
dist-hook:
cd $(distdir) ; rm -f $(CLEANFILES)
diff --git a/libpanel-applet/libpanelapplet-2.0-uninstalled.pc.in b/libpanel-applet/libpanelapplet-2.0-uninstalled.pc.in
index 4173cc8..20324c2 100644
--- a/libpanel-applet/libpanelapplet-2.0-uninstalled.pc.in
+++ b/libpanel-applet/libpanelapplet-2.0-uninstalled.pc.in
@@ -5,7 +5,7 @@ includedir= includedir@
Name: libpanel-applet-2
Description: libpanel-applet-2
-Requires: gconf-2.0 gtk+-2.0 libbonoboui-2.0
+Requires: gconf-2.0 gtk+-2.0 eggdbus-1
Version: @VERSION@
Libs: ${pc_top_builddir}/${pcfiledir}/libpanel-applet-2.la
Cflags: -I${pc_top_builddir}/${pcfiledir}
diff --git a/libpanel-applet/libpanelapplet-2.0.pc.in b/libpanel-applet/libpanelapplet-2.0.pc.in
index b55e893..e6fd6b0 100644
--- a/libpanel-applet/libpanelapplet-2.0.pc.in
+++ b/libpanel-applet/libpanelapplet-2.0.pc.in
@@ -5,7 +5,7 @@ includedir= includedir@
Name: libpanel-applet-2
Description: libpanel-applet-2
-Requires: gconf-2.0 gtk+-2.0 libbonoboui-2.0
+Requires: gconf-2.0 gtk+-2.0 eggdbus-1
Version: @VERSION@
Libs: -L${libdir} -lpanel-applet-2
Cflags: -I${includedir}/panel-2.0
diff --git a/libpanel-applet/panel-applet-factory.c b/libpanel-applet/panel-applet-factory.c
new file mode 100644
index 0000000..6e1984d
--- /dev/null
+++ b/libpanel-applet/panel-applet-factory.c
@@ -0,0 +1,228 @@
+/*
+ * panel-applet-factory.c: panel applet writing API.
+ *
+ * Copyright (C) 2010 Carlos Garcia Campos <carlosgc gnome org>
+ *
+ * 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.
+ */
+
+#include "panel-applet-factory.h"
+#include "_panelappletfactory.h"
+#include "panel-applet.h"
+#include "_panelapplet.h"
+
+struct _PanelAppletFactory {
+ GObject base;
+
+ gchar *factory_id;
+ EggDBusConnection *connection;
+
+ guint n_applets;
+ GType applet_type;
+ GClosure *closure;
+};
+
+struct _PanelAppletFactoryClass {
+ GObjectClass base_class;
+};
+
+#define PANEL_APPLET_FACTORY_OBJECT_PATH "/org/gnome/panel/applet/%s"
+#define PANEL_APPLET_FACTORY_SERVICE_NAME "org.gnome.panel.applet.%s"
+#define PANEL_APPLET_OBJECT_PATH "/org/gnome/panel/applet/%s/%d"
+
+
+static void panel_applet_factory_factory_iface_init (_PanelAppletFactoryIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (PanelAppletFactory, panel_applet_factory, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (_PANEL_TYPE_APPLET_FACTORY, panel_applet_factory_factory_iface_init));
+
+static void
+panel_applet_factory_finalize (GObject *object)
+{
+ PanelAppletFactory *factory = PANEL_APPLET_FACTORY (object);
+
+ if (factory->connection) {
+ g_object_unref (factory->connection);
+ factory->connection = NULL;
+ }
+
+ if (factory->factory_id) {
+ g_free (factory->factory_id);
+ factory->factory_id = NULL;
+ }
+
+ if (factory->closure) {
+ g_closure_unref (factory->closure);
+ factory->closure = NULL;
+ }
+
+ G_OBJECT_CLASS (panel_applet_factory_parent_class)->finalize (object);
+}
+
+static void
+panel_applet_factory_init (PanelAppletFactory *factory)
+{
+}
+
+static void
+panel_applet_factory_class_init (PanelAppletFactoryClass *klass)
+{
+ GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
+
+ g_object_class->finalize = panel_applet_factory_finalize;
+}
+
+static void
+panel_applet_factory_applet_removed (PanelAppletFactory *factory,
+ GObject *applet)
+{
+ if (--factory->n_applets == 0)
+ g_object_unref (factory);
+}
+
+/* PanelAppletFactory Interface */
+static gboolean
+set_property (EggDBusHashMap *hash_map,
+ gchar *name,
+ EggDBusVariant *variant,
+ GObject *applet)
+{
+ g_object_set_property (applet, name, egg_dbus_variant_get_gvalue (variant));
+
+ return FALSE;
+}
+
+static void
+panel_applet_factory_get_applet (_PanelAppletFactory *_factory,
+ const gchar *applet_id,
+ gint screen_num,
+ EggDBusHashMap *props,
+ EggDBusMethodInvocation *method_invocation)
+{
+ PanelAppletFactory *factory = PANEL_APPLET_FACTORY (_factory);
+ GObject *applet;
+ gchar *object_path;
+ GdkScreen *screen;
+ guint32 xid;
+ static gint id = 0;
+
+ applet = g_object_new (factory->applet_type,
+ "id", applet_id,
+ "closure", factory->closure,
+ NULL);
+ factory->n_applets++;
+
+ object_path = g_strdup_printf (PANEL_APPLET_OBJECT_PATH, applet_id, id++);
+ egg_dbus_connection_register_interface (factory->connection,
+ object_path,
+ _PANEL_TYPE_APPLET,
+ G_OBJECT (applet),
+ G_TYPE_INVALID);
+ g_object_weak_ref (applet, (GWeakNotify)panel_applet_factory_applet_removed, factory);
+
+ egg_dbus_hash_map_foreach (props,
+ (EggDBusHashMapForeachFunc)set_property,
+ applet);
+
+ screen = screen_num != -1 ?
+ gdk_display_get_screen (gdk_display_get_default (), screen_num) :
+ gdk_screen_get_default ();
+ xid = panel_applet_get_xid (PANEL_APPLET (applet), screen);
+
+ _panel_applet_factory_handle_get_applet_finish (method_invocation, object_path, xid);
+ g_free (object_path);
+}
+
+static void
+panel_applet_factory_factory_iface_init (_PanelAppletFactoryIface *factory_iface)
+{
+ factory_iface->handle_get_applet = panel_applet_factory_get_applet;
+}
+
+PanelAppletFactory *
+panel_applet_factory_new (const gchar *factory_id,
+ GType applet_type,
+ GClosure *closure)
+{
+ PanelAppletFactory *factory;
+
+ factory = PANEL_APPLET_FACTORY (g_object_new (PANEL_TYPE_APPLET_FACTORY, NULL));
+ factory->factory_id = g_strdup (factory_id);
+ factory->applet_type = applet_type;
+ factory->closure = g_closure_ref (closure);
+
+ return factory;
+}
+
+gboolean
+panel_applet_factory_register_service (PanelAppletFactory *factory)
+{
+ guint request_name_result;
+ gchar *service_name;
+ gchar *object_path;
+ GError *error = NULL;
+
+ if (!factory->connection) {
+ factory->connection = egg_dbus_connection_get_for_bus (EGG_DBUS_BUS_TYPE_SESSION);
+ if (!factory->connection) {
+ g_printerr ("Failed to connect to the D-BUS daemon\n");
+
+ return FALSE;
+ }
+ }
+
+ service_name = g_strdup_printf (PANEL_APPLET_FACTORY_SERVICE_NAME, factory->factory_id);
+ if (!egg_dbus_bus_request_name_sync (egg_dbus_connection_get_bus (factory->connection),
+ EGG_DBUS_CALL_FLAGS_NONE,
+ service_name,
+ EGG_DBUS_REQUEST_NAME_FLAGS_DO_NOT_QUEUE,
+ &request_name_result,
+ NULL,
+ &error)) {
+ g_printerr ("Failed to acquire daemon name: %s", error->message);
+ g_error_free (error);
+ g_free (service_name);
+
+ return FALSE;
+ }
+ g_free (service_name);
+
+ switch (request_name_result) {
+ case EGG_DBUS_REQUEST_NAME_REPLY_EXISTS:
+ g_printerr ("Panel applet already running, exiting.\n");
+
+ return FALSE;
+ case EGG_DBUS_REQUEST_NAME_REPLY_ALREADY_OWNED:
+ case EGG_DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER:
+ object_path = g_strdup_printf (PANEL_APPLET_FACTORY_OBJECT_PATH, factory->factory_id);
+ egg_dbus_connection_register_interface (factory->connection,
+ object_path,
+ _PANEL_TYPE_APPLET_FACTORY,
+ G_OBJECT (factory),
+ G_TYPE_INVALID);
+ g_free (object_path);
+
+ break;
+ default:
+ g_printerr ("Not primary owner of the service, exiting.\n");
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
diff --git a/libpanel-applet/panel-applet-factory.h b/libpanel-applet/panel-applet-factory.h
new file mode 100644
index 0000000..5207bd6
--- /dev/null
+++ b/libpanel-applet/panel-applet-factory.h
@@ -0,0 +1,45 @@
+/*
+ * panel-applet-factory.h: panel applet writing API.
+ *
+ * Copyright (C) 2010 Carlos Garcia Campos <carlosgc gnome org>
+ *
+ * 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.
+ */
+
+#ifndef PANEL_APPLET_FACTORY_H
+#define PANEL_APPLET_FACTORY_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define PANEL_TYPE_APPLET_FACTORY (panel_applet_factory_get_type ())
+#define PANEL_APPLET_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PANEL_TYPE_APPLET_FACTORY, PanelAppletFactory))
+#define PANEL_APPLET_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PANEL_TYPE_APPLET_FACTORY, PanelAppletFactoryClass))
+#define PANEL_IS_APPLET_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PANEL_TYPE_APPLET_FACTORY))
+
+typedef struct _PanelAppletFactory PanelAppletFactory;
+typedef struct _PanelAppletFactoryClass PanelAppletFactoryClass;
+
+GType panel_applet_factory_get_type (void) G_GNUC_CONST;
+PanelAppletFactory *panel_applet_factory_new (const gchar *applet_id,
+ GType applet_type,
+ GClosure *closure);
+gboolean panel_applet_factory_register_service (PanelAppletFactory *factory);
+
+G_END_DECLS
+
+#endif /* PANEL_APPLET_FACTORY_H */
diff --git a/libpanel-applet/panel-applet-factory.xml b/libpanel-applet/panel-applet-factory.xml
new file mode 100644
index 0000000..314a6ee
--- /dev/null
+++ b/libpanel-applet/panel-applet-factory.xml
@@ -0,0 +1,14 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+
+<node>
+ <interface name="org.gnome.panel.applet.AppletFactory">
+ <method name="GetApplet">
+ <arg name="applet_id" type="s" direction="in"/>
+ <arg name="screen" type="i" direction="in"/>
+ <arg name="props" type="a{sv}" direction="in"/>
+ <arg name="applet" type="o" direction="out"/>
+ <arg name="xid" type="u" direction="out"/>
+ </method>
+ </interface>
+</node>
diff --git a/libpanel-applet/panel-applet-gconf.c b/libpanel-applet/panel-applet-gconf.c
index 1a37790..2e569f5 100644
--- a/libpanel-applet/panel-applet-gconf.c
+++ b/libpanel-applet/panel-applet-gconf.c
@@ -25,7 +25,6 @@
#include <gconf/gconf-client.h>
#include "panel-applet-gconf.h"
-#include "panel-applet-private.h"
static GConfClient *
panel_applet_gconf_get_client (void)
diff --git a/libpanel-applet/panel-applet.c b/libpanel-applet/panel-applet.c
index 6652ba8..ee90f00 100644
--- a/libpanel-applet/panel-applet.c
+++ b/libpanel-applet/panel-applet.c
@@ -1,6 +1,7 @@
/*
* panel-applet.c: panel applet writing library.
*
+ * Copyright (c) 2010 Carlos Garcia Campos <carlosgc gnome org>
* Copyright (C) 2001 Sun Microsystems, Inc.
*
* This library is free software; you can redistribute it and/or
@@ -31,56 +32,52 @@
#include <string.h>
#include <cairo.h>
+#include <glib/gi18n-lib.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 "_panelapplet.h"
+#include "panel-applet-factory.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;
+ GtkWidget *plug;
+ GtkWidget *applet;
+ GConfClient *client;
- char *iid;
- GClosure *closure;
- gboolean bound;
- char *prefs_key;
+ char *id;
+ GClosure *closure;
+ char *prefs_key;
- PanelAppletFlags flags;
- PanelAppletOrient orient;
- guint size;
- char *background;
- GtkWidget *background_widget;
+ GtkUIManager *ui_manager;
+ GtkActionGroup *applet_action_group;
+ GtkActionGroup *panel_action_group;
- int previous_width;
- int previous_height;
+ PanelAppletFlags flags;
+ PanelAppletOrient orient;
+ guint size;
+ char *background;
+ GtkWidget *background_widget;
- int *size_hints;
- int size_hints_len;
+ int previous_width;
+ int previous_height;
- gboolean moving_focus_out;
+ int *size_hints;
+ int size_hints_len;
- gboolean locked_down;
+ gboolean moving_focus_out;
+
+ gboolean locked;
+ gboolean locked_down;
};
enum {
@@ -94,26 +91,61 @@ enum {
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
+ PROP_0,
+ PROP_ID,
+ PROP_CLOSURE,
+ PROP_PREFS_KEY,
+ PROP_ORIENT,
+ PROP_SIZE,
+ PROP_BACKGROUND,
+ PROP_FLAGS,
+ PROP_SIZE_HINTS,
+ PROP_LOCKED,
+ PROP_LOCKED_DOWN
+};
+
+static void panel_applet_handle_background (PanelApplet *applet);
+static GtkAction *panel_applet_menu_get_action (PanelApplet *applet,
+ const gchar *action);
+static void panel_applet_menu_update_actions (PanelApplet *applet);
+static void panel_applet_menu_cmd_remove (GtkAction *action,
+ PanelApplet *applet);
+static void panel_applet_menu_cmd_move (GtkAction *action,
+ PanelApplet *applet);
+static void panel_applet_menu_cmd_lock (GtkAction *action,
+ PanelApplet *applet);
+static void panel_applet_applet_iface_init (_PanelAppletIface *iface);
+
+static const gchar panel_menu_ui[] =
+ "<ui>\n"
+ " <popup name=\"PanelAppletPopup\" action=\"PopupAction\">\n"
+ " <placeholder name=\"AppletItems\"/>\n"
+ " <separator/>\n"
+ " <menuitem name=\"RemoveItem\" action=\"Remove\"/>\n"
+ " <menuitem name=\"MoveItem\" action=\"Move\"/>\n"
+ " <separator/>\n"
+ " <menuitem name=\"LockItem\" action=\"Lock\"/>\n"
+ " </popup>\n"
+ "</ui>\n";
+
+static const GtkActionEntry menu_entries[] = {
+ { "Remove", GTK_STOCK_REMOVE, N_("_Remove From Panel"),
+ NULL, NULL,
+ G_CALLBACK (panel_applet_menu_cmd_remove) },
+ { "Move", NULL, N_("_Move"),
+ NULL, NULL,
+ G_CALLBACK (panel_applet_menu_cmd_move) }
};
-G_DEFINE_TYPE (PanelApplet, panel_applet, GTK_TYPE_EVENT_BOX)
+static const GtkToggleActionEntry menu_toggle_entries[] = {
+ { "Lock", NULL, N_("Loc_k To Panel"),
+ NULL, NULL,
+ G_CALLBACK (panel_applet_menu_cmd_lock) }
+};
-static void panel_applet_handle_background (PanelApplet *applet);
-static void panel_applet_setup (PanelApplet *applet);
+G_DEFINE_TYPE_WITH_CODE (PanelApplet, panel_applet, GTK_TYPE_EVENT_BOX,
+ G_IMPLEMENT_INTERFACE (_PANEL_TYPE_APPLET, panel_applet_applet_iface_init));
static void
panel_applet_associate_schemas_in_dir (GConfClient *client,
@@ -263,7 +295,12 @@ 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 == prefs_key)
+ return;
+
+ if (applet->priv->prefs_key && prefs_key &&
+ strcmp (applet->priv->prefs_key, prefs_key) == 0)
+ return;
if (applet->priv->prefs_key) {
gconf_client_remove_dir (applet->priv->client,
@@ -282,6 +319,8 @@ panel_applet_set_preferences_key (PanelApplet *applet,
GCONF_CLIENT_PRELOAD_RECURSIVE,
NULL);
}
+
+ g_object_notify (G_OBJECT (applet), "prefs-key");
}
PanelAppletFlags
@@ -298,45 +337,83 @@ panel_applet_set_flags (PanelApplet *applet,
{
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;
+ if (applet->priv->flags == flags)
+ return;
+
+ applet->priv->flags = flags;
+
+ g_object_notify (G_OBJECT (applet), "flags");
}
-void
-panel_applet_set_size_hints (PanelApplet *applet,
- const int *size_hints,
- int n_elements,
- int base_size)
+static void
+panel_applet_size_hints_ensure (PanelApplet *applet,
+ int new_size)
{
- CORBA_sequence_CORBA_long *seq;
- CORBA_Environment env;
- CORBA_any any;
- int i;
+ if (applet->priv->size_hints && applet->priv->size_hints_len < new_size) {
+ g_free (applet->priv->size_hints);
+ applet->priv->size_hints = g_new (gint, new_size);
+ } else if (!applet->priv->size_hints) {
+ applet->priv->size_hints = g_new (gint, new_size);
+ }
+ applet->priv->size_hints_len = new_size;
+}
- CORBA_exception_init (&env);
+static gboolean
+panel_applet_size_hints_changed (PanelApplet *applet,
+ const int *size_hints,
+ int n_elements,
+ int base_size)
+{
+ gint i;
- 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);
+ if (!applet->priv->size_hints)
+ return TRUE;
+
+ if (applet->priv->size_hints_len != n_elements)
+ return TRUE;
+ for (i = 0; i < n_elements; i++) {
+ if (size_hints[i] + base_size != applet->priv->size_hints[i])
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+void
+panel_applet_set_size_hints (PanelApplet *applet,
+ const int *size_hints,
+ int n_elements,
+ int base_size)
+{
+ gint i;
+
+ /* Make sure property has really changed
+ * to avoid bus traffic
+ */
+ if (!panel_applet_size_hints_changed (applet, size_hints, n_elements, base_size))
+ return;
+
+ panel_applet_size_hints_ensure (applet, n_elements);
for (i = 0; i < n_elements; i++)
- seq->_buffer [i] = size_hints [i] + base_size;
+ applet->priv->size_hints[i] = size_hints[i] + base_size;
- any._type = TC_CORBA_sequence_CORBA_long;
- any._release = CORBA_FALSE;
- any._value = seq;
+ g_object_notify (G_OBJECT (applet), "size-hints");
+}
- Bonobo_PropertyBag_setValue (BONOBO_OBJREF (applet->priv->prop_sack),
- PROPERTY_SIZE_HINTS,
- &any,
- &env);
+static void
+panel_applet_set_size_hints_from_seq (PanelApplet *applet,
+ EggDBusArraySeq *seq)
+{
+ gint i;
+ gint n_elements;
- CORBA_free (seq);
+ n_elements = egg_dbus_array_seq_get_size (seq);
+ panel_applet_size_hints_ensure (applet, n_elements);
+ for (i = 0; i < n_elements; i++)
+ applet->priv->size_hints[i] = egg_dbus_array_seq_get_fixed (seq, i);
- CORBA_exception_free (&env);
+ g_object_notify (G_OBJECT (applet), "size-hints");
}
guint
@@ -347,6 +424,23 @@ panel_applet_get_size (PanelApplet *applet)
return applet->priv->size;
}
+void
+panel_applet_set_size (PanelApplet *applet,
+ guint size)
+{
+ g_return_if_fail (PANEL_IS_APPLET (applet));
+
+ if (applet->priv->size == size)
+ return;
+
+ applet->priv->size = size;
+ g_signal_emit (G_OBJECT (applet),
+ panel_applet_signals [CHANGE_SIZE],
+ 0, size);
+
+ g_object_notify (G_OBJECT (applet), "size");
+}
+
PanelAppletOrient
panel_applet_get_orient (PanelApplet *applet)
{
@@ -355,6 +449,59 @@ panel_applet_get_orient (PanelApplet *applet)
return applet->priv->orient;
}
+void
+panel_applet_set_orient (PanelApplet *applet,
+ PanelAppletOrient orient)
+{
+ g_return_if_fail (PANEL_IS_APPLET (applet));
+
+ if (applet->priv->orient == orient)
+ return;
+
+ applet->priv->orient = orient;
+ g_signal_emit (G_OBJECT (applet),
+ panel_applet_signals [CHANGE_ORIENT],
+ 0, orient);
+
+ g_object_notify (G_OBJECT (applet), "orient");
+}
+
+gboolean
+panel_applet_get_locked (PanelApplet *applet)
+{
+ g_return_val_if_fail (PANEL_IS_APPLET (applet), FALSE);
+
+ return applet->priv->locked;
+}
+
+void
+panel_applet_set_locked (PanelApplet *applet,
+ gboolean locked)
+{
+ GtkAction *action;
+
+ g_return_if_fail (PANEL_IS_APPLET (applet));
+
+ if (applet->priv->locked == locked)
+ return;
+
+ applet->priv->locked = locked;
+
+ action = panel_applet_menu_get_action (applet, "Lock");
+ g_signal_handlers_block_by_func (action,
+ panel_applet_menu_cmd_lock,
+ applet);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), locked);
+ g_signal_handlers_unblock_by_func (action,
+ panel_applet_menu_cmd_lock,
+ applet);
+
+ panel_applet_menu_update_actions (applet);
+
+ g_signal_emit_by_name (applet, locked ? "lock" : "unlock");
+ g_object_notify (G_OBJECT (applet), "locked");
+}
+
gboolean
panel_applet_get_locked_down (PanelApplet *applet)
{
@@ -363,6 +510,21 @@ panel_applet_get_locked_down (PanelApplet *applet)
return applet->priv->locked_down;
}
+void
+panel_applet_set_locked_down (PanelApplet *applet,
+ gboolean locked_down)
+{
+ g_return_if_fail (PANEL_IS_APPLET (applet));
+
+ if (applet->priv->locked_down == locked_down)
+ return;
+
+ applet->priv->locked_down = locked_down;
+ panel_applet_menu_update_actions (applet);
+
+ g_object_notify (G_OBJECT (applet), "locked-down");
+}
+
static Atom _net_wm_window_type = None;
static Atom _net_wm_window_type_dock = None;
static Atom _net_active_window = None;
@@ -498,71 +660,101 @@ panel_applet_request_focus (PanelApplet *applet,
&xev);
}
-void
-panel_applet_setup_menu (PanelApplet *applet,
- const gchar *xml,
- const BonoboUIVerb *verb_list,
- gpointer user_data)
+static GtkAction *
+panel_applet_menu_get_action (PanelApplet *applet,
+ const gchar *action)
{
- BonoboUIComponent *popup_component;
+ return gtk_action_group_get_action (applet->priv->panel_action_group, action);
+}
- g_return_if_fail (PANEL_IS_APPLET (applet));
- g_return_if_fail (xml != NULL && verb_list != NULL);
+static void
+panel_applet_menu_update_actions (PanelApplet *applet)
+{
+ gboolean locked = applet->priv->locked;
+ gboolean locked_down = applet->priv->locked_down;
+
+ g_object_set (panel_applet_menu_get_action (applet, "Lock"),
+ "visible", !locked_down, NULL);
+ g_object_set (panel_applet_menu_get_action (applet, "Move"),
+ "sensitive", !locked,
+ "visible", !locked_down,
+ NULL);
+ g_object_set (panel_applet_menu_get_action (applet, "Remove"),
+ "sensitive", !locked,
+ "visible", !locked_down,
+ NULL);
+}
- popup_component = panel_applet_get_popup_component (applet);
+static void
+panel_applet_menu_cmd_remove (GtkAction *action,
+ PanelApplet *applet)
+{
+ g_signal_emit_by_name (applet, "remove-from-panel");
+}
- bonobo_ui_component_set (popup_component, "/", "<popups/>", NULL);
+static void
+panel_applet_menu_cmd_move (GtkAction *action,
+ PanelApplet *applet)
+{
+ g_signal_emit_by_name (applet, "move");
+}
- bonobo_ui_component_set_translate (popup_component, "/popups", xml, NULL);
+static void
+panel_applet_menu_cmd_lock (GtkAction *action,
+ PanelApplet *applet)
+{
+ gboolean locked;
- bonobo_ui_component_add_verb_list_with_data (popup_component, verb_list, user_data);
+ locked = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ panel_applet_set_locked (applet, locked);
}
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)
+panel_applet_setup_menu (PanelApplet *applet,
+ const gchar *xml,
+ GtkActionGroup *applet_action_group)
{
- BonoboUIComponent *popup_component;
- gchar *app_name = NULL;
+ gchar *new_xml;
+ GError *error = 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 ());
+ g_return_if_fail (xml != NULL);
- 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 (applet->priv->applet_action_group)
+ return;
- if (app_name)
- g_free (app_name);
+ applet->priv->applet_action_group = g_object_ref (applet_action_group);
+ gtk_ui_manager_insert_action_group (applet->priv->ui_manager,
+ applet_action_group, 0);
+
+ new_xml = g_strdup_printf ("<ui><popup name=\"PanelAppletPopup\" action=\"AppletItems\">"
+ "<placeholder name=\"AppletItems\">%s\n</placeholder>\n"
+ "</popup></ui>\n", xml);
+ gtk_ui_manager_add_ui_from_string (applet->priv->ui_manager, new_xml, -1, &error);
+ g_free (new_xml);
+ gtk_ui_manager_ensure_update (applet->priv->ui_manager);
+ if (error) {
+ g_warning ("Error merging menus: %s\n", error->message);
+ g_error_free (error);
+ }
}
-BonoboControl *
-panel_applet_get_control (PanelApplet *applet)
+void
+panel_applet_setup_menu_from_file (PanelApplet *applet,
+ const gchar *filename,
+ GtkActionGroup *applet_action_group)
{
- g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
+ gchar *xml = NULL;
+ GError *error = NULL;
- return applet->priv->control;
-}
-
-BonoboUIComponent *
-panel_applet_get_popup_component (PanelApplet *applet)
-{
- g_return_val_if_fail (PANEL_IS_APPLET (applet), NULL);
+ if (g_file_get_contents (filename, &xml, NULL, &error)) {
+ panel_applet_setup_menu (applet, xml, applet_action_group);
+ } else {
+ g_warning ("%s", error->message);
+ g_clear_error (&error);
+ }
- return bonobo_control_get_popup_ui_component (applet->priv->control);
+ g_free (xml);
}
static void
@@ -576,18 +768,27 @@ panel_applet_finalize (GObject *object)
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;
+ if (applet->priv->applet_action_group) {
+ g_object_unref (applet->priv->applet_action_group);
+ applet->priv->applet_action_group = NULL;
+ }
+
+ if (applet->priv->panel_action_group) {
+ g_object_unref (applet->priv->panel_action_group);
+ applet->priv->panel_action_group = NULL;
+ }
+
+ if (applet->priv->ui_manager) {
+ g_object_unref (applet->priv->ui_manager);
+ applet->priv->ui_manager = NULL;
+ }
g_free (applet->priv->size_hints);
g_free (applet->priv->prefs_key);
g_free (applet->priv->background);
- g_free (applet->priv->iid);
+ g_free (applet->priv->id);
- if (applet->priv->closure)
- g_closure_unref (applet->priv->closure);
+ /* closure is owned by the factory */
applet->priv->closure = NULL;
G_OBJECT_CLASS (panel_applet_parent_class)->finalize (object);
@@ -686,6 +887,24 @@ panel_applet_position_menu (GtkMenu *menu,
*push_in = TRUE;
}
+static void
+panel_applet_menu_popup (PanelApplet *applet,
+ guint button,
+ guint32 time)
+{
+ GtkWidget *menu;
+
+ menu = gtk_ui_manager_get_widget (applet->priv->ui_manager,
+ "/PanelAppletPopup");
+ gtk_menu_popup (GTK_MENU (menu),
+ NULL, NULL,
+ (GtkMenuPositionFunc)panel_applet_position_menu,
+ applet,
+ button, time);
+}
+
+
+
static gboolean
panel_applet_can_focus (GtkWidget *widget)
{
@@ -702,6 +921,59 @@ panel_applet_can_focus (GtkWidget *widget)
return !container_has_focusable_child (GTK_CONTAINER (widget));
}
+/* Taken from libbonoboui/bonobo/bonobo-plug.c */
+static gboolean
+panel_applet_button_event (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ XEvent xevent;
+
+ if (!GTK_WIDGET_TOPLEVEL (widget))
+ return FALSE;
+
+ if (event->type == GDK_BUTTON_PRESS) {
+ xevent.xbutton.type = ButtonPress;
+
+ /* X does an automatic pointer grab on button press
+ * if we have both button press and release events
+ * selected.
+ * We don't want to hog the pointer on our parent.
+ */
+ gdk_display_pointer_ungrab
+ (gtk_widget_get_display (widget),
+ GDK_CURRENT_TIME);
+ } else {
+ xevent.xbutton.type = ButtonRelease;
+ }
+
+ xevent.xbutton.display = GDK_WINDOW_XDISPLAY (widget->window);
+ xevent.xbutton.window = GDK_WINDOW_XWINDOW (GTK_PLUG (widget)->socket_window);
+ xevent.xbutton.root = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window
+ (gdk_drawable_get_screen (widget->window)));
+ /*
+ * FIXME: the following might cause
+ * big problems for non-GTK apps
+ */
+ xevent.xbutton.x = 0;
+ xevent.xbutton.y = 0;
+ xevent.xbutton.x_root = 0;
+ xevent.xbutton.y_root = 0;
+ xevent.xbutton.state = event->state;
+ xevent.xbutton.button = event->button;
+ xevent.xbutton.same_screen = TRUE; /* FIXME ? */
+
+ gdk_error_trap_push ();
+
+ XSendEvent (GDK_WINDOW_XDISPLAY (widget->window),
+ GDK_WINDOW_XWINDOW (GTK_PLUG (widget)->socket_window),
+ False, NoEventMask, &xevent);
+
+ gdk_flush ();
+ gdk_error_trap_pop ();
+
+ return TRUE;
+}
+
static gboolean
panel_applet_button_press (GtkWidget *widget,
GdkEventButton *event)
@@ -715,37 +987,30 @@ panel_applet_button_press (GtkWidget *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);
+ if (event->button == 3) {
+ panel_applet_menu_popup (applet, event->button, event->time);
+
return TRUE;
}
- return FALSE;
+ return panel_applet_button_event (applet->priv->plug, event);
}
-gboolean
-_panel_applet_popup_menu (PanelApplet *applet,
- guint button,
- guint32 time)
+static gboolean
+panel_applet_button_release (GtkWidget *widget,
+ GdkEventButton *event)
{
- bonobo_control_do_popup_full (applet->priv->control, NULL, NULL,
- (GtkMenuPositionFunc) panel_applet_position_menu,
- applet, button, time);
- return TRUE;
+ PanelApplet *applet = PANEL_APPLET (widget);
+
+ return panel_applet_button_event (applet->priv->plug, event);
}
static gboolean
-panel_applet_popup_menu (PanelApplet *applet)
+panel_applet_popup_menu (GtkWidget *widget)
{
- return _panel_applet_popup_menu (applet, 3, GDK_CURRENT_TIME);
+ panel_applet_menu_popup (PANEL_APPLET (widget), 3, GDK_CURRENT_TIME);
+
+ return TRUE;
}
static void
@@ -1123,48 +1388,22 @@ panel_applet_get_background (PanelApplet *applet,
}
static void
-panel_applet_get_prop (BonoboPropertyBag *sack,
- BonoboArg *arg,
- guint arg_id,
- CORBA_Environment *ev,
- gpointer user_data)
+panel_applet_set_background_string (PanelApplet *applet,
+ const gchar *background)
{
- PanelApplet *applet = PANEL_APPLET (user_data);
+ if (applet->priv->background == background)
+ return;
- 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;
+ if (applet->priv->background && background &&
+ strcmp (applet->priv->background, background) == 0)
+ return;
- seq = arg->_value;
+ if (applet->priv->background)
+ g_free (applet->priv->background);
+ applet->priv->background = background ? g_strdup (background) : NULL;
+ panel_applet_handle_background (applet);
- 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;
- }
+ g_object_notify (G_OBJECT (applet), "background");
}
static void
@@ -1240,319 +1479,224 @@ panel_applet_handle_background (PanelApplet *applet)
}
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;
+panel_applet_realize (GtkWidget *widget)
+{
+ GTK_WIDGET_CLASS (panel_applet_parent_class)->realize (widget);
- size = BONOBO_ARG_GET_SHORT (arg);
+ if (PANEL_APPLET (widget)->priv->background)
+ panel_applet_handle_background (PANEL_APPLET (widget));
+}
- if (applet->priv->size != size) {
- applet->priv->size = size;
+static void
+panel_applet_move_focus_out_of_applet (PanelApplet *applet,
+ GtkDirectionType dir)
+{
+ GtkWidget *toplevel;
- 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->moving_focus_out = TRUE;
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (applet));
+ g_return_if_fail (toplevel);
- applet->priv->background = g_strdup (BONOBO_ARG_GET_STRING (arg));
+ gtk_widget_child_focus (toplevel, dir);
+ applet->priv->moving_focus_out = FALSE;
+}
- panel_applet_handle_background (applet);
+static void
+panel_applet_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ PanelApplet *applet = PANEL_APPLET (object);
+
+ switch (prop_id) {
+ case PROP_ID:
+ g_value_set_string (value, applet->priv->id);
break;
- case PROPERTY_FLAGS_IDX:
- applet->priv->flags = BONOBO_ARG_GET_SHORT (arg);
+ case PROP_CLOSURE:
+ g_value_set_pointer (value, applet->priv->closure);
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;;
+ case PROP_PREFS_KEY:
+ g_value_set_string (value, applet->priv->prefs_key);
+ break;
+ case PROP_ORIENT:
+ g_value_set_enum (value, applet->priv->orient);
+ break;
+ case PROP_SIZE:
+ g_value_set_uint (value, applet->priv->size);
+ break;
+ case PROP_BACKGROUND:
+ g_value_set_string (value, applet->priv->background);
+ break;
+ case PROP_FLAGS:
+ g_value_set_uint (value, applet->priv->flags);
+ break;
+ case PROP_SIZE_HINTS: {
+ EggDBusArraySeq *array;
+ gint i;
+
+ array = egg_dbus_array_seq_new (G_TYPE_INT, NULL, NULL, NULL);
+ for (i = 0; i < applet->priv->size_hints_len; i++)
+ egg_dbus_array_seq_add_fixed (array, applet->priv->size_hints[i]);
+ g_value_take_object (value, array);
+
}
break;
- case PROPERTY_LOCKED_DOWN_IDX:
- applet->priv->locked_down = BONOBO_ARG_GET_BOOLEAN (arg);
+ case PROP_LOCKED:
+ g_value_set_boolean (value, applet->priv->locked);
break;
- default:
- g_assert_not_reached ();
+ case PROP_LOCKED_DOWN:
+ g_value_set_boolean (value, applet->priv->locked_down);
break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
-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_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ PanelApplet *applet = PANEL_APPLET (object);
+
+ switch (prop_id) {
+ case PROP_ID:
+ applet->priv->id = g_value_dup_string (value);
+ break;
+ case PROP_CLOSURE:
+ applet->priv->closure = g_value_get_pointer (value);
+ g_closure_set_marshal (applet->priv->closure,
+ panel_applet_marshal_BOOLEAN__STRING);
+ break;
+ case PROP_PREFS_KEY:
+ panel_applet_set_preferences_key (applet, g_value_get_string (value));
+ break;
+ case PROP_ORIENT:
+ panel_applet_set_orient (applet, g_value_get_enum (value));
+ break;
+ case PROP_SIZE:
+ panel_applet_set_size (applet, g_value_get_uint (value));
+ break;
+ case PROP_BACKGROUND:
+ panel_applet_set_background_string (applet, g_value_get_string (value));
+ break;
+ case PROP_FLAGS:
+ panel_applet_set_flags (applet, g_value_get_uint (value));
+ break;
+ case PROP_SIZE_HINTS:
+ panel_applet_set_size_hints_from_seq (applet, g_value_get_object (value));
+ break;
+ case PROP_LOCKED:
+ panel_applet_set_locked (applet, g_value_get_boolean (value));
+ break;
+ case PROP_LOCKED_DOWN:
+ panel_applet_set_locked_down (applet, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
}
static void
-panel_applet_realize (GtkWidget *widget)
+add_tab_bindings (GtkBindingSet *binding_set,
+ GdkModifierType modifiers,
+ GtkDirectionType direction)
{
- GTK_WIDGET_CLASS (panel_applet_parent_class)->realize (widget);
-
- if (PANEL_APPLET (widget)->priv->background)
- panel_applet_handle_background (PANEL_APPLET (widget));
+ 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 void
-panel_applet_control_bound (BonoboControl *control,
- PanelApplet *applet)
+panel_applet_setup (PanelApplet *applet)
{
+ GValue value = {0, };
+ GArray *params;
+ gint i;
gboolean ret;
- g_return_if_fail (PANEL_IS_APPLET (applet));
- g_return_if_fail (applet->priv->iid != NULL &&
- applet->priv->closure != NULL);
+ g_assert (applet->priv->id != NULL &&
+ applet->priv->closure != NULL);
- if (applet->priv->bound)
- return;
+ params = g_array_sized_new (FALSE, TRUE, sizeof (GValue), 2);
+ value.g_type = 0;
+ g_value_init (&value, G_TYPE_OBJECT);
+ g_value_set_object (&value, G_OBJECT (applet));
+ g_array_append_val (params, value);
+
+ value.g_type = 0;
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_string (&value, applet->priv->id);
+ g_array_append_val (params, value);
+
+ value.g_type = 0;
+ g_value_init (&value, G_TYPE_BOOLEAN);
- bonobo_closure_invoke (applet->priv->closure,
- G_TYPE_BOOLEAN, &ret,
- PANEL_TYPE_APPLET, applet,
- G_TYPE_STRING, applet->priv->iid,
- NULL);
+ g_closure_invoke (applet->priv->closure,
+ &value, params->len,
+ (GValue *) params->data,
+ NULL);
+ for (i = 0; i < params->len; i++)
+ g_value_unset (&g_array_index (params, GValue, i));
+ g_array_free (params, TRUE);
+
+ ret = g_value_get_boolean (&value);
+ g_value_unset (&value);
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)
+panel_applet_init (PanelApplet *applet)
{
- GtkWidget *toplevel;
+ applet->priv = PANEL_APPLET_GET_PRIVATE (applet);
- applet->priv->moving_focus_out = TRUE;
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (applet));
- g_return_if_fail (toplevel);
+ applet->priv->flags = PANEL_APPLET_FLAGS_NONE;
+ applet->priv->orient = PANEL_APPLET_ORIENT_UP;
+ applet->priv->size = 24;
- gtk_widget_child_focus (toplevel, dir);
- applet->priv->moving_focus_out = FALSE;
-}
+ applet->priv->client = gconf_client_get_default ();
+
+ applet->priv->panel_action_group = gtk_action_group_new ("PanelActions");
+ gtk_action_group_set_translation_domain (applet->priv->panel_action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (applet->priv->panel_action_group,
+ menu_entries,
+ G_N_ELEMENTS (menu_entries),
+ applet);
+ gtk_action_group_add_toggle_actions (applet->priv->panel_action_group,
+ menu_toggle_entries,
+ G_N_ELEMENTS (menu_toggle_entries),
+ applet);
+
+ applet->priv->ui_manager = gtk_ui_manager_new ();
+ gtk_ui_manager_insert_action_group (applet->priv->ui_manager,
+ applet->priv->panel_action_group, 1);
+ gtk_ui_manager_add_ui_from_string (applet->priv->ui_manager,
+ panel_menu_ui, -1, NULL);
-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);
+ applet->priv->plug = gtk_plug_new (0);
+ g_signal_connect_swapped (G_OBJECT (applet->priv->plug), "embedded",
+ G_CALLBACK (panel_applet_setup),
+ applet);
- panel_applet_setup (applet);
+ gtk_widget_set_events (GTK_WIDGET (applet),
+ GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK);
- return obj;
+ gtk_container_add (GTK_CONTAINER (applet->priv->plug), GTK_WIDGET (applet));
}
static void
@@ -1563,20 +1707,41 @@ panel_applet_class_init (PanelAppletClass *klass)
GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
GtkBindingSet *binding_set;
- gobject_class->constructor = panel_applet_constructor;
+ gobject_class->get_property = panel_applet_get_property;
+ gobject_class->set_property = panel_applet_set_property;
klass->move_focus_out_of_applet = panel_applet_move_focus_out_of_applet;
widget_class->button_press_event = panel_applet_button_press;
+ widget_class->button_release_event = panel_applet_button_release;
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;
+ widget_class->popup_menu = panel_applet_popup_menu;
gobject_class->finalize = panel_applet_finalize;
g_type_class_add_private (klass, sizeof (PanelAppletPrivate));
+ g_object_class_install_property (gobject_class,
+ PROP_ID,
+ g_param_spec_string ("id",
+ "Id",
+ "The Applet identifier",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class,
+ PROP_CLOSURE,
+ g_param_spec_pointer ("closure",
+ "GClocure",
+ "The Applet closure",
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_READWRITE));
+
+ g_assert (_panel_applet_override_properties (gobject_class, PROP_PREFS_KEY) == PROP_LOCKED_DOWN);
+
panel_applet_signals [CHANGE_ORIENT] =
g_signal_new ("change_orient",
G_TYPE_FROM_CLASS (klass),
@@ -1634,58 +1799,6 @@ panel_applet_class_init (PanelAppletClass *klass)
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)
{
@@ -1696,154 +1809,116 @@ panel_applet_new (void)
return GTK_WIDGET (applet);
}
-typedef struct {
- GType applet_type;
- GClosure *closure;
-} PanelAppletCallBackData;
-
-static PanelAppletCallBackData *
-panel_applet_callback_data_new (GType applet_type,
- GClosure *closure)
+/* Panel Applet Interface */
+static void
+panel_applet_handle_popup_menu (_PanelApplet *instance,
+ guint button,
+ guint time,
+ EggDBusMethodInvocation *method_invocation)
{
- PanelAppletCallBackData *retval;
-
- retval = g_new0 (PanelAppletCallBackData, 1);
-
- retval->applet_type = applet_type;
- retval->closure = closure;
-
- return retval;
+ panel_applet_menu_popup (PANEL_APPLET (instance), button, time);
+ _panel_applet_handle_popup_menu_finish (method_invocation);
}
static void
-panel_applet_callback_data_free (PanelAppletCallBackData *data)
+panel_applet_applet_iface_init (_PanelAppletIface *iface)
{
- g_closure_unref (data->closure);
- g_free (data);
+ iface->handle_popup_menu = panel_applet_handle_popup_menu;
}
-static BonoboObject *
-panel_applet_factory_callback (BonoboGenericFactory *factory,
- const char *iid,
- PanelAppletCallBackData *data)
+static void
+panel_applet_factory_main_finalized (gpointer data,
+ GObject *object)
{
- PanelApplet *applet;
+ gtk_main_quit ();
+}
- applet = g_object_new (data->applet_type, NULL);
+static int (*_x_error_func) (Display *, XErrorEvent *);
- applet->priv->iid = g_strdup (iid);
- applet->priv->closure = g_closure_ref (data->closure);
+static int
+_x_error_handler (Display *display, XErrorEvent *error)
+{
+ if (!error->error_code)
+ return 0;
- bonobo_control_life_instrument (applet->priv->control);
+ /*
+ * If we got a BadDrawable or a BadWindow, we ignore it for
+ * now. FIXME: We need to somehow distinguish real errors
+ * from X-server-induced errors. Keeping a list of windows
+ * for which we will ignore BadDrawables would be a good idea.
+ */
+ if (error->error_code == BadDrawable ||
+ error->error_code == BadWindow)
+ return 0;
- return BONOBO_OBJECT (applet->priv->control);
+ return _x_error_func (display, error);
}
+/*
+ * To do graphical embedding in the X window system, GNOME Panel
+ * uses the classic foreign-window-reparenting trick. The
+ * GtkPlug/GtkSocket widgets are used for this purpose. However,
+ * serious robustness problems arise if the GtkSocket end of the
+ * connection unexpectedly dies. The X server sends out DestroyNotify
+ * events for the descendants of the GtkPlug (i.e., your embedded
+ * component's windows) in effectively random order. Furthermore, if
+ * you happened to be drawing on any of those windows when the
+ * GtkSocket was destroyed (a common state of affairs), an X error
+ * will kill your application.
+ *
+ * To solve this latter problem, GNOME Panel sets up its own X error
+ * handler which ignores certain X errors that might have been
+ * caused by such a scenario. Other X errors get passed to gdk_x_error
+ * normally.
+ */
static void
-panel_applet_all_controls_dead (void)
+_panel_applet_setup_x_error_handler (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));
+ static gboolean error_handler_setup = FALSE;
- 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);
+ if (error_handler_setup)
+ return;
- panel_applet_callback_data_free (data);
+ error_handler_setup = TRUE;
- return retval;
+ _x_error_func = XSetErrorHandler (_x_error_handler);
}
int
-panel_applet_factory_main (const gchar *iid,
- GType applet_type,
- PanelAppletFactoryCallback callback,
- gpointer data)
+panel_applet_factory_main (const gchar *factory_id,
+ gboolean out_process,
+ GType applet_type,
+ PanelAppletFactoryCallback callback,
+ gpointer user_data)
{
- GClosure *closure;
+ PanelAppletFactory *factory;
+ GClosure *closure;
- g_return_val_if_fail (iid != NULL, 1);
+ g_return_val_if_fail (factory_id != 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");
+ if (out_process)
+ _panel_applet_setup_x_error_handler ();
- 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));
+ closure = g_cclosure_new (G_CALLBACK (callback), user_data, NULL);
+ factory = panel_applet_factory_new (factory_id, applet_type, closure);
+ g_closure_unref (closure);
- return CORBA_Object_duplicate (BONOBO_OBJREF (factory), ev);
-}
+ if (panel_applet_factory_register_service (factory)) {
+ if (out_process) {
+ g_object_weak_ref (G_OBJECT (factory),
+ panel_applet_factory_main_finalized,
+ NULL);
+ gtk_main ();
+ }
-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 0;
+ }
- return panel_applet_shlib_factory_closure (
- iid, applet_type, poa, impl_ptr,
- g_cclosure_new (G_CALLBACK (callback),
- user_data, NULL),
- ev);
+ g_object_unref (factory);
+
+ return 1;
}
void
@@ -1864,3 +1939,13 @@ panel_applet_set_background_widget (PanelApplet *applet,
g_object_unref (pixmap);
}
}
+
+guint32
+panel_applet_get_xid (PanelApplet *applet,
+ GdkScreen *screen)
+{
+ gtk_window_set_screen (GTK_WINDOW (applet->priv->plug), screen);
+ gtk_widget_show (applet->priv->plug);
+
+ return gtk_plug_get_id (GTK_PLUG (applet->priv->plug));
+}
diff --git a/libpanel-applet/panel-applet.h b/libpanel-applet/panel-applet.h
index 85e93e0..250be91 100644
--- a/libpanel-applet/panel-applet.h
+++ b/libpanel-applet/panel-applet.h
@@ -27,22 +27,15 @@
#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
-
+typedef enum {
+ PANEL_APPLET_ORIENT_UP,
+ PANEL_APPLET_ORIENT_DOWN,
+ PANEL_APPLET_ORIENT_LEFT,
+ PANEL_APPLET_ORIENT_RIGHT
+} PanelAppletOrient;
#define PANEL_TYPE_APPLET (panel_applet_get_type ())
#define PANEL_APPLET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PANEL_TYPE_APPLET, PanelApplet))
@@ -98,11 +91,15 @@ struct _PanelAppletClass {
GType panel_applet_get_type (void) G_GNUC_CONST;
GtkWidget *panel_applet_new (void);
+guint32 panel_applet_get_xid (PanelApplet *applet,
+ GdkScreen *screen);
PanelAppletOrient panel_applet_get_orient (PanelApplet *applet);
-
+void panel_applet_set_orient (PanelApplet *applet,
+ PanelAppletOrient orient);
guint panel_applet_get_size (PanelApplet *applet);
-
+void panel_applet_set_size (PanelApplet *applet,
+ guint size);
PanelAppletBackgroundType
panel_applet_get_background (PanelApplet *applet,
/* return values */
@@ -127,50 +124,28 @@ void panel_applet_set_size_hints (PanelApplet *applet,
int n_elements,
int base_size);
+gboolean panel_applet_get_locked (PanelApplet *applet);
+void panel_applet_set_locked (PanelApplet *applet,
+ gboolean locked);
gboolean panel_applet_get_locked_down (PanelApplet *applet);
-
+void panel_applet_set_locked_down (PanelApplet *applet,
+ gboolean locked_down);
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);
-
+ GtkActionGroup *action_group);
+void panel_applet_setup_menu_from_file (PanelApplet *applet,
+ const gchar *filename,
+ GtkActionGroup *action_group);
-int panel_applet_factory_main (const gchar *iid,
+int panel_applet_factory_main (const gchar *factory_id,
+ gboolean out_process,
GType applet_type,
PanelAppletFactoryCallback callback,
gpointer data);
+gboolean _panel_applet_shlib_factory (void);
-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.
@@ -194,7 +169,7 @@ Bonobo_Unknown panel_applet_shlib_factory_closure (const char
} while (0)
#endif /* !defined(ENABLE_NLS) */
-#define PANEL_APPLET_BONOBO_FACTORY(iid, type, name, version, callback, data) \
+#define PANEL_APPLET_OUT_PROCESS_FACTORY(id, type, name, callback, data) \
int main (int argc, char *argv []) \
{ \
GOptionContext *context; \
@@ -205,8 +180,6 @@ int main (int argc, char *argv []) \
\
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)) { \
@@ -221,33 +194,20 @@ int main (int argc, char *argv []) \
} \
\
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); \
+ \
+ retval = panel_applet_factory_main (id, TRUE, 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) \
+#define PANEL_APPLET_IN_PROCESS_FACTORY(id, type, descr, callback, data) \
+G_MODULE_EXPORT gint \
+_panel_applet_shlib_factory (void) \
{ \
_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) };
+ return panel_applet_factory_main (id, FALSE, type, callback, data); \
+}
G_END_DECLS
diff --git a/libpanel-applet/panel-test-applets.c b/libpanel-applet/panel-test-applets.c
index bbc5581..c61716f 100644
--- a/libpanel-applet/panel-test-applets.c
+++ b/libpanel-applet/panel-test-applets.c
@@ -10,13 +10,13 @@
#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"
+#include <gnome-panel/panel-applet-container.h>
+#include <gnome-panel/panel-applets-manager.h>
+
G_GNUC_UNUSED void on_execute_button_clicked (GtkButton *button, gpointer dummy);
static GtkWidget *win = NULL;
@@ -46,32 +46,48 @@ enum {
typedef struct {
const char *name;
- const char *value;
+ guint value;
} ComboItem;
static ComboItem orient_items [] = {
- { NC_("Orientation", "Top"), "top" },
- { NC_("Orientation", "Bottom"), "bottom" },
- { NC_("Orientation", "Left"), "left" },
- { NC_("Orientation", "Right"), "right" }
+ { NC_("Orientation", "Top"), PANEL_ORIENTATION_TOP },
+ { NC_("Orientation", "Bottom"), PANEL_ORIENTATION_BOTTOM },
+ { NC_("Orientation", "Left"), PANEL_ORIENTATION_LEFT },
+ { NC_("Orientation", "Right"), PANEL_ORIENTATION_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" }
+ { NC_("Size", "XX Small"), 12 },
+ { NC_("Size", "X Small"), 24 },
+ { NC_("Size", "Small"), 36 },
+ { NC_("Size", "Medium"), 48 },
+ { NC_("Size", "Large"), 64 },
+ { NC_("Size", "X Large"), 80 },
+ { NC_("Size", "XX Large"), 128 }
};
-static char *
+static guint
get_combo_value (GtkWidget *combo_box)
{
GtkTreeIter iter;
GtkTreeModel *model;
+ guint value;
+
+ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_box), &iter))
+ return 0;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
+ gtk_tree_model_get (model, &iter, COLUMN_ITEM, &value, -1);
+
+ return value;
+}
+
+static gchar *
+get_combo_applet_id (GtkWidget *combo_box)
+{
+ GtkTreeIter iter;
+ GtkTreeModel *model;
char *value;
if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_box), &iter))
@@ -83,111 +99,115 @@ get_combo_value (GtkWidget *combo_box)
return value;
}
-static char *
-construct_moniker (void)
+static void
+applet_broken_cb (GtkWidget *container,
+ GtkWidget *window)
{
- 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;
+ gtk_widget_destroy (window);
}
static void
-load_applet_into_window (const char *moniker,
- const char *title)
+applet_activated_cb (GObject *source_object,
+ GAsyncResult *res,
+ GtkWidget *applet_window)
{
- GtkWidget *applet_window;
- GtkWidget *applet;
+ GError *error = NULL;
- applet = bonobo_widget_new_control (moniker, NULL);
-
- if (!applet) {
+ if (!panel_applet_container_add_finish (PANEL_APPLET_CONTAINER (source_object),
+ res, &error)) {
GtkWidget *dialog;
- dialog = gtk_message_dialog_new (win ? GTK_WINDOW (win) : NULL,
- GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+ dialog = gtk_message_dialog_new (GTK_WINDOW (applet_window),
+ GTK_DIALOG_MODAL|
+ GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
_("Failed to load applet %s"),
- title);
+ error->message); // FIXME
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
return;
}
- applet_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_widget_show (applet_window);
+}
- gtk_widget_show (applet);
+static void
+load_applet_into_window (const char *title,
+ const char *prefs_key,
+ guint size,
+ guint orientation)
+{
+ GtkWidget *container;
+ GtkWidget *applet_window;
- gtk_container_add (GTK_CONTAINER (applet_window), applet);
+ container = panel_applet_container_new ();
+ applet_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
//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);
+ gtk_container_add (GTK_CONTAINER (applet_window), container);
+ gtk_widget_show (container);
+
+ g_signal_connect (container, "applet-broken",
+ G_CALLBACK (applet_broken_cb),
+ applet_window);
+
+ panel_applet_container_add (PANEL_APPLET_CONTAINER (container),
+ title, NULL,
+ (GAsyncReadyCallback)applet_activated_cb,
+ applet_window,
+ "prefs-key", prefs_key,
+ "size", size,
+ "orient", orientation,
+ NULL);
}
static void
load_applet_from_command_line (void)
{
- GString *str;
+ guint size = 24, orient = PANEL_ORIENTATION_TOP;
+ gint i;
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);
+ if (cli_size || cli_orient) {
+ if (cli_size) {
+ for (i = 0; i < G_N_ELEMENTS (size_items); i++) {
+ if (strcmp (g_dpgettext2 (NULL, "Size", size_items[i].name), cli_size) == 0) {
+ size = size_items[i].value;
+ break;
+ }
+ }
+ }
+
+ if (cli_orient) {
+ for (i = 0; i < G_N_ELEMENTS (orient_items); i++) {
+ if (strcmp (g_dpgettext2 (NULL, "Orientation", orient_items[i].name), cli_orient) == 0) {
+ orient = orient_items[i].value;
+ break;
+ }
+ }
+ }
}
-
- g_print ("Loading %s\n", str->str);
- load_applet_into_window (str->str, cli_iid);
+ g_print ("Loading %s\n", cli_iid);
- g_string_free (str, TRUE);
+ load_applet_into_window (cli_iid, cli_prefs_dir, size, orient);
}
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);
+ title = get_combo_applet_id (applet_combo);
+
+ load_applet_into_window (title,
+ gtk_entry_get_text (GTK_ENTRY (prefs_dir_entry)),
+ get_combo_value (size_combo),
+ get_combo_value (orient_combo));
g_free (title);
}
@@ -195,8 +215,7 @@ static void
setup_combo (GtkWidget *combo_box,
ComboItem *items,
const char *context,
- int nb_items,
- gboolean dynamic)
+ int nb_items)
{
GtkListStore *model;
GtkTreeIter iter;
@@ -205,7 +224,7 @@ setup_combo (GtkWidget *combo_box,
model = gtk_list_store_new (NUMBER_COLUMNS,
G_TYPE_STRING,
- G_TYPE_STRING);
+ G_TYPE_INT);
gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box),
GTK_TREE_MODEL (model));
@@ -214,8 +233,8 @@ setup_combo (GtkWidget *combo_box,
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,
+ COLUMN_TEXT, g_dpgettext2 (NULL, context, items [i].name),
+ COLUMN_ITEM, items [i].value,
-1);
}
@@ -231,45 +250,45 @@ setup_combo (GtkWidget *combo_box,
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;
+ GList *applet_list, *l;
+ int i;
+ char *prefs_dir;
+ char *unique_key;
+ GtkListStore *model;
+ GtkTreeIter iter;
+ GtkCellRenderer *renderer;
- 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);
+ model = gtk_list_store_new (NUMBER_COLUMNS,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
- for (i = 0; i < applet_nb; i++) {
- Bonobo_ServerInfo *info;
+ gtk_combo_box_set_model (GTK_COMBO_BOX (applet_combo),
+ GTK_TREE_MODEL (model));
- info = &applets->_buffer [i];
+ applet_list = panel_applets_manager_get_applets ();
+ for (l = applet_list, i = 1; l; l = g_list_next (l), i++) {
+ PanelAppletInfo *info = (PanelAppletInfo *)l->data;
- applet_items[i].name = info->iid;
- applet_items[i].value = info->iid;
+ gtk_list_store_append (model, &iter);
+ gtk_list_store_set (model, &iter,
+ COLUMN_TEXT, g_strdup (panel_applet_info_get_name (info)),
+ COLUMN_ITEM, g_strdup (panel_applet_info_get_iid (info)),
+ -1);
}
+ g_list_free (applet_list);
- setup_combo (applet_combo, applet_items, NULL, applet_nb, TRUE);
- g_free (applet_items);
- CORBA_free (applets);
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (applet_combo),
+ renderer, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (applet_combo),
+ renderer, "text", COLUMN_TEXT, NULL);
+
+ gtk_combo_box_set_active (GTK_COMBO_BOX (applet_combo), 0);
setup_combo (size_combo, size_items, "Size",
- G_N_ELEMENTS (size_items), FALSE);
+ G_N_ELEMENTS (size_items));
setup_combo (orient_combo, orient_items, "Orientation",
- G_N_ELEMENTS (orient_items), FALSE);
+ G_N_ELEMENTS (orient_items));
unique_key = gconf_unique_key ();
prefs_dir = g_strdup_printf ("/tmp/%s", unique_key);
@@ -283,6 +302,7 @@ main (int argc, char **argv)
{
GtkBuilder *builder;
char *uifile;
+ char *applets_dir;
GError *error;
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
@@ -302,14 +322,16 @@ main (int argc, char **argv)
return 1;
}
- if (!bonobo_init (&argc, argv)) {
- g_printerr ("Cannot initialize bonobo.\n");
- return 1;
- }
+ applets_dir = g_strdup_printf ("%s:./", PANEL_APPLETS_DIR);
+ g_setenv ("PANEL_APPLETS_DIR", applets_dir, FALSE);
+ g_free (applets_dir);
+
+ panel_applets_manager_init ();
if (cli_iid) {
load_applet_from_command_line ();
gtk_main ();
+ panel_applets_manager_shutdown ();
return 0;
}
@@ -322,6 +344,8 @@ main (int argc, char **argv)
if (error) {
g_warning ("Error loading \"%s\": %s", uifile, error->message);
g_error_free (error);
+ panel_applets_manager_shutdown ();
+
return 1;
}
@@ -345,5 +369,7 @@ main (int argc, char **argv)
gtk_main ();
+ panel_applets_manager_shutdown ();
+
return 0;
}
diff --git a/libpanel-applet/test-bonobo-applet.c b/libpanel-applet/test-dbus-applet.c
similarity index 58%
rename from libpanel-applet/test-bonobo-applet.c
rename to libpanel-applet/test-dbus-applet.c
index ea60bbe..c35eb8a 100644
--- a/libpanel-applet/test-bonobo-applet.c
+++ b/libpanel-applet/test-dbus-applet.c
@@ -1,71 +1,62 @@
-/*
- * 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)
+test_applet_on_do (GtkAction *action,
+ gpointer user_data)
{
- g_message ("%s called\n", verbname);
+ g_message ("%s called\n", gtk_action_get_name (action));
}
-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 GtkActionEntry test_applet_menu_actions[] = {
+ { "TestAppletDo1", NULL, "TestAppletDo1",
+ NULL, NULL,
+ G_CALLBACK (test_applet_on_do) },
+ { "TestAppletDo2", NULL, "TestAppletDo2",
+ NULL, NULL,
+ G_CALLBACK (test_applet_on_do) },
+ { "TestAppletDo3", NULL, "TestAppletDo3",
+ NULL, NULL,
+ G_CALLBACK (test_applet_on_do) }
};
-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";
+static const char test_applet_menu_xml[] =
+ "<menuitem name=\"Test Item 1\" action=\"TestAppletDo1\" />\n"
+ "<menuitem name=\"Test Item 2\" action=\"TestAppletDo2\" />\n"
+ "<menuitem name=\"Test Item 3\" action=\"TestAppletDo3\" />\n";
-typedef struct {
+typedef struct _TestApplet TestApplet;
+typedef struct _TestAppletClass TestAppletClass;
+
+struct _TestApplet {
PanelApplet base;
GtkWidget *label;
-} TestApplet;
+};
+
+struct _TestAppletClass {
+ PanelAppletClass base_class;
+};
+
+static GType test_applet_get_type (void) G_GNUC_CONST;
+
+G_DEFINE_TYPE (TestApplet, test_applet, PANEL_TYPE_APPLET);
-static GType
-test_applet_get_type (void)
+static void
+test_applet_init (TestApplet *applet)
{
- 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_class_init (TestAppletClass *klass)
+{
}
static void
-test_applet_handle_orient_change (TestApplet *applet,
- PanelAppletOrient orient,
- gpointer dummy)
+test_applet_handle_orient_change (TestApplet *applet,
+ PanelAppletOrient orient,
+ gpointer dummy)
{
gchar *text;
@@ -84,31 +75,31 @@ test_applet_handle_size_change (TestApplet *applet,
gpointer dummy)
{
switch (size) {
- case GNOME_Vertigo_PANEL_XX_SMALL:
+ case 12:
gtk_label_set_markup (
GTK_LABEL (applet->label), "<span size=\"xx-small\">Hello</span>");
break;
- case GNOME_Vertigo_PANEL_X_SMALL:
+ case 24:
gtk_label_set_markup (
GTK_LABEL (applet->label), "<span size=\"x-small\">Hello</span>");
break;
- case GNOME_Vertigo_PANEL_SMALL:
+ case 36:
gtk_label_set_markup (
GTK_LABEL (applet->label), "<span size=\"small\">Hello</span>");
break;
- case GNOME_Vertigo_PANEL_MEDIUM:
+ case 48:
gtk_label_set_markup (
GTK_LABEL (applet->label), "<span size=\"medium\">Hello</span>");
break;
- case GNOME_Vertigo_PANEL_LARGE:
+ case 64:
gtk_label_set_markup (
GTK_LABEL (applet->label), "<span size=\"large\">Hello</span>");
break;
- case GNOME_Vertigo_PANEL_X_LARGE:
+ case 80:
gtk_label_set_markup (
GTK_LABEL (applet->label), "<span size=\"x-large\">Hello</span>");
break;
- case GNOME_Vertigo_PANEL_XX_LARGE:
+ case 128:
gtk_label_set_markup (
GTK_LABEL (applet->label), "<span size=\"xx-large\">Hello</span>");
break;
@@ -132,7 +123,7 @@ test_applet_handle_background_change (TestApplet *applet,
break;
case PANEL_COLOR_BACKGROUND:
g_message ("Setting background to #%2x%2x%2x",
- color->red, color->green, color->blue);
+ color->red, color->green, color->blue);
gdk_window_set_back_pixmap (applet->label->window, NULL, FALSE);
break;
case PANEL_PIXMAP_BACKGROUND:
@@ -148,16 +139,31 @@ test_applet_handle_background_change (TestApplet *applet,
static gboolean
test_applet_fill (TestApplet *applet)
{
+ GtkActionGroup *action_group;
+
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);
+ test_applet_handle_size_change (applet,
+ panel_applet_get_size (PANEL_APPLET (applet)),
+ NULL);
+ test_applet_handle_orient_change (applet,
+ panel_applet_get_orient (PANEL_APPLET (applet)),
+ NULL);
+
+ action_group = gtk_action_group_new ("TestAppletActions");
+ gtk_action_group_add_actions (action_group,
+ test_applet_menu_actions,
+ G_N_ELEMENTS (test_applet_menu_actions),
+ applet);
- panel_applet_setup_menu (
- PANEL_APPLET (applet), test_applet_menu_xml, test_applet_menu_verbs, NULL);
+ panel_applet_setup_menu (PANEL_APPLET (applet),
+ test_applet_menu_xml,
+ action_group);
+ g_object_unref (action_group);
gtk_widget_set_tooltip_text (GTK_WIDGET (applet), "Hello Tip");
@@ -188,15 +194,16 @@ test_applet_factory (TestApplet *applet,
{
gboolean retval = FALSE;
- if (!strcmp (iid, "OAFIID:GNOME_Panel_TestBonoboApplet"))
+ if (!strcmp (iid, "TestApplet"))
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)
+
+PANEL_APPLET_OUT_PROCESS_FACTORY ("TestAppletFactory",
+ test_applet_get_type (),
+ "A Test Applet for the GNOME-3.0 Panel",
+ (PanelAppletFactoryCallback) test_applet_factory,
+ NULL)
+
diff --git a/po/POTFILES.in b/po/POTFILES.in
index db0ffbe..8dab7e5 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,8 +1,7 @@
# List of source files containing translatable strings.
# Please keep this file sorted alphabetically.
[encoding: UTF-8]
-applets/clock/GNOME_ClockApplet.xml
-applets/clock/GNOME_ClockApplet_Factory.server.in.in
+applets/clock/GNOME_ClockApplet.panel-applet.in.in
applets/clock/calendar-client.c
applets/clock/calendar-window.c
applets/clock/clock.c
@@ -12,20 +11,14 @@ applets/clock/clock-location.c
applets/clock/clock-location-tile.c
applets/clock/clock-utils.c
applets/clock/org.gnome.clockapplet.mechanism.policy.in
-applets/fish/GNOME_FishApplet.xml
-applets/fish/GNOME_FishApplet_Factory.server.in.in
+applets/fish/GNOME_FishApplet.panel-applet.in.in
applets/fish/fish.c
[type: gettext/glade]applets/fish/fish.ui
applets/fish/fish.schemas.in
-applets/notification_area/GNOME_NotificationAreaApplet.server.in.in
-applets/notification_area/GNOME_NotificationAreaApplet.xml
+applets/notification_area/GNOME_NotificationAreaApplet.panel-applet.in.in
applets/notification_area/na-tray-manager.c
applets/notification_area/main.c
-applets/wncklet/GNOME_ShowDesktopApplet.xml
-applets/wncklet/GNOME_WindowListApplet.xml
-applets/wncklet/GNOME_WindowMenuApplet.xml
-applets/wncklet/GNOME_Wncklet_Factory.server.in.in
-applets/wncklet/GNOME_WorkspaceSwitcherApplet.xml
+applets/wncklet/GNOME_Wncklet.panel-applet.in.in
applets/wncklet/showdesktop.c
applets/wncklet/window-list.c
[type: gettext/glade]applets/wncklet/window-list.ui
@@ -41,7 +34,6 @@ gnome-panel/libpanel-util/panel-error.c
gnome-panel/libpanel-util/panel-icon-chooser.c
gnome-panel/libpanel-util/panel-launch.c
gnome-panel/libpanel-util/panel-show.c
-gnome-panel/GNOME_Panel_Popup.xml
gnome-panel/applet.c
gnome-panel/button-widget.c
gnome-panel/drawer.c
@@ -79,6 +71,6 @@ gnome-panel/panel-toplevel.c
gnome-panel/panel-toplevel.schemas.in
gnome-panel/panel-util.c
gnome-panel/panel.c
-libpanel-applet/GNOME_Panel_TestApplet.server.in
+libpanel-applet/GNOME_Panel_TestApplet.panel-applet.in
libpanel-applet/panel-test-applets.c
[type: gettext/glade]libpanel-applet/panel-test-applets.ui
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]