[gnome-applets] [multiload] Port to new libpanel-applet API
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets] [multiload] Port to new libpanel-applet API
- Date: Wed, 18 Aug 2010 14:39:50 +0000 (UTC)
commit 62ab2e7d968e2186a309fa06d04b8442daf4bafd
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Tue Feb 23 11:24:21 2010 +0100
[multiload] Port to new libpanel-applet API
.../GNOME_MultiLoadApplet_Factory.server.in.in | 36 ---------
multiload/GNOME_MultiloadApplet.xml | 15 ----
multiload/Makefile.am | 46 +++++++----
multiload/global.h | 6 +-
multiload/main.c | 83 +++++++++++---------
multiload/multiload-applet-menu.xml | 6 ++
...nome.applets.MultiLoadApplet.panel-applet.in.in | 16 ++++
....panel.applet.MultiLoadAppletFactory.service.in | 3 +
multiload/properties.c | 5 +-
9 files changed, 104 insertions(+), 112 deletions(-)
---
diff --git a/multiload/Makefile.am b/multiload/Makefile.am
index ac028ab..53b3147 100644
--- a/multiload/Makefile.am
+++ b/multiload/Makefile.am
@@ -2,10 +2,10 @@ SUBDIRS = docs
INCLUDES = \
-I$(srcdir) \
- $(GNOME_APPLETS_CFLAGS) \
+ -DMULTILOAD_MENU_UI_DIR=\""$(uidir)"\" \
+ $(GNOME_APPLETS3_CFLAGS) \
$(GTOP_APPLETS_CFLAGS) \
- $(GNOMEDESKTOP_CFLAGS) \
- $(GNOME_LIBS2_CFLAGS)
+ $(GNOMEDESKTOP_CFLAGS)
libexec_PROGRAMS = multiload-applet-2
@@ -22,10 +22,9 @@ multiload_applet_2_SOURCES = \
autoscaler.h
multiload_applet_2_LDADD = \
- $(GNOME_APPLETS_LIBS) \
+ $(GNOME_APPLETS3_LIBS) \
$(GTOP_APPLETS_LIBS) \
- $(GNOMEDESKTOP_LIBS) \
- $(GNOME_LIBS2_LIBS)
+ $(GNOMEDESKTOP_LIBS)
schemasdir = @GCONF_SCHEMA_FILE_DIR@
schemas_in_files = multiload.schemas.in
@@ -33,24 +32,37 @@ schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
@INTLTOOL_SCHEMAS_RULE@
-EXTRA_DIST = \
- GNOME_MultiLoadApplet_Factory.server.in.in \
- $(schemas_in_files) \
+EXTRA_DIST = \
+ org.gnome.applets.MultiLoadApplet.panel-applet.in.in \
+ $(service_in_files) \
+ $(schemas_in_files) \
$(ui_DATA)
uidir = $(datadir)/gnome-2.0/ui
-ui_DATA = GNOME_MultiloadApplet.xml
+ui_DATA = multiload-applet-menu.xml
-serverdir = $(libdir)/bonobo/servers
-server_in_files = GNOME_MultiLoadApplet_Factory.server.in
-server_DATA = $(server_in_files:.server.in=.server)
+appletdir = $(datadir)/gnome-panel/applets
+applet_in_files = org.gnome.applets.MultiLoadApplet.panel-applet.in
+applet_DATA = $(applet_in_files:.panel-applet.in=.panel-applet)
-$(server_in_files): $(server_in_files:.server.in=.server.in.in)
- sed -e "s|\ LIBEXECDIR\@|$(libexecdir)|" $< > $@
+$(applet_in_files): $(applet_in_files).in Makefile
+ $(AM_V_GEN)sed \
+ -e "s|\ LIBEXECDIR\@|$(libexecdir)|" \
+ -e "s|\ VERSION\@|$(PACKAGE_VERSION)|" \
+ $< > $@
-CLEANFILES = $(server_in_files) $(server_DATA) $(schemas_DATA)
+%.panel-applet: %.panel-applet.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
- INTLTOOL_SERVER_RULE@
+servicedir = $(datadir)/dbus-1/services
+service_in_files = org.gnome.panel.applet.MultiLoadAppletFactory.service.in
+service_DATA = $(service_in_files:.service.in=.service)
+
+org.gnome.panel.applet.MultiLoadAppletFactory.service: $(service_in_files)
+ $(AM_V_GEN)sed \
+ -e "s|\ LIBEXECDIR\@|$(libexecdir)|" \
+ $< > $@
+
+CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA) $(schemas_DATA)
if GCONF_SCHEMAS_INSTALL
install-data-local:
diff --git a/multiload/global.h b/multiload/global.h
index 5fb50c0..9f96ccf 100644
--- a/multiload/global.h
+++ b/multiload/global.h
@@ -2,6 +2,7 @@
#define __GLOBAL_H__
#include <glib.h>
+#include <glib/gi18n.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtk.h>
#include <panel-applet.h>
@@ -82,9 +83,8 @@ struct _MultiloadApplet
/* show properties dialog */
G_GNUC_INTERNAL void
-multiload_properties_cb (BonoboUIComponent *uic,
- MultiloadApplet *ma,
- const char *name);
+multiload_properties_cb (GtkAction *action,
+ MultiloadApplet *ma);
/* remove the old graphs and rebuild them */
G_GNUC_INTERNAL void
diff --git a/multiload/main.c b/multiload/main.c
index a44ac84..f5cf5f6 100644
--- a/multiload/main.c
+++ b/multiload/main.c
@@ -30,9 +30,8 @@
#include "global.h"
static void
-about_cb (BonoboUIComponent *uic,
- MultiloadApplet *ma,
- const char *name)
+about_cb (GtkAction *action,
+ MultiloadApplet *ma)
{
const gchar * const authors[] =
{
@@ -65,9 +64,8 @@ about_cb (BonoboUIComponent *uic,
}
static void
-help_cb (BonoboUIComponent *uic,
- MultiloadApplet *ma,
- const char *name)
+help_cb (GtkAction *action,
+ MultiloadApplet *ma)
{
GError *error = NULL;
@@ -142,9 +140,8 @@ start_procman (MultiloadApplet *ma)
}
static void
-start_procman_cb (BonoboUIComponent *uic,
- MultiloadApplet *ma,
- const char *name)
+start_procman_cb (GtkAction *action,
+ MultiloadApplet *ma)
{
start_procman (ma);
}
@@ -432,13 +429,19 @@ multiload_applet_refresh(MultiloadApplet *ma)
return;
}
-static const BonoboUIVerb multiload_menu_verbs [] = {
- BONOBO_UI_UNSAFE_VERB ("MultiLoadProperties", multiload_properties_cb),
- BONOBO_UI_UNSAFE_VERB ("MultiLoadRunProcman", start_procman_cb),
- BONOBO_UI_UNSAFE_VERB ("MultiLoadHelp", help_cb),
- BONOBO_UI_UNSAFE_VERB ("MultiLoadAbout", about_cb),
-
- BONOBO_UI_VERB_END
+static const GtkActionEntry multiload_menu_actions [] = {
+ { "MultiLoadProperties", GTK_STOCK_PROPERTIES, N_("_Preferences"),
+ NULL, NULL,
+ G_CALLBACK (multiload_properties_cb) },
+ { "MultiLoadRunProcman", GTK_STOCK_EXECUTE, N_("_Open System Monitor"),
+ NULL, NULL,
+ G_CALLBACK (start_procman_cb) },
+ { "MultiLoadHelp", GTK_STOCK_HELP, N_("_Help"),
+ NULL, NULL,
+ G_CALLBACK (help_cb) },
+ { "MultiLoadAbout", GTK_STOCK_ABOUT, N_("_About"),
+ NULL, NULL,
+ G_CALLBACK (about_cb) }
};
/* create a box and stuff the load graphs inside of it */
@@ -447,7 +450,8 @@ multiload_applet_new(PanelApplet *applet, const gchar *iid, gpointer data)
{
MultiloadApplet *ma;
GConfClient *client;
- BonoboUIComponent *popup_component;
+ GtkActionGroup *action_group;
+ gchar *ui_path;
ma = g_new0(MultiloadApplet, 1);
@@ -465,33 +469,37 @@ multiload_applet_new(PanelApplet *applet, const gchar *iid, gpointer data)
panel_applet_add_preferences (applet, "/schemas/apps/multiload/prefs", NULL);
panel_applet_set_flags (applet, PANEL_APPLET_EXPAND_MINOR);
- panel_applet_setup_menu_from_file (applet,
- DATADIR,
- "GNOME_MultiloadApplet.xml",
- NULL,
- multiload_menu_verbs,
- ma);
+ action_group = gtk_action_group_new ("Multiload Applet Actions");
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (action_group,
+ multiload_menu_actions,
+ G_N_ELEMENTS (multiload_menu_actions),
+ ma);
+ ui_path = g_build_filename (MULTILOAD_MENU_UI_DIR, "multiload-applet-menu.xml", NULL);
+ panel_applet_setup_menu_from_file (applet, ui_path, action_group);
+ g_free (ui_path);
- popup_component = panel_applet_get_popup_component (applet);
if (panel_applet_get_locked_down (applet)) {
- bonobo_ui_component_set_prop (popup_component,
- "/commands/MultiLoadProperties",
- "hidden", "1",
- NULL);
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (action_group, "MultiLoadProperties");
+ gtk_action_set_visible (action, FALSE);
}
client = gconf_client_get_default ();
if (gconf_client_get_bool (client, "/desktop/gnome/lockdown/inhibit_command_line", NULL) ||
panel_applet_get_locked_down (applet)) {
+ GtkAction *action;
+
/* When the panel is locked down or when the command line is inhibited,
it seems very likely that running the procman would be at least harmful */
- bonobo_ui_component_set_prop (popup_component,
- "/commands/MultiLoadRunProcman",
- "hidden", "1",
- NULL);
+ action = gtk_action_group_get_action (action_group, "MultiLoadRunProcman");
+ gtk_action_set_visible (action, FALSE);
}
+ g_object_unref (action_group);
+
g_signal_connect(G_OBJECT(applet), "change_size",
G_CALLBACK(multiload_change_size_cb), ma);
g_signal_connect(G_OBJECT(applet), "change_orient",
@@ -524,9 +532,8 @@ multiload_factory (PanelApplet *applet,
return retval;
}
-PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_MultiLoadApplet_Factory",
- PANEL_TYPE_APPLET,
- "multiload",
- "0",
- multiload_factory,
- NULL)
+PANEL_APPLET_OUT_PROCESS_FACTORY ("MultiLoadAppletFactory",
+ PANEL_TYPE_APPLET,
+ "multiload",
+ multiload_factory,
+ NULL)
diff --git a/multiload/multiload-applet-menu.xml b/multiload/multiload-applet-menu.xml
new file mode 100644
index 0000000..88d28dd
--- /dev/null
+++ b/multiload/multiload-applet-menu.xml
@@ -0,0 +1,6 @@
+<menuitem name="Procman Item" action="MultiLoadRunProcman" />
+<separator/>
+<menuitem name="Properties Item" action="MultiLoadProperties" />
+<menuitem name="Help" action="MultiLoadHelp" />
+<menuitem name="About Item" action="MultiLoadAbout" />
+
diff --git a/multiload/org.gnome.applets.MultiLoadApplet.panel-applet.in.in b/multiload/org.gnome.applets.MultiLoadApplet.panel-applet.in.in
new file mode 100644
index 0000000..7a147b4
--- /dev/null
+++ b/multiload/org.gnome.applets.MultiLoadApplet.panel-applet.in.in
@@ -0,0 +1,16 @@
+[Applet Factory]
+Id=MultiLoadAppletFactory
+Location= LIBEXECDIR@/multiload-applet-2
+Name=MultiLoad Applet Factory
+Description=Factory for creating the load applet.
+
+[MultiLoadApplet]
+_Name=System Monitor
+_Description=A system load indicator
+Icon=utilities-system-monitor
+BonoboId=OAFIID:GNOME_MultiLoadApplet
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=gnome-applets
+X-GNOME-Bugzilla-Component=multiload
+X-GNOME-Bugzilla-Version= VERSION@
+X-GNOME-Bugzilla-OtherBinaries=multiload-applet-2
diff --git a/multiload/org.gnome.panel.applet.MultiLoadAppletFactory.service.in b/multiload/org.gnome.panel.applet.MultiLoadAppletFactory.service.in
new file mode 100644
index 0000000..0cdda97
--- /dev/null
+++ b/multiload/org.gnome.panel.applet.MultiLoadAppletFactory.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.panel.applet.MultiLoadAppletFactory
+Exec= LIBEXECDIR@/multiload-applet-2
diff --git a/multiload/properties.c b/multiload/properties.c
index 2dd32d3..661e44d 100644
--- a/multiload/properties.c
+++ b/multiload/properties.c
@@ -637,9 +637,8 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
/* show properties dialog */
void
-multiload_properties_cb (BonoboUIComponent *uic,
- MultiloadApplet *ma,
- const char *name)
+multiload_properties_cb (GtkAction *action,
+ MultiloadApplet *ma)
{
GtkWidget *dialog = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]