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;
}
Пример #2
0
int
main (int argc, char ** argv)
{
  GtkApplication *app;
  int status, clutter_status;

  gtk_init (&argc, &argv);
  clutter_status = gtk_clutter_init (&argc, &argv);

  app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
  g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
  status =\
      g_application_run (G_APPLICATION (app), argc, argv) && clutter_status;
  g_object_unref (app);

  return status;
}
static void
gt_player_backend_gstreamer_clutter_class_init(GtPlayerBackendGstreamerClutterClass* klass)
{
    GObjectClass* obj_class = G_OBJECT_CLASS(klass);
    static gboolean init = FALSE;

    obj_class->finalize = finalise;
    obj_class->get_property = get_property;
    obj_class->set_property = set_property;

    props[PROP_VOLUME] = g_param_spec_double("volume",
                                             "Volume",
                                             "Volume of player",
                                             0.0, 1.0, 0.3,
                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
    props[PROP_PLAYING] = g_param_spec_boolean("playing",
                                               "Playing",
                                               "Whether playing",
                                               FALSE,
                                               G_PARAM_READABLE | G_PARAM_CONSTRUCT);
    props[PROP_URI] = g_param_spec_string("uri",
                                          "Uri",
                                          "Current uri",
                                          "",
                                          G_PARAM_READWRITE);
    props[PROP_BUFFER_FILL] = g_param_spec_double("buffer-fill",
                                                     "Buffer fill",
                                                     "Current buffer fill",
                                                     0, 1.0, 0,
                                                     G_PARAM_READWRITE | G_PARAM_CONSTRUCT);

    g_object_class_override_property(obj_class, PROP_VOLUME, "volume");
    g_object_class_override_property(obj_class, PROP_PLAYING, "playing");
    g_object_class_override_property(obj_class, PROP_URI, "uri");
    g_object_class_override_property(obj_class, PROP_BUFFER_FILL, "buffer-fill");

    if (!init)
    {
        gint res = gtk_clutter_init(NULL, NULL);
        clutter_gst_init(NULL, NULL);
        init = TRUE;
    }
}
Пример #4
0
/**
 * cheese_gtk_init:
 * @argc: pointer to the argument list count
 * @argv: pointer to the argument list vector
 *
 * Initialize libcheese-gtk, by initializing Clutter, GStreamer and GTK+. This
 * automatically calls cheese_init(), initializing libcheese.
 *
 * Returns: %TRUE if the initialization was successful, %FALSE otherwise
 */
gboolean
cheese_gtk_init (int *argc, char ***argv)
{
    ClutterInitError error;

#ifdef GDK_WINDOWING_X11
    XInitThreads ();
#endif

    error = gtk_clutter_init (argc, argv);

    if (error != CLUTTER_INIT_SUCCESS)
        return FALSE;

    if (!cheese_init (argc, argv))
        return FALSE;

    return TRUE;
}
Пример #5
0
int main(int argc, char **argv){
	GtkWidget *window;


	gtk_init(&argc, &argv);

	if (gtk_clutter_init(&argc, &argv)){

		window = main_window();

		gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
		gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);
		gtk_widget_set_app_paintable(window, TRUE);

		gtk_widget_show_all(window);
		test_clutter();
		gtk_main();
	}
	return (0);
}
Пример #6
0
int
main (int    argc,
      char **argv)
{
  MpdPowerIcon *icon;

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

  gtk_clutter_init (&argc, &argv);
  notify_init (_("Dawati Power Icon"));

  icon = mpd_power_icon_new ();

  clutter_main ();

  g_object_unref (icon);

  return EXIT_SUCCESS;
}
Пример #7
0
bool
videooutput_clutter_gst_init (Ekiga::ServiceCore &core,
                              G_GNUC_UNUSED int *argc,
                              G_GNUC_UNUSED char **argv[])
{
    bool result = false;
    boost::shared_ptr<Ekiga::VideoOutputCore> videooutput_core =
        core.get<Ekiga::VideoOutputCore> ("videooutput-core");

    if (videooutput_core) {

        gst_init (argc, argv);
        if (gtk_clutter_init (argc, argv) != CLUTTER_INIT_SUCCESS)
            return false;

        GMVideoOutputManager_clutter_gst *videooutput_manager =
            new GMVideoOutputManager_clutter_gst (core);

        videooutput_core->add_manager (*videooutput_manager);
        result = true;
    }

    return result;
}
Пример #8
0
static void
eog_map_plugin_init (EogMapPlugin *plugin)
{
	eog_debug_message (DEBUG_PLUGINS, "EogMapPlugin initializing");
	gtk_clutter_init (NULL, NULL);
}
Пример #9
0
int
main (int argc, char **argv)
{
  GOptionContext *context;
  gboolean retval;
  GError *error = NULL;

  if (!games_runtime_init ("gnibbles"))
    return 1;

#ifdef ENABLE_SETGID
  setgid_io_init ();
#endif

  gtk_clutter_init (&argc, &argv);
  context = g_option_context_new (NULL);

#if GLIB_CHECK_VERSION (2, 12, 0)
  g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
#endif

  g_option_context_add_group (context, gtk_get_option_group (TRUE));

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

  g_set_application_name (_("Nibbles"));

  gtk_window_set_default_icon_name ("mate-gnibbles");
  srand (time (NULL));

  highscores = games_scores_new ("gnibbles",
                                 scorecats, G_N_ELEMENTS (scorecats),
                                 "game speed", NULL,
                                 0 /* default category */,
                                 GAMES_SCORES_STYLE_PLAIN_DESCENDING);

  games_conf_initialise ("Gnibbles");
  properties = gnibbles_properties_new ();
  setup_window ();
  gnibbles_load_pixmap (properties->tilesize);
  gnibbles_load_logo (properties->tilesize);

#ifdef GGZ_CLIENT
  network_init ();
  network_gui_update ();
#endif

  gtk_action_set_sensitive (pause_action, FALSE);
  gtk_action_set_sensitive (resume_action, FALSE);
  gtk_action_set_sensitive (end_game_action, FALSE);
  gtk_action_set_visible (resume_action, paused);
  gtk_action_set_visible (new_game_action, !ggz_network_mode);
  gtk_action_set_visible (player_list_action, ggz_network_mode);

  gtk_main ();

  gnibbles_properties_destroy (properties);
  games_conf_shutdown ();

  games_runtime_shutdown ();

  return 0;
}
Пример #10
0
int
main (int argc, char *argv[])
{
#if HAVE_GEOCLUE
  EmpathyLocationManager *location_manager = NULL;
#endif
  EmpathyStatusIcon *icon;
  EmpathyDispatcher *dispatcher;
  TpAccountManager *account_manager;
  EmpathyLogManager *log_manager;
  EmpathyChatroomManager *chatroom_manager;
  EmpathyCallFactory *call_factory;
  EmpathyFTFactory  *ft_factory;
  GtkWidget *window;
  EmpathyIdle *idle;
  EmpathyConnectivity *connectivity;
  GError *error = NULL;
  TpDBusDaemon *dbus_daemon;
  UniqueApp *unique_app;
  gboolean chatroom_manager_ready;

  GOptionContext *optcontext;
  GOptionEntry options[] = {
      { "no-connect", 'n',
        0, G_OPTION_ARG_NONE, &no_connect,
        N_("Don't connect on startup"),
        NULL },
      { "start-hidden", 'h',
        0, G_OPTION_ARG_NONE, &start_hidden,
        N_("Don't display the contact list or any other dialogs on startup"),
        NULL },
      { "accounts", 'a',
        0, G_OPTION_ARG_NONE, &account_dialog_only,
        N_("Show the accounts dialog"),
        NULL },
      { "version", 'v',
        G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, show_version_cb,
        NULL, NULL },
      { NULL }
  };

  /* Init */
  g_thread_init (NULL);
  empathy_init ();

  optcontext = g_option_context_new (N_("- Empathy IM 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 init: %s", error->message);
    return EXIT_FAILURE;
  }

  g_option_context_free (optcontext);

  empathy_gtk_init ();
  g_set_application_name (_(PACKAGE_NAME));
  g_setenv ("PULSE_PROP_media.role", "phone", TRUE);

#if HAVE_LIBCHAMPLAIN
  gtk_clutter_init (&argc, &argv);
#endif

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

#ifdef ENABLE_DEBUG
  /* Set up debugger */
  g_log_set_default_handler (default_log_handler, NULL);
#endif

  unique_app = unique_app_new_with_commands ("org.gnome.Empathy",
      NULL, "accounts_dialog", COMMAND_ACCOUNTS_DIALOG, NULL);

  if (unique_app_is_running (unique_app))
    {
      unique_app_send_message (unique_app, account_dialog_only ?
          COMMAND_ACCOUNTS_DIALOG : UNIQUE_ACTIVATE, NULL);

      g_object_unref (unique_app);
      return EXIT_SUCCESS;
    }

  /* Take well-known name */
  dbus_daemon = tp_dbus_daemon_dup (&error);
  if (error == NULL)
    {
      if (!tp_dbus_daemon_request_name (dbus_daemon,
          "org.gnome.Empathy", TRUE, &error))
        {
          DEBUG ("Failed to request well-known name: %s",
                 error ? error->message : "no message");
          g_clear_error (&error);
        }
      g_object_unref (dbus_daemon);
    }
  else
    {
      DEBUG ("Failed to dup dbus daemon: %s",
             error ? error->message : "no message");
      g_clear_error (&error);
    }

  if (account_dialog_only)
    {
      account_manager = tp_account_manager_dup ();
      show_accounts_ui (NULL, TRUE);

      gtk_main ();

      g_object_unref (account_manager);
      return 0;
    }

  notify_init (_(PACKAGE_NAME));

  /* Setting up Idle */
  idle = empathy_idle_dup_singleton ();
  empathy_idle_set_auto_away (idle, TRUE);

  /* Setting up Connectivity */
  connectivity = empathy_connectivity_dup_singleton ();
  use_conn_notify_cb (empathy_conf_get (), EMPATHY_PREFS_USE_CONN,
      connectivity);
  empathy_conf_notify_add (empathy_conf_get (), EMPATHY_PREFS_USE_CONN,
      use_conn_notify_cb, connectivity);

  /* account management */
  account_manager = tp_account_manager_dup ();
  tp_account_manager_prepare_async (account_manager, NULL,
      account_manager_ready_cb, NULL);

  /* Handle channels */
  dispatcher = setup_dispatcher ();
  g_signal_connect (dispatcher, "dispatch", G_CALLBACK (dispatch_cb), NULL);

  migrate_config_to_xdg_dir ();

  /* Setting up UI */
  window = empathy_main_window_show ();
  icon = empathy_status_icon_new (GTK_WINDOW (window), start_hidden);

  g_signal_connect (unique_app, "message-received",
      G_CALLBACK (unique_app_message_cb), window);

  /* Logging */
  log_manager = empathy_log_manager_dup_singleton ();
  empathy_log_manager_observe (log_manager, dispatcher);

  chatroom_manager = empathy_chatroom_manager_dup_singleton (NULL);
  empathy_chatroom_manager_observe (chatroom_manager, dispatcher);

  g_object_get (chatroom_manager, "ready", &chatroom_manager_ready, NULL);
  if (!chatroom_manager_ready)
    {
      g_signal_connect (G_OBJECT (chatroom_manager), "notify::ready",
          G_CALLBACK (chatroom_manager_ready_cb), account_manager);
    }
  else
    {
      chatroom_manager_ready_cb (chatroom_manager, NULL, account_manager);
    }

  /* Create the call factory */
  call_factory = empathy_call_factory_initialise ();
  g_signal_connect (G_OBJECT (call_factory), "new-call-handler",
      G_CALLBACK (new_call_handler_cb), NULL);
  /* Create the FT factory */
  ft_factory = empathy_ft_factory_dup_singleton ();
  g_signal_connect (ft_factory, "new-ft-handler",
      G_CALLBACK (new_ft_handler_cb), NULL);
  g_signal_connect (ft_factory, "new-incoming-transfer",
      G_CALLBACK (new_incoming_transfer_cb), NULL);

  /* Location mananger */
#if HAVE_GEOCLUE
  location_manager = empathy_location_manager_dup_singleton ();
#endif

  gtk_main ();

  empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_OFFLINE);

  g_object_unref (idle);
  g_object_unref (connectivity);
  g_object_unref (icon);
  g_object_unref (account_manager);
  g_object_unref (log_manager);
  g_object_unref (dispatcher);
  g_object_unref (chatroom_manager);
#if HAVE_GEOCLUE
  g_object_unref (location_manager);
#endif
  g_object_unref (ft_factory);
  g_object_unref (unique_app);

  notify_uninit ();

  return EXIT_SUCCESS;
}
Пример #11
0
int AP_UnixApp::main(const char * szAppName, int argc, char ** argv)
{
    // This is a static function.	
	
	if (!g_thread_supported ())
		g_thread_init (NULL);	
    
    // initialize our application.
	int exit_status = 0;
	AP_UnixApp * pMyUnixApp = new AP_UnixApp(szAppName);

#ifdef WITH_CHAMPLAIN
    gtk_clutter_init (&argc, &argv);
#endif
    
	/* this brace is here to ensure that our local variables on the stack
	 * do not outlive the application object by giving them a lower scope
	 */
	{
		XAP_Args XArgs = XAP_Args(argc, argv);
		AP_Args Args = AP_Args(&XArgs, szAppName, pMyUnixApp);
#ifdef LOGFILE
		UT_String sLogFile = pMyUnixApp->getUserPrivateDirectory();
		sLogFile += "abiLogFile";
		logfile = fopen(sLogFile.c_str(),"a+");
		fprintf(logfile,"About to do gtk_set_locale \n");
		fprintf(logfile,"New logfile \n");
#endif
		// Step 1: Initialize GTK and create the APP.
		// hack needed to intialize gtk before ::initialize
		setlocale(LC_ALL, "");
		gboolean have_display = gtk_init_check(&argc, &argv);
#ifdef LOGFILE
		fprintf(logfile,"Got display %d \n",have_display);
		fprintf(logfile,"Really display %d \n",have_display);
#endif
		if (have_display > 0) {
			Args.addOptions(gtk_get_option_group(TRUE));
			Args.parseOptions();
		}
		else {
			// no display, but we still need to at least parse our own arguments, damnit, for --to, --to-png, and --print
			Args.addOptions(gtk_get_option_group(FALSE));
			Args.parseOptions();
		}

		// if the initialize fails, we don't have icons, fonts, etc.
		if (!pMyUnixApp->initialize(have_display))
		{
			delete pMyUnixApp;
			return -1;	// make this something standard?
		}
	
		// Setup signal handlers, primarily for segfault
		// If we segfaulted before here, we *really* blew it
		struct sigaction sa;
		sa.sa_handler = signalWrapper;
    
		sigfillset(&sa.sa_mask);  // We don't want to hear about other signals
		sigdelset(&sa.sa_mask, SIGABRT); // But we will call abort(), so we can't ignore that
#if defined (SA_NODEFER) && defined (SA_RESETHAND)
		sa.sa_flags = SA_NODEFER | SA_RESETHAND; // Don't handle nested signals
#else
		sa.sa_flags = 0;
#endif
    
		sigaction(SIGSEGV, &sa, NULL);
		sigaction(SIGBUS, &sa, NULL);
		sigaction(SIGILL, &sa, NULL);
		sigaction(SIGQUIT, &sa, NULL);
		sigaction(SIGFPE, &sa, NULL);

		// TODO: handle SIGABRT
	
		// Step 2: Handle all non-window args.
    
		bool windowlessArgsWereSuccessful = true;
		if (!Args.doWindowlessArgs(windowlessArgsWereSuccessful )) {
			delete pMyUnixApp;
			return (windowlessArgsWereSuccessful ? 0 : -1);
		}

		if (have_display) {

			// Step 3: Create windows as appropriate.
			// if some args are botched, it returns false and we should
			// continue out the door.
			// We used to check for bShowApp here.  It shouldn't be needed
			// anymore, because doWindowlessArgs was supposed to bail already. -PL

			if (pMyUnixApp->openCmdLineFiles(&Args))
			{
#if defined(EMBEDDED_TARGET) && EMBEDDED_TARGET == EMBEDDED_TARGET_HILDON
				s_bInitDone = true;
				pMyUnixApp->processStartupQueue();
#endif
				// turn over control to gtk
				gtk_main();
			}
			else
			{
				UT_DEBUGMSG(("DOM: not parsing command line or showing app\n"));
			}
		}
		else {
			fprintf(stderr, "No DISPLAY: this may not be what you want.\n");
			exit_status = 1;
		}
		// unload all loaded plugins (remove some of the memory leaks shown at shutdown :-)
		XAP_ModuleManager::instance().unloadAllPlugins();

		// Step 4: Destroy the App.  It should take care of deleting all frames.
		pMyUnixApp->shutdown();
	}
	
	delete pMyUnixApp;
	
	return exit_status;
}
Пример #12
0
int
main (int argc, char *argv[])
{
  ClutterTimeline *timeline;
  ClutterActor *stage;
  GtkWidget *window, *stack, *clutter;
  GtkWidget *label, *button, *vbox;
  GdkPixbuf *pixbuf;
  SuperOH *oh;
  gint i;
  GError *error;

  error = NULL;
  if (gtk_clutter_init_with_args (&argc, &argv,
                                  NULL,
                                  NULL,
                                  NULL,
                                  &error) != CLUTTER_INIT_SUCCESS)
    {
      if (error)
        {
          g_critical ("Unable to initialize Clutter-GTK: %s", error->message);
          g_error_free (error);
          return EXIT_FAILURE;
        }
      else
        g_error ("Unable to initialize Clutter-GTK");
    }

  /* calling gtk_clutter_init* multiple times should be safe */
  g_assert (gtk_clutter_init (NULL, NULL) == CLUTTER_INIT_SUCCESS);

  pixbuf = gdk_pixbuf_new_from_file (EXAMPLES_DATADIR G_DIR_SEPARATOR_S "redhand.png", NULL);

  if (!pixbuf)
    g_error("pixbuf load failed");

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), WINWIDTH, WINHEIGHT);
  gtk_window_set_title (GTK_WINDOW (window), "Clutter Embedding");
  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

  vbox = gtk_grid_new ();
  gtk_orientable_set_orientation (GTK_ORIENTABLE (vbox), GTK_ORIENTATION_VERTICAL);
  gtk_widget_set_hexpand (vbox, TRUE);
  gtk_widget_set_vexpand (vbox, TRUE);
  gtk_container_add (GTK_CONTAINER (window), vbox);

  stack = gtk_stack_new ();
  gtk_container_add (GTK_CONTAINER (vbox), stack);

  label = gtk_label_new ("This is a label in a stack");
  gtk_stack_add_named (GTK_STACK (stack), label, "label");

  clutter = gtk_clutter_embed_new ();
  gtk_stack_add_named (GTK_STACK (stack), clutter, "clutter");
  gtk_widget_realize (clutter);

  stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter));
  clutter_actor_set_background_color (stage, CLUTTER_COLOR_LightSkyBlue);

  label = gtk_label_new ("This is a label");
  gtk_container_add (GTK_CONTAINER (vbox), label);
  gtk_widget_set_hexpand (label, TRUE);

  button = gtk_button_new_with_label ("This is a button...clicky");
  g_signal_connect (button, "clicked", G_CALLBACK (clickity), stack);
  gtk_container_add (GTK_CONTAINER (vbox), button);
  gtk_widget_set_hexpand (button, TRUE);

  button = gtk_button_new_with_mnemonic ("_Fullscreen");
  g_signal_connect (button, "clicked",
                    G_CALLBACK (on_fullscreen),
                    window);
  gtk_container_add (GTK_CONTAINER (vbox), button);
  gtk_widget_set_hexpand (button, TRUE);

  button = gtk_button_new_with_mnemonic ("_Quit");
  g_signal_connect_swapped (button, "clicked",
                            G_CALLBACK (gtk_widget_destroy),
                            window);
  gtk_container_add (GTK_CONTAINER (vbox), button);
  gtk_widget_set_hexpand (button, TRUE);

  oh = g_new (SuperOH, 1);
  oh->stage = stage;

  oh->group = clutter_actor_new ();
  clutter_actor_set_pivot_point (oh->group, 0.5, 0.5);
  
  for (i = 0; i < NHANDS; i++)
    {
      gint x, y, w, h;

      /* Create a texture from pixbuf, then clone in to same resources */
      if (i == 0)
        {
          oh->hand[i] = gtk_clutter_texture_new ();
          gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (oh->hand[i]), pixbuf, NULL);
        }
      else
        oh->hand[i] = clutter_clone_new (oh->hand[0]);

      /* Place around a circle */
      w = clutter_actor_get_width (oh->hand[0]);
      h = clutter_actor_get_height (oh->hand[0]);

      x = WINWIDTH / 2  + RADIUS * cos (i * M_PI / (NHANDS / 2)) - w / 2;
      y = WINHEIGHT / 2 + RADIUS * sin (i * M_PI / (NHANDS / 2)) - h / 2;

      clutter_actor_set_position (oh->hand[i], x, y);
      clutter_actor_set_pivot_point (oh->hand[i], 0.5, 0.5);

      /* Add to our group group */
      clutter_actor_add_child (oh->group, oh->hand[i]);
    }

  /* Add the group to the stage */
  clutter_actor_add_child (stage, oh->group);

  clutter_actor_add_constraint (oh->group, clutter_align_constraint_new (oh->stage, CLUTTER_ALIGN_BOTH, 0.5));

  g_signal_connect (stage, "button-press-event",
		    G_CALLBACK (input_cb), 
		    oh);
  g_signal_connect (stage, "key-release-event",
		    G_CALLBACK (input_cb),
		    oh);

  gtk_widget_show_all (window);

  /* Create a timeline to manage animation */
  timeline = clutter_timeline_new (6000);
  clutter_timeline_set_repeat_count (timeline, -1);

  /* fire a callback for frame change */
  g_signal_connect (timeline, "new-frame",  G_CALLBACK (frame_cb), oh);

  /* and start it */
  clutter_timeline_start (timeline);

  gtk_main ();

  return 0;
}
Пример #13
0
int main(int argc, char *argv[])
{
  ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff };

  /* Call gtk_clutter_init() to init both clutter and gtk+ */
  if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
    g_error ("Unable to initialize GtkClutter");

  if (argc != 2)
    g_error ("Usage: example <image file>");
  
  /* Create a toplevel window: */
  GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

  /* Create a table to hold the scrollbars and the ClutterEmbed widget: */
  GtkWidget *table = gtk_table_new (2, 2, FALSE);
  gtk_container_add (GTK_CONTAINER (window), table);
  gtk_widget_show (table);

  /* Create ClutterEmbed widget for the stage: */
  GtkWidget *embed = gtk_clutter_embed_new ();
  gtk_table_attach (GTK_TABLE (table), embed,
    0, 1,
    0, 1,
    GTK_EXPAND | GTK_FILL,
    GTK_EXPAND | GTK_FILL,
    0, 0);
  gtk_widget_show (embed);

  /* Init the stage: */
  ClutterActor *stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (embed));
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
  clutter_actor_set_size (stage, 640, 480);

  /* Create a viewport actor to be able to scroll actor. By passing NULL it
   * will create new GtkAdjustments. */
  ClutterActor *viewport = gtk_clutter_viewport_new (NULL, NULL, NULL);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), viewport);

  /* Load image from first command line argument and add it to viewport: */
  ClutterActor *texture = clutter_texture_new_from_file (argv[1], NULL);
  clutter_container_add_actor (CLUTTER_CONTAINER (viewport), texture);
  clutter_actor_set_position (texture, 0, 0);
  clutter_actor_set_position (texture, 0, 0);
  clutter_actor_set_position (viewport, 0, 0);
  clutter_actor_set_size (viewport, 640, 480);

  /* Create scrollbars and connect them to viewport: */
  GtkAdjustment *h_adjustment = NULL;
  GtkAdjustment *v_adjustment = NULL;
  gtk_clutter_scrollable_get_adjustments (GTK_CLUTTER_SCROLLABLE (viewport),
    &h_adjustment, &v_adjustment);
  GtkWidget *scrollbar = gtk_vscrollbar_new (v_adjustment);
  gtk_table_attach (GTK_TABLE (table), scrollbar,
    1, 2,
    0, 1,
    0, GTK_EXPAND | GTK_FILL,
    0, 0);
  gtk_widget_show (scrollbar);
  
  scrollbar = gtk_hscrollbar_new (h_adjustment);
  gtk_table_attach (GTK_TABLE (table), scrollbar,
    0, 1,
    1, 2,
    GTK_EXPAND | GTK_FILL, 0,
    0, 0);

  gtk_widget_show (scrollbar);
  gtk_widget_show (window);

  gtk_main();

	return EXIT_SUCCESS;
}
int
main (int argc,
    char *argv[])
{
  GtkWidget *window;
  GtkWidget *widget, *vbox, *bbox, *button, *viewport, *image;
  ChamplainView *view;
  ChamplainMarkerLayer *layer;
  ClutterActor *scale;
  ChamplainLicense *license_actor;

  if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
    return 1;

  /* create the main, top level, window */
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  /* give the window a 10px wide border */
  gtk_container_set_border_width (GTK_CONTAINER (window), 10);

  /* give it the title */
  gtk_window_set_title (GTK_WINDOW (window), "libchamplain Gtk+ demo");

  /* Connect the destroy event of the window with our on_destroy function
   * When the window is about to be destroyed we get a notificaiton and
   * stop the main GTK loop
   */
  g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (on_destroy),
      NULL);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);

  widget = gtk_champlain_embed_new ();
  view = gtk_champlain_embed_get_view (GTK_CHAMPLAIN_EMBED (widget));
  clutter_actor_set_reactive (CLUTTER_ACTOR (view), TRUE);
  g_signal_connect (view, "button-release-event", G_CALLBACK (mouse_click_cb), view);


  g_object_set (G_OBJECT (view),
      "kinetic-mode", TRUE,
      "zoom-level", 5,
      NULL);

  g_object_set_data (G_OBJECT (view), "window", window);
      
  scale = champlain_scale_new ();
  champlain_scale_connect_view (CHAMPLAIN_SCALE (scale), view);
  
  /* align to the bottom left */
  clutter_actor_set_x_expand (scale, TRUE);
  clutter_actor_set_y_expand (scale, TRUE);
  clutter_actor_set_x_align (scale, CLUTTER_ACTOR_ALIGN_START);
  clutter_actor_set_y_align (scale, CLUTTER_ACTOR_ALIGN_END);
  clutter_actor_add_child (CLUTTER_ACTOR (view), scale);
  
  license_actor = champlain_view_get_license_actor (view);
  champlain_license_set_extra_text (license_actor, "Don't eat cereals with orange juice\nIt tastes bad");
  
  champlain_view_center_on (CHAMPLAIN_VIEW (view), 45.466, -73.75);

  layer = create_marker_layer (view, &path);
  champlain_view_add_layer (view, CHAMPLAIN_LAYER (path));
  champlain_view_add_layer (view, CHAMPLAIN_LAYER (layer));
  
  path_layer = champlain_path_layer_new ();
  /* Cheap approx of Highway 10 */
  append_point (path_layer, 45.4095, -73.3197);
  append_point (path_layer, 45.4104, -73.2846);
  append_point (path_layer, 45.4178, -73.2239);
  append_point (path_layer, 45.4176, -73.2181);
  append_point (path_layer, 45.4151, -73.2126);
  append_point (path_layer, 45.4016, -73.1926);
  append_point (path_layer, 45.3994, -73.1877);
  append_point (path_layer, 45.4000, -73.1815);
  append_point (path_layer, 45.4151, -73.1218);
  champlain_view_add_layer (view, CHAMPLAIN_LAYER (path_layer));

  gtk_widget_set_size_request (widget, 640, 481);

  bbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
  button = gtk_button_new ();
  image = gtk_image_new_from_icon_name ("zoom-in", GTK_ICON_SIZE_BUTTON);
  gtk_button_set_image (GTK_BUTTON (button), image);
  gtk_button_set_label (GTK_BUTTON (button), "Zoom In");
  g_signal_connect (button, "clicked", G_CALLBACK (zoom_in), view);
  gtk_container_add (GTK_CONTAINER (bbox), button);

  button = gtk_button_new ();
  image = gtk_image_new_from_icon_name ("zoom-out", GTK_ICON_SIZE_BUTTON);
  gtk_button_set_image (GTK_BUTTON (button), image);
  gtk_button_set_label (GTK_BUTTON (button), "Zoom Out");
  g_signal_connect (button, "clicked", G_CALLBACK (zoom_out), view);
  gtk_container_add (GTK_CONTAINER (bbox), button);

  button = gtk_toggle_button_new_with_label ("Markers");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
  g_signal_connect (button, "toggled", G_CALLBACK (toggle_layer), layer);
  gtk_container_add (GTK_CONTAINER (bbox), button);

  button = gtk_toggle_button_new_with_label ("Toggle wrap");
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
                                champlain_view_get_horizontal_wrap (view));
  g_signal_connect (button, "toggled", G_CALLBACK (toggle_wrap), view);
  gtk_container_add (GTK_CONTAINER (bbox), button);

  button = gtk_combo_box_new ();
  build_combo_box (GTK_COMBO_BOX (button));
  gtk_combo_box_set_active (GTK_COMBO_BOX (button), 0);
  g_signal_connect (button, "changed", G_CALLBACK (map_source_changed), view);
  gtk_container_add (GTK_CONTAINER (bbox), button);

  button = gtk_spin_button_new_with_range (0, 20, 1);
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (button),
      champlain_view_get_zoom_level (view));
  g_signal_connect (button, "changed", G_CALLBACK (zoom_changed), view);
  g_signal_connect (view, "notify::zoom-level", G_CALLBACK (map_zoom_changed),
      button);
  gtk_container_add (GTK_CONTAINER (bbox), button);

  button = gtk_button_new ();
  image = gtk_image_new_from_icon_name ("list-add", GTK_ICON_SIZE_BUTTON);
  gtk_button_set_image (GTK_BUTTON (button), image);
  g_signal_connect (button, "clicked", G_CALLBACK (add_clicked), view);
  gtk_container_add (GTK_CONTAINER (bbox), button);

  button = gtk_button_new ();
  image = gtk_image_new_from_icon_name ("camera-photo-symbolic", GTK_ICON_SIZE_BUTTON);
  gtk_button_set_image (GTK_BUTTON (button), image);
  g_signal_connect (button, "clicked", G_CALLBACK (export_png), view);
  gtk_container_add (GTK_CONTAINER (bbox), button);

  button = gtk_image_new ();
  gtk_widget_set_size_request (button, 22, -1);
  g_signal_connect (view, "notify::state", G_CALLBACK (view_state_changed),
      button);
  gtk_box_pack_end (GTK_BOX (bbox), button, FALSE, FALSE, 0);

  viewport = gtk_frame_new (NULL);
  gtk_container_add (GTK_CONTAINER (viewport), widget);

  gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0);
  gtk_container_add (GTK_CONTAINER (vbox), viewport);

  /* and insert it into the main window  */
  gtk_container_add (GTK_CONTAINER (window), vbox);

  /* make sure that everything, window and label, are visible */
  gtk_widget_show_all (window);
  /* start the main loop */
  gtk_main ();

  return 0;
}
int
main (int argc, char *argv[])
{
  ClutterActor *stage0, *stage1, *stage2, *tex1, *tex2;
  GtkWidget *window, *clutter0, *clutter1, *clutter2;
  GtkWidget *notebook, *vbox;
  ClutterColor col0 = { 0xdd, 0xff, 0xdd, 0xff };
  ClutterColor col1 = { 0xff, 0xff, 0xff, 0xff };
  ClutterColor col2 = {    0,    0,    0, 0xff };

  if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
    g_error ("Unable to initialize GtkClutter");

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (window, "destroy",
                    G_CALLBACK (gtk_main_quit), NULL);

  notebook = gtk_notebook_new ();
  gtk_container_add (GTK_CONTAINER (window), notebook);

  clutter0 = gtk_clutter_embed_new ();
  gtk_widget_set_size_request (clutter0, 320, 320);
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), clutter0,
                            gtk_label_new ("One stage"));
  stage0 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter0));
  clutter_stage_set_color (CLUTTER_STAGE (stage0), &col0);

  vbox = gtk_vbox_new (FALSE, 6);
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox,
                            gtk_label_new ("Two stages"));

  clutter1 = gtk_clutter_embed_new ();
  gtk_widget_set_size_request (clutter1, 320, 240);
  stage1 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter1));
  clutter_stage_set_color (CLUTTER_STAGE(stage1), &col1);
  tex1 = gtk_clutter_texture_new ();
  gtk_clutter_texture_set_from_stock (GTK_CLUTTER_TEXTURE (tex1),
                                      clutter1,
                                      GTK_STOCK_DIALOG_INFO,
                                      GTK_ICON_SIZE_DIALOG,
                                      NULL);
  clutter_actor_set_anchor_point (tex1,
                                  clutter_actor_get_width (tex1) / 2,
                                  clutter_actor_get_height (tex1) / 2);
  clutter_actor_set_position (tex1, 160, 120);
  clutter_stage_add (stage1, tex1); 
  clutter_actor_show (tex1);

  gtk_container_add (GTK_CONTAINER (vbox), clutter1);

  clutter2 = gtk_clutter_embed_new ();
  gtk_widget_set_size_request (clutter2, 320, 120);
  stage2 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter2));
  clutter_stage_set_color (CLUTTER_STAGE(stage2), &col2);
  tex2 = gtk_clutter_texture_new ();
  gtk_clutter_texture_set_from_icon_name (GTK_CLUTTER_TEXTURE (tex2),
                                          clutter1,
                                          "user-info",
                                          GTK_ICON_SIZE_BUTTON,
                                          NULL);
  clutter_actor_set_anchor_point (tex2,
                                  clutter_actor_get_width (tex2) / 2,
                                  clutter_actor_get_height (tex2) / 2);
  clutter_actor_set_position (tex2, 160, 60);
  clutter_stage_add (stage2, tex2);

  gtk_container_add (GTK_CONTAINER (vbox), clutter2);

  g_signal_connect (stage2, "allocation-changed",
                    G_CALLBACK (on_stage2_allocation_changed),
                    tex2);

  gtk_widget_show_all (window);

  gtk_main();

  return 0;
}
int
main (int argc, char *argv[])
{
  ClutterActor *stage0, *stage1, *stage2, *tex1, *tex2;
  GtkWidget *window, *clutter0, *clutter1, *clutter2;
  GtkWidget *notebook, *vbox;
  ClutterColor col0 = { 0xdd, 0xff, 0xdd, 0xff };
  ClutterColor col1 = { 0xff, 0xff, 0xff, 0xff };
  ClutterColor col2 = {    0,    0,    0, 0xff };

  if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
    g_error ("Unable to initialize GtkClutter");

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
  gtk_window_set_title (GTK_WINDOW (window), "Multiple GtkClutterEmbed");
  g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

  notebook = gtk_notebook_new ();
  gtk_container_add (GTK_CONTAINER (window), notebook);

  clutter0 = gtk_clutter_embed_new ();
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), clutter0,
                            gtk_label_new ("One stage"));
  stage0 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter0));
  clutter_actor_set_background_color (stage0, &col0);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox,
                            gtk_label_new ("Two stages"));

  clutter1 = gtk_clutter_embed_new ();
  gtk_widget_set_size_request (clutter1, 320, 240);
  stage1 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter1));
  clutter_actor_set_background_color (stage1, &col1);
  tex1 = gtk_clutter_texture_new ();
  gtk_clutter_texture_set_from_icon_name (GTK_CLUTTER_TEXTURE (tex1),
                                          clutter1,
                                          "dialog-information",
                                          GTK_ICON_SIZE_DIALOG,
                                          NULL);
  clutter_actor_set_position (tex1,
                              160 - clutter_actor_get_width (tex1) / 2.0,
                              120 - clutter_actor_get_height (tex1) / 2.0);
  clutter_actor_add_child (stage1, tex1); 
  clutter_actor_show (tex1);

  gtk_container_add (GTK_CONTAINER (vbox), clutter1);

  clutter2 = gtk_clutter_embed_new ();
  gtk_widget_set_size_request (clutter2, 320, 120);
  stage2 = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (clutter2));
  clutter_actor_set_background_color (stage2, &col2);
  tex2 = gtk_clutter_texture_new ();
  gtk_clutter_texture_set_from_icon_name (GTK_CLUTTER_TEXTURE (tex2),
                                          clutter1,
                                          "user-info",
                                          GTK_ICON_SIZE_BUTTON,
                                          NULL);
  clutter_actor_add_constraint (tex2, clutter_align_constraint_new (stage2, CLUTTER_ALIGN_BOTH, .5));
  clutter_actor_add_child (stage2, tex2);

  gtk_container_add (GTK_CONTAINER (vbox), clutter2);

  gtk_widget_show_all (window);

  gtk_main();

  return 0;
}
Пример #17
0
int
main (int argc, char *argv[])
{
    GOptionContext *ctx;
    GError *error = NULL;

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

#ifdef G_THREADS_ENABLED

#if GLIB_CHECK_VERSION(2,31,0)
    /* No longer need to init threads manually anymore */
#else
    /* this must be called before gtk_init () */
    g_thread_init (NULL);
#endif

    /* FIXME: this call causes gtkpod to freeze as soon as tracks should be
       displayed */
    gdk_threads_init ();
#endif

#ifdef HAVE_CLUTTER_GTK
    gtk_clutter_init(&argc, &argv);
    clutter_threads_init();
#else
    gtk_init (&argc, &argv);
#endif

    ctx = g_option_context_new (_("- Interface with your iPod"));
    g_option_context_add_main_entries(ctx, gtkpod_get_option_entries(), NULL);

    g_option_context_add_group (ctx, gtk_get_option_group (TRUE));

#ifdef HAVE_GSTREAMER
    g_option_context_add_group (ctx, gst_init_get_option_group ());
#endif

#ifdef HAVE_BRASERO
    g_option_context_add_group (ctx, brasero_media_get_option_group ());
#endif

    g_option_context_parse (ctx, &argc, &argv, &error);
    if (error != NULL) {
        g_printerr (_("Error parsing options: %s\n"), error->message);
        g_error_free(error);
        exit(1);
    }
    g_option_context_free (ctx);

    g_set_application_name(_("gtkpod"));
    gtk_window_set_auto_startup_notification(FALSE);

    srand(time(NULL));

    gtkpod_init (argc, argv);

#ifdef G_THREADS_ENABLED
    gdk_threads_enter();
#endif
    gtk_main ();
#ifdef G_THREADS_ENABLED
    gdk_threads_leave();
#endif

    return 0;
}
static void
gnome_control_center_init (GnomeControlCenter *self)
{
  GError *err = NULL;
  GnomeControlCenterPrivate *priv;
  GdkScreen *screen;

  priv = self->priv = CONTROL_CENTER_PRIVATE (self);

#ifdef HAVE_CHEESE
  if (gtk_clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS)
    {
      g_critical ("Clutter-GTK init failed");
      return;
    }
#endif /* HAVE_CHEESE */

  priv->monitor_num = -1;
  self->priv->small_screen = SMALL_SCREEN_UNSET;

  /* load the user interface */
  priv->builder = gtk_builder_new ();

  if (!gtk_builder_add_from_file (priv->builder, UIDIR "/shell.ui", &err))
    {
      g_critical ("Could not build interface: %s", err->message);
      g_error_free (err);

      return;
    }

  /* connect various signals */
  priv->window = W (priv->builder, "main-window");
  gtk_window_set_hide_titlebar_when_maximized (GTK_WINDOW (priv->window), TRUE);
  screen = gtk_widget_get_screen (priv->window);
  g_signal_connect (screen, "monitors-changed", G_CALLBACK (monitors_changed_cb), self);
  g_signal_connect (priv->window, "configure-event", G_CALLBACK (main_window_configure_cb), self);
  g_signal_connect (priv->window, "notify::application", G_CALLBACK (application_set_cb), self);
  g_signal_connect_swapped (priv->window, "delete-event", G_CALLBACK (g_object_unref), self);
  g_signal_connect_after (priv->window, "key_press_event",
                          G_CALLBACK (window_key_press_event), self);

  priv->notebook = W (priv->builder, "notebook");

  /* Main scrolled window */
  priv->scrolled_window = W (priv->builder, "scrolledwindow1");

  gtk_widget_set_size_request (priv->scrolled_window, FIXED_WIDTH, -1);
  priv->main_vbox = W (priv->builder, "main-vbox");
  g_signal_connect (priv->notebook, "notify::page",
                    G_CALLBACK (notebook_page_notify_cb), priv);

  g_signal_connect (gtk_builder_get_object (priv->builder, "home-button"),
                    "clicked", G_CALLBACK (home_button_clicked_cb), self);

  /* keep a list of custom widgets to unload on panel change */
  priv->custom_widgets = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);

  /* load the available settings panels */
  setup_model (self);

  /* load the panels that are implemented as plugins */
  load_panel_plugins (self);

  /* setup search functionality */
  setup_search (self);

  setup_lock (self);

  /* store default window title and name */
  priv->default_window_title = g_strdup (gtk_window_get_title (GTK_WINDOW (priv->window)));
  priv->default_window_icon = g_strdup (gtk_window_get_icon_name (GTK_WINDOW (priv->window)));

  notebook_page_notify_cb (GTK_NOTEBOOK (priv->notebook), NULL, priv);
}
Пример #19
0
/*            snappy's main function             */
int
main (int argc, char *argv[])
{
  UserInterface *ui = NULL;
  GstEngine *engine = NULL;
  ClutterActor *video_texture;
  ClutterGstVideoSink *sink;

  gboolean ok, blind = FALSE, fullscreen = FALSE, hide = FALSE, loop = FALSE;
  gboolean secret = FALSE, tags = FALSE;
  gint ret = 0;
  gchar *uri = NULL;
  gchar *suburi = NULL;
  GList *uri_list;
  GOptionContext *context;
  gchar *data_dir;

  ClutterInitError ci_err;

#ifdef ENABLE_DBUS
  SnappyMP *mp_obj = NULL;
#endif

  context = g_option_context_new ("<media file> - Play movie files");

  clutter_set_windowing_backend (CLUTTER_WINDOWING_X11);
  ci_err = gtk_clutter_init (&argc, &argv);
  if (ci_err != CLUTTER_INIT_SUCCESS)
    goto quit;

  /* Try to find the path for our resources in case snappy was relocated */
  data_dir = g_strdup (SNAPPY_DATA_DIR);
  if (!g_file_test (data_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
    gchar *root_dir;

#ifdef G_OS_WIN32
    root_dir = g_win32_get_package_installation_directory_of_module (NULL);
#elif !defined(G_OS_UNIX)
    gchar *exec_path;
    gchar *bin_dir;

    exec_path = g_file_read_link ("/proc/self/exe", NULL);
    bin_dir = g_path_get_dirname (exec_path);
    root_dir = g_build_filename (bin_dir, "..", NULL);
    g_free (exec_path);
    g_free (bin_dir);
#else
    root_dir = NULL;
#endif
    if (root_dir != NULL) {
      data_dir = g_build_filename (root_dir, "share", "snappy", NULL);
      g_free (root_dir);
    }
  }

  /* Process command arguments */
  uri_list = process_args (argc, argv, &blind, &fullscreen, &hide,
      &loop, &secret, &suburi, &tags, context);

  gst_init (&argc, &argv);
  clutter_gst_init (NULL, NULL);

  /* User Interface */
  ui = g_new (UserInterface, 1);
  ui->uri_list = uri_list;
  ui->blind = blind;
  ui->fullscreen = fullscreen;
  ui->hide = hide;
  ui->tags = tags;
  ui->data_dir = data_dir;
  interface_init (ui);

  /* Gstreamer engine */
  engine = g_new (GstEngine, 1);
  sink = clutter_gst_video_sink_new ();
  if (sink == NULL) {
    g_print ("ERROR: Failed to create clutter-gst sink element\n");
    return FALSE;
  }
  video_texture = g_object_new (CLUTTER_TYPE_ACTOR, "content",
      g_object_new (CLUTTER_GST_TYPE_CONTENT, "sink", sink, NULL),
      "name", "texture", NULL);

  ok = engine_init (engine, sink);
  if (!ok)
    goto quit;

  engine->secret = secret;
  engine->loop = loop;

  ui->engine = engine;
  ui->texture = video_texture;

  gst_bus_add_watch (engine->bus, bus_call, ui);
  gst_object_unref (engine->bus);

  /* Get uri to load */
  if (uri_list) {
    uri = g_list_first (uri_list)->data;
    /* based on video filename we can guess subtitle file (.srt files only) */
    if (NULL == suburi) {
      gchar suburi_path_guessing[1024]; //buffer
      gchar *uri_no_extension = strip_filename_extension (uri);

      sprintf (suburi_path_guessing, "%s.srt", uri_no_extension);
      /* subtitle file exists, defaults for it */
      if (g_file_test (g_filename_from_uri (suburi_path_guessing, NULL, NULL),
              G_FILE_TEST_EXISTS))
        suburi = suburi_path_guessing;
    }
  }

  /* Load engine and start interface */
  engine_load_uri (engine, uri);
  interface_start (ui, uri);

  /* Load subtitle file if available */
  if (suburi != NULL) {
    suburi = clean_uri (suburi);
    set_subtitle_uri (engine, suburi);
  }

  /* Start playing if we have a URI to play */
  if (uri) {
    change_state (engine, "Paused");
    change_state (engine, "Playing");
  }
#ifdef ENABLE_DBUS
  /* Start MPRIS Dbus object */
  mp_obj = g_new (SnappyMP, 1);
  mp_obj->engine = engine;
  mp_obj->ui = ui;
  load_dlna (mp_obj);
#endif

  /* Main loop */
  gtk_main ();

  /* Close snappy */
  close_down (ui, engine);
#ifdef ENABLE_DBUS
  close_dlna (mp_obj);
#endif

quit:
  g_list_free (uri_list);
  g_option_context_free (context);

  return ret;
}
Пример #20
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);

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

  tpy_cli_init ();

  gtk_clutter_init (&argc, &argv);
  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);

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