コード例 #1
0
ファイル: gnit.c プロジェクト: dutch/gnit
int main(int argc, char *argv[]) {
    ClutterScript *ui;
    ClutterActor *stage;
    GError *err;
    int return_value;

    err = NULL;
    return_value = EXIT_SUCCESS;

    if (clutter_init(&argc, &argv) != CLUTTER_INIT_SUCCESS) {
        fprintf(stderr, "Clutter initialization failed\n");
        return_value = EXIT_FAILURE;
        goto done;
    }

    ui = clutter_script_new();
    clutter_script_load_from_resource(ui, "/org/dutch/Gnit/ui.json", &err);

    if (err) {
        g_critical("%s", err->message);
        g_error_free(err);
        return_value = EXIT_FAILURE;
        goto done;
    }

    clutter_script_connect_signals(ui, ui);

    clutter_script_get_objects(ui, "stage", &stage, NULL);
    clutter_actor_show(stage);
    clutter_main();

done:
    g_object_unref(ui);

    return EXIT_SUCCESS;
}
コード例 #2
0
static void
mex_music_player_init (MexMusicPlayer *self)
{
  GError *error = NULL;
  ClutterActor *box;
  MexMusicPlayerPrivate *priv;
  ClutterActor *button;

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

  priv->script = clutter_script_new ();
  clutter_script_load_from_resource (priv->script,
                                     "/org/media-explorer/MediaExplorer/json/"
                                     "music-player.json",
                                     &error);

  if (error)
    {
      g_error (G_STRLOC " %s", error->message);
      g_clear_error (&error);
    }

  box = mex_script_get_actor (priv->script, "box");
  g_assert (box);

  clutter_actor_add_child (CLUTTER_ACTOR (self), box);


  /* labels */
  priv->title_label = mex_script_get_actor (priv->script, "title-label");
  priv->subtitle_label = mex_script_get_actor (priv->script, "subtitle-label");

  /* play */
  priv->play_button = mex_script_get_actor (priv->script, "play-button");
  g_signal_connect_swapped (priv->play_button, "clicked",
                            G_CALLBACK (mex_music_player_play_toggle), self);

  /* next */
  button = mex_script_get_actor (priv->script, "next-button");
  g_signal_connect_swapped (button, "clicked",
                            G_CALLBACK (mex_music_player_next), self);

  /* previous */
  button = mex_script_get_actor (priv->script, "previous-button");
  g_signal_connect_swapped (button, "clicked",
                            G_CALLBACK (mex_music_player_previous), self);

  /* stop */
  button = mex_script_get_actor (priv->script, "stop-button");
  g_signal_connect_swapped (button, "clicked",
                            G_CALLBACK (mex_music_player_quit), self);

  /* repeat */
  button = mex_script_get_actor (priv->script, "repeat-button");
  g_signal_connect_swapped (button, "notify::toggled",
                            G_CALLBACK (mex_music_player_repeat_toggled), self);

  button = mex_script_get_actor (priv->script, "shuffle-button");
  g_signal_connect_swapped (button, "notify::toggled",
                            G_CALLBACK (mex_music_player_shuffle_toggled), self);


  /* player */
  priv->player = (ClutterMedia *) clutter_gst_video_texture_new ();
  g_signal_connect (priv->player, "notify",
                    G_CALLBACK (mex_music_player_notify_cb), self);
  g_signal_connect (priv->player, "eos",
                    G_CALLBACK (mex_music_player_eos_cb), self);

  /* slider */
  priv->slider = mex_script_get_actor (priv->script, "progress-slider");
  priv->slider_notify_id = g_signal_connect (priv->slider, "notify::value",
                                             G_CALLBACK (mex_music_player_slider_notify),
                                             self);


  g_signal_connect (self, "captured-event",
                    G_CALLBACK (mex_music_player_captured_event), NULL);
}