summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Untz <[email protected]>2012-02-02 09:12:03 +0100
committerraveit65 <[email protected]>2018-04-26 13:04:23 +0200
commit0b9863fb7c09681c4c62d6c12a199bb4ddffefd2 (patch)
tree559a00ca8c1f51c4fd503f9539cb0b758a4814ee
parent36a36ddcf5698324317d7598cee0da52e69b829b (diff)
downloadmate-panel-0b9863fb7c09681c4c62d6c12a199bb4ddffefd2.tar.bz2
mate-panel-0b9863fb7c09681c4c62d6c12a199bb4ddffefd2.tar.xz
libpanel-applet: Add panel_applet_setup_menu_from_resource() API
Add API to be able to use the new GResource framework. origin commit: https://git.gnome.org/browse/gnome-panel/commit/?id=182cefd
-rw-r--r--configure.ac1
-rw-r--r--libmate-panel-applet/mate-panel-applet.c40
-rw-r--r--libmate-panel-applet/mate-panel-applet.h3
3 files changed, 44 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index f0887585..21cabbb1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,6 +30,7 @@ AC_PROG_LIBTOOL
AM_PROG_CC_C_O
AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
+AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)
AC_PATH_PROG([GDBUS_CODEGEN], [gdbus-codegen])
MATE_COMPILE_WARNINGS(maximum)
diff --git a/libmate-panel-applet/mate-panel-applet.c b/libmate-panel-applet/mate-panel-applet.c
index a1b49122..ec481ccf 100644
--- a/libmate-panel-applet/mate-panel-applet.c
+++ b/libmate-panel-applet/mate-panel-applet.c
@@ -711,6 +711,46 @@ mate_panel_applet_setup_menu_from_file (MatePanelApplet *applet,
g_free (xml);
}
+/**
+ * mate_panel_applet_setup_menu_from_resource:
+ * @applet: a #MatePanelApplet.
+ * @resource_path: a resource path
+ * @action_group: a #GtkActionGroup.
+ *
+ * Sets up the context menu of @applet. @filename is a resource path to a menu
+ * XML file, containing a #GtkUIManager UI definition that describes how to
+ * display the menu items. @action_group contains the various #GtkAction that
+ * are referenced in @xml.
+ *
+ * See also the <link linkend="getting-started.context-menu">Context
+ * Menu</link> section.
+ *
+ * Since: 1.20.1
+ **/
+void
+mate_panel_applet_setup_menu_from_resource (MatePanelApplet *applet,
+ const gchar *resource_path,
+ GtkActionGroup *action_group)
+{
+ GBytes *bytes;
+ GError *error = NULL;
+
+ bytes = g_resources_lookup_data (resource_path,
+ G_RESOURCE_LOOKUP_FLAGS_NONE,
+ &error);
+
+ if (bytes) {
+ mate_panel_applet_setup_menu (applet,
+ g_bytes_get_data (bytes, NULL),
+ action_group);
+ } else {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+
+ g_bytes_unref (bytes);
+}
+
static void
mate_panel_applet_finalize (GObject *object)
{
diff --git a/libmate-panel-applet/mate-panel-applet.h b/libmate-panel-applet/mate-panel-applet.h
index f231cb80..931a681f 100644
--- a/libmate-panel-applet/mate-panel-applet.h
+++ b/libmate-panel-applet/mate-panel-applet.h
@@ -111,6 +111,9 @@ void mate_panel_applet_request_focus(MatePanelApplet* applet, guint32 timestamp)
void mate_panel_applet_setup_menu(MatePanelApplet* applet, const gchar* xml, GtkActionGroup* action_group);
void mate_panel_applet_setup_menu_from_file(MatePanelApplet* applet, const gchar* filename, GtkActionGroup* action_group);
+void mate_panel_applet_setup_menu_from_resource (MatePanelApplet *applet,
+ const gchar *resource_path,
+ GtkActionGroup *action_group);
int mate_panel_applet_factory_main(const gchar* factory_id,gboolean out_process, GType applet_type, MatePanelAppletFactoryCallback callback, gpointer data);