예제 #1
0
int
main (int argc, char **argv)
{
  GtkWidget *window;
  GtkWidget *camera;

  gst_init (&argc, &argv);

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

  if (!cheese_gtk_init (&argc, &argv))
    return EXIT_FAILURE;

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
  g_signal_connect (G_OBJECT (window), "delete-event",
                    G_CALLBACK (delete_callback), NULL);


  camera = cheese_widget_new ();
  gtk_container_add (GTK_CONTAINER (window), camera);

  gtk_widget_show_all (window);

  gtk_main ();

  return EXIT_SUCCESS;
}
예제 #2
0
int
main (int argc, char *argv[])
{
  GtkApplication *app;
  GObjectClass *app_class;
  gint retval;

  g_type_init ();

#ifdef HAVE_CHEESE
  /* Used by the avatar chooser */
  g_return_val_if_fail (cheese_gtk_init (&argc, &argv), 1);
#endif

  empathy_init ();

  g_set_application_name (_("Empathy Accounts"));

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

  app = gtk_application_new (EMPATHY_ACCOUNTS_DBUS_NAME, G_APPLICATION_FLAGS_NONE);
  app_class = G_OBJECT_GET_CLASS (app);
  G_APPLICATION_CLASS (app_class)->local_command_line = local_cmdline;
  G_APPLICATION_CLASS (app_class)->activate = app_activate;

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

  g_object_unref (app);

  return retval;
}
int
main (int argc, char *argv[])
{
  GisDriver *driver;
  int status;
  GOptionContext *context;

  GOptionEntry entries[] = {
    { "existing-user", 0, 0, G_OPTION_ARG_NONE, &force_existing_user_mode,
      _("Force existing user mode"), NULL },
    { NULL }
  };

  g_unsetenv ("GIO_USE_VFS");

  context = g_option_context_new (_("- GNOME initial setup"));
  g_option_context_add_main_entries (context, entries, NULL);

  g_option_context_parse (context, &argc, &argv, NULL);

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

#ifdef HAVE_CHEESE
  cheese_gtk_init (NULL, NULL);
#endif

  gtk_init (&argc, &argv);

#if HAVE_CLUTTER
  if (gtk_clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS) {
    g_critical ("Clutter-GTK init failed");
    exit (1);
  }
#endif

  gis_ensure_login_keyring ();

  driver = gis_driver_new (get_mode ());
  g_signal_connect (driver, "rebuild-pages", G_CALLBACK (rebuild_pages_cb), NULL);
  status = g_application_run (G_APPLICATION (driver), argc, argv);

  g_object_unref (driver);
  g_option_context_free (context);
  return status;
}
static int
cc_application_command_line (GApplication *application,
                             GApplicationCommandLine *command_line)
{
  CcApplication *self = CC_APPLICATION (application);
  int argc;
  char **argv;
  int retval = 0;
  GOptionContext *context;
  GError *error = NULL;
  GVariantBuilder *flags_builder;

  verbose = FALSE;
  show_overview = FALSE;
  show_help = FALSE;
  start_panels = NULL;

  flags_builder = g_variant_builder_new (G_VARIANT_TYPE_VARDICT);

  argv = g_application_command_line_get_arguments (command_line, &argc);

  context = g_option_context_new (N_("- Settings"));
  g_option_context_add_main_entries (context, all_options, GETTEXT_PACKAGE);
  g_option_context_set_translation_domain(context, GETTEXT_PACKAGE);
  g_option_context_add_group (context, gtk_get_option_group (TRUE));
  cc_panel_loader_add_option_groups (context, flags_builder);
  g_option_context_set_help_enabled (context, FALSE);

  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);
      return 1;
    }

  if (show_help || show_help_all || show_help_gtk)
    {
      gchar *help;
      GOptionGroup *group;

      if (show_help || show_help_all)
        group = NULL;
      else
        group = gtk_get_option_group (FALSE);

      help = g_option_context_get_help (context, FALSE, group);
      g_print ("%s", help);
      g_free (help);
      g_option_context_free (context);
      return 0;
    }

  if (list_panels)
    {
      GList *panels, *l;

      panels = cc_panel_loader_get_panels ();

      g_print ("%s\n", _("Available panels:"));
      for (l = panels; l != NULL; l = l->next)
        g_print ("\t%s\n", (char *) l->data);

      g_list_free (panels);

      return 0;
    }

#ifdef HAVE_CHEESE
  cheese_gtk_init (&argc, &argv);
#endif /* HAVE_CHEESE */

  cc_shell_log_set_debug (verbose);

  cc_window_show (self->priv->window);

  if (search_str)
    {
      cc_window_set_search_item (self->priv->window, search_str);
    }
  else if (show_overview)
    {
      cc_window_set_overview_page (self->priv->window);
    }
  else if (start_panels != NULL && start_panels[0] != NULL)
    {
      const char *start_id;
      GError *err = NULL;
      GVariant *parameters;
      GVariantBuilder *builder;
      int i;

      start_id = start_panels[0];

      if (start_panels[1])
        g_debug ("Extra argument: %s", start_panels[1]);
      else
        g_debug ("No extra argument");

      builder = g_variant_builder_new (G_VARIANT_TYPE ("av"));
      g_variant_builder_add (builder, "v", g_variant_builder_end (flags_builder));

      for (i = 1; start_panels[i] != NULL; i++)
        g_variant_builder_add (builder, "v", g_variant_new_string (start_panels[i]));
      parameters = g_variant_builder_end (builder);
      if (!cc_shell_set_active_panel_from_id (CC_SHELL (self->priv->window), start_id, parameters, &err))
        {
          g_warning ("Could not load setting panel \"%s\": %s", start_id,
                     (err) ? err->message : "Unknown error");
          retval = 1;
          if (err)
            {
              g_error_free (err);
              err = NULL;
            }
        }
    }

  if (start_panels != NULL)
    {
      g_strfreev (start_panels);
      start_panels = NULL;
    }

  show_overview = FALSE;

  g_option_context_free (context);
  g_strfreev (argv);

  return retval;
}