Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

add open_node entry in context menu #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions src/dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable

int retval;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable

strcpy(strbuf,"xdg-open ");
node_info = get_node_info(node);
strcat (strbuf, node_info->prefix);
strcat (strbuf, "/");
strcat (strbuf, node_info->name);
Comment on lines +1478 to +1482
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
strcpy(strbuf,"xdg-open ");
node_info = get_node_info(node);
strcat (strbuf, node_info->prefix);
strcat (strbuf, "/");
strcat (strbuf, node_info->name);
node_info = get_node_info(node);
snprintf(strbuf, sizeof(strbuf), "xdg-open %s/%s", node_info->prefix, node_info->name);

system(strbuf);

}

void
context_menu( GNode *node, GdkEventButton *ev_button )
Expand All @@ -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)) {
Expand All @@ -1498,7 +1508,9 @@ 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, _("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 );
}
Expand Down