From: Linus Torvalds Date: Fri, 17 Aug 2012 17:57:24 +0000 (-0700) Subject: Merge branch 'misc-fixes' of git://github.com/DataBeaver/subsurface X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=d0e27c6c533005b5fd161286f68f1325bdabe8e3;p=ext%2Fsubsurface.git Merge branch 'misc-fixes' of git://github.com/DataBeaver/subsurface Pull miscellaneous fixes, mostly UI stuff from Mikko Rasa. Both this and the pull from Pierre-Yves Chibon created a "Save As" menu entry and logic. As a result, there were a fair number of conflicts, but I tried to make the end result somewhat reasonable. I might have missed some semantic conflict, though. Series-acked-by: Henrik Brautaset Aronsen * 'misc-fixes' of git://github.com/DataBeaver/subsurface: Add a separate "Save as" entry to the menu Changes to menu icons Improved depth info for dives without samples Divide the panes evenly in view_three --- d0e27c6c533005b5fd161286f68f1325bdabe8e3 diff --cc divelist.c index 0e1b40d,27d2424..5d69152 --- a/divelist.c +++ b/divelist.c @@@ -1040,27 -700,16 +1040,29 @@@ void add_dive_cb(GtkWidget *menuitem, g free(dive); } +void edit_dive_cb(GtkWidget *menuitem, gpointer data) +{ + edit_multi_dive_info(amount_selected, selectiontracker); +} + static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int button) { - GtkWidget *menu, *menuitem; + GtkWidget *menu, *menuitem, *image; + char editlabel[] = "Edit dives"; menu = gtk_menu_new(); - menuitem = gtk_menu_item_new_with_label("Add dive"); + menuitem = gtk_image_menu_item_new_with_label("Add dive"); + image = gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU); + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image); - g_signal_connect(menuitem, "activate", G_CALLBACK(add_dive_cb), model); + g_signal_connect(menuitem, "activate", G_CALLBACK(add_dive_cb), NULL); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + if (amount_selected) { + if (amount_selected == 1) + editlabel[strlen(editlabel) - 1] = '\0'; + menuitem = gtk_menu_item_new_with_label(editlabel); + g_signal_connect(menuitem, "activate", G_CALLBACK(edit_dive_cb), model); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + } gtk_widget_show_all(menu); gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, diff --cc gtk-gui.c index 02463d9,bef03a0..5bc46d2 --- a/gtk-gui.c +++ b/gtk-gui.c @@@ -170,61 -170,43 +170,45 @@@ static void file_open(GtkWidget *w, gpo gtk_widget_destroy(dialog); } - static void file_save(GtkWidget *w, gpointer data) + static void file_save_as(GtkWidget *w, gpointer data) { GtkWidget *dialog; - dialog = gtk_file_chooser_dialog_new("Save File", + char *filename; - if (!existing_filename) { - dialog = gtk_file_chooser_dialog_new("Save File", ++ dialog = gtk_file_chooser_dialog_new("Save File As", GTK_WINDOW(main_window), GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); - gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE); - - gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), "Untitled document"); - if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { - filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); - } - gtk_widget_destroy(dialog); - } else { - filename = existing_filename; - } - if (filename){ - save_dives(filename); - mark_divelist_changed(FALSE); - } - } - - static void file_save_as(GtkWidget *w, gpointer data) - { - GtkWidget *dialog; - char *filename; - dialog = gtk_file_chooser_dialog_new("Save File As", - GTK_WINDOW(main_window), - GTK_FILE_CHOOSER_ACTION_SAVE, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, - NULL); gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE); - if (!existing_filename) { - gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), "Untitled document"); - } else - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), existing_filename); + gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), existing_filename); if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { - char *filename; filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); + } + gtk_widget_destroy(dialog); + + if (filename){ save_dives(filename); + set_filename(filename); + g_free(filename); mark_divelist_changed(FALSE); } - gtk_widget_destroy(dialog); } + static void file_save(GtkWidget *w, gpointer data) + { + if (!existing_filename) + return file_save_as(w, data); + + save_dives(existing_filename); ++ mark_divelist_changed(FALSE); + } + -static void ask_save_changes() +static gboolean ask_save_changes() { GtkWidget *dialog, *label, *content; + gboolean quit = TRUE; dialog = gtk_dialog_new_with_buttons("Save Changes?", GTK_WINDOW(main_window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, @@@ -247,14 -217,10 +231,14 @@@ gtk_container_add (GTK_CONTAINER (content), label); gtk_widget_show_all (dialog); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); - gint *outcode = gtk_dialog_run(GTK_DIALOG(dialog)); - if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { ++ gint outcode = gtk_dialog_run(GTK_DIALOG(dialog)); + if (outcode == GTK_RESPONSE_ACCEPT) { file_save(NULL,NULL); + } else if (outcode == GTK_RESPONSE_CANCEL) { + quit = FALSE; } gtk_widget_destroy(dialog); + return quit; } static gboolean on_delete(GtkWidget* w, gpointer data) @@@ -683,18 -628,18 +669,18 @@@ static void view_three(GtkWidget *w, gp } static GtkActionEntry menu_items[] = { - { "FileMenuAction", GTK_STOCK_FILE, "File", NULL, NULL, NULL}, - { "LogMenuAction", GTK_STOCK_FILE, "Log", NULL, NULL, NULL}, - { "ViewMenuAction", GTK_STOCK_FILE, "View", NULL, NULL, NULL}, - { "FilterMenuAction", GTK_STOCK_FILE, "Filter", NULL, NULL, NULL}, - { "HelpMenuAction", GTK_STOCK_HELP, "Help", NULL, NULL, NULL}, + { "FileMenuAction", NULL, "File", NULL, NULL, NULL}, + { "LogMenuAction", NULL, "Log", NULL, NULL, NULL}, + { "ViewMenuAction", NULL, "View", NULL, NULL, NULL}, + { "FilterMenuAction", NULL, "Filter", NULL, NULL, NULL}, + { "HelpMenuAction", NULL, "Help", NULL, NULL, NULL}, { "OpenFile", GTK_STOCK_OPEN, NULL, CTRLCHAR "O", NULL, G_CALLBACK(file_open) }, { "SaveFile", GTK_STOCK_SAVE, NULL, CTRLCHAR "S", NULL, G_CALLBACK(file_save) }, - { "SaveFileAs", GTK_STOCK_SAVE_AS, NULL, CTRLCHAR "S", NULL, G_CALLBACK(file_save_as) }, + { "SaveAsFile", GTK_STOCK_SAVE_AS, NULL, SHIFTCHAR CTRLCHAR "S", NULL, G_CALLBACK(file_save_as) }, { "Print", GTK_STOCK_PRINT, NULL, CTRLCHAR "P", NULL, G_CALLBACK(do_print) }, { "Import", NULL, "Import", NULL, NULL, G_CALLBACK(import_dialog) }, - { "AddDive", NULL, "Add Dive", NULL, NULL, G_CALLBACK(add_dive_cb) }, - { "Preferences", NULL, "Preferences", PREFERENCE_ACCEL, NULL, G_CALLBACK(preferences_dialog) }, + { "AddDive", GTK_STOCK_ADD, "Add Dive", NULL, NULL, G_CALLBACK(add_dive_cb) }, + { "Preferences", GTK_STOCK_PREFERENCES, "Preferences", PREFERENCE_ACCEL, NULL, G_CALLBACK(preferences_dialog) }, { "Renumber", NULL, "Renumber", NULL, NULL, G_CALLBACK(renumber_dialog) }, { "SelectEvents", NULL, "SelectEvents", NULL, NULL, G_CALLBACK(selectevents_dialog) }, { "Quit", GTK_STOCK_QUIT, NULL, CTRLCHAR "Q", NULL, G_CALLBACK(quit) },