void
nautilus_navigation_window_load_extension_toolbar_items (NautilusNavigationWindow *window)
{
	GtkActionGroup *action_group;
	GtkAction *action;
	GtkUIManager *ui_manager;
	GList *items;
	GList *l;
	NautilusMenuItem *item;
	guint merge_id;

	ui_manager = nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window));
	if (window->details->extensions_toolbar_merge_id != 0) {
		gtk_ui_manager_remove_ui (ui_manager,
					  window->details->extensions_toolbar_merge_id);
		window->details->extensions_toolbar_merge_id = 0;
	}

	if (window->details->extensions_toolbar_action_group != NULL) {
		gtk_ui_manager_remove_action_group (ui_manager,
						    window->details->extensions_toolbar_action_group);
		window->details->extensions_toolbar_action_group = NULL;
	}
	
	merge_id = gtk_ui_manager_new_merge_id (ui_manager);
	window->details->extensions_toolbar_merge_id = merge_id;
	action_group = gtk_action_group_new ("ExtensionsToolbarGroup");
	window->details->extensions_toolbar_action_group = action_group;
	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
	gtk_ui_manager_insert_action_group (ui_manager, action_group, -1);
	g_object_unref (action_group); /* owned by ui manager */

	items = get_extension_toolbar_items (window);

	for (l = items; l != NULL; l = l->next) {
		item = NAUTILUS_MENU_ITEM (l->data);

		action = nautilus_toolbar_action_from_menu_item (item);

		gtk_action_group_add_action (action_group,
					     GTK_ACTION (action));
		g_object_unref (action);
		
		gtk_ui_manager_add_ui (ui_manager,
				       merge_id,
				       TOOLBAR_PATH_EXTENSION_ACTIONS,
				       gtk_action_get_name (action),
				       gtk_action_get_name (action),
				       GTK_UI_MANAGER_TOOLITEM,
				       FALSE);

		g_object_unref (item);
	}

	g_list_free (items);
}
Esempio n. 2
0
static void
nautilus_menu_item_set_property (GObject *object,
				 guint param_id,
				 const GValue *value,
				 GParamSpec *pspec)
{
	NautilusMenuItem *item;
	
	item = NAUTILUS_MENU_ITEM (object);

	switch (param_id) {
	case PROP_NAME :
		g_free (item->details->name);
		item->details->name = g_strdup (g_value_get_string (value));
		g_object_notify (object, "name");
		break;
	case PROP_LABEL :
		g_free (item->details->label);
		item->details->label = g_strdup (g_value_get_string (value));
		g_object_notify (object, "label");
		break;
	case PROP_TIP :
		g_free (item->details->tip);
		item->details->tip = g_strdup (g_value_get_string (value));
		g_object_notify (object, "tip");
		break;
	case PROP_ICON :
		g_free (item->details->icon);
		item->details->icon = g_strdup (g_value_get_string (value));
		g_object_notify (object, "icon");
		break;
	case PROP_SENSITIVE :
		item->details->sensitive = g_value_get_boolean (value);
		g_object_notify (object, "sensitive");
		break;
	case PROP_PRIORITY :
		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;
	}
}
Esempio n. 3
0
static void
nautilus_menu_item_finalize (GObject *object)
{
	NautilusMenuItem *item;

	item = NAUTILUS_MENU_ITEM (object);

	g_free (item->details->name);
	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);

	G_OBJECT_CLASS (parent_class)->finalize (object);
}
Esempio n. 4
0
static void
nautilus_menu_item_get_property (GObject *object,
				 guint param_id,
				 GValue *value,
				 GParamSpec *pspec)
{
	NautilusMenuItem *item;
	
	item = NAUTILUS_MENU_ITEM (object);
	
	switch (param_id) {
	case PROP_NAME :
		g_value_set_string (value, item->details->name);
		break;
	case PROP_LABEL :
		g_value_set_string (value, item->details->label);
		break;
	case PROP_TIP :
		g_value_set_string (value, item->details->tip);
		break;
	case PROP_ICON :
		g_value_set_string (value, item->details->icon);
		break;
	case PROP_SENSITIVE :
		g_value_set_boolean (value, item->details->sensitive);
		break;
	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;
	}
}
static void
add_extension_menu_items (NautilusWindow *window,
			  guint merge_id,
			  GtkActionGroup *action_group,
			  GList *menu_items,
			  const char *subdirectory)
{
	GtkUIManager *ui_manager;
	GList *l;

	ui_manager = window->details->ui_manager;
	
	for (l = menu_items; l; l = l->next) {
		NautilusMenuItem *item;
		NautilusMenu *menu;
		GtkAction *action;
		char *path;
		
		item = NAUTILUS_MENU_ITEM (l->data);
		
		g_object_get (item, "menu", &menu, NULL);
		
		action = nautilus_action_from_menu_item (item);
		gtk_action_group_add_action_with_accel (action_group, action, NULL);
		
		path = g_build_path ("/", POPUP_PATH_EXTENSION_ACTIONS, subdirectory, NULL);
		gtk_ui_manager_add_ui (ui_manager,
				       merge_id,
				       path,
				       gtk_action_get_name (action),
				       gtk_action_get_name (action),
				       (menu != NULL) ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM,
				       FALSE);
		g_free (path);

		path = g_build_path ("/", MENU_PATH_EXTENSION_ACTIONS, subdirectory, NULL);
		gtk_ui_manager_add_ui (ui_manager,
				       merge_id,
				       path,
				       gtk_action_get_name (action),
				       gtk_action_get_name (action),
				       (menu != NULL) ? GTK_UI_MANAGER_MENU : GTK_UI_MANAGER_MENUITEM,
				       FALSE);
		g_free (path);

		/* recursively fill the menu */		       
		if (menu != NULL) {
			char *subdir;
			GList *children;
			
			children = nautilus_menu_get_items (menu);
			
			subdir = g_build_path ("/", subdirectory, "/", gtk_action_get_name (action), NULL);
			add_extension_menu_items (window,
						  merge_id,
						  action_group,
						  children,
						  subdir);

			nautilus_menu_item_list_free (children);
			g_free (subdir);
		}			
	}
}
static void
extension_action_callback (GtkAction *action,
			   gpointer callback_data)
{
	nautilus_menu_item_activate (NAUTILUS_MENU_ITEM (callback_data));
}