Skip to content

Commit b6372ca

Browse files
vuntzraveit65
authored andcommitted
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
1 parent 45b2541 commit b6372ca

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ AC_PROG_LIBTOOL
3030
AM_PROG_CC_C_O
3131

3232
AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
33+
AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)
3334
AC_PATH_PROG([GDBUS_CODEGEN], [gdbus-codegen])
3435

3536
MATE_COMPILE_WARNINGS(maximum)

libmate-panel-applet/mate-panel-applet.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,46 @@ mate_panel_applet_setup_menu_from_file (MatePanelApplet *applet,
711711
g_free (xml);
712712
}
713713

714+
/**
715+
* mate_panel_applet_setup_menu_from_resource:
716+
* @applet: a #MatePanelApplet.
717+
* @resource_path: a resource path
718+
* @action_group: a #GtkActionGroup.
719+
*
720+
* Sets up the context menu of @applet. @filename is a resource path to a menu
721+
* XML file, containing a #GtkUIManager UI definition that describes how to
722+
* display the menu items. @action_group contains the various #GtkAction that
723+
* are referenced in @xml.
724+
*
725+
* See also the <link linkend="getting-started.context-menu">Context
726+
* Menu</link> section.
727+
*
728+
* Since: 1.20.1
729+
**/
730+
void
731+
mate_panel_applet_setup_menu_from_resource (MatePanelApplet *applet,
732+
const gchar *resource_path,
733+
GtkActionGroup *action_group)
734+
{
735+
GBytes *bytes;
736+
GError *error = NULL;
737+
738+
bytes = g_resources_lookup_data (resource_path,
739+
G_RESOURCE_LOOKUP_FLAGS_NONE,
740+
&error);
741+
742+
if (bytes) {
743+
mate_panel_applet_setup_menu (applet,
744+
g_bytes_get_data (bytes, NULL),
745+
action_group);
746+
} else {
747+
g_warning ("%s", error->message);
748+
g_error_free (error);
749+
}
750+
751+
g_bytes_unref (bytes);
752+
}
753+
714754
static void
715755
mate_panel_applet_finalize (GObject *object)
716756
{

libmate-panel-applet/mate-panel-applet.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ void mate_panel_applet_request_focus(MatePanelApplet* applet, guint32 timestamp)
111111

112112
void mate_panel_applet_setup_menu(MatePanelApplet* applet, const gchar* xml, GtkActionGroup* action_group);
113113
void mate_panel_applet_setup_menu_from_file(MatePanelApplet* applet, const gchar* filename, GtkActionGroup* action_group);
114+
void mate_panel_applet_setup_menu_from_resource (MatePanelApplet *applet,
115+
const gchar *resource_path,
116+
GtkActionGroup *action_group);
114117

115118
int mate_panel_applet_factory_main(const gchar* factory_id,gboolean out_process, GType applet_type, MatePanelAppletFactoryCallback callback, gpointer data);
116119

0 commit comments

Comments
 (0)