static void
bg_filename_changed_cb (GConfClient *client,
                        guint        cnxn_id,
                        GConfEntry  *entry,
                        gpointer     userdata)
{
  PengeViewBackground *pvb = PENGE_VIEW_BACKGROUND (userdata);
  const gchar *filename;
  GConfValue *value;
  GError *error = NULL;

  value = gconf_entry_get_value (entry);

  if (value)
  {
    filename = gconf_value_get_string (value);
    if (!clutter_texture_set_from_file (CLUTTER_TEXTURE (pvb),
                                        filename,
                                        &error))
    {
      g_warning (G_STRLOC ": Error setting magic texture contents: %s",
                 error->message);
      g_clear_error (&error);
    } else {
      clutter_actor_set_opacity ((ClutterActor *)pvb, 0xff);
    }
  } else {
    /* If the key is unset let's just make ourselves invisible */
    clutter_actor_set_opacity ((ClutterActor *)pvb, 0x0);
  }
}
static void
penge_calendar_pane_update_calendar_icon (PengeCalendarPane *pane,
                                          JanaTime          *time)
{
  PengeCalendarPanePrivate *priv = GET_PRIVATE (pane);
  GError *error = NULL;
  gchar *path = NULL;

  if (jana_time_get_day (time) != priv->day_of_month)
  {
    priv->day_of_month = jana_time_get_day (time);
    path = g_strdup_printf (CALENDAR_ICON, priv->day_of_month);
    clutter_texture_set_from_file (CLUTTER_TEXTURE (priv->calendar_tex),
                                   path,
                                   &error);

    g_free (path);

    if (error)
    {
      g_warning (G_STRLOC ": Error setting path on calendar texture: %s",
                 error->message);
      g_clear_error (&error);
    }
  }
}
Example #3
0
static void
_update_icon_from_icon_theme (PengeAppTile *tile)
{
  PengeAppTilePrivate *priv = GET_PRIVATE (tile);
  gchar *icon_path;
  GError *error = NULL;
  GIcon *icon;

  icon = g_app_info_get_icon (priv->app_info);

  if (G_IS_FILE_ICON (icon))
  {
    icon_path = g_icon_to_string (icon);
  }
  
  if (!clutter_texture_set_from_file (CLUTTER_TEXTURE (priv->tex),
                                      icon_path,
                                      &error))
  {
    g_warning (G_STRLOC ": Error loading texture from file: %s",
                error->message);
    g_clear_error (&error);
  }

  g_free (icon_path);
}
Example #4
0
void
mpd_folder_button_set_icon_path (MpdFolderButton *self,
                                 char const      *icon_path)
{
  MpdFolderButtonPrivate *priv = GET_PRIVATE (self);

  g_return_if_fail (MPD_IS_FOLDER_BUTTON (self));

  if (0 != g_strcmp0 (icon_path, priv->icon_path))
  {
    if (priv->icon_path)
    {
      g_free (priv->icon_path);
      priv->icon_path = NULL;
    }

    if (icon_path)
    {
      GError *error = NULL;
      priv->icon_path = g_strdup (icon_path);
      clutter_texture_set_from_file (CLUTTER_TEXTURE (priv->icon),
                                     priv->icon_path,
                                     &error);
      if (error)
      {
        g_warning ("%s : %s", G_STRLOC, error->message);
        g_clear_error (&error);
      }
    }
    g_object_notify (G_OBJECT (self), "icon-path");
  }
}
Example #5
0
static void
toggle_playing (UserInterface * ui)
{
  GstEngine *engine = ui->engine;

  if (engine->playing) {
    change_state (engine, "Paused");
    engine->playing = FALSE;

    clutter_texture_set_from_file (CLUTTER_TEXTURE (ui->control_play_toggle),
        ui->play_png, NULL);
  } else {
    change_state (engine, "Playing");
    engine->playing = TRUE;

    clutter_texture_set_from_file (CLUTTER_TEXTURE (ui->control_play_toggle),
        ui->pause_png, NULL);
  }
}
Example #6
0
static gboolean
load_image (ClutterTexture *texture,
            gchar          *image_path)
{
  GError *error = NULL;

  gboolean success = clutter_texture_set_from_file (CLUTTER_TEXTURE (texture),
                                                    image_path,
                                                    &error);

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

  return success;
}
Example #7
0
G_MODULE_EXPORT int
test_texture_material_main (int argc, char *argv[])
{
  ClutterActor *stage, *box;
  ClutterLayoutManager *manager;
  int i;

  g_thread_init (NULL);
  clutter_threads_init ();
  clutter_init (&argc, &argv);

  stage = clutter_stage_new ();
  clutter_stage_set_title (CLUTTER_STAGE (stage), "Texture Material");
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  manager = clutter_flow_layout_new (CLUTTER_FLOW_HORIZONTAL);
  box = clutter_box_new (manager);
  clutter_actor_add_constraint (box, clutter_bind_constraint_new (stage, CLUTTER_BIND_WIDTH, -25.0));
  clutter_actor_add_constraint (box, clutter_bind_constraint_new (stage, CLUTTER_BIND_HEIGHT, -25.0));
  clutter_actor_set_position (box, 25.0, 25.0);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), box);

  for (i = 0; i < 48; i++)
    {
      ClutterActor *texture = clutter_texture_new ();

      clutter_texture_set_load_data_async (CLUTTER_TEXTURE (texture), TRUE);
      clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (texture), TRUE);
      clutter_texture_set_from_file (CLUTTER_TEXTURE (texture),
                                     TESTS_DATADIR "/redhand.png",
                                     NULL);
      clutter_actor_set_width (texture, 96);

      clutter_container_add_actor (CLUTTER_CONTAINER (box), texture);
    }

  clutter_actor_show (stage);

  clutter_main ();

  return EXIT_SUCCESS;
}
Example #8
0
int
main (int argc, char *argv[])
{
  ClutterActor *stage;
  ClutterActor *texture;
  GError *error = NULL;
  ClutterActor *clone;
  gfloat y_offset;

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

  stage = clutter_stage_new ();
  clutter_stage_set_title (CLUTTER_STAGE (stage), "Reflection");
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  texture = clutter_texture_new ();
  clutter_texture_set_from_file (CLUTTER_TEXTURE (texture),
                                 "redhand.png",
                                 &error);
  clutter_actor_add_constraint (texture, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.5));
  clutter_actor_add_constraint (texture, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.2));

  y_offset = clutter_actor_get_height (texture) + V_PADDING;

  clone = clutter_clone_new (texture);
  clutter_actor_add_constraint (clone, clutter_bind_constraint_new (texture, CLUTTER_BIND_X, 0.0));
  clutter_actor_add_constraint (clone, clutter_bind_constraint_new (texture, CLUTTER_BIND_Y, y_offset));
  g_signal_connect (clone,
                    "paint",
                    G_CALLBACK (_clone_paint_cb),
                    NULL);

  clutter_container_add (CLUTTER_CONTAINER (stage), texture, clone, NULL);

  clutter_actor_show (stage);

  clutter_main ();

  return EXIT_SUCCESS;
}
Example #9
0
int
main (int argc, char *argv[])
{
  ClutterActor *stage;
  ClutterActor *texture;
  ClutterState *transitions;
  GError *error = NULL;
  gfloat texture_width, texture_height;

  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  texture = clutter_texture_new ();
  clutter_actor_add_constraint (texture,
                                clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.5));
  clutter_actor_add_constraint (texture,
                                clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.5));
  clutter_texture_set_sync_size (CLUTTER_TEXTURE (texture), TRUE);
  clutter_texture_set_from_file (CLUTTER_TEXTURE (texture),
                                 TESTS_DATA_DIR "/redhand.png",
                                 &error);

  if (error != NULL)
    {
      g_error ("Problem loading image into texture - %s", error->message);
      g_error_free (error);
      return 1;
    }

  clutter_actor_get_size (texture, &texture_width, &texture_height);
  clutter_actor_set_size (stage, texture_width * 2, texture_height * 2);

  /* set all centres of rotation to the centre of the texture */
  clutter_actor_set_rotation (texture,
                              CLUTTER_X_AXIS,
                              0.0,
                              texture_width * 0.5,
                              texture_height * 0.5,
                              0.0);
  clutter_actor_set_rotation (texture,
                              CLUTTER_Y_AXIS,
                              0.0,
                              texture_width * 0.5,
                              texture_height * 0.5,
                              0.0);
  clutter_actor_set_z_rotation_from_gravity (texture, 0.0, CLUTTER_GRAVITY_CENTER);

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), texture);

  /* set up the animations */
  transitions = clutter_state_new ();

  clutter_state_set (transitions, NULL, "start",
                     texture, "rotation-angle-x", CLUTTER_LINEAR, 0.0,
                     texture, "rotation-angle-y", CLUTTER_LINEAR, 0.0,
                     texture, "rotation-angle-z", CLUTTER_LINEAR, 0.0,
                     NULL);
  clutter_state_set (transitions, NULL, "x-cw",
                     texture, "rotation-angle-x", CLUTTER_LINEAR, ROTATION_ANGLE,
                     NULL);
  clutter_state_set (transitions, NULL, "x-ccw",
                     texture, "rotation-angle-x", CLUTTER_LINEAR, -ROTATION_ANGLE,
                     NULL);
  clutter_state_set (transitions, NULL, "x-after",
                     texture, "rotation-angle-x", CLUTTER_LINEAR, 0.0,
                     NULL);
  clutter_state_set (transitions, NULL, "y-cw",
                     texture, "rotation-angle-y", CLUTTER_LINEAR, ROTATION_ANGLE,
                     NULL);
  clutter_state_set (transitions, NULL, "y-ccw",
                     texture, "rotation-angle-y", CLUTTER_LINEAR, -ROTATION_ANGLE,
                     NULL);
  clutter_state_set (transitions, NULL, "y-after",
                     texture, "rotation-angle-y", CLUTTER_LINEAR, 0.0,
                     NULL);
  clutter_state_set (transitions, NULL, "z-cw",
                     texture, "rotation-angle-z", CLUTTER_LINEAR, ROTATION_ANGLE,
                     NULL);
  clutter_state_set (transitions, NULL, "z-ccw",
                     texture, "rotation-angle-z", CLUTTER_LINEAR, -ROTATION_ANGLE,
                     NULL);
  clutter_state_set_duration (transitions, NULL, NULL, DURATION);
  clutter_state_set_duration (transitions, "start", NULL, DURATION * 0.5);
  clutter_state_set_duration (transitions, NULL, "start", DURATION * 0.5);
  clutter_state_set_duration (transitions, NULL, "x-after", DURATION * 0.5);
  clutter_state_set_duration (transitions, NULL, "y-after", DURATION * 0.5);

  clutter_state_warp_to_state (transitions, "start");

  g_signal_connect (transitions,
                    "completed",
                    G_CALLBACK (_set_next_state),
                    NULL);

  clutter_state_set_state (transitions, "x-cw");

  clutter_actor_show (stage);

  clutter_main ();

  return 0;
}
static void
penge_interesting_tile_set_property (GObject *object, guint property_id,
                                     const GValue *value, GParamSpec *pspec)
{
    PengeInterestingTilePrivate *priv = GET_PRIVATE (object);
    GError *error = NULL;
    const gchar *path;

    switch (property_id) {
    case PROP_BODY:
        if (priv->body)
        {
            clutter_container_remove_actor (CLUTTER_CONTAINER (priv->inner_table),
                                            priv->body);
        }

        priv->body = g_value_get_object (value);

        if (!priv->body)
            return;

        mx_table_add_actor_with_properties (MX_TABLE (priv->inner_table),
                                            priv->body,
                                            0, 0,
                                            "y-align", MX_ALIGN_START,
                                            "x-align", MX_ALIGN_START,
                                            "y-fill", TRUE,
                                            "y-expand", TRUE,
                                            NULL);
        break;
    case PROP_ICON_PATH:
        path = g_value_get_string (value);

        if (path && !clutter_texture_set_from_file (CLUTTER_TEXTURE (priv->icon),
                path,
                &error))
        {
            g_critical (G_STRLOC ": error setting icon texture from file: %s",
                        error->message);
            g_clear_error (&error);
        }

        if (path)
        {
            clutter_actor_show (priv->icon);
            clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay),
                                         priv->primary_text,
                                         "column", 1,
                                         NULL);
            clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay),
                                         priv->secondary_text,
                                         "column", 1,
                                         NULL);
        } else {
            clutter_actor_hide (priv->icon);
            clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay),
                                         priv->primary_text,
                                         "column", 0,
                                         NULL);
            clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay),
                                         priv->secondary_text,
                                         "column", 0,
                                         NULL);
        }

        break;
    case PROP_PRIMARY_TEXT:
        mx_label_set_text (MX_LABEL (priv->primary_text),
                           g_value_get_string (value));
        break;
    case PROP_SECONDARY_TEXT:
        mx_label_set_text (MX_LABEL (priv->secondary_text),
                           g_value_get_string (value));
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
    }
}
Example #11
0
static void
ntf_libnotify_update (NtfNotification *ntf, Notification *details)
{
  ClutterActor *icon = NULL;

  g_return_if_fail (store && ntf && details);

  if (details->summary)
    ntf_notification_set_summary (ntf, details->summary);

  if (details->body)
    ntf_notification_set_body (ntf, details->body);

  if (details->icon_pixbuf)
    {
      GdkPixbuf *pixbuf = details->icon_pixbuf;

      icon = clutter_texture_new ();

      clutter_texture_set_from_rgb_data (CLUTTER_TEXTURE (icon),
                                         gdk_pixbuf_get_pixels (pixbuf),
                                         gdk_pixbuf_get_has_alpha (pixbuf),
                                         gdk_pixbuf_get_width (pixbuf),
                                         gdk_pixbuf_get_height (pixbuf),
                                         gdk_pixbuf_get_rowstride (pixbuf),
                                         gdk_pixbuf_get_has_alpha (pixbuf) ?
                                         4 : 3,
                                         0, NULL);
    }
  else if (details->icon_name)
    {
      GtkIconTheme *theme;
      GtkIconInfo  *info;

      theme = gtk_icon_theme_get_default ();
      info = gtk_icon_theme_lookup_icon (theme, details->icon_name, 24, 0);

      if (info)
        {
          icon = clutter_texture_new ();

          clutter_texture_set_from_file (CLUTTER_TEXTURE(icon),
                                         gtk_icon_info_get_filename (info),
                                         NULL);
          gtk_icon_info_free (info);
        }
    }

  if (icon)
    clutter_actor_set_size (icon, 24.0, 24.0);
  ntf_notification_set_icon (ntf, icon);

  if (details->actions)
    {
      GList *action;
      gchar *key, *value;

      ntf_notification_remove_all_buttons (ntf);

      for (action = details->actions; action;)
        {
          /*
           * The action list length is
           * guaranteed to be % 2 and > 0
           */
          key = action->data;
          action = g_list_next (action);
          value = action->data;
          action = g_list_next (action);

          if (strcasecmp(key, "default") != 0)
            {
              ActionData   *data;
              ClutterActor *button;
              KeySym        keysym = 0;

              data = g_slice_new0 (ActionData);
              data->notification = ntf;
              data->action       = g_strdup (key);
              data->id           = details->id;
              data->store        = store;

              button = mx_button_new ();

              mx_button_set_label (MX_BUTTON (button), value);

              g_signal_connect_data (button, "clicked",
                                     G_CALLBACK (ntf_libnotify_action_cb),
                                     data,
                                     (GClosureNotify) free_action_data,
                                     0);

              /*
               * Handle the dawati key shortcut protocol
               */
              if (!strncmp (key, DAWATI_KEY_PREFIX, strlen (DAWATI_KEY_PREFIX)))
                {
                  const char *k = key + strlen (DAWATI_KEY_PREFIX);
                  const char *pfx = strstr (k, "XK_");
                  char       *name;

                  if (pfx)
                    {
                      if (k == pfx)
                        {
                          name = g_strdup (k + 3);
                        }
                      else
                        {
                          name = g_strdup (k);

                          name [pfx - k] = 0;
                          strcat (name, pfx + 3);
                        }

                      keysym = XStringToKeysym (name);

                      if (!keysym)
                        g_warning (G_STRLOC ": no keysym found for %s (%s)",
                                   key, name);

                      g_free (name);

                    }
                  else
                    {
                      g_warning (G_STRLOC ": invalid key %s", key);
                    }
                }

              ntf_notification_add_button (ntf, button, key, keysym);
              mx_stylable_set_style_class (MX_STYLABLE (button),
                                           "Primary");
            }
        }
    }

  ntf_notification_set_urgent (ntf, details->is_urgent);

  ntf_notification_set_timeout (ntf, details->timeout_ms);
}
int
main (int   argc,
      char *argv[])
{
  ClutterActor *stage;
  ClutterActor *texture;
  gchar *image_path;
  GError *error = NULL;

  if (argc < 2)
    {
      g_print ("Usage: %s <path to image file>\n", argv[0]);
      exit (EXIT_FAILURE);
    }

  image_path = argv[1];

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

  stage = clutter_stage_new ();
  clutter_actor_set_size (stage, STAGE_SIDE, STAGE_SIDE);
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  texture = clutter_texture_new ();
  clutter_actor_set_reactive (texture, TRUE);
  clutter_actor_set_width (texture, STAGE_SIDE);
  clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (texture), TRUE);

  clutter_actor_add_action (texture, clutter_drag_action_new ());

  g_object_set (G_OBJECT (texture),
                "scale-gravity", CLUTTER_GRAVITY_NORTH_WEST,
                NULL);

  clutter_texture_set_from_file (CLUTTER_TEXTURE (texture), image_path, &error);

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

  clutter_actor_set_y (texture, (STAGE_SIDE - clutter_actor_get_height (texture)) * 0.5);

  g_signal_connect (texture,
                    "button-release-event",
                    G_CALLBACK (clicked_cb),
                    NULL);

  g_signal_connect_swapped (stage,
                            "key-press-event",
                            G_CALLBACK (key_press_cb),
                            texture);

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), texture);

  clutter_actor_show (stage);

  clutter_main ();

  return EXIT_SUCCESS;
}
int
main (int   argc,
      char *argv[])
{
  ClutterActor *stage;
  ClutterActor *texture;
  ClutterEffect *effect;
  ClutterState *transitions;
  GError *error = NULL;

  gchar *filename;

  if (argc < 2)
    {
      g_print ("Usage: %s <path to image file>\n", argv[0]);
      return EXIT_FAILURE;
    }

  filename = argv[1];

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

  stage = clutter_stage_new ();
  clutter_actor_set_size (stage, 400, 300);
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  texture = clutter_texture_new ();
  clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (texture), TRUE);
  clutter_actor_set_width (texture, 400);
  clutter_actor_set_reactive (texture, TRUE);
  clutter_texture_set_from_file (CLUTTER_TEXTURE (texture),
                                 filename,
                                 &error);

  if (error != NULL)
    {
      g_critical ("Error loading texture from file %s; error was:\n%s",
                  filename,
                  error->message);
      return EXIT_FAILURE;
    }

  /* create the page fold effect instance with destination fold angle
   * of 180 degrees and starting period of 0 (no folding)
   */
  effect = cb_page_fold_effect_new (180.0, 0.0);

  /* add the effect to the texture actor */
  clutter_actor_add_effect (texture, effect);

  clutter_container_add_actor (CLUTTER_CONTAINER (stage), texture);

  /* animation for the period property of the effect,
   * to animate its value between 0.0 and 1.0 and back
   */
  transitions = clutter_state_new ();
  clutter_state_set_duration (transitions, NULL, NULL, 500);

  clutter_state_set_duration (transitions,
                              "partially-folded",
                              "folded",
                              375);

  clutter_state_set (transitions, NULL, "folded",
                     effect, "period", CLUTTER_LINEAR, 1.0,
                     NULL);

  clutter_state_set (transitions, NULL, "partially-folded",
                     effect, "period", CLUTTER_LINEAR, 0.25,
                     NULL);

  clutter_state_set (transitions, NULL, "unfolded",
                     effect, "period", CLUTTER_LINEAR, 0.0,
                     NULL);

  clutter_state_warp_to_state (transitions, "partially-folded");

  g_signal_connect (texture,
                    "button-press-event",
                    G_CALLBACK (button_pressed_cb),
                    transitions);

  clutter_actor_show (stage);

  clutter_main ();

  g_object_unref (transitions);

  return EXIT_SUCCESS;
}
int
main (int argc, char *argv[])
{
  ClutterActor *stage;
  ClutterActor *texture;
  ClutterActor *overlay;
  ClutterAction *click;
  GError *error = NULL;

  const gchar *filename = "redhand.png";

  if (argc > 1)
    filename = argv[1];

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

  stage = clutter_stage_new ();
  clutter_actor_set_size (stage, STAGE_SIDE, STAGE_SIDE);
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  texture = clutter_texture_new ();
  clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (texture), TRUE);
  clutter_actor_set_reactive (texture, TRUE);
  clutter_actor_set_size (texture, RECTANGLE_SIDE, RECTANGLE_SIDE);
  clutter_actor_add_constraint (texture, clutter_align_constraint_new (stage, CLUTTER_ALIGN_X_AXIS, 0.5));
  clutter_actor_add_constraint (texture, clutter_align_constraint_new (stage, CLUTTER_ALIGN_Y_AXIS, 0.5));

  clutter_texture_set_from_file (CLUTTER_TEXTURE (texture),
                                 filename,
                                 &error);

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

  /* overlay is 10px wider and taller than the texture, and centered on it;
   * initially, it is transparent; but it is made semi-opaque when the
   * texture is clicked
   */
  overlay = clutter_rectangle_new_with_color (&overlay_color);
  clutter_actor_set_opacity (overlay, OVERLAY_OPACITY_OFF);
  clutter_actor_add_constraint (overlay, clutter_bind_constraint_new (texture, CLUTTER_BIND_WIDTH, 10));
  clutter_actor_add_constraint (overlay, clutter_bind_constraint_new (texture, CLUTTER_BIND_HEIGHT, 10));
  clutter_actor_add_constraint (overlay, clutter_align_constraint_new (texture, CLUTTER_ALIGN_X_AXIS, 0.5));
  clutter_actor_add_constraint (overlay, clutter_align_constraint_new (texture, CLUTTER_ALIGN_Y_AXIS, 0.5));

  click = clutter_click_action_new ();
  clutter_actor_add_action (texture, click);

  clutter_container_add (CLUTTER_CONTAINER (stage), texture, overlay, NULL);
  clutter_actor_raise_top (overlay);

  g_signal_connect (click, "clicked", G_CALLBACK (click_cb), overlay);

  g_signal_connect (stage,
                    "key-press-event",
                    G_CALLBACK (key_press_cb),
                    texture);

  clutter_actor_show (stage);

  clutter_main ();

  return EXIT_SUCCESS;
}
Example #15
0
static
gboolean task (gpointer user_data)
{
  ClutterTimeline  *timeline;
  ClutterAlpha     *alpha;
  ClutterBehaviour *depth_behavior;
  ClutterActor     *image[4];
  ClutterActor     *clone[4];
  ClutterActor     *stage;
  gchar            *path = user_data;
  gint i;

  stage = clutter_stage_get_default ();

  image[0] = g_object_new (CLUTTER_TYPE_TEXTURE, NULL);
  g_signal_connect (image[0], "load-finished",
                    G_CALLBACK (on_load_finished),
                    GINT_TO_POINTER (LOAD_SYNC));

  image[1] = g_object_new (CLUTTER_TYPE_TEXTURE,
                           "load-data-async", TRUE,
                           NULL);
  g_signal_connect (image[1], "load-finished",
                    G_CALLBACK (on_load_finished),
                    GINT_TO_POINTER (LOAD_DATA_ASYNC));
  image[2] = g_object_new (CLUTTER_TYPE_TEXTURE,
                           "load-async", TRUE,
                           NULL);
  g_signal_connect (image[2], "load-finished",
                    G_CALLBACK (on_load_finished),
                    GINT_TO_POINTER (LOAD_ASYNC));

  for (i = 0; i < 3; i++)
    {
      GError *error = NULL;

      clutter_texture_set_from_file (CLUTTER_TEXTURE (image[i]), path, &error);
      if (error != NULL)
        g_error ("Unable to load image at '%s': %s",
                 path != NULL ? path : "<unknown>",
                 error->message);
    }

  for (i = 0; i < 3; i++)
    clutter_container_add (CLUTTER_CONTAINER (stage), image[i], NULL);

  for (i = 0; i < 3; i++)
    {
      clutter_actor_set_position (image[i], 50+i*100, 0+i*50);
      clone[i]=clutter_clone_new (image[i]);
      g_signal_connect (image[i], "size-change",
                        G_CALLBACK (size_change_cb), clone[i]);
      clutter_container_add (CLUTTER_CONTAINER (stage), clone[i], NULL);
      clutter_actor_set_position (clone[i], 50+i*100, 150+i*50+100);
    }

  for (i = 0; i < 3; i++)
    {
      timeline = clutter_timeline_new (5000);
      alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR);
      depth_behavior = clutter_behaviour_depth_new (alpha, -2500, 0);
      clutter_behaviour_apply (depth_behavior, image[i]);
      clutter_timeline_start (timeline);
    }

  return FALSE;
}
static GObject *
_constructor (GType                  type,
              unsigned int           n_properties,
              GObjectConstructParam *properties)
{
  MpdStorageDeviceTile *self = (MpdStorageDeviceTile *)
                        G_OBJECT_CLASS (mpd_storage_device_tile_parent_class)
                          ->constructor (type, n_properties, properties);
  MpdStorageDeviceTilePrivate *priv = GET_PRIVATE (self);
  GError  *error = NULL;

  if (priv->icon_file &&
      g_file_test (priv->icon_file, G_FILE_TEST_IS_REGULAR))
  {
    clutter_texture_set_from_file (CLUTTER_TEXTURE (priv->icon),
                                   priv->icon_file,
                                   &error);
  } else {
    clutter_texture_set_from_file (CLUTTER_TEXTURE (priv->icon),
                                   PKGICONDIR "/device-usb.png",
                                   &error);
  }
  if (error)
  {
    g_warning ("%s : %s", G_STRLOC, error->message);
    g_clear_error (&error);
  }

  if (priv->mount_point)
  {
    char *path;

    path = g_filename_from_uri (priv->mount_point, NULL, &error);
    if (error)
    {
      /* not all uris are file paths, that's ok */
      if (error->code != G_CONVERT_ERROR_BAD_URI)
      {
        g_warning ("%s: Failed to get filename from uri: %s",
                   G_STRLOC, error->message);
      }
      g_clear_error (&error);
    }
    if (path)
    {
      priv->storage = mpd_storage_device_new (path);
      g_signal_connect (priv->storage, "notify::size",
                      G_CALLBACK (_storage_size_notify_cb), self);
      g_signal_connect (priv->storage, "notify::available-size",
                      G_CALLBACK (_storage_size_notify_cb), self);
      g_free (path);
    }

    update (self);

  } else {
    g_critical ("%s : %s",
                G_STRLOC,
                "Invalid or no mount-point passed to constructor.");
    self = NULL;
  }

  /* FIXME: import button should only be active if the import app is available,
   * otherwise show an error. */
  if (0 == g_strcmp0 ("x-content/image-dcf", priv->mime_type))
  {
    mx_button_set_label (MX_BUTTON (priv->import), _("Import photos"));
  } else {
    mx_button_set_label (MX_BUTTON (priv->import), _("Import media"));
  }

  return (GObject *) self;
}