Kaydet (Commit) 53d91a4c authored tarafından Enrico Tröger's avatar Enrico Tröger

Fixed wrong behaviour of Save As on unchanged files.

Don't set file as changed when changing encoding to the same one.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@663 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 3508a0e3
2006-08-02 Enrico Tröger <enrico.troeger@uvena.de>
* src/callbacks.c:
Don't set file as changed when changing encoding to the same one.
* src/document.c, src/callbacks.c, dialogs.c:
Fixed wrong behaviour of Save As on unchanged files.
2006-08-01 Enrico Tröger <enrico.troeger@uvena.de> 2006-08-01 Enrico Tröger <enrico.troeger@uvena.de>
* geany.glade, src/interface.c, src/callbacks.c, src/keybindings.c, * geany.glade, src/interface.c, src/callbacks.c, src/keybindings.c,
......
...@@ -270,7 +270,7 @@ on_save1_activate (GtkMenuItem *menuitem, ...@@ -270,7 +270,7 @@ on_save1_activate (GtkMenuItem *menuitem,
if (doc_list[idx].file_name == NULL) if (doc_list[idx].file_name == NULL)
dialogs_show_save_as(); dialogs_show_save_as();
else else
document_save_file(idx); document_save_file(idx, FALSE);
} }
} }
...@@ -296,7 +296,7 @@ on_save_all1_activate (GtkMenuItem *menuitem, ...@@ -296,7 +296,7 @@ on_save_all1_activate (GtkMenuItem *menuitem,
if (doc_list[idx].file_name == NULL) if (doc_list[idx].file_name == NULL)
dialogs_show_save_as(); dialogs_show_save_as();
else else
document_save_file(idx); document_save_file(idx, FALSE);
} }
utils_update_tag_list(cur_idx, TRUE); utils_update_tag_list(cur_idx, TRUE);
utils_set_window_title(cur_idx); utils_set_window_title(cur_idx);
...@@ -925,7 +925,7 @@ on_file_save_dialog_response (GtkDialog *dialog, ...@@ -925,7 +925,7 @@ on_file_save_dialog_response (GtkDialog *dialog,
doc_list[idx].file_name = new_filename; doc_list[idx].file_name = new_filename;
utils_replace_filename(idx); utils_replace_filename(idx);
document_save_file(idx); document_save_file(idx, TRUE);
utils_build_show_hide(idx); utils_build_show_hide(idx);
...@@ -1511,7 +1511,7 @@ on_openfiles_tree_popup_clicked (GtkMenuItem *menuitem, ...@@ -1511,7 +1511,7 @@ on_openfiles_tree_popup_clicked (GtkMenuItem *menuitem,
} }
case 1: case 1:
{ {
if (doc_list[idx].changed) document_save_file(idx); if (doc_list[idx].changed) document_save_file(idx, FALSE);
break; break;
} }
case 2: case 2:
...@@ -1604,7 +1604,7 @@ on_build_compile_activate (GtkMenuItem *menuitem, ...@@ -1604,7 +1604,7 @@ on_build_compile_activate (GtkMenuItem *menuitem,
gint idx = document_get_cur_idx(); gint idx = document_get_cur_idx();
GPid child_pid = (GPid) 0; GPid child_pid = (GPid) 0;
if (doc_list[idx].changed) document_save_file(idx); if (doc_list[idx].changed) document_save_file(idx, FALSE);
if (doc_list[idx].file_type->id == GEANY_FILETYPES_LATEX) if (doc_list[idx].file_type->id == GEANY_FILETYPES_LATEX)
child_pid = build_compile_tex_file(idx, 0); child_pid = build_compile_tex_file(idx, 0);
...@@ -1626,7 +1626,7 @@ on_build_tex_activate (GtkMenuItem *menuitem, ...@@ -1626,7 +1626,7 @@ on_build_tex_activate (GtkMenuItem *menuitem,
gint idx = document_get_cur_idx(); gint idx = document_get_cur_idx();
GPid child_pid = (GPid) 0; GPid child_pid = (GPid) 0;
if (doc_list[idx].changed) document_save_file(idx); if (doc_list[idx].changed) document_save_file(idx, FALSE);
switch (GPOINTER_TO_INT(user_data)) switch (GPOINTER_TO_INT(user_data))
{ {
...@@ -1651,7 +1651,7 @@ on_build_build_activate (GtkMenuItem *menuitem, ...@@ -1651,7 +1651,7 @@ on_build_build_activate (GtkMenuItem *menuitem,
gint idx = document_get_cur_idx(); gint idx = document_get_cur_idx();
GPid child_pid = (GPid) 0; GPid child_pid = (GPid) 0;
if (doc_list[idx].changed) document_save_file(idx); if (doc_list[idx].changed) document_save_file(idx, FALSE);
if (doc_list[idx].file_type->id == GEANY_FILETYPES_LATEX) if (doc_list[idx].file_type->id == GEANY_FILETYPES_LATEX)
child_pid = build_compile_tex_file(idx, 1); child_pid = build_compile_tex_file(idx, 1);
...@@ -1706,7 +1706,7 @@ on_build_make_activate (GtkMenuItem *menuitem, ...@@ -1706,7 +1706,7 @@ on_build_make_activate (GtkMenuItem *menuitem,
{ {
GPid child_pid; GPid child_pid;
if (doc_list[idx].changed) document_save_file(idx); if (doc_list[idx].changed) document_save_file(idx, FALSE);
child_pid = build_make_file(idx, make_object); child_pid = build_make_file(idx, make_object);
if (child_pid != (GPid) 0) if (child_pid != (GPid) 0)
...@@ -1737,7 +1737,7 @@ on_build_execute_activate (GtkMenuItem *menuitem, ...@@ -1737,7 +1737,7 @@ on_build_execute_activate (GtkMenuItem *menuitem,
// save the file only if the run command uses it // save the file only if the run command uses it
if (doc_list[idx].changed && if (doc_list[idx].changed &&
strstr(doc_list[idx].file_type->programs->run_cmd, "%f") != NULL) strstr(doc_list[idx].file_type->programs->run_cmd, "%f") != NULL)
document_save_file(idx); document_save_file(idx, FALSE);
if (build_run_cmd(idx) == (GPid) 0) if (build_run_cmd(idx) == (GPid) 0)
{ {
msgwin_status_add(_("Failed to execute the terminal program")); msgwin_status_add(_("Failed to execute the terminal program"));
...@@ -1773,7 +1773,7 @@ on_make_target_dialog_response (GtkDialog *dialog, ...@@ -1773,7 +1773,7 @@ on_make_target_dialog_response (GtkDialog *dialog,
gint idx = document_get_cur_idx(); gint idx = document_get_cur_idx();
GPid child_pid; GPid child_pid;
if (doc_list[idx].changed) document_save_file(idx); if (doc_list[idx].changed) document_save_file(idx, FALSE);
strncpy(app->build_make_custopt, gtk_entry_get_text(GTK_ENTRY(user_data)), 255); strncpy(app->build_make_custopt, gtk_entry_get_text(GTK_ENTRY(user_data)), 255);
...@@ -2593,7 +2593,8 @@ on_encoding_change (GtkMenuItem *menuitem, ...@@ -2593,7 +2593,8 @@ on_encoding_change (GtkMenuItem *menuitem,
gint idx = document_get_cur_idx(); gint idx = document_get_cur_idx();
guint i = GPOINTER_TO_INT(user_data); guint i = GPOINTER_TO_INT(user_data);
if (idx < 0 || encodings[i].charset == NULL) return; if (idx < 0 || encodings[i].charset == NULL ||
utils_strcmp(encodings[i].charset, doc_list[idx].encoding)) return;
g_free(doc_list[idx].encoding); g_free(doc_list[idx].encoding);
doc_list[idx].encoding = g_strdup(encodings[i].charset); doc_list[idx].encoding = g_strdup(encodings[i].charset);
......
...@@ -154,7 +154,7 @@ void dialogs_show_open_file () ...@@ -154,7 +154,7 @@ void dialogs_show_open_file ()
/* This shows the file selection dialog to save a file. */ /* This shows the file selection dialog to save a file. */
void dialogs_show_save_as () void dialogs_show_save_as()
{ {
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
win32_show_file_dialog(FALSE); win32_show_file_dialog(FALSE);
...@@ -320,7 +320,7 @@ gboolean dialogs_show_unsaved_file(gint idx) ...@@ -320,7 +320,7 @@ gboolean dialogs_show_unsaved_file(gint idx)
if (doc_list[idx].file_name == NULL) if (doc_list[idx].file_name == NULL)
dialogs_show_save_as(); dialogs_show_save_as();
else else
document_save_file(idx); document_save_file(idx, FALSE);
ret = TRUE; ret = TRUE;
break; break;
} }
...@@ -361,7 +361,7 @@ void dialogs_show_open_font(void) ...@@ -361,7 +361,7 @@ void dialogs_show_open_font(void)
"clicked", G_CALLBACK(on_font_apply_button_clicked), NULL); "clicked", G_CALLBACK(on_font_apply_button_clicked), NULL);
gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(app->open_fontsel), app->editor_font); gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(app->open_fontsel), app->editor_font);
gtk_window_set_transient_for(GTK_WINDOW (app->open_fontsel), GTK_WINDOW(app->window)); gtk_window_set_transient_for(GTK_WINDOW(app->open_fontsel), GTK_WINDOW(app->window));
} }
/* We make sure the dialog is visible. */ /* We make sure the dialog is visible. */
gtk_window_present(GTK_WINDOW(app->open_fontsel)); gtk_window_present(GTK_WINDOW(app->open_fontsel));
...@@ -558,7 +558,7 @@ GtkWidget *dialogs_create_build_menu_gen(gint idx) ...@@ -558,7 +558,7 @@ GtkWidget *dialogs_create_build_menu_gen(gint idx)
item = gtk_image_menu_item_new_with_mnemonic(_("_Set Includes and Arguments")); item = gtk_image_menu_item_new_with_mnemonic(_("_Set Includes and Arguments"));
gtk_widget_show(item); gtk_widget_show(item);
GEANY_ADD_WIDGET_ACCEL(GEANY_KEYS_BUILD_OPTIONS, item); GEANY_ADD_WIDGET_ACCEL(GEANY_KEYS_BUILD_OPTIONS, item);
gtk_container_add(GTK_CONTAINER (menu), item); gtk_container_add(GTK_CONTAINER(menu), item);
gtk_tooltips_set_tip(tooltips, item, gtk_tooltips_set_tip(tooltips, item,
_("Sets the includes and library paths for the compiler and " _("Sets the includes and library paths for the compiler and "
"the program arguments for execution"), NULL); "the program arguments for execution"), NULL);
...@@ -666,7 +666,7 @@ GtkWidget *dialogs_create_build_menu_tex(gint idx) ...@@ -666,7 +666,7 @@ GtkWidget *dialogs_create_build_menu_tex(gint idx)
if (keys[GEANY_KEYS_BUILD_OPTIONS]->key) if (keys[GEANY_KEYS_BUILD_OPTIONS]->key)
gtk_widget_add_accelerator(item, "activate", accel_group, keys[GEANY_KEYS_BUILD_OPTIONS]->key, gtk_widget_add_accelerator(item, "activate", accel_group, keys[GEANY_KEYS_BUILD_OPTIONS]->key,
keys[GEANY_KEYS_BUILD_OPTIONS]->mods, GTK_ACCEL_VISIBLE); keys[GEANY_KEYS_BUILD_OPTIONS]->mods, GTK_ACCEL_VISIBLE);
gtk_container_add(GTK_CONTAINER (menu), item); gtk_container_add(GTK_CONTAINER(menu), item);
gtk_tooltips_set_tip(tooltips, item, gtk_tooltips_set_tip(tooltips, item,
_("Sets the program paths and arguments"), NULL); _("Sets the program paths and arguments"), NULL);
image = gtk_image_new_from_stock("gtk-preferences", GTK_ICON_SIZE_MENU); image = gtk_image_new_from_stock("gtk-preferences", GTK_ICON_SIZE_MENU);
...@@ -726,8 +726,8 @@ void dialogs_show_make_target(void) ...@@ -726,8 +726,8 @@ void dialogs_show_make_target(void)
gtk_entry_set_max_length(GTK_ENTRY(entry), 248); gtk_entry_set_max_length(GTK_ENTRY(entry), 248);
gtk_entry_set_width_chars(GTK_ENTRY(entry), 30); gtk_entry_set_width_chars(GTK_ENTRY(entry), 30);
g_signal_connect((gpointer) entry, "activate", G_CALLBACK (on_make_target_entry_activate), dialog); g_signal_connect((gpointer) entry, "activate", G_CALLBACK(on_make_target_entry_activate), dialog);
g_signal_connect((gpointer) dialog, "response", G_CALLBACK (on_make_target_dialog_response), entry); g_signal_connect((gpointer) dialog, "response", G_CALLBACK(on_make_target_dialog_response), entry);
g_signal_connect((gpointer) dialog, "delete_event", G_CALLBACK(gtk_widget_destroy), NULL); g_signal_connect((gpointer) dialog, "delete_event", G_CALLBACK(gtk_widget_destroy), NULL);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), label);
......
...@@ -255,6 +255,8 @@ gint document_create_new_sci(const gchar *filename) ...@@ -255,6 +255,8 @@ gint document_create_new_sci(const gchar *filename)
sci_set_symbol_margin(sci, app->show_markers_margin); sci_set_symbol_margin(sci, app->show_markers_margin);
sci_set_line_numbers(sci, app->show_linenumber_margin, 0); sci_set_line_numbers(sci, app->show_linenumber_margin, 0);
sci_set_lines_wrapped(sci, app->pref_editor_line_breaking); sci_set_lines_wrapped(sci, app->pref_editor_line_breaking);
SSM(sci, SCI_SETLAYOUTCACHE, SC_CACHE_PAGE, 0);
pfd = pango_font_description_from_string(app->editor_font); pfd = pango_font_description_from_string(app->editor_font);
fname = g_strdup_printf("!%s", pango_font_description_get_family(pfd)); fname = g_strdup_printf("!%s", pango_font_description_get_family(pfd));
document_set_font(new_idx, fname, pango_font_description_get_size(pfd) / PANGO_SCALE); document_set_font(new_idx, fname, pango_font_description_get_size(pfd) / PANGO_SCALE);
...@@ -372,6 +374,7 @@ void document_new_file(filetype *ft) ...@@ -372,6 +374,7 @@ void document_new_file(filetype *ft)
g_free(template); g_free(template);
doc_list[idx].encoding = g_strdup(encodings[app->pref_editor_default_encoding].charset); doc_list[idx].encoding = g_strdup(encodings[app->pref_editor_default_encoding].charset);
//document_set_filetype(idx, (ft == NULL) ? filetypes[GEANY_FILETYPES_ALL] : ft);
document_set_filetype(idx, ft); document_set_filetype(idx, ft);
utils_set_window_title(idx); utils_set_window_title(idx);
utils_build_show_hide(idx); utils_build_show_hide(idx);
...@@ -681,15 +684,17 @@ gint document_reload_file(gint idx, const gchar *forced_enc) ...@@ -681,15 +684,17 @@ gint document_reload_file(gint idx, const gchar *forced_enc)
} }
/* This saves the file */ /* This saves the file.
void document_save_file(gint idx) * When force is set then it is always saved, even if it is unchanged(useful when using Save As) */
void document_save_file(gint idx, gboolean force)
{ {
gchar *data; gchar *data;
FILE *fp; FILE *fp;
gint bytes_written, len; gint bytes_written, len;
gchar *locale_filename = NULL; gchar *locale_filename = NULL;
if (idx == -1 || ! doc_list[idx].changed) return; if (idx == -1) return;
if (! force && ! doc_list[idx].changed) return;
if (doc_list[idx].file_name == NULL) if (doc_list[idx].file_name == NULL)
{ {
......
...@@ -88,9 +88,9 @@ int document_open_file(gint, const gchar*, gint, gboolean, filetype*, const gcha ...@@ -88,9 +88,9 @@ int document_open_file(gint, const gchar*, gint, gboolean, filetype*, const gcha
int document_reload_file(gint idx, const gchar *forced_enc); int document_reload_file(gint idx, const gchar *forced_enc);
/* This saves the file, which is in on-disk encoding (which may not /* This saves the file.
be UTF-8). */ * When force is set then it is always saved, even if it is unchanged(useful when using Save As) */
void document_save_file (gint); void document_save_file(gint, gboolean force);
/* special search function, used from the find entry in the toolbar */ /* special search function, used from the find entry in the toolbar */
void document_find_next(gint, const gchar*, gint, gboolean, gboolean); void document_find_next(gint, const gchar*, gint, gboolean, gboolean);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment