From: Guilhem B. <gui...@gm...> - 2011-10-01 21:40:47
|
Instead of a not so standard "Append" menu entry, prefer to use an explicit "Open in new window" toggle in "Open" dialog box. Signed-off-by: Guilhem Bonnefille <gui...@gm...> --- src/menu.xml.h | 1 - src/vikwindow.c | 22 ++++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/menu.xml.h b/src/menu.xml.h index ef1fef2..353a795 100644 --- a/src/menu.xml.h +++ b/src/menu.xml.h @@ -8,7 +8,6 @@ static const char *menu_xml = " <menuitem action='New'/>" " <menuitem action='Open'/>" " <menuitem action='OpenRecentFile'/>" - " <menuitem action='Append'/>" " <menuitem action='Save'/>" " <menuitem action='SaveAs'/>" " <separator/>" diff --git a/src/vikwindow.c b/src/vikwindow.c index 7ac2d1d..a975885 100644 --- a/src/vikwindow.c +++ b/src/vikwindow.c @@ -1784,26 +1784,23 @@ static void load_file ( GtkAction *a, VikWindow *vw ) { GSList *files = NULL; GSList *cur_file = NULL; - gboolean newwindow; - if (!strcmp(gtk_action_get_name(a), "Open")) { - newwindow = TRUE; - } - else if (!strcmp(gtk_action_get_name(a), "Append")) { - newwindow = FALSE; - } - else { - g_critical("Houston, we've had a problem."); - return; - } if ( ! vw->open_dia ) { + /* A toggle to decide if we have to open a new window or not */ + GtkWidget *toggle = gtk_check_button_new_with_label (_("Open file in a new window")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), TRUE); + gtk_widget_show (toggle); + vw->open_dia = gtk_file_chooser_dialog_new (_("Please select a GPS data file to open. "), GTK_WINDOW(vw), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); + + gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (vw->open_dia), toggle); + GtkFileFilter *filter; // NB file filters are listed this way for alphabetical ordering #ifdef VIK_CONFIG_GEOCACHES @@ -1847,6 +1844,8 @@ static void load_file ( GtkAction *a, VikWindow *vw ) if ( gtk_dialog_run ( GTK_DIALOG(vw->open_dia) ) == GTK_RESPONSE_ACCEPT ) { gtk_widget_hide ( vw->open_dia ); + GtkWidget *toggle = gtk_file_chooser_get_extra_widget (GTK_FILE_CHOOSER (vw->open_dia)); + gboolean newwindow = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (toggle)); #ifdef VIKING_PROMPT_IF_MODIFIED if ( vw->modified && newwindow ) #else @@ -2520,7 +2519,6 @@ static GtkActionEntry entries[] = { { "New", GTK_STOCK_NEW, N_("_New"), "<control>N", N_("New file"), (GCallback)newwindow_cb }, { "Open", GTK_STOCK_OPEN, N_("_Open..."), "<control>O", N_("Open a file"), (GCallback)load_file }, { "OpenRecentFile", NULL, N_("Open _Recent File"), NULL, NULL, (GCallback)NULL }, - { "Append", GTK_STOCK_ADD, N_("Append _File..."), NULL, N_("Append data from a different file"), (GCallback)load_file }, { "Acquire", NULL, N_("A_cquire"), 0, 0, 0 }, { "AcquireGPS", NULL, N_("From _GPS..."), NULL, N_("Transfer data from a GPS device"), (GCallback)acquire_from_gps }, { "AcquireGPSBabel", NULL, N_("Import File With GPS_Babel..."), NULL, N_("Import file via GPSBabel converter"), (GCallback)acquire_from_file }, -- tg: (9fde573..) t/fix/remove-append (depends on: t/fix/append) |