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



commit 96691bc4a604688d419f64bbf3e119c438d6c9f7
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Tue Feb 23 09:49:31 2010 +0100

    [drivemount] Port to new libpanel-applet API

 drivemount/GNOME_DriveMountApplet.server.in.in     |   28 -----------
 drivemount/GNOME_DriveMountApplet.xml              |   10 ----
 drivemount/Makefile.am                             |   49 ++++++++++++-------
 drivemount/drivemount-applet-menu.xml              |    3 +
 drivemount/drivemount.c                            |   51 ++++++++++++--------
 ...ome.applets.DriveMountApplet.panel-applet.in.in |   16 ++++++
 ...panel.applet.DriveMountAppletFactory.service.in |    3 +
 7 files changed, 83 insertions(+), 77 deletions(-)
---
diff --git a/drivemount/Makefile.am b/drivemount/Makefile.am
index 791db7a..91ddc40 100644
--- a/drivemount/Makefile.am
+++ b/drivemount/Makefile.am
@@ -1,10 +1,10 @@
 SUBDIRS = help
 
-INCLUDES =			\
-	-I.			\
-	-I$(srcdir)		\
-	$(GNOME_APPLETS_CFLAGS)	\
-	$(GNOME_LIBS2_CFLAGS)
+INCLUDES =					\
+	-I.					\
+	-I$(srcdir)				\
+	-DDRIVEMOUNT_MENU_UI_DIR=\""$(uidir)"\"	\
+	$(GNOME_APPLETS3_CFLAGS)
 
 libexec_PROGRAMS = drivemount_applet2
 
@@ -16,22 +16,32 @@ drivemount_applet2_SOURCES =	\
 	drive-button.h
 
 drivemount_applet2_LDADD =	\
-	$(GNOME_APPLETS_LIBS)	\
-	$(GNOME_LIBS2_LIBS)
+	$(GNOME_APPLETS3_LIBS)
 
-serverdir       = $(libdir)/bonobo/servers
-server_in_files = GNOME_DriveMountApplet.server.in
-server_DATA     = $(server_in_files:.server.in=.server)
 
-$(server_in_files): $(server_in_files:.server.in=.server.in.in)
-	sed -e "s|\ LIBEXECDIR\@|$(libexecdir)|" $< > $@
+appletdir       = $(datadir)/gnome-panel/applets
+applet_in_files = org.gnome.applets.DriveMountApplet.panel-applet.in
+applet_DATA     = $(applet_in_files:.panel-applet.in=.panel-applet)
 
-CLEANFILES = $(server_in_files) $(server_DATA) $(schemas_DATA)
+$(applet_in_files): $(applet_in_files).in Makefile
+	$(AM_V_GEN)sed \
+            -e "s|\ LIBEXECDIR\@|$(libexecdir)|" \
+            -e "s|\ VERSION\@|$(PACKAGE_VERSION)|" \
+            $< > $@
 
-uidir = $(datadir)/gnome-2.0/ui
-ui_DATA = GNOME_DriveMountApplet.xml
+%.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.DriveMountAppletFactory.service.in
+service_DATA     = $(service_in_files:.service.in=.service)
 
- INTLTOOL_SERVER_RULE@
+org.gnome.panel.applet.DriveMountAppletFactory.service: $(service_in_files)
+	$(AM_V_GEN)sed \
+            -e "s|\ LIBEXECDIR\@|$(libexecdir)|" \
+            $< > $@
+
+uidir = $(datadir)/gnome-2.0/ui
+ui_DATA = drivemount-applet-menu.xml
 
 schemasdir   = $(GCONF_SCHEMA_FILE_DIR)
 schemas_in_files = drivemount.schemas.in
@@ -39,9 +49,12 @@ schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
 
 @INTLTOOL_SCHEMAS_RULE@
 
+CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA)
+
 EXTRA_DIST = \
- GNOME_DriveMountApplet.server.in.in	\
- $(schemas_in_files)			\
+ org.gnome.applets.DriveMountApplet.panel-applet.in.in	\
+ $(service_in_files)					\
+ $(schemas_in_files)					\
  $(ui_DATA)
 
 if GCONF_SCHEMAS_INSTALL
diff --git a/drivemount/drivemount-applet-menu.xml b/drivemount/drivemount-applet-menu.xml
new file mode 100644
index 0000000..efc2659
--- /dev/null
+++ b/drivemount/drivemount-applet-menu.xml
@@ -0,0 +1,3 @@
+<menuitem name="Help" action="Help" />
+<menuitem name="About" action="About" />
+
diff --git a/drivemount/drivemount.c b/drivemount/drivemount.c
index f311076..baba9f8 100644
--- a/drivemount/drivemount.c
+++ b/drivemount/drivemount.c
@@ -26,13 +26,14 @@
 
 #include <string.h>
 
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <panel-applet.h>
 
 #include "drive-list.h"
 
-static const char drivemount_iid[] = "OAFIID:GNOME_DriveMountApplet";
-static const char factory_iid[] = "OAFIID:GNOME_DriveMountApplet_Factory";
+static const char drivemount_iid[] = "DriveMountApplet";
+static const char factory_iid[] = "DriveMountAppletFactory";
 
 static void
 change_orient (PanelApplet *applet, PanelAppletOrient o, DriveList *drive_list)
@@ -94,9 +95,8 @@ change_background (PanelApplet               *applet,
 }
 
 static void
-display_about_dialog (BonoboUIComponent *uic,
-		      DriveList *drive_list,
-		      const gchar *verbname)
+display_about_dialog (GtkAction *action,
+		      DriveList *drive_list)
 {
     const gchar *authors[] = {
 	"James Henstridge <jamesh canonical com>",
@@ -120,9 +120,8 @@ display_about_dialog (BonoboUIComponent *uic,
 }
 
 static void
-display_help (BonoboUIComponent *uic,
-	      DriveList *drive_list,
-	      const gchar *verbname)
+display_help (GtkAction *action,
+	      DriveList *drive_list)
 {
     GdkScreen *screen;
     GError *error = NULL;
@@ -150,10 +149,13 @@ display_help (BonoboUIComponent *uic,
     }
 }
 
-static const BonoboUIVerb applet_menu_verbs[] = {
-    BONOBO_UI_UNSAFE_VERB ("About", display_about_dialog),
-    BONOBO_UI_UNSAFE_VERB ("Help",  display_help),
-    BONOBO_UI_VERB_END
+static const GtkActionEntry applet_menu_actions[] = {
+    { "Help", GTK_STOCK_HELP, N_("_Help"),
+      NULL, NULL,
+      G_CALLBACK (display_help) },
+    { "About", GTK_STOCK_ABOUT, N_("_About"),
+      NULL, NULL,
+      G_CALLBACK (display_about_dialog) }
 };
 
 static gboolean
@@ -164,6 +166,8 @@ applet_factory (PanelApplet *applet,
     gboolean ret = FALSE;
     GtkWidget *drive_list;
     AtkObject *ao;
+    GtkActionGroup *action_group;
+    gchar *ui_path;
 
     if (!strcmp (iid, drivemount_iid)) {
 	g_set_application_name (_("Disk Mounter"));
@@ -191,11 +195,16 @@ applet_factory (PanelApplet *applet,
 		       panel_applet_get_orient (applet),
 		       DRIVE_LIST (drive_list));
 
-	panel_applet_setup_menu_from_file (applet,
-					   DATADIR,
-					   "GNOME_DriveMountApplet.xml",
-					   NULL, applet_menu_verbs,
-					   drive_list);
+	action_group = gtk_action_group_new ("DriveMount Applet Actions");
+	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+	gtk_action_group_add_actions (action_group,
+				      applet_menu_actions,
+				      G_N_ELEMENTS (applet_menu_actions),
+				      drive_list);
+	ui_path = g_build_filename (DRIVEMOUNT_MENU_UI_DIR, "drivemount-applet-menu.xml", NULL);
+	panel_applet_setup_menu_from_file (applet, ui_path, action_group);
+	g_free (ui_path);
+	g_object_unref (action_group);
 
 	ao = gtk_widget_get_accessible (GTK_WIDGET (applet));
 	atk_object_set_name (ao, _("Disk Mounter"));
@@ -208,7 +217,7 @@ applet_factory (PanelApplet *applet,
     return ret;
 }
 
-PANEL_APPLET_BONOBO_FACTORY (factory_iid,
-			     PANEL_TYPE_APPLET,
-			     "Drive-Mount-Applet", "0",
-			     applet_factory, NULL)
+PANEL_APPLET_OUT_PROCESS_FACTORY (factory_iid,
+				  PANEL_TYPE_APPLET,
+				  "Drive-Mount-Applet",
+				  applet_factory, NULL)
diff --git a/drivemount/org.gnome.applets.DriveMountApplet.panel-applet.in.in b/drivemount/org.gnome.applets.DriveMountApplet.panel-applet.in.in
new file mode 100644
index 0000000..ec90444
--- /dev/null
+++ b/drivemount/org.gnome.applets.DriveMountApplet.panel-applet.in.in
@@ -0,0 +1,16 @@
+[Applet Factory]
+Id=DriveMountAppletFactory
+Location= LIBEXECDIR@/drivemount_applet2
+_Name=Drive Mount Applet Factory
+_Description=Factory for drive mount applet
+
+[DriveMountApplet]
+_Name=Disk Mounter
+_Description=Mount local disks and devices
+Icon=media-floppy
+BonoboId=OAFIID:GNOME_DriveMountApplet
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=gnome-applets
+X-GNOME-Bugzilla-Component=Disk Mounter (drivemount)
+X-GNOME-Bugzilla-Version= VERSION@
+X-GNOME-Bugzilla-OtherBinaries=drivemount_applet2
diff --git a/drivemount/org.gnome.panel.applet.DriveMountAppletFactory.service.in b/drivemount/org.gnome.panel.applet.DriveMountAppletFactory.service.in
new file mode 100644
index 0000000..617b63d
--- /dev/null
+++ b/drivemount/org.gnome.panel.applet.DriveMountAppletFactory.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.panel.applet.DriveMountAppletFactory
+Exec= LIBEXECDIR@/drivemount_applet2



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