[mousetweaks] Port applets to libpanelapplet-3



commit 81cbb8f4c6882c4b1c5d23af0c1e88983ae8ad3f
Author: Gerd Kohlberger <gerdk src gnome org>
Date:   Fri Nov 19 14:14:49 2010 +0100

    Port applets to libpanelapplet-3

 configure.ac                                       |    2 +-
 data/DwellClick.xml                                |    9 --
 data/DwellClick_Factory.server.in.in               |   28 -------
 data/Makefile.am                                   |   57 ++++++++------
 data/PointerCapture.xml                            |    9 --
 data/PointerCapture_Factory.server.in.in           |   26 ------
 ...ome.applets.DwellClickApplet.panel-applet.in.in |   16 ++++
 ...applets.PointerCaptureApplet.panel-applet.in.in |   16 ++++
 ...panel.applet.DwellClickAppletFactory.service.in |    3 +
 ...l.applet.PointerCaptureAppletFactory.service.in |    3 +
 po/POTFILES.in                                     |    6 +-
 po/POTFILES.skip                                   |    4 +-
 src/dwell-click-applet.c                           |   83 ++++++++++----------
 src/pointer-capture-applet.c                       |   55 ++++++++------
 14 files changed, 149 insertions(+), 168 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8da2836..5440cd8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -81,7 +81,7 @@ fi
 dnl *** libpanelapplet (OPTIONAL) ***
 
 if test "$build_dca" = yes -o "$build_pca" = yes; then
-	PKG_CHECK_MODULES(PANELAPPLET, libpanelapplet-2.0)
+	PKG_CHECK_MODULES(PANELAPPLET, libpanelapplet-3.0)
 fi
 
 dnl *** GLib tools ***
diff --git a/data/Makefile.am b/data/Makefile.am
index 663d28c..df4ebd9 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,38 +1,44 @@
 if BUILD_PCA
 pca_schema  = org.gnome.pointer-capture.gschema.xml.in
 pca_ui      = pointer-capture-applet.ui
-pca_server  = PointerCapture_Factory.server.in
-pca_menu    = PointerCapture.xml
+pca_service = org.gnome.panel.applet.PointerCaptureAppletFactory.service.in
+pca_applet  = org.gnome.applets.PointerCaptureApplet.panel-applet.in
+
+org.gnome.panel.applet.PointerCaptureAppletFactory.service: $(pca_service)
+	$(AM_V_GEN) sed -e "s|\ BINDIR\@|$(bindir)|" $< > $@
+
+$(pca_applet): $(pca_applet).in Makefile
+	$(AM_V_GEN) sed -e "s|\ BINDIR\@|$(bindir)|" -e "s|\ VERSION\@|$(VERSION)|" $< > $@
 endif
 
 if BUILD_DCA
-dca_ui     = dwell-click-applet.ui
-dca_server = DwellClick_Factory.server.in
-dca_menu   = DwellClick.xml
-endif
+dca_ui      = dwell-click-applet.ui
+dca_service = org.gnome.panel.applet.DwellClickAppletFactory.service.in
+dca_applet  = org.gnome.applets.DwellClickApplet.panel-applet.in
 
- INTLTOOL_SERVER_RULE@
-serverdir = $(libdir)/bonobo/servers
-server_in_files = $(pca_server)	$(dca_server)
-server_in_in_files = $(server_in_files:.server.in=.server.in.in)
-server_DATA = $(server_in_files:.server.in=.server)
+org.gnome.panel.applet.DwellClickAppletFactory.service: $(dca_service)
+	$(AM_V_GEN) sed -e "s|\ BINDIR\@|$(bindir)|" $< > $@
 
-if BUILD_PCA
-$(pca_server): $(pca_server).in Makefile
-	sed -e "s|\ bindir\@|$(bindir)|g" < $< > $@
+$(dca_applet): $(dca_applet).in Makefile
+	$(AM_V_GEN) sed -e "s|\ BINDIR\@|$(bindir)|" -e "s|\ VERSION\@|$(VERSION)|" $< > $@
 endif
 
-if BUILD_DCA
-$(dca_server): $(dca_server).in Makefile
-	sed -e "s|\ bindir\@|$(bindir)|g" < $< > $@
-endif
+appletdir = $(datadir)/gnome-panel/applets
+applet_in_in_files = $(applet_in_files:.panel-applet.in=.panel-applet.in.in)
+applet_in_files = $(pca_applet) $(dca_applet)
+applet_DATA = $(applet_in_files:.panel-applet.in=.panel-applet)
+
+%.panel-applet: %.panel-applet.in \
+	$(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po);
+	LC_ALL=C $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
+
+servicedir = $(datadir)/dbus-1/services
+service_in_files = $(pca_service) $(dca_service)
+service_DATA = $(service_in_files:.service.in=.service)
 
 uidir = $(datadir)/mousetweaks
 ui_DATA = mousetweaks.ui $(pca_ui) $(dca_ui)
 
-menudir = $(datadir)/mousetweaks
-menu_DATA = $(pca_menu) $(dca_menu)
-
 convertdir = $(datadir)/GConf/gsettings
 convert_DATA = mousetweaks.convert
 
@@ -45,16 +51,17 @@ gsettings_SCHEMAS = $(gsettings_in_files:.xml.in=.xml)
 @GSETTINGS_RULES@
 
 EXTRA_DIST =                \
-    $(server_in_in_files)   \
-    $(menu_DATA)            \
+    $(service_in_files)     \
+    $(applet_in_in_files)   \
     $(ui_DATA)              \
     $(gsettings_in_files)   \
     $(gsettings_ENUM_FILES) \
     $(convert_DATA)
 
 DISTCLEANFILES =            \
-    $(server_DATA)          \
-    $(server_in_files)      \
+    $(service_DATA)         \
+    $(applet_in_files)      \
+    $(applet_DATA)          \
     $(gsettings_SCHEMAS)
 
 -include $(top_srcdir)/git.mk
diff --git a/data/org.gnome.applets.DwellClickApplet.panel-applet.in.in b/data/org.gnome.applets.DwellClickApplet.panel-applet.in.in
new file mode 100644
index 0000000..c561742
--- /dev/null
+++ b/data/org.gnome.applets.DwellClickApplet.panel-applet.in.in
@@ -0,0 +1,16 @@
+[Applet Factory]
+Id=DwellClickAppletFactory
+Location= BINDIR@/dwell-click-applet
+Name=Dwell Click Applet Factory
+Description=Dwell Click Applet Factory
+
+[DwellClickApplet]
+_Name=Dwell Click Applet
+_Description=Control your desktop without using mouse buttons
+Icon=input-mouse
+BonoboId=OAFIID:DwellClickApplet
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=mousetweaks
+X-GNOME-Bugzilla-Component=dwell-click applet
+X-GNOME-Bugzilla-Version= VERSION@
+
diff --git a/data/org.gnome.applets.PointerCaptureApplet.panel-applet.in.in b/data/org.gnome.applets.PointerCaptureApplet.panel-applet.in.in
new file mode 100644
index 0000000..c1b7174
--- /dev/null
+++ b/data/org.gnome.applets.PointerCaptureApplet.panel-applet.in.in
@@ -0,0 +1,16 @@
+[Applet Factory]
+Id=PointerCaptureAppletFactory
+Location= BINDIR@/pointer-capture-applet
+Name=Pointer Capture Applet Factory
+Description=Pointer Capture Applet Factory
+
+[PointerCaptureApplet]
+_Name=Pointer Capture Applet
+_Description=Area to lock the pointer
+Icon=input-mouse
+BonoboId=OAFIID:PointerCaptureApplet
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=mousetweaks
+X-GNOME-Bugzilla-Component=pointer-capture applet
+X-GNOME-Bugzilla-Version= VERSION@
+
diff --git a/data/org.gnome.panel.applet.DwellClickAppletFactory.service.in b/data/org.gnome.panel.applet.DwellClickAppletFactory.service.in
new file mode 100644
index 0000000..218268e
--- /dev/null
+++ b/data/org.gnome.panel.applet.DwellClickAppletFactory.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.panel.applet.DwellClickAppletFactory
+Exec= BINDIR@/dwell-click-applet
diff --git a/data/org.gnome.panel.applet.PointerCaptureAppletFactory.service.in b/data/org.gnome.panel.applet.PointerCaptureAppletFactory.service.in
new file mode 100644
index 0000000..8174a7c
--- /dev/null
+++ b/data/org.gnome.panel.applet.PointerCaptureAppletFactory.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.panel.applet.PointerCaptureAppletFactory
+Exec= BINDIR@/pointer-capture-applet
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 36068a1..6ac62a7 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,10 +1,8 @@
 [type: gettext/glade]data/dwell-click-applet.ui
 [type: gettext/glade]data/pointer-capture-applet.ui
 [type: gettext/glade]data/mousetweaks.ui
-data/DwellClick_Factory.server.in.in
-data/PointerCapture_Factory.server.in.in
-data/DwellClick.xml
-data/PointerCapture.xml
+[type: gettext/ini]data/org.gnome.applets.DwellClickApplet.panel-applet.in.in
+[type: gettext/ini]data/org.gnome.applets.PointerCaptureApplet.panel-applet.in.in
 data/org.gnome.mousetweaks.gschema.xml.in
 data/org.gnome.pointer-capture.gschema.xml.in
 src/mt-main.c
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 31c9201..f8f2691 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -1,2 +1,2 @@
-data/DwellClick_Factory.server.in
-data/PointerCapture_Factory.server.in
+data/org.gnome.applets.DwellClickApplet.panel-applet.in
+data/org.gnome.applets.PointerCaptureApplet.panel-applet.in
diff --git a/src/dwell-click-applet.c b/src/dwell-click-applet.c
index 6ccd1ac..3aff2f9 100644
--- a/src/dwell-click-applet.c
+++ b/src/dwell-click-applet.c
@@ -62,25 +62,28 @@ static const gchar *img_widgets_v[] =
     "single_click_img_v"
 };
 
-static void preferences_dialog (BonoboUIComponent *component,
-                                gpointer           data,
-                                const char        *cname);
-static void help_dialog        (BonoboUIComponent *component,
-                                DwellData         *dd,
-                                const char        *cname);
-static void about_dialog       (BonoboUIComponent *component,
-                                DwellData         *dd,
-                                const char        *cname);
-
-static const BonoboUIVerb menu_verb[] =
-{
-    BONOBO_UI_UNSAFE_VERB ("PropertiesVerb", preferences_dialog),
-    BONOBO_UI_UNSAFE_VERB ("HelpVerb", help_dialog),
-    BONOBO_UI_UNSAFE_VERB ("AboutVerb", about_dialog),
-    BONOBO_UI_VERB_END
+static const gchar menu_xml[] =
+{
+    "<menuitem name=\"item1\" action=\"Preferences\" />"
+    "<separator/>"
+    "<menuitem name=\"item2\" action=\"Help\" />"
+    "<menuitem name=\"item3\" action=\"About\" />"
 };
 
-static void button_cb (GtkToggleButton *button, DwellData *dd);
+static void button_cb          (GtkToggleButton *button, DwellData *dd);
+static void preferences_dialog (GtkAction *action, DwellData *dd);
+static void help_dialog        (GtkAction *action, DwellData *dd);
+static void about_dialog       (GtkAction *action, DwellData *dd);
+
+static const GtkActionEntry menu_actions[] =
+{
+    { "Preferences", GTK_STOCK_PREFERENCES, N_("_Preferences"), NULL, NULL,
+      G_CALLBACK (preferences_dialog) },
+    { "Help", GTK_STOCK_HELP, N_("_Help"), NULL, NULL,
+      G_CALLBACK (help_dialog) },
+    { "About", GTK_STOCK_ABOUT, N_("_About"), NULL, NULL,
+      G_CALLBACK (about_dialog) }
+};
 
 static void
 update_sensitivity (DwellData *dd)
@@ -438,9 +441,7 @@ applet_unrealized (GtkWidget *widget, DwellData *dd)
 }
 
 static void
-preferences_dialog (BonoboUIComponent *component,
-                    gpointer           data,
-                    const char        *cname)
+preferences_dialog (GtkAction *action, DwellData *dd)
 {
     GError *error = NULL;
 
@@ -454,18 +455,14 @@ preferences_dialog (BonoboUIComponent *component,
 }
 
 static void
-help_dialog (BonoboUIComponent *component,
-             DwellData         *dd,
-             const char        *cname)
+help_dialog (GtkAction *action, DwellData *dd)
 {
     mt_common_show_help (gtk_widget_get_screen (dd->box),
                          gtk_get_current_event_time ());
 }
 
 static void
-about_dialog (BonoboUIComponent *component,
-              DwellData         *dd,
-              const char        *cname)
+about_dialog (GtkAction *action, DwellData *dd)
 {
     gtk_window_present (GTK_WINDOW (WID ("about")));
 }
@@ -577,13 +574,14 @@ fill_applet (PanelApplet *applet)
     DwellData *dd;
     GError *error = NULL;
     GtkWidget *about;
+    GtkActionGroup *group;
     PanelAppletOrient orient;
 
     bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
     bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
     textdomain (GETTEXT_PACKAGE);
 
-    g_set_application_name (_("Dwell Click"));
+    g_set_application_name (_("Dwell Click Applet"));
     gtk_window_set_default_icon_name (MT_ICON_NAME);
 
     dd = g_slice_new0 (DwellData);
@@ -617,12 +615,12 @@ fill_applet (PanelApplet *applet)
                       G_CALLBACK (about_response), dd);
 
     /* gsettings */
-    dd->settings = g_settings_new (MOUSETWEAKS_SCHEMA_ID);
-    g_signal_connect (dd->settings, "value::" KEY_DWELL_ENABLED,
+    dd->settings = g_settings_new (A11Y_MOUSE_SCHEMA_ID);
+    g_signal_connect (dd->settings, "changed::" KEY_DWELL_ENABLED,
                       G_CALLBACK (dwell_enabled_changed), dd);
-    g_signal_connect (dd->settings, "value::" KEY_DWELL_MODE,
+    g_signal_connect (dd->settings, "changed::" KEY_DWELL_MODE,
                       G_CALLBACK (dwell_mode_changed), dd);
-    g_signal_connect (dd->settings, "value::" KEY_DWELL_TIME,
+    g_signal_connect (dd->settings, "changed::" KEY_DWELL_TIME,
                       G_CALLBACK (dwell_time_changed), dd);
 
     /* icons */
@@ -640,15 +638,19 @@ fill_applet (PanelApplet *applet)
                             PANEL_APPLET_EXPAND_MINOR |
                             PANEL_APPLET_HAS_HANDLE);
     panel_applet_set_background_widget (applet, GTK_WIDGET(applet));
-    panel_applet_setup_menu_from_file (applet,
-                                       DATADIR, "DwellClick.xml",
-                                       NULL, menu_verb, dd);
 
     g_signal_connect (applet, "change-orient",
                       G_CALLBACK (applet_orient_changed), dd);
     g_signal_connect (applet, "unrealize",
                       G_CALLBACK (applet_unrealized), dd);
 
+    /* context menu */
+    group = gtk_action_group_new ("actions");
+    gtk_action_group_set_translation_domain (group, GETTEXT_PACKAGE);
+    gtk_action_group_add_actions (group, menu_actions, 3, dd);
+    panel_applet_setup_menu (applet, menu_xml, group);
+    g_object_unref (group);
+
     /* check initial orientation */
     orient = panel_applet_get_orient (applet);
     if (orient == PANEL_APPLET_ORIENT_UP ||
@@ -683,15 +685,14 @@ fill_applet (PanelApplet *applet)
 static gboolean
 applet_factory (PanelApplet *applet, const gchar *iid, gpointer data)
 {
-    if (!g_str_equal (iid, "OAFIID:DwellClickApplet"))
+    if (!g_str_equal (iid, "DwellClickApplet"))
         return FALSE;
 
     return fill_applet (applet);
 }
 
-PANEL_APPLET_BONOBO_FACTORY ("OAFIID:DwellClickApplet_Factory",
-                             PANEL_TYPE_APPLET,
-                             "Dwell Click Factory",
-                             VERSION,
-                             applet_factory,
-                             NULL);
+PANEL_APPLET_OUT_PROCESS_FACTORY ("DwellClickAppletFactory",
+                                  PANEL_TYPE_APPLET,
+                                  "Dwell Click Applet",
+                                  applet_factory,
+                                  NULL)
diff --git a/src/pointer-capture-applet.c b/src/pointer-capture-applet.c
index 7567013..23f67a2 100644
--- a/src/pointer-capture-applet.c
+++ b/src/pointer-capture-applet.c
@@ -56,6 +56,14 @@ typedef struct _PcApplet
     GtkToggleButton *modifier_control;
 } PcApplet;
 
+static const gchar menu_xml[] =
+{
+    "<menuitem name=\"item1\" action=\"Preferences\" />"
+    "<separator/>"
+    "<menuitem name=\"item2\" action=\"Help\" />"
+    "<menuitem name=\"item3\" action=\"About\" />"
+};
+
 GType pc_applet_get_type (void) G_GNUC_CONST;
 
 G_DEFINE_TYPE (PcApplet, pc_applet, PANEL_TYPE_APPLET)
@@ -144,36 +152,32 @@ pc_applet_class_init (PcAppletClass *klass)
 }
 
 static void
-capture_preferences (BonoboUIComponent *component,
-                     PcApplet          *pc,
-                     const gchar       *cname)
+capture_preferences (GtkAction *action, PcApplet *pc)
 {
     gtk_window_present (GTK_WINDOW (WID ("preferences")));
 }
 
 static void
-capture_help (BonoboUIComponent *component,
-              PcApplet          *pc,
-              const gchar       *cname)
+capture_help (GtkAction *action, PcApplet *pc)
 {
     mt_common_show_help (gtk_widget_get_screen (pc->area),
                          gtk_get_current_event_time ());
 }
 
 static void
-capture_about (BonoboUIComponent *component,
-               PcApplet          *pc,
-               const gchar       *cname)
+capture_about (GtkAction *action, PcApplet *pc)
 {
     gtk_window_present (GTK_WINDOW (WID ("about")));
 }
 
-static const BonoboUIVerb menu_verb[] =
+static const GtkActionEntry menu_actions[] =
 {
-    BONOBO_UI_UNSAFE_VERB ("PropertiesVerb", capture_preferences),
-    BONOBO_UI_UNSAFE_VERB ("HelpVerb", capture_help),
-    BONOBO_UI_UNSAFE_VERB ("AboutVerb", capture_about),
-    BONOBO_UI_VERB_END
+    { "Preferences", GTK_STOCK_PREFERENCES, N_("_Preferences"), NULL, NULL,
+      G_CALLBACK (capture_preferences) },
+    { "Help", GTK_STOCK_HELP, N_("_Help"), NULL, NULL,
+      G_CALLBACK (capture_help) },
+    { "About", GTK_STOCK_ABOUT, N_("_About"), NULL, NULL,
+      G_CALLBACK (capture_about) }
 };
 
 static void
@@ -426,6 +430,7 @@ fill_applet (PanelApplet *applet)
     PcApplet *pc = PC_APPLET (applet);
     GtkIconTheme *theme;
     GtkWidget *about;
+    GtkActionGroup *group;
 
     bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
     bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
@@ -449,8 +454,6 @@ fill_applet (PanelApplet *applet)
     panel_applet_set_background_widget (applet, GTK_WIDGET (applet));
     panel_applet_set_flags (applet, PANEL_APPLET_EXPAND_MINOR |
                                     PANEL_APPLET_HAS_HANDLE);
-    panel_applet_setup_menu_from_file (applet, DATADIR, "PointerCapture.xml",
-                                       NULL, menu_verb, pc);
 
     g_signal_connect (pc, "destroy",
                       G_CALLBACK (pc_applet_destroy), NULL);
@@ -461,6 +464,13 @@ fill_applet (PanelApplet *applet)
     g_signal_connect (pc, "visibility_notify_event",
                       G_CALLBACK (pc_applet_visibility_notify), pc);
 
+    /* context menu */
+    group = gtk_action_group_new ("actions");
+    gtk_action_group_set_translation_domain (group, GETTEXT_PACKAGE);
+    gtk_action_group_add_actions (group, menu_actions, 3, pc);
+    panel_applet_setup_menu (applet, menu_xml, group);
+    g_object_unref (group);
+
     /* icon theme */
     theme = gtk_icon_theme_get_default ();
     g_signal_connect (theme, "changed", G_CALLBACK (icon_theme_changed), pc);
@@ -494,15 +504,14 @@ fill_applet (PanelApplet *applet)
 static gboolean
 applet_factory (PanelApplet *applet, const gchar *iid, gpointer data)
 {
-    if (!g_str_equal (iid, "OAFIID:PointerCaptureApplet"))
+    if (!g_str_equal (iid, "PointerCaptureApplet"))
         return FALSE;
 
     return fill_applet (applet);
 }
 
-PANEL_APPLET_BONOBO_FACTORY ("OAFIID:PointerCaptureApplet_Factory",
-                             PC_TYPE_APPLET,
-                             "Pointer Capture Factory",
-                             VERSION,
-                             applet_factory,
-                             NULL);
+PANEL_APPLET_OUT_PROCESS_FACTORY ("PointerCaptureAppletFactory",
+                                  PC_TYPE_APPLET,
+                                  "Pointer Capture Applet",
+                                  applet_factory,
+                                  NULL)



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