int main(int argc, char* argv[])
{
	GError* error;
	int conflicting_options;

	/* Initialize the i18n stuff */
	bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
	textdomain(GETTEXT_PACKAGE);

	error = NULL;

	if (!gtk_init_with_args(&argc, &argv, NULL, options, NULL, &error))
	{
		g_warning("Unable to start: %s", error->message);
		g_error_free(error);
		exit(1);
	}

	conflicting_options = 0;

	if (kill_session)
	{
		conflicting_options++;
	}

	if (logout)
	{
		conflicting_options++;
	}

	if (force_logout)
	{
		conflicting_options++;
	}

	if (logout_dialog)
	{
		conflicting_options++;
	}

	if (shutdown_dialog)
	{
		conflicting_options++;
	}

	if (conflicting_options > 1)
	{
		display_error(_("Program called with conflicting options"));
	}

	if (kill_session)
	{
		if (no_interaction)
		{
			force_logout = TRUE;
		}
		else
		{
			logout_dialog = TRUE;
		}
	}

	if (logout)
	{
		do_logout(GSM_LOGOUT_MODE_NO_CONFIRMATION);
	}
	else if (force_logout)
	{
		do_logout(GSM_LOGOUT_MODE_FORCE);
	}
	else if (logout_dialog)
	{
		do_logout(GSM_LOGOUT_MODE_NORMAL);
	}
	else if (shutdown_dialog)
	{
		do_shutdown_dialog();
	}

	return 0;
}
Esempio n. 2
0
int main(int argc, char *argv[])
{
	UniqueApp *app;
	GtkStatusIcon *statusicon;
	GtkWidget *menu;
	GOptionContext *context;
	GError *error = NULL;

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

	g_type_init ();

	/* Parse command-line options */
	context = g_option_context_new (N_("- Bluetooth applet"));
	g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
	g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
	g_option_context_add_group (context, gtk_get_option_group (TRUE));
	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);
		return 1;
	}

	if (option_debug == FALSE) {
		app = unique_app_new ("org.mate.Bluetooth.applet", NULL);
		if (unique_app_is_running (app)) {
			gdk_notify_startup_complete ();
			g_warning ("Applet is already running, exiting");
			return 0;
		}
	} else {
		app = NULL;
	}

	g_set_application_name(_("Bluetooth Applet"));

	gtk_window_set_default_icon_name("bluetooth");

	killswitch = bluetooth_killswitch_new ();
	g_signal_connect (G_OBJECT (killswitch), "state-changed",
			  G_CALLBACK (killswitch_state_changed), NULL);

	menu = create_popupmenu();

	client = bluetooth_client_new();

	devices_model = bluetooth_client_get_model(client);

	g_signal_connect(G_OBJECT(devices_model), "row-inserted",
			 G_CALLBACK(device_added), NULL);
	g_signal_connect(G_OBJECT(devices_model), "row-deleted",
			 G_CALLBACK(device_removed), NULL);
	g_signal_connect (G_OBJECT (devices_model), "row-changed",
			  G_CALLBACK (device_changed), NULL);

	/* Set the default adapter */
	device_changed (devices_model, NULL, NULL, NULL);
	if (bluetooth_killswitch_has_killswitches (killswitch) != FALSE) {
		killswitch_state_changed (killswitch,
					  bluetooth_killswitch_get_state (killswitch));
	}

	/* Make sure all the unblocked adapters are powered,
	 * so as to avoid seeing unpowered, but unblocked
	 * devices */
	bluetooth_set_adapter_powered ();

	settings = g_settings_new (SCHEMA_NAME);
	show_icon_pref = g_settings_get_boolean (settings, PREF_SHOW_ICON);

	g_signal_connect (G_OBJECT (settings), "changed::" PREF_SHOW_ICON,
			  G_CALLBACK (show_icon_changed), NULL);

	statusicon = init_notification();

	update_icon_visibility();

	g_signal_connect(statusicon, "activate",
				G_CALLBACK(activate_callback), menu);
	g_signal_connect(statusicon, "popup-menu",
				G_CALLBACK(popup_callback), menu);

	setup_agents();

	gtk_main();

	gtk_widget_destroy(menu);

	g_object_unref(settings);

	cleanup_agents();

	cleanup_notification();

	g_object_unref(devices_model);

	g_object_unref(client);

	if (app != NULL)
		g_object_unref (app);

	return 0;
}
Esempio n. 3
0
void init_gettext(const char *path, const std::string &configured_language, int argc, char** argv) {
#else
void init_gettext(const char *path, const std::string &configured_language) {
#endif
#if USE_GETTEXT
	/** first try to set user override environment **/
	if (configured_language.length() != 0) {
#ifndef _WIN32
		/* add user specified locale to environment */
		setenv("LANGUAGE", configured_language.c_str(), 1);

		/* reload locale with changed environment */
		setlocale(LC_ALL, "");
#elif defined(_MSC_VER)
		std::string current_language_var("");
		if (getenv("LANGUAGE") != 0) {
			current_language_var = std::string(getenv("LANGUAGE"));
		}

		char *lang_str = (char*)calloc(10 + configured_language.length(), sizeof(char));
		strcat(lang_str, "LANGUAGE=");
		strcat(lang_str, configured_language.c_str());
		putenv(lang_str);

		SetEnvironmentVariableA("LANGUAGE",configured_language.c_str());

#ifndef SERVER
		//very very dirty workaround to force gettext to see the right environment
		if (current_language_var != configured_language) {
			STARTUPINFO startupinfo;
			PROCESS_INFORMATION processinfo;
			memset(&startupinfo, 0, sizeof(startupinfo));
			memset(&processinfo, 0, sizeof(processinfo));
			errorstream << "MSVC localization workaround active restating minetest in new environment!" << std::endl;

			std::string parameters = "";

			for (unsigned int i=1;i < argc; i++) {
				if (parameters != "") {
					parameters += " ";
				}
				parameters += argv[i];
			}

			const char* ptr_parameters = 0;

			if (parameters != "") {
				ptr_parameters = parameters.c_str();
			}
			
			/** users may start by short name in commandline without extention **/
			std::string appname = argv[0];
			if (appname.substr(appname.length() - 4) != ".exe") {
				appname += ".exe";
			}

			if (!CreateProcess(appname.c_str(),
					(char*) ptr_parameters,
					NULL,
					NULL,
					false,
					DETACHED_PROCESS | CREATE_UNICODE_ENVIRONMENT,
					NULL,
					NULL,
					&startupinfo,
					&processinfo)) {
				char buffer[1024];		
				FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
					NULL,
					GetLastError(),
					MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
					buffer,
					sizeof(buffer)-1,
					NULL);
				errorstream << "*******************************************************" << std::endl;
				errorstream << "CMD: " << appname << std::endl;
				errorstream << "Failed to restart with current locale: " << std::endl;
				errorstream << buffer;
				errorstream << "Expect language to be broken!" << std::endl;
				errorstream << "*******************************************************" << std::endl;
			}
			else {
				exit(0);
			}
#else
			errorstream << "*******************************************************" << std::endl;
			errorstream << "Can't apply locale workaround for server!" << std::endl;
			errorstream << "Expect language to be broken!" << std::endl;
			errorstream << "*******************************************************" << std::endl;

#endif
		}

		setlocale(LC_ALL,configured_language.c_str());
#else // Mingw
		char *lang_str = (char*)calloc(10 + configured_language.length(), sizeof(char));
		strcat(lang_str, "LANGUAGE=");
		strcat(lang_str, configured_language.c_str());
		putenv(lang_str);

		setlocale(LC_ALL, "");
#endif // ifndef _WIN32
	}
	else {
		 /* set current system default locale */
		setlocale(LC_ALL, "");
	}

#if defined(_WIN32)
	if (getenv("LANGUAGE") != 0) {
		setlocale(LC_ALL, getenv("LANGUAGE"));
	}
#ifdef _MSC_VER
	else if (getenv("LANG") != 0) {
		setlocale(LC_ALL, getenv("LANG"));
	}
#endif
#endif

	bindtextdomain(PROJECT_NAME, path);
	textdomain(PROJECT_NAME);

#if defined(_WIN32)
	// Set character encoding for Win32
	char *tdomain = textdomain( (char *) NULL );
	if( tdomain == NULL )
	{
		errorstream << "Warning: domainname parameter is the null pointer" <<
				", default domain is not set" << std::endl;
		tdomain = (char *) "messages";
	}
	/* char *codeset = */bind_textdomain_codeset( tdomain, "UTF-8" );
	//errorstream << "Gettext debug: domainname = " << tdomain << "; codeset = "<< codeset << std::endl;
#endif // defined(_WIN32)

#else
	/* set current system default locale */
	setlocale(LC_ALL, "");
#endif // if USE_GETTEXT

	/* no matter what locale is used we need number format to be "C" */
	/* to ensure formspec parameters are evaluated correct!          */

	setlocale(LC_NUMERIC, "C");
	infostream << "Message locale is now set to: "
			<< setlocale(LC_ALL, 0) << std::endl;
}
Esempio n. 4
0
static gboolean
cw_applet_fill (MatePanelApplet *applet, 
                const gchar *iid, 
                gpointer     data)
{
  WnckScreen *screen;
  WinPickerApp *app;
  GtkWidget *eb, *tasks, *title;
  gchar *ui_path;
  GtkActionGroup *action_group;
  GObjectClass *object_class;
  
  if (strcmp (iid, "MateWindowPicker") != 0)
    return FALSE;
  	
  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);

  /* Have our background automatically painted. */
  mate_panel_applet_set_background_widget (MATE_PANEL_APPLET (applet), GTK_WIDGET (applet));

  wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER);
  
  app = g_slice_new0 (WinPickerApp);
  mainapp = app;
  screen = wnck_screen_get_default ();

  object_class = G_OBJECT_GET_CLASS (G_OBJECT(applet));
  object_class->finalize = cw_applet_finalize;
  parent_class = g_type_class_peek_parent (object_class);

  /* gsettings prefs */
  app->settings = mate_panel_applet_settings_new (applet, APPLET_SCHEMA);
  g_signal_connect (app->settings, "changed::" SHOW_WIN_KEY,
                    G_CALLBACK (on_show_all_windows_changed), app);

  app->applet = GTK_WIDGET (applet);
  force_no_focus_padding (GTK_WIDGET (applet));
  gtk_container_set_border_width (GTK_CONTAINER (applet), 0);

  eb = gtk_hbox_new (FALSE, 6);
  gtk_container_add (GTK_CONTAINER (applet), eb);
  gtk_container_set_border_width (GTK_CONTAINER (eb), 0);

  tasks = app->tasks = task_list_get_default ();
  gtk_box_pack_start (GTK_BOX (eb), tasks, FALSE, FALSE, 0);

  title = app->title = task_title_new ();
  gtk_box_pack_start (GTK_BOX (eb), title, TRUE, TRUE, 0);

  gtk_widget_show_all (GTK_WIDGET (applet));
	
  on_show_all_windows_changed (app->settings, SHOW_WIN_KEY, app);
		
  action_group = gtk_action_group_new ("MateWindowPicker Applet Actions");
  gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
  gtk_action_group_add_actions (action_group,
                                window_picker_menu_actions,
                                G_N_ELEMENTS (window_picker_menu_actions),
                                app);
  ui_path = g_build_filename (MATEWINDOWPICKER_MENU_UI_DIR, "mate-window-picker-applet-menu.xml", NULL);
  mate_panel_applet_setup_menu_from_file (MATE_PANEL_APPLET (app->applet),
                                          ui_path, action_group);
  g_free (ui_path);
  g_object_unref (action_group);

  mate_panel_applet_set_flags (MATE_PANEL_APPLET (applet), 
                               MATE_PANEL_APPLET_EXPAND_MAJOR
                               | MATE_PANEL_APPLET_EXPAND_MINOR
                               | MATE_PANEL_APPLET_HAS_HANDLE);
	
  return TRUE;
}
Esempio n. 5
0
int main (int argc, char *argv[]) {
	GError *error_parsearg = NULL;
	GOptionContext *context;
	GtkWidget *window, *vbox, *hbox1, *hbox2;
	GtkAdjustment *sadj, *madj, *hadj;

#ifdef ENABLE_NLS
	bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
#endif

	gtk_init (&argc, &argv);
	notify_init ("Gtimer");
	ca_context_create (&sound);

	context = g_option_context_new (_("- a simple countdown timer"));
	g_option_context_add_main_entries (context, entries, NULL);
#ifdef ENABLE_NLS
	g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
#endif
	if (!g_option_context_parse (context, &argc, &argv, &error_parsearg)) {
		g_fprintf (stderr, "%s\n", error_parsearg->message);
		exit(1);
	}

	vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
	hbox1 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	hbox2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);

	gtk_box_set_spacing (GTK_BOX (hbox2), 5);
	gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);

	gui_elem.timer_display = gtk_label_new (NULL);
	reset_display();

	sadj = gtk_adjustment_new (0, 0, 60, 1, 1, 0);
	madj = gtk_adjustment_new (0, 0, 60, 1, 1, 0);
	hadj = gtk_adjustment_new (0, 0, 24, 1, 1, 0);
	gui_time_elem.spin_seconds = gtk_spin_button_new (sadj, 1, 0);
	gui_time_elem.spin_minutes = gtk_spin_button_new (madj, 1, 0);
	gui_time_elem.spin_hours = gtk_spin_button_new (hadj, 1, 0);

	gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (gui_time_elem.spin_seconds), TRUE);
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (gui_time_elem.spin_seconds), time_elem.seconds);
	g_object_set (gui_time_elem.spin_seconds, "shadow-type", GTK_SHADOW_IN, NULL);
	gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (gui_time_elem.spin_minutes), TRUE);
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (gui_time_elem.spin_minutes), time_elem.minutes);
	g_object_set (gui_time_elem.spin_minutes, "shadow-type", GTK_SHADOW_IN, NULL);
	gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (gui_time_elem.spin_hours), TRUE);
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (gui_time_elem.spin_hours), time_elem.hours);
	g_object_set (gui_time_elem.spin_hours, "shadow-type", GTK_SHADOW_IN, NULL);

	gui_elem.entry = gtk_entry_new();
	gtk_entry_set_text (GTK_ENTRY (gui_elem.entry), entry_text);

	gui_elem.button_timer = gtk_button_new();
	gtk_button_set_label (GTK_BUTTON (gui_elem.button_timer), _("Start"));
	gui_elem.button_reset = gtk_button_new_with_label (_("Reset"));
	gtk_widget_set_sensitive (gui_elem.button_reset, FALSE);

	gtk_box_pack_start (GTK_BOX (hbox1), gui_time_elem.spin_hours, TRUE, FALSE, 5);
	gtk_box_pack_start (GTK_BOX (hbox1), gui_time_elem.spin_minutes, TRUE, FALSE, 5);
	gtk_box_pack_start (GTK_BOX (hbox1), gui_time_elem.spin_seconds, TRUE, FALSE, 5);
	gtk_box_pack_start (GTK_BOX (vbox), gui_elem.timer_display, FALSE, TRUE, 5);
	gtk_box_pack_start (GTK_BOX (hbox2), gui_elem.button_timer, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (hbox2), gui_elem.button_reset, TRUE, TRUE, 0);
	gtk_container_add (GTK_CONTAINER (vbox), hbox1);
	gtk_box_pack_start (GTK_BOX (vbox), gui_elem.entry, FALSE, TRUE, 5);
	gtk_container_add (GTK_CONTAINER (vbox), hbox2);

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title (GTK_WINDOW (window), "Gtimer");
	gtk_container_add (GTK_CONTAINER (window), vbox);
	gtk_widget_show_all (window);

	g_timeout_add_seconds (1, (GSourceFunc) timer_function, NULL);
	g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
	g_signal_connect (gui_elem.button_timer, "clicked", G_CALLBACK (on_timer_button_clicked), NULL);
	g_signal_connect (gui_elem.button_reset, "clicked", G_CALLBACK (on_reset_button_clicked), NULL);

	gtk_main();
	notify_uninit();
	ca_context_destroy (sound);
	g_option_context_free (context);
	return 0;
}
Esempio n. 6
0
int APIENTRY	WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
 int argc = __argc;
 char **argv = __argv;
#else
int main(int argc, char *argv[])
{
#endif
#ifdef ENABLE_LOGGING
  setupDebug();
#endif
 int seed = time(NULL);

    // set locale to system default
    setlocale(LC_ALL, "");
    bindtextdomain("cataclysm-dda", "lang/mo");
    bind_textdomain_codeset("cataclysm-dda", "UTF-8");
    textdomain("cataclysm-dda");

//args: world seeding only.
 argc--; argv++;
 while (argc){
  if(std::string(argv[0]) == "--seed"){
   argc--; argv++;
   if(argc){
    seed = djb2_hash((unsigned char*)argv[0]);
    argc--; argv++;
   }
  }
  else // ignore unknown args.
   argc--; argv++;
 }

// ncurses stuff
 load_options(); // For getting size options
 initscr(); // Initialize ncurses
 noecho();  // Don't echo keypresses
 cbreak();  // C-style breaks (e.g. ^C to SIGINT)
 keypad(stdscr, true); // Numpad is numbers
 init_colors(); // See color.cpp
// curs_set(0); // Invisible cursor
 set_escdelay(10); // Make escape actually responsive

 std::srand(seed);

 bool quit_game = false;
 bool delete_world = false;
 g = new game;
 if(g->game_error())
  exit_handler(-999);
 g->init_ui();
 MAPBUFFER.set_game(g);
 g->load_artifacts(); //artifacts have to be loaded before any items are created
 if(g->game_error())
  exit_handler(-999);
 MAPBUFFER.load();

 curs_set(0); // Invisible cursor here, because MAPBUFFER.load() is crash-prone

 #if (!(defined _WIN32 || defined WINDOWS))
  struct sigaction sigIntHandler;
  sigIntHandler.sa_handler = exit_handler;
  sigemptyset(&sigIntHandler.sa_mask);
  sigIntHandler.sa_flags = 0;
  sigaction(SIGINT, &sigIntHandler, NULL);
 #endif

 do {
  g->setup();
  while (!g->do_turn()) ;
  if (g->uquit == QUIT_DELETE_WORLD)
    delete_world = true;
  if (g->game_quit() || g->game_error())
   quit_game = true;
 } while (!quit_game);

 if (delete_world)
 {
   g->delete_save();
 } else {
  MAPBUFFER.save_if_dirty();
 }

 exit_handler(-999);

 return 0;
}
/**
 * main:
 **/
int
main (int argc, char *argv[])
{
	GOptionContext *context;
	gboolean ret;
	GError *error = NULL;
	gchar **files = NULL;
	DBusGConnection *connection;
	DBusGProxy *proxy = NULL;

	const GOptionEntry options[] = {
		{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &files,
		  /* TRANSLATORS: command line option: a list of files to install */
		  _("Files to install"), NULL },
		{ NULL}
	};

	setlocale (LC_ALL, "");

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

	if (! g_thread_supported ())
		g_thread_init (NULL);
	g_type_init ();
	gtk_init (&argc, &argv);

	/* TRANSLATORS: program name: application to install a package to provide a file */
	g_set_application_name (_("PackageKit File Installer"));
	context = g_option_context_new ("gpk-install-file");
	g_option_context_set_summary (context, _("PackageKit File Installer"));
	g_option_context_add_main_entries (context, options, NULL);
	g_option_context_add_group (context, egg_debug_get_option_group ());
	g_option_context_add_group (context, gtk_get_option_group (TRUE));
	g_option_context_parse (context, &argc, &argv, NULL);
	g_option_context_free (context);

	/* TRANSLATORS: title to pass to to the user if there are not enough privs */
	ret = gpk_check_privileged_user (_("Local file installer"), TRUE);
	if (!ret)
		goto out;

	if (files == NULL) {
		/* TRANSLATORS: could not install a package that contained the file we wanted */
		gpk_error_dialog (_("Failed to install a package to provide a file"),
				  /* TRANSLATORS: nothing selected */
				  _("You need to specify a file to install"), NULL);
		goto out;
	}

	/* check dbus connections, exit if not valid */
	connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
	if (connection == NULL) {
		egg_warning ("%s", error->message);
		goto out;
	}

	/* get a connection */
	proxy = dbus_g_proxy_new_for_name (connection,
					   "org.freedesktop.PackageKit",
					   "/org/freedesktop/PackageKit",
					   "org.freedesktop.PackageKit.Modify");
	if (proxy == NULL) {
		egg_warning ("Cannot connect to session service");
		goto out;
	}

	/* don't timeout, as dbus-glib sets the timeout ~25 seconds */
	dbus_g_proxy_set_default_timeout (proxy, INT_MAX);

	/* do method */
	ret = dbus_g_proxy_call (proxy, "InstallPackageFiles", &error,
				 G_TYPE_UINT, 0, /* xid */
				 G_TYPE_STRV, files, /* data */
				 G_TYPE_STRING, "hide-finished,hide-warnings", /* interaction */
				 G_TYPE_INVALID,
				 G_TYPE_INVALID);
	if (!ret && !gpk_ignore_session_error (error)) {
		/* TRANSLATORS: This is when the specified DBus method did not execute successfully */
		gpk_error_dialog (_("The action could not be completed"),
				  /* TRANSLATORS: we don't have anything more useful to translate. sorry. */
				  _("The request failed. More details are available in the detailed report."),
				  error->message);
		egg_warning ("%s", error->message);
		goto out;
	}
out:
	if (error != NULL)
		g_error_free (error);
	if (proxy != NULL)
		g_object_unref (proxy);
	g_strfreev (files);
	return !ret;
}
Esempio n. 8
0
int
main (int argc, char *argv[])
{
  GError *error;
  GOptionContext *context;
  GFile *source, *dest, *target;
  gboolean dest_is_dir;
  char *basename;
  int i;
  GFileCopyFlags flags;
  int retval = 0;
  gchar *param;
  gchar *summary;

  setlocale (LC_ALL, "");

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

  error = NULL;
  param = g_strdup_printf ("%s... %s", _("SOURCE"), _("DEST"));
  summary = _("Move one or more files from SOURCE to DEST.");

  context = g_option_context_new (param);
  g_option_context_set_summary (context, summary);
  g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
  g_option_context_parse (context, &argc, &argv, &error);

  if (error != NULL)
    {
      g_printerr (_("Error parsing commandline options: %s\n"), error->message);
      g_printerr ("\n");
      g_printerr (_("Try \"%s --help\" for more information."), g_get_prgname ());
      g_printerr ("\n");
      g_error_free (error);
      return 1;
    }

  if (argc <= 2)
    {
      show_help (context, _("Missing operand\n"));
      return 1;
    }

  dest = g_file_new_for_commandline_arg (argv[argc-1]);

  if (no_target_directory && argc > 3)
    {
      show_help (context, _("Too many arguments\n"));
      g_object_unref (dest);
      return 1;
    }

  dest_is_dir = is_dir (dest);

  if (!dest_is_dir && argc > 3)
    {
      g_printerr (_("Target %s is not a directory\n"), argv[argc-1]);
      show_help (context, NULL);
      g_object_unref (dest);
      return 1;
    }

  g_option_context_free (context);
  g_free (param);

  for (i = 1; i < argc - 1; i++)
    {
      source = g_file_new_for_commandline_arg (argv[i]);

      if (dest_is_dir && !no_target_directory)
	{
	  basename = g_file_get_basename (source);
	  target = g_file_get_child (dest, basename);
	  g_free (basename);
	}
      else
	target = g_object_ref (dest);

      flags = 0;
      if (backup)
	flags |= G_FILE_COPY_BACKUP;
      if (!interactive)
	flags |= G_FILE_COPY_OVERWRITE;

      error = NULL;
      if (!g_file_move (source, target, flags, NULL, progress?show_progress:NULL, NULL, &error))
	{
	  if (interactive && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
	    {
	      char line[16];

	      g_error_free (error);
	      error = NULL;

	      basename = g_file_get_basename (target);
	      g_print ("overwrite %s?", basename);
	      g_free (basename);

	      if (fgets(line, sizeof (line), stdin) &&
		  line[0] == 'y')
		{
		  flags |= G_FILE_COPY_OVERWRITE;
		  if (!g_file_move (source, target, flags, NULL, NULL, NULL, &error))
		    goto move_failed;
		}
	    }
	  else
	    {
	    move_failed:
	      g_printerr (_("Error moving file %s: %s\n"), argv[i], error->message);
	      g_error_free (error);
	      retval = 1;
	    }
	}

      g_object_unref (source);
      g_object_unref (target);
    }

  g_object_unref (dest);

  return retval;
}
Esempio n. 9
0
int
main (int argc, char **argv)
{
    GOptionContext *ctx;
    GError *error = NULL;
    int ecode;
    g_setenv ("CLUTTER_DISABLE_XINPUT", "1", TRUE);
    g_type_init ();

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

    g_setenv ("GDK_SCALE", "1", TRUE);

    ctx = meta_get_option_context ();
    g_option_context_add_main_entries (ctx, gnome_cinnamon_options, GETTEXT_PACKAGE);
    if (!g_option_context_parse (ctx, &argc, &argv, &error))
    {
        g_printerr ("%s: %s\n", argv[0], error->message);
        exit (1);
    }

    g_option_context_free (ctx);

    meta_plugin_type_register (gnome_cinnamon_plugin_get_type ());

    /* Prevent meta_init() from causing gtk to load gail and at-bridge */
    g_setenv ("NO_GAIL", "1", TRUE);
    g_setenv ("NO_AT_BRIDGE", "1", TRUE);
    meta_init ();
    g_unsetenv ("NO_GAIL");
    g_unsetenv ("NO_AT_BRIDGE");
    g_unsetenv ("CLUTTER_DISABLE_XINPUT");

    /* FIXME: Add gjs API to set this stuff and don't depend on the
     * environment.  These propagate to child processes.
     */
    g_setenv ("GJS_DEBUG_OUTPUT", "stderr", TRUE);
    g_setenv ("GJS_DEBUG_TOPICS", "JS ERROR;JS LOG", TRUE);

    g_setenv ("CINNAMON_VERSION", VERSION, TRUE);


    center_pointer_on_screen();

    cinnamon_dbus_init (meta_get_replace_current_wm ());
    cinnamon_a11y_init ();
    cinnamon_perf_log_init ();

    g_irepository_prepend_search_path (CINNAMON_PKGLIBDIR);
#if HAVE_BLUETOOTH
    g_irepository_prepend_search_path (BLUETOOTH_DIR);
#endif

    /* Disable debug spew from various libraries */
    g_log_set_handler ("Gvc", G_LOG_LEVEL_DEBUG,
                       muted_log_handler, NULL);
    g_log_set_handler ("AccountsService", G_LOG_LEVEL_DEBUG,
                       muted_log_handler, NULL);
    g_log_set_handler ("Bluetooth", G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_MESSAGE,
                       muted_log_handler, NULL);

    /* Initialize the global object */
    _cinnamon_global_init (NULL);

    g_unsetenv ("GDK_SCALE");

    ecode = meta_run ();

    if (g_getenv ("CINNAMON_ENABLE_CLEANUP"))
    {
        g_printerr ("Doing final cleanup...\n");
        g_object_unref (cinnamon_global_get ());
    }

    return ecode;
}
Esempio n. 10
0
int
main (int argc, char **argv)
{
  GOptionContext *ctx;
  GError *error = NULL;
  int ecode;
  TpDebugSender *sender;

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

  session_mode = (char *) g_getenv ("GNOME_SHELL_SESSION_MODE");

  ctx = meta_get_option_context ();
  g_option_context_add_main_entries (ctx, gnome_shell_options, GETTEXT_PACKAGE);
  g_option_context_add_group (ctx, g_irepository_get_option_group ());
  if (!g_option_context_parse (ctx, &argc, &argv, &error))
    {
      g_printerr ("%s: %s\n", argv[0], error->message);
      exit (1);
    }

  g_option_context_free (ctx);

  meta_plugin_manager_set_plugin_type (gnome_shell_plugin_get_type ());

  meta_set_wm_name (WM_NAME);
  meta_set_gnome_wm_keybindings (GNOME_WM_KEYBINDINGS);

  /* Prevent meta_init() from causing gtk to load the atk-bridge*/
  g_setenv ("NO_AT_BRIDGE", "1", TRUE);
  meta_init ();
  g_unsetenv ("NO_AT_BRIDGE");

  /* FIXME: Add gjs API to set this stuff and don't depend on the
   * environment.  These propagate to child processes.
   */
  g_setenv ("GJS_DEBUG_OUTPUT", "stderr", TRUE);
  g_setenv ("GJS_DEBUG_TOPICS", "JS ERROR;JS LOG", TRUE);

  shell_init_debug (g_getenv ("SHELL_DEBUG"));

  shell_dbus_init (meta_get_replace_current_wm ());
  shell_a11y_init ();
  shell_perf_log_init ();
  shell_introspection_init ();
  shell_fonts_init ();

  /* Turn on telepathy-glib debugging but filter it out in
   * default_log_handler. This handler also exposes all the logs over D-Bus
   * using TpDebugSender. */
  tp_debug_set_flags ("all");

  sender = tp_debug_sender_dup ();

  g_log_set_default_handler (default_log_handler, sender);

  /* Initialize the global object */
  if (session_mode == NULL)
    session_mode = is_gdm_mode ? (char *)"gdm" : (char *)"user";

  _shell_global_init ("session-mode", session_mode, NULL);

  shell_prefs_init ();

  ecode = meta_run ();

  if (g_getenv ("GNOME_SHELL_ENABLE_CLEANUP"))
    {
      g_printerr ("Doing final cleanup...\n");
      g_object_unref (shell_global_get ());
    }

  g_object_unref (sender);

  return ecode;
}
Esempio n. 11
0
int
fe_args (int argc, char *argv[])
{
	GError *error = NULL;
	GOptionContext *context;

#ifdef ENABLE_NLS
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
#endif

	context = g_option_context_new (NULL);
	g_option_context_add_main_entries (context, gopt_entries, GETTEXT_PACKAGE);
	g_option_context_parse (context, &argc, &argv, &error);
	
	if (error)
	{
		if (error->message)
			printf ("%s\n", error->message);
		return 1;
	}

	g_option_context_free (context);

	if (arg_show_version)
	{
		printf (PACKAGE_TARNAME" "PACKAGE_VERSION"\n");
		return 0;
	}

	if (arg_show_autoload)
	{
#ifdef WIN32
		/* see the chdir() below */
		char *sl, *exe = strdup (argv[0]);
		sl = strrchr (exe, '\\');
		if (sl)
		{
			*sl = 0;
			printf ("%s\\plugins\n", exe);
		}
		free (exe);
#else
		printf ("%s\n", HEXCHATLIBDIR"/plugins");
#endif
		return 0;
	}

	if (arg_show_config)
	{
		printf ("%s\n", get_xdir ());
		return 0;
	}

	if (arg_cfgdir)	/* we want filesystem encoding */
	{
		if (xdir)
			g_free (xdir);
		xdir = strdup (arg_cfgdir);
		if (xdir[strlen (xdir) - 1] == '/')
			xdir[strlen (xdir) - 1] = 0;
		g_free (arg_cfgdir);
	}

	g_type_init ();
	
#ifndef WIN32
#ifndef __EMX__
		/* OS/2 uses UID 0 all the time */
		if (getuid () == 0)
			fe_message (_("* Running IRC as root is stupid! You should\n"
							"  create a User Account and use that to login.\n"), FE_MSG_WARN|FE_MSG_WAIT);
#endif
#endif /* !WIN32 */

	return -1;
}
int
main (int argc, char **argv)
{
	ServiceData svc = {0,};
	DBusError dbus_error = {0,};
	const char *address = NULL;

#ifdef ENABLE_NLS
	/* initialize i18n */
	bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
#endif
	g_type_init ();
	gst_init (NULL, NULL);
	g_set_prgname ("rhythmbox-metadata");

	if (argv[1] != NULL && strcmp(argv[1], "--debug") == 0) {
		argv++;
		rb_debug_init (TRUE);
	} else if (argv[1] != NULL && strcmp (argv[1], "--debug-match") == 0) {
		rb_debug_init_match (argv[2]);
		argv += 2;
	} else {
		rb_debug_init (FALSE);
	}

	/* bug report modes */
	if (argv[1] != NULL && strcmp(argv[1], "--load") == 0) {
		return test_load (argv[2]);
	}
	if (argv[1] != NULL && strcmp(argv[1], "--saveable-types") == 0) {
		return test_saveable_types ();
	}

	if (argv[1] != NULL && strcmp (argv[1], "--external") == 0) {
		argv++;
		svc.external = TRUE;
	}
	if (argv[1] == NULL) {
		address = "unix:tmpdir=/tmp";
	} else {
		address = argv[1];
	}

	rb_debug ("initializing metadata service; pid = %d; address = %s", getpid (), address);
	svc.metadata = rb_metadata_new ();

	/* set up D-BUS server */
	svc.server = dbus_server_listen (address, &dbus_error);
	if (!svc.server) {
		rb_debug ("D-BUS server init failed: %s", dbus_error.message);
		return -1;
	}

	dbus_server_set_new_connection_function (svc.server,
						 _new_connection,
						 (gpointer) &svc,
						 NULL);

	/* write the server address back to the parent process */
	{
		char *addr;
		addr = dbus_server_get_address (svc.server);
		rb_debug ("D-BUS server listening on address %s", addr);
		printf ("%s\n", addr);
		fflush (stdout);
		free (addr);
	}

	/* run main loop until we get bored */
	svc.loop = g_main_loop_new (NULL, TRUE);
	dbus_server_setup_with_g_main (svc.server,
				       g_main_loop_get_context (svc.loop));

	if (!svc.external)
		g_timeout_add_seconds (ATTENTION_SPAN / 2, (GSourceFunc) electromagnetic_shotgun, &svc);

	g_main_loop_run (svc.loop);

	if (svc.connection) {
		dbus_connection_close (svc.connection);
		dbus_connection_unref (svc.connection);
	}

	g_object_unref (svc.metadata);
	g_main_loop_unref (svc.loop);

	dbus_server_disconnect (svc.server);
	dbus_server_unref (svc.server);
	gst_deinit ();

	return 0;
}
Esempio n. 13
0
/*--------------------------------- MAIN -------------------------------------*/
int main(int argc, char *argv[])
{
	int ret=0;
	int n=0; //button box labels column
	gboolean control_only = FALSE;
	
	/* 
   	* In order to register the reading end of the pipe with the event loop 
   	* we must convert it into a GIOChannel.
   	*/
  	GIOChannel *g_signal_in; 
  	long fd_flags; 	    /* used to change the pipe into non-blocking mode */
  	GError *error = NULL;	/* handle errors */
  	
	/*print package name and version*/ 
	g_print("%s\n", PACKAGE_STRING);
	
	g_type_init ();
	gdk_threads_init();
	
#ifdef ENABLE_NLS
	char* lc_all = setlocale (LC_ALL, "");
	char* lc_dir = bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	char* txtdom = textdomain (GETTEXT_PACKAGE);
	const gchar * const * langs = g_get_language_names (); //get ordered list of defined languages
#endif
	/*structure containing all shared data - passed in callbacks*/
	struct ALL_DATA all_data;
	memset(&all_data,0,sizeof(struct ALL_DATA));
	
	/*allocate global variables*/
	global = g_new0(struct GLOBAL, 1);
	initGlobals(global);
	
	/*------------------------ reads command line options --------------------*/
	readOpts(argc,argv,global);
	
	/*------------------------- reads configuration file ---------------------*/
	readConf(global);
	
	//sets local control_only flag - prevents several initializations/allocations
	control_only = (global->control_only || global->add_ctrls) ;
    if(global->no_display && (global->control_only || !(global->exit_on_close && (global->Capture_time || global->image_timer))))
    {
        if(!(global->exit_on_close && (global->Capture_time || global->image_timer)))
            g_printerr("no_display must be used with exit_on_close and a timed capture: enabling display");
        else
            g_printerr("incompatible options (control_only and no_display): enabling display");
        global->no_display = FALSE;
    }
	
	/*---------------------------------- Allocations -------------------------*/
	
	gwidget = g_new0(struct GWIDGET, 1);
	gwidget->vid_widget_state = TRUE;

	/* widgets */
	GtkWidget *scroll1;
	GtkWidget *buttons_table;
	GtkWidget *profile_labels;
	GtkWidget *capture_labels;
	GtkWidget *SProfileButton;
	GtkWidget *LProfileButton;
    GtkWidget *DefaultsButton;
	GtkWidget *Tab1;
	GtkWidget *Tab1Label;
	GtkWidget *Tab1Icon;
	GtkWidget *ImgButton_Img;
	GtkWidget *SButton_Img;
	GtkWidget *LButton_Img;
	GtkWidget *DButton_Img;
	GtkWidget *QButton_Img;
	GtkWidget *HButtonBox;
	
	
	s = g_new0(struct VidState, 1);

	if(!control_only) /*control_only exclusion (video and Audio) */
	{
		pdata = g_new0(struct paRecordData, 1);
		//pdata->maincontext = g_main_context_default();
		/*create mutex for sound buffers*/
		__INIT_MUTEX(__AMUTEX);

		/* Allocate the video Format struct */
		videoF = g_new0(struct VideoFormatData, 1);
		
#if !LIBAVCODEC_VER_AT_LEAST(53,34)
		avcodec_init();
#endif

		// register all the codecs (you can also register only the codec
		//you wish to have smaller code)
		avcodec_register_all();

		/*---------------------------- Start PortAudio API -----------------------*/
		if(global->debug) g_print("starting portaudio...\n");
		Pa_Initialize(); 
	}