void
panel_session_init (void)
{
	EggSMClientMode  mode;
	EggSMClient     *client;

	/* Explicitly tell the session manager we're ready -- we don't do it
	 * before. Note: this depends on setting the mode to DISABLED early
	 * during startup. */

        if (do_not_restart || getenv ("MATE_PANEL_DEBUG"))
		mode = EGG_SM_CLIENT_MODE_NO_RESTART;
	else
		mode = EGG_SM_CLIENT_MODE_NORMAL;

	egg_sm_client_set_mode (mode);

	client = egg_sm_client_get ();

	g_signal_connect (client, "quit",
			  G_CALLBACK (panel_session_handle_quit), NULL);

	/* We don't want the WM to try and save/restore our
	 * window position */
	gdk_set_sm_client_id (NULL);
}
static gboolean
sm_client_post_parse_func (GOptionContext  *context,
                           GOptionGroup    *group,
                           gpointer         data,
                           GError         **error)
{
  EggSMClient *client = egg_sm_client_get ();

  if (sm_client_id == NULL)
    {
      const gchar *desktop_autostart_id;

      desktop_autostart_id = g_getenv ("DESKTOP_AUTOSTART_ID");

      if (desktop_autostart_id != NULL)
        sm_client_id = g_strdup (desktop_autostart_id);
    }

  /* Unset DESKTOP_AUTOSTART_ID in order to avoid child processes to
   * use the same client id. */
  g_unsetenv ("DESKTOP_AUTOSTART_ID");

  if (EGG_SM_CLIENT_GET_CLASS (client)->startup)
    EGG_SM_CLIENT_GET_CLASS (client)->startup (client, sm_client_id);
  return TRUE;
}
Пример #3
0
static void
ev_application_init_session (EvApplication *application)
{
#ifdef WITH_SMCLIENT
	application->smclient = egg_sm_client_get ();
	g_signal_connect (application->smclient, "save_state",
			  G_CALLBACK (smclient_save_state_cb),
			  application);
	g_signal_connect (application->smclient, "quit",
			  G_CALLBACK (smclient_quit_cb),
			  application);
#endif
}
/**
 * egg_sm_client_end_session:
 * @style: a hint at how to end the session
 * @request_confirmation: whether or not the user should get a chance
 * to confirm the action
 *
 * Requests that the session manager end the current session. @style
 * indicates how the session should be ended, and
 * @request_confirmation indicates whether or not the user should be
 * given a chance to confirm the logout/reboot/shutdown. Both of these
 * flags are merely hints though; the session manager may choose to
 * ignore them.
 *
 * Return value: %TRUE if the request was sent; %FALSE if it could not
 * be (eg, because it could not connect to the session manager).
 **/
gboolean
egg_sm_client_end_session (EggSMClientEndStyle  style,
                           gboolean             request_confirmation)
{
  EggSMClient *client = egg_sm_client_get ();

  g_return_val_if_fail (EGG_IS_SM_CLIENT (client), FALSE);

  if (EGG_SM_CLIENT_GET_CLASS (client)->end_session)
    {
      return EGG_SM_CLIENT_GET_CLASS (client)->end_session (client, style,
                                                            request_confirmation);
    }
  else
    return FALSE;
}
Пример #5
0
int
main (int argc, char **argv)
{
  EggSMClient *client;
  GOptionContext *goption_context;
  GError *err = NULL;
  GtkWidget *label;

  g_type_init ();

  goption_context = g_option_context_new (_("- Test logout functionality"));
  g_option_context_add_group (goption_context, gtk_get_option_group (TRUE));
  g_option_context_add_group (goption_context, egg_sm_client_get_option_group ());

  if (!g_option_context_parse (goption_context, &argc, &argv, &err))
    {
      g_printerr ("Could not parse arguments: %s\n", err->message);
      g_error_free (err);
      return 1;
    }

  client = egg_sm_client_get ();
  g_signal_connect (client, "quit-requested",
		    G_CALLBACK (quit_requested), NULL);
  g_signal_connect (client, "quit-cancelled",
		    G_CALLBACK (quit_cancelled), NULL);
  g_signal_connect (client, "quit",
		    G_CALLBACK (quit), NULL);
  g_signal_connect (client, "save-state",
		    G_CALLBACK (save_state), NULL);

  main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (main_window), "Logout Test");
  g_signal_connect (main_window, "delete_event",
		    G_CALLBACK (window_closed), NULL);

  label = gtk_label_new ("Logout test running...");
  gtk_container_add (GTK_CONTAINER (main_window), label);

  gtk_widget_show_all (main_window);

  gtk_main ();
  return 0;
}
Пример #6
0
/**
 * main:
 * @argc: default arguments
 * @argv: default arguments
 *
 * Parses the options, daemonizes, starts HKP, DBus and Avahi
 *
 * Returns: 0 on success
 */
int main(int argc, char* argv[])
{
    GOptionContext *octx = NULL;
    GError *error = NULL;

    seahorse_secure_memory_init ();
    
    octx = g_option_context_new ("");
    g_option_context_add_main_entries (octx, options, GETTEXT_PACKAGE);
    g_option_context_add_group (octx, egg_sm_client_get_option_group ());

    if (!gtk_init_with_args (&argc, &argv, _("Encryption Daemon (Seahorse)"), 
                             (GOptionEntry *)options, GETTEXT_PACKAGE, &error)) {
	    g_printerr ("seahorse-daemon: %s\n", error->message);
	    g_error_free (error);
	    exit (1);
    }
     	 
	g_signal_connect (egg_sm_client_get (), "quit", G_CALLBACK (smclient_quit), NULL);

    /*
     * All functions after this point have to print messages
     * nicely and not just called exit()
     */
    daemonize ();

    /* Handle some signals */
    seahorse_unix_signal_register (SIGINT, unix_signal);
    seahorse_unix_signal_register (SIGTERM, unix_signal);

    /* We log to the syslog */
    prepare_logging ();

    /* Insert Icons into Stock */
    seahorse_gtkstock_init ();
   
    /* Make the default SeahorseContext */
    seahorse_context_new (SEAHORSE_CONTEXT_APP | SEAHORSE_CONTEXT_DAEMON);

    /* Load the various components */
    seahorse_pgp_module_init ();

    seahorse_context_refresh_auto (NULL);

    /* Initialize the various daemon components */
    seahorse_dbus_server_init ();

    /* Sometimes we've already gotten a quit signal */
    if(!daemon_quit) {
        daemon_running = TRUE;
        gtk_main ();
        g_message ("left gtk_main\n");
    }

    seahorse_dbus_server_cleanup ();

    g_option_context_free (octx);
    seahorse_context_destroy (SCTX_APP ());

    return 0;
}
Пример #7
0
static int
fr_application_command_line (GApplication            *application,
                             GApplicationCommandLine *command_line)
{
	char           **argv;
	int              argc;
	GOptionContext  *context;
	GError          *error = NULL;
	GFile           *extraction_destination = NULL;
	GFile           *add_to_archive = NULL;
	GFile           *default_directory = NULL;

	argv = g_application_command_line_get_arguments (command_line, &argc);

	/* parse command line options */

	context = fr_application_create_option_context ();
	if (! g_option_context_parse (context, &argc, &argv, &error)) {
		g_critical ("Failed to parse arguments: %s", error->message);
		g_error_free (error);
		g_option_context_free (context);

		return fr_application_command_line_finished (application, EXIT_FAILURE);
	}
	g_option_context_free (context);

	/* restore the session */

#ifdef USE_SMCLIENT
	{
		EggSMClient *client;

		client = egg_sm_client_get ();
		g_signal_connect (client,
				  "save_state",
				  G_CALLBACK (client_save_state),
				  NULL);
		g_signal_connect (client,
				  "quit",
				  G_CALLBACK (client_quit_cb),
				  NULL);
		if (egg_sm_client_is_resumed (client)) {
			fr_restore_session (client);
			return fr_application_command_line_finished (application, EXIT_SUCCESS);
		}
	}
#endif

	if (remaining_args == NULL) { /* No archive specified. */
		if (! arg_service)
			gtk_widget_show (fr_window_new ());
		return fr_application_command_line_finished (application, EXIT_SUCCESS);
	}

	if (arg_extract_to != NULL)
		extraction_destination = g_file_new_for_commandline_arg (arg_extract_to);

	if (arg_add_to != NULL)
		add_to_archive = g_file_new_for_commandline_arg (arg_add_to);

	if (arg_default_dir != NULL)
		default_directory = g_file_new_for_commandline_arg (arg_default_dir);

	if ((arg_add_to != NULL) || (arg_add == 1)) { /* Add files to an archive */
		GtkWidget   *window;
		GList       *file_list;
		const char  *filename;
		int          i = 0;

		window = fr_window_new ();

		if (default_directory != NULL)
			fr_window_set_default_dir (FR_WINDOW (window), default_directory, TRUE);

		file_list = NULL;
		while ((filename = remaining_args[i++]) != NULL)
			file_list = g_list_prepend (file_list, g_file_new_for_commandline_arg (filename));
		file_list = g_list_reverse (file_list);

		fr_window_new_batch (FR_WINDOW (window), _("Compress"));
		fr_window_set_batch__add (FR_WINDOW (window), add_to_archive, file_list);

		if (! arg_notify)
			fr_window_append_batch_action (FR_WINDOW (window), FR_BATCH_ACTION_QUIT, NULL, NULL);
		else
			fr_window_set_notify (FR_WINDOW (window), TRUE);
		fr_window_start_batch (FR_WINDOW (window));

		_g_object_list_unref (file_list);
	}
	else if ((arg_extract_to != NULL) || (arg_extract == 1) || (arg_extract_here == 1)) {

		/* Extract all archives. */

		GtkWidget  *window;
		const char *archive;
		int         i = 0;

		window = fr_window_new ();

		if (default_directory != NULL)
			fr_window_set_default_dir (FR_WINDOW (window), default_directory, TRUE);

		fr_window_new_batch (FR_WINDOW (window), _("Extract archive"));
		while ((archive = remaining_args[i++]) != NULL) {
			GFile *file;

			file = g_file_new_for_commandline_arg (archive);
			if (arg_extract_here == 1)
				fr_window_set_batch__extract_here (FR_WINDOW (window), file);
			else
				fr_window_set_batch__extract (FR_WINDOW (window), file, extraction_destination);

			g_object_unref (file);
		}
		if (! arg_notify)
			fr_window_append_batch_action (FR_WINDOW (window), FR_BATCH_ACTION_QUIT, NULL, NULL);
		else
			fr_window_set_notify (FR_WINDOW (window), TRUE);

		fr_window_start_batch (FR_WINDOW (window));
	}
	else { /* Open each archive in a window */
		const char *filename = NULL;

		int i = 0;
		while ((filename = remaining_args[i++]) != NULL) {
			GtkWidget *window;
			GFile     *file;

			window = fr_window_new ();
			gtk_widget_show (window);

			file = g_file_new_for_commandline_arg (filename);
			fr_window_archive_open (FR_WINDOW (window), file, GTK_WINDOW (window));

			g_object_unref (file);
		}
	}

	_g_object_unref (default_directory);
	_g_object_unref (add_to_archive);
	_g_object_unref (extraction_destination);

	return fr_application_command_line_finished (application, EXIT_SUCCESS);
}