Example #1
0
/* 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;
}
Example #2
0
static int
save_state (GnomeClient *client,
	    gint phase,
	    GnomeSaveStyle save_style,
	    gint shutdown, 
	    GnomeInteractStyle interact_style,
	    gint fast,
	    gpointer client_data)
{
	gchar *prefix = gnome_client_get_config_prefix (client);
	gchar *argv []= { "rm", "-r", NULL };
	gchar *buf;
	struct ball *f = (struct ball*) field;
	int i;  
	
	if (debugging)
		g_print ("Saving state\n");
	
	gnome_config_push_prefix (prefix);
	
	gnome_config_set_int ("Game/Score", score);
	gnome_config_set_int ("Game/NStones", sync_stones ? 1 : nstones);
	
	buf= g_malloc (STONE_COLS*STONE_LINES+1);
	
	for (i = 0 ; i < (STONE_COLS*STONE_LINES); i++){
		buf [i]= f [i].color + 'a';
	}
	buf [STONE_COLS*STONE_LINES]= '\0';
	gnome_config_set_string ("Game/Field", buf);
	g_free(buf);
	
	gnome_config_pop_prefix ();
	gnome_config_sync();
	
	argv[2]= gnome_config_get_real_path (prefix);
	gnome_client_set_discard_command (client, 3, argv);
	
	return TRUE;
}