Ejemplo n.º 1
0
static AppearanceData *
init_appearance_data (int *argc, char ***argv, GOptionContext *context)
{
  AppearanceData *data = NULL;
  gchar *uifile;
  GtkBuilder *ui;
  GError *err = NULL;

  g_thread_init (NULL);
  gdk_threads_init ();
  gdk_threads_enter ();
  theme_thumbnail_factory_init (*argc, *argv);
  capplet_init (context, argc, argv);
  activate_settings_daemon ();

  /* set up the data */
  uifile = g_build_filename (MATECC_GTKBUILDER_DIR, "appearance.ui",
                             NULL);
  ui = gtk_builder_new ();
  gtk_builder_add_from_file (ui, uifile, &err);
  g_free (uifile);

  if (err)
    {
      g_warning (_("Could not load user interface file: %s"), err->message);
      g_error_free (err);
      g_object_unref (ui);
    }
  else
    {
      data = g_new (AppearanceData, 1);
      data->settings = g_settings_new (APPEARANCE_SCHEMA);
      data->wp_settings = g_settings_new (WP_SCHEMA);
      data->caja_settings = g_settings_new (CAJA_SCHEMA);
      data->interface_settings = g_settings_new (INTERFACE_SCHEMA);
      data->marco_settings = g_settings_new (MARCO_SCHEMA);
      data->mouse_settings = g_settings_new (MOUSE_SCHEMA);
#ifdef HAVE_XFT2
      data->font_settings = g_settings_new (FONT_RENDER_SCHEMA);
#endif /* HAVE_XFT2 */
      data->ui = ui;
      data->thumb_factory = mate_desktop_thumbnail_factory_new (MATE_DESKTOP_THUMBNAIL_SIZE_NORMAL);
    }

  return data;
}
int
main (int argc, char **argv)
{
	GtkBuilder     *dialog;
	GtkWidget      *dialog_win, *w;
	gchar *start_page = NULL;

	GOptionContext *context;
	GOptionEntry cap_options[] = {
		{"show-page", 'p', G_OPTION_FLAG_IN_MAIN,
		 G_OPTION_ARG_STRING,
		 &start_page,
		 /* TRANSLATORS: don't translate the terms in brackets */
		 N_("Specify the name of the page to show (general)"),
		 N_("page") },
		{NULL}
	};

	context = g_option_context_new (_("- MATE Mouse Preferences"));
	g_option_context_add_main_entries (context, cap_options, GETTEXT_PACKAGE);
	capplet_init (context, &argc, &argv);

	capplet_init_stock_icons ();

	activate_settings_daemon ();

	mouse_settings = g_settings_new (MOUSE_SCHEMA);
	touchpad_settings = g_settings_new (TOUCHPAD_SCHEMA);

	dialog = create_dialog ();

	if (dialog) {
		setup_dialog (dialog);

		dialog_win = WID ("mouse_properties_dialog");
		g_signal_connect (dialog_win, "response",
				  G_CALLBACK (dialog_response_cb), NULL);

		if (start_page != NULL) {
			gchar *page_name;

			page_name = g_strconcat (start_page, "_vbox", NULL);
			g_free (start_page);

			w = WID (page_name);
			if (w != NULL) {
				GtkNotebook *nb;
				gint pindex;

				nb = GTK_NOTEBOOK (WID ("prefs_widget"));
				pindex = gtk_notebook_page_num (nb, w);
				if (pindex != -1)
					gtk_notebook_set_current_page (nb, pindex);
			}
			g_free (page_name);
		}

		capplet_set_icon (dialog_win, "input-mouse");
		gtk_widget_show (dialog_win);

		gtk_main ();

		g_object_unref (dialog);
	}

	g_object_unref (mouse_settings);
	g_object_unref (touchpad_settings);

	return 0;
}
int
main (int argc, char **argv)
{
	GConfChangeSet *changeset;
	GladeXML       *dialog;
	GnomeProgram   *program;
 	GOptionContext *context;
	gboolean apply_only = FALSE;
	gboolean get_legacy = FALSE;
 	GOptionEntry cap_options[] = {
 		{ "apply", 0, 0, G_OPTION_ARG_NONE, &apply_only,
		  N_("Just apply settings and quit (compatibility only; now handled by daemon)"), NULL },
		{ "init-session-settings", 0, 0, G_OPTION_ARG_NONE, &apply_only,
		  N_("Just apply settings and quit (compatibility only; now handled by daemon)"), NULL },
 		{ "get-legacy", 0, 0, G_OPTION_ARG_NONE, &get_legacy,
		  N_("Retrieve and store legacy settings"), NULL },
 		{ NULL }
	};

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

        /* Since gstreamer and gnome-vfs require threads, we
         * have to initialise threads here as the first call to glib.
         */
        g_thread_init (NULL);

 	context = g_option_context_new (N_("- GNOME Sound Preferences"));
#if GLIB_CHECK_VERSION (2, 12, 0)
        g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
#endif
 	g_option_context_add_main_entries (context, cap_options, GETTEXT_PACKAGE);
	g_option_context_add_group (context, gst_init_get_option_group ());

	program = gnome_program_init ("gnome-sound-properties", VERSION,
				      LIBGNOMEUI_MODULE, argc, argv,
 			    	      GNOME_PARAM_GOPTION_CONTEXT, context,
				      NULL);

	activate_settings_daemon ();

	gconf_client = gconf_client_get_default ();
	gconf_client_add_dir (gconf_client, "/desktop/gnome/sound", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
	gconf_client_add_dir (gconf_client, "/apps/metacity/general", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);

	if (get_legacy) {
		get_legacy_settings ();
	} else {
		dialog = create_dialog ();

		if (dialog) {
			changeset = gconf_change_set_new ();
			setup_dialog (dialog, changeset);
			setup_devices ();

			dialog_win = WID ("sound_prefs_dialog");
			g_signal_connect (dialog_win, "response", G_CALLBACK (dialog_response_cb), changeset);
			g_signal_connect (dialog_win, "destroy", G_CALLBACK (gtk_main_quit), NULL);
			capplet_set_icon (dialog_win, "gnome-sound-properties");
			gtk_widget_show (dialog_win);

			gtk_main ();
			gconf_change_set_unref (changeset);
			g_object_unref (dialog);
		}
	}

	g_object_unref (gconf_client);
	g_object_unref (program);

	return 0;
}
int
main (int argc, char **argv)
{
	GtkBuilder *dialog;
	GOptionContext *context;

	static gboolean apply_only = FALSE;
	static gboolean switch_to_typing_break_page = FALSE;
	static gboolean switch_to_a11y_page = FALSE;

	static GOptionEntry cap_options[] = {
		{"apply", 0, 0, G_OPTION_ARG_NONE, &apply_only,
		 N_
		 ("Just apply settings and quit (compatibility only; now handled by daemon)"),
		 NULL},
		{"init-session-settings", 0, 0, G_OPTION_ARG_NONE,
		 &apply_only,
		 N_
		 ("Just apply settings and quit (compatibility only; now handled by daemon)"),
		 NULL},
		{"typing-break", 0, 0, G_OPTION_ARG_NONE,
		 &switch_to_typing_break_page,
		 N_
		 ("Start the page with the typing break settings showing"),
		 NULL},
		{"a11y", 0, 0, G_OPTION_ARG_NONE,
		 &switch_to_a11y_page,
		 N_
		 ("Start the page with the accessibility settings showing"),
		 NULL},
		{NULL}
	};


	context = g_option_context_new (_("- MATE Keyboard Preferences"));
	g_option_context_add_main_entries (context, cap_options,
					   GETTEXT_PACKAGE);

	capplet_init (context, &argc, &argv);

	activate_settings_daemon ();

	keyboard_settings = g_settings_new (KEYBOARD_SCHEMA);
	interface_settings = g_settings_new (INTERFACE_SCHEMA);
	typing_break_settings = g_settings_new (TYPING_BREAK_SCHEMA);

	dialog = create_dialog ();
	if (!dialog) /* Warning was already printed to console */
		exit (EXIT_FAILURE);

	setup_dialog (dialog);
	if (switch_to_typing_break_page) {
		gtk_notebook_set_current_page (GTK_NOTEBOOK
					       (WID
						("keyboard_notebook")),
					       4);
	}
	else if (switch_to_a11y_page) {
		gtk_notebook_set_current_page (GTK_NOTEBOOK
					       (WID
						("keyboard_notebook")),
					       2);

	}

	capplet_set_icon (WID ("keyboard_dialog"),
			  "preferences-desktop-keyboard");
	gtk_widget_show (WID ("keyboard_dialog"));
	gtk_main ();

	finalize_a11y_tabs ();
	g_object_unref (keyboard_settings);
	g_object_unref (interface_settings);
	g_object_unref (typing_break_settings);

	return 0;
}
int
main (int argc, char **argv)
{
	GnomeProgram   *program;
	GConfClient    *client;
	GladeXML       *dialog;
	GtkWidget      *dialog_win, *w;
	GOptionContext *context;
	gchar *start_page = NULL;

	GOptionEntry cap_options[] = {
		{"show-page", 'p', G_OPTION_FLAG_IN_MAIN,
		 G_OPTION_ARG_STRING,
		 &start_page,
		 /* TRANSLATORS: don't translate the terms in brackets */
		 N_("Specify the name of the page to show (general|accessibility)"),
		 N_("page") },
		{NULL}
	};

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

	context = g_option_context_new (_("- GNOME Mouse Preferences"));
	g_option_context_add_main_entries (context, cap_options,
					   GETTEXT_PACKAGE);

	program = gnome_program_init ("gnome-mouse-properties", VERSION,
				      LIBGNOMEUI_MODULE, argc, argv,
				      GNOME_PARAM_GOPTION_CONTEXT, context,
				      GNOME_PARAM_APP_DATADIR, GNOMECC_DATA_DIR,
				      NULL);

	capplet_init_stock_icons ();

	activate_settings_daemon ();

	client = gconf_client_get_default ();
	gconf_client_add_dir (client, "/desktop/gnome/peripherals/mouse", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);

	dialog = create_dialog ();

	if (dialog) {
		setup_dialog (dialog, NULL);
		setup_accessibility (dialog, client);

		dialog_win = WID ("mouse_properties_dialog");
		g_signal_connect (dialog_win, "response",
				  G_CALLBACK (dialog_response_cb), NULL);

		if (start_page != NULL) {
			gchar *page_name;

			page_name = g_strconcat (start_page, "_vbox", NULL);
			g_free (start_page);

			w = WID (page_name);
			if (w != NULL) {
				GtkNotebook *nb;
				gint pindex;

				nb = GTK_NOTEBOOK (WID ("prefs_widget"));
				pindex = gtk_notebook_page_num (nb, w);
				if (pindex != -1)
					gtk_notebook_set_current_page (nb, pindex);
			}
			g_free (page_name);
		}

		capplet_set_icon (dialog_win, "gnome-dev-mouse-optical");
		gtk_widget_show (dialog_win);

		gtk_main ();

		g_object_unref (dialog);
	}

	g_object_unref (client);
	g_object_unref (program);

	return 0;
}