[Thunar-dev] Creating a submenu in a thunar extension
Adam Plumb
adamplumb at gmail.com
Tue Dec 15 17:54:06 CET 2009
After digging in a bit more, the reason why thunar-vcs-plugin is able to
create submenus is because they register a new menu provider for each
submenu. While this works to a degree, I'd like to have more flexibility as
well as allow more than one level of submenus to be possible.
In order to get "real" submenus working for thunar extensions, the
thunar_standard_view_merge_custom_actions() function needs to be modified
and a new *_add_custom_actions function needs to be created to recursively
add submenus and submenu actions. Nautilus does something similar to this,
actually.
I've got a working patch for thunar that I will be submitting shortly.
Adam
On Mon, Dec 14, 2009 at 10:07 AM, Adam Plumb <adamplumb at gmail.com> wrote:
> I'm trying to create a simple submenu for a thunar extension, and I just
> can't get it to show up. The parent item shows up fine, but the submenu
> does not. Here is the get_file_actions code I'm using...
>
> static GList*
> twp_provider_get_file_actions (ThunarxMenuProvider *menu_provider,
> GtkWidget *window,
> GList *files)
> {
> GtkWidget *action = NULL;
> GList *actions = NULL;
> GtkWidget *item = NULL;
> GtkWidget *menu = NULL;
> GtkAction *subaction = NULL;
> GtkWidget *subitem = NULL;
>
> action = gtk_action_new("Txp::menuitem",
> NULL,
> "Menu Parent",
> NULL);
>
> item = gtk_action_create_menu_item(GTK_ACTION(action));
>
> menu = gtk_menu_new();
> gtk_menu_item_set_submenu(GTK_MENU_ITEM (item), menu);
>
> subaction = gtk_action_new("Txp::submenuitem",
> NULL,
> "Submenu Item",
> NULL);
> subitem = gtk_action_create_menu_item(GTK_ACTION(subaction));
> gtk_menu_shell_append(GTK_MENU_SHELL(menu), subitem);
> gtk_widget_show(subitem);
>
> actions = g_list_append (actions, action);
>
> return actions;
> }
>
> Can anyone tell me what I'm doing wrong?
>
> Thanks,
> Adam
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.xfce.org/pipermail/thunar-dev/attachments/20091215/e248dbe3/attachment.html>
More information about the Thunar-dev
mailing list