Example #1
0
static GOptionContext *
gth_application_create_option_context (void)
{
	GOptionContext *context;
	static gsize    initialized = FALSE;

	context = g_option_context_new (N_("— Image browser and viewer"));
	g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
	g_option_context_set_ignore_unknown_options (context, TRUE);
	g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);

	if (g_once_init_enter (&initialized)) {
		g_option_context_add_group (context, gtk_get_option_group (TRUE));
#ifdef HAVE_CLUTTER
		g_option_context_add_group (context, clutter_get_option_group_without_init ());
		g_option_context_add_group (context, gtk_clutter_get_option_group ());
#endif
#ifdef HAVE_GSTREAMER
		g_option_context_add_group (context, gst_init_get_option_group ());
#endif
		g_once_init_leave (&initialized, TRUE);
	}

	return context;
}
int
main (int     argc,
      char  **argv)
{
  gboolean down = false;
  gboolean up = false;
  GOptionEntry _options[] = {
    { "brightness-down", 'd', 0, G_OPTION_ARG_NONE, &down,
      "Decrease screen brightness by one step", NULL },
    { "brightness-up", 'u', 0, G_OPTION_ARG_NONE, &up,
      "Increase screen brightness by one step", NULL },
    { NULL }
  };

  MpdDisplayDevice  *display;
  GOptionContext    *context;
  GError            *error = NULL;

  context = g_option_context_new ("");
  g_option_context_add_main_entries (context, _options, NULL);
  g_option_context_add_group (context, clutter_get_option_group_without_init ());
  if (!g_option_context_parse (context, &argc, &argv, &error))
  {
    g_critical ("%s %s", G_STRLOC, error->message);
    return EXIT_FAILURE;
  }
  g_option_context_free (context);

  gtk_clutter_init (&argc, &argv);

  display = mpd_display_device_new ();
  g_debug ("enabled: %i, brightness, %.1f",
           mpd_display_device_is_enabled (display),
           mpd_display_device_get_brightness (display));

  g_signal_connect (display, "notify::enabled",
                    G_CALLBACK (_display_enabled_notify_cb), NULL);
  g_signal_connect (display, "notify::brightness",
                    G_CALLBACK (_display_brightness_notify_cb), NULL);

  if (up)
  {
    g_idle_add ((GSourceFunc) _brightness_up_cb, display);
  } else if (down)
  {
    g_idle_add ((GSourceFunc) _brightness_down_cb, display);
  }

  clutter_main ();
  g_object_unref (display);
  return EXIT_SUCCESS;
}
int
main (int argc, char *argv[])
{
    GOptionContext *context;
    GError *error = NULL;

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

    context = g_option_context_new ("- dawati status panel");
    g_option_context_add_main_entries (context, status_options, GETTEXT_PACKAGE);
    g_option_context_add_group (context, clutter_get_option_group_without_init ());
    g_option_context_add_group (context, cogl_get_option_group ());
    g_option_context_add_group (context, gtk_get_option_group (FALSE));

    if (!g_option_context_parse (context, &argc, &argv, &error))
    {
        g_critical (G_STRLOC ": Error parsing option: %s", error->message);
        g_clear_error (&error);
    }

    g_option_context_free (context);

    mpl_panel_clutter_init_with_gtk (&argc, &argv);

    mx_style_load_from_file (mx_style_get_default (),
                             THEMEDIR "/panel.css",
                             &error);

    if (error)
    {
        g_critical ("Unable to load style: %s", error->message);
        g_clear_error (&error);
    }

    panel = g_new0 (DawatiStatusPanel, 1);

    if (status_standalone)
        setup_standalone (panel);
    else
        setup_panel (panel);

    clutter_main ();


    return EXIT_SUCCESS;
}
Example #4
0
/**
 * meta_get_option_context: (skip)
 *
 * Returns a #GOptionContext initialized with muffin-related options.
 * Parse the command-line args with this before calling meta_init().
 *
 * Return value: the #GOptionContext
 */
GOptionContext *
meta_get_option_context (void)
{
  GOptionContext *ctx;

  if (setlocale (LC_ALL, "") == NULL)
    meta_warning ("Locale not understood by C library, internationalization will not work\n");
  bindtextdomain (GETTEXT_PACKAGE, MUFFIN_LOCALEDIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");

  ctx = g_option_context_new (NULL);
  g_option_context_add_main_entries (ctx, meta_options, GETTEXT_PACKAGE);
  g_option_context_add_group (ctx, clutter_get_option_group_without_init ());
  g_option_context_add_group (ctx, cogl_get_option_group ());

  return ctx;
}
Example #5
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 #6
0
/* Handle command-line on primary instance */
static int _xfdashboard_application_command_line(GApplication *inApplication, GApplicationCommandLine *inCommandLine)
{
	XfdashboardApplication			*self;
	XfdashboardApplicationPrivate	*priv;
	XfdashboardStage				*stage;
	GOptionContext					*context;
	gboolean						result;
	gint							argc;
	gchar							**argv;
	GError							*error;
	gboolean						optionDaemonize;
	gboolean						optionQuit;
	gboolean						optionRestart;
	gboolean						optionToggle;
	gchar							*optionSwitchToView;
	GOptionEntry					XfdashboardApplicationOptions[]=
									{
										{ "daemonize", 'd', 0, G_OPTION_ARG_NONE, &optionDaemonize, N_("Fork to background"), NULL },
										{ "quit", 'q', 0, G_OPTION_ARG_NONE, &optionQuit, N_("Quit running instance"), NULL },
										{ "restart", 'r', 0, G_OPTION_ARG_NONE, &optionRestart, N_("Restart running instance"), NULL },
										{ "toggle", 't', 0, G_OPTION_ARG_NONE, &optionToggle, N_("Toggles suspend/resume state if running instance was started in daemon mode otherwise it quits running non-daemon instance"), NULL },
										{ "view", 0, 0, G_OPTION_ARG_STRING, &optionSwitchToView, N_(""), NULL },
										{ NULL }
									};

	g_return_val_if_fail(XFDASHBOARD_IS_APPLICATION(inApplication), 1);

	self=XFDASHBOARD_APPLICATION(inApplication);
	priv=self->priv;
	error=NULL;
	stage=NULL;

	/* Set up options */
	optionDaemonize=FALSE;
	optionQuit=FALSE;
	optionRestart=FALSE;
	optionToggle=FALSE;
	optionSwitchToView=NULL;

	/* Parse command-line arguments */
	argv=g_application_command_line_get_arguments(inCommandLine, &argc);

	/* Setup command-line options */
	context=g_option_context_new(N_("- A Gnome Shell like dashboard for Xfce4"));
	g_option_context_add_group(context, gtk_get_option_group(TRUE));
	g_option_context_add_group(context, clutter_get_option_group_without_init());
	g_option_context_add_group(context, xfce_sm_client_get_option_group(argc, argv));
	g_option_context_add_main_entries(context, XfdashboardApplicationOptions, GETTEXT_PACKAGE);

#ifdef DEBUG
	/* I always forget the name of the environment variable to get the debug
	 * message display which are emitted with g_debug(). So display a hint
	 * if application was compiled with debug enabled.
	 */
	g_print("** To get debug messages set environment variable G_MESSAGES_DEBUG to %s\n", PACKAGE_NAME);
	g_print("** e.g.: G_MESSAGES_DEBUG=%s %s\n", PACKAGE_NAME, argv[0]);
#endif

	result=g_option_context_parse(context, &argc, &argv, &error);
	g_strfreev(argv);
	g_option_context_free(context);
	if(result==FALSE)
	{
		/* Show error */
		g_print(N_("%s\n"), (error && error->message) ? error->message : _("unknown error"));
		if(error) g_error_free(error);

		/* Release allocated resources */
		if(optionSwitchToView) g_free(optionSwitchToView);

		return(XFDASHBOARD_APPLICATION_ERROR_FAILED);
	}

	/* Handle options: restart
	 * - Only handle option if application was inited already
	 */
	if(priv->inited && optionRestart)
	{
		/* Return state to restart this applicationa */
		g_debug("Received request to restart application!");

		/* Release allocated resources */
		if(optionSwitchToView) g_free(optionSwitchToView);

		return(XFDASHBOARD_APPLICATION_ERROR_RESTART);
	}

	/* Handle options: quit */
	if(optionQuit)
	{
		/* Quit existing instance */
		g_debug("Quitting running instance!");
		_xfdashboard_application_quit(self, TRUE);

		/* Release allocated resources */
		if(optionSwitchToView) g_free(optionSwitchToView);

		return(XFDASHBOARD_APPLICATION_ERROR_QUIT);
	}

	/* Handle options: toggle
	 * - If application was not inited yet, perform normal start-up as usual
	 *   with command-line options given
	 * - If running in daemon mode, resume if suspended otherwise suspend
	 * - If not running in daemon mode, quit application
	 */
	if(priv->inited && optionToggle)
	{
		/* If application is running in daemon mode, toggle between suspend/resume ... */
		if(priv->isDaemon)
		{
			if(priv->isSuspended)
			{
				/* Switch to view if requested */
				_xfdashboard_application_switch_to_view(self, optionSwitchToView);

				/* Show application again */
				_xfdashboard_application_activate(inApplication);
			}
				else
				{
					/* Hide application */
					_xfdashboard_application_quit(self, FALSE);
				}
		}
			/* ... otherwise if not running in daemon mode, just quit */
			else
			{
				/* Hide application */
				_xfdashboard_application_quit(self, FALSE);
			}

		/* Release allocated resources */
		if(optionSwitchToView) g_free(optionSwitchToView);

		/* Stop here because option was handled and application does not get initialized */
		return(XFDASHBOARD_APPLICATION_ERROR_NONE);
	}

	/* Handle options: daemonize */
	if(!priv->inited)
	{
		priv->isDaemon=optionDaemonize;
		g_object_notify_by_pspec(G_OBJECT(self), XfdashboardApplicationProperties[PROP_DAEMONIZED]);

		if(priv->isDaemon)
		{
			priv->isSuspended=TRUE;
			g_object_notify_by_pspec(G_OBJECT(self), XfdashboardApplicationProperties[PROP_SUSPENDED]);
		}
	}

	/* Check if this instance needs to be initialized fully */
	if(!priv->inited)
	{
		/* Perform full initialization of this application instance */
		result=_xfdashboard_application_initialize_full(self, &stage);
		if(result==FALSE) return(XFDASHBOARD_APPLICATION_ERROR_FAILED);

		/* Switch to view if requested */
		_xfdashboard_application_switch_to_view(self, optionSwitchToView);

		/* Show application if not started daemonized */
		if(!priv->isDaemon) clutter_actor_show(CLUTTER_ACTOR(stage));
	}

	/* Check if this instance need to be activated. Is should only be done
	 * if instance is initialized
	 */
	if(priv->inited)
	{
		/* Switch to view if requested */
		_xfdashboard_application_switch_to_view(self, optionSwitchToView);

		/* Show application */
		_xfdashboard_application_activate(inApplication);
	}

	/* Release allocated resources */
	if(optionSwitchToView) g_free(optionSwitchToView);

	/* All done successfully so return status code 0 for success */
	priv->inited=TRUE;
	return(XFDASHBOARD_APPLICATION_ERROR_NONE);
}
int
main (int     argc,
      char  **argv)
{
  bool standalone = false;
  char const *geometry = NULL;
  int dpi = 0;
  GOptionEntry _options[] = {
    { "standalone", 's', 0, G_OPTION_ARG_NONE, &standalone,
      "Run as standalone app (for testing purpose)", NULL },
    { "geometry", 'g', 0, G_OPTION_ARG_STRING, &geometry,
      "Window geometry in standalone mode", NULL },
#if CLUTTER_CHECK_VERSION(1, 3, 0)
    { "clutter-font-dpi", 'd', 0, G_OPTION_ARG_INT, &dpi,
      "Set clutter font resolution to <dpi>", "<dpi>" },
#endif
    { NULL }
  };

  ClutterActor     *shell;
  GOptionContext   *context;
  ClutterInitError  clutter_error;
  GError           *error = NULL;

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

  context = g_option_context_new ("- Dawati devices panel");
  g_option_context_add_main_entries (context, _options, GETTEXT_PACKAGE);
  g_option_context_add_group (context, clutter_get_option_group_without_init ());
  if (!g_option_context_parse (context, &argc, &argv, &error))
  {
    g_critical ("%s %s", G_STRLOC, error->message);
    g_critical ("Starting in standalone mode.");
    g_clear_error (&error);
    standalone = true;
  }
  g_option_context_free (context);

  clutter_error = clutter_init (&argc, &argv);
  if (clutter_error != CLUTTER_INIT_SUCCESS)
    {
      g_critical ("Unable to initialise clutter");
      return EXIT_FAILURE;
    }

  notify_init (_("Dawati Devices Panel"));

  /* Just for icon theme, no widgets. */
  gtk_init (&argc, &argv);

  if (dpi)
    {
#if CLUTTER_CHECK_VERSION(1, 3, 0)
      ClutterSettings *settings = clutter_settings_get_default ();
      g_object_set (settings, "font-dpi", dpi * 1000, NULL);
#endif
    }

  /* Load base styling for default font size */
  mpl_panel_clutter_load_base_style ();

  mx_texture_cache_load_cache (mx_texture_cache_get_default (),
                               PKGDATADIR "/mx.cache");
  mx_style_load_from_file (mx_style_get_default (),
                           THEMEDIR "/panel.css", NULL);

  if (standalone)
  {
    ClutterActor *stage = clutter_stage_get_default ();

    if (geometry)
    {
      int x, y;
      unsigned int width, height;
      XParseGeometry (geometry, &x, &y, &width, &height);
      clutter_actor_set_size (stage, width, height);
    } else
    {
      clutter_actor_set_size (stage, MPD_SHELL_WIDTH, MPD_SHELL_HEIGHT);
    }

    shell = mpd_shell_new ();

    g_signal_connect (shell, "request-hide",
                      G_CALLBACK (_shell_request_hide_cb), NULL);
    g_signal_connect (stage, "notify::width",
                      G_CALLBACK (_stage_width_notify_cb), shell);
    g_signal_connect (stage, "notify::height",
                      G_CALLBACK (_stage_height_notify_cb), shell);

    clutter_container_add_actor (CLUTTER_CONTAINER (stage), shell);
    clutter_actor_show_all (stage);

  } else {

    MplPanelClient *panel = mpd_panel_new ("devices",
                                           _("devices"),
                                           "devices-button");
    shell = mpd_shell_new ();
    mpd_shell_set_client (MPD_SHELL (shell), panel);
    g_signal_connect (shell, "request-hide",
                      G_CALLBACK (_shell_request_hide_cb), panel);
    g_signal_connect (shell, "request-show",
                      G_CALLBACK (_shell_request_show_cb), panel);
    g_signal_connect (panel, "size-changed",
                      G_CALLBACK (_panel_set_size_cb), shell);
    clutter_container_add_actor (CLUTTER_CONTAINER (panel), shell);
  }

  clutter_main ();
  return EXIT_SUCCESS;
}
Example #8
0
int
main (int    argc,
      char **argv)
{
    PinPointRenderer *renderer;
    GOptionContext   *context;
    GError *error = NULL;
    char   *text  = NULL;

    memcpy (&default_point, &pin_default_point, sizeof (default_point));
    renderer = pp_clutter_renderer ();

    context = g_option_context_new ("- Presentations made easy");
    g_option_context_add_main_entries (context, entries, NULL);
    g_option_context_add_group (context, clutter_get_option_group_without_init ());
    g_option_context_add_group (context, cogl_get_option_group ());
    if (!g_option_context_parse (context, &argc, &argv, &error))
    {
        g_print ("option parsing failed: %s\n", error->message);
        return EXIT_FAILURE;
    }

    pinfile = argv[1];

    if (!pinfile)
    {
        g_print ("usage: %s [options] <presentation>\n", argv[0]);
        text = g_strdup ("[no-markup][transition=sheet][red]\n"
                         "--\n"
                         "usage: pinpoint [options] <presentation.txt>\n");
    }
    else
    {
        if (!g_file_get_contents (pinfile, &text, NULL, NULL))
        {
            g_print ("failed to load presentation from %s\n", pinfile);
            return -1;
        }
    }

#ifdef USE_CLUTTER_GST
    clutter_gst_init (&argc, &argv);
#else
    clutter_init (&argc, &argv);
#endif
#ifdef USE_DAX
    dax_init (&argc, &argv);
#endif

    /* select the cairo renderer if we have requested pdf output */
    if (pp_output_filename && g_str_has_suffix (pp_output_filename, ".pdf"))
    {
#ifdef HAVE_PDF
        renderer = pp_cairo_renderer ();
        /* makes more sense to default to a white "stage" colour in PDFs*/
        default_point.stage_color = "white";
#else
        g_warning ("Pinpoint was built without PDF support");
        return EXIT_FAILURE;
#endif
    }

    if (!pinfile)
        pp_rehearse = FALSE;

    if (pinfile)
    {
        GFile *file;

        file = g_file_new_for_commandline_arg (pinfile);
        pp_basedir = g_file_get_parent (file);
        g_object_unref (file);
    }

    renderer->init (renderer, pinfile);
    pp_parse_slides (renderer, text);
    g_free (text);

    if (pp_rehearse)
    {
        pp_rehearse_init ();
        printf ("Running in rehearsal mode, press ctrl+C to abort without saving timings back to %s\n", pinfile);
    }
    renderer->run (renderer);
    renderer->finalize (renderer);
    if (renderer->source)
        g_free (renderer->source);
#if 0
    if (pp_rehearse)
        pp_rehearse_save ();
#endif

    g_list_free (pp_slides);

    return 0;
}
Example #9
0
gint
main (gint argc, gchar ** argv)
{
  gboolean res = FALSE;
  gchar *command = NULL, *input_file_name = NULL;
  BtEditApplication *app;
  GOptionContext *ctx = NULL;
  GOptionGroup *group;
  GError *err = NULL;

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

  bt_setup_for_local_install ();

  GOptionEntry options[] = {
    {"version", '\0', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
        (gpointer) parse_goption_arg, N_("Print application version"), NULL}
    ,
    {"command", 'c', 0, G_OPTION_ARG_STRING, &command, N_("Command name"),
        "{load}"}
    ,
    {"input-file", 'i', 0, G_OPTION_ARG_FILENAME, &input_file_name,
        N_("Input file name"), N_("<songfile>")}
    ,
    {NULL}
  };

  // init libraries
  ctx = g_option_context_new (NULL);
  //g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
  group =
      g_option_group_new ("main", _("buzztrax-edit options"),
      _("Show buzztrax-edit options"), argv[0], NULL);
  g_option_group_add_entries (group, options);
  g_option_group_set_translation_domain (group, GETTEXT_PACKAGE);
  g_option_context_set_main_group (ctx, group);

  bt_init_add_option_groups (ctx);
  g_option_context_add_group (ctx, btic_init_get_option_group ());
  g_option_context_add_group (ctx, gtk_get_option_group (TRUE));
  g_option_context_add_group (ctx, clutter_get_option_group_without_init ());
  g_option_context_add_group (ctx, gtk_clutter_get_option_group ());

  if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
    g_print ("Error initializing: %s\n", safe_string (err->message));
    g_error_free (err);
    goto Done;
  }

  GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "bt-edit", 0,
      "music production environment / editor ui");

  // give some global context info
  g_set_prgname ("buzztrax-edit");
  g_set_application_name ("Buzztrax");
  gtk_window_set_default_icon_name ("buzztrax");
  g_setenv ("PULSE_PROP_media.role", "production", TRUE);

  extern gboolean bt_memory_audio_src_plugin_init (GstPlugin * const plugin);
  gst_plugin_register_static (GST_VERSION_MAJOR,
      GST_VERSION_MINOR,
      "memoryaudiosrc",
      "Plays audio from memory",
      bt_memory_audio_src_plugin_init,
      VERSION, "LGPL", PACKAGE, PACKAGE_NAME, "http://www.buzztrax.org");

  GST_INFO ("starting: thread=%p", g_thread_self ());

  app = bt_edit_application_new ();

  // set a default command, if a file is given
  if (!command && BT_IS_STRING (input_file_name)) {
    command = g_strdup ("l");
  }

  if (command) {
    // depending on the options call the correct method
    if (!strcmp (command, "l") || !strcmp (command, "load")) {
      if (!BT_IS_STRING (input_file_name)) {
        usage (argc, argv, ctx);
        // if commandline options where wrong, just start
        res = bt_edit_application_run (app);
      } else {
        res = bt_edit_application_load_and_run (app, input_file_name);
      }
    } else {
      usage (argc, argv, ctx);
      // if commandline options where wrong, just start
      res = bt_edit_application_run (app);
    }
  } else {
    res = bt_edit_application_run (app);
  }

  // free application
  GST_INFO ("app %" G_OBJECT_REF_COUNT_FMT, G_OBJECT_LOG_REF_COUNT (app));
  g_object_unref (app);

Done:
  g_free (command);
  g_free (input_file_name);
  g_option_context_free (ctx);
  return !res;
}
Example #10
0
static void
main_prog (void *closure, int argc, char *argv[])
{
  AppData data;
  GOptionContext *option_context;
  GError *error = NULL;
  gboolean retval;

  memset (&data, 0, sizeof (AppData));

  option_context = g_option_context_new (NULL);
  g_option_context_set_translation_domain (option_context, GETTEXT_PACKAGE);

  add_main_options (option_context, &data);

  ar_sound_enable (FALSE);

  g_option_context_add_group (option_context, gtk_get_option_group (TRUE));

#ifdef HAVE_CLUTTER
  g_option_context_add_group (option_context, cogl_get_option_group ());
  g_option_context_add_group (option_context, clutter_get_option_group_without_init ());
  g_option_context_add_group (option_context, gtk_clutter_get_option_group ());
#endif /* HAVE_CLUTTER */

  retval = g_option_context_parse (option_context, &argc, &argv, &error);
  g_option_context_free (option_context);

  if (!retval) {
    g_printerr ("%s\n", error->message);
    g_error_free (error);
    goto cleanup;
  }

  g_set_application_name (data.freecell ? _("FreeCell Solitaire") : _("AisleRiot"));

  aisleriot_conf_init ();

  /* If we are asked for a specific game, check that it is valid. */
  if (!data.freecell &&
      data.variation != NULL) {
    char *game_module = NULL;

    if (data.variation[0] != '\0') {
      game_module = ar_filename_to_game_module (data.variation);
    }

    g_free (data.variation);
    data.variation = game_module;
  }

  if (!data.freecell && !data.variation) {
    char *pref;

    pref = ar_conf_get_string_with_default (NULL, aisleriot_conf_get_key (CONF_VARIATION), DEFAULT_VARIATION);
    data.variation = ar_filename_to_game_module (pref);
    g_free (pref);
  }

  g_assert (data.variation != NULL || data.freecell);

  ar_stock_init ();

  gtk_window_set_default_icon_name (data.freecell ? "gnome-freecell" : "gnome-aisleriot");

  data.window = AISLERIOT_WINDOW (aisleriot_window_new (data.freecell));
  g_signal_connect (data.window, "destroy",
		    G_CALLBACK (gtk_main_quit), NULL);

  if (data.freecell) {
    aisleriot_window_set_game_module (data.window, FREECELL_VARIATION, NULL);
  } else {
    aisleriot_window_set_game_module (data.window, data.variation, NULL);
  }

  gtk_window_present (GTK_WINDOW (data.window));

  gtk_main ();

  aisleriot_conf_shutdown ();

cleanup:
  g_free (data.variation);

  g_settings_sync ();

  ar_runtime_shutdown ();
}