[gnome-applets] [accessx-status] Port to new libpanel-applet API
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets] [accessx-status] Port to new libpanel-applet API
- Date: Wed, 18 Aug 2010 14:39:30 +0000 (UTC)
commit 45f4cd1bbdbaae19d1455fb9f87563624ee9eea5
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Mon Feb 22 15:44:33 2010 +0100
[accessx-status] Port to new libpanel-applet API
accessx-status/GNOME_AccessxApplet.xml | 13 ----
.../GNOME_AccessxStatusApplet.server.in.in | 35 ---------
accessx-status/Makefile.am | 40 +++++++----
accessx-status/accessx-status-applet-menu.xml | 5 ++
accessx-status/applet.c | 77 ++++++++++----------
....applets.AccessxStatusApplet.panel-applet.in.in | 16 ++++
...el.applet.AccessxStatusAppletFactory.service.in | 3 +
7 files changed, 90 insertions(+), 99 deletions(-)
---
diff --git a/accessx-status/Makefile.am b/accessx-status/Makefile.am
index 3fd9842..c0f8362 100644
--- a/accessx-status/Makefile.am
+++ b/accessx-status/Makefile.am
@@ -1,9 +1,9 @@
SUBDIRS = docs pixmaps
INCLUDES = \
- $(GNOME_APPLETS_CFLAGS) \
- $(GNOME_LIBS2_CFLAGS) \
- -DACCESSX_PIXMAPS_DIR=\""$(datadir)/pixmaps/accessx-status-applet"\"
+ $(GNOME_APPLETS3_CFLAGS) \
+ -DACCESSX_PIXMAPS_DIR=\""$(datadir)/pixmaps/accessx-status-applet"\" \
+ -DACCESSX_MENU_UI_DIR=\""$(uidir)"\"
libexec_PROGRAMS = accessx-status-applet
@@ -12,26 +12,38 @@ accessx_status_applet_SOURCES = \
applet.h
accessx_status_applet_LDADD = \
- $(GNOME_APPLETS_LIBS) \
- $(GNOME_LIBS2_LIBS) \
+ $(GNOME_APPLETS3_LIBS) \
$(X_LIBS)
-serverdir = $(libdir)/bonobo/servers
-server_in_files = GNOME_AccessxStatusApplet.server.in
-server_DATA = $(server_in_files:.server.in=.server)
+appletdir = $(datadir)/gnome-panel/applets
+applet_in_files = org.gnome.applets.AccessxStatusApplet.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.AccessxStatusAppletFactory.service.in
+service_DATA = $(service_in_files:.service.in=.service)
+
+org.gnome.panel.applet.AccessxStatusAppletFactory.service: $(service_in_files)
+ $(AM_V_GEN)sed \
+ -e "s|\ LIBEXECDIR\@|$(libexecdir)|" \
+ $< > $@
uidir = $(datadir)/gnome-2.0/ui
-ui_DATA = GNOME_AccessxApplet.xml
+ui_DATA = accessx-status-applet-menu.xml
-CLEANFILES = $(server_in_files) $(server_DATA) $(ACCESSX_STATUS_APPLET_CLEANFILES)
+CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA) $(ACCESSX_STATUS_APPLET_CLEANFILES)
EXTRA_DIST = \
- GNOME_AccessxStatusApplet.server.in.in \
+ org.gnome.applets.AccessxStatusApplet.panel-applet.in.in \
+ $(service_in_files) \
$(ui_DATA)
diff --git a/accessx-status/accessx-status-applet-menu.xml b/accessx-status/accessx-status-applet-menu.xml
new file mode 100644
index 0000000..f4d1c26
--- /dev/null
+++ b/accessx-status/accessx-status-applet-menu.xml
@@ -0,0 +1,5 @@
+<menuitem name="Item 1" action="Dialog" />
+<menuitem name="Item 2" action="Help" />
+<menuitem name="Item 3" action="About" />
+
+
diff --git a/accessx-status/applet.c b/accessx-status/applet.c
index f8a5081..4498f42 100644
--- a/accessx-status/applet.c
+++ b/accessx-status/applet.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <string.h>
+#include <glib/gi18n.h>
#include <glib-object.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h>
@@ -116,9 +117,8 @@ static void popup_error_dialog (AccessxStatusApplet *sapplet);
/* cribbed from geyes */
static void
-about_cb (BonoboUIComponent *uic,
- AccessxStatusApplet *sapplet,
- const gchar *verbname)
+about_cb (GtkAction *action,
+ AccessxStatusApplet *sapplet)
{
static const gchar *authors [] = {
"Calum Benson <calum benson sun com>",
@@ -145,9 +145,8 @@ about_cb (BonoboUIComponent *uic,
}
static void
-help_cb (BonoboUIComponent *uic,
- AccessxStatusApplet *sapplet,
- const char *verbname)
+help_cb (GtkAction *action,
+ AccessxStatusApplet *sapplet)
{
GError *error = NULL;
@@ -182,9 +181,8 @@ help_cb (BonoboUIComponent *uic,
}
static void
-dialog_cb (BonoboUIComponent *component,
- AccessxStatusApplet *sapplet,
- const char *verb)
+dialog_cb (GtkAction *action,
+ AccessxStatusApplet *sapplet)
{
GError *error = NULL;
@@ -231,12 +229,16 @@ dialog_cb (BonoboUIComponent *component,
}
}
-static const BonoboUIVerb accessx_status_applet_menu_verbs [] = {
- BONOBO_UI_UNSAFE_VERB ("Dialog", dialog_cb),
- BONOBO_UI_UNSAFE_VERB ("Help", help_cb),
- BONOBO_UI_UNSAFE_VERB ("About", about_cb),
-
- BONOBO_UI_VERB_END
+static const GtkActionEntry accessx_status_applet_menu_actions [] = {
+ { "Dialog", GTK_STOCK_PROPERTIES, N_("_Keyboard Accessibility Preferences"),
+ NULL, NULL,
+ G_CALLBACK (dialog_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 XkbDescPtr
@@ -1217,7 +1219,7 @@ static gboolean
button_press_cb (GtkWidget *widget, GdkEventButton *event, AccessxStatusApplet *sapplet)
{
if (event->button == 1 && event->type == GDK_BUTTON_PRESS)
- dialog_cb (NULL, sapplet, NULL);
+ dialog_cb (NULL, sapplet);
return FALSE;
}
@@ -1232,7 +1234,7 @@ key_press_cb (GtkWidget *widget, GdkEventKey *event, AccessxStatusApplet *sapple
case GDK_Return:
case GDK_space:
case GDK_KP_Space:
- dialog_cb (NULL, sapplet, NULL);
+ dialog_cb (NULL, sapplet);
return TRUE;
default:
@@ -1287,6 +1289,8 @@ accessx_status_applet_fill (PanelApplet *applet)
{
AccessxStatusApplet *sapplet;
AtkObject *atk_object;
+ GtkActionGroup *action_group;
+ gchar *ui_path;
gboolean was_realized = FALSE;
sapplet = create_applet (applet);
@@ -1312,23 +1316,23 @@ accessx_status_applet_fill (PanelApplet *applet)
g_signal_connect (sapplet->applet, "key_press_event",
G_CALLBACK (key_press_cb), sapplet);
- panel_applet_setup_menu_from_file (sapplet->applet,
- DATADIR,
- "GNOME_AccessxApplet.xml",
- NULL,
- accessx_status_applet_menu_verbs,
- sapplet);
+ action_group = gtk_action_group_new ("Accessx Applet Actions");
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (action_group,
+ accessx_status_applet_menu_actions,
+ G_N_ELEMENTS (accessx_status_applet_menu_actions),
+ sapplet);
+ ui_path = g_build_filename (ACCESSX_MENU_UI_DIR, "accessx-status-applet-menu.xml", NULL);
+ panel_applet_setup_menu_from_file (sapplet->applet, ui_path, action_group);
+ g_free (ui_path);
if (panel_applet_get_locked_down (sapplet->applet)) {
- BonoboUIComponent *popup_component;
-
- popup_component = panel_applet_get_popup_component (sapplet->applet);
+ GtkAction *action;
- bonobo_ui_component_set_prop (popup_component,
- "/commands/Dialog",
- "hidden", "1",
- NULL);
+ action = gtk_action_group_get_action (action_group, "Dialog");
+ gtk_action_set_visible (action, FALSE);
}
+ g_object_unref (action_group);
gtk_widget_set_tooltip_text (GTK_WIDGET (sapplet->applet), _("Keyboard Accessibility Status"));
@@ -1350,14 +1354,13 @@ accessx_status_applet_factory (PanelApplet *applet,
gpointer data)
{
gboolean retval = FALSE;
- if (!strcmp (iid, "OAFIID:GNOME_AccessxStatusApplet"))
+ if (!strcmp (iid, "AccessxStatusApplet"))
retval = accessx_status_applet_fill (applet);
return retval;
}
-PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_AccessxStatusApplet_Factory",
- PANEL_TYPE_APPLET,
- "accessx-status",
- "0",
- accessx_status_applet_factory,
- NULL)
+PANEL_APPLET_OUT_PROCESS_FACTORY ("AccessxStatusAppletFactory",
+ PANEL_TYPE_APPLET,
+ "accessx-status",
+ accessx_status_applet_factory,
+ NULL)
diff --git a/accessx-status/org.gnome.applets.AccessxStatusApplet.panel-applet.in.in b/accessx-status/org.gnome.applets.AccessxStatusApplet.panel-applet.in.in
new file mode 100644
index 0000000..fc5fb5d
--- /dev/null
+++ b/accessx-status/org.gnome.applets.AccessxStatusApplet.panel-applet.in.in
@@ -0,0 +1,16 @@
+[Applet Factory]
+Id=AccessxStatusAppletFactory
+Location= LIBEXECDIR@/accessx-status-applet
+_Name=AccessX Status Applet Factory
+_Description=Keyboard Accessibility Status Applet Factory
+
+[AccessxStatusApplet]
+_Name=Keyboard Accessibility Status
+_Description=Shows the status of keyboard accessibility features
+Icon=ax-applet
+BonoboId=OAFIID:GNOME_AccessxStatusApplet
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=gnome-applets
+X-GNOME-Bugzilla-Component=keyboard-accessibility (accessx-status)
+X-GNOME-Bugzilla-Version= VERSION@
+X-GNOME-Bugzilla-OtherBinaries=accessx-status-applet
diff --git a/accessx-status/org.gnome.panel.applet.AccessxStatusAppletFactory.service.in b/accessx-status/org.gnome.panel.applet.AccessxStatusAppletFactory.service.in
new file mode 100644
index 0000000..71d32c2
--- /dev/null
+++ b/accessx-status/org.gnome.panel.applet.AccessxStatusAppletFactory.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.panel.applet.AccessxStatusAppletFactory
+Exec= LIBEXECDIR@/accessx-status-applet
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]