Example #1
0
int main(int argc, char* argv[])
{
	GApplication* app;
	int status;

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

#ifdef HAVE_PTHREAD
	g_type_init ();
	gdk_threads_init ();
#endif

#ifdef HAVE_LIBGCRYPT
	gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
	gcry_check_version (NULL);
	gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
	gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
#endif

	gtk_init(&argc, &argv);

	app = g_application_new("org.Remmina", G_APPLICATION_HANDLES_COMMAND_LINE);
	g_signal_connect(app, "startup", G_CALLBACK(remmina_on_startup), NULL);
	g_signal_connect(app, "command-line", G_CALLBACK(remmina_on_command_line), NULL);
	g_application_set_inactivity_timeout(app, 10000);

	status = g_application_run(app, argc, argv);

	if (status == 0 && !g_application_get_is_remote(app))
	{
		THREADS_ENTER
		gtk_main();
		THREADS_LEAVE
	}
Example #2
0
int
main (int argc, char **argv)
{
  GtkWidget *window;
  GdkScreen *screen;
  int monitor;
  GdkRectangle rect;
  GError *error = NULL;
  char *font = NULL;
  GtkApplication *application;
  guint status;
  GOptionEntry goptions[] =
  {
    { "font", 0, 0, G_OPTION_ARG_STRING, &font,
      N_("Font to start with; ex: 'Serif 27'"), N_("FONT") },
    { "version", 0, G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG, 
      G_OPTION_ARG_CALLBACK, option_version_cb, NULL, NULL },
    { NULL }
  };

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

#ifdef HAVE_GCONF
  /* GConf uses ORBit2 which need GThread. See bug #565516 */
  g_thread_init (NULL);
#endif

  /* Set programme name explicitly (see bug #653115) */
  g_set_prgname("gucharmap");

  if (!gtk_init_with_args (&argc, &argv, NULL, goptions, GETTEXT_PACKAGE, &error))
    {
      g_printerr ("%s\n", error->message);
      g_error_free (error);

      exit (1);
    }

  g_set_application_name (_("Character Map"));
  gtk_window_set_default_icon_name (GUCHARMAP_ICON_NAME);

  application = gtk_application_new ("org.gnome.Charmap",
                                     G_APPLICATION_NON_UNIQUE);
  g_signal_connect (application, "startup", G_CALLBACK (startup_cb), NULL);
  g_signal_connect (application, "activate",
                    G_CALLBACK (gucharmap_activate), NULL);

  g_application_register (G_APPLICATION (application), NULL, NULL);

  window = gucharmap_window_new (application);

  screen = gtk_window_get_screen (GTK_WINDOW (window));
  monitor = gdk_screen_get_monitor_at_point (screen, 0, 0);
#if GTK_CHECK_VERSION (3, 3, 5)
  gdk_screen_get_monitor_workarea (screen, monitor, &rect);
#else
  gdk_screen_get_monitor_geometry (screen, monitor, &rect);
#endif
  gtk_window_set_default_size (GTK_WINDOW (window), rect.width * 9/16, rect.height * 9/16);

  if (font)
    {
      gucharmap_window_set_font (GUCHARMAP_WINDOW (window), font);
      g_free (font);
    }

  gtk_window_present (GTK_WINDOW (window));

  status = g_application_run (G_APPLICATION (application), argc, argv);
  g_object_unref (application);

  return status;
}
Example #3
0
File: main.c Project: Juson/xmradio
int main(int argc, char **argv)
{
	XmrApp *app;
	GOptionContext *context;
	GError *error = NULL;
	PlayerAction player_action = ActionNone;
	gchar *tmp_dir = NULL;

#if !GLIB_CHECK_VERSION(2, 32, 0)
	g_thread_init(NULL);
#endif

	// !!! glib manual says since version 2.36
	// but ubuntu 13.04 !!!
#if !GLIB_CHECK_VERSION(2, 35, 7)
	g_type_init();
#endif

	setlocale(LC_ALL, NULL);

#ifdef ENABLE_NLS
	/* initialize i18n */
	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, options, GETTEXT_PACKAGE);

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

	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);

	if (action_play){
		player_action = ActionPlay;
	}else if (action_pause){
		player_action = ActionPause;
	}else if(action_next){
		player_action = ActionNext;
	}else if(action_love){
		player_action = ActionLove;
	}else if(action_hate){
		player_action = ActionHate;
	}

	if (player_action != ActionNone)
	{
		DBusConnection *bus;
		DBusError dbus_error;
		dbus_error_init(&dbus_error);
		bus = dbus_bus_get(DBUS_BUS_SESSION, &dbus_error);
		if (!bus)
		{
			g_warning ("Failed to connect to the D-BUS daemon: %s", dbus_error.message);
			dbus_error_free(&dbus_error);
			exit(1);
		}
		
		dbus_connection_setup_with_g_main(bus, NULL);

		send_action(bus, player_action);

		// exit directly
		return 0;
	}

	xmr_debug_enable(debug);

	gst_init(&argc, &argv);

	curl_global_init(CURL_GLOBAL_ALL);

	// this make our XmrRadio always works
	g_object_set(gtk_settings_get_default(),
				"gtk-button-images", TRUE,
				NULL);

	// ensure folder exists
	tmp_dir = g_strdup_printf("%s/%s", g_get_tmp_dir(), PACKAGE);
	g_mkdir_with_parents(tmp_dir, 0755);

	app = xmr_app_instance();

	g_application_run(G_APPLICATION(app), argc, argv);

	// remove ...
	list_file(tmp_dir, FALSE, remove_file, NULL);

	g_free(tmp_dir);
	g_object_unref(app);

	curl_global_cleanup();

	return 0;
}
Example #4
0
// Entry point for the application
int main(int argc, char **argv)
{
	// Start the application	
	return g_application_run(G_APPLICATION(stack_app_new()), argc, argv);
}
Example #5
0
int
main (int argc, char **argv)
{
  GApplication *app;
  int exit_code = EXIT_FAILURE;
  const char *home_dir, *charset;
  GError *error = NULL;

  if (G_UNLIKELY ((getuid () != geteuid () ||
                  getgid () != getegid ()) &&
                  geteuid () == 0 &&
                  getegid () == 0)) {
    g_printerr ("Wrong euid/egid, exiting.\n");
    return _EXIT_FAILURE_WRONG_ID;
  }

  setlocale (LC_ALL, "");

  terminal_i18n_init (TRUE);

  if (!g_get_charset (&charset)) {
    g_printerr ("Non UTF-8 locale (%s) is not supported!\n", charset);
    return _EXIT_FAILURE_NO_UTF8;
  }

#ifndef ENABLE_DISTRO_PACKAGING
#ifdef HAVE_UBUNTU
  /* Set some env vars to disable the ubuntu modules. Their package will be 
   * built using --enable-distro-packaging, but anyone running from git will
   * get the right behaviour.
   */
  g_setenv ("LIBOVERLAY_SCROLLBAR", "0", TRUE);
  g_setenv ("UBUNTU_MENUPROXY", "0", TRUE);
  g_setenv ("NO_UNITY_GTK_MODULE", "1", TRUE);
#endif
#endif

  _terminal_debug_init ();

  // FIXMEchpe: just use / here but make sure #565328 doesn't regress
  /* Change directory to $HOME so we don't prevent unmounting, e.g. if the
   * factory is started by nautilus-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 ("/");

  g_set_prgname ("gnome-terminal-server");
  g_set_application_name (_("Terminal"));

  if (!gtk_init_with_args (&argc, &argv, NULL, options, NULL, &error)) {
    g_printerr ("Failed to parse arguments: %s\n", error->message);
    g_error_free (error);
    exit (EXIT_FAILURE);
  }

  app = terminal_app_new (app_id);
  g_free (app_id);

  if (!g_application_register (app, NULL, &error)) {
    g_printerr ("Failed to register application: %s\n", error->message);
    g_error_free (error);
    goto out;
  }

  if (g_application_get_is_remote (app)) {
    /* How the f**k did this happen? */
    g_printerr ("Cannot be remote instance!\n");
    goto out;
  }

  exit_code = g_application_run (app, 0, NULL);

out:
  g_object_unref (app);

  return exit_code;
}
Example #6
0
File: main.c Project: rosedu/anjuta
[+ESAC+] */

#include <config.h>
#include <gtk/gtk.h>
#include "[+NameLower+].h"

[+IF (=(get "HaveI18n") "1")+]
#include <glib/gi18n.h>
[+ENDIF+]

int
main (int argc, char *argv[])
{
    [+NameCClass+] *app;
    int status;

    [+IF (=(get "HaveI18n") "1")+]
#ifdef ENABLE_NLS
    bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
    textdomain (GETTEXT_PACKAGE);
#endif
    [+ENDIF+]

    app = [+NameCLower+]_new ();
    status = g_application_run (G_APPLICATION (app), argc, argv);
    g_object_unref (app);

    return status;
}
Example #7
0
int
main (int argc, char *argv[])
{
    gtk_init(&argc,&argv);
  return g_application_run (G_APPLICATION (sc_app_new()), argc, argv);
}
Example #8
0
	int main(int argc, char** argv)
	{
		int status = 0;

		mate_gettext(GETTEXT_PACKAGE, LOCALE_DIR, "UTF-8");

		#if !GLIB_CHECK_VERSION (2, 36, 0)
		g_type_init();
		#endif

		/* http://www.gtk.org/api/2.6/glib/glib-Commandline-option-parser.html */
		GOptionContext* context = g_option_context_new(NULL);
		g_option_context_add_main_entries(context, command_entries, GETTEXT_PACKAGE);
		g_option_context_add_group(context, gtk_get_option_group(TRUE));
		g_option_context_parse(context, &argc, &argv, NULL);

		/* Not necesary at all, program just run and die.
		 * But it free a little memory. */
		g_option_context_free(context);

		if (mate_about_nogui == TRUE)
		{
			printf("%s %s\n", gettext(program_name), version);
		}
		else
		{
			gtk_init(&argc, &argv);

			/**
			 * Examples taken from:
			 * http://developer.gnome.org/gtk3/3.0/gtk-migrating-GtkApplication.html
			 */
			#ifdef USE_UNIQUE

				mate_about_application = unique_app_new("org.mate.about", NULL);

				if (unique_app_is_running(mate_about_application))
				{
					UniqueResponse response = unique_app_send_message(mate_about_application, UNIQUE_ACTIVATE, NULL);

					if (response != UNIQUE_RESPONSE_OK)
					{
						status = 1;
					}
				}
				else
				{
					mate_about_run();
				}

			#elif GTK_CHECK_VERSION(3, 0, 0) && !defined(USE_UNIQUE)

				mate_about_application = gtk_application_new("org.mate.about", 0);
				g_signal_connect(mate_about_application, "activate", G_CALLBACK(mate_about_on_activate), NULL);

				status = g_application_run(G_APPLICATION(mate_about_application), argc, argv);

				g_object_unref(mate_about_application);

			#elif GLIB_CHECK_VERSION(2, 26, 0) && !defined(USE_UNIQUE)

				mate_about_application = g_application_new("org.mate.about", G_APPLICATION_FLAGS_NONE);
				g_signal_connect(mate_about_application, "activate", G_CALLBACK(mate_about_on_activate), NULL);

				status = g_application_run(G_APPLICATION(mate_about_application), argc, argv);

				g_object_unref(mate_about_application);

			#else

				mate_about_run();

			#endif
		}

		return status;
	}
int
OxApplication_Run()
{
	g_signal_connect(OxApp->pGtk, "activate", G_CALLBACK(OxApplicationActivateCB), NULL);
	return g_application_run(G_APPLICATION(OxApp->pGtk), 0, NULL); //argc, argv);
}
Example #10
0
int main(int argc, char **argv)
{
    int expert_mode = 0;

    const char *prgname = "abrt";
    abrt_init(argv);

    /* I18n */
    setlocale(LC_ALL, "");
#if ENABLE_NLS
    bindtextdomain(PACKAGE, LOCALEDIR);
    textdomain(PACKAGE);
#endif

    /* without this the name is set to argv[0] which confuses
     * desktops which uses the name to find the corresponding .desktop file
     * trac#180
     *
     * env variable can be used to override the default prgname, so it's the
     * same as the application which is calling us (trac#303)
     *
     * note that g_set_prgname has to be called before gtk_init
     */
    char *env_prgname = getenv("LIBREPORT_PRGNAME");
    g_set_prgname(env_prgname ? env_prgname : prgname);

    gtk_init(&argc, &argv);

    /* Can't keep these strings/structs static: _() doesn't support that */
    const char *program_usage_string = _(
        "& [-vpdx] [-e EVENT]... [-g GUI_FILE] PROBLEM_DIR\n"
        "\n"
        "GUI tool to analyze and report problem saved in specified PROBLEM_DIR"
    );
    enum {
        OPT_v = 1 << 0,
        OPT_g = 1 << 1,
        OPT_p = 1 << 2,
        OPT_d = 1 << 3,
        OPT_e = 1 << 4,
        OPT_x = 1 << 5,
    };
    /* Keep enum above and order of options below in sync! */
    struct options program_options[] = {
        OPT__VERBOSE(&g_verbose),
        OPT_STRING('g', NULL, &g_glade_file, "FILE",          _("Alternate GUI file")),
        OPT_BOOL(  'p', NULL, NULL,                           _("Add program names to log")),
        OPT_BOOL(  'd', "delete", NULL,                       _("Remove PROBLEM_DIR after reporting")),
        OPT_LIST(  'e', "event", &g_auto_event_list, "EVENT", _("Run only these events")),
        OPT_BOOL(  'x', "expert", &expert_mode,               _("Expert mode")),
        OPT_END()
    };
    unsigned opts = parse_opts(argc, argv, program_options, program_usage_string);
    argv += optind;
    if (!argv[0] || argv[1]) /* zero or >1 arguments */
        show_usage_and_die(program_usage_string, program_options);

    /* Allow algorithms to add mallocated strings */
    for (GList *elem = g_auto_event_list; elem; elem = g_list_next(elem))
        elem->data = xstrdup((const char *)elem->data);

    export_abrt_envvars(opts & OPT_p);

    g_dump_dir_name = xstrdup(argv[0]);

    /* load /etc/abrt/events/foo.{conf,xml} stuff
       and $XDG_CACHE_HOME/abrt/events/foo.conf */
    g_event_config_list = load_event_config_data();
    load_event_config_data_from_user_storage(g_event_config_list);
    load_user_settings("report-gtk");

    load_workflow_config_data(WORKFLOWS_DIR);

    /* list of workflows applicable to the currently processed problem */
    GList *possible_names = list_possible_events_glist(g_dump_dir_name, "workflow");
    GHashTable *possible_workflows = load_workflow_config_data_from_list(possible_names, WORKFLOWS_DIR);
    g_list_free_full(possible_names, free);

    /* if we have only 1 workflow, we can use the events from it as default */
    if (!expert_mode && g_auto_event_list == NULL && g_hash_table_size(possible_workflows) == 1)
    {
        GHashTableIter iter;
        gpointer key, value;

        g_hash_table_iter_init(&iter, possible_workflows);
        if (g_hash_table_iter_next(&iter, &key, &value))
        {
            log_notice("autoselected workflow: '%s'", (char *)key);
            g_auto_event_list = wf_get_event_names((workflow_t *)value);
        }
    }
    g_hash_table_destroy(possible_workflows);

    problem_data_reload_from_dump_dir();

    g_custom_logger = &show_error_as_msgbox;
    GtkApplication *app = gtk_application_new("org.freedesktop.libreport.report", G_APPLICATION_NON_UNIQUE);
    g_signal_connect(app, "activate", G_CALLBACK(activate_wizard), (gpointer)&expert_mode);
    g_signal_connect(app, "startup",  G_CALLBACK(startup_wizard),  NULL);
    /* Enter main loop */
    g_application_run(G_APPLICATION(app), argc, argv);
    g_object_unref(app);

    if (opts & OPT_d)
        delete_dump_dir_possibly_using_abrtd(g_dump_dir_name);

    save_user_settings();

    return 0;
}
Example #11
0
int main(int argc, char *argv[]) {
  

  return g_application_run(G_APPLICATION(my_style_new()), argc, argv);
}
Example #12
0
int
main (int argc,
    char *argv[])
{
  GOptionContext *optcontext;
  GOptionEntry options[] = {
      { NULL }
  };
#ifdef ENABLE_DEBUG
  TpDebugSender *debug_sender;
#endif
  GError *error = NULL;
  gint retval;

  /* Init */
  g_thread_init (NULL);

  optcontext = g_option_context_new (N_("- Empathy Audio/Video Client"));
  g_option_context_add_group (optcontext, gst_init_get_option_group ());
  g_option_context_add_group (optcontext, gtk_get_option_group (TRUE));
  g_option_context_add_main_entries (optcontext, options, GETTEXT_PACKAGE);

  if (!g_option_context_parse (optcontext, &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_warning ("Error in empathy-av init: %s", error->message);
    return EXIT_FAILURE;
  }

  g_option_context_free (optcontext);

  clutter_gst_init (&argc, &argv);

  empathy_gtk_init ();
  g_set_application_name (_("Empathy Audio/Video Client"));
  g_setenv ("PULSE_PROP_media.role", "phone", TRUE);

  /* Make empathy and empathy-av appear as the same app in gnome-shell */
  gdk_set_program_class ("Empathy");
  gtk_window_set_default_icon_name ("empathy");
  textdomain (GETTEXT_PACKAGE);

  app = gtk_application_new (EMPATHY_AV_DBUS_NAME, G_APPLICATION_FLAGS_NONE);
  g_signal_connect (app, "activate", G_CALLBACK (activate_cb), NULL);

#ifdef ENABLE_DEBUG
  /* Set up debug sender */
  debug_sender = tp_debug_sender_dup ();
  g_log_set_default_handler (tp_debug_sender_log_handler, G_LOG_DOMAIN);
#endif

  if (g_getenv ("EMPATHY_PERSIST") != NULL)
    {
      DEBUG ("Disable timer");

      use_timer = FALSE;
    }

  /* the inactivity timeout can only be set while the application is held */
  g_application_hold (G_APPLICATION (app));
  g_application_set_inactivity_timeout (G_APPLICATION (app), TIMEOUT * 1000);
  g_application_release (G_APPLICATION (app));

  retval = g_application_run (G_APPLICATION (app), argc, argv);

  g_object_unref (app);
  tp_clear_object (&call_factory);

#ifdef ENABLE_DEBUG
  g_object_unref (debug_sender);
#endif

  return retval;
}
Example #13
0
gint preferences_app_main (gchar** args, int args_length1) {
	gint result = 0;
	const gchar* _tmp0_ = NULL;
	GOptionContext* _tmp1_;
	GOptionContext* context;
	GOptionContext* _tmp2_;
	GOptionContext* _tmp3_;
	GOptionGroup* _tmp4_ = NULL;
	gint status = 0;
	gint _tmp11_ = 0;
	gboolean _tmp12_ = FALSE;
	GtkIconTheme* _tmp13_ = NULL;
	gboolean _tmp14_ = FALSE;
	GtkApplication* _tmp15_;
	GtkApplication* app;
	GtkApplication* _tmp16_;
	GtkApplication* _tmp17_;
	gint _tmp18_ = 0;
	GError * _inner_error_ = NULL;
	deja_dup_i18n_setup ();
	_tmp0_ = _ ("Backup");
	g_set_application_name (_tmp0_);
	_tmp1_ = g_option_context_new ("");
	context = _tmp1_;
	_tmp2_ = context;
	g_option_context_add_main_entries (_tmp2_, PREFERENCES_APP_options, GETTEXT_PACKAGE);
	_tmp3_ = context;
	_tmp4_ = gtk_get_option_group (FALSE);
	g_option_context_add_group (_tmp3_, _tmp4_);
	{
		GOptionContext* _tmp5_;
		_tmp5_ = context;
		g_option_context_parse (_tmp5_, &args_length1, &args, &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp6_;
		const gchar* _tmp7_;
		GOptionContext* _tmp8_;
		gchar* _tmp9_ = NULL;
		gchar* _tmp10_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp6_ = e;
		_tmp7_ = _tmp6_->message;
		_tmp8_ = context;
		_tmp9_ = g_option_context_get_help (_tmp8_, TRUE, NULL);
		_tmp10_ = _tmp9_;
		g_printerr ("%s\n\n%s", _tmp7_, _tmp10_);
		_g_free0 (_tmp10_);
		result = 1;
		_g_error_free0 (e);
		_g_option_context_free0 (context);
		return result;
	}
	__finally0:
	if (_inner_error_ != NULL) {
		_g_option_context_free0 (context);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return 0;
	}
	_tmp12_ = preferences_app_handle_console_options (&_tmp11_);
	status = _tmp11_;
	if (!_tmp12_) {
		result = status;
		_g_option_context_free0 (context);
		return result;
	}
	gtk_init (&args_length1, &args);
	_tmp13_ = gtk_icon_theme_get_default ();
	gtk_icon_theme_append_search_path (_tmp13_, THEME_DIR);
	gtk_window_set_default_icon_name (PACKAGE);
	_tmp14_ = deja_dup_gui_initialize (NULL, TRUE);
	if (!_tmp14_) {
		result = 1;
		_g_option_context_free0 (context);
		return result;
	}
	_tmp15_ = gtk_application_new ("org.gnome.DejaDup.Preferences", 0);
	app = _tmp15_;
	_tmp16_ = app;
	g_signal_connect ((GApplication*) _tmp16_, "activate", (GCallback) ___lambda9__g_application_activate, NULL);
	_tmp17_ = app;
	_tmp18_ = g_application_run ((GApplication*) _tmp17_, 0, NULL);
	result = _tmp18_;
	_g_object_unref0 (app);
	_g_option_context_free0 (context);
	return result;
}
Example #14
0
int
main (int argc, char **argv)
{
    ChAssemblePrivate *priv;
    gboolean ret;
    gboolean verbose = FALSE;
    GError *error = NULL;
    GOptionContext *context;
    int status = 0;
    const GOptionEntry options[] = {
        {   "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
            /* TRANSLATORS: command line option */
            _("Show extra debugging information"), NULL
        },
        { NULL}
    };

    setlocale (LC_ALL, "");

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

    gtk_init (&argc, &argv);

    /* TRANSLATORS: A program to assemble calibrate the hardware */
    context = g_option_context_new (_("ColorHug assembly tester"));
    g_option_context_add_group (context, gtk_get_option_group (TRUE));
    g_option_context_add_main_entries (context, options, NULL);
    ret = g_option_context_parse (context, &argc, &argv, &error);
    if (!ret) {
        g_warning ("%s: %s",
                   _("Failed to parse command line options"),
                   error->message);
        g_error_free (error);
    }
    g_option_context_free (context);

    priv = g_new0 (ChAssemblePrivate, 1);
    priv->sample_widget = CD_SAMPLE_WIDGET (cd_sample_widget_new ());
    priv->usb_ctx = g_usb_context_new (NULL);
    priv->device_queue = ch_device_queue_new ();
    g_signal_connect (priv->usb_ctx, "device-added",
                      G_CALLBACK (ch_assemble_device_added_cb), priv);
    g_signal_connect (priv->usb_ctx, "device-removed",
                      G_CALLBACK (ch_assemble_device_removed_cb), priv);

    /* ensure single instance */
    priv->application = gtk_application_new ("com.hughski.ColorHug.Assemble", 0);
    g_signal_connect (priv->application, "startup",
                      G_CALLBACK (ch_assemble_startup_cb), priv);
    g_signal_connect (priv->application, "activate",
                      G_CALLBACK (ch_assemble_activate_cb), priv);
    /* set verbose? */
    if (verbose) {
        g_setenv ("COLORHUG_VERBOSE", "1", FALSE);
    } else {
        g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
                           ch_assemble_ignore_cb, NULL);
    }

    /* wait */
    status = g_application_run (G_APPLICATION (priv->application), argc, argv);

    g_object_unref (priv->application);
    if (priv->device_queue != NULL)
        g_object_unref (priv->device_queue);
    if (priv->usb_ctx != NULL)
        g_object_unref (priv->usb_ctx);
    if (priv->builder != NULL)
        g_object_unref (priv->builder);
    g_free (priv);
    return status;
}
Example #15
0
gint
main (gint argc, gchar *argv[])
{
    gtk_init (&argc, &argv);
    g_object_set (gtk_settings_get_default (), "gtk-application-prefer-dark-theme", TRUE, NULL);

    gsize size = DEFAULT_SIZE;
    guint32 target = DEFAULT_TARGET;
    const gchar *theme = DEFAULT_THEME;

    GOptionEntry options[] = {
        { "size",   's',  0, G_OPTION_ARG_INT,    &size,   "The size of the grid", "4"           },
        { "target", '\0', 0, G_OPTION_ARG_INT,    &target, "The tile to reach",    "2048"        },
        { "theme",  't',  0, G_OPTION_ARG_STRING, &theme,  "The theme to use",     DEFAULT_THEME },
        { NULL,     '\0', 0, G_OPTION_ARG_NONE,   NULL,    NULL,                   NULL          }
    };
    G_2048_CLEANUP_OPTIONS_FREE GOptionContext *ctx = g_option_context_new ("foobar");
    g_option_context_add_main_entries (ctx, options, NULL);
    g_option_context_add_group (ctx, gtk_get_option_group (TRUE));
    g_option_context_parse (ctx, &argc, &argv, NULL);

    GtkApplication *app = gtk_application_new ("org.gnome.g2048", G_APPLICATION_FLAGS_NONE);
    GApplication *gapp = G_APPLICATION (app);
    G_2048_CLEANUP_ERROR_FREE GError *error = NULL;
    G_APPLICATION_GET_CLASS (gapp)->activate = show_win;

    g_application_register (gapp, NULL, &error);
    if (error)
    {
        fprintf (stderr, "Failed to register the gtk application: %s\n", error->message);
        return EXIT_FAILURE;
    }
    if (g_application_get_is_remote (gapp))
    {
        g_application_activate (gapp);
        return EXIT_SUCCESS;
    }

    G_2048_CLEANUP_FREE gchar *theme_path = get_theme_path (theme);
    if (!theme_path)
        theme_path = get_theme_path (DEFAULT_THEME);
    if (!theme_path)
    {
        g_critical ("No theme found");
        exit (EXIT_FAILURE);
    }

    GtkWidget *score_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
    GtkBox *hbox = GTK_BOX (score_box);
    gtk_box_pack_start (hbox, gtk_label_new ("Score:"), TRUE, TRUE, 0);

    GtkWidget *score_label = gtk_label_new ("0");
    GtkLabel *label = GTK_LABEL (score_label);
    GdkRGBA color;
    gdk_rgba_parse (&color, "white");
    gtk_widget_override_background_color (score_label, GTK_STATE_FLAG_NORMAL, &color);
    gdk_rgba_parse (&color, "black");
    gtk_widget_override_color (score_label, GTK_STATE_FLAG_NORMAL, &color);
    gtk_label_set_width_chars (GTK_LABEL (score_label), 8);
    gtk_box_pack_end (hbox, score_label, TRUE, FALSE, 0);

    GtkWidget *box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
    GtkBox *vbox = GTK_BOX (box);
    gtk_box_pack_start (vbox, g_2048_grid_new (size, target, theme_path, label), TRUE, TRUE, 0);
    gtk_box_pack_end (vbox, score_box, TRUE, TRUE, 20);

    GtkWidget *win = gtk_widget_new (GTK_TYPE_APPLICATION_WINDOW,
                                     "application",     app,
                                     "type",            GTK_WINDOW_TOPLEVEL,
                                     "window-position", GTK_WIN_POS_CENTER,
                                     "resizable",       FALSE,
                                     NULL);
    gtk_container_add (GTK_CONTAINER (win), box);
    gtk_widget_show_all (win);
    gtk_widget_override_font (win, pango_font_description_from_string("Monospace 18"));
    GTK_WIDGET_GET_CLASS (win)->key_press_event = on_key;

    return g_application_run (gapp, argc, argv);
}
Example #16
0
File: gedit.c Project: GNOME/gedit
int
main (int argc, char *argv[])
{
	GType type;
	GeditApp *app;
	gint status;
	const gchar *dir;

#ifdef OS_OSX
	type = GEDIT_TYPE_APP_OSX;
#else
#ifdef G_OS_WIN32
	if (!gedit_w32_load_private_dll ())
	{
		return 1;
	}

	type = GEDIT_TYPE_APP_WIN32;
#else
	type = GEDIT_TYPE_APP_X11;
#endif
#endif

	/* NOTE: we should not make any calls to the gedit api before the
	 * private library is loaded */
	gedit_dirs_init ();

	/* Setup locale/gettext */
	setlocale (LC_ALL, "");

	dir = gedit_dirs_get_gedit_locale_dir ();
	bindtextdomain (GETTEXT_PACKAGE, dir);

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

	app = g_object_new (type,
	                    "application-id", "org.gnome.gedit",
	                    "flags", G_APPLICATION_HANDLES_COMMAND_LINE | G_APPLICATION_HANDLES_OPEN,
	                    NULL);


	/* https://honk.sigxcpu.org/con/GTK__and_the_application_id.html */
	g_set_prgname("org.gnome.gedit");

	status = g_application_run (G_APPLICATION (app), argc, argv);

	/* Break reference cycles caused by the PeasExtensionSet
	 * for GeditAppActivatable which holds a ref on the GeditApp
	 */
	g_object_run_dispose (G_OBJECT (app));

	g_object_add_weak_pointer (G_OBJECT (app), (gpointer *) &app);
	g_object_unref (app);

	if (app != NULL)
	{
		gedit_debug_message (DEBUG_APP, "Leaking with %i refs",
		                     G_OBJECT (app)->ref_count);
	}

#ifdef G_OS_WIN32
	gedit_w32_unload_private_dll ();
#endif

	return status;
}
Example #17
0
File: main.c Project: danigm/aguita
int main (int argc, char *argv[])
{
    return g_application_run (G_APPLICATION (h2o_xs_app_new ()),
                                             argc, argv);
}
Example #18
0
File: main.c Project: 3v1n0/gtk
int
main (int argc, char *argv[])
{
  return g_application_run (G_APPLICATION (icon_browser_app_new ()), argc, argv);
}
int main(int argc,char *argv[]){
	#ifdef _DEBUG_					//调试时启用内存泄露检测工具
	printf("DEBUG !!!!!!!!!!!!!!!!!!!!!!!\n\n\n");
	atexit(report_mem_leak);		//
	#endif							//
	
	//UI start
	
	//-------------------------------------------------------------------
	//初始化-------------------------------------------------------------
	//-------------------------------------------------------------------
	//1.将发送的命令转换成正确的格式
	asciiToHex(UPS_COMMUNICATION_INI,UPS_COMMUNICATION_INI_DECODE);
	asciiToHex(UPS_CMD_ACCEPT,UPS_CMD_ACCEPT_DECODE);
	asciiToHex(UPS_CMD_01,UPS_CMD_01_DECODE);
	asciiToHex(UPS_CMD_02,UPS_CMD_02_DECODE);
	asciiToHex(UPS_CMD_03,UPS_CMD_03_DECODE);
	asciiToHex(UPS_CMD_06,UPS_CMD_06_DECODE);
	asciiToHex(UPS_CMD_07,UPS_CMD_07_DECODE);
	asciiToHex(UPS_CMD_24,UPS_CMD_24_DECODE);
	asciiToHex(UPS_CMD_27,UPS_CMD_27_DECODE);
	asciiToHex(UPS_CMD_31,UPS_CMD_31_DECODE);
	asciiToHex(UPS_CMD_32,UPS_CMD_32_DECODE);
	asciiToHex(UPS_CMD_3B,UPS_CMD_3B_DECODE);
	asciiToHex(UPS_CMD_42,UPS_CMD_42_DECODE);
	//UI show "ok"
	
	//2.读取配置文件参数
	char *value_buf	=	(char*)	malloc(MAX_CHAR_PER_PARA);		//临时变量
	char *key_buf	=	(char*)	malloc(MAX_CHAR_PER_CONF);		//临时变量
	KEY_VAL config_file,	*config_file_ptr1=&config_file,	*config_file_ptr2=NULL;
	if(analyzeConfFile("config",&config_file)){
		//read file successfully
	}
	else{
		//file not existed
	}
	errorReport();								//
	for(int i=0;i<NUM_OF_UPS;i++){								//读取配置文件参数的设定值
		sprintf(key_buf,"com_num_%d",i+1);
		if(getValue(&config_file,key_buf,value_buf)){
			_2023ups[i].LINK_COM_NUM=atoi(value_buf);//
		}
		else{
			
		}
		
		sprintf(key_buf,"READ_INTERVAL_UPS%d",i+1);
		if(getValue(&config_file,key_buf,value_buf)){
			_2023ups[i].READ_INTERVAL=atoi(value_buf);//
		}
		else{
			
		}
		
		sprintf(key_buf,"READ_MULTIPLIER_UPS%d",i+1);
		if(getValue(&config_file,key_buf,value_buf)){
			_2023ups[i].READ_MULTIPLIER=atoi(value_buf);//
		}
		else{
			
		}
		
		sprintf(key_buf,"READ_CONSTANT_UPS%d",i+1);
		if(getValue(&config_file,key_buf,value_buf)){
			_2023ups[i].READ_CONSTANT=atoi(value_buf);//
		}
		else{
			
		}
		
		sprintf(key_buf,"WRITE_MULTIPLIER_UPS%d",i+1);
		if(getValue(&config_file,key_buf,value_buf)){
			_2023ups[i].WRITE_MULTIPLIER=atoi(value_buf);//
		}
		else{
			
		}
		
		sprintf(key_buf,"WRITE_CONSTANT_UPS%d",i+1);
		if(getValue(&config_file,key_buf,value_buf)){
			_2023ups[i].WRITE_CONSTANT=atoi(value_buf);//
		}
		else{
			
		}
	}
	#ifdef _DEBUG_
	printf("%d %d %d %d\n\n",_2023ups[0].LINK_COM_NUM,_2023ups[1].LINK_COM_NUM,_2023ups[2].LINK_COM_NUM,_2023ups[3].LINK_COM_NUM);
	for(int i=0;i<NUM_OF_UPS;i++){
		printf("%d %d %d %d %d\n",_2023ups[i].READ_INTERVAL,_2023ups[i].READ_MULTIPLIER,_2023ups[i].READ_CONSTANT,\
		_2023ups[i].WRITE_MULTIPLIER,_2023ups[i].WRITE_CONSTANT);
	}
	#endif
	free(value_buf);
	free(key_buf);
	while(config_file_ptr1!=NULL){
		config_file_ptr2=config_file_ptr1;
		config_file_ptr1=config_file_ptr1->next;
		free(config_file_ptr2);
	}
	
	//3.初始化相应串口
	char com[20];
	for(int i=0;i<NUM_OF_UPS;i++){			//打开串口,配置相应参数
		memset(com,0,20);
		if(_2023ups[i].LINK_COM_NUM	>	0){		// _2023ups[i].LINK_COM_NUM从配置文件读取,>0有效	
			_2023ups[i].UPS_SET_ACTIVE=TRUE;
			//gtk_switch_set_active(itemValue[i][9],TRUE);
			//_2023ups[i].UPS_ALARM_ENABLE=TRUE;
			#ifdef _DEBUG_
			printf("start com%d communication\n",_2023ups[i].LINK_COM_NUM);
			#endif
			sprintf(com,"\\\\.\\COM%d",_2023ups[i].LINK_COM_NUM);
			_2023ups[i].UPS_COM_HANDLE=initialCom(com,1024);
			if(_2023ups[i].UPS_COM_HANDLE == INVALID_HANDLE_VALUE){
				//需要加入异常处理及日志记录
				errorReport();
				printf("Open Com%d Error shit\n",_2023ups[i].LINK_COM_NUM);
				//
				exit(0);
			}
			COMMTIMEOUTS timeouts={_2023ups[i].READ_INTERVAL,_2023ups[i].READ_MULTIPLIER,\
				_2023ups[i].READ_CONSTANT,_2023ups[i].WRITE_MULTIPLIER,_2023ups[i].WRITE_CONSTANT};
			if(setComTimeout(_2023ups[i].UPS_COM_HANDLE,timeouts))
				printf("set com timeout ok\n");
				//需要加入异常处理及日志记录
			if(setComPara(_2023ups[i].UPS_COM_HANDLE,_24_N_8_1))
				printf("set com parameter ok\n");	
				//需要加入异常处理及日志记录
		}
		else {
			_2023ups[i].UPS_SET_ACTIVE=FALSE;
		}
	}

	GtkApplication *app;
	app = gtk_application_new ("org.gtk.ups_monitor_v3", G_APPLICATION_FLAGS_NONE);
	int status;
	g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
	g_signal_connect (app, "startup", G_CALLBACK (startup), NULL);
	//5.创建一个线程,用来发送接收串口数据
	//	#ifndef NO_DATA_THREAD
	HANDLE sendDataThreadProc=CreateThread(NULL,0,sendDataViaCom,NULL,0,NULL);
	printf("Start data transmision\n");
	//	#endif
	status = g_application_run (G_APPLICATION (app), argc, argv);
	g_object_unref (app);
	return 0;
}
Example #20
0
/* Main entry point */
int main(int argc, char **argv)
{
	XfdashboardApplication		*app=NULL;
	GError						*error=NULL;
	gint						status;

#if !defined(GLIB_CHECK_VERSION) || !GLIB_CHECK_VERSION(2, 36, 0)
	/* Initialize GObject type system */
	g_type_init();
#endif

	/* Check for running instance (keep only one instance) */
	app=xfdashboard_application_get_default();

	g_application_register(G_APPLICATION(app), NULL, &error);
	if(error!=NULL)
	{
		g_warning(_("Unable to register application: %s"), error->message);
		g_error_free(error);
		error=NULL;
		return(XFDASHBOARD_APPLICATION_ERROR_FAILED);
	}

	if(g_application_get_is_remote(G_APPLICATION(app))==TRUE)
	{
		/* Handle command-line on primary instance of application
		 * and activate primary instance if handling command-line
		 * was successful
		 */
		status=g_application_run(G_APPLICATION(app), argc, argv);
		switch(status)
		{
			case XFDASHBOARD_APPLICATION_ERROR_NONE:
			case XFDASHBOARD_APPLICATION_ERROR_QUIT:
				/* Do nothing at remote instance */
				break;

			default:
				g_error(_("Initializing application failed with status code %d"), status);
				break;
		}

		/* Exit this instance of application */
		g_object_unref(app);
		return(status);
	}

	/* Tell clutter to try to initialize an RGBA visual */
	clutter_x11_set_use_argb_visual(TRUE);

	/* Initialize GTK+ and Clutter */
	gtk_init(&argc, &argv);
	if(!clutter_init(&argc, &argv))
	{
		g_error(_("Initializing clutter failed!"));
		return(1);
	}

	/* Handle command-line on primary instance */
	status=g_application_run(G_APPLICATION(app), argc, argv);
	if(status!=XFDASHBOARD_APPLICATION_ERROR_NONE)
	{
		g_object_unref(app);
		return(status);
	}

	/* Start main loop */
	clutter_main();

	/* Clean up, release allocated resources */
	g_object_unref(app);

	return(XFDASHBOARD_APPLICATION_ERROR_NONE);
}
Example #21
0
File: main.c Project: 8l/ghex
int
main(int argc, char **argv)
{
	GtkWidget *win;
	GError *error = NULL;
	GtkApplication *application;
	gchar *locale_dir;
	gint retval;

	locale_dir = ghex_locale_dir ();
	bindtextdomain (GETTEXT_PACKAGE, locale_dir);
	g_free (locale_dir);

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

	/* Initialize GTK+ program */
	if (!gtk_init_with_args (&argc, &argv,
	                         _("- GTK+ binary editor"),
	                         options,
	                         GETTEXT_PACKAGE,
	                         &error)) {
		g_printerr (_("%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;
	}

	/* Set default window icon */
	gtk_window_set_default_icon_name ("ghex");

	/* load preferences */
	ghex_init_configuration();

	/* accessibility setup */
	setup_factory();

	application = gtk_application_new ("org.gnome.GHexApplication",
	                                   G_APPLICATION_NON_UNIQUE);
	g_signal_connect (application, "activate",
	                  G_CALLBACK (ghex_activate), NULL);

	g_application_register (G_APPLICATION (application), NULL, NULL);

	if (args_remaining != NULL) {
		gchar **filename;
		for (filename = args_remaining; *filename != NULL; filename++) {
			if (g_file_test (*filename, G_FILE_TEST_EXISTS)) {
				win = ghex_window_new_from_file (application, *filename);
				if(win != NULL) {
					if(geometry) {
						if(!gtk_window_parse_geometry(GTK_WINDOW(win), geometry))
							g_warning(_("Invalid geometry string \"%s\"\n"), geometry);
						geometry = NULL;
					}
					gtk_widget_show(win);
				}
			}
		}
	}

	if(ghex_window_get_list() == NULL) {
		win = ghex_window_new (application);
		if(geometry) {
			if(!gtk_window_parse_geometry(GTK_WINDOW(win), geometry))
				g_warning(_("Invalid geometry string \"%s\"\n"), geometry);
			geometry = NULL;
		}
		gtk_widget_show(win);
	}
	else win = GTK_WIDGET(ghex_window_get_list()->data);

	retval = g_application_run (G_APPLICATION (application), argc, argv);
	g_object_unref (application);

	return retval;
}
Example #22
0
gint
main (gint argc, gchar **argv)
{
        GtkApplication  *application;
	GOptionContext  *context;
	GError          *error = NULL;
        int              status = 1;

#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

#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 (_("GNOME Document Previewer"));
	g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
	g_option_context_add_main_entries (context, goption_options, GETTEXT_PACKAGE);

	g_option_context_add_group (context, gtk_get_option_group (TRUE));

	if (!g_option_context_parse (context, &argc, &argv, &error)) {
		g_printerr ("Error parsing command line arguments: %s\n", error->message);
		g_error_free (error);
		g_option_context_free (context);
                return 1;
	}
	g_option_context_free (context);

	if (argc < 2) {
		g_printerr ("File argument is required\n");
                return 1;
	} else if (argc > 2) {
                g_printerr ("Too many files\n");
                return 1;
        }

	if (!g_file_test (argv[1], G_FILE_TEST_IS_REGULAR)) {
		g_printerr ("Filename \"%s\" does not exist or is not a regular file\n", argv[1]);
                return 1;
	}

	if (!ev_init ())
                return 1;

	ev_stock_icons_init ();

	g_set_application_name (_("GNOME Document Previewer"));
	gtk_window_set_default_icon_name ("evince");

        application = gtk_application_new (NULL,
                                           G_APPLICATION_NON_UNIQUE |
                                           G_APPLICATION_HANDLES_OPEN);
        g_signal_connect (application, "activate", G_CALLBACK (activate_cb), NULL);
        g_signal_connect (application, "open", G_CALLBACK (open_cb), NULL);

        status = g_application_run (G_APPLICATION (application), argc, argv);

        if (unlink_temp_file)
                ev_previewer_unlink_tempfile (argv[1]);
        if (print_settings)
                ev_previewer_unlink_tempfile (print_settings);

	ev_shutdown ();
	ev_stock_icons_shutdown ();

	return status;
}
Example #23
0
int
main (int argc, char **argv)
{
	RBShell *shell;
	gboolean autostarted;
	char *desktop_file_path;
	int new_argc;
	char **new_argv;

	/* disable multidevice so clutter-gtk events work.
	 * this needs to be done before gtk_open, so the visualizer
	 * plugin can't do it.
	 */
	gdk_disable_multidevice ();
	g_thread_init (NULL);
	g_type_init ();
	g_random_set_seed (time (0));

	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);

	setlocale (LC_ALL, NULL);

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

	textdomain (GETTEXT_PACKAGE);
#endif

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

	/* TODO: kill this function */
	rb_threads_init ();
	if (glib_check_version (2, 31, 1) != NULL) {
		gdk_threads_enter ();
	}

	new_argc = argc;
	new_argv = argv;
	shell = rb_shell_new (autostarted, &argc, &argv);

	g_application_run (G_APPLICATION (shell), new_argc, new_argv);

	g_object_unref (shell);

	if (glib_check_version (2, 31, 1) != NULL) {
		gdk_threads_leave ();
	}

	exit (0);
}
Example #24
0
int
main (int argc, char *argv[])
{
  char **player_names;
  gsize n_player_names;
  guint i;
  GOptionContext *context;
  gboolean retval;
  GError *error = NULL;

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

  application = gtk_application_new ("org.gnome.gtali", 0);
  g_signal_connect (application, "activate", G_CALLBACK (GyahtzeeCreateMainWindow), NULL);

  games_scores_startup ();

  /* Reset all yahtzee variables before parsing args */
  YahtzeeInit ();

  context = g_option_context_new (NULL);
  g_option_context_add_group (context, gtk_get_option_group (TRUE));
  g_option_context_add_main_entries (context, yahtzee_options,
				     GETTEXT_PACKAGE);
  retval = g_option_context_parse (context, &argc, &argv, &error);
  g_option_context_free (context);
  if (!retval) {
    g_print ("%s", error->message);
    g_error_free (error);
    exit (1);
  }

  settings = g_settings_new ("org.gnome.gtali");

  g_set_application_name (_(appName));

  games_stock_init ();

  /* If we're in computer test mode, just run some tests, no GUI */
  if (test_computer_play > 0) {
      gint ii, jj, kk;
      gdouble sum_scores = 0.0;
      game_type = GAME_YAHTZEE;
      if (game_type_string)
          game_type = game_type_from_string(game_type_string);
      g_message("In test computer play section - Using %d trials for simulation", NUM_TRIALS);
      for (ii = 0; ii < test_computer_play; ii++) {
          int num_rolls = 0;
          NumberOfHumans = 0;
          NumberOfComputers = 1;
          NewGame ();

          while (!GameIsOver() && num_rolls < 100) {
              ComputerRolling (CurrentPlayer);
              if (NoDiceSelected () || (NumberOfRolls >= NUM_ROLLS)) {
                ComputerScoring (CurrentPlayer);
                NumberOfRolls = 0;
                SelectAllDice ();
                RollSelectedDice ();
              } else {
                RollSelectedDice ();
              }
              num_rolls++;
          }
          for (kk = NumberOfHumans; kk < NumberOfPlayers; kk++) {
              printf("Computer score: %d\n", total_score(kk));
              sum_scores += total_score(kk);
              if (num_rolls > 98) {
                  for (jj = 0; jj < NUM_FIELDS; jj++)
                      g_message("Category %d is score %d", jj, players[kk].score[jj]);
              }
          }
      }
      printf("Computer average: %.2f for %d trials\n", sum_scores / test_computer_play, NUM_TRIALS);
      exit(0);
  }

  highscores = games_scores_new ("gtali",
                                 category_array, G_N_ELEMENTS (category_array),
                                 "game type", NULL,
                                 0 /* default category */,
                                 GAMES_SCORES_STYLE_PLAIN_DESCENDING);

  gtk_window_set_default_icon_name ("gtali");

  if (NumberOfComputers == 0)	/* Not set on the command-line. */
    NumberOfComputers = g_settings_get_int (settings, "number-of-computer-opponents");

  if (NumberOfHumans == 0)	/* Not set on the command-line. */
    NumberOfHumans = g_settings_get_int (settings, "number-of-human-opponents");

  if (NumberOfHumans < 1)
    NumberOfHumans = 1;
  if (NumberOfComputers < 0)
    NumberOfComputers = 0;

  if (NumberOfHumans > MAX_NUMBER_OF_PLAYERS)
    NumberOfHumans = MAX_NUMBER_OF_PLAYERS;
  if ((NumberOfHumans + NumberOfComputers) > MAX_NUMBER_OF_PLAYERS)
    NumberOfComputers = MAX_NUMBER_OF_PLAYERS - NumberOfHumans;

  if (game_type_string)
    game_type = game_type_from_string(game_type_string);
  else {
    char *type;

    type = g_settings_get_string (settings, "game-type");
    game_type = game_type_from_string(type);
  }

  set_new_game_type(game_type);

  if (NUM_TRIALS <= 0)
      NUM_TRIALS = g_settings_get_int (settings, "monte-carlo-trials");

  if (DoDelay == 0)		/* Not set on the command-line */
    DoDelay = g_settings_get_boolean (settings, "delay-between-rolls");
  if (DisplayComputerThoughts == 0)	/* Not set on the command-line */
    DisplayComputerThoughts = g_settings_get_boolean (settings, "display-computer-thoughts");
  
  /* Read in new player names */
  player_names = g_settings_get_strv (settings, "player-names");
  n_player_names = g_strv_length (player_names);
  if (player_names) {
    n_player_names = MIN (n_player_names, MAX_NUMBER_OF_PLAYERS);

    for (i = 0; i < n_player_names; ++i) {
      if (i == 0 && strcasecmp (player_names[i], _("Human")) == 0) {
	const char *realname;

	realname = g_get_real_name ();
        if (realname && realname[0] && strcmp (realname, "Unknown") != 0) {
          players[i].name = g_locale_to_utf8 (realname, -1, NULL, NULL, NULL);
        }
        if (!players[i].name) {
	  players[i].name = g_strdup (player_names[i]);
	}
      } else {
        players[i].name = g_strdup (player_names[i]);
      }
    }

    g_strfreev (player_names);
  }

  g_application_run (G_APPLICATION (application), argc, argv);

  exit(0);
}
Example #25
0
File: main.c Project: tiwoc/liferea
int
main (int argc, char *argv[])
{
	GtkApplication	*app;
	GError		*error = NULL;
	GOptionContext	*context;
	GOptionGroup	*debug;
	gulong		debug_flags = 0;
	LifereaDBus	*dbus = NULL;
	gchar		*feedUri = NULL;
	gint 		status;

	GOptionEntry entries[] = {
		{ "mainwindow-state", 'w', 0, G_OPTION_ARG_STRING, &initialStateOption, N_("Start Liferea with its main window in STATE. STATE may be `shown', `iconified', or `hidden'"), N_("STATE") },
		{ "version", 'v', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, show_version, N_("Show version information and exit"), NULL },
		{ "add-feed", 'a', 0, G_OPTION_ARG_STRING, &feedUri, N_("Add a new subscription"), N_("uri") },
		{ NULL, 0, 0, 0, NULL, NULL, NULL }
	};

	GOptionEntry debug_entries[] = {
		{ "debug-all", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of all types"), NULL },
		{ "debug-cache", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages for the cache handling"), NULL },
		{ "debug-conf", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages for the configuration handling"), NULL },
		{ "debug-db", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of the database handling"), NULL },
		{ "debug-gui", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of all GUI functions"), NULL },
		{ "debug-html", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Enables HTML rendering debugging. Each time Liferea renders HTML output it will also dump the generated HTML into ~/.cache/liferea/output.xhtml"), NULL },
		{ "debug-net", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of all network activity"), NULL },
		{ "debug-parsing", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of all parsing functions"), NULL },
		{ "debug-performance", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages when a function takes too long to process"), NULL },
		{ "debug-trace", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages when entering/leaving functions"), NULL },
		{ "debug-update", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of the feed update processing"), NULL },
		{ "debug-vfolder", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of the search folder matching"), NULL },
		{ "debug-verbose", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print verbose debugging messages"), NULL },
		{ NULL, 0, 0, 0, NULL, NULL, NULL }
	};

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

	debug = g_option_group_new ("debug",
				    _("Print debugging messages for the given topic"),
				    _("Print debugging messages for the given topic"),
				    &debug_flags,
				    NULL);
	g_option_group_set_translation_domain(debug, GETTEXT_PACKAGE);
	g_option_group_add_entries (debug, debug_entries);

	context = g_option_context_new (NULL);
	g_option_context_set_summary (context, N_("Liferea, the Linux Feed Reader"));
	g_option_context_set_description (context, N_("For more information, please visit http://lzone.de/liferea/"));
	g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
	g_option_context_set_translation_domain(context, GETTEXT_PACKAGE);
	g_option_context_add_group (context, debug);
	g_option_context_add_group (context, gtk_get_option_group (FALSE));
	g_option_context_add_group (context, g_irepository_get_option_group ());

	g_option_context_parse (context, &argc, &argv, &error);
	g_option_context_free (context);
	if (error) {
		g_print ("Error parsing options: %s\n", error->message);
	}

	set_debug_level (debug_flags);

	/* Configuration necessary for network options, so it
	   has to be initialized before update_init() */
	conf_init ();

	/* We need to do the network initialization here to allow
	   network-manager to be setup before gtk_init() */
	update_init ();

	gtk_init (&argc, &argv);

	/* Single instance checks, also note that we pass or only RPC (add-feed)
	   as activate signal payload as it is simply an URI string. */
	app = gtk_application_new ("net.sourceforge.liferea", G_APPLICATION_HANDLES_OPEN);
	g_signal_connect (app, "activate", G_CALLBACK (on_app_activate), feedUri);
	g_signal_connect (app, "open", G_CALLBACK (on_feed_add), NULL);

	g_set_prgname ("liferea");
	g_set_application_name (_("Liferea"));
	gtk_window_set_default_icon_name ("liferea");	/* GTK theme support */

	debug_start_measurement (DEBUG_DB);

	/* order is important! */
	db_init ();			/* initialize sqlite */
	xml_init ();			/* initialize libxml2 */
#ifdef HAVE_LIBNOTIFY
	notification_plugin_register (&libnotify_plugin);
#endif
	social_init ();			/* initialize social bookmarking */

	dbus = liferea_dbus_new ();

	signal (SIGTERM, signal_handler);
	signal (SIGINT, signal_handler);
	signal (SIGHUP, signal_handler);

	/* Note: we explicitely do not use the gdk_thread_*
	   locking in Liferea because it freezes the program
	   when running Flash applets */

	runState = STATE_STARTING;
	
	debug_end_measurement (DEBUG_DB, "startup");

	status = g_application_run (G_APPLICATION (app), 0, NULL);

	/* Trigger RPCs if we are not primary instance (currently only feed-add) */
	if (feedUri && g_application_get_is_remote (G_APPLICATION (app))) {
		GFile *uris[2];

		uris[0] = g_file_new_for_uri (feedUri);
		uris[1] = NULL;
		g_application_open (G_APPLICATION (app), uris, 1, "feed-add");
		g_object_unref (uris[0]);
	}
	
	g_object_unref (G_OBJECT (dbus));
	g_object_unref (app);

	return status;
}
Example #26
0
/* Main entry point */
int main(int argc, char **argv)
{
	XfdashboardApplication		*app=NULL;
	gint						status;

#ifdef ENABLE_NLS
	/* Set up localization */
	xfce_textdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
#endif

#if !GLIB_CHECK_VERSION(2, 36, 0)
	/* Initialize GObject type system */
	g_type_init();
#endif

#if CLUTTER_CHECK_VERSION(1, 16, 0)
	/* Enforce X11 backend in Clutter. This function must be called before any
	 * other Clutter API function.
	 */
	clutter_set_windowing_backend("x11");
#endif

	/* Tell clutter to try to initialize an RGBA visual */
	clutter_x11_set_use_argb_visual(TRUE);

	/* Initialize GTK+ and Clutter */
	gtk_init(&argc, &argv);
	if(!clutter_init(&argc, &argv))
	{
		g_error(_("Initializing clutter failed!"));
		return(1);
	}

	/* Notify that application has started and main loop will be entered */
	gdk_notify_startup_complete();

	/* Start application as primary or remote instace */
	app=xfdashboard_application_get_default();
	if(!app)
	{
		g_warning(_("Failed to create application instance"));
		return(XFDASHBOARD_APPLICATION_ERROR_FAILED);
	}

	status=g_application_run(G_APPLICATION(app), argc, argv);
	if(status==XFDASHBOARD_APPLICATION_ERROR_RESTART &&
		g_application_get_is_remote(G_APPLICATION(app)))
	{
		/* Wait for existing primary instance to quit */
		if(_restart(app))
		{
			g_debug("Reached clean state to restart application");

			/* Destroy remote instance application object for restart */
			g_object_unref(app);
			app=NULL;

			/* Create new application instance which should become
			 * the new primary instance.
			 */
			app=xfdashboard_application_get_default();
			if(!app)
			{
				g_warning(_("Failed to create application instance"));
				return(XFDASHBOARD_APPLICATION_ERROR_FAILED);
			}

			g_debug("Starting new primary instance");
			status=g_application_run(G_APPLICATION(app), argc, argv);
		}
			else
			{
				g_warning(_("Could not restart application because existing instance seems still to be running."));
			}
	}

	/* Clean up, release allocated resources */
	g_object_unref(app);

	return(status);
}
Example #27
0
gint
main (gint argc,
      gchar **argv)
{
	AlarmNotify *alarm_notify_service;
	gint exit_status;
	GError *error = NULL;
#ifdef G_OS_WIN32
	gchar *path;

	/* Reduce risks */
	{
		typedef BOOL (WINAPI *t_SetDllDirectoryA) (LPCSTR lpPathName);
		t_SetDllDirectoryA p_SetDllDirectoryA;

		p_SetDllDirectoryA = GetProcAddress (GetModuleHandle ("kernel32.dll"), "SetDllDirectoryA");
		if (p_SetDllDirectoryA)
			(*p_SetDllDirectoryA) ("");
	}
#ifndef _WIN64
	{
		typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags);
		t_SetProcessDEPPolicy p_SetProcessDEPPolicy;

		p_SetProcessDEPPolicy = GetProcAddress (GetModuleHandle ("kernel32.dll"), "SetProcessDEPPolicy");
		if (p_SetProcessDEPPolicy)
			(*p_SetProcessDEPPolicy) (PROCESS_DEP_ENABLE | PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION);
	}
#endif
#endif

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

	gtk_init (&argc, &argv);

	e_gdbus_templates_init_main_thread ();

#ifdef G_OS_WIN32
	path = g_build_path (";", _e_get_bindir (), g_getenv ("PATH"), NULL);

	if (!g_setenv ("PATH", path, TRUE))
		g_warning ("Could not set PATH for Evolution Alarm Notifier");
#endif

	alarm_notify_service = alarm_notify_new (NULL, &error);

	if (error != NULL) {
		g_printerr ("%s\n", error->message);
		g_error_free (error);
		exit (EXIT_FAILURE);
	}

	g_application_register (G_APPLICATION (alarm_notify_service), NULL, &error);

	if (error != NULL) {
		g_printerr ("%s\n", error->message);
		g_error_free (error);
		g_object_unref (alarm_notify_service);
		exit (EXIT_FAILURE);
	}

	if (g_application_get_is_remote (G_APPLICATION (alarm_notify_service))) {
		g_object_unref (alarm_notify_service);
		return 0;
	}

	exit_status = g_application_run (
		G_APPLICATION (alarm_notify_service), argc, argv);

	g_object_unref (alarm_notify_service);
	config_data_cleanup ();

	return exit_status;
}
Example #28
0
int
main (int argc, char **argv)
{
  GtkWidget *window;
  GdkScreen *screen;
  int monitor;
  GdkRectangle rect;
  GError *error = NULL;
  char *font = NULL;
  char **remaining = NULL;
  GtkApplication *application;
  guint status;
  GOptionEntry goptions[] =
  {
    { "font", 0, 0, G_OPTION_ARG_STRING, &font,
      N_("Font to start with; ex: 'Serif 27'"), N_("FONT") },
    { "version", 0, G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG, 
      G_OPTION_ARG_CALLBACK, option_version_cb, NULL, NULL },
    { "print", 'p', 0, G_OPTION_ARG_CALLBACK, option_print_cb,
      "Print characters in string", "STRING" },
    { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining,
      NULL, N_("[STRING…]") },
    { NULL }
  };

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

  /* Not interested in silly debug spew polluting the journal, bug #749195 */
  if (g_getenv ("G_ENABLE_DIAGNOSTIC") == NULL)
    g_setenv ("G_ENABLE_DIAGNOSTIC", "0", TRUE);

  /* Set programme name explicitly (see bug #653115) */
  g_set_prgname("gucharmap");

  if (!gtk_init_with_args (&argc, &argv, NULL, goptions, GETTEXT_PACKAGE, &error))
    {
      g_printerr ("%s\n", error->message);
      g_error_free (error);

      exit (1);
    }

  g_set_application_name (_("Character Map"));
  gtk_window_set_default_icon_name (GUCHARMAP_ICON_NAME);

  application = gtk_application_new ("org.gnome.Charmap",
                                     G_APPLICATION_NON_UNIQUE);
  g_signal_connect (application, "startup", G_CALLBACK (startup_cb), NULL);
  g_signal_connect (application, "activate",
                    G_CALLBACK (gucharmap_activate), NULL);

  g_application_register (G_APPLICATION (application), NULL, NULL);

  /* Gucharmap doesn't work right with the dark theme, see #741939. 
   * Apparently this got fixed in gtk+ some time before 3.22, so
   * only work around this on older versions.
   */
  if (gtk_check_version (3, 22, 0) != NULL /* < 3.22.0 */)
    g_object_set (gtk_settings_get_default (), "gtk-application-prefer-dark-theme", FALSE, NULL);

  window = gucharmap_window_new (application);

  screen = gtk_window_get_screen (GTK_WINDOW (window));
  monitor = gdk_screen_get_monitor_at_point (screen, 0, 0);
#if GTK_CHECK_VERSION (3, 3, 5)
  gdk_screen_get_monitor_workarea (screen, monitor, &rect);
#else
  gdk_screen_get_monitor_geometry (screen, monitor, &rect);
#endif
  gtk_window_set_default_size (GTK_WINDOW (window), rect.width * 9/16, rect.height * 9/16);

  if (font)
    {
      gucharmap_window_set_font (GUCHARMAP_WINDOW (window), font);
      g_free (font);
    }

  gtk_window_present (GTK_WINDOW (window));

  if (remaining) {
    char *str = g_strjoinv (" ", remaining);
    gucharmap_window_search (GUCHARMAP_WINDOW (window), str);
    g_free (str);
    g_strfreev (remaining);
  }

  status = g_application_run (G_APPLICATION (application), argc, argv);
  g_object_unref (application);

  return status;
}
Example #29
0
int
main (int argc,
    char *argv[])
{
  GOptionContext *optcontext;
  GOptionEntry options[] = {
      { NULL }
  };
#ifdef ENABLE_DEBUG
  TpDebugSender *debug_sender;
#endif
  GError *error = NULL;
  gint retval;
  GtkSettings *gtk_settings;

  /* Init */
  g_thread_init (NULL);

#ifdef GDK_WINDOWING_X11
  /* We can't call clutter_gst_init() before gtk_clutter_init(), so no choice
   * but to intiialise X11 threading ourself */
  XInitThreads ();
#endif

  /* Clutter needs this */
  gdk_disable_multidevice ();

  optcontext = g_option_context_new (N_("- Empathy Audio/Video Client"));
  g_option_context_add_group (optcontext, gst_init_get_option_group ());
  g_option_context_add_group (optcontext, gtk_get_option_group (TRUE));
  g_option_context_add_group (optcontext, cogl_get_option_group ());
  g_option_context_add_group (optcontext,
      clutter_get_option_group_without_init ());
  g_option_context_add_group (optcontext, gtk_clutter_get_option_group ());
  g_option_context_add_main_entries (optcontext, options, GETTEXT_PACKAGE);

  if (!g_option_context_parse (optcontext, &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_warning ("Error in empathy-call init: %s", error->message);
    return EXIT_FAILURE;
  }

  g_option_context_free (optcontext);

  clutter_gst_init (&argc, &argv);

  empathy_gtk_init ();
  g_set_application_name (_("Empathy Audio/Video Client"));

  /* Make empathy and empathy-call appear as the same app in gnome-shell */
  gdk_set_program_class ("Empathy");
  gtk_window_set_default_icon_name ("empathy");
  textdomain (GETTEXT_PACKAGE);

  gtk_settings = gtk_settings_get_default ();
  g_object_set (G_OBJECT (gtk_settings), "gtk-application-prefer-dark-theme",
      TRUE, NULL);

  app = gtk_application_new (EMPATHY_CALL_DBUS_NAME, G_APPLICATION_FLAGS_NONE);
  g_signal_connect (app, "activate", G_CALLBACK (activate_cb), NULL);

#ifdef ENABLE_DEBUG
  /* Set up debug sender */
  debug_sender = tp_debug_sender_dup ();
  g_log_set_default_handler (tp_debug_sender_log_handler, G_LOG_DOMAIN);
#endif

  if (g_getenv ("EMPATHY_PERSIST") != NULL)
    {
      DEBUG ("Disable timer");

      use_timer = FALSE;
    }

  call_windows = g_hash_table_new_full (g_direct_hash, g_direct_equal,
      g_object_unref, NULL);

  /* the inactivity timeout can only be set while the application is held */
  g_application_hold (G_APPLICATION (app));
  g_application_set_inactivity_timeout (G_APPLICATION (app), TIMEOUT * 1000);
  g_application_release (G_APPLICATION (app));

  retval = g_application_run (G_APPLICATION (app), argc, argv);

  g_hash_table_unref (call_windows);
  g_object_unref (app);
  tp_clear_object (&call_factory);

#ifdef ENABLE_DEBUG
  g_object_unref (debug_sender);
#endif

  return retval;
}
Example #30
0
int
main (int argc,
    char *argv[])
{
  GOptionContext *optcontext;
  GOptionEntry options[] = {
      { NULL }
  };
#ifdef ENABLE_DEBUG
  TpDebugSender *debug_sender;
#endif
  GError *error = NULL;
  EmpathyChatManager *chat_mgr;
  EmpathyIdle *idle;
  gint retval;

  /* Init */
  g_thread_init (NULL);

  optcontext = g_option_context_new (N_("- Empathy Chat Client"));
  g_option_context_add_group (optcontext, gtk_get_option_group (TRUE));
  g_option_context_add_main_entries (optcontext, options, GETTEXT_PACKAGE);

  if (!g_option_context_parse (optcontext, &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_warning ("Error in empathy-av init: %s", error->message);
      return EXIT_FAILURE;
    }

  g_option_context_free (optcontext);

  empathy_gtk_init ();

  gtk_window_set_default_icon_name ("empathy");
  textdomain (GETTEXT_PACKAGE);

  app = gtk_application_new (EMPATHY_CHAT_DBUS_NAME, G_APPLICATION_IS_SERVICE);
  g_signal_connect (app, "activate", G_CALLBACK (activate_cb), NULL);

#ifdef ENABLE_DEBUG
  /* Set up debug sender */
  debug_sender = tp_debug_sender_dup ();
  g_log_set_default_handler (tp_debug_sender_log_handler, G_LOG_DOMAIN);
#endif

  /* Setting up Idle */
  idle = empathy_idle_dup_singleton ();

  chat_mgr = empathy_chat_manager_dup_singleton ();

  g_signal_connect (chat_mgr, "handled-chats-changed",
      G_CALLBACK (handled_chats_changed_cb), GUINT_TO_POINTER (1));

  if (g_getenv ("EMPATHY_PERSIST") != NULL)
    {
      DEBUG ("Disable timer");

      use_timer = FALSE;
    }

  /* the inactivity timeout can only be set while the application is held */
  g_application_hold (G_APPLICATION (app));
  g_application_set_inactivity_timeout (G_APPLICATION (app), TIMEOUT * 1000);
  g_application_release (G_APPLICATION (app));

  DEBUG ("Waiting for text channels to handle");

  retval = g_application_run (G_APPLICATION (app), argc, argv);

  g_object_unref (app);
  g_object_unref (idle);
  g_object_unref (chat_mgr);

#ifdef ENABLE_DEBUG
  g_object_unref (debug_sender);
#endif

  return retval;
}