summaryrefslogtreecommitdiff
path: root/libnautilus-extension/nautilus-menu-item.c
diff options
context:
space:
mode:
authorMartin Wehner <martin.wehner@gmail.com>2006-07-24 21:38:26 +0000
committerMartin Wehner <mwehner@src.gnome.org>2006-07-24 21:38:26 +0000
commit0a9fe18765d0376c3dcf544b1ca521300d76b7e1 (patch)
treedaa6ea05f83829acbe843cff74ad0f37eb112a87 /libnautilus-extension/nautilus-menu-item.c
parent8fa38099a1028f6904325c47d7960fcde9788159 (diff)
downloadnautilus-0a9fe18765d0376c3dcf544b1ca521300d76b7e1.tar.gz
Add extension versioning infrastructure and add nautilus-menu.[ch].
2006-07-24 Martin Wehner <martin.wehner@gmail.com> * configure.in: * libnautilus-extension/Makefile.am: Add extension versioning infrastructure and add nautilus-menu.[ch]. * libnautilus-extension/nautilus-menu-item.[ch]: Add and handle a 'menu' property and add a function nautilus_menu_item_set_submenu. * libnautilus-extension/nautilus-menu.[ch]: New files implementing a submenu item. * src/file-manager/fm-directory-view.c: (add_extension_menu_items), (reset_extension_actions_menu): Add extension menu items recursively. * libnautilus-extension/nautilus-menu-provider.h: Update include. Extend extension API to support submenus. (#314579) Patch from Raffaele Sandrini <rasa@gmx.ch>
Diffstat (limited to 'libnautilus-extension/nautilus-menu-item.c')
-rw-r--r--libnautilus-extension/nautilus-menu-item.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/libnautilus-extension/nautilus-menu-item.c b/libnautilus-extension/nautilus-menu-item.c
index 714562751..7012301d4 100644
--- a/libnautilus-extension/nautilus-menu-item.c
+++ b/libnautilus-extension/nautilus-menu-item.c
@@ -23,7 +23,7 @@
*/
#include <config.h>
-#include "nautilus-menu-item.h"
+#include "nautilus-menu.h"
#include "nautilus-extension-i18n.h"
enum {
@@ -39,6 +39,7 @@ enum {
PROP_ICON,
PROP_SENSITIVE,
PROP_PRIORITY,
+ PROP_MENU,
LAST_PROP
};
@@ -47,6 +48,7 @@ struct _NautilusMenuItemDetails {
char *label;
char *tip;
char *icon;
+ NautilusMenu *menu;
gboolean sensitive;
gboolean priority;
};
@@ -83,6 +85,12 @@ nautilus_menu_item_activate (NautilusMenuItem *item)
g_signal_emit (item, signals[ACTIVATE], 0);
}
+void
+nautilus_menu_item_set_submenu (NautilusMenuItem *item, NautilusMenu *menu)
+{
+ g_object_set (item, "menu", menu, NULL);
+}
+
static void
nautilus_menu_item_get_property (GObject *object,
guint param_id,
@@ -112,6 +120,9 @@ nautilus_menu_item_get_property (GObject *object,
case PROP_PRIORITY :
g_value_set_boolean (value, item->details->priority);
break;
+ case PROP_MENU :
+ g_value_set_object (value, item->details->menu);
+ break;
default :
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -157,6 +168,13 @@ nautilus_menu_item_set_property (GObject *object,
item->details->priority = g_value_get_boolean (value);
g_object_notify (object, "priority");
break;
+ case PROP_MENU :
+ if (item->details->menu) {
+ g_object_unref (item->details->menu);
+ }
+ item->details->menu = g_object_ref (g_value_get_object (value));
+ g_object_notify (object, "menu");
+ break;
default :
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -174,6 +192,9 @@ nautilus_menu_item_finalize (GObject *object)
g_free (item->details->label);
g_free (item->details->tip);
g_free (item->details->icon);
+ if (item->details->menu) {
+ g_object_unref (item->details->menu);
+ }
g_free (item->details);
@@ -185,6 +206,7 @@ nautilus_menu_item_instance_init (NautilusMenuItem *item)
{
item->details = g_new0 (NautilusMenuItemDetails, 1);
item->details->sensitive = TRUE;
+ item->details->menu = NULL;
}
static void
@@ -249,6 +271,13 @@ nautilus_menu_item_class_init (NautilusMenuItemClass *class)
"Show priority text in toolbars",
TRUE,
G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (class),
+ PROP_MENU,
+ g_param_spec_object ("menu",
+ "Menu",
+ "The menu belonging to this item. May be null.",
+ NAUTILUS_TYPE_MENU,
+ G_PARAM_READWRITE));
}
GType