Commit dff90b4aabedc3fdc56ea7f7efea0e114c6f7c58

Authored by perry
1 parent 2489c02f
Exists in master

Implementando save/restore de sessao.

Showing 3 changed files with 39 additions and 25 deletions   Show diff stats
@@ -29,6 +29,7 @@ @@ -29,6 +29,7 @@
29 const struct action_callback action_callbacks[] = 29 const struct action_callback action_callbacks[] =
30 { 30 {
31 { "print", action_print }, 31 { "print", action_print },
  32 + { "save", action_save },
32 { "toggle", action_toggle }, 33 { "toggle", action_toggle },
33 #ifdef __GTK_ABOUT_DIALOG_H__ 34 #ifdef __GTK_ABOUT_DIALOG_H__
34 { "about", action_AboutBox }, 35 { "about", action_AboutBox },
@@ -166,6 +166,8 @@ @@ -166,6 +166,8 @@
166 166
167 gboolean KeyboardAction(GtkWidget *widget, GdkEventKey *event, gpointer user_data); 167 gboolean KeyboardAction(GtkWidget *widget, GdkEventKey *event, gpointer user_data);
168 168
  169 + void action_save(GtkWidget *w, gpointer data);
  170 +
169 void action_crosshair( GtkWidget *w, gpointer data ); 171 void action_crosshair( GtkWidget *w, gpointer data );
170 void action_disconnect(GtkWidget *w, gpointer data); 172 void action_disconnect(GtkWidget *w, gpointer data);
171 void action_connect(GtkWidget *w, gpointer data); 173 void action_connect(GtkWidget *w, gpointer data);
@@ -79,7 +79,7 @@ @@ -79,7 +79,7 @@
79 79
80 /*---[ Main program ]---------------------------------------------------------*/ 80 /*---[ Main program ]---------------------------------------------------------*/
81 81
82 - void action_exit(GtkWidget *w, gpointer data) 82 + void action_save(GtkWidget *w, gpointer data)
83 { 83 {
84 char filename[4096]; 84 char filename[4096];
85 char *home = getenv("HOME"); 85 char *home = getenv("HOME");
@@ -163,7 +163,11 @@ @@ -163,7 +163,11 @@
163 } 163 }
164 } 164 }
165 #endif 165 #endif
  166 + }
166 167
  168 + void action_exit(GtkWidget *w, gpointer data)
  169 + {
  170 + action_save(w,data);
167 gtk_main_quit(); 171 gtk_main_quit();
168 } 172 }
169 173
@@ -361,33 +365,35 @@ static gint save_session (GnomeClient *client, gint phase, GnomeSaveStyle save_s @@ -361,33 +365,35 @@ static gint save_session (GnomeClient *client, gint phase, GnomeSaveStyle save_s
361 gint is_shutdown, GnomeInteractStyle interact_style, 365 gint is_shutdown, GnomeInteractStyle interact_style,
362 gint is_fast, gpointer client_data) 366 gint is_fast, gpointer client_data)
363 { 367 {
364 - gchar** argv;  
365 - guint argc; 368 + gchar** argv;
  369 + guint argc;
  370 +
  371 + Log("Saving session for %s",(char *) client_data);
366 372
367 - Log("Saving session for %s",(char *) client_data); 373 + action_save(0,0);
368 374
369 - /* allocate 0-filled, so it will be NULL-terminated */  
370 - argv = g_malloc0(sizeof(gchar*)*4);  
371 - argc = 0; 375 + /* allocate 0-filled, so it will be NULL-terminated */
  376 + argv = g_malloc0(sizeof(gchar*)*4);
  377 + argc = 0;
372 378
373 - argv[argc++] = client_data; 379 + argv[argc++] = client_data;
374 380
375 - if(cl_hostname)  
376 - {  
377 - argv[argc++] = ((gchar *) cl_hostname);  
378 - } 381 + if(cl_hostname)
  382 + {
  383 + argv[argc++] = ((gchar *) cl_hostname);
  384 + }
379 385
380 - gnome_client_set_clone_command(client, argc, argv);  
381 - gnome_client_set_restart_command(client, argc, argv); 386 + gnome_client_set_clone_command(client, argc, argv);
  387 + gnome_client_set_restart_command(client, argc, argv);
382 388
383 - return TRUE; 389 + return TRUE;
384 } 390 }
385 391
386 -static void session_die(GnomeClient* client, gpointer client_data) 392 +static gint session_die(GnomeClient* client, gpointer client_data)
387 { 393 {
388 Log("Exiting by gnome's request"); 394 Log("Exiting by gnome's request");
389 - action_exit(0,0);  
390 - Log("Session Die"); 395 + gtk_exit(0);
  396 + return FALSE;
391 } 397 }
392 #endif 398 #endif
393 399
@@ -407,13 +413,6 @@ static void session_die(GnomeClient* client, gpointer client_data) @@ -407,13 +413,6 @@ static void session_die(GnomeClient* client, gpointer client_data)
407 CHKPoint(); 413 CHKPoint();
408 set_3270_keyboard(&g3270_keyboard_info); 414 set_3270_keyboard(&g3270_keyboard_info);
409 415
410 - g_thread_init(NULL);  
411 - gdk_threads_init();  
412 - gtk_init(&argc, &argv);  
413 -  
414 - MainThread = g_thread_self();  
415 - DBGPrintf("Main thread: %p",MainThread);  
416 -  
417 #ifdef USE_GNOME 416 #ifdef USE_GNOME
418 417
419 gnome_init(PROJECT_NAME, PROJECT_VERSION, argc, argv); 418 gnome_init(PROJECT_NAME, PROJECT_VERSION, argc, argv);
@@ -423,8 +422,20 @@ static void session_die(GnomeClient* client, gpointer client_data) @@ -423,8 +422,20 @@ static void session_die(GnomeClient* client, gpointer client_data)
423 gtk_signal_connect(GTK_OBJECT (client), "save_yourself", GTK_SIGNAL_FUNC(save_session), argv[0]); 422 gtk_signal_connect(GTK_OBJECT (client), "save_yourself", GTK_SIGNAL_FUNC(save_session), argv[0]);
424 gtk_signal_connect(GTK_OBJECT (client), "die", GTK_SIGNAL_FUNC(session_die), NULL); 423 gtk_signal_connect(GTK_OBJECT (client), "die", GTK_SIGNAL_FUNC(session_die), NULL);
425 DBGMessage("Gnome session setup finished"); 424 DBGMessage("Gnome session setup finished");
  425 +
  426 +#else
  427 +
  428 + g_thread_init(NULL);
  429 + gdk_threads_init();
  430 + gtk_init(&argc, &argv);
  431 +
  432 +
426 #endif 433 #endif
427 434
  435 +
  436 + MainThread = g_thread_self();
  437 + DBGPrintf("Main thread: %p",MainThread);
  438 +
428 /* Parse 3270 command line */ 439 /* Parse 3270 command line */
429 parse_3270_command_line(argc, (const char **) argv, &cl_hostname); 440 parse_3270_command_line(argc, (const char **) argv, &cl_hostname);
430 441