Exemplo n.º 1
0
static void
mpl_content_pane_init (MplContentPane *self)
{
  MplContentPanePrivate *priv = GET_PRIVATE (self);

  mx_box_layout_set_orientation (MX_BOX_LAYOUT (self), MX_ORIENTATION_VERTICAL);
  mx_box_layout_set_spacing (MX_BOX_LAYOUT (self), 6);

  priv->header = (MxBoxLayout *) mx_box_layout_new ();
  mx_box_layout_set_spacing (priv->header, 12);
  mx_stylable_set_style_class (MX_STYLABLE (priv->header), "header");
  clutter_actor_set_height ((ClutterActor *) priv->header, 36);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (self),
                              CLUTTER_ACTOR (priv->header), 0);
  clutter_container_child_set (CLUTTER_CONTAINER (self),
                               (ClutterActor *) priv->header,
                               "expand", FALSE,
                               "x-fill", TRUE,
                               "y-fill", TRUE,
                               NULL);

  priv->title = (MxLabel *) mx_label_new ();
  mx_stylable_set_style_class (MX_STYLABLE (priv->title), "title");
  mx_box_layout_insert_actor (priv->header, (ClutterActor *) priv->title, 0);
  clutter_container_child_set (CLUTTER_CONTAINER (priv->header),
                               (ClutterActor *) priv->title,
                               "expand", TRUE,
                               "x-fill", TRUE,
                               "y-fill", FALSE,
                               NULL);
}
Exemplo n.º 2
0
static void
mex_queue_button_init (MexQueueButton *self)
{
  ClutterActor *temp_text;

  self->priv = QUEUE_BUTTON_PRIVATE (self);

  self->priv->inner_box = mx_box_layout_new ();
  self->priv->icon = mx_icon_new ();
  self->priv->label = mx_label_new_with_text ("Unknown queue state");
  self->priv->spinner = mx_spinner_new ();
  self->priv->queue_model = mex_queue_model_dup_singleton ();

  g_signal_connect (self->priv->spinner,
                    "looped",
                    (GCallback)_spinner_looped_cb,
                    self);

  clutter_container_add (CLUTTER_CONTAINER (self->priv->inner_box),
                         self->priv->label,
                         self->priv->icon,
                         self->priv->spinner,
                         NULL);

  clutter_container_child_set (CLUTTER_CONTAINER (self->priv->inner_box),
                               self->priv->label,
                               "expand", TRUE,
                               "y-align", MX_ALIGN_MIDDLE,
                               "y-fill", FALSE,
                               NULL);

  clutter_container_child_set (CLUTTER_CONTAINER (self->priv->inner_box),
                               self->priv->icon,
                               "y-align", MX_ALIGN_MIDDLE,
                               "y-fill", FALSE,
                               "x-align", MX_ALIGN_END,
                               NULL);

  clutter_container_child_set (CLUTTER_CONTAINER (self->priv->inner_box),
                               self->priv->spinner,
                               "y-align", MX_ALIGN_MIDDLE,
                               "y-fill", FALSE,
                               "x-align", MX_ALIGN_END,
                               NULL);

  clutter_actor_hide (self->priv->spinner);

  mx_bin_set_child (MX_BIN (self), self->priv->inner_box);
  mx_bin_set_fill (MX_BIN (self), TRUE, FALSE);

  temp_text = mx_label_get_clutter_text (MX_LABEL (self->priv->label));
  clutter_text_set_ellipsize (CLUTTER_TEXT (temp_text), PANGO_ELLIPSIZE_NONE);

  g_signal_connect (self,
                    "notify::toggled",
                    (GCallback)_queue_button_notify_toggled_cb,
                    self);

  mx_button_set_is_toggle (MX_BUTTON (self), TRUE);
}
Exemplo n.º 3
0
static void
button_release_event (ClutterActor *actor, ClutterButtonEvent *event,
                      ClutterContainer *box)
{
  gboolean xfill, yfill;
  gint xalign, yalign;

  if (event->button == 1)
    {
      clutter_container_child_get (box, actor,
                                   "x-fill", &xfill,
                                   "y-fill", &yfill,
                                   NULL);

      clutter_container_child_set (box, actor,
                                   "x-fill", !xfill,
                                   "y-fill", !yfill,
                                   NULL);
    }
  else if (event->button == 3)
    {
      clutter_container_child_get (box, actor,
                                   "x-align", &xalign,
                                   "y-align", &yalign,
                                   NULL);

      if (xalign < 2)
        xalign++;
      else
        xalign = 0;

      if (yalign < 2)
        yalign++;
      else
        yalign = 0;

      clutter_container_child_set (box, actor,
                                   "x-align", xalign,
                                   "y-align", yalign,
                                   NULL);
    }
  else if (event->button == 2)
    {
      gboolean expand;
      clutter_container_child_get (box, actor, "expand", &expand, NULL);

      clutter_container_child_set (box, actor, "expand", !expand, NULL);
    }
}
Exemplo n.º 4
0
/**
 * mpl_content_pane_set_header_actor:
 * @self: #MplContentPane
 * @actor: #ClutterActor or %NULL
 *
 * Sets the pane header actor. The header actor is an optional actor inserted
 * into the header and packed from its right edge. It can be used, for example,
 * to add a close button to the pane.
 */
void
mpl_content_pane_set_header_actor (MplContentPane *self,
                                   ClutterActor   *actor)
{
  MplContentPanePrivate *priv = GET_PRIVATE (self);

  g_return_if_fail (MPL_IS_CONTENT_PANE (self));

  if (actor != priv->header_actor)
  {
    if (priv->header_actor)
    {
      clutter_actor_destroy (priv->header_actor);
      priv->header_actor = NULL;
    }

    if (actor)
    {
      clutter_actor_add_child (CLUTTER_ACTOR (priv->header), actor);
      clutter_container_child_set (CLUTTER_CONTAINER (priv->header), actor,
                                   "expand", FALSE,
                                   "x-align", MX_ALIGN_END,
                                   "x-fill", TRUE,
                                   NULL);
      priv->header_actor = actor;
    }

    g_object_notify (G_OBJECT (self), "header-actor");
  }
}
Exemplo n.º 5
0
static void
mpd_fs_pane_init (MpdFsPane *self)
{
  ClutterActor  *tile;

  self->priv = FS_PANEL_PRIVATE (self);

  mx_box_layout_set_orientation (MX_BOX_LAYOUT (self), MX_ORIENTATION_VERTICAL);
  mx_box_layout_set_spacing (MX_BOX_LAYOUT (self), 21);
  clutter_actor_set_width (CLUTTER_ACTOR (self), MPD_PANE_WIDTH);

  tile = mpd_disk_tile_new ();
  clutter_container_add_actor (CLUTTER_CONTAINER (self), tile);

  tile = mpd_folder_tile_new ();
  clutter_actor_set_width (tile,  MPD_FOLDER_TILE_WIDTH);
  g_signal_connect (tile, "request-hide",
                    G_CALLBACK (_tile_request_hide_cb), self);
  clutter_container_add_actor (CLUTTER_CONTAINER (self), tile);
  clutter_container_child_set (CLUTTER_CONTAINER (self), tile,
                               "expand", TRUE,
                               "x-fill", TRUE,
                               "y-fill", TRUE,
                               NULL);
}
Exemplo n.º 6
0
static void
mex_column_view_init (MexColumnView *self)
{
  MexColumnViewPrivate *priv = self->priv = COLUMN_VIEW_PRIVATE (self);

  /* Begin private children */
  clutter_actor_push_internal (CLUTTER_ACTOR (self));

  /* Create the header */
  priv->header = mx_box_layout_new ();
  mx_box_layout_set_orientation ((MxBoxLayout *) priv->header,
                                 MX_ORIENTATION_HORIZONTAL);

  clutter_actor_push_internal (CLUTTER_ACTOR (self));
  clutter_actor_set_parent (priv->header, CLUTTER_ACTOR (self));
  clutter_actor_pop_internal (CLUTTER_ACTOR (self));

  priv->button = mx_button_new ();
  mx_stylable_set_style_class (MX_STYLABLE (priv->button), "Header");
  priv->label = mx_label_new ();
  g_object_set (priv->label, "clip-to-allocation", TRUE, "fade-out", TRUE,
                NULL);

  clutter_actor_add_child (CLUTTER_ACTOR (priv->button), priv->label);

  clutter_actor_add_child (priv->header, priv->button);
  clutter_container_child_set (CLUTTER_CONTAINER (priv->header), priv->button,
                               "expand", TRUE,
                               "x-fill", TRUE,
                               "x-align", MX_ALIGN_START,
                               "y-fill", TRUE,
                               NULL);

  g_signal_connect (priv->button, "clicked",
                    G_CALLBACK (mex_column_header_clicked_cb), self);


  priv->scroll = mex_scroll_view_new ();
  mx_kinetic_scroll_view_set_scroll_policy (MX_KINETIC_SCROLL_VIEW (priv->scroll),
                                            MX_SCROLL_POLICY_VERTICAL);
  mex_scroll_view_set_indicators_hidden (MEX_SCROLL_VIEW (priv->scroll),
                                         TRUE);
  clutter_actor_set_parent (priv->scroll, CLUTTER_ACTOR (self));

  priv->column = mex_column_new ();
  clutter_actor_add_child (CLUTTER_ACTOR (priv->scroll), priv->column);

  g_signal_connect (priv->column, "notify::opened",
                    G_CALLBACK (mex_column_view_opened_cb), self);

  /* End of private children */
  clutter_actor_pop_internal (CLUTTER_ACTOR (self));

  /* Set the column as reactive and enable collapsing */
  clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE);
}
Exemplo n.º 7
0
static
gboolean
action_set_dynamic (ClutterActor *action,
                    ClutterEvent *event,
                    gpointer      userdata)
{
  ClutterActor *actor;
  ClutterBox2D *box2d;

  actor = CLUTTER_ACTOR (userdata);
  box2d = CLUTTER_BOX2D (clutter_actor_get_parent (actor));

  clutter_container_child_set (CLUTTER_CONTAINER (box2d),
                               actor, "mode", CLUTTER_BOX2D_DYNAMIC, NULL);
  clutter_container_child_set (CLUTTER_CONTAINER (box2d),
                               actor, "manipulatable", TRUE, NULL);

  return FALSE;
}
Exemplo n.º 8
0
static void
toggle_editable_cb (MxPathBar *bar)
{
  ClutterActor *parent = clutter_actor_get_parent (CLUTTER_ACTOR (bar));
  gboolean editable = !mx_path_bar_get_editable (bar);
  mx_path_bar_set_editable (bar, editable);
  if (MX_IS_BIN (parent))
    mx_bin_set_fill (MX_BIN (parent), editable, FALSE);
  else if (MX_IS_BOX_LAYOUT (parent))
    clutter_container_child_set (CLUTTER_CONTAINER (parent),
                                 CLUTTER_ACTOR (bar),
                                 "x-fill", editable,
                                 NULL);
}
Exemplo n.º 9
0
static void
mpd_folder_button_init (MpdFolderButton *self)
{
  MpdFolderButtonPrivate *priv = GET_PRIVATE (self);
  ClutterActor  *vbox;
  ClutterText   *text;

  /* Box */
  vbox = mx_box_layout_new ();
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (vbox), MX_ORIENTATION_VERTICAL);
  mx_bin_set_child (MX_BIN (self), vbox);

  /* Icon */
  priv->icon = clutter_texture_new ();
  clutter_texture_set_sync_size (CLUTTER_TEXTURE (priv->icon), true);
  clutter_container_add_actor (CLUTTER_CONTAINER (vbox), priv->icon);
  clutter_container_child_set (CLUTTER_CONTAINER (vbox), priv->icon,
                               "expand", false,
                               "x-align", MX_ALIGN_MIDDLE,
                               "x-fill", false,
                               "y-align", MX_ALIGN_START,
                               "y-fill", false,
                               NULL);

  /* Label */
  priv->label = mx_label_new ();
  text = (ClutterText *) mx_label_get_clutter_text (MX_LABEL (priv->label));
  clutter_text_set_line_wrap_mode (text, PANGO_WRAP_WORD_CHAR);
  clutter_container_add_actor (CLUTTER_CONTAINER (vbox), priv->label);
  clutter_container_child_set (CLUTTER_CONTAINER (vbox), priv->label,
                               "expand", false,
                               "x-align", MX_ALIGN_MIDDLE,
                               "x-fill", false,
                               "y-align", MX_ALIGN_START,
                               "y-fill", false,
                               NULL);
}
Exemplo n.º 10
0
static void
_update_layout (PengeGridView *grid_view)
{
  PengeGridViewPrivate *priv = GET_PRIVATE (grid_view);

    clutter_container_child_set (CLUTTER_CONTAINER (grid_view),
                                 priv->everything_pane,
                                 "row-span", 1,
                                 "column", 0,
                                 "x-expand", TRUE,
                                 "x-fill", TRUE,
                                 "y-expand", TRUE,
                                 "y-fill", TRUE,
                                 NULL);

    clutter_actor_queue_relayout (CLUTTER_ACTOR (grid_view));
}
Exemplo n.º 11
0
static void
add_static_box (ClutterActor *group,
                gint          x,
                gint          y,
                gint          width,
                gint          height)
{
  ClutterActor *box;
  box = clutter_rectangle_new ();
  clutter_actor_set_size (box, width, height);
  clutter_actor_set_position (box, x, y);
  clutter_group_add (CLUTTER_GROUP (group), box);


  clutter_container_child_set (CLUTTER_CONTAINER (group), box,
                               "mode", CLUTTER_BOX2D_STATIC, NULL);

}
Exemplo n.º 12
0
ClutterActor *
add_hand (ClutterActor *group,
          gint          x,
          gint          y)
{
  ClutterActor     *actor;

  actor = clutter_texture_new_from_file (ASSETS_DIR "redhand.png", NULL);
  clutter_group_add (CLUTTER_GROUP (group), actor);

  clutter_actor_set_opacity (actor, 1.0 * 255);
  clutter_actor_set_position (actor, x, y);

  clutter_container_child_set (CLUTTER_CONTAINER (group), actor,
                               "manipulatable", TRUE,
                               "mode", CLUTTER_BOX2D_DYNAMIC, NULL);
  return actor;
}
Exemplo n.º 13
0
static
gboolean
action_set_linear_velocity (ClutterActor *action,
                            ClutterEvent *event,
                            gpointer      userdata)
{
  ClutterActor *actor;
  ClutterBox2D *box2d;
  ClutterVertex velocity = {  (150.0f),
                              (-150.0f) };
  actor = CLUTTER_ACTOR (userdata);
  box2d = CLUTTER_BOX2D (clutter_actor_get_parent (actor));

  clutter_container_child_set (CLUTTER_CONTAINER (box2d),
                               actor, "linear-velocity", &velocity, NULL);

  return TRUE;
}
Exemplo n.º 14
0
static void
add_actor (ClutterContainer *container)
{
  ClutterActor *rect;
  ClutterColor color = { 0xff, 0xff, 0xff, 255 };
  static gboolean expand = TRUE;

  clutter_color_from_hls (&color,
                          g_random_double_range (0.0, 360.0), 0.5, 0.5);

  rect = clutter_rectangle_new_with_color (&color);
  clutter_actor_set_size (rect, 32, 64);
  clutter_container_add_actor (container, rect);
  clutter_actor_set_reactive (rect, TRUE);
  g_signal_connect (rect, "enter-event", G_CALLBACK (enter_event), NULL);
  g_signal_connect (rect, "leave-event", G_CALLBACK (leave_event), NULL);
  g_signal_connect (rect, "button-release-event",
                    G_CALLBACK (button_release_event), container);

  clutter_container_child_set (container, rect, "expand", expand, NULL);
  expand = !expand;
}
static void
penge_count_tile_set_compact (PengeCountTile *self,
                              gboolean        compact)
{
  PengeCountTilePrivate *priv = self->priv;

  if (priv->compact == compact)
    return;

  priv->compact = compact;
  if (compact)
  {
    clutter_actor_set_width (CLUTTER_ACTOR (self), -1);
    
    g_object_ref (priv->count_label);
    clutter_container_remove_actor (CLUTTER_CONTAINER (priv->table),
                                    priv->count_label);
    clutter_actor_unparent (priv->count_label);
    clutter_actor_add_child ((self), priv->count_label);

    penge_count_tile_update_tooltip (self);
  }
  else
  {
    clutter_actor_set_width (CLUTTER_ACTOR (self), 280);
    clutter_actor_reparent (priv->count_label, priv->table);
    clutter_container_child_set (CLUTTER_CONTAINER (priv->table),
                                 priv->count_label,
                                 "column", 0,
                                 "row", 0,
                                 "row-span", 2,
                                 "x-expand", FALSE,
                                 NULL);
    clutter_actor_add_child ((self), priv->table);

    mx_widget_set_tooltip_text (MX_WIDGET (self), NULL);
  }
}
Exemplo n.º 16
0
static gboolean
action_add_circle (ClutterActor *action,
                   ClutterEvent *event,
                   gpointer      userdata)
{
  const ClutterColor transparent = { 0x00, 0x00, 0x00, 0x01 };
  ClutterActor *group = CLUTTER_ACTOR (userdata);
  ClutterActor *box;

  box = clutter_rectangle_new_with_color (&transparent);
  clutter_actor_set_size (box, 50, 50);
  clutter_actor_set_position (box, event->button.x, event->button.y);
  clutter_group_add (CLUTTER_GROUP (group), box);

  clutter_container_child_set (CLUTTER_CONTAINER (group),
                               box,
                               "is-circle", TRUE,
                               NULL);
  g_signal_connect (box, "paint",
                    G_CALLBACK (paint_circle), NULL);

  return FALSE;
}
static void
mpd_devices_pane_init (MpdDevicesPane *self)
{
  ClutterActor  *label;
  ClutterActor  *tile;

  mx_box_layout_set_orientation (MX_BOX_LAYOUT (self), MX_ORIENTATION_VERTICAL);
  clutter_actor_set_width (CLUTTER_ACTOR (self), MPD_DEVICES_PANE_WIDTH);

  label = mx_label_new_with_text (_("Other devices"));
  clutter_actor_set_name (label, "pane-label");
  clutter_container_add_actor (CLUTTER_CONTAINER (self), label);

  tile = mpd_devices_tile_new ();
  g_signal_connect (tile, "request-hide",
                    G_CALLBACK (_tile_request_hide_cb), self);
  g_signal_connect (tile, "request-show",
                    G_CALLBACK (_tile_request_show_cb), self);
  clutter_container_add_actor (CLUTTER_CONTAINER (self), tile);
  clutter_container_child_set (CLUTTER_CONTAINER (self), tile,
                               "expand", true,
                               NULL);
}
void
mnp_clock_area_add_tile (MnpClockArea *area, MnpClockTile *tile)
{

	clutter_actor_set_reactive ((ClutterActor *)tile, TRUE);
	clutter_actor_set_name ((ClutterActor *)tile, "ClockTile");
	clutter_container_add_actor ((ClutterContainer *)clutter_stage_get_default(), (ClutterActor *)tile);
	mx_draggable_set_axis (MX_DRAGGABLE (tile), MX_DRAG_AXIS_Y);
	mx_draggable_enable ((MxDraggable *)tile);
	clutter_actor_set_size ((ClutterActor *)tile, 230, 75);
	clutter_actor_set_depth ((ClutterActor *)tile, area->priv->position);
	area->priv->position += 0.05;
	clutter_actor_reparent ((ClutterActor *)tile, (ClutterActor *)area);
  	clutter_container_child_set (CLUTTER_CONTAINER (area),
                               (ClutterActor *)tile,
                               "expand", FALSE,
			       "y-fill", FALSE,
			       "x-fill", TRUE,
                               NULL);	
	g_ptr_array_add (area->priv->clock_tiles, tile);
	mnp_clock_tile_set_remove_cb (tile, (TileRemoveFunc)mnp_clock_tile_removed, (gpointer)area);

	g_signal_connect (tile, "drag-y-pos", G_CALLBACK(tile_drag_run), area);
}
Exemplo n.º 19
0
static void
penge_apps_pane_update (PengeAppsPane *pane)
{
  PengeAppsPanePrivate *priv = GET_PRIVATE (pane);
  GList *bookmarks, *l, *to_remove;
  ClutterActor *actor;
  gint count = 0;
  gchar *path;
  GError *error = NULL;
  const gchar *uri = NULL;

  bookmarks = mpl_app_bookmark_manager_get_bookmarks (priv->manager);

  to_remove = g_hash_table_get_keys (priv->uris_to_actors);

  for (l = bookmarks; l && count < MAX_COUNT; l = l->next)
  {
    uri = (gchar *)l->data;

    actor = g_hash_table_lookup (priv->uris_to_actors,
                                 uri);

    /* Check if this URI is on the system */
    path = g_filename_from_uri (uri, NULL, &error);

    if (error)
    {
      g_warning (G_STRLOC ": Error converting uri to path: %s",
                 error->message);
      g_clear_error (&error);

      if (actor)
      {
        clutter_container_remove_actor (CLUTTER_CONTAINER (pane),
                                        actor);
      }

      continue;
    }

    if (!g_file_test (path, G_FILE_TEST_EXISTS))
    {
      /* skip those that have a missing .desktop file */
      g_free (path);
      continue;
    }

    g_free (path);

    if (actor)
    {
      if (!priv->vertical)
      {
        clutter_container_child_set (CLUTTER_CONTAINER (pane),
                                     actor,
                                     "row",
                                     count / ROW_SIZE,
                                     "column",
                                     count % ROW_SIZE,
                                     NULL);
      } else {
        clutter_container_child_set (CLUTTER_CONTAINER (pane),
                                     actor,
                                     "row",
                                     count / 1,
                                     "column",
                                     count % 1,
                                     NULL);
      }
    } else {
      actor = g_object_new (PENGE_TYPE_APP_TILE,
                            "bookmark",
                            uri,
                            NULL);
      if (!priv->vertical)
      {
        mx_table_add_actor (MX_TABLE (pane),
                            actor,
                            count / ROW_SIZE,
                            count % ROW_SIZE);
      } else {
        mx_table_add_actor (MX_TABLE (pane),
                            actor,
                            count / 1,
                            count % 1);
      }
      clutter_container_child_set (CLUTTER_CONTAINER (pane),
                                   actor,
                                   "x-expand", TRUE,
                                   "y-expand", TRUE,
                                   "x-fill", FALSE,
                                   "y-fill", FALSE,
                                   NULL);
      g_hash_table_insert (priv->uris_to_actors,
                           g_strdup (uri),
                           actor);
    }

    /* Found, so don't remove */
    /* This craziness is because the allocated string is probably different */
    to_remove = g_list_delete_link (to_remove,
                                    g_list_find_custom (to_remove,
                                                        uri,
                                                        (GCompareFunc)g_strcmp0));
    count++;
  }

  g_list_free (bookmarks);

  for (l = to_remove; l; l = g_list_delete_link (l, l))
  {
    actor = g_hash_table_lookup (priv->uris_to_actors,
                                 (gchar *)(l->data));
    clutter_container_remove_actor (CLUTTER_CONTAINER (pane),
                                    actor);
    g_hash_table_remove (priv->uris_to_actors, (gchar *)(l->data));
  }
}
static void
_update_layout (PengeGridView *grid_view)
{
  PengeGridViewPrivate *priv = GET_PRIVATE (grid_view);
  gint col = 0;

  if (priv->vertical_apps)
  {
    clutter_container_child_set (CLUTTER_CONTAINER (grid_view),
                                 priv->favourite_apps_pane,
                                 "column", col,
                                 "row", 1,
                                 "y-expand", TRUE,
                                 "y-fill", FALSE,
                                 "y-align", MX_ALIGN_START,
                                 "x-align", MX_ALIGN_START,
                                 "x-expand", FALSE,
                                 "x-fill", FALSE,
                                 NULL);

    if (priv->show_calendar_pane)
    {
      col++;

      clutter_actor_show (priv->calendar_pane);
      clutter_container_child_set (CLUTTER_CONTAINER (grid_view),
                                   priv->calendar_pane,
                                   "column", col,
                                   "x-expand", FALSE,
                                   "y-fill", FALSE,
                                   "y-align", MX_ALIGN_START,
                                   NULL);
    } else {
      clutter_actor_hide (priv->calendar_pane);
    }

    if (priv->show_email_pane)
    { 
      clutter_actor_show (priv->email_pane);
      clutter_container_child_set (CLUTTER_CONTAINER (grid_view),
                                   priv->email_pane,
                                   "column", col,
                                   "y-expand", TRUE,
                                   "y-fill", FALSE,
                                   "y-align", MX_ALIGN_END,
                                   "x-align", MX_ALIGN_MIDDLE,
                                   "x-expand", FALSE,
                                   "x-fill", FALSE,
                                   NULL);
      col++;
    } else {
      clutter_actor_hide (priv->email_pane);
    }


    clutter_container_child_set (CLUTTER_CONTAINER (grid_view),
                                 priv->div_tex,
                                 "row-span", 1,
                                 "column", col,
                                 "x-expand", FALSE,
                                 NULL);

    col++;

    clutter_container_child_set (CLUTTER_CONTAINER (grid_view),
                                 priv->everything_pane,
                                 "row-span", 1,
                                 "column", col,
                                 "x-expand", TRUE,
                                 "x-fill", TRUE,
                                 "y-expand", TRUE,
                                 "y-fill", TRUE,
                                 NULL);

    if (priv->show_email_pane)
    {
      clutter_container_child_set (CLUTTER_CONTAINER (grid_view),
                                   priv->everything_pane,
                                   "row-span", 2,
                                   NULL);
      clutter_container_child_set (CLUTTER_CONTAINER (grid_view),
                                   priv->div_tex,
                                   "row-span", 2,
                                   NULL);
    } else {
      clutter_container_child_set (CLUTTER_CONTAINER (grid_view),
                                   priv->everything_pane,
                                   "row-span", 1,
                                   NULL);
      clutter_container_child_set (CLUTTER_CONTAINER (grid_view),
                                   priv->div_tex,
                                   "row-span", 1,
                                   NULL);
    }

    g_object_set (priv->favourite_apps_pane,
                  "vertical", TRUE,
                  NULL);

    if (!priv->show_calendar_pane)
      g_object_set (priv->email_pane,
                    "vertical", TRUE,
                    NULL);
    else
      g_object_set (priv->email_pane,
                    "vertical", FALSE,
                    NULL);

    clutter_actor_queue_relayout (CLUTTER_ACTOR (grid_view));
  } else {
    if (priv->show_calendar_pane)
    {
      clutter_actor_show (priv->calendar_pane);
      clutter_container_child_set (CLUTTER_CONTAINER (grid_view),
                                   priv->calendar_pane,
                                   "column", col,
                                   "x-expand", FALSE,
                                   "y-expand", FALSE,
                                   "y-fill", FALSE,
                                   NULL);
    } else {
      clutter_actor_hide (priv->calendar_pane);
    }

    if (priv->show_email_pane)
    {
      clutter_actor_show (priv->email_pane);
      clutter_container_child_set (CLUTTER_CONTAINER (grid_view),
                                   priv->email_pane,
                                   "column", col,
                                   "x-expand", FALSE,
                                   "y-expand", TRUE,
                                   "y-fill", FALSE,
                                   "y-align", MX_ALIGN_END,
                                   NULL);
    } else {
      clutter_actor_hide (priv->email_pane);
    }


    clutter_container_child_set (CLUTTER_CONTAINER (grid_view),
                                 priv->favourite_apps_pane,
                                 "column", col,
                                 "row", 3,
                                 "x-expand", FALSE,
                                 "x-fill", TRUE,
                                 "y-fill", FALSE,
                                 "y-align", MX_ALIGN_END,
                                 NULL);

    /* If we are showing the email then it is responsible for expanding to fill
     * the area. Otherwise the favourites app pane is responsible.
     */
    clutter_container_child_set (CLUTTER_CONTAINER (grid_view),
                                 priv->favourite_apps_pane,
                                 "y-expand", !priv->show_email_pane,
                                 NULL);

    col++;
    clutter_container_child_set (CLUTTER_CONTAINER (grid_view),
                                 priv->div_tex,
                                 "row-span", 3,
                                 "column", col,
                                 "x-expand", FALSE,
                                 NULL);
    col++;
    clutter_container_child_set (CLUTTER_CONTAINER (grid_view),
                                 priv->everything_pane,
                                 "row-span", 3,
                                 "column", col,
                                 "x-expand", TRUE,
                                 "x-fill", TRUE,
                                 "y-expand", TRUE,
                                 "y-fill", TRUE,
                                 NULL);
    g_object_set (priv->favourite_apps_pane,
                  "vertical", FALSE,
                  NULL);
    g_object_set (priv->email_pane,
                  "vertical", FALSE,
                  NULL);
    clutter_actor_queue_relayout (CLUTTER_ACTOR (grid_view));
  }
}
Exemplo n.º 21
0
static gboolean
key_release_cb (ClutterActor    *actor,
                ClutterKeyEvent *event,
                MxBoxLayout   *box)
{

  if (event->keyval == 'v')
    {
      mx_box_layout_set_orientation (box,
                                     !mx_box_layout_get_orientation (box));
    }

  if (event->keyval == '=')
    {
      add_actor ((ClutterContainer*) box);
    }

  if (event->keyval == '-')
    {
      ClutterActor *child = NULL;

      clutter_container_foreach (CLUTTER_CONTAINER (box), (ClutterCallback) find_last_child, &child);

      if (child)
        clutter_container_remove_actor (CLUTTER_CONTAINER (box), child);
    }

  if (event->keyval == 'c')
    {
      gboolean clip;

      g_object_get (actor, "clip-to-allocation", &clip, NULL);
      g_object_set (actor, "clip-to-allocation", !clip, NULL);
    }

  if (event->keyval == 's')
    {
      guint spacing;

      spacing = mx_box_layout_get_spacing (box);

      if (spacing > 6)
        spacing = 0;
      else
        spacing++;

      mx_box_layout_set_spacing (box, spacing);
    }

  if (event->keyval == 'e')
    {
      if (hover_actor)
        {
          gboolean expand;
          clutter_container_child_get ((ClutterContainer*) box, hover_actor,
                                       "expand", &expand, NULL);
          clutter_container_child_set ((ClutterContainer*) box, hover_actor,
                                       "expand", !expand, NULL);
        }
    }

  if (event->keyval == 'a')
    {
      mx_box_layout_set_enable_animations (box,
                                           !mx_box_layout_get_enable_animations (box));
    }

  return FALSE;
}
Exemplo n.º 22
0
void
scene_chain (Scene *scene)
{
  ClutterActor *stage;
  ClutterActor *group;
  ClutterActor *box;

  stage = clutter_stage_get_default ();

  group = clutter_box2d_new ();
  clutter_group_add (CLUTTER_GROUP (stage), group);
  scene->group = group;

  add_cage (group, TRUE);

  {
    gint          i;
    gint          y;
    gint          numlinks = 32;
    ClutterActor *prev_actor;

    y = 50;
    box = clutter_rectangle_new ();
    clutter_actor_set_size (box, 18, 5);
    clutter_actor_set_position (box, clutter_actor_get_width(stage)/2, y);
    clutter_group_add (CLUTTER_GROUP (group), box);

    clutter_container_child_set (CLUTTER_CONTAINER (group), box,
                                 "mode", CLUTTER_BOX2D_STATIC, NULL);

    prev_actor = box;

    numlinks = clutter_actor_get_height (stage)/20;
    if (clutter_actor_get_width (stage)/20 < numlinks)
      {
        numlinks = clutter_actor_get_width (stage)/20;
      }

    for (i = 0; i < numlinks; ++i)
      {
        box = clutter_rectangle_new ();
        clutter_actor_set_size (box, 18, 5);
        clutter_actor_set_position (box, 20 + 20 * i, y+=1);
        clutter_group_add (CLUTTER_GROUP (group), box);

        clutter_container_child_set (CLUTTER_CONTAINER (group), box,
                                       "manipulatable", TRUE,
                                     "mode", CLUTTER_BOX2D_DYNAMIC, NULL);

        {
          ClutterVertex anchor1 = {  (18.0),
                                     (0.0) };
          ClutterVertex anchor2 = {  (0.0),
                                     (0.0) };
          clutter_box2d_add_revolute_joint (CLUTTER_BOX2D (group),
                                            prev_actor, box,
                                            &anchor1,
                                            &anchor2);
        }

        prev_actor = box;
      }
  }

  clutter_box2d_set_simulating (CLUTTER_BOX2D (group), simulating);
}
Exemplo n.º 23
0
Arquivo: mx-button.c Projeto: danni/mx
static void
mx_button_update_contents (MxButton *self)
{
  MxButtonPrivate *priv = self->priv;
  ClutterActor *child;
  gboolean icon_visible, label_visible;
  const gchar *text;

  /* If the icon doesn't have a name set, treat it as
   * not-visible.
   */
  if (priv->icon_visible && mx_icon_get_icon_name (MX_ICON (priv->icon)))
    icon_visible = TRUE;
  else
    icon_visible = FALSE;

  text = clutter_text_get_text (CLUTTER_TEXT (priv->label));

  if (priv->label_visible && text && (strcmp (text, "") != 0))
    label_visible = TRUE;
  else
    label_visible = FALSE;

  /* replace any custom content */
  child = mx_bin_get_child (MX_BIN (self));

  if (child != priv->hbox)
    mx_bin_set_child (MX_BIN (self), priv->hbox);

  /* Handle the simple cases first */
  if (!icon_visible && !label_visible)
    {
      clutter_actor_hide (priv->hbox);
      return;
    }

  /* ensure the hbox is visible */
  clutter_actor_show (priv->hbox);

  if (icon_visible && !label_visible)
    {
      clutter_actor_show (priv->icon);
      clutter_actor_hide (priv->label);
      clutter_actor_set_child_below_sibling (priv->hbox, priv->icon, NULL);
      return;
    }

  if (!icon_visible && label_visible)
    {
      clutter_actor_hide (priv->icon);
      clutter_actor_show (priv->label);
      clutter_actor_set_child_below_sibling (priv->hbox, priv->label, NULL);
      return;
    }

  /* Both the icon and text are visible, handle this case */
  clutter_actor_show (priv->icon);
  clutter_actor_show (priv->label);

  switch (priv->icon_position)
    {
    case MX_POSITION_TOP:
      mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->hbox),
                                     MX_ORIENTATION_VERTICAL);
      clutter_actor_set_child_below_sibling (priv->hbox, priv->icon, NULL);

      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->label, "x-align", MX_ALIGN_MIDDLE,
                                   "y-align", MX_ALIGN_END, NULL);
      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->icon, "x-align", MX_ALIGN_MIDDLE,
                                   "y-align", MX_ALIGN_START, NULL);
      break;

    case MX_POSITION_RIGHT:
      mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->hbox),
                                     MX_ORIENTATION_HORIZONTAL);
      clutter_actor_set_child_above_sibling (priv->hbox, priv->icon, NULL);

      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->label, "x-align", MX_ALIGN_START,
                                   "y-align", MX_ALIGN_MIDDLE, NULL);
      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->icon, "x-align", MX_ALIGN_END,
                                   "y-align", MX_ALIGN_MIDDLE, NULL);
      break;

    case MX_POSITION_BOTTOM:
      mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->hbox),
                                     MX_ORIENTATION_VERTICAL);
      clutter_actor_set_child_above_sibling (priv->hbox, priv->icon, NULL);

      mx_box_layout_child_set_x_align (MX_BOX_LAYOUT (priv->hbox),
                                       priv->label, MX_ALIGN_MIDDLE);
      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->label, "x-align", MX_ALIGN_MIDDLE,
                                   "y-align", MX_ALIGN_START, NULL);
      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->icon, "x-align", MX_ALIGN_MIDDLE,
                                   "y-align", MX_ALIGN_END, NULL);
      break;

    case MX_POSITION_LEFT:
      mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->hbox),
                                     MX_ORIENTATION_HORIZONTAL);
      clutter_actor_set_child_below_sibling (priv->hbox, priv->icon, NULL);

      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->label, "x-align", MX_ALIGN_END,
                                   "y-align", MX_ALIGN_MIDDLE, NULL);
      clutter_container_child_set (CLUTTER_CONTAINER (priv->hbox),
                                   priv->icon, "x-align", MX_ALIGN_START,
                                   "y-align", MX_ALIGN_MIDDLE, NULL);
      break;
    }
}
Exemplo n.º 24
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);
    }
}
Exemplo n.º 25
0
static void
_zeitgeist_log_find_received (GObject *source_object,
                              GAsyncResult *res,
                              gpointer user_data)
{
  ZeitgeistLog *log = ZEITGEIST_LOG (source_object);
  PengeEverythingPane *pane = user_data;
  PengeEverythingPanePrivate *priv;
  GList *sw_items, *recent_file_items, *l;
  ZeitgeistResultSet *set = NULL;
  GList *old_actors = NULL;
  ClutterActor *actor;
  gboolean show_welcome_tile = TRUE;
  gint recent_files_count, sw_items_count;
  GError *error = NULL;

  g_return_if_fail (PENGE_IS_EVERYTHING_PANE (user_data));

  priv = GET_PRIVATE (pane);

  set = zeitgeist_log_find_events_finish (log, res, &error);
  if (error != NULL)
    {
      g_warning (G_STRLOC ": Error obtaining recent files: %s",
          error->message);
      g_clear_error (&error);
    }

  /* It actually moves the interesting events into a list */
  recent_file_items = _filter_out_unshowable_recent_items (pane, set);
  recent_file_items = g_list_sort (recent_file_items,
                                   (GCompareFunc)_recent_files_sort_func);

  /* Get Sw items */
  sw_items = g_hash_table_get_values (priv->uuid_to_sw_items);
  sw_items = g_list_sort (sw_items,
                          (GCompareFunc)_sw_item_sort_compare_func);

  recent_files_count = priv->block_count * priv->ratio;

  if (recent_files_count > g_list_length (recent_file_items))
    recent_files_count = g_list_length (recent_file_items);

  sw_items_count = priv->block_count - recent_files_count;

  old_actors = g_hash_table_get_values (priv->pointer_to_actor);

  if (sw_items != NULL || recent_file_items != NULL)
  {
    if (priv->welcome_tile)
    {
      clutter_container_remove_actor (CLUTTER_CONTAINER (pane),
                                      priv->welcome_tile);
      priv->welcome_tile = NULL;
    }
  }

  while ((sw_items_count && sw_items) ||
         (recent_files_count && recent_file_items))
  {
    SwItem *sw_item = NULL;
    ZeitgeistEvent *recent_file_event = NULL;

    /* If no sw items -> force compare to favour recent file */
    if (sw_items_count && sw_items)
      sw_item = (SwItem *)sw_items->data;
    else
      sw_item = NULL;

    /* If no recent files -> force compare to favour sw stuff */
    if (recent_files_count && recent_file_items)
      recent_file_event = recent_file_items->data;
    else
      recent_file_event = NULL;

    if (_compare_item_and_event (sw_item, recent_file_event) < 1)
    {
      /* Sw item is newer */

      actor = g_hash_table_lookup (priv->pointer_to_actor,
                                   sw_item);
      if (!actor)
      {
        actor = _add_from_sw_item (pane, sw_item);
        g_hash_table_insert (priv->pointer_to_actor,
                             sw_item,
                             actor);

        /* Needed to remove from hash when we kill the actor */
        g_object_set_data (G_OBJECT (actor), "data-pointer", sw_item);
      }

      sw_items_count -= _sw_item_weight (sw_item);

      clutter_container_child_set (CLUTTER_CONTAINER (pane),
                                   actor,
                                   "col-span", _sw_item_weight (sw_item),
                                   NULL);

      sw_items = g_list_remove (sw_items, sw_item);

      show_welcome_tile = FALSE;
    } else {
      /* Recent file item is newer */

      actor = g_hash_table_lookup (priv->pointer_to_actor,
                                   recent_file_event);

      if (!actor)
      {
        const gchar *uri = NULL;
        gchar *thumbnail_path = NULL;
        ZeitgeistSubject *subj;

        /* FIXME we assume there is only one subject */
        subj = zeitgeist_event_get_subject (recent_file_event, 0);
        uri = zeitgeist_subject_get_uri (subj);

        thumbnail_path = mpl_utils_get_thumbnail_path (uri);

        actor = _add_from_recent_file_event (pane,
                                            recent_file_event,
                                            thumbnail_path);
        g_free (thumbnail_path);
        g_hash_table_insert (priv->pointer_to_actor,
                             recent_file_event,
                             actor);

        /* Needed to remove from hash when we kill the actor */
        g_object_set_data (G_OBJECT (actor), "data-pointer", recent_file_event);

        show_welcome_tile = FALSE;
      }

      recent_files_count--;

      g_object_unref (recent_file_event);
      recent_file_items = g_list_remove (recent_file_items,
                                         recent_file_event);
    }

    clutter_container_lower_child (CLUTTER_CONTAINER (pane),
                                   actor,
                                   NULL);

    old_actors = g_list_remove (old_actors, actor);
  }

  for (l = old_actors; l; l = l->next)
  {
    gpointer p;
    p = g_object_get_data (G_OBJECT (l->data), "data-pointer");

    if (p)
    {
      clutter_container_remove_actor (CLUTTER_CONTAINER (pane),
                                      CLUTTER_ACTOR (l->data));
      g_hash_table_remove (priv->pointer_to_actor, p);
    }
  }

  g_list_free (old_actors);

  if (show_welcome_tile && !priv->welcome_tile)
  {
    priv->welcome_tile = penge_welcome_tile_new ();
    clutter_container_add_actor (CLUTTER_CONTAINER (pane),
                                 priv->welcome_tile);
    clutter_container_child_set (CLUTTER_CONTAINER (pane),
                                 priv->welcome_tile,
                                 "col-span", 3,
                                 NULL);
  }

  g_list_free (sw_items);

  for (l = recent_file_items; l; l = l->next)
  {
    ZeitgeistEvent *recent_file_event = l->data;
    g_object_unref (recent_file_event);
  }
  g_list_free (recent_file_items);

}
Exemplo n.º 26
0
static void
penge_interesting_tile_init (PengeInterestingTile *self)
{
    PengeInterestingTilePrivate *priv = GET_PRIVATE_REAL (self);
    ClutterActor *tmp_text;
    ClutterActor *icon;

    self->priv = priv;

    priv->inner_table = mx_table_new ();
    mx_bin_set_child (MX_BIN (self),
                      priv->inner_table);
    mx_bin_set_fill (MX_BIN (self), TRUE, TRUE);

    priv->primary_text = mx_label_new ();
    mx_stylable_set_style_class (MX_STYLABLE (priv->primary_text),
                                 "PengeInterestingTilePrimaryLabel");
    tmp_text = mx_label_get_clutter_text (MX_LABEL (priv->primary_text));
    clutter_text_set_line_alignment (CLUTTER_TEXT (tmp_text),
                                     PANGO_ALIGN_LEFT);
    clutter_text_set_ellipsize (CLUTTER_TEXT (tmp_text),
                                PANGO_ELLIPSIZE_END);
    g_signal_connect (priv->primary_text,
                      "notify::allocation",
                      (GCallback)_label_notify_allocation_cb,
                      self);

    priv->secondary_text = mx_label_new ();
    mx_stylable_set_style_class (MX_STYLABLE (priv->secondary_text),
                                 "PengeInterestingTileSecondaryLabel");
    tmp_text = mx_label_get_clutter_text (MX_LABEL (priv->secondary_text));
    clutter_text_set_line_alignment (CLUTTER_TEXT (tmp_text),
                                     PANGO_ALIGN_LEFT);
    clutter_text_set_ellipsize (CLUTTER_TEXT (tmp_text),
                                PANGO_ELLIPSIZE_END);
    g_signal_connect (priv->secondary_text,
                      "notify::allocation",
                      (GCallback)_label_notify_allocation_cb,
                      self);

    priv->icon = clutter_texture_new ();
    clutter_actor_set_size (priv->icon, 28, 28);
    clutter_actor_hide (priv->icon);

    /* This gets added to ourself table after our body because of ordering */
    priv->details_overlay = mx_table_new ();
    mx_stylable_set_style_class (MX_STYLABLE (priv->details_overlay),
                                 "PengeInterestingTileDetails");

    mx_table_add_actor (MX_TABLE (priv->inner_table),
                        priv->details_overlay,
                        1,
                        0);

    clutter_container_child_set (CLUTTER_CONTAINER (priv->inner_table),
                                 (ClutterActor *)priv->details_overlay,
                                 "x-expand", TRUE,
                                 "y-expand", FALSE,
                                 "y-fill", FALSE,
                                 "y-align", MX_ALIGN_END,
                                 NULL);

    mx_table_add_actor (MX_TABLE (priv->details_overlay),
                        priv->primary_text,
                        0,
                        1);

    clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay),
                                 (ClutterActor *)priv->primary_text,
                                 "x-expand",
                                 TRUE,
                                 "y-expand",
                                 FALSE,
                                 NULL);

    mx_table_add_actor (MX_TABLE (priv->details_overlay),
                        priv->secondary_text,
                        1,
                        1);
    clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay),
                                 (ClutterActor *)priv->secondary_text,
                                 "x-expand",
                                 TRUE,
                                 "y-expand",
                                 FALSE,
                                 NULL);

    mx_table_add_actor (MX_TABLE (priv->details_overlay),
                        priv->icon,
                        0,
                        0);
    clutter_container_child_set (CLUTTER_CONTAINER (priv->details_overlay),
                                 priv->icon,
                                 "row-span", 2,
                                 "y-expand", FALSE,
                                 "x-expand", FALSE,
                                 "y-fill", FALSE,
                                 "x-fill", FALSE,
                                 NULL);

    priv->remove_button = mx_button_new ();
    mx_stylable_set_style_class (MX_STYLABLE (priv->remove_button),
                                 "PengeInterestingTileRemoveButton");
    icon = (ClutterActor *)mx_icon_new ();
    mx_stylable_set_style_class (MX_STYLABLE (icon),
                                 "PengeInterestingTileIcon");
    mx_bin_set_child (MX_BIN (priv->remove_button),
                      (ClutterActor *)icon);
    mx_table_add_actor_with_properties (MX_TABLE (priv->details_overlay),
                                        priv->remove_button,
                                        0, 2,
                                        "row-span", 2,
                                        "x-expand", TRUE,
                                        "y-expand", TRUE,
                                        "x-fill", FALSE,
                                        "y-fill", FALSE,
                                        "x-align", MX_ALIGN_END,
                                        "y-align", MX_ALIGN_MIDDLE,
                                        NULL);

    g_signal_connect (priv->remove_button,
                      "clicked",
                      (GCallback)_remove_button_clicked,
                      self);

    mx_table_set_column_spacing (MX_TABLE (priv->details_overlay), 4);

    clutter_actor_set_reactive ((ClutterActor *) self, TRUE);

    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);
}
Exemplo n.º 27
0
static ClutterActor *
mex_menu_item_new (MexMenu *self, MxAction *action, MexMenuActionType type)
{
  ClutterActor *button, *layout, *icon, *vbox, *label, *arrow = NULL;

  button = mx_button_new ();
  mx_button_set_is_toggle (MX_BUTTON (button), TRUE);
  mx_stylable_set_style_class (MX_STYLABLE (button), "Item");

  layout = mx_box_layout_new ();
  mx_bin_set_child (MX_BIN (button), layout);
  mx_bin_set_fill (MX_BIN (button), TRUE, FALSE);

  if (type == MEX_MENU_LEFT)
    {
      arrow = mx_icon_new ();
      mx_stylable_set_style_class (MX_STYLABLE (arrow), "Left");
      clutter_container_add_actor (CLUTTER_CONTAINER (layout), arrow);

    }

  vbox = mx_box_layout_new ();
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (vbox), MX_ORIENTATION_VERTICAL);

  label = mx_label_new ();
  mx_label_set_fade_out (MX_LABEL (label), TRUE);
  mx_stylable_set_style_class (MX_STYLABLE (label), "Action");
  g_object_bind_property (action, "display-name", label, "text",
                          G_BINDING_SYNC_CREATE);
  clutter_container_add_actor (CLUTTER_CONTAINER (vbox), label);

  label = mx_label_new ();
  mx_label_set_fade_out (MX_LABEL (label), TRUE);
  mx_stylable_set_style_class (MX_STYLABLE (label), "Detail");
  clutter_container_add_actor (CLUTTER_CONTAINER (vbox), label);
  clutter_actor_hide (label);
  g_object_set_data (G_OBJECT (button), "detail-label", label);

  clutter_container_add_actor (CLUTTER_CONTAINER (layout), vbox);
  clutter_container_child_set (CLUTTER_CONTAINER (layout), vbox,
                               "expand", TRUE,
                               "x-fill", FALSE,
                               "x-align", MX_ALIGN_START,
                               "y-fill", FALSE,
                               NULL);

  icon = mx_icon_new ();
  g_object_bind_property (action, "icon", icon, "icon-name",
                          G_BINDING_SYNC_CREATE);
  clutter_container_add_actor (CLUTTER_CONTAINER (layout), icon);

  if (type == MEX_MENU_RIGHT)
    {
      arrow = mx_icon_new ();
      mx_stylable_set_style_class (MX_STYLABLE (arrow), "Right");
      clutter_container_add_actor (CLUTTER_CONTAINER (layout), arrow);
    }
  else if (type == MEX_MENU_TOGGLE)
    {
      ClutterActor *toggle = mx_icon_new ();
      mx_stylable_set_style_class (MX_STYLABLE (toggle), "Toggle");
      clutter_container_add_actor (CLUTTER_CONTAINER (layout), toggle);
      g_object_set_data (G_OBJECT (button), "toggle-icon", toggle);
    }

  if (arrow)
    clutter_container_child_set (CLUTTER_CONTAINER (layout),
                                 arrow,
                                 "expand", FALSE,
                                 "y-align", MX_ALIGN_MIDDLE,
                                 "y-fill", FALSE,
                                 NULL);

  g_signal_connect (button, "clicked",
                    G_CALLBACK (mex_menu_item_clicked_cb), action);

  g_object_weak_ref (G_OBJECT (button),
                     (GWeakNotify)mex_menu_item_destroyed_cb,
                     self);

  /* Set the item qdata on the button to mark that we created it */
  g_object_set_qdata (G_OBJECT (button), mex_menu_item_quark,
                      GINT_TO_POINTER (TRUE));

  return button;
}
Exemplo n.º 28
0
static void
mex_player_init (MexPlayer *self)
{
  MexPlayerPrivate *priv;

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

#ifdef USE_PLAYER_CLUTTER_GST
  priv->media = (ClutterMedia *) clutter_gst_video_texture_new ();

  /* We want to keep a reference to the media here to ensure consistency with
   * the D-BUS client interface behaviour
   */
  g_object_ref_sink (priv->media);

  clutter_container_add_actor (CLUTTER_CONTAINER (self),
                               CLUTTER_ACTOR (priv->media));
  clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (priv->media), TRUE);
  clutter_container_child_set (CLUTTER_CONTAINER (self),
                               CLUTTER_ACTOR (priv->media),
                               "fit", TRUE, NULL);

  /* Use progressive download when possible. Don't enable that yet, the
   * behaviour of seeking in the non already downloaded part of the stream
   * is not great. Either disable seeking in that case or find out why.*/
#if 0
  video_texture = CLUTTER_GST_VIDEO_TEXTURE (priv->media);
  clutter_gst_video_texture_set_buffering_mode (video_texture,
						CLUTTER_GST_BUFFERING_MODE_DOWNLOAD);
#endif
#else
#ifdef USE_PLAYER_DBUS
  priv->media = (ClutterMedia *) mex_player_client_new ();
#else
#ifdef USE_PLAYER_SURFACE
  priv->media = (ClutterMedia *) mex_surface_player_new ();
#else
#error Unexpected player setup
#endif
#endif
#endif

  g_signal_connect (priv->media, "eos", G_CALLBACK (media_eos_cb), self);
  g_signal_connect (priv->media, "notify::playing",
                    G_CALLBACK (media_playing_cb), self);
  g_signal_connect (priv->media, "notify::progress",
                    G_CALLBACK (media_update_progress), self);


#if defined(USE_PLAYER_SURFACE) || defined (USE_PLAYER_CLUTTER_GST)
  {
    GError *error = NULL;
    priv->bridge = mex_media_dbus_bridge_new (priv->media);
    if (!mex_media_dbus_bridge_register (priv->bridge, &error))
      {
        g_warning (G_STRLOC ": Error registering player on D-BUS");
        g_clear_error (&error);
      }
  }
#endif

  /* add info panel */
  priv->info_panel = mex_info_panel_new (MEX_INFO_PANEL_MODE_FULL);
  mx_widget_set_disabled (MX_WIDGET (priv->info_panel), TRUE);
  clutter_container_add_actor (CLUTTER_CONTAINER (self), priv->info_panel);
  clutter_container_child_set (CLUTTER_CONTAINER (self), priv->info_panel,
                               "y-fill", FALSE, "y-align", MX_ALIGN_END,
                               NULL);
  clutter_actor_set_opacity (priv->info_panel, 0);

  /* add media controls */
  priv->controls = mex_media_controls_new ();
  g_signal_connect (priv->controls, "stopped", G_CALLBACK (controls_stopped_cb),
                    self);
  mex_media_controls_set_media (MEX_MEDIA_CONTROLS (priv->controls),
                                priv->media);
  clutter_container_add_actor (CLUTTER_CONTAINER (self), priv->controls);
  clutter_container_child_set (CLUTTER_CONTAINER (self), priv->controls,
                               "y-fill", FALSE, "y-align", MX_ALIGN_END,
                               NULL);

  priv->screensaver = mex_screensaver_new ();

  /* start in idle mode */
  mex_player_set_idle_mode (MEX_PLAYER (self), TRUE);
}
Exemplo n.º 29
0
void
scene_prismatic_joint (Scene *scene)
{
  ClutterActor     *ground;
  ClutterActor     *group;
  ClutterActor     *prev_hand  = NULL;
  ClutterActor     *first_hand = NULL;
  ClutterActor     *stage;

  stage = clutter_stage_get_default ();

  first_hand = ground = clutter_rectangle_new ();
  clutter_actor_set_size (ground, 500, 120);



  group = clutter_box2d_new ();
  clutter_group_add (CLUTTER_GROUP (stage), group);

  clutter_group_add (CLUTTER_GROUP (group), ground);
  clutter_actor_set_position (ground, clutter_actor_get_width (
                                ground) * -0.3, 568);                             /*
                                                                                    this
                                                                                    is
                                                                                    wrong
                                                                                    */

  add_cage (group, TRUE);

  ground = clutter_rectangle_new ();
  clutter_actor_set_size (ground, 256, 3);
  clutter_actor_set_position (ground, -100, 310);
  clutter_actor_set_rotation (ground, CLUTTER_Z_AXIS, 30, 128, 16, 0);
  clutter_group_add (CLUTTER_GROUP (group), ground);

  clutter_container_child_set (CLUTTER_CONTAINER (group), ground,
                               "mode", CLUTTER_BOX2D_STATIC, NULL);

  ground = clutter_rectangle_new ();
  clutter_actor_set_size (ground, 256, 3);
  clutter_actor_set_position (ground, 200, 200);
  clutter_actor_set_rotation (ground, CLUTTER_Z_AXIS, -30, 0, 0, 0);
  clutter_group_add (CLUTTER_GROUP (group), ground);
  clutter_container_child_set (CLUTTER_CONTAINER (group), ground,
                               "mode", CLUTTER_BOX2D_STATIC, NULL);

  /*add_hand (group, 100, 100);*/
  prev_hand = add_hand (group, 200, 100);

  if(0){
    ClutterVertex anchor1 = {  (0),
                               (0) };
    ClutterVertex anchor2 = {  (0),
                               (0) };
    ClutterVertex axis = {  (100.0),
                            (20.0) };
    clutter_box2d_add_prismatic_joint (CLUTTER_BOX2D (group),
                                       first_hand, prev_hand,
                                       &anchor1, &anchor2,
                                       200.0, 220.0, &axis);
  }

  clutter_actor_set_depth (group, -600);
  clutter_actor_set_position (group, 0, -100);

  clutter_actor_set_reactive (group, TRUE);

  clutter_box2d_set_simulating (CLUTTER_BOX2D (group), simulating);

  scene->group = group;
}
Exemplo n.º 30
0
static void
mtp_bin_constructed (GObject *self)
{
  MtpBinPrivate *priv = MTP_BIN (self)->priv;
  MtpToolbar    *toolbar = (MtpToolbar*) mtp_toolbar_new ();
  ClutterActor  *box = (ClutterActor *)self;
  ClutterActor  *jar = mtp_jar_new ();
  GConfClient   *client;

  priv->toolbar = (ClutterActor*)toolbar;
  priv->jar     = jar;

  clutter_actor_set_name (jar, "jar");
  clutter_actor_set_height ((ClutterActor*)toolbar, TOOLBAR_HEIGHT);

  mx_box_layout_set_orientation (MX_BOX_LAYOUT (box), MX_ORIENTATION_VERTICAL);
  mx_box_layout_set_spacing (MX_BOX_LAYOUT (box), 10);

  clutter_container_add (CLUTTER_CONTAINER (box), (ClutterActor*)toolbar, NULL);

  {
    ClutterActor *dummy = mx_label_new ();
    ClutterActor *hbox = mx_box_layout_new ();
    ClutterActor *button = mx_button_new_with_label (_("Save toolbar"));

    clutter_actor_set_name (hbox, "message-box");
    clutter_actor_set_name (button, "save-button");

    priv->err_msg = _("Sorry, you'll have to remove a panel before you can "
                      "add a new one.");
    priv->normal_msg = _("You can add, remove, and reorder many of the panels "
                         "in your toolbar.");

    priv->message = mx_label_new_with_text (priv->normal_msg);

    clutter_actor_set_name (priv->message, "error-message");

    clutter_container_add (CLUTTER_CONTAINER (box), hbox, NULL);
    clutter_container_add (CLUTTER_CONTAINER (hbox), priv->message,
                           dummy, button, NULL);
    clutter_container_child_set (CLUTTER_CONTAINER (hbox), dummy,
                                 "expand", TRUE, NULL);
    clutter_container_child_set (CLUTTER_CONTAINER (hbox), button,
                                 "x-align", MX_ALIGN_END,
                                 "y-align", MX_ALIGN_MIDDLE, NULL);
    clutter_container_child_set (CLUTTER_CONTAINER (hbox), priv->message,
                                 "y-align", MX_ALIGN_MIDDLE, NULL);

    g_signal_connect (button, "clicked",
                      G_CALLBACK (mtp_bin_save_button_clicked_cb),
                      self);

    g_signal_connect (toolbar, "notify::free-space",
                      G_CALLBACK (mtp_bin_toolbar_free_space_cb),
                      self);
  }

  clutter_container_add (CLUTTER_CONTAINER (box), jar, NULL);

  clutter_container_child_set (CLUTTER_CONTAINER (box), jar,
                               "expand", TRUE, NULL);

  client = priv->client = gconf_client_get_default ();
  gconf_client_add_dir (client, KEY_DIR, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
}