Commit a98fef54 authored by Alberts Muktupāvels's avatar Alberts Muktupāvels

menu: add right click menu

parent 8171e207
......@@ -33,6 +33,7 @@ menu_la_SOURCES = \
gp-menu.h \
gp-user-menu-applet.c \
gp-user-menu-applet.h \
$(BUILT_SOURCES) \
$(NULL)
menu_la_LIBADD = \
......@@ -47,4 +48,32 @@ menu_la_LDFLAGS = \
$(AM_LDFLAGS) \
$(NULL)
menu_resources := $(shell $(GLIB_COMPILE_RESOURCES) \
--sourcedir=$(srcdir) --generate-dependencies \
$(srcdir)/menu.gresource.xml)
menu-resources.c: $(srcdir)/menu.gresource.xml $(menu_resources)
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ \
--sourcedir=$(srcdir) --generate-source --c-name menu \
$(srcdir)/menu.gresource.xml
menu-resources.h: $(srcdir)/menu.gresource.xml $(menu_resources)
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ \
--sourcedir=$(srcdir) --generate-header --c-name menu \
$(srcdir)/menu.gresource.xml
BUILT_SOURCES = \
menu-resources.c \
menu-resources.h \
$(NULL)
EXTRA_DIST = \
menu.gresource.xml \
$(menu_resources) \
$(NULL)
CLEANFILES = \
$(BUILT_SOURCES) \
$(NULL)
-include $(top_srcdir)/git.mk
......@@ -16,21 +16,104 @@
*/
#include "config.h"
#include <glib/gi18n-lib.h>
#include "gp-main-menu-applet.h"
#include "gp-menu-utils.h"
#define RESOURCE_PATH "/org/gnome/gnome-panel/modules/menu"
struct _MainMenuApplet
struct _GpMainMenuApplet
{
GpApplet parent;
};
G_DEFINE_TYPE (MainMenuApplet, main_menu_applet, GP_TYPE_APPLET)
G_DEFINE_TYPE (GpMainMenuApplet, gp_main_menu_applet, GP_TYPE_APPLET)
static void
edit_menus_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
const gchar *application;
GDesktopAppInfo *app_info;
application = "alacarte.desktop";
app_info = g_desktop_app_info_new (application);
if (app_info == NULL)
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (NULL, 0,
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
_("Please install the '%s' application."),
application);
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_window_present (GTK_WINDOW (dialog));
return;
}
gp_menu_launch_app_info (app_info);
}
static const GActionEntry main_menu_menu_actions[] =
{
{ "edit-menus", edit_menus_cb, NULL, NULL, NULL },
{ NULL }
};
static void
setup_menu (GpMainMenuApplet *main_menu)
{
GpApplet *applet;
const gchar *resource;
GAction *action;
GBindingFlags flags;
applet = GP_APPLET (main_menu);
resource = RESOURCE_PATH "/main-menu-menu.ui";
gp_applet_setup_menu_from_resource (applet, resource, main_menu_menu_actions);
action = gp_applet_menu_lookup_action (applet, "edit-menus");
flags = G_BINDING_DEFAULT | G_BINDING_INVERT_BOOLEAN | G_BINDING_SYNC_CREATE;
g_object_bind_property (applet, "locked-down", action, "enabled", flags);
}
static void
gp_main_menu_applet_setup (GpMainMenuApplet *main_menu)
{
setup_menu (main_menu);
}
static void
main_menu_applet_class_init (MainMenuAppletClass *main_menu_class)
gp_main_menu_applet_constructed (GObject *object)
{
G_OBJECT_CLASS (gp_main_menu_applet_parent_class)->constructed (object);
gp_main_menu_applet_setup (GP_MAIN_MENU_APPLET (object));
}
static void
main_menu_applet_init (MainMenuApplet *main_menu)
gp_main_menu_applet_class_init (GpMainMenuAppletClass *main_menu_class)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (main_menu_class);
object_class->constructed = gp_main_menu_applet_constructed;
}
static void
gp_main_menu_applet_init (GpMainMenuApplet *main_menu)
{
GpApplet *applet;
applet = GP_APPLET (main_menu);
gp_applet_set_flags (applet, GP_APPLET_FLAGS_EXPAND_MINOR);
}
......@@ -15,16 +15,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MAIN_MENU_APPLET_H
#define MAIN_MENU_APPLET_H
#ifndef GP_MAIN_MENU_APPLET_H
#define GP_MAIN_MENU_APPLET_H
#include <libgnome-panel/gp-applet.h>
G_BEGIN_DECLS
#define MAIN_MENU_TYPE_APPLET (main_menu_applet_get_type ())
G_DECLARE_FINAL_TYPE (MainMenuApplet, main_menu_applet,
MAIN_MENU, APPLET, GpApplet)
#define GP_MAIN_MENU_TYPE_APPLET (gp_main_menu_applet_get_type ())
G_DECLARE_FINAL_TYPE (GpMainMenuApplet, gp_main_menu_applet,
GP, MAIN_MENU_APPLET, GpApplet)
G_END_DECLS
......
......@@ -22,8 +22,11 @@
#include "gp-menu-bar-applet.h"
#include "gp-menu-bar.h"
#include "gp-menu-utils.h"
#include "gp-menu.h"
#define RESOURCE_PATH "/org/gnome/gnome-panel/modules/menu"
struct _GpMenuBarApplet
{
GpApplet parent;
......@@ -86,6 +89,60 @@ append_applications_item (GpMenuBarApplet *applet)
G_CALLBACK (button_press_event_cb), NULL);
}
static void
edit_menus_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
const gchar *application;
GDesktopAppInfo *app_info;
application = "alacarte.desktop";
app_info = g_desktop_app_info_new (application);
if (app_info == NULL)
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (NULL, 0,
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
_("Please install the '%s' application."),
application);
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
gtk_window_present (GTK_WINDOW (dialog));
return;
}
gp_menu_launch_app_info (app_info);
}
static const GActionEntry menu_bar_menu_actions[] =
{
{ "edit-menus", edit_menus_cb, NULL, NULL, NULL },
{ NULL }
};
static void
setup_menu (GpMenuBarApplet *menu_bar)
{
GpApplet *applet;
const gchar *resource;
GAction *action;
GBindingFlags flags;
applet = GP_APPLET (menu_bar);
resource = RESOURCE_PATH "/menu-bar-menu.ui";
gp_applet_setup_menu_from_resource (applet, resource, menu_bar_menu_actions);
action = gp_applet_menu_lookup_action (applet, "edit-menus");
flags = G_BINDING_DEFAULT | G_BINDING_INVERT_BOOLEAN | G_BINDING_SYNC_CREATE;
g_object_bind_property (applet, "locked-down", action, "enabled", flags);
}
static void
gp_menu_bar_applet_setup (GpMenuBarApplet *menu_bar)
{
......@@ -102,6 +159,8 @@ gp_menu_bar_applet_setup (GpMenuBarApplet *menu_bar)
G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
append_applications_item (menu_bar);
setup_menu (menu_bar);
}
static void
......
......@@ -35,7 +35,7 @@ menu_get_applet_info (const gchar *id)
if (g_strcmp0 (id, "main-menu") == 0)
{
type_func = main_menu_applet_get_type;
type_func = gp_main_menu_applet_get_type;
name = _("Main Menu");
description = _("The main GNOME menu");
icon = "start-here";
......
<interface>
<menu id="main-menu-menu">
<section>
<item>
<attribute name="label" translatable="yes">_Edit Menus</attribute>
<attribute name="action">menu-menu.edit-menus</attribute>
</item>
</section>
</menu>
</interface>
<interface>
<menu id="menu-bar-menu">
<section>
<item>
<attribute name="label" translatable="yes">_Edit Menus</attribute>
<attribute name="action">menu-bar.edit-menus</attribute>
</item>
</section>
</menu>
</interface>
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/gnome-panel/modules/menu">
<file compressed="true">main-menu-menu.ui</file>
<file compressed="true">menu-bar-menu.ui</file>
</gresource>
</gresources>
......@@ -59,9 +59,12 @@ modules/fish/fish-applet.c
modules/fish/fish-module.c
modules/fish/fish-menu.ui
modules/fish/fish.ui
modules/menu/gp-main-menu-applet.c
modules/menu/gp-menu-bar-applet.c
modules/menu/gp-menu-module.c
modules/menu/gp-menu-utils.c
modules/menu/main-menu-menu.ui
modules/menu/menu-bar-menu.ui
modules/notification-area/na-applet.c
modules/notification-area/na-module.c
modules/notification-area/na-tray-manager.c
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment