[gnome-main-menu] main-menu: port to libmatepanelapplet-4.0 and DBUS
- From: Stefano Karapetsas <stefanok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-main-menu] main-menu: port to libmatepanelapplet-4.0 and DBUS
- Date: Wed, 12 Dec 2012 15:04:18 +0000 (UTC)
commit 8ef3e56d130f275cdafe42932dcc0460ae508843
Author: Stefano Karapetsas <stefano karapetsas com>
Date: Wed Dec 12 16:02:31 2012 +0100
main-menu: port to libmatepanelapplet-4.0 and DBUS
main-menu/etc/GNOME_MainMenu_ContextMenu.xml | 10 +--
main-menu/etc/Makefile.am | 31 +++++--
.../org.mate.GNOMEMainMenu.mate-panel-applet.in.in | 11 +++
...te.panel.applet.GNOMEMainMenuFactory.service.in | 3 +
main-menu/src/Makefile.am | 4 +-
main-menu/src/main-menu-ui.c | 86 ++++++++++++--------
main-menu/src/main-menu-ui.h | 4 +-
main-menu/src/main-menu.c | 12 ++-
8 files changed, 102 insertions(+), 59 deletions(-)
---
diff --git a/main-menu/etc/GNOME_MainMenu_ContextMenu.xml b/main-menu/etc/GNOME_MainMenu_ContextMenu.xml
index caa2214..2f32fc2 100644
--- a/main-menu/etc/GNOME_MainMenu_ContextMenu.xml
+++ b/main-menu/etc/GNOME_MainMenu_ContextMenu.xml
@@ -1,8 +1,2 @@
-<Root>
- <popups>
- <popup name="button3">
- <menuitem name="Main Menu Open Item" verb="MainMenuOpen" _label="_Open Menu" pixtype="stock" pixname="gnome-fs-client"/>
- <menuitem name="Main Menu About Item" verb="MainMenuAbout" _label="_About" pixtype="stock" pixname="gnome-stock-about"/>
- </popup>
- </popups>
-</Root>
+<menuitem name="MainMenuOpen" action="MainMenuOpen" />
+<menuitem name="MainMenuAbout" action="MainMenuAbout" />
diff --git a/main-menu/etc/Makefile.am b/main-menu/etc/Makefile.am
index e568213..412b5ab 100644
--- a/main-menu/etc/Makefile.am
+++ b/main-menu/etc/Makefile.am
@@ -1,6 +1,22 @@
-serverdir = $(libdir)/bonobo/servers
-server_DATA = GNOME_MainMenu.server
- INTLTOOL_SERVER_RULE@
+appletdir = $(datadir)/mate-panel/applets
+applet_in_files = org.mate.GNOMEMainMenu.mate-panel-applet.in
+applet_DATA = $(applet_in_files:.mate-panel-applet.in=.mate-panel-applet)
+
+$(applet_in_files): $(applet_in_files).in Makefile
+ $(AM_V_GEN) $(SED) \
+ -e "s|\ LIBEXECDIR\@|$(libexecdir)|" \
+ $< > $@
+
+%.mate-panel-applet: %.mate-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.mate.panel.applet.GNOMEMainMenuFactory.service.in
+service_DATA = $(service_in_files:.service.in=.service)
+
+org.mate.panel.applet.GNOMEMainMenuFactory.service: $(service_in_files)
+ $(AM_V_GEN) $(SED) \
+ -e "s|\ LIBEXECDIR\@|$(libexecdir)|" \
+ $< > $@
@INTLTOOL_XML_NOMERGE_RULE@
gsettings_SCHEMAS = org.mate.gnome-main-menu.gschema.xml
@@ -9,7 +25,7 @@ gsettings_SCHEMAS = org.mate.gnome-main-menu.gschema.xml
%.gschema.xml.in: %.gschema.xml.in.in Makefile
$(AM_V_GEN) $(SED) -e 's^\ DATADIR\@^$(datadir)^g' -e 's^\ GETTEXT_PACKAGE\@^$(GETTEXT_PACKAGE)^g' < $< > $@
-uidir = $(datadir)/gnome-2.0/ui
+uidir = $(datadir)/$(PACKAGE)
ui_DATA = GNOME_MainMenu_ContextMenu.xml
desktop_helperdir = $(datadir)/applications
@@ -28,12 +44,9 @@ systemitems_DATA = system-items.xbel
$(desktop_DATA).in: $(desktop_DATA).in.in
sed -e "s|\ BINDIR\@|$(bindir)|" $< > $@
-$(server_DATA).in: $(server_DATA).in.in
- sed -e "s|\ LIBEXECDIR\@|$(libexecdir)|" $< > $@
-
$(systemitems_DATA): $(systemitems_DATA).in
sed -e "s|_title>|title>|g" $< > $@
-EXTRA_DIST = $(server_DATA).in.in $(gsettings_SCHEMAS).in.in $(ui_DATA) $(desktop_helper_DATA) $(desktop_DATA).in.in $(bookmark_DATA) $(systemitems_DATA).in
+EXTRA_DIST = $(service_in_files) $(gsettings_SCHEMAS).in.in $(ui_DATA) $(desktop_helper_DATA) $(desktop_DATA).in.in $(bookmark_DATA) $(systemitems_DATA).in
-CLEANFILES = $(server_DATA) $(gsettings_SCHEMAS) $(server_DATA).in $(gsettings_SCHEMAS).in $(systemitems_DATA) $(desktop_DATA) $(desktop_DATA).in
+CLEANFILES = org.mate.panel.applet.GNOMEMainMenuFactory.service $(gsettings_SCHEMAS) $(gsettings_SCHEMAS).in $(systemitems_DATA) $(desktop_DATA) $(desktop_DATA).in
diff --git a/main-menu/etc/org.mate.GNOMEMainMenu.mate-panel-applet.in.in b/main-menu/etc/org.mate.GNOMEMainMenu.mate-panel-applet.in.in
new file mode 100644
index 0000000..df97869
--- /dev/null
+++ b/main-menu/etc/org.mate.GNOMEMainMenu.mate-panel-applet.in.in
@@ -0,0 +1,11 @@
+[Applet Factory]
+Id=GNOMEMainMenuFactory
+Location= LIBEXECDIR@/main-menu
+_Name=GNOME Main Menu Factory
+_Description=Factory for the GNOME Main Menu applet
+
+[GNOMEMainMenu]
+_Name=GNOME Main Menu
+_Description=Default menu and application browser
+Icon=computer
+MateComponentId=OAFIID:GNOME_MainMenu
diff --git a/main-menu/etc/org.mate.panel.applet.GNOMEMainMenuFactory.service.in b/main-menu/etc/org.mate.panel.applet.GNOMEMainMenuFactory.service.in
new file mode 100644
index 0000000..1e7f070
--- /dev/null
+++ b/main-menu/etc/org.mate.panel.applet.GNOMEMainMenuFactory.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.mate.panel.applet.GNOMEMainMenuFactory
+Exec=/usr/lib/gnome-main-menu/main-menu
diff --git a/main-menu/src/Makefile.am b/main-menu/src/Makefile.am
index 2830f47..f62a43f 100644
--- a/main-menu/src/Makefile.am
+++ b/main-menu/src/Makefile.am
@@ -12,7 +12,9 @@ bin_PROGRAMS = trigger-panel-run-dialog
AM_CPPFLAGS = \
-DDATADIR=\""$(datadir)"\" \
- -DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
+ -DUIDIR=\""$(uidir)"\" \
+ -DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
+ -DMATELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
main_menu_SOURCES = \
main-menu.c \
diff --git a/main-menu/src/main-menu-ui.c b/main-menu/src/main-menu-ui.c
index d086a41..c7e529e 100644
--- a/main-menu/src/main-menu-ui.c
+++ b/main-menu/src/main-menu-ui.c
@@ -24,7 +24,7 @@
# include <config.h>
#endif
-#include <panel-applet.h>
+#include <mate-panel-applet.h>
#include <cairo.h>
#include <string.h>
#include <libxml/parser.h>
@@ -32,6 +32,8 @@
#include <gdk/gdkkeysyms.h>
#include <X11/Xlib.h>
#include <gdk/gdkx.h>
+#include <glib.h>
+#include <glib/gi18n.h>
#include <gio/gio.h>
#include <gio/gdesktopappinfo.h>
#include <unistd.h>
@@ -81,7 +83,7 @@
G_DEFINE_TYPE (MainMenuUI, main_menu_ui, G_TYPE_OBJECT)
typedef struct {
- PanelApplet *panel_applet;
+ MatePanelApplet *panel_applet;
GtkWidget *panel_about_dialog;
GtkBuilder *main_menu_ui;
@@ -202,10 +204,10 @@ static void more_buttons_clicked_cb (GtkButton *, gpointer);
static void search_cmd_notify_cb (GSettings *, gchar *, gpointer);
static void current_page_notify_cb (GSettings *, gchar *, gpointer);
static void lockdown_notify_cb (GSettings *, gchar *, gpointer);
-static void panel_menu_open_cb (BonoboUIComponent *, gpointer, const gchar *);
-static void panel_menu_about_cb (BonoboUIComponent *, gpointer, const gchar *);
-static void panel_applet_change_orient_cb (PanelApplet *, PanelAppletOrient, gpointer);
-static void panel_applet_change_background_cb (PanelApplet *, PanelAppletBackgroundType, GdkColor *,
+static void panel_menu_open_cb (GtkAction *, gpointer);
+static void panel_menu_about_cb (GtkAction *, gpointer);
+static void panel_applet_change_orient_cb (MatePanelApplet *, MatePanelAppletOrient, gpointer);
+static void panel_applet_change_background_cb (MatePanelApplet *, MatePanelAppletBackgroundType, GdkColor *,
GdkPixmap * pixmap, gpointer);
static void slab_window_tomboy_bindkey_cb (gchar *, gpointer);
static void search_tomboy_bindkey_cb (gchar *, gpointer);
@@ -216,10 +218,13 @@ static void volume_monitor_mount_cb (GVolumeMonitor *, GMount *, g
static GdkFilterReturn slab_gdk_message_filter (GdkXEvent *, GdkEvent *, gpointer);
-static const BonoboUIVerb applet_bonobo_verbs [] = {
- BONOBO_UI_UNSAFE_VERB ("MainMenuOpen", panel_menu_open_cb),
- BONOBO_UI_UNSAFE_VERB ("MainMenuAbout", panel_menu_about_cb),
- BONOBO_UI_VERB_END
+static const GtkActionEntry applet_actions [] = {
+ { "MainMenuOpen", GTK_STOCK_OPEN, N_("_Open Menu"),
+ NULL, NULL,
+ G_CALLBACK (panel_menu_open_cb) },
+ { "MainMenuAbout", GTK_STOCK_ABOUT, N_("_About"),
+ NULL, NULL,
+ G_CALLBACK (panel_menu_about_cb) }
};
static const gchar *main_menu_authors [] = {
@@ -308,7 +313,7 @@ main_menu_delayed_setup (MainMenuUI *this)
}
MainMenuUI *
-main_menu_ui_new (PanelApplet *applet)
+main_menu_ui_new (MatePanelApplet *applet)
{
MainMenuUI *this;
MainMenuUIPrivate *priv;
@@ -474,6 +479,9 @@ create_panel_button (MainMenuUI *this)
GtkWidget *button_root;
GtkWidget *button_parent;
+ GtkActionGroup* action_group;
+ gchar* ui_path;
+
gint i;
@@ -525,13 +533,18 @@ create_panel_button (MainMenuUI *this)
gtk_widget_destroy (button_root);
- panel_applet_set_flags (priv->panel_applet, PANEL_APPLET_EXPAND_MINOR);
+ mate_panel_applet_set_flags (priv->panel_applet, MATE_PANEL_APPLET_EXPAND_MINOR);
reorient_panel_button (this);
- panel_applet_setup_menu_from_file (
- priv->panel_applet, NULL, "GNOME_MainMenu_ContextMenu.xml",
- NULL, applet_bonobo_verbs, this);
+ action_group = gtk_action_group_new ("GNOME MainMenu Applet Actions");
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (action_group,
+ applet_actions, G_N_ELEMENTS (applet_actions), this);
+ ui_path = g_build_filename (UIDIR, "GNOME_MainMenu_ContextMenu.xml", NULL);
+ mate_panel_applet_setup_menu_from_file (priv->panel_applet, ui_path, action_group);
+ g_free (ui_path);
+ g_object_unref (action_group);
g_signal_connect (
G_OBJECT (priv->panel_applet), "change_orient",
@@ -927,7 +940,7 @@ setup_lock_down (MainMenuUI *this)
G_CALLBACK (lockdown_notify_cb), this);
g_signal_connect (priv->mate_lockdown_settings, "changed::" DISABLE_LOCKSCREEN_SETTINGS_KEY,
G_CALLBACK (lockdown_notify_cb), this);
- g_signal_connect (priv->panel_settings, "changed:" DISABLE_LOGOUT_SETTINGS_KEY.
+ g_signal_connect (priv->panel_settings, "changed:" DISABLE_LOGOUT_SETTINGS_KEY,
G_CALLBACK (lockdown_notify_cb), this);
}
@@ -1232,7 +1245,7 @@ app_is_in_blacklist (const gchar *uri, MainMenuUI *this)
blacklist = g_settings_get_strv (priv->filearea_settings, APP_BLACKLIST_SETTINGS_KEY);
- for (i = 0; blacklist[i] != NULL, i++) {
+ for (i = 0; blacklist[i] != NULL; i++) {
if (! blacklisted && strstr (uri, blacklist[i]))
blacklisted = TRUE;
}
@@ -1448,8 +1461,13 @@ get_search_argv (const gchar *search_txt)
gint i;
+ GSettings *settings = NULL;
+
+ settings = g_settings_new (SETTINGS_SCHEMA);
+
+ cmd = g_settings_get_string (settings, SEARCH_CMD_SETTINGS_KEY);
- cmd = g_settings_get_string (priv->settings, SEARCH_CMD_SETTINGS_KEY);
+ g_object_unref (settings);
if (! cmd) {
g_warning ("could not find search command in gsettings [" SEARCH_CMD_SETTINGS_KEY "]\n");
@@ -1484,12 +1502,12 @@ reorient_panel_button (MainMenuUI *this)
{
MainMenuUIPrivate *priv = PRIVATE (this);
- PanelAppletOrient orientation;
+ MatePanelAppletOrient orientation;
GtkWidget *child;
- orientation = panel_applet_get_orient (priv->panel_applet);
+ orientation = mate_panel_applet_get_orient (priv->panel_applet);
child = gtk_bin_get_child (GTK_BIN (priv->panel_applet));
@@ -1497,15 +1515,15 @@ reorient_panel_button (MainMenuUI *this)
gtk_container_remove (GTK_CONTAINER (priv->panel_applet), child);
switch (orientation) {
- case PANEL_APPLET_ORIENT_LEFT:
+ case MATE_PANEL_APPLET_ORIENT_LEFT:
priv->panel_button = priv->panel_buttons [PANEL_BUTTON_ORIENT_RIGHT];
break;
- case PANEL_APPLET_ORIENT_RIGHT:
+ case MATE_PANEL_APPLET_ORIENT_RIGHT:
priv->panel_button = priv->panel_buttons [PANEL_BUTTON_ORIENT_LEFT];
break;
- case PANEL_APPLET_ORIENT_UP:
+ case MATE_PANEL_APPLET_ORIENT_UP:
priv->panel_button = priv->panel_buttons [PANEL_BUTTON_ORIENT_BOTTOM];
break;
@@ -2094,7 +2112,7 @@ slab_window_allocate_cb (GtkWidget *widget, GtkAllocation *alloc, gpointer user_
GdkRectangle slab_geom;
GdkRectangle monitor_geom;
- PanelAppletOrient orient;
+ MatePanelAppletOrient orient;
gdk_window_get_origin (GTK_WIDGET (priv->panel_button)->window, & button_geom.x, & button_geom.y);
@@ -2112,25 +2130,25 @@ slab_window_allocate_cb (GtkWidget *widget, GtkAllocation *alloc, gpointer user_
panel_button_screen, GTK_WIDGET (priv->panel_button)->window),
& monitor_geom);
- orient = panel_applet_get_orient (priv->panel_applet);
+ orient = mate_panel_applet_get_orient (priv->panel_applet);
switch (orient) {
- case PANEL_APPLET_ORIENT_UP:
+ case MATE_PANEL_APPLET_ORIENT_UP:
slab_geom.x = button_geom.x;
slab_geom.y = button_geom.y - slab_geom.height;
break;
- case PANEL_APPLET_ORIENT_DOWN:
+ case MATE_PANEL_APPLET_ORIENT_DOWN:
slab_geom.x = button_geom.x;
slab_geom.y = button_geom.y + button_geom.height;
break;
- case PANEL_APPLET_ORIENT_RIGHT:
+ case MATE_PANEL_APPLET_ORIENT_RIGHT:
slab_geom.x = button_geom.x + button_geom.width;
slab_geom.y = button_geom.y;
break;
- case PANEL_APPLET_ORIENT_LEFT:
+ case MATE_PANEL_APPLET_ORIENT_LEFT:
slab_geom.x = button_geom.x - slab_geom.width;
slab_geom.y = button_geom.y;
break;
@@ -2141,7 +2159,7 @@ slab_window_allocate_cb (GtkWidget *widget, GtkAllocation *alloc, gpointer user_
break;
}
- if (orient == PANEL_APPLET_ORIENT_UP || orient == PANEL_APPLET_ORIENT_DOWN) {
+ if (orient == MATE_PANEL_APPLET_ORIENT_UP || orient == MATE_PANEL_APPLET_ORIENT_DOWN) {
if ((slab_geom.x + slab_geom.width) > (monitor_geom.x + monitor_geom.width))
slab_geom.x = MAX (monitor_geom.x, monitor_geom.x + monitor_geom.width - slab_geom.width);
}
@@ -2363,13 +2381,13 @@ lockdown_notify_cb (GSettings *settings, gchar *key, gpointer user_data)
}
static void
-panel_menu_open_cb (BonoboUIComponent *component, gpointer user_data, const gchar *verb)
+panel_menu_open_cb (GtkAction *action, gpointer user_data)
{
gtk_toggle_button_set_active (PRIVATE (user_data)->panel_button, TRUE);
}
static void
-panel_menu_about_cb (BonoboUIComponent *component, gpointer user_data, const gchar *verb)
+panel_menu_about_cb (GtkAction *action, gpointer user_data)
{
MainMenuUI *this = MAIN_MENU_UI (user_data);
MainMenuUIPrivate *priv = PRIVATE (this);
@@ -2399,13 +2417,13 @@ panel_menu_about_cb (BonoboUIComponent *component, gpointer user_data, const gch
}
static void
-panel_applet_change_orient_cb (PanelApplet *applet, PanelAppletOrient orient, gpointer user_data)
+panel_applet_change_orient_cb (MatePanelApplet *applet, MatePanelAppletOrient orient, gpointer user_data)
{
reorient_panel_button (MAIN_MENU_UI (user_data));
}
static void
-panel_applet_change_background_cb (PanelApplet *applet, PanelAppletBackgroundType type, GdkColor *color,
+panel_applet_change_background_cb (MatePanelApplet *applet, MatePanelAppletBackgroundType type, GdkColor *color,
GdkPixmap *pixmap, gpointer user_data)
{
MainMenuUI *this = MAIN_MENU_UI (user_data);
diff --git a/main-menu/src/main-menu-ui.h b/main-menu/src/main-menu-ui.h
index eeeb518..e972ed2 100644
--- a/main-menu/src/main-menu-ui.h
+++ b/main-menu/src/main-menu-ui.h
@@ -22,7 +22,7 @@
#define __MAIN_MENU_COMMON_H__
#include <gtk/gtk.h>
-#include <panel-applet.h>
+#include <mate-panel-applet.h>
G_BEGIN_DECLS
@@ -43,7 +43,7 @@ typedef struct {
GType main_menu_ui_get_type (void);
-MainMenuUI *main_menu_ui_new (PanelApplet *applet);
+MainMenuUI *main_menu_ui_new (MatePanelApplet *applet);
G_END_DECLS
diff --git a/main-menu/src/main-menu.c b/main-menu/src/main-menu.c
index 7694303..34648ea 100644
--- a/main-menu/src/main-menu.c
+++ b/main-menu/src/main-menu.c
@@ -23,29 +23,31 @@
#endif
#include <glib.h>
-#include <panel-applet.h>
+#include <glib/gi18n.h>
+#include <mate-panel-applet.h>
#include <string.h>
#include <libslab/slab.h>
#include "main-menu-ui.h"
-static gboolean main_menu_applet_init (PanelApplet *, const gchar *, gpointer);
+static gboolean main_menu_applet_init (MatePanelApplet *, const gchar *, gpointer);
-PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_MainMenu_Factory", PANEL_TYPE_APPLET, "Main Menu", "0",
+
+MATE_PANEL_APPLET_OUT_PROCESS_FACTORY ("GNOMEMainMenuFactory", PANEL_TYPE_APPLET, "Main Menu",
main_menu_applet_init, NULL);
#define CHECKPOINT_CONFIG_BASENAME "main-menu-checkpoint.conf"
#define CHECKPOINT_FILE_BASENAME "main-menu"
static gboolean
-main_menu_applet_init (PanelApplet *applet, const gchar *iid, gpointer user_data)
+main_menu_applet_init (MatePanelApplet *applet, const gchar *iid, gpointer user_data)
{
libslab_checkpoint_init (CHECKPOINT_CONFIG_BASENAME, CHECKPOINT_FILE_BASENAME);
libslab_checkpoint ("Main-menu starts up");
- if (strcmp (iid, "OAFIID:GNOME_MainMenu") != 0)
+ if (strcmp (iid, "GNOMEMainMenu") != 0)
return FALSE;
#ifdef ENABLE_NLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]