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



commit 07253b902e9591ca661651081ae8d637e8a76fd3
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Thu Feb 25 15:06:10 2010 +0100

    [trashapplet] Port to new libpanel-applet API

 trashapplet/GNOME_Panel_TrashApplet.server.in.in   |   36 -------
 trashapplet/GNOME_Panel_TrashApplet.xml            |   11 --
 trashapplet/Makefile.am                            |   31 +++++--
 ...rg.gnome.applets.TrashApplet.panel-applet.in.in |   16 +++
 ...nome.panel.applet.TrashAppletFactory.service.in |    3 +
 trashapplet/src/Makefile.am                        |    9 +-
 trashapplet/src/trashapplet.c                      |   97 +++++++++++---------
 trashapplet/trashapplet-menu.xml                   |    6 +
 8 files changed, 103 insertions(+), 106 deletions(-)
---
diff --git a/trashapplet/Makefile.am b/trashapplet/Makefile.am
index 8081d06..b47ff9c 100644
--- a/trashapplet/Makefile.am
+++ b/trashapplet/Makefile.am
@@ -1,24 +1,37 @@
 SUBDIRS = src docs
 
-serverdir = $(libdir)/bonobo/servers
-server_in_files = GNOME_Panel_TrashApplet.server.in
-server_DATA = $(server_in_files:.server.in=.server)
+appletdir       = $(datadir)/gnome-panel/applets
+applet_in_files = org.gnome.applets.TrashApplet.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)|" \
+            $< > $@
 
- 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.TrashAppletFactory.service.in
+service_DATA     = $(service_in_files:.service.in=.service)
+
+org.gnome.panel.applet.TrashAppletFactory.service: $(service_in_files)
+	$(AM_V_GEN)sed \
+            -e "s|\ LIBEXECDIR\@|$(libexecdir)|" \
+            $< > $@
 
 uidir = $(datadir)/gnome-2.0/ui
-ui_DATA = GNOME_Panel_TrashApplet.xml
+ui_DATA = trashapplet-menu.xml
 
 builder_DATA = trashapplet-empty-progress.ui
 
 EXTRA_DIST = \
 	$(ui_DATA) \
-	GNOME_Panel_TrashApplet.server.in.in \
+	org.gnome.applets.TrashApplet.panel-applet.in.in \
+	$(service_in_files) \
 	$(builder_DATA)
 
-CLEANFILES = $(server_in_files) $(server_DATA)
+CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA)
 
 -include $(top_srcdir)/git.mk
diff --git a/trashapplet/org.gnome.applets.TrashApplet.panel-applet.in.in b/trashapplet/org.gnome.applets.TrashApplet.panel-applet.in.in
new file mode 100644
index 0000000..6bb1a2d
--- /dev/null
+++ b/trashapplet/org.gnome.applets.TrashApplet.panel-applet.in.in
@@ -0,0 +1,16 @@
+[Applet Factory]
+Id=TrashAppletFactory
+Location= LIBEXECDIR@/trashapplet
+Name=Trash Applet Factory
+Description=Trash Applet Factory
+
+[TrashApplet]
+_Name=Trash
+_Description=Go to Trash
+Icon=user-trash-full
+BonoboId=OAFIID:GNOME_Panel_TrashApplet
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=gnome-applets
+X-GNOME-Bugzilla-Component=trash applet
+X-GNOME-Bugzilla-Version= VERSION@
+X-GNOME-Bugzilla-OtherBinaries=trashapplet
diff --git a/trashapplet/org.gnome.panel.applet.TrashAppletFactory.service.in b/trashapplet/org.gnome.panel.applet.TrashAppletFactory.service.in
new file mode 100644
index 0000000..82f19fd
--- /dev/null
+++ b/trashapplet/org.gnome.panel.applet.TrashAppletFactory.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.panel.applet.TrashAppletFactory
+Exec= LIBEXECDIR@/trashapplet
diff --git a/trashapplet/src/Makefile.am b/trashapplet/src/Makefile.am
index ae3182a..52da653 100644
--- a/trashapplet/src/Makefile.am
+++ b/trashapplet/src/Makefile.am
@@ -1,7 +1,7 @@
 INCLUDES = -I$(top_srcdir)		\
-	   $(GNOME_APPLETS_CFLAGS)	\
-	   $(GNOME_LIBS2_CFLAGS)	\
-	   $(GIO_CFLAGS)
+	   $(GNOME_APPLETS3_CFLAGS)	\
+	   $(GIO_CFLAGS)		\
+           -DTRASH_MENU_UI_DIR=\""$(datadir)/gnome-2.0/ui"\"
 
 libexec_PROGRAMS = trashapplet
 
@@ -13,8 +13,7 @@ trashapplet_SOURCES = \
 	xstuff.h
 
 trashapplet_LDADD = 		\
-	$(GNOME_APPLETS_LIBS) 	\
-	$(GNOME_LIBS2_LIBS)	\
+	$(GNOME_APPLETS3_LIBS) 	\
 	$(GIO_LIBS)
 
 -include $(top_srcdir)/git.mk
diff --git a/trashapplet/src/trashapplet.c b/trashapplet/src/trashapplet.c
index c8e615c..ed38423 100644
--- a/trashapplet/src/trashapplet.c
+++ b/trashapplet/src/trashapplet.c
@@ -27,6 +27,7 @@
 
 #include <string.h>
 
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
 #include <gconf/gconf-client.h>
@@ -55,25 +56,28 @@ G_DEFINE_TYPE (TrashApplet, trash_applet, PANEL_TYPE_APPLET);
 #define TRASH_APPLET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
                            TRASH_TYPE_APPLET, TrashApplet))
 
-static void trash_applet_do_empty    (BonoboUIComponent *component,
-                                      TrashApplet       *applet,
-                                      const gchar       *cname);
-static void trash_applet_show_about  (BonoboUIComponent *component,
-                                      TrashApplet       *applet,
-                                      const gchar       *cname);
-static void trash_applet_open_folder (BonoboUIComponent *component,
-                                      TrashApplet       *applet,
-                                      const gchar       *cname);
-static void trash_applet_show_help   (BonoboUIComponent *component,
-                                      TrashApplet       *applet,
-                                      const gchar       *cname);
-
-static const BonoboUIVerb trash_applet_menu_verbs [] = {
-  BONOBO_UI_UNSAFE_VERB ("EmptyTrash", trash_applet_do_empty),
-  BONOBO_UI_UNSAFE_VERB ("OpenTrash", trash_applet_open_folder),
-  BONOBO_UI_UNSAFE_VERB ("AboutTrash", trash_applet_show_about),
-  BONOBO_UI_UNSAFE_VERB ("HelpTrash", trash_applet_show_help),
-  BONOBO_UI_VERB_END
+static void trash_applet_do_empty    (GtkAction   *action,
+                                      TrashApplet *applet);
+static void trash_applet_show_about  (GtkAction   *action,
+                                      TrashApplet *applet);
+static void trash_applet_open_folder (GtkAction   *action,
+                                      TrashApplet *applet);
+static void trash_applet_show_help   (GtkAction   *action,
+                                      TrashApplet *applet);
+
+static const GtkActionEntry trash_applet_menu_actions [] = {
+	{ "EmptyTrash", GTK_STOCK_CLEAR, N_("_Empty Trash"),
+	  NULL, NULL,
+	  G_CALLBACK (trash_applet_do_empty) },
+	{ "OpenTrash", GTK_STOCK_OPEN, N_("_Open Trash"),
+	  NULL, NULL,
+	  G_CALLBACK (trash_applet_open_folder) },
+	{ "HelpTrash", GTK_STOCK_HELP, N_("_Help"),
+	  NULL, NULL,
+	  G_CALLBACK (trash_applet_show_help) },
+	{ "AboutTrash", GTK_STOCK_ABOUT, N_("_About"),
+	  NULL, NULL,
+	  G_CALLBACK (trash_applet_show_about) }
 };
 
 static void
@@ -256,7 +260,7 @@ trash_applet_button_release (GtkWidget      *widget,
       if (gconf_client_get_bool (client, PANEL_ENABLE_ANIMATIONS, NULL))
         xstuff_zoom_animate (widget, NULL);
 
-      trash_applet_open_folder (NULL, applet, NULL);
+      trash_applet_open_folder (NULL, applet);
 
       return TRUE;
     }
@@ -281,7 +285,7 @@ trash_applet_key_press (GtkWidget   *widget,
      case GDK_Return:
      case GDK_space:
      case GDK_KP_Space:
-      trash_applet_open_folder (NULL, applet, NULL);
+      trash_applet_open_folder (NULL, applet);
       return TRUE;
 
      default:
@@ -352,17 +356,15 @@ error_dialog (TrashApplet *applet, const gchar *error, ...)
 }
 
 static void
-trash_applet_do_empty (BonoboUIComponent *component,
-                       TrashApplet       *applet,
-                       const gchar       *cname)
+trash_applet_do_empty (GtkAction   *action,
+                       TrashApplet *applet)
 {
   trash_empty (GTK_WIDGET (applet));
 }
 
 static void
-trash_applet_open_folder (BonoboUIComponent *component,
-                          TrashApplet       *applet,
-                          const gchar       *cname)
+trash_applet_open_folder (GtkAction   *action,
+                          TrashApplet *applet)
 {
   GError *err = NULL;
 
@@ -380,9 +382,8 @@ trash_applet_open_folder (BonoboUIComponent *component,
 }
 
 static void
-trash_applet_show_help (BonoboUIComponent *component,
-                        TrashApplet       *applet,
-                        const gchar       *cname)
+trash_applet_show_help (GtkAction   *action,
+                        TrashApplet *applet)
 {
   GError *err = NULL;
 
@@ -403,9 +404,8 @@ trash_applet_show_help (BonoboUIComponent *component,
 
 
 static void
-trash_applet_show_about (BonoboUIComponent *component,
-                         TrashApplet       *applet,
-                         const gchar       *cname)
+trash_applet_show_about (GtkAction   *action,
+                         TrashApplet *applet)
 {
   static const char *authors[] = {
     "Michiel Sikkes <michiel eyesopened nl>",
@@ -609,19 +609,26 @@ trash_applet_factory (PanelApplet *applet,
 {
   gboolean retval = FALSE;
 
-  if (!strcmp (iid, "OAFIID:GNOME_Panel_TrashApplet"))
+  if (!strcmp (iid, "TrashApplet"))
     {
+      GtkActionGroup *action_group;
+      gchar          *ui_path;
+
       g_set_application_name (_("Trash Applet"));
 
       gtk_window_set_default_icon_name ("user-trash");
 
       /* Set up the menu */
-      panel_applet_setup_menu_from_file (applet,
-                                         DATADIR,
-                                         "GNOME_Panel_TrashApplet.xml",
-                                         NULL,
-                                         trash_applet_menu_verbs,
-                                         applet);
+      action_group = gtk_action_group_new ("Trash Applet Actions");
+      gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+      gtk_action_group_add_actions (action_group,
+				    trash_applet_menu_actions,
+				    G_N_ELEMENTS (trash_applet_menu_actions),
+				    applet);
+      ui_path = g_build_filename (TRASH_MENU_UI_DIR, "trashapplet-menu.xml", NULL);
+      panel_applet_setup_menu_from_file (applet, ui_path, action_group);
+      g_free (ui_path);
+      g_object_unref (action_group);
 
       gtk_widget_show (GTK_WIDGET (applet));
 
@@ -631,8 +638,8 @@ trash_applet_factory (PanelApplet *applet,
   return retval;
 }
 
-PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_Panel_TrashApplet_Factory",
-                             TRASH_TYPE_APPLET,
-                             "TrashApplet", "0",
-                             trash_applet_factory,
-                             NULL)
+PANEL_APPLET_OUT_PROCESS_FACTORY ("TrashAppletFactory",
+				  TRASH_TYPE_APPLET,
+				  "TrashApplet",
+				  trash_applet_factory,
+				  NULL)
diff --git a/trashapplet/trashapplet-menu.xml b/trashapplet/trashapplet-menu.xml
new file mode 100644
index 0000000..e2bc535
--- /dev/null
+++ b/trashapplet/trashapplet-menu.xml
@@ -0,0 +1,6 @@
+<menuitem name="Open Trash Item" action="OpenTrash" />
+<menuitem name="Empty Trash Item" action="EmptyTrash" />
+<separator/>
+<menuitem name="Open Help Item" action="HelpTrash" />
+<menuitem name="About Item" action="AboutTrash" />
+



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