Commit dff90b4aabedc3fdc56ea7f7efea0e114c6f7c58
1 parent
2489c02f
Exists in
master
Implementando save/restore de sessao.
Showing
3 changed files
with
39 additions
and
25 deletions
Show diff stats
src/actions.c
src/g3270.h
| ... | ... | @@ -166,6 +166,8 @@ |
| 166 | 166 | |
| 167 | 167 | gboolean KeyboardAction(GtkWidget *widget, GdkEventKey *event, gpointer user_data); |
| 168 | 168 | |
| 169 | + void action_save(GtkWidget *w, gpointer data); | |
| 170 | + | |
| 169 | 171 | void action_crosshair( GtkWidget *w, gpointer data ); |
| 170 | 172 | void action_disconnect(GtkWidget *w, gpointer data); |
| 171 | 173 | void action_connect(GtkWidget *w, gpointer data); | ... | ... |
src/main.c
| ... | ... | @@ -79,7 +79,7 @@ |
| 79 | 79 | |
| 80 | 80 | /*---[ Main program ]---------------------------------------------------------*/ |
| 81 | 81 | |
| 82 | - void action_exit(GtkWidget *w, gpointer data) | |
| 82 | + void action_save(GtkWidget *w, gpointer data) | |
| 83 | 83 | { |
| 84 | 84 | char filename[4096]; |
| 85 | 85 | char *home = getenv("HOME"); |
| ... | ... | @@ -163,7 +163,11 @@ |
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | #endif |
| 166 | + } | |
| 166 | 167 | |
| 168 | + void action_exit(GtkWidget *w, gpointer data) | |
| 169 | + { | |
| 170 | + action_save(w,data); | |
| 167 | 171 | gtk_main_quit(); |
| 168 | 172 | } |
| 169 | 173 | |
| ... | ... | @@ -361,33 +365,35 @@ static gint save_session (GnomeClient *client, gint phase, GnomeSaveStyle save_s |
| 361 | 365 | gint is_shutdown, GnomeInteractStyle interact_style, |
| 362 | 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 | 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 | 398 | #endif |
| 393 | 399 | |
| ... | ... | @@ -407,13 +413,6 @@ static void session_die(GnomeClient* client, gpointer client_data) |
| 407 | 413 | CHKPoint(); |
| 408 | 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 | 416 | #ifdef USE_GNOME |
| 418 | 417 | |
| 419 | 418 | gnome_init(PROJECT_NAME, PROJECT_VERSION, argc, argv); |
| ... | ... | @@ -423,8 +422,20 @@ static void session_die(GnomeClient* client, gpointer client_data) |
| 423 | 422 | gtk_signal_connect(GTK_OBJECT (client), "save_yourself", GTK_SIGNAL_FUNC(save_session), argv[0]); |
| 424 | 423 | gtk_signal_connect(GTK_OBJECT (client), "die", GTK_SIGNAL_FUNC(session_die), NULL); |
| 425 | 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 | 433 | #endif |
| 427 | 434 | |
| 435 | + | |
| 436 | + MainThread = g_thread_self(); | |
| 437 | + DBGPrintf("Main thread: %p",MainThread); | |
| 438 | + | |
| 428 | 439 | /* Parse 3270 command line */ |
| 429 | 440 | parse_3270_command_line(argc, (const char **) argv, &cl_hostname); |
| 430 | 441 | ... | ... |