From c71fe393bfd440256ea701973c5d75bd6eb0402d Mon Sep 17 00:00:00 2001 From: "David C. Rankin" Date: Fri, 10 Mar 2017 16:30:18 -0600 Subject: [PATCH] Added check for existing syntax language in sourceview_guess to prevent clearing manually set highlight on save. --- gtk_filebuf.c | 5 +++++ gtk_menu.c | 17 +++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/gtk_filebuf.c b/gtk_filebuf.c index 1aabd53..9eb6d9c 100644 --- a/gtk_filebuf.c +++ b/gtk_filebuf.c @@ -42,6 +42,8 @@ void file_get_stats (const gchar *filename, kwinst *app) void sourceview_guess_language (kwinst *app) { + if (app->language) return; /* prevent changing manually applied language */ + gboolean result_uncertain; gchar *content_type; @@ -141,6 +143,9 @@ void buffer_clear (kwinst *app) app->filemode = 0; app->fileuid = 0; app->filegid = 0; +#ifdef HAVESOURCEVIEW + app->language = NULL; /* reset syntax language */ +#endif /* reset values to default */ status_set_default (app); diff --git a/gtk_menu.c b/gtk_menu.c index 6367d28..bf82a0c 100644 --- a/gtk_menu.c +++ b/gtk_menu.c @@ -691,22 +691,18 @@ GtkWidget *create_menubar (kwinst *app, GtkAccelGroup *mainaccel) * _File menu */ void menu_file_new_activate (GtkMenuItem *menuitem, kwinst *app) -{ - buffer_clear (app); +{ /* TODO: fork/execv, create new window and process */ - /* reset values to default */ - status_set_default (app); + buffer_clear (app); /* check for save and clear */ + status_set_default (app); /* statusbard default values */ if (menuitem) {} } void menu_file_open_activate (GtkMenuItem *menuitem, kwinst *app) { - /* check for save and clear */ - buffer_clear (app); - - /* insert file */ - buffer_file_open_dlg (app, NULL); + buffer_clear (app); /* check for save and clear */ + buffer_file_open_dlg (app, NULL); /* insert file */ if (menuitem) {} } @@ -823,8 +819,9 @@ void menu_file_print_activate (GtkMenuItem *menuitem, kwinst *app) void menu_file_close_activate (GtkMenuItem *menuitem, kwinst *app) { + buffer_clear (app); /* check for save and clear */ + if (menuitem) {} - if (app) {} } void menu_file_quit_activate (GtkMenuItem *menuitem, kwinst *app)