static int save_state (GnomeClient *client, gint phase, GnomeRestartStyle save_style, gint shutdown, GnomeInteractStyle interact_style, gint fast, gpointer client_data) { gchar *argv[20]; gint i = 0; GList *l; Diagram *dia; argv[i++] = "dia"; for(l = dia_open_diagrams(); l != NULL; l = g_list_next(l)) { dia = (Diagram *)l->data; if(!dia->unsaved) { argv[i++] = dia->filename; } } gnome_client_set_restart_command (client, i, argv); gnome_client_set_clone_command (client, i, argv); return TRUE; }
/* save_yourself handler for the master client */ static gboolean client_save_yourself_cb (GnomeClient *client, gint phase, GnomeSaveStyle save_style, gboolean shutdown, GnomeInteractStyle interact_style, gboolean fast, gpointer data) { const char *prefix; char *argv[4] = { NULL }; save_session (client); prefix = gnome_client_get_config_prefix (client); /* Tell the session manager how to discard this save */ argv[0] = "rm"; argv[1] = "-rf"; argv[2] = gnome_config_get_real_path (prefix); argv[3] = NULL; gnome_client_set_discard_command (client, 3, argv); /* Tell the session manager how to clone or restart this instance */ argv[0] = (char *) program_argv0; argv[1] = NULL; /* "--debug-session"; */ gnome_client_set_clone_command (client, 1, argv); gnome_client_set_restart_command (client, 1, argv); return TRUE; }
/* the gnome session manager may call this function */ static gboolean save_session (GnomeClient * client, gint phase, GnomeSaveStyle save_style, gboolean is_shutdown, GnomeInteractStyle interact_style, gboolean is_fast, gpointer client_data) { gchar **argv; guint argc; /* allocate 0-filled, so it will be NULL-terminated */ argv = g_malloc0 (sizeof (gchar *) * 4); g_assert(argv); argc = 1; argv[0] = client_data; g_message ("In save_session"); #if 0 if (message) { argv[1] = "--message"; argv[2] = message; argc = 3; } #endif gnome_client_set_clone_command (client, argc, argv); gnome_client_set_restart_command (client, argc, argv); return TRUE; } /* save_session */
static gint save_session (GnomeClient *client, gint phase, GnomeSaveStyle save_style, gint shutdown, GnomeInteractStyle interact_style, gint fast, GwgetApplication *application) { char **restart_argv; int argc = 0; restart_argv = g_new (char *, 1); restart_argv[0] = g_strdup ("gwget"); gnome_client_set_restart_command (client, argc, restart_argv); return TRUE; }