[gnome-applets] [gweather] Port to new libpanel-applet API
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets] [gweather] Port to new libpanel-applet API
- Date: Wed, 18 Aug 2010 14:39:25 +0000 (UTC)
commit 445b1ebba673fbc8d4943829c4607c41613cde5e
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Mon Feb 22 15:19:51 2010 +0100
[gweather] Port to new libpanel-applet API
gweather/GNOME_GWeatherApplet.xml | 16 ----
gweather/GNOME_GWeatherApplet_Factory.server.in.in | 36 --------
gweather/Makefile.am | 49 +++++++----
gweather/gweather-applet-menu.xml | 7 ++
gweather/gweather-applet.c | 86 +++++++++++---------
gweather/gweather.h | 1 +
gweather/main.c | 11 +--
...gnome.applets.GWeatherApplet.panel-applet.in.in | 16 ++++
...e.panel.applet.GWeatherAppletFactory.service.in | 3 +
9 files changed, 109 insertions(+), 116 deletions(-)
---
diff --git a/gweather/Makefile.am b/gweather/Makefile.am
index 9eba0b3..ea6ac96 100644
--- a/gweather/Makefile.am
+++ b/gweather/Makefile.am
@@ -2,13 +2,13 @@
SUBDIRS = docs
-INCLUDES = \
- -I$(srcdir) \
- -I$(top_srcdir) \
- $(GNOME_APPLETS_CFLAGS) \
- $(GNOME_LIBS2_CFLAGS) \
- $(LIBNOTIFY_CFLAGS) \
- $(LIBGWEATHER_CFLAGS) \
+INCLUDES = \
+ -I$(srcdir) \
+ -I$(top_srcdir) \
+ -DGWEATHER_MENU_UI_DIR=\""$(uidir)"\" \
+ $(GNOME_APPLETS3_CFLAGS) \
+ $(LIBNOTIFY_CFLAGS) \
+ $(LIBGWEATHER_CFLAGS) \
$(NETWORKMANAGER_CFLAGS)
libexec_PROGRAMS = gweather-applet-2
@@ -23,27 +23,40 @@ gweather_applet_2_SOURCES = \
gweather_applet_2_LDADD = \
$(LIBNOTIFY_LIBS) \
- $(GNOME_APPLETS_LIBS) \
+ $(GNOME_APPLETS3_LIBS) \
$(GNOME_LIBS2_LIBS) \
$(LIBGWEATHER_LIBS) \
$(NETWORKMANAGER_LIBS)
uidir = $(datadir)/gnome-2.0/ui
-ui_DATA = GNOME_GWeatherApplet.xml
+ui_DATA = gweather-applet-menu.xml
-serverdir = $(libdir)/bonobo/servers
-server_in_files = GNOME_GWeatherApplet_Factory.server.in
-server_DATA = $(server_in_files:.server.in=.server)
+appletdir = $(datadir)/gnome-panel/applets
+applet_in_files = org.gnome.applets.GWeatherApplet.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)
+%.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.GWeatherAppletFactory.service.in
+service_DATA = $(service_in_files:.service.in=.service)
+
+org.gnome.panel.applet.GWeatherAppletFactory.service: $(service_in_files)
+ $(AM_V_GEN)sed \
+ -e "s|\ LIBEXECDIR\@|$(libexecdir)|" \
+ $< > $@
+
+CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA)
EXTRA_DIST = \
- GNOME_GWeatherApplet_Factory.server.in.in \
+ org.gnome.applets.GWeatherApplet.panel-applet.in.in \
+ $(service_in_files) \
$(ui_DATA)
- INTLTOOL_SERVER_RULE@
-
-include $(top_srcdir)/git.mk
diff --git a/gweather/gweather-applet-menu.xml b/gweather/gweather-applet-menu.xml
new file mode 100644
index 0000000..8fc0a35
--- /dev/null
+++ b/gweather/gweather-applet-menu.xml
@@ -0,0 +1,7 @@
+<menuitem name="Item 1" action="Details" />
+<menuitem name="Item 2" action="Update" />
+<separator/>
+<menuitem name="Item 3" action="Props" />
+<menuitem name="Item 4" action="Help" />
+<menuitem name="Item 5" action="About" />
+
diff --git a/gweather/gweather-applet.c b/gweather/gweather-applet.c
index 09044ca..3768ded 100644
--- a/gweather/gweather-applet.c
+++ b/gweather/gweather-applet.c
@@ -48,17 +48,15 @@
#define MAX_CONSECUTIVE_FAULTS (3)
-static void about_cb (BonoboUIComponent *uic,
- GWeatherApplet *gw_applet,
- const gchar *verbname)
+static void about_cb (GtkAction *action,
+ GWeatherApplet *gw_applet)
{
gweather_about_run (gw_applet);
}
-static void help_cb (BonoboUIComponent *uic,
- GWeatherApplet *gw_applet,
- const gchar *verbname)
+static void help_cb (GtkAction *action,
+ GWeatherApplet *gw_applet)
{
GError *error = NULL;
@@ -79,9 +77,8 @@ static void help_cb (BonoboUIComponent *uic,
}
}
-static void pref_cb (BonoboUIComponent *uic,
- GWeatherApplet *gw_applet,
- const gchar *verbname)
+static void pref_cb (GtkAction *action,
+ GWeatherApplet *gw_applet)
{
if (gw_applet->pref_dialog) {
gtk_window_present (GTK_WINDOW (gw_applet->pref_dialog));
@@ -93,9 +90,8 @@ static void pref_cb (BonoboUIComponent *uic,
}
}
-static void details_cb (BonoboUIComponent *uic,
- GWeatherApplet *gw_applet,
- const gchar *verbname)
+static void details_cb (GtkAction *action,
+ GWeatherApplet *gw_applet)
{
if (gw_applet->details_dialog) {
gtk_window_present (GTK_WINDOW (gw_applet->details_dialog));
@@ -108,22 +104,29 @@ static void details_cb (BonoboUIComponent *uic,
}
}
-static void update_cb (BonoboUIComponent *uic,
- GWeatherApplet *gw_applet,
- const gchar *verbname)
+static void update_cb (GtkAction *action,
+ GWeatherApplet *gw_applet)
{
gweather_update (gw_applet);
}
-static const BonoboUIVerb weather_applet_menu_verbs [] = {
- BONOBO_UI_UNSAFE_VERB ("Details", details_cb),
- BONOBO_UI_UNSAFE_VERB ("Update", update_cb),
- BONOBO_UI_UNSAFE_VERB ("Props", pref_cb),
- BONOBO_UI_UNSAFE_VERB ("Help", help_cb),
- BONOBO_UI_UNSAFE_VERB ("About", about_cb),
-
- BONOBO_UI_VERB_END
+static const GtkActionEntry weather_applet_menu_actions [] = {
+ { "Details", NULL, N_("_Details"),
+ NULL, NULL,
+ G_CALLBACK (details_cb) },
+ { "Update", GTK_STOCK_REFRESH, N_("_Update"),
+ NULL, NULL,
+ G_CALLBACK (update_cb) },
+ { "Props", GTK_STOCK_PROPERTIES, N_("_Preferences"),
+ NULL, NULL,
+ G_CALLBACK (pref_cb) },
+ { "Help", GTK_STOCK_HELP, N_("_Help"),
+ NULL, NULL,
+ G_CALLBACK (help_cb) },
+ { "About", GTK_STOCK_ABOUT, N_("_About"),
+ NULL, NULL,
+ G_CALLBACK (about_cb) }
};
static void place_widgets (GWeatherApplet *gw_applet)
@@ -230,7 +233,7 @@ static gboolean clicked_cb (GtkWidget *widget, GdkEventButton *ev, gpointer data
if (ev->type == GDK_BUTTON_PRESS) {
if (!gw_applet->details_dialog)
- details_cb (NULL, gw_applet, NULL);
+ details_cb (NULL, gw_applet);
else
gtk_widget_destroy (GTK_WIDGET (gw_applet->details_dialog));
@@ -252,7 +255,7 @@ key_press_cb (GtkWidget *widget, GdkEventKey *event, GWeatherApplet *gw_applet)
break;
case GDK_d:
if (event->state == GDK_CONTROL_MASK) {
- details_cb (NULL, gw_applet, NULL);
+ details_cb (NULL, gw_applet);
return TRUE;
}
break;
@@ -262,7 +265,7 @@ key_press_cb (GtkWidget *widget, GdkEventKey *event, GWeatherApplet *gw_applet)
case GDK_Return:
case GDK_space:
case GDK_KP_Space:
- details_cb (NULL, gw_applet, NULL);
+ details_cb (NULL, gw_applet);
return TRUE;
default:
break;
@@ -304,7 +307,9 @@ static void setup_network_monitor (GWeatherApplet *gw_applet);
void gweather_applet_create (GWeatherApplet *gw_applet)
{
- AtkObject *atk_obj;
+ GtkActionGroup *action_group;
+ gchar *ui_path;
+ AtkObject *atk_obj;
gw_applet->gweather_pref.location = NULL;
gw_applet->gweather_pref.update_interval = 1800;
@@ -348,24 +353,25 @@ void gweather_applet_create (GWeatherApplet *gw_applet)
gw_applet->size = panel_applet_get_size (gw_applet->applet);
gw_applet->orient = panel_applet_get_orient (gw_applet->applet);
-
+
+ action_group = gtk_action_group_new ("GWeather Applet Actions");
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (action_group,
+ weather_applet_menu_actions,
+ G_N_ELEMENTS (weather_applet_menu_actions),
+ gw_applet);
+ ui_path = g_build_filename (GWEATHER_MENU_UI_DIR, "gweather-applet-menu.xml", NULL);
panel_applet_setup_menu_from_file (gw_applet->applet,
- DATADIR,
- "GNOME_GWeatherApplet.xml",
- NULL,
- weather_applet_menu_verbs,
- gw_applet);
+ ui_path, action_group);
+ g_free (ui_path);
if (panel_applet_get_locked_down (gw_applet->applet)) {
- BonoboUIComponent *popup_component;
-
- popup_component = panel_applet_get_popup_component (gw_applet->applet);
+ GtkAction *action;
- bonobo_ui_component_set_prop (popup_component,
- "/commands/Props",
- "hidden", "1",
- NULL);
+ action = gtk_action_group_get_action (action_group, "Props");
+ gtk_action_set_visible (action, FALSE);
}
+ g_object_unref (action_group);
place_widgets(gw_applet);
diff --git a/gweather/gweather.h b/gweather/gweather.h
index 69c7a5c..db4f8f8 100644
--- a/gweather/gweather.h
+++ b/gweather/gweather.h
@@ -10,6 +10,7 @@
* main header file
*
*/
+#include <glib/gi18n.h>
#include <panel-applet.h>
diff --git a/gweather/main.c b/gweather/main.c
index 74bfa01..1ec177a 100644
--- a/gweather/main.c
+++ b/gweather/main.c
@@ -62,9 +62,8 @@ gweather_applet_factory(PanelApplet *applet,
return retval;
}
-PANEL_APPLET_BONOBO_FACTORY("OAFIID:GNOME_GWeatherApplet_Factory",
- PANEL_TYPE_APPLET,
- "gweather",
- "0",
- gweather_applet_factory,
- NULL);
+PANEL_APPLET_OUT_PROCESS_FACTORY ("GWeatherAppletFactory",
+ PANEL_TYPE_APPLET,
+ "gweather",
+ gweather_applet_factory,
+ NULL)
diff --git a/gweather/org.gnome.applets.GWeatherApplet.panel-applet.in.in b/gweather/org.gnome.applets.GWeatherApplet.panel-applet.in.in
new file mode 100644
index 0000000..5b24954
--- /dev/null
+++ b/gweather/org.gnome.applets.GWeatherApplet.panel-applet.in.in
@@ -0,0 +1,16 @@
+[Applet Factory]
+Id=GWeatherAppletFactory
+Location= LIBEXECDIR@/gweather-applet-2
+_Name=Gweather Applet Factory
+_Description=Factory for creating the weather applet.
+
+[GWeatherApplet]
+_Name=Weather Report
+_Description=Monitor the current weather conditions, and forecasts
+Icon=weather-storm
+BonoboId=OAFIID:GNOME_GWeatherApplet
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=gnome-applets
+X-GNOME-Bugzilla-Component=gweather
+X-GNOME-Bugzilla-Version= VERSION@
+X-GNOME-Bugzilla-OtherBinaries=gweather-applet-2
diff --git a/gweather/org.gnome.panel.applet.GWeatherAppletFactory.service.in b/gweather/org.gnome.panel.applet.GWeatherAppletFactory.service.in
new file mode 100644
index 0000000..d5b0c7c
--- /dev/null
+++ b/gweather/org.gnome.panel.applet.GWeatherAppletFactory.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.panel.applet.GWeatherAppletFactory
+Exec= LIBEXECDIR@/gweather-applet-2
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]