--- ./src/callback.c.orig 2008-06-27 23:01:33.000000000 +0300 +++ ./src/callback.c 2009-05-18 20:27:13.000000000 +0300 @@ -398,3 +398,22 @@ "Copyright © 2005-2006 Erik Harrison\nBased on Code by Tarot Osuji and the Gedit team", ICONDIR G_DIR_SEPARATOR_S PACKAGE ".png"); } + +gboolean cb_interact_2(gpointer client_data, SessionInteractStyle interact_style) +{ + return interact_style == SESSION_INTERACT_ANY && + check_text_modification((StructData *) client_data); +} + +void cb_save_yourself (gpointer client_data, int save_style, + gboolean shutdown, int interact_style, gboolean fast) +{ + StructData *sd = ((StructData *) client_data); + gchar *restart[3]; + + restart[0] = PACKAGE; + restart[1] = sd->fi->filename; + restart[2] = NULL; + client_session_set_restart_command(sd->session_client, restart); + save_config_file(sd); +} --- ./src/callback.h.orig 2008-06-27 23:01:33.000000000 +0300 +++ ./src/callback.h 2009-05-17 12:49:01.000000000 +0300 @@ -52,5 +52,9 @@ void cb_option_auto_indent(StructData *sd, guint action, GtkWidget *widget); void cb_help_about(StructData *sd); void cb_xfprint_closed (GPid pid, gint status, gpointer sd); +gboolean cb_interact_2(gpointer client_data, SessionInteractStyle interact_style); +void cb_save_phase_2(gpointer *client_data); +void cb_save_yourself (gpointer client_data, int save_style, + gboolean shutdown, int interact_style, gboolean fast); #endif /* _CALLBACK_H */ --- ./src/main.c.orig 2008-06-27 23:01:33.000000000 +0300 +++ ./src/main.c 2009-05-18 20:12:46.000000000 +0300 @@ -112,7 +112,7 @@ return 0; } -static gint save_config_file(StructData *sd) +gint save_config_file(StructData *sd) { FILE *fp; gchar *path; @@ -161,12 +161,19 @@ return 0; } -static void create_new_process(gchar *filename) +static void create_new_process(gchar *filename, SessionClient *session_client) { StructData *sd = g_malloc(sizeof(StructData)); FileInfo *fi; GtkItemFactory *ifactory; + sd->session_client = session_client; + client_session_set_data(session_client, sd); + client_session_set_interact_style(session_client, SESSION_INTERACT_ANY); + client_session_set_interact_2_callback(session_client, cb_interact_2); + client_session_set_save_yourself_callback(session_client, cb_save_yourself); + session_init(session_client); + load_config_file(sd); sd->mainwin = create_main_window(sd); gtk_widget_show_all(sd->mainwin->window); @@ -213,7 +220,8 @@ gtk_main(); save_config_file(sd); -/* gtk_widget_destroy(sd->mainwin->window); +/* client_session_free(sd->session_client); + gtk_widget_destroy(sd->mainwin->window); g_free(sd->fi); g_free(sd->mainwin); g_free(sd->conf.fontname); @@ -250,7 +258,8 @@ } } - create_new_process(filename); + create_new_process(filename, + client_session_new(argc, argv, NULL, SESSION_RESTART_IF_RUNNING, 50)); return 0; } --- ./src/mousepad.h.orig 2008-06-27 23:01:33.000000000 +0300 +++ ./src/mousepad.h 2009-05-15 19:57:34.000000000 +0300 @@ -82,8 +82,12 @@ gchar *string_replace; gboolean match_case, replace_all; } search; + /* session */ + SessionClient *session_client; } StructData; +gint save_config_file(StructData *sd); + /* Local Functions */ #include "window.h" #include "menu.h"