[gnome-applets] [geyes] Port to new libpanel-applet API



commit 149a3570f0228503ce3ed01a79db1b6f25855e8e
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Thu May 27 13:57:10 2010 +0200

    [geyes] Port to new libpanel-applet API

 geyes/GNOME_GeyesApplet.server.in.in               |   36 ----------
 geyes/GNOME_GeyesApplet.xml                        |   13 ----
 geyes/Makefile.am                                  |   48 +++++++++-----
 geyes/geyes-applet-menu.xml                        |    5 ++
 geyes/geyes.c                                      |   68 ++++++++++---------
 geyes/geyes.h                                      |    6 +-
 ...rg.gnome.applets.GeyesApplet.panel-applet.in.in |   16 +++++
 geyes/themes.c                                     |    5 +-
 8 files changed, 92 insertions(+), 105 deletions(-)
---
diff --git a/geyes/Makefile.am b/geyes/Makefile.am
index 2303b24..7668b4c 100644
--- a/geyes/Makefile.am
+++ b/geyes/Makefile.am
@@ -3,10 +3,10 @@ SUBDIRS = themes docs
 INCLUDES =						\
 	-I.						\
 	-I$(srcdir) 					\
-	$(GNOME_APPLETS_CFLAGS)				\
-	$(GNOME_LIBS2_CFLAGS)				\
+	$(GNOME_APPLETS3_CFLAGS)			\
 	-I$(includedir) 				\
-	-DGEYES_THEMES_DIR=\""$(pkgdatadir)/geyes/"\"
+	-DGEYES_THEMES_DIR=\""$(pkgdatadir)/geyes/"\"	\
+	-DGEYES_MENU_UI_DIR=\""$(uidir)"\"
 
 libexec_PROGRAMS = geyes_applet2
 
@@ -16,20 +16,33 @@ geyes_applet2_SOURCES =	\
 	geyes.h
 
 geyes_applet2_LDADD = 		\
-	$(GNOME_APPLETS_LIBS)	\
-	$(GNOME_LIBS2_LIBS)
+	$(GNOME_APPLETS3_LIBS)
 
-serverdir       = $(libdir)/bonobo/servers
-server_in_files = GNOME_GeyesApplet.server.in
-server_DATA     = $(server_in_files:.server.in=.server)
+appletdir       = $(datadir)/gnome-panel/applets
+applet_in_files = org.gnome.applets.GeyesApplet.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
+
+servicedir       = $(datadir)/dbus-1/services
+service_in_files = org.gnome.panel.applet.GeyesAppletFactory.service.in
+service_DATA     = $(service_in_files:.service.in=.service)
+
+org.gnome.panel.applet.GeyesAppletFactory.service: $(service_in_files)
+	$(AM_V_GEN)sed \
+            -e "s|\ LIBEXECDIR\@|$(libexecdir)|" \
+            $< > $@
+
+CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA) $(schemas_DATA)
 
 uidir = $(datadir)/gnome-2.0/ui
-ui_DATA = GNOME_GeyesApplet.xml
+ui_DATA = geyes-applet-menu.xml
 
 schemasdir   = @GCONF_SCHEMA_FILE_DIR@
 schemas_in_files = geyes.schemas.in
@@ -37,8 +50,6 @@ schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
 
 @INTLTOOL_SCHEMAS_RULE@
 
- INTLTOOL_SERVER_RULE@
-
 themesdir = $(pkgdatadir)/geyes
 
 icons =	\
@@ -49,10 +60,11 @@ icons =	\
 	gnome-eyes-applet.16.png
 
 EXTRA_DIST = \
-	     README.themes			\
-	     GNOME_GeyesApplet.server.in.in	\
-	     $(schemas_in_files)		\
-	     $(ui_DATA)				\
+	     README.themes					\
+	     org.gnome.applets.GeyesApplet.panel-applet.in.in 	\
+             $(service_in_files)				\
+	     $(schemas_in_files)				\
+	     $(ui_DATA)						\
 	     $(icons)
 
 gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
diff --git a/geyes/geyes-applet-menu.xml b/geyes/geyes-applet-menu.xml
new file mode 100644
index 0000000..860052a
--- /dev/null
+++ b/geyes/geyes-applet-menu.xml
@@ -0,0 +1,5 @@
+<menuitem name="Item 1" action="Props" />
+<menuitem name="Item 2" action="Help" />
+<menuitem name="Item 3" action="About" />
+
+
diff --git a/geyes/geyes.c b/geyes/geyes.c
index 8114bce..e5d65bd 100644
--- a/geyes/geyes.c
+++ b/geyes/geyes.c
@@ -171,9 +171,8 @@ timer_cb (EyesApplet *eyes_applet)
 }
 
 static void
-about_cb (BonoboUIComponent *uic,
-	  EyesApplet        *eyes_applet,
-	  const gchar       *verbname)
+about_cb (GtkAction   *action,
+	  EyesApplet  *eyes_applet)
 {
         static const gchar *authors [] = {
 		"Dave Camp <campd oit edu>",
@@ -332,9 +331,8 @@ destroy_cb (GtkObject *object, EyesApplet *eyes_applet)
 }
 
 static void
-help_cb (BonoboUIComponent *uic,
-	 EyesApplet        *eyes_applet,
-	 const char        *verbname)
+help_cb (GtkAction  *action,
+	 EyesApplet *eyes_applet)
 {
 	GError *error = NULL;
 
@@ -356,12 +354,16 @@ help_cb (BonoboUIComponent *uic,
 }
 
 
-static const BonoboUIVerb geyes_applet_menu_verbs [] = {
-        BONOBO_UI_UNSAFE_VERB ("Props", properties_cb),
-        BONOBO_UI_UNSAFE_VERB ("Help", help_cb),
-        BONOBO_UI_UNSAFE_VERB ("About", about_cb),
-
-        BONOBO_UI_VERB_END
+static const GtkActionEntry geyes_applet_menu_actions [] = {
+	{ "Props", GTK_STOCK_PROPERTIES, N_("_Preferences"),
+	  NULL, NULL,
+	  G_CALLBACK (properties_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
@@ -383,6 +385,8 @@ static gboolean
 geyes_applet_fill (PanelApplet *applet)
 {
 	EyesApplet *eyes_applet;
+	GtkActionGroup *action_group;
+	gchar *ui_path;
 
 	g_set_application_name (_("Eyes"));
 	
@@ -395,24 +399,25 @@ geyes_applet_fill (PanelApplet *applet)
 
         eyes_applet->timeout_id = g_timeout_add (
 		UPDATE_TIMEOUT, (GtkFunction) timer_cb, eyes_applet);
-			
+
+	action_group = gtk_action_group_new ("Geyes Applet Actions");
+	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+	gtk_action_group_add_actions (action_group,
+				      geyes_applet_menu_actions,
+				      G_N_ELEMENTS (geyes_applet_menu_actions),
+				      eyes_applet);
+	ui_path = g_build_filename (GEYES_MENU_UI_DIR, "geyes-applet-menu.xml", NULL);
 	panel_applet_setup_menu_from_file (eyes_applet->applet,
-                                           DATADIR,
-				           "GNOME_GeyesApplet.xml",
-                                           NULL,
-				           geyes_applet_menu_verbs,
-				           eyes_applet);
+					   ui_path, action_group);
+	g_free (ui_path);
 
 	if (panel_applet_get_locked_down (eyes_applet->applet)) {
-		BonoboUIComponent *popup_component;
-
-		popup_component = panel_applet_get_popup_component (eyes_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);
 
 	gtk_widget_set_tooltip_text (GTK_WIDGET (eyes_applet->applet), _("Eyes"));
 
@@ -450,7 +455,7 @@ geyes_applet_factory (PanelApplet *applet,
 
 	theme_dirs_create ();
 
-	if (!strcmp (iid, "OAFIID:GNOME_GeyesApplet"))
+	if (!strcmp (iid, "GeyesApplet"))
 		retval = geyes_applet_fill (applet); 
    
 	if (retval == FALSE) {
@@ -460,9 +465,8 @@ geyes_applet_factory (PanelApplet *applet,
 	return retval;
 }
 
-PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_GeyesApplet_Factory",
-			     PANEL_TYPE_APPLET,
-			     "geyes",
-			     "0",
-			     geyes_applet_factory,
-			     NULL)
+PANEL_APPLET_OUT_PROCESS_FACTORY ("GeyesAppletFactory",
+				  PANEL_TYPE_APPLET,
+				  "geyes",
+				  geyes_applet_factory,
+				  NULL)
diff --git a/geyes/geyes.h b/geyes/geyes.h
index 7adac13..8f12d9d 100644
--- a/geyes/geyes.h
+++ b/geyes/geyes.h
@@ -21,6 +21,7 @@
 #define __GEYES_H__
 
 #include <glib.h>
+#include <glib/gi18n.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <gtk/gtk.h>
 #include <panel-applet.h>
@@ -74,8 +75,7 @@ void theme_dirs_create (void);
 int load_theme    (EyesApplet        *eyes_applet,
 		   const gchar       *theme_dir);
 
-void properties_cb (BonoboUIComponent *uic,
-		    EyesApplet        *eyes_applet,
-		    const gchar       *verbname);
+void properties_cb (GtkAction         *action,
+		    EyesApplet        *eyes_applet);
 
 #endif
diff --git a/geyes/org.gnome.applets.GeyesApplet.panel-applet.in.in b/geyes/org.gnome.applets.GeyesApplet.panel-applet.in.in
new file mode 100644
index 0000000..9beb6f5
--- /dev/null
+++ b/geyes/org.gnome.applets.GeyesApplet.panel-applet.in.in
@@ -0,0 +1,16 @@
+[Applet Factory]
+Id=GeyesAppletFactory
+Location= LIBEXECDIR@/geyes_applet2
+_Name=Geyes Applet Factory
+_Description=Geyes Applet Factory
+
+[GeyesApplet]
+_Name=Eyes
+_Description=A set of eyeballs for your panel
+Icon=gnome-eyes-applet
+BonoboId=OAFIID:GNOME_GeyesApplet
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=gnome-applets
+X-GNOME-Bugzilla-Component=geyes
+X-GNOME-Bugzilla-Version= VERSION@
+X-GNOME-Bugzilla-OtherBinaries=geyes_applet2
diff --git a/geyes/themes.c b/geyes/themes.c
index bc9eb5c..a265aa3 100644
--- a/geyes/themes.c
+++ b/geyes/themes.c
@@ -267,9 +267,8 @@ presponse_cb (GtkDialog *dialog, gint id, gpointer data)
 }
 
 void
-properties_cb (BonoboUIComponent *uic,
-	       EyesApplet        *eyes_applet,
-	       const gchar       *verbname)
+properties_cb (GtkAction  *action,
+	       EyesApplet *eyes_applet)
 {
 	GtkWidget *pbox, *hbox;
 	GtkWidget *vbox, *indent;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]