[gnome-applets] [mini-commander] Port to new libpanel-applet API



commit 9512923e49ff77b664a89ebbfe723c6e4afcdbad
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Mon Feb 22 16:10:48 2010 +0100

    [mini-commander] Port to new libpanel-applet API

 .../src/GNOME_MiniCommanderApplet.server.in.in     |   35 -----------
 mini-commander/src/GNOME_MiniCommanderApplet.xml   |   12 ----
 mini-commander/src/Makefile.am                     |   50 ++++++++++------
 mini-commander/src/about.c                         |    5 +-
 mini-commander/src/about.h                         |    5 +-
 mini-commander/src/help.c                          |    5 +-
 mini-commander/src/help.h                          |    5 +-
 mini-commander/src/mini-commander-applet-menu.xml  |    4 +
 mini-commander/src/mini-commander_applet.c         |   62 ++++++++++---------
 mini-commander/src/mini-commander_applet.h         |    1 +
 ....applets.MiniCommanderApplet.panel-applet.in.in |   16 +++++
 ...el.applet.MiniCommanderAppletFactory.service.in |    3 +
 mini-commander/src/preferences.c                   |    5 +-
 mini-commander/src/preferences.h                   |    6 +-
 14 files changed, 100 insertions(+), 114 deletions(-)
---
diff --git a/mini-commander/src/Makefile.am b/mini-commander/src/Makefile.am
index 87c9baa..b5dd10e 100644
--- a/mini-commander/src/Makefile.am
+++ b/mini-commander/src/Makefile.am
@@ -3,8 +3,8 @@
 INCLUDES = 				\
 	-I.				\
 	-I$(srcdir)			\
-	$(GNOME_LIBS2_CFLAGS)		\
-	$(GNOME_APPLETS_CFLAGS)		\
+	-DMC_MENU_UI_DIR=\""$(uidir)"\"	\
+	$(GNOME_APPLETS3_CFLAGS)	\
 	$(WARN_CFLAGS)			\
 	$(GNOME_INCLUDEDIR)
 
@@ -35,8 +35,7 @@ mini_commander_applet_SOURCES =			\
 	mc-default-macros.h
 
 mini_commander_applet_LDADD =	\
-	$(GNOME_LIBS2_LIBS)	\
-	$(GNOME_APPLETS_LIBS)
+	$(GNOME_APPLETS3_LIBS)
 
 mc_install_default_macros_SOURCES =	\
 	mc-install-default-macros.c	\
@@ -66,14 +65,28 @@ update-icon-cache:
 		echo "***   $(gtk_update_icon_cache)"; \
 	fi
 
-serverdir       = $(libdir)/bonobo/servers
-server_in_files = GNOME_MiniCommanderApplet.server.in
-server_DATA     = $(server_in_files:.server.in=.server)
+appletdir       = $(datadir)/gnome-panel/applets
+applet_in_files = org.gnome.applets.MiniCommanderApplet.panel-applet.in
+applet_DATA     = $(applet_in_files:.panel-applet.in=.panel-applet)
+
+$(applet_in_files): $(applet_in_files).in Makefile
+	$(AM_V_GEN)sed \
+            -e "s|\ LIBEXECDIR\@|$(libexecdir)|" \
+            -e "s|\ VERSION\@|$(PACKAGE_VERSION)|" \
+            $< > $@
+
+%.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
 
-$(server_in_files): $(server_in_files:.server.in=.server.in.in)
-	sed -e "s|\ LIBEXECDIR\@|$(libexecdir)|" $< > $@
+servicedir       = $(datadir)/dbus-1/services
+service_in_files = org.gnome.panel.applet.MiniCommanderAppletFactory.service.in
+service_DATA     = $(service_in_files:.service.in=.service)
 
-CLEANFILES = $(server_in_files) $(server_DATA) $(schemas_DATA)
+org.gnome.panel.applet.MiniCommanderAppletFactory.service: $(service_in_files)
+	$(AM_V_GEN)sed \
+            -e "s|\ LIBEXECDIR\@|$(libexecdir)|" \
+            $< > $@
+
+CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA) $(schemas_DATA)
 
 schemasdir   = @GCONF_SCHEMA_FILE_DIR@
 schemas_in_files = mini-commander.schemas.in mini-commander-global.schemas.in
@@ -82,7 +95,7 @@ schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
 @INTLTOOL_SCHEMAS_RULE@
 
 uidir = $(datadir)/gnome-2.0/ui
-ui_DATA = GNOME_MiniCommanderApplet.xml
+ui_DATA = mini-commander-applet-menu.xml
 
 if GCONF_SCHEMAS_INSTALL
 install-data-local:
@@ -90,14 +103,13 @@ install-data-local:
 	GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(top_builddir)/mini-commander/src/mc-install-default-macros
 endif
 
- INTLTOOL_SERVER_RULE@
-
-EXTRA_DIST =					\
-	GNOME_MiniCommanderApplet.server.in.in	\
-	$(desktop_icons_DATA)			\
-	$(BITMAPS)				\
-	$(ui_DATA)				\
-	$(builder_DATA)				\
+EXTRA_DIST =								\
+	org.gnome.applets.MiniCommanderApplet.panel-applet.in.in	\
+	$(service_in_files)						\
+	$(desktop_icons_DATA)						\
+	$(BITMAPS)							\
+	$(ui_DATA)							\
+	$(builder_DATA)							\
 	$(schemas_in_files)
 
 -include $(top_srcdir)/git.mk
diff --git a/mini-commander/src/about.c b/mini-commander/src/about.c
index 9908394..2832127 100644
--- a/mini-commander/src/about.c
+++ b/mini-commander/src/about.c
@@ -26,9 +26,8 @@
 
 #include "about.h"
 
-void about_box (BonoboUIComponent *uic,
-		MCData            *mcdata,
-		const char        *verbname)
+void about_box (GtkAction *action,
+		MCData    *mcdata)
 {
 	static const gchar *authors[] = {
 		"Oliver Maruhn <oliver maruhn com>",
diff --git a/mini-commander/src/about.h b/mini-commander/src/about.h
index 231f129..875ea62 100644
--- a/mini-commander/src/about.h
+++ b/mini-commander/src/about.h
@@ -1,5 +1,4 @@
 #include "mini-commander_applet.h"
 
-void about_box (BonoboUIComponent *uic,
-		MCData            *mcdata,
-		const char        *verbname);
+void about_box (GtkAction *action,
+		MCData    *mcdata);
diff --git a/mini-commander/src/help.c b/mini-commander/src/help.c
index 4380b37..b5c4b66 100644
--- a/mini-commander/src/help.c
+++ b/mini-commander/src/help.c
@@ -24,9 +24,8 @@
 #include "help.h"
 
 void 
-show_help (BonoboUIComponent *uic,
-	   MCData            *mcdata,
-	   const char        *verbname)
+show_help (GtkAction *action,
+	   MCData    *mcdata)
 {
     GError *error = NULL;
    
diff --git a/mini-commander/src/help.h b/mini-commander/src/help.h
index ab462bd..495984a 100644
--- a/mini-commander/src/help.h
+++ b/mini-commander/src/help.h
@@ -1,5 +1,4 @@
 #include "mini-commander_applet.h"
 
-void show_help (BonoboUIComponent *uic,
-		MCData            *mcdata,
-		const char        *verbname);
+void show_help (GtkAction *action,
+		MCData    *mcdata);
diff --git a/mini-commander/src/mini-commander-applet-menu.xml b/mini-commander/src/mini-commander-applet-menu.xml
new file mode 100644
index 0000000..5cef44f
--- /dev/null
+++ b/mini-commander/src/mini-commander-applet-menu.xml
@@ -0,0 +1,4 @@
+<menuitem name="Item 1" action="Props" />
+<menuitem name="Item 2" action="Help" />
+<menuitem name="Item 3" action="About" />
+
diff --git a/mini-commander/src/mini-commander_applet.c b/mini-commander/src/mini-commander_applet.c
index 4999de5..62339c4 100644
--- a/mini-commander/src/mini-commander_applet.c
+++ b/mini-commander/src/mini-commander_applet.c
@@ -49,12 +49,16 @@
 static gboolean icons_initialized = FALSE;
 static GtkIconSize button_icon_size = 0;
 
-static const BonoboUIVerb mini_commander_menu_verbs [] = {
-        BONOBO_UI_UNSAFE_VERB ("Props", mc_show_preferences),
-        BONOBO_UI_UNSAFE_VERB ("Help",  show_help),
-        BONOBO_UI_UNSAFE_VERB ("About", about_box),
-
-        BONOBO_UI_VERB_END
+static const GtkActionEntry mini_commander_menu_actions [] = {
+	{ "Props", GTK_STOCK_PROPERTIES, N_("_Preferences"),
+	  NULL, NULL,
+	  G_CALLBACK (mc_show_preferences) },
+	{ "Help", GTK_STOCK_HELP, N_("_Help"),
+	  NULL, NULL,
+	  G_CALLBACK (show_help) },
+	{ "About", GTK_STOCK_ABOUT, N_("_About"),
+	  NULL, NULL,
+	  G_CALLBACK (about_box) }
 };
 
 typedef struct {
@@ -198,7 +202,7 @@ mc_applet_draw (MCData *mc)
         gtk_widget_destroy (mc->applet_box);
     }
 
-    if ( ((mc->orient == PANEL_APPLET_ORIENT_LEFT) || (mc->orient == PANEL_APPLET_ORIENT_RIGHT)) && (prefs.panel_size_x < GNOME_Vertigo_PANEL_SMALL) )
+    if ( ((mc->orient == PANEL_APPLET_ORIENT_LEFT) || (mc->orient == PANEL_APPLET_ORIENT_RIGHT)) && (prefs.panel_size_x < 36) )
       mc->applet_box = gtk_vbox_new (FALSE, 0);
     else
       mc->applet_box = gtk_hbox_new (FALSE, 0);
@@ -214,12 +218,12 @@ mc_applet_draw (MCData *mc)
 
     /* hbox for message label and buttons */
     if ((mc->orient == PANEL_APPLET_ORIENT_LEFT) || (mc->orient == PANEL_APPLET_ORIENT_RIGHT))
-      if (prefs.panel_size_x < GNOME_Vertigo_PANEL_SMALL)
+      if (prefs.panel_size_x < 36)
 	hbox_buttons = gtk_vbox_new (TRUE, 0);
       else
 	hbox_buttons = gtk_hbox_new (TRUE, 0);
     else
-      if (prefs.normal_size_y > GNOME_Vertigo_PANEL_SMALL)
+      if (prefs.normal_size_y > 36)
 	hbox_buttons = gtk_vbox_new (TRUE, 0);
       else
 	hbox_buttons = gtk_hbox_new (TRUE, 0);
@@ -328,6 +332,8 @@ mini_commander_applet_fill (PanelApplet *applet)
 {
     MCData *mc;
     GConfClient *client;
+    GtkActionGroup *action_group;
+    gchar *ui_path;
 
     client = gconf_client_get_default ();
     if (gconf_client_get_bool (client, "/desktop/gnome/lockdown/inhibit_command_line", NULL)) {
@@ -380,23 +386,22 @@ mini_commander_applet_fill (PanelApplet *applet)
     g_signal_connect (mc->applet, "key_press_event",
 		      G_CALLBACK (key_press_cb), mc);
 
-    panel_applet_setup_menu_from_file (mc->applet,
-				       DATADIR,
-				       "GNOME_MiniCommanderApplet.xml",
-				       NULL,
-				       mini_commander_menu_verbs,
-				       mc);
+    action_group = gtk_action_group_new ("MiniCommander Applet Actions");
+    gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+    gtk_action_group_add_actions (action_group,
+				  mini_commander_menu_actions,
+				  G_N_ELEMENTS (mini_commander_menu_actions),
+				  mc);
+    ui_path = g_build_filename (MC_MENU_UI_DIR, "mini-commander-applet-menu.xml", NULL);
+    panel_applet_setup_menu_from_file (mc->applet, ui_path, action_group);
 
     if (panel_applet_get_locked_down (mc->applet)) {
-	    BonoboUIComponent *popup_component;
-
-	    popup_component = panel_applet_get_popup_component (mc->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);
 
     set_atk_name_description (GTK_WIDGET (applet),
 			      _("Mini-Commander applet"),
@@ -412,15 +417,14 @@ mini_commander_applet_factory (PanelApplet *applet,
 {
         gboolean retval = FALSE;
 
-        if (!strcmp (iid, "OAFIID:GNOME_MiniCommanderApplet"))
+        if (!strcmp (iid, "MiniCommanderApplet"))
                 retval = mini_commander_applet_fill(applet);
 
         return retval;
 }
 
-PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_MiniCommanderApplet_Factory",
-			     PANEL_TYPE_APPLET,
-                             "command-line",
-                             "0",
-                             mini_commander_applet_factory,
-                             NULL)
+PANEL_APPLET_OUT_PROCESS_FACTORY ("MiniCommanderAppletFactory",
+				  PANEL_TYPE_APPLET,
+				  "command-line",
+				  mini_commander_applet_factory,
+				  NULL)
diff --git a/mini-commander/src/mini-commander_applet.h b/mini-commander/src/mini-commander_applet.h
index b31aad8..a64327c 100644
--- a/mini-commander/src/mini-commander_applet.h
+++ b/mini-commander/src/mini-commander_applet.h
@@ -25,6 +25,7 @@
 #define __MC_APPLET_H__
 
 #include <glib.h>
+#include <glib/gi18n.h>
 
 G_BEGIN_DECLS
 
diff --git a/mini-commander/src/org.gnome.applets.MiniCommanderApplet.panel-applet.in.in b/mini-commander/src/org.gnome.applets.MiniCommanderApplet.panel-applet.in.in
new file mode 100644
index 0000000..ca790aa
--- /dev/null
+++ b/mini-commander/src/org.gnome.applets.MiniCommanderApplet.panel-applet.in.in
@@ -0,0 +1,16 @@
+[Applet Factory]
+Id=MiniCommanderAppletFactory
+Location= LIBEXECDIR@/mini_commander_applet
+_Name=MiniCommander Applet Factory
+_Description=MiniCommander Applet Factory
+
+[MiniCommanderApplet]
+_Name=Command Line
+_Description=Mini-Commander
+Icon=gnome-mini-commander.png
+BonoboId=OAFIID:GNOME_MiniCommanderApplet
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=gnome-applets
+X-GNOME-Bugzilla-Component=mini-commander
+X-GNOME-Bugzilla-Version= VERSION@
+X-GNOME-Bugzilla-OtherBinaries=mini_commander_applet
diff --git a/mini-commander/src/org.gnome.panel.applet.MiniCommanderAppletFactory.service.in b/mini-commander/src/org.gnome.panel.applet.MiniCommanderAppletFactory.service.in
new file mode 100644
index 0000000..983750c
--- /dev/null
+++ b/mini-commander/src/org.gnome.panel.applet.MiniCommanderAppletFactory.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.panel.applet.MiniCommanderAppletFactory
+Exec=/home/carlos/gnome-cvs/libexec/mini_commander_applet
diff --git a/mini-commander/src/preferences.c b/mini-commander/src/preferences.c
index fff51f8..3e5920b 100644
--- a/mini-commander/src/preferences.c
+++ b/mini-commander/src/preferences.c
@@ -788,9 +788,8 @@ mc_preferences_setup_dialog (GtkBuilder *builder,
 }
 
 void
-mc_show_preferences (BonoboUIComponent *uic,
-		     MCData            *mc,
-		     const char        *verbname)
+mc_show_preferences (GtkAction *action,
+		     MCData    *mc)
 {
     if (!mc->prefs_dialog.dialog) {
 	GtkBuilder *builder;
diff --git a/mini-commander/src/preferences.h b/mini-commander/src/preferences.h
index 1707307..875a7fa 100644
--- a/mini-commander/src/preferences.h
+++ b/mini-commander/src/preferences.h
@@ -32,7 +32,6 @@ G_BEGIN_DECLS
 #include <regex.h>
 
 #include <gtk/gtk.h>
-#include <bonobo/bonobo-ui-component.h>
 
 typedef struct {
     char    *pattern;
@@ -98,9 +97,8 @@ typedef struct {
 #include "mini-commander_applet.h"
 
 void       mc_load_preferences (MCData            *mc);
-void       mc_show_preferences (BonoboUIComponent *uic,
-				MCData            *mc,
-				const char        *verbname);
+void       mc_show_preferences (GtkAction         *action,
+				MCData            *mc);
 void       mc_macros_free      (GSList            *macros);
 
 gboolean   mc_key_writable     (MCData            *mc,



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