add open_node entry in context menu

This commit is contained in:
Matthias Martin 2020-03-31 18:46:15 +02:00
parent 131849191d
commit ada00fc5ba
1 changed files with 19 additions and 7 deletions

View File

@ -1467,6 +1467,22 @@ properties_cb( GtkWidget *unused, GNode *node )
dialog_node_properties( node );
}
/* open this filesystem node using xdg-open */
static void
open_node( GtkWidget *unused, GNode *node )
{
struct NodeInfo *node_info;
char strbuf[1024];
char strbuf1[1024];
int retval;
strcpy(strbuf,"xdg-open ");
node_info = get_node_info(node);
strcat (strbuf, node_info->prefix);
strcat (strbuf, "/");
strcat (strbuf, node_info->name);
system(strbuf);
}
void
context_menu( GNode *node, GdkEventButton *ev_button )
@ -1479,12 +1495,6 @@ context_menu( GNode *node, GdkEventButton *ev_button )
gtk_widget_destroy( popup_menu_w );
}
/* Check for the special case in which the menu has only one item */
if (!NODE_IS_DIR(node) && (node == globals.current_node)) {
dialog_node_properties( node );
return;
}
/* Create menu */
popup_menu_w = gtk_menu_new( );
if (NODE_IS_DIR(node)) {
@ -1499,6 +1509,8 @@ context_menu( GNode *node, GdkEventButton *ev_button )
if (node != globals.current_node)
gui_menu_item_add( popup_menu_w, _("Look at"), look_at_cb, node );
gui_menu_item_add( popup_menu_w, _("Properties"), properties_cb, node );
gui_menu_item_add( popup_menu_w, _("Open"), open_node, node );
gtk_menu_popup( GTK_MENU(popup_menu_w), NULL, NULL, NULL, NULL, ev_button->button, ev_button->time );
}