Added an "Open file..." entry to the file menu
This commit is contained in:
parent
344a8137d6
commit
df341e9aca
@ -47,6 +47,7 @@ static struct _menu _browser_menu_file[] =
|
|||||||
{
|
{
|
||||||
{ "_New window", G_CALLBACK(on_file_new_window), "window-new", GDK_N },
|
{ "_New window", G_CALLBACK(on_file_new_window), "window-new", GDK_N },
|
||||||
{ "New _folder", G_CALLBACK(on_file_new_folder), "folder-new", 0 },
|
{ "New _folder", G_CALLBACK(on_file_new_folder), "folder-new", 0 },
|
||||||
|
{ "Open file...", G_CALLBACK(on_file_open_file), NULL, GDK_O },
|
||||||
{ "", NULL, NULL, 0 },
|
{ "", NULL, NULL, 0 },
|
||||||
{ "_Properties", G_CALLBACK(on_properties), GTK_STOCK_PROPERTIES, 0 },
|
{ "_Properties", G_CALLBACK(on_properties), GTK_STOCK_PROPERTIES, 0 },
|
||||||
{ "", NULL, NULL, 0 },
|
{ "", NULL, NULL, 0 },
|
||||||
@ -599,6 +600,28 @@ void browser_go_home(Browser * browser)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* browser_open */
|
||||||
|
void browser_open(Browser * browser, char const * path)
|
||||||
|
{
|
||||||
|
GtkWidget * dialog;
|
||||||
|
|
||||||
|
if(path == NULL)
|
||||||
|
{
|
||||||
|
dialog = gtk_file_chooser_dialog_new("Open file...",
|
||||||
|
GTK_WINDOW(browser->window),
|
||||||
|
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL,
|
||||||
|
GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN,
|
||||||
|
GTK_RESPONSE_ACCEPT, NULL);
|
||||||
|
if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
|
||||||
|
path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(
|
||||||
|
dialog));
|
||||||
|
gtk_widget_destroy(dialog);
|
||||||
|
}
|
||||||
|
if(browser->mime != NULL && path != NULL)
|
||||||
|
mime_action(browser->mime, "open", path);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* browser_open_with */
|
/* browser_open_with */
|
||||||
void browser_open_with(Browser * browser, char const * path)
|
void browser_open_with(Browser * browser, char const * path)
|
||||||
{
|
{
|
||||||
|
@ -155,6 +155,7 @@ int browser_config_save(Browser * browser);
|
|||||||
|
|
||||||
void browser_go_home(Browser * browser);
|
void browser_go_home(Browser * browser);
|
||||||
|
|
||||||
|
void browser_open(Browser * browser, char const * path);
|
||||||
void browser_open_with(Browser * browser, char const * path);
|
void browser_open_with(Browser * browser, char const * path);
|
||||||
|
|
||||||
void browser_refresh(Browser * browser);
|
void browser_refresh(Browser * browser);
|
||||||
|
@ -96,6 +96,14 @@ void on_file_close(GtkMenuItem * menuitem, gpointer data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void on_file_open_file(GtkMenuItem * menuitem, gpointer data)
|
||||||
|
{
|
||||||
|
Browser * browser = data;
|
||||||
|
|
||||||
|
browser_open(browser, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* edit menu */
|
/* edit menu */
|
||||||
/* on_edit_copy */
|
/* on_edit_copy */
|
||||||
static GList * _copy_selection(Browser * browser);
|
static GList * _copy_selection(Browser * browser);
|
||||||
|
@ -28,6 +28,7 @@ gboolean on_closex(GtkWidget * widget, GdkEvent * event, gpointer data);
|
|||||||
void on_file_new_window(GtkMenuItem * menuitem, gpointer data);
|
void on_file_new_window(GtkMenuItem * menuitem, gpointer data);
|
||||||
void on_file_new_folder(GtkMenuItem * menuitem, gpointer data);
|
void on_file_new_folder(GtkMenuItem * menuitem, gpointer data);
|
||||||
void on_file_close(GtkMenuItem * menuitem, gpointer data);
|
void on_file_close(GtkMenuItem * menuitem, gpointer data);
|
||||||
|
void on_file_open_file(GtkMenuItem * menuitem, gpointer data);
|
||||||
|
|
||||||
/* edit menu */
|
/* edit menu */
|
||||||
void on_edit_copy(GtkMenuItem * menuitem, gpointer data);
|
void on_edit_copy(GtkMenuItem * menuitem, gpointer data);
|
||||||
|
Loading…
Reference in New Issue
Block a user