[gnome-applets] [cpufreq] Port to new libpanel-applet API
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets] [cpufreq] Port to new libpanel-applet API
- Date: Wed, 18 Aug 2010 14:39:20 +0000 (UTC)
commit d160a23971c50ef890b7ed308174bb2556d0222c
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Thu May 27 12:45:10 2010 +0200
[cpufreq] Port to new libpanel-applet API
cpufreq/GNOME_CPUFreqApplet.server.in.in | 35 --------
cpufreq/GNOME_CPUFreqApplet.xml | 12 ---
cpufreq/Makefile.am | 39 ++++++---
cpufreq/cpufreq-applet-menu.xml | 4 +
....gnome.applets.CPUFreqApplet.panel-applet.in.in | 15 +++
cpufreq/src/Makefile.am | 7 +-
cpufreq/src/cpufreq-applet.c | 93 ++++++++++----------
7 files changed, 94 insertions(+), 111 deletions(-)
---
diff --git a/cpufreq/Makefile.am b/cpufreq/Makefile.am
index fec1afb..70f1e9c 100644
--- a/cpufreq/Makefile.am
+++ b/cpufreq/Makefile.am
@@ -6,20 +6,31 @@ schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
@INTLTOOL_SCHEMAS_RULE@
-serverdir = $(libdir)/bonobo/servers
-server_in_files = GNOME_CPUFreqApplet.server.in
-server_in_in_files = $(server_in_files:.server.in=.server.in.in)
-server_DATA = $(server_in_files:.server.in=.server)
+appletdir = $(datadir)/gnome-panel/applets
+applet_in_files = org.gnome.applets.CPUFreqApplet.panel-applet.in
+applet_DATA = $(applet_in_files:.panel-applet.in=.panel-applet)
-$(server_in_files): $(server_in_in_files)
- sed -e "s|\ DATADIR\@|$(datadir)|;s|\ LIBEXECDIR\@|$(libexecdir)|" $< > $@
+$(applet_in_files): $(applet_in_files).in Makefile
+ $(AM_V_GEN)sed \
+ -e "s|\ LIBEXECDIR\@|$(libexecdir)|" \
+ -e "s|\ VERSION\@|$(PACKAGE_VERSION)|" \
+ $< > $@
- INTLTOOL_SERVER_RULE@
+%.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
+
+servicedir = $(datadir)/dbus-1/services
+service_in_files = org.gnome.panel.applet.CPUFreqAppletFactory.service.in
+service_DATA = $(service_in_files:.service.in=.service)
+
+org.gnome.panel.applet.CPUFreqAppletFactory.service: $(service_in_files)
+ $(AM_V_GEN)sed \
+ -e "s|\ LIBEXECDIR\@|$(libexecdir)|" \
+ $< > $@
builder_DATA = cpufreq-preferences.ui
uidir = $(datadir)/gnome-2.0/ui
-ui_DATA = GNOME_CPUFreqApplet.xml
+ui_DATA = cpufreq-applet-menu.xml
if GCONF_SCHEMAS_INSTALL
install-data-local:
@@ -27,16 +38,18 @@ install-data-local:
endif
CLEANFILES = \
- GNOME_CPUFreqApplet.server \
- GNOME_CPUFreqApplet.server.in \
+ $(applet_DATA) \
+ $(applet_DATA).in \
+ $(service_DATA) \
cpufreq-applet.schemas \
*.bak \
*.gladep
EXTRA_DIST = \
- $(server_in_in_files) \
- $(schemas_in_files) \
- $(builder_DATA) \
+ org.gnome.applets.CPUFreqApplet.panel-applet.in.in \
+ $(service_in_files) \
+ $(schemas_in_files) \
+ $(builder_DATA) \
$(ui_DATA)
diff --git a/cpufreq/cpufreq-applet-menu.xml b/cpufreq/cpufreq-applet-menu.xml
new file mode 100644
index 0000000..9837581
--- /dev/null
+++ b/cpufreq/cpufreq-applet-menu.xml
@@ -0,0 +1,4 @@
+<menuitem name="CPUFreq Preferences Item" action="CPUFreqAppletPreferences" />
+<menuitem name="CPUFreq Help Item" action="CPUFreqAppletHelp" />
+<menuitem name="CPUFreq About Item" action="CPUFreqAppletAbout" />
+
diff --git a/cpufreq/org.gnome.applets.CPUFreqApplet.panel-applet.in.in b/cpufreq/org.gnome.applets.CPUFreqApplet.panel-applet.in.in
new file mode 100644
index 0000000..abfd026
--- /dev/null
+++ b/cpufreq/org.gnome.applets.CPUFreqApplet.panel-applet.in.in
@@ -0,0 +1,15 @@
+[Applet Factory]
+Id=CPUFreqAppletFactory
+Location= LIBEXECDIR@/cpufreq-applet
+_Name=CPU Frequency Scaling Monitor
+_Description=Monitor the CPU Frequency Scaling
+
+[CPUFreqApplet]
+_Name=CPU Frequency Scaling Monitor
+_Description=Monitor the CPU Frequency Scaling
+Icon=gnome-cpu-frequency-applet
+BonoboId=OAFIID:GNOME_CPUFreqApplet
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=gnome-applets
+X-GNOME-Bugzilla-Component=cpufreq
+X-GNOME-Bugzilla-Version= VERSION@
diff --git a/cpufreq/src/Makefile.am b/cpufreq/src/Makefile.am
index 4d51e42..2f94de7 100644
--- a/cpufreq/src/Makefile.am
+++ b/cpufreq/src/Makefile.am
@@ -5,8 +5,8 @@ endif
SUBDIRS = $(selector_SUBDIR)
INCLUDES = \
- $(GNOME_APPLETS_CFLAGS) \
- $(GNOME_LIBS2_CFLAGS) \
+ -DCPUFREQ_MENU_UI_DIR=\""$(datadir)/gnome-2.0/ui"\" \
+ $(GNOME_APPLETS3_CFLAGS) \
$(LIBGLADE_CFLAGS)
libexec_PROGRAMS = cpufreq-applet
@@ -29,8 +29,7 @@ cpufreq_applet_SOURCES = \
cpufreq-monitor-cpuinfo.c cpufreq-monitor-cpuinfo.h
cpufreq_applet_LDADD = \
- $(GNOME_APPLETS_LIBS) \
- $(GNOME_LIBS2_LIBS) \
+ $(GNOME_APPLETS3_LIBS) \
$(LIBGLADE_LIBS) \
$(LIBCPUFREQ_LIBS)
diff --git a/cpufreq/src/cpufreq-applet.c b/cpufreq/src/cpufreq-applet.c
index 3ee9e75..c7d08e3 100644
--- a/cpufreq/src/cpufreq-applet.c
+++ b/cpufreq/src/cpufreq-applet.c
@@ -79,15 +79,12 @@ struct _CPUFreqAppletClass {
static void cpufreq_applet_init (CPUFreqApplet *applet);
static void cpufreq_applet_class_init (CPUFreqAppletClass *klass);
-static void cpufreq_applet_preferences_cb (BonoboUIComponent *uic,
- CPUFreqApplet *applet,
- const gchar *cname);
-static void cpufreq_applet_help_cb (BonoboUIComponent *uic,
- CPUFreqApplet *applet,
- const gchar *cname);
-static void cpufreq_applet_about_cb (BonoboUIComponent *uic,
- CPUFreqApplet *applet,
- const gchar *cname);
+static void cpufreq_applet_preferences_cb (GtkAction *action,
+ CPUFreqApplet *applet);
+static void cpufreq_applet_help_cb (GtkAction *action,
+ CPUFreqApplet *applet);
+static void cpufreq_applet_about_cb (GtkAction *action,
+ CPUFreqApplet *applet);
static void cpufreq_applet_pixmap_set_image (CPUFreqApplet *applet,
gint perc);
@@ -121,14 +118,16 @@ static const gchar *const cpufreq_icons[] = {
NULL
};
-static const BonoboUIVerb cpufreq_applet_menu_verbs[] = {
- BONOBO_UI_UNSAFE_VERB ("CPUFreqAppletPreferences",
- cpufreq_applet_preferences_cb),
- BONOBO_UI_UNSAFE_VERB ("CPUFreqAppletHelp",
- cpufreq_applet_help_cb),
- BONOBO_UI_UNSAFE_VERB ("CPUFreqAppletAbout",
- cpufreq_applet_about_cb),
- BONOBO_UI_VERB_END
+static const GtkActionEntry cpufreq_applet_menu_actions[] = {
+ { "CPUFreqAppletPreferences", GTK_STOCK_PROPERTIES, N_("_Preferences"),
+ NULL, NULL,
+ G_CALLBACK (cpufreq_applet_preferences_cb) },
+ { "CPUFreqAppletHelp", GTK_STOCK_HELP, N_("_Help"),
+ NULL, NULL,
+ G_CALLBACK (cpufreq_applet_help_cb) },
+ { "CPUFreqAppletAbout", GTK_STOCK_ABOUT, N_("_About"),
+ NULL, NULL,
+ G_CALLBACK (cpufreq_applet_about_cb) }
};
G_DEFINE_TYPE (CPUFreqApplet, cpufreq_applet, PANEL_TYPE_APPLET)
@@ -560,18 +559,16 @@ cpufreq_applet_change_orient (PanelApplet *pa, PanelAppletOrient orient)
}
static void
-cpufreq_applet_preferences_cb (BonoboUIComponent *uic,
- CPUFreqApplet *applet,
- const gchar *cname)
+cpufreq_applet_preferences_cb (GtkAction *action,
+ CPUFreqApplet *applet)
{
cpufreq_preferences_dialog_run (applet->prefs,
gtk_widget_get_screen (GTK_WIDGET (applet)));
}
static void
-cpufreq_applet_help_cb (BonoboUIComponent *uic,
- CPUFreqApplet *applet,
- const gchar *cname)
+cpufreq_applet_help_cb (GtkAction *action,
+ CPUFreqApplet *applet)
{
GError *error = NULL;
@@ -588,9 +585,8 @@ cpufreq_applet_help_cb (BonoboUIComponent *uic,
}
static void
-cpufreq_applet_about_cb (BonoboUIComponent *uic,
- CPUFreqApplet *applet,
- const gchar *cname)
+cpufreq_applet_about_cb (GtkAction *action,
+ CPUFreqApplet *applet)
{
static const gchar *const authors[] = {
"Carlos Garcia Campos <carlosgc gnome org>",
@@ -942,9 +938,10 @@ cpufreq_applet_prefs_show_mode_changed (CPUFreqPrefs *prefs,
static void
cpufreq_applet_setup (CPUFreqApplet *applet)
{
- BonoboUIComponent *popup_component;
- AtkObject *atk_obj;
- gchar *prefs_key;
+ GtkActionGroup *action_group;
+ gchar *ui_path;
+ AtkObject *atk_obj;
+ gchar *prefs_key;
g_set_application_name (_("CPU Frequency Scaling Monitor"));
@@ -983,21 +980,24 @@ cpufreq_applet_setup (CPUFreqApplet *applet)
(gpointer) applet);
/* Setup the menus */
+ action_group = gtk_action_group_new ("CPUFreq Applet Actions");
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (action_group,
+ cpufreq_applet_menu_actions,
+ G_N_ELEMENTS (cpufreq_applet_menu_actions),
+ applet);
+ ui_path = g_build_filename (CPUFREQ_MENU_UI_DIR, "cpufreq-applet-menu.xml", NULL);
panel_applet_setup_menu_from_file (PANEL_APPLET (applet),
- DATADIR,
- "GNOME_CPUFreqApplet.xml",
- NULL,
- cpufreq_applet_menu_verbs,
- applet);
+ ui_path, action_group);
+ g_free (ui_path);
if (panel_applet_get_locked_down (PANEL_APPLET (applet))) {
- popup_component = panel_applet_get_popup_component (PANEL_APPLET (applet));
-
- bonobo_ui_component_set_prop (popup_component,
- "/commands/CPUFreqPreferences",
- "hidden", "1",
- NULL);
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (action_group, "CPUFreqPreferences");
+ gtk_action_set_visible (action, FALSE);
}
+ g_object_unref (action_group);
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (applet));
@@ -1016,7 +1016,7 @@ cpufreq_applet_factory (CPUFreqApplet *applet, const gchar *iid, gpointer gdata)
{
gboolean retval = FALSE;
- if (!strcmp (iid, "OAFIID:GNOME_CPUFreqApplet")) {
+ if (!strcmp (iid, "CPUFreqApplet")) {
cpufreq_applet_setup (applet);
retval = TRUE;
@@ -1025,9 +1025,8 @@ cpufreq_applet_factory (CPUFreqApplet *applet, const gchar *iid, gpointer gdata)
return retval;
}
-PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_CPUFreqApplet_Factory",
- CPUFREQ_TYPE_APPLET,
- "cpufreq-applet",
- "0",
- (PanelAppletFactoryCallback) cpufreq_applet_factory,
- NULL)
+PANEL_APPLET_OUT_PROCESS_FACTORY ("CPUFreqAppletFactory",
+ CPUFREQ_TYPE_APPLET,
+ "cpufreq-applet",
+ (PanelAppletFactoryCallback) cpufreq_applet_factory,
+ NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]