--- ./src/main.c.orig 2008-06-27 23:01:33.000000000 +0300 +++ ./src/main.c 2009-05-20 21:16:17.000000000 +0300 @@ -161,12 +161,37 @@ return 0; } -static void create_new_process(gchar *filename) +static SessionClient *client; + +static void interact_proc_cb(gpointer client_data, SessionInteractStyle interact_style) +{ + StructData *sd = (StructData *) client_data; + gchar *basename, *str; + GtkTextBuffer *textbuffer = sd->mainwin->textbuffer; + + if (interact_style != SESSION_INTERACT_ANY) + return; + + if (gtk_text_buffer_get_modified(textbuffer)) { + basename = get_current_file_basename(sd->fi->filename); + str = g_strdup_printf(_("Save changes to '%s'?"), basename); + run_dialog_message_question(sd->mainwin->window, str); + g_free(str); + g_free(basename); + } +} + +static void create_new_process(gchar *filename, int argc, char **argv) { StructData *sd = g_malloc(sizeof(StructData)); FileInfo *fi; GtkItemFactory *ifactory; + client = client_session_new(argc, argv, sd, SESSION_RESTART_IF_RUNNING, 50); + client->interact = interact_proc_cb; + client->interact_style = SESSION_INTERACT_ANY; + session_init(client); + load_config_file(sd); sd->mainwin = create_main_window(sd); gtk_widget_show_all(sd->mainwin->window); @@ -250,7 +275,7 @@ } } - create_new_process(filename); + create_new_process(filename, argc, argv); return 0; }