Exemple #1
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;
}
Exemple #2
0
static GOptionContext *
fr_application_create_option_context (void)
{
	GOptionContext *context;
	static gsize    initialized = FALSE;

	context = g_option_context_new (N_("- Create and modify an archive"));
	g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
	g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
	g_option_context_set_ignore_unknown_options (context, TRUE);

	if (g_once_init_enter (&initialized)) {
		g_option_context_add_group (context, gtk_get_option_group (TRUE));
#ifdef USE_SMCLIENT
		g_option_context_add_group (context, egg_sm_client_get_option_group ());
#endif
		g_once_init_leave (&initialized, TRUE);
	}

	return context;
}
int
main (int argc, char **argv)
{
	char           *desktopfile;
	GOptionContext *context;
	GError         *error;

	bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);

	/* We will register explicitly when we're ready -- see panel-session.c */
	egg_sm_client_set_mode (EGG_SM_CLIENT_MODE_DISABLED);

	g_set_prgname ("mate-panel");

	desktopfile = panel_g_lookup_in_applications_dirs ("mate-panel.desktop");
	if (desktopfile) {
		egg_set_desktop_file (desktopfile);
		g_free (desktopfile);
	}

	context = g_option_context_new ("");
	g_option_context_add_group (context,
				    egg_sm_client_get_option_group ());
	g_option_context_add_group (context, gtk_get_option_group (TRUE));
	g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);

	gtk_init (&argc, &argv);

	error = NULL;
	if (!g_option_context_parse (context, &argc, &argv, &error)) {
		g_printerr ("%s\n", error->message);
		g_error_free (error);
		g_option_context_free (context);

		return 1;
	}

	g_option_context_free (context);

	/* reset the configuration and exit. */
	if (reset == TRUE)
	{
		panel_reset();
		return 0;
	}


	if (!egg_get_desktop_file ()) {
		g_set_application_name (_("Panel"));
		gtk_window_set_default_icon_name (PANEL_ICON_PANEL);
	}

	if (!panel_shell_register (replace)) {
		panel_cleanup_do ();
		return -1;
	}

	panel_action_protocol_init ();
	panel_multiscreen_init ();
	panel_init_stock_icons_and_items ();

	mateconf_client_add_dir (panel_mateconf_get_client (),
			      "/desktop/mate/interface",
			      MATECONF_CLIENT_PRELOAD_NONE,
			      NULL);

	panel_global_config_load ();
	panel_lockdown_init ();
	panel_profile_load ();

	/*add forbidden lists to ALL panels*/
	g_slist_foreach (panels,
			 (GFunc)panel_widget_add_forbidden,
			 NULL);

	xstuff_init ();

	/* Flush to make sure our struts are seen by everyone starting
	 * immediate after (eg, the caja desktop). */
	gdk_flush ();

	/* Do this at the end, to be sure that we're really ready when
	 * connecting to the session manager */
	panel_session_init ();

	gtk_main ();

	panel_lockdown_finalize ();

	mateconf_client_remove_dir (panel_mateconf_get_client (),
				 "/desktop/mate/interface",
				 NULL);

	panel_cleanup_do ();

	return 0;
}
Exemple #4
0
int
main (int argc, char **argv)
{
	DBusGConnection *session_bus;
	GError *error = NULL;
	RBShell *rb_shell;
	gboolean activated;
	gboolean autostarted;
	char *accel_map_file = NULL;
	char *desktop_file_path;

	GOptionContext *context;
	static const GOptionEntry options []  = {
		{ "debug",           'd', 0, G_OPTION_ARG_NONE,         &debug,           N_("Enable debug output"), NULL },
		{ "debug-match",     'D', 0, G_OPTION_ARG_STRING,       &debug_match,     N_("Enable debug output matching a specified string"), NULL },
		{ "no-update",	       0, 0, G_OPTION_ARG_NONE,         &no_update,       N_("Do not update the library with file changes"), NULL },
		{ "no-registration", 'n', 0, G_OPTION_ARG_NONE,         &no_registration, N_("Do not register the shell"), NULL },
		{ "dry-run",	       0, 0, G_OPTION_ARG_NONE,         &dry_run,         N_("Don't save any data permanently (implies --no-registration)"), NULL },
		{ "disable-plugins",   0, 0, G_OPTION_ARG_NONE,         &disable_plugins, N_("Disable loading of plugins"), NULL },
		{ "rhythmdb-file",     0, 0, G_OPTION_ARG_STRING,       &rhythmdb_file,   N_("Path for database file to use"), NULL },
		{ "playlists-file",    0, 0, G_OPTION_ARG_STRING,       &playlists_file,   N_("Path for playlists file to use"), NULL },
		{ "quit",	     'q', 0, G_OPTION_ARG_NONE,         &quit,            N_("Quit Rhythmbox"), NULL },
		{ G_OPTION_REMAINING,  0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining_args,  NULL, N_("[URI...]") },
		{ NULL }
	};

	g_thread_init (NULL);

	rb_profile_start ("starting rhythmbox");

	autostarted = (g_getenv ("DESKTOP_AUTOSTART_ID") != NULL);

#ifdef USE_UNINSTALLED_DIRS
	desktop_file_path = g_build_filename (SHARE_UNINSTALLED_BUILDDIR, "rhythmbox.desktop", NULL);

	g_setenv ("GSETTINGS_SCHEMA_DIR", SHARE_UNINSTALLED_BUILDDIR, TRUE);
#else
	desktop_file_path = g_build_filename (DATADIR, "applications", "rhythmbox.desktop", NULL);
#endif
	egg_set_desktop_file (desktop_file_path);
	g_free (desktop_file_path);

	context = g_option_context_new (NULL);
	g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);

	rb_profile_start ("initializing gstreamer");
	g_option_context_add_group (context, gst_init_get_option_group ());
	rb_profile_end ("initializing gstreamer");

	g_option_context_add_group (context, egg_sm_client_get_option_group ());
	g_option_context_add_group (context, gtk_get_option_group (TRUE));

	setlocale (LC_ALL, NULL);

	rb_profile_start ("parsing command line options");
	if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) {
		g_print (_("%s\nRun '%s --help' to see a full list of available command line options.\n"),
			 error->message, argv[0]);
		g_error_free (error);
		g_option_context_free (context);
		exit (1);
	}
	g_option_context_free (context);
	rb_profile_end ("parsing command line options");

	g_random_set_seed (time (0));

#ifdef ENABLE_NLS
	/* initialize i18n */
	bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");

	/* ask for utf-8 message text from GStreamer too,
	 * since it doesn't do that itself.
	 */
	bind_textdomain_codeset ("gstreamer-0.10", "UTF-8");
	textdomain (GETTEXT_PACKAGE);
#endif

	if (!debug && debug_match)
		rb_debug_init_match (debug_match);
	else
		rb_debug_init (debug);
	rb_debug ("initializing Rhythmbox %s", VERSION);

#if defined(USE_UNINSTALLED_DIRS)
	g_irepository_prepend_search_path (SHARE_UNINSTALLED_BUILDDIR "/../bindings/gi");
#endif

	/* TODO: kill this function */
	rb_threads_init ();
	gdk_threads_enter ();

	activated = FALSE;

	rb_debug ("going to create DBus object");

	dbus_g_thread_init ();

	session_bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
	if (session_bus == NULL) {
		g_warning ("couldn't connect to session bus: %s", (error) ? error->message : "(null)");
		g_clear_error (&error);
	} else if (!no_registration) {
		guint request_name_reply;
		int flags;
#ifndef DBUS_NAME_FLAG_DO_NOT_QUEUE
		flags = DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT;
#else
		flags = DBUS_NAME_FLAG_DO_NOT_QUEUE;
#endif

		DBusGProxy *bus_proxy;

		bus_proxy = dbus_g_proxy_new_for_name (session_bus,
						       "org.freedesktop.DBus",
						       "/org/freedesktop/DBus",
						       "org.freedesktop.DBus");

		if (!dbus_g_proxy_call (bus_proxy,
					"RequestName",
					&error,
					G_TYPE_STRING,
					"org.gnome.Rhythmbox",
					G_TYPE_UINT,
					flags,
					G_TYPE_INVALID,
					G_TYPE_UINT,
					&request_name_reply,
					G_TYPE_INVALID)) {
			g_warning ("Failed to invoke RequestName: %s",
				   error->message);
		}
		g_object_unref (bus_proxy);

		if (request_name_reply == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER
		    || request_name_reply == DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER)
			activated = FALSE;
		else if (request_name_reply == DBUS_REQUEST_NAME_REPLY_EXISTS
			 || request_name_reply == DBUS_REQUEST_NAME_REPLY_IN_QUEUE)
			activated = TRUE;
		else {
			g_warning ("Got unhandled reply %u from RequestName",
				   request_name_reply);
			activated = FALSE;
		}
	}

	if (!activated) {
		if (quit) {
			rb_debug ("was asked to quit, but no instance was running");
			gdk_notify_startup_complete ();
			exit (0);
		}
#ifdef WITH_RHYTHMDB_GDA
		gda_init (PACKAGE, VERSION, argc, argv);
#endif

		rb_refstring_system_init ();

#ifdef USE_UNINSTALLED_DIRS
		rb_file_helpers_init (TRUE);
#else
		rb_file_helpers_init (FALSE);
#endif

		/* XXX not sure what to do with this.  should we move it to
		 * the config dir, or leave it where it is?
		 */
		accel_map_file = g_build_filename (g_get_home_dir (),
						   ".gnome2",
						   "accels",
						   "rhythmbox",
						   NULL);
		gtk_accel_map_load (accel_map_file);


		rb_debug ("Going to create a new shell");

		rb_stock_icons_init ();

		g_setenv ("PULSE_PROP_media.role", "music", TRUE);

		rb_shell = rb_shell_new (no_registration, no_update, dry_run, autostarted, disable_plugins, rhythmdb_file, playlists_file);
		g_object_weak_ref (G_OBJECT (rb_shell), main_shell_weak_ref_cb, NULL);
		if (!no_registration && session_bus != NULL) {
			dbus_g_object_type_install_info (RB_TYPE_SHELL, &dbus_glib_rb_shell_object_info);
			dbus_g_connection_register_g_object (session_bus, "/org/gnome/Rhythmbox/Shell", G_OBJECT (rb_shell));

			g_signal_connect (G_OBJECT (rb_shell),
					  "database-load-complete",
					  G_CALLBACK (database_load_complete),
					  NULL);
		}
	} else if (!no_registration && session_bus != NULL) {
		DBusGProxy *shell_proxy;
		guint32 current_time;
		current_time = gdk_x11_display_get_user_time (gdk_display_get_default ());
		shell_proxy = dbus_g_proxy_new_for_name_owner (session_bus,
							       "org.gnome.Rhythmbox",
							       "/org/gnome/Rhythmbox/Shell",
							       "org.gnome.Rhythmbox.Shell",
							       &error);
		if (!shell_proxy) {
			g_warning ("Couldn't create proxy for Rhythmbox shell: %s",
				   error->message);
		} else {
			if (quit) {
				dbus_g_proxy_call_no_reply (shell_proxy, "quit",
							    G_TYPE_INVALID);
			} else {
				load_uri_args ((const char **) remaining_args, (GFunc) dbus_load_uri, shell_proxy);
				dbus_g_proxy_call_no_reply (shell_proxy, "present",
							    G_TYPE_UINT, current_time,
							    G_TYPE_INVALID);
			}
			g_object_unref (G_OBJECT (shell_proxy));
		}
	}

	if (activated) {
		gdk_notify_startup_complete ();
	} else {

		rb_profile_start ("mainloop");
#ifdef ENABLE_PYTHON
		if (rb_python_init_successful ()) {
			pyg_begin_allow_threads;
			gtk_main ();
			pyg_end_allow_threads;
		} else {
			gtk_main ();
		}
#else
		gtk_main ();
#endif
		rb_profile_end ("mainloop");

		rb_debug ("out of toplevel loop");

		rb_file_helpers_shutdown ();
		rb_stock_icons_shutdown ();
		rb_refstring_system_shutdown ();
	}

	gst_deinit ();

	rb_debug ("THE END");
	rb_profile_end ("starting rhythmbox");

	if (accel_map_file != NULL) {
		gtk_accel_map_save (accel_map_file);
	}

	gdk_threads_leave ();

	exit (0);
}
int
main (int argc, char *argv[])
{
    gboolean kill_shell;
    gboolean no_default_window;
    gboolean browser_window;
    gboolean no_desktop;
    gboolean version;
    gboolean autostart_mode;
    const char *autostart_id;
    gchar *geometry;
    gchar **remaining;
    gboolean perform_self_check;
    CajaApplication *application;
    GOptionContext *context;
    GFile *file = NULL;
    GFileInfo *fileinfo = NULL;
    GAppInfo *appinfo = NULL;
    char *uri = NULL;
    char **uris = NULL;
    GPtrArray *uris_array;
    GError *error;
    int i;

    const GOptionEntry options[] =
    {
#ifndef CAJA_OMIT_SELF_CHECK
        {
            "check", 'c', 0, G_OPTION_ARG_NONE, &perform_self_check,
            N_("Perform a quick set of self-check tests."), NULL
        },
#endif
        {
            "version", '\0', 0, G_OPTION_ARG_NONE, &version,
            N_("Show the version of the program."), NULL
        },
        {
            "geometry", 'g', 0, G_OPTION_ARG_STRING, &geometry,
            N_("Create the initial window with the given geometry."), N_("GEOMETRY")
        },
        {
            "no-default-window", 'n', 0, G_OPTION_ARG_NONE, &no_default_window,
            N_("Only create windows for explicitly specified URIs."), NULL
        },
        {
            "no-desktop", '\0', 0, G_OPTION_ARG_NONE, &no_desktop,
            N_("Do not manage the desktop (ignore the preference set in the preferences dialog)."), NULL
        },
        {
            "browser", '\0', 0, G_OPTION_ARG_NONE, &browser_window,
            N_("open a browser window."), NULL
        },
        {
            "quit", 'q', 0, G_OPTION_ARG_NONE, &kill_shell,
            N_("Quit Caja."), NULL
        },
        { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining, NULL,  N_("[URI...]") },

        { NULL }
    };

#if defined (HAVE_MALLOPT) && defined(M_MMAP_THRESHOLD)
    /* Caja uses lots and lots of small and medium size allocations,
     * and then a few large ones for the desktop background. By default
     * glibc uses a dynamic treshold for how large allocations should
     * be mmaped. Unfortunately this triggers quickly for caja when
     * it does the desktop background allocations, raising the limit
     * such that a lot of temporary large allocations end up on the
     * heap and are thus not returned to the OS. To fix this we set
     * a hardcoded limit. I don't know what a good value is, but 128K
     * was the old glibc static limit, lets use that.
     */
    mallopt (M_MMAP_THRESHOLD, 128 *1024);
#endif

    g_thread_init (NULL);

    /* This will be done by gtk+ later, but for now, force it to MATE */
    g_desktop_app_info_set_desktop_env ("MATE");

    if (g_getenv ("CAJA_DEBUG") != NULL)
    {
        eel_make_warnings_and_criticals_stop_in_debugger ();
    }

    /* Initialize gettext support */
    bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
    textdomain (GETTEXT_PACKAGE);

    autostart_mode = FALSE;

    autostart_id = g_getenv ("DESKTOP_AUTOSTART_ID");
    if (autostart_id != NULL && *autostart_id != '\0')
    {
        autostart_mode = TRUE;
    }

    /* Get parameters. */
    remaining = NULL;
    geometry = NULL;
    version = FALSE;
    kill_shell = FALSE;
    no_default_window = FALSE;
    no_desktop = FALSE;
    perform_self_check = FALSE;
    browser_window = FALSE;

    g_set_prgname ("caja");

    if (g_file_test (DATADIR "/applications/caja.desktop", G_FILE_TEST_EXISTS))
    {
        egg_set_desktop_file (DATADIR "/applications/caja.desktop");
    }

    context = g_option_context_new (_("\n\nBrowse the file system with the file manager"));
    g_option_context_add_main_entries (context, options, NULL);

    g_option_context_add_group (context, gtk_get_option_group (TRUE));
    g_option_context_add_group (context, egg_sm_client_get_option_group ());

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

    g_option_context_free (context);

    if (version)
    {
        g_print ("MATE caja " PACKAGE_VERSION "\n");
        return 0;
    }

#ifdef HAVE_EXEMPI
    xmp_init();
#endif

    setup_debug_log ();

    /* If in autostart mode (aka started by mate-session), we need to ensure
         * caja starts with the correct options.
         */
    if (autostart_mode)
    {
        no_default_window = TRUE;
        no_desktop = FALSE;
    }

    if (perform_self_check && remaining != NULL)
    {
        /* translators: %s is an option (e.g. --check) */
        fprintf (stderr, _("caja: %s cannot be used with URIs.\n"),
                 "--check");
        return EXIT_FAILURE;
    }
    if (perform_self_check && kill_shell)
    {
        fprintf (stderr, _("caja: --check cannot be used with other options.\n"));
        return EXIT_FAILURE;
    }
    if (kill_shell && remaining != NULL)
    {
        fprintf (stderr, _("caja: %s cannot be used with URIs.\n"),
                 "--quit");
        return EXIT_FAILURE;
    }
    if (geometry != NULL && remaining != NULL && remaining[0] != NULL && remaining[1] != NULL)
    {
        fprintf (stderr, _("caja: --geometry cannot be used with more than one URI.\n"));
        return EXIT_FAILURE;
    }

    /* Initialize the services that we use. */
    LIBXML_TEST_VERSION

    /* Initialize preferences. This is needed so that proper
     * defaults are available before any preference peeking
     * happens.
     */
    caja_global_preferences_init ();

    /* exit_with_last_window being FALSE, caja can run without window. */
    exit_with_last_window = g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_EXIT_WITH_LAST_WINDOW);

    application = NULL;

    /* Do either the self-check or the real work. */
    if (perform_self_check)
    {
		#ifndef CAJA_OMIT_SELF_CHECK
			/* Run the checks (each twice) for caja and libcaja-private. */

			caja_run_self_checks ();
			caja_run_lib_self_checks ();
			eel_exit_if_self_checks_failed ();

			caja_run_self_checks ();
			caja_run_lib_self_checks ();
			eel_exit_if_self_checks_failed ();
		#endif
    }
    else
    {
        /* Convert args to URIs */
        if (remaining != NULL)
        {
            uris_array = g_ptr_array_new ();
            for (i = 0; remaining[i] != NULL; i++)
            {
                file = g_file_new_for_commandline_arg (remaining[i]);
                if (file != NULL)
                {
                    uri = g_file_get_uri (file);
                    if (uri)
                    {
                        fileinfo = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL);
                        if (fileinfo && g_file_info_get_file_type(fileinfo) == G_FILE_TYPE_DIRECTORY)
                        {
                            g_ptr_array_add (uris_array, uri);
                        }
                        else
                        {
                            if (fileinfo)
                                g_object_unref (fileinfo);
                            fileinfo = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL);
                            if (fileinfo)
                            {
                                appinfo = g_app_info_get_default_for_type (g_file_info_get_content_type (fileinfo), TRUE);
                                if (appinfo)
                                {
                                    if (g_strcmp0 (g_app_info_get_executable (appinfo), "caja") != 0)
                                    {
                                        g_app_info_launch_default_for_uri (uri, NULL, NULL);
                                    }
                                    else
                                    {
                                        fprintf (stderr, _("caja: set erroneously as default application for '%s' content type.\n"),
                                                 g_file_info_get_content_type (fileinfo));
                                    }
                                    g_object_unref (appinfo);
                                }
                                g_free (uri);
                            }
                            else
                            {
                                g_ptr_array_add (uris_array, uri);
                            }
                        }
                        if (fileinfo)
                            g_object_unref (fileinfo);
                    }
                    if (file)
                        g_object_unref (file);
                }
            }
            if (uris_array->len == 0)
            {
                /* Caja is being used only to open files (not directories), so closing */
                g_strfreev (remaining);
                return EXIT_SUCCESS;
            }
            g_ptr_array_add (uris_array, NULL);
            uris = (char**) g_ptr_array_free (uris_array, FALSE);
            g_strfreev (remaining);
        }


        /* Run the caja application. */
        application = caja_application_new ();

        if (egg_sm_client_is_resumed (application->smclient))
        {
            no_default_window = TRUE;
        }

        caja_application_startup
        (application,
         kill_shell, no_default_window, no_desktop,
         browser_window,
         geometry,
         uris);
        g_strfreev (uris);

        if (unique_app_is_running (application->unique_app) ||
                kill_shell)
        {
            exit_with_last_window = TRUE;
        }

        if (is_event_loop_needed ())
        {
            gtk_main ();
        }
    }

    caja_icon_info_clear_caches ();

    if (application != NULL)
    {
        g_object_unref (application);
    }

    eel_debug_shut_down ();

    caja_application_save_accel_map (NULL);

    return EXIT_SUCCESS;
}
Exemple #6
0
int
main (int argc, char *argv[])
{
	GOptionContext *context;
	PlumaPluginsEngine *engine;
	PlumaWindow *window;
	PlumaApp *app;
	gboolean restored = FALSE;
	GError *error = NULL;
	gchar *dir;
	gchar *icon_dir;


	/* Setup debugging */
	pluma_debug_init ();
	pluma_debug_message (DEBUG_APP, "Startup");

	setlocale (LC_ALL, "");

	dir = pluma_dirs_get_pluma_locale_dir ();
	bindtextdomain (GETTEXT_PACKAGE, dir);
	g_free (dir);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);

	startup_timestamp = get_startup_timestamp();

	/* Setup command line options */
	context = g_option_context_new (_("- Edit text files"));
	g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
	g_option_context_add_group (context, gtk_get_option_group (FALSE));
	g_option_context_add_group (context, egg_sm_client_get_option_group ());

	gtk_init (&argc, &argv);

	if (!g_option_context_parse (context, &argc, &argv, &error))
	{
		g_print(_("%s\nRun '%s --help' to see a full list of available command line options.\n"),
		        error->message, argv[0]);
		g_error_free (error);
		g_option_context_free (context);
		return 1;
	}

	g_option_context_free (context);

	pluma_debug_message (DEBUG_APP, "Create bacon connection");

	connection = bacon_message_connection_new ("pluma");

	if (connection != NULL)
	{
		if (!bacon_message_connection_get_is_server (connection))
		{
			pluma_debug_message (DEBUG_APP, "I'm a client");

			pluma_get_command_line_data ();

			send_bacon_message ();

			free_command_line_data ();

			/* we never popup a window... tell startup-notification
			 * that we are done.
			 */
			gdk_notify_startup_complete ();

			bacon_message_connection_free (connection);

			exit (0);
		}
		else
		{
		  	pluma_debug_message (DEBUG_APP, "I'm a server");

			bacon_message_connection_set_callback (connection,
							       on_message_received,
							       NULL);
		}
	}
	else
	{
		g_warning ("Cannot create the 'pluma' connection.");
	}

	pluma_debug_message (DEBUG_APP, "Set icon");

	dir = pluma_dirs_get_pluma_data_dir ();
	icon_dir = g_build_filename (dir,
				     "icons",
				     NULL);
	g_free (dir);

	gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
					   icon_dir);
	g_free (icon_dir);

	/* Set the associated .desktop file */
	egg_set_desktop_file (DATADIR "/applications/pluma.desktop");

	/* Load user preferences */
	pluma_debug_message (DEBUG_APP, "Init prefs manager");
	pluma_prefs_manager_app_init ();

	/* Init plugins engine */
	pluma_debug_message (DEBUG_APP, "Init plugins");
	engine = pluma_plugins_engine_get_default ();

	/* Initialize session management */
	pluma_debug_message (DEBUG_APP, "Init session manager");
	pluma_session_init ();

	if (pluma_session_is_restored ())
		restored = pluma_session_load ();

	if (!restored)
	{
		pluma_debug_message (DEBUG_APP, "Analyze command line data");
		pluma_get_command_line_data ();

		pluma_debug_message (DEBUG_APP, "Get default app");
		app = pluma_app_get_default ();

		pluma_debug_message (DEBUG_APP, "Create main window");
		window = pluma_app_create_window (app, NULL);

		if (file_list != NULL)
		{
			const PlumaEncoding *encoding = NULL;

			if (encoding_charset)
				encoding = pluma_encoding_get_from_charset (encoding_charset);

			pluma_debug_message (DEBUG_APP, "Load files");
			_pluma_cmd_load_files_from_prompt (window,
							   file_list,
							   encoding,
							   line_position);
		}
		else
		{
			pluma_debug_message (DEBUG_APP, "Create tab");
			pluma_window_create_tab (window, TRUE);
		}

		pluma_debug_message (DEBUG_APP, "Show window");
		gtk_widget_show (GTK_WIDGET (window));

		free_command_line_data ();
	}

	pluma_debug_message (DEBUG_APP, "Start gtk-main");

	gtk_main();

	bacon_message_connection_free (connection);

	/* We kept the original engine reference here. So let's unref it to
	 * finalize it properly.
	 */
	g_object_unref (engine);
	pluma_prefs_manager_app_shutdown ();

#ifndef ENABLE_GVFS_METADATA
	pluma_metadata_manager_shutdown ();
#endif

	return 0;
}
Exemple #7
0
int
main (int argc, char **argv)
{
	int i;
	char **argv_copy;
	int argc_copy;
	const char *startup_id, *display_name, *home_dir;
	GdkDisplay *display;
	TerminalOptions *options;
	GError *error = NULL;
	char *working_directory;
	int ret = EXIT_SUCCESS;

	setlocale (LC_ALL, "");

	bindtextdomain (GETTEXT_PACKAGE, TERM_LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);

	_terminal_debug_init ();

	/* Make a NULL-terminated copy since we may need it later */
	argv_copy = g_new (char *, argc + 1);
	for (i = 0; i < argc; ++i)
		argv_copy [i] = argv [i];
	argv_copy [i] = NULL;
	argc_copy = argc;

	startup_id = g_getenv ("DESKTOP_STARTUP_ID");

	working_directory = g_get_current_dir ();

	/* Now change directory to $HOME so we don't prevent unmounting, e.g. if the
	 * factory is started by caja-open-terminal. See bug #565328.
	 * On failure back to /.
	 */
	home_dir = g_get_home_dir ();
	if (home_dir == NULL || chdir (home_dir) < 0)
		(void) chdir ("/");

	options = terminal_options_parse (working_directory,
	                                  NULL,
	                                  startup_id,
	                                  NULL,
	                                  FALSE,
	                                  FALSE,
	                                  &argc, &argv,
	                                  &error,
	                                  gtk_get_option_group (TRUE),
	                                  egg_sm_client_get_option_group (),
	                                  NULL);

	g_free (working_directory);

	if (options == NULL)
	{
		g_printerr (_("Failed to parse arguments: %s\n"), error->message);
		g_error_free (error);
		exit (EXIT_FAILURE);
	}

	g_set_application_name (_("Terminal"));

	/* Unset the these env variables, so they doesn't end up
	 * in the factory's env and thus in the terminals' envs.
	 */
	g_unsetenv ("DESKTOP_STARTUP_ID");
	g_unsetenv ("GIO_LAUNCHED_DESKTOP_FILE_PID");
	g_unsetenv ("GIO_LAUNCHED_DESKTOP_FILE");

	display = gdk_display_get_default ();
	display_name = gdk_display_get_name (display);
	options->display_name = g_strdup (display_name);

	if (options->startup_id == NULL)
	{
		/* Create a fake one containing a timestamp that we can use */
		Time timestamp;

		timestamp = slowly_and_stupidly_obtain_timestamp (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));

		options->startup_id = g_strdup_printf ("_TIME%lu", timestamp);
	}

	if (options->use_factory)
	{
		OwnData *data;
		guint owner_id;

		data = g_new (OwnData, 1);
		data->factory_name = get_factory_name_for_display (display_name);
		data->options = options;
		data->exit_code = -1;
		data->argv = argv_copy;
		data->argc = argc_copy;

		gtk_init(&argc, &argv);
		options->initial_workspace = get_initial_workspace ();

		owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
		                           data->factory_name,
		                           G_BUS_NAME_OWNER_FLAGS_NONE,
		                           bus_acquired_cb,
		                           name_acquired_cb,
		                           name_lost_cb,
		                           data, NULL);

		gtk_main ();

		ret = data->exit_code;
		g_bus_unown_name (owner_id);

		g_free (data->factory_name);
		g_free (data);

	}
	else
	{

		terminal_app_handle_options (terminal_app_get (), options, TRUE /* allow resume */, &error);
		terminal_options_free (options);

		if (error == NULL)
		{
			gtk_main ();
		}
		else
		{
			g_printerr ("Error handling options: %s\n", error->message);
			g_error_free (error);
			ret = EXIT_FAILURE;
		}
	}

	terminal_app_shutdown ();

	g_free (argv_copy);

	return ret;
}
Exemple #8
0
int
main (int argc, char **argv)
{
	char           *desktopfile;
	GOptionContext *context;
	GError         *error;

	bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);

	/* We will register explicitly when we're ready -- see panel-session.c */
	egg_sm_client_set_mode (EGG_SM_CLIENT_MODE_DISABLED);

	g_set_prgname ("gnome-panel");

	desktopfile = panel_g_lookup_in_applications_dirs ("gnome-panel.desktop");
	if (desktopfile) {
		egg_set_desktop_file (desktopfile);
		g_free (desktopfile);
	}

	context = g_option_context_new ("");
	g_option_context_add_group (context,
				    egg_sm_client_get_option_group ());
	g_option_context_add_group (context, gtk_get_option_group (TRUE));
	g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);

	gtk_init (&argc, &argv);

	error = NULL;
	if (!g_option_context_parse (context, &argc, &argv, &error)) {
		g_printerr ("%s\n", error->message);
		g_error_free (error);
		g_option_context_free (context);

		return 1;
	}

	g_option_context_free (context);

	if (!egg_get_desktop_file ()) {
		g_set_application_name (_("Panel"));
		gtk_window_set_default_icon_name (PANEL_ICON_PANEL);
	}

	if (!panel_shell_register (replace)) {
		panel_cleanup_do ();
		return 1;
	}

	panel_action_protocol_init ();
	panel_multiscreen_init ();
	panel_init_stock_icons_and_items ();

	if (!panel_layout_load ()) {
		panel_cleanup_do ();
		return 1;
	}

	xstuff_init ();

	/* Flush to make sure our struts are seen by everyone starting
	 * immediate after (eg, the nautilus desktop). */
	gdk_flush ();

	/* Do this at the end, to be sure that we're really ready when
	 * connecting to the session manager */
	panel_session_init ();

	gtk_main ();

	panel_cleanup_do ();

	return 0;
}
Exemple #9
0
int
main (int argc, char *argv[])
{
	GOptionContext *context;
	GError         *error = NULL;

#ifdef G_OS_WIN32

    if (fileno (stdout) != -1 &&
 	  _get_osfhandle (fileno (stdout)) != -1)
	{
	  /* stdout is fine, presumably redirected to a file or pipe */
	}
    else
    {
	  typedef BOOL (* WINAPI AttachConsole_t) (DWORD);

	  AttachConsole_t p_AttachConsole =
	    (AttachConsole_t) GetProcAddress (GetModuleHandle ("kernel32.dll"), "AttachConsole");

	  if (p_AttachConsole != NULL && p_AttachConsole (ATTACH_PARENT_PROCESS))
      {
	      freopen ("CONOUT$", "w", stdout);
	      dup2 (fileno (stdout), 1);
	      freopen ("CONOUT$", "w", stderr);
	      dup2 (fileno (stderr), 2);

      }
	}
#endif

#if (!GLIB_CHECK_VERSION(2,31,0))
/* Remove this once we bump dependencies to glib >= 2.31.0 */
	/* Init glib threads asap */
	if (!g_thread_supported ())
		g_thread_init (NULL);
#endif

#ifdef ENABLE_NLS
	/* Initialize the i18n stuff */
	bindtextdomain (GETTEXT_PACKAGE, ev_get_locale_dir());
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
#endif

	context = g_option_context_new (N_("GNOME Document Viewer"));
	g_option_context_set_translation_domain(context, GETTEXT_PACKAGE);
	g_option_context_add_main_entries (context, goption_options, GETTEXT_PACKAGE);

#ifdef WITH_SMCLIENT
	g_option_context_add_group (context, egg_sm_client_get_option_group ());
#endif

	g_option_context_add_group (context, gtk_get_option_group (TRUE));

	if (!g_option_context_parse (context, &argc, &argv, &error)) {
		g_printerr ("Cannot parse arguments: %s\n", error->message);
		g_error_free (error);
		g_option_context_free (context);

		return 1;
	}
	g_option_context_free (context);

	if (preview_mode) {
		gboolean retval;
		
		retval = launch_previewer ();
		
		return retval ? 0 : 1;
	}

        if (!ev_init ())
                return 1;

	ev_stock_icons_init ();

#if defined(WITH_SMCLIENT) && defined(GDK_WINDOWING_X11)
	egg_set_desktop_file (GNOMEDATADIR "/applications/evince.desktop");
#else
	/* Manually set name and icon */
	g_set_application_name (_("Document Viewer"));
	gtk_window_set_default_icon_name ("evince");
#endif /* WITH_SMCLIENT && GDK_WINDOWING_X11 */

	ev_application_load_session (EV_APP);
	load_files (file_arguments);

	/* Change directory so we don't prevent unmounting in case the initial cwd
	 * is on an external device (see bug #575436)
	 */
	g_chdir (g_get_home_dir ());

	gtk_main ();

	ev_shutdown ();
	ev_stock_icons_shutdown ();

	return 0;
}
Exemple #10
0
gboolean parse_options(int *argc, char ***argv)
{
    GError *error = NULL;
    GOptionContext *context = NULL;

    GOptionEntry entries[] =
    {
        {
            "fullscreen", 0, 0, G_OPTION_ARG_NONE,
            &(settings.fullscreen), N_("Start the program in full screen"), NULL
        },
        {
            "version", 'v', 0, G_OPTION_ARG_NONE,
            &(settings.show_version), N_("Show program version and revision"), NULL
        },
        {
            "quit", 'q', 0, G_OPTION_ARG_NONE,
            &(settings.quit), N_("Quits the running gmpc"), NULL
        },
        {
            "disable-plugins", 0, 0, G_OPTION_ARG_NONE,
            &(settings.disable_plugins), N_("Don't load the plugins"), NULL
        },
        {
            "config", 0, 0, G_OPTION_ARG_FILENAME,
            &(settings.config_path), N_("Load alternative config file"), "Path"
        },
        {
            "debug-level", 'd', 0, G_OPTION_ARG_INT,
            &(settings.debug_level), N_("Set the debug level"), "level"
        },
        {
            "start-hidden", 'h', 0, G_OPTION_ARG_NONE,
            &(settings.start_hidden), N_("Start gmpc hidden to tray"), NULL
        },
        {
            "clean-cover-db", 0, 0, G_OPTION_ARG_NONE,
            &(settings.clean_config), N_("Remove all failed hits from metadata cache"), NULL
        },
        {
            "bug-information", 'b', 0, G_OPTION_ARG_NONE,
            &(settings.show_bug_information), N_("Show bug information"), NULL
        },
        {
            "log-filter", 'f', 0, G_OPTION_ARG_CALLBACK,
            log_add_filter, N_("Shows all output from a certain log domain"), "<Log domain>"
        },
        {
            "profile", 'p', 0, G_OPTION_ARG_STRING,
            &(settings.profile_name), N_("Select a profile"), "<Profile Name>"
        },
        {
            "icon-theme", 'i', 0, G_OPTION_ARG_STRING,
            &(settings.icon_theme), N_("Run GMPC with a different icon theme"), "<icon theme name>"
        },

        {NULL}
    };
	INIT_TIC_TAC();
    context = g_option_context_new(_("Gnome Music Player Client"));
	TEC("context new")
    g_option_context_add_main_entries(context, entries, "gmpc");
	TEC(" add main context")
    g_option_context_add_group(context, gtk_get_option_group(TRUE));
	TEC("Add gtk option group")
    g_option_context_add_group(context, egg_sm_client_get_option_group());
	TEC("Add egg sm option group")
    g_option_context_parse(context, argc, argv, &error);
	TEC("Parse option group")
    g_option_context_free(context);
    if (error)
    {
        g_log(NULL, G_LOG_LEVEL_ERROR, "Failed to parse commandline options: %s", error->message);
        g_error_free(error);
        return FALSE;
    }
    return TRUE;
}
Exemple #11
0
int
main (int argc, char **argv)
{
	char           *desktopfile;
	GOptionContext *context;
	GError         *error;

	bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);

	/* We will register explicitly when we're ready -- see panel-session.c */
	egg_sm_client_set_mode (EGG_SM_CLIENT_MODE_DISABLED);

	g_set_prgname ("mate-panel");

	desktopfile = panel_g_lookup_in_applications_dirs ("mate-panel.desktop");
	if (desktopfile) {
		egg_set_desktop_file (desktopfile);
		g_free (desktopfile);
	}

	context = g_option_context_new ("");
	g_option_context_add_group (context,
				    egg_sm_client_get_option_group ());
	g_option_context_add_group (context, gtk_get_option_group (TRUE));
	g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);

	gtk_init (&argc, &argv);

	error = NULL;
	if (!g_option_context_parse (context, &argc, &argv, &error)) {
		g_printerr ("%s\n", error->message);
		g_error_free (error);
		g_option_context_free (context);

		return 1;
	}

	g_option_context_free (context);

	/* set the default layout */
	if (layout != NULL && layout[0] != 0)
	{
		GSettings *settings;
		settings = g_settings_new (PANEL_SCHEMA);
		g_settings_set_string (settings, PANEL_DEFAULT_LAYOUT, layout);
		g_object_unref (settings);
		g_message ("Panel layout set to '%s'", layout);
		/* exit, except if reset argument is given */
		if (!reset)
			return 0;
	}

	/* reset the configuration and exit. */
	if (reset == TRUE)
	{
		panel_reset();
		return 0;
	}

	/* open the run dialog and exit */
	if (run_dialog == TRUE)
	{
		panel_multiscreen_init ();
		panel_global_config_load ();
		panel_lockdown_init ();
		panel_profile_settings_load ();
		panel_run_dialog_present (gdk_screen_get_default (),
		                          gtk_get_current_event_time ());
		panel_run_dialog_quit_on_destroy ();
		gtk_main ();
		panel_lockdown_finalize ();
		panel_cleanup_do ();
		return 0;
	}

	if (!egg_get_desktop_file ()) {
		g_set_application_name (_("Panel"));
		gtk_window_set_default_icon_name (PANEL_ICON_PANEL);
	}

	if (!panel_shell_register (replace)) {
		panel_cleanup_do ();
		return -1;
	}

	panel_action_protocol_init ();
	panel_multiscreen_init ();
	panel_init_stock_icons_and_items ();

	panel_global_config_load ();
	panel_lockdown_init ();
	panel_profile_load ();

	/*add forbidden lists to ALL panels*/
	g_slist_foreach (panels,
	                 (GFunc)panel_widget_add_forbidden,
	                 NULL);

	xstuff_init ();

	/* Flush to make sure our struts are seen by everyone starting
	 * immediate after (eg, the caja desktop). */
	gdk_flush ();

	/* Do this at the end, to be sure that we're really ready when
	 * connecting to the session manager */
	panel_session_init ();

	gtk_main ();

	panel_lockdown_finalize ();

	panel_cleanup_do ();

	return 0;
}
Exemple #12
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;
}