static ClutterActor *
create_button (const char *button_style, const char *icon_style, const char *icon_name)
{
    ClutterActor *widget;
    ClutterActor *icon;

    icon = mx_icon_new ();
    mx_stylable_set_style_class (MX_STYLABLE (icon), icon_style);
    mx_stylable_set_style (MX_STYLABLE (icon), style);
    mx_icon_set_icon_name (MX_ICON (icon), icon_name);
    mx_icon_set_icon_size (MX_ICON (icon), 64);

    widget = mx_button_new ();
    mx_stylable_set_style_class (MX_STYLABLE (widget), button_style);
    mx_stylable_set_style (MX_STYLABLE (widget), style);
    mx_bin_set_child (MX_BIN (widget), icon);

    return widget;
}
Esempio n. 2
0
static void
startup_cb (MxApplication *application)
{
  MxWindow *window;
  ClutterActor *scroll, *child;
  gint i;

  window = mx_application_create_window (application, "Test Widgets");

  /* Create scroll view */
  scroll = mx_kinetic_scroll_view_new ();
  mx_kinetic_scroll_view_set_use_grab (MX_KINETIC_SCROLL_VIEW (scroll), TRUE);
  mx_kinetic_scroll_view_set_mouse_button (MX_KINETIC_SCROLL_VIEW (scroll), 3);
  clutter_actor_set_clip_to_allocation (scroll, TRUE);

  child = mx_box_layout_new_with_orientation (MX_ORIENTATION_VERTICAL);

  for (i = 0; i < 10000; i++) {
    ClutterActor *layout, *label, *icon;
    gchar *s = g_strdup_printf ("Row %d", i);

    layout = mx_box_layout_new_with_orientation (MX_ORIENTATION_HORIZONTAL);
    label = mx_label_new_with_text (s);
    clutter_actor_add_child (layout, label);
    g_free (s);

    icon = mx_icon_new ();
    mx_icon_set_icon_name (MX_ICON (icon), "object-rotate-left");
    mx_icon_set_icon_size (MX_ICON (icon), 32);
    clutter_actor_add_child (layout, icon);

    clutter_actor_add_child (child, layout);
  }

  clutter_actor_add_child (scroll, child);

  mx_window_set_child (window, scroll);

  /* show the window */
  mx_window_set_has_toolbar (window, FALSE);
  mx_window_show (window);
}
Esempio n. 3
0
File: mx-button.c Progetto: danni/mx
/**
 * mx_button_set_icon_size:
 * @button: a #MxButton
 *
 * Sets the icon-size to use for the icon displayed inside the button. This will
 * override the icon-size set in the style. Setting a value of %0 resets to the
 * size from the style.
 *
 * Since: 1.2
 */
void
mx_button_set_icon_size (MxButton *button,
                         guint     icon_size)
{
  MxButtonPrivate *priv;

  g_return_if_fail (MX_IS_BUTTON (button));

  priv = button->priv;

  if (priv->icon_size != icon_size)
    {
      priv->icon_size = icon_size;

      mx_icon_set_icon_size (MX_ICON (priv->icon), icon_size ?
                             icon_size : priv->style_icon_size);

      g_object_notify (G_OBJECT (button), "icon-size");
    }
}
Esempio n. 4
0
File: mx-button.c Progetto: danni/mx
static void
mx_button_style_changed (MxWidget *widget)
{
  MxButton *button = MX_BUTTON (widget);
  MxButtonPrivate *priv = button->priv;
  MxBorderImage *content_image = NULL;

  /* update the label styling */
  mx_button_update_label_style (button);

  g_free (priv->style_icon_name);
  mx_stylable_get (MX_STYLABLE (widget),
                   "x-mx-content-image", &content_image,
                   "x-mx-icon-name", &priv->style_icon_name,
                   "x-mx-icon-size", &priv->style_icon_size,
                   NULL);

  if (content_image && content_image->uri)
    {
      if (priv->content_image)
        {
          clutter_actor_remove_child (CLUTTER_ACTOR (widget),
                                      priv->content_image);
        }

      priv->content_image =
        (ClutterActor*) mx_texture_cache_get_texture (mx_texture_cache_get_default (),
                                                      content_image->uri);

      if (priv->content_image)
        clutter_actor_add_child (CLUTTER_ACTOR (widget), priv->content_image);
      else
        g_warning ("Could not load content image \"%s\"", content_image->uri);

      g_boxed_free (MX_TYPE_BORDER_IMAGE, content_image);

      return;
    }
  else
    {
      /* remove any previous content image */
      if (priv->content_image)
        {
          clutter_actor_remove_child (CLUTTER_ACTOR (widget),
                                      priv->content_image);
          priv->content_image = NULL;
        }

      if (content_image)
        g_boxed_free (MX_TYPE_BORDER_IMAGE, content_image);
    }

  if (priv->icon_size == 0)
    mx_icon_set_icon_size (MX_ICON (priv->icon), priv->style_icon_size);

  if (priv->style_icon_name && !priv->icon_name)
    {
      mx_icon_set_icon_name (MX_ICON (priv->icon), priv->style_icon_name);
      mx_button_update_contents (button);
    }
}
static void
add_pictures (ClutterActor *box)
{
  GList *files = get_pictures ();

  while (files)
    {
      gint w, h, i;
      ClutterActor *drawer, *drawer2, *tile, *texture, *menu, *description;

      gchar *file = files->data;

      /* Create texture */
      texture = clutter_texture_new_from_file (file, NULL);
      clutter_texture_get_base_size (CLUTTER_TEXTURE (texture), &w, &h);
      clutter_actor_set_size (texture, 300, 300.0/w * h);

      /* Create menu */
      menu = mx_box_layout_new ();
      mx_box_layout_set_orientation (MX_BOX_LAYOUT (menu),
                                     MX_ORIENTATION_VERTICAL);
      for (i = 0; i < 4; i++)
        {
          ClutterActor *button, *layout, *icon, *label;

          button = mx_button_new ();

          layout = mx_box_layout_new ();
          icon = mx_icon_new ();
          label = mx_label_new ();

          mx_box_layout_set_spacing (MX_BOX_LAYOUT (layout), 8);

          mx_icon_set_icon_size (MX_ICON (icon), 16);
          clutter_actor_set_size (icon, 16, 16);

          clutter_container_add (CLUTTER_CONTAINER (layout),
                                 icon, label, NULL);
          mx_bin_set_child (MX_BIN (button), layout);
          mx_bin_set_alignment (MX_BIN (button),
                                MX_ALIGN_START,
                                MX_ALIGN_MIDDLE);

          clutter_container_add_actor (CLUTTER_CONTAINER (menu), button);
          mx_box_layout_child_set_x_fill (MX_BOX_LAYOUT (menu), button, TRUE);

          switch (i)
            {
            case 0:
              mx_icon_set_icon_name (MX_ICON (icon), "dialog-information");
              mx_label_set_text (MX_LABEL (label), "This");
              break;

            case 1:
              mx_icon_set_icon_name (MX_ICON (icon), "dialog-question");
              mx_label_set_text (MX_LABEL (label), "is");
              break;

            case 2:
              mx_icon_set_icon_name (MX_ICON (icon), "dialog-warning");
              mx_label_set_text (MX_LABEL (label), "a");
              break;

            case 3:
              mx_icon_set_icon_name (MX_ICON (icon), "dialog-error");
              mx_label_set_text (MX_LABEL (label), "menu");
              break;
            }
        }

      /* Create description */
      description = mx_label_new_with_text ("Here you could put a very "
                                            "long description of whatever "
                                            "is above it. Or you could put "
                                            "another focusable widget here "
                                            "and it'd be navigable, like "
                                            "the menu on the right. Whoo!");
      clutter_text_set_line_wrap ((ClutterText *)mx_label_get_clutter_text (
                                    MX_LABEL (description)), TRUE);

      drawer = mex_expander_box_new ();
      mex_expander_box_set_important_on_focus (MEX_EXPANDER_BOX (drawer), TRUE);
      drawer2 = mex_expander_box_new ();
      mex_expander_box_set_grow_direction (MEX_EXPANDER_BOX (drawer2),
                                          MEX_EXPANDER_BOX_RIGHT);
      mex_expander_box_set_important (MEX_EXPANDER_BOX (drawer2), TRUE);

      tile = mex_tile_new_with_label (file);
      mex_tile_set_important (MEX_TILE (tile), TRUE);
      mx_bin_set_child (MX_BIN (tile), texture);

      clutter_container_add (CLUTTER_CONTAINER (drawer2), tile, menu, NULL);
      clutter_container_add (CLUTTER_CONTAINER (drawer),
                             drawer2, description, NULL);

      g_signal_connect (drawer, "notify::open",
                        G_CALLBACK (sync_drawer2_cb), drawer2);

      clutter_container_add_actor (CLUTTER_CONTAINER (box), drawer);

      clutter_actor_set_reactive (texture, TRUE);
      g_signal_connect (texture, "enter-event",
                        G_CALLBACK (texture_enter_cb), drawer);
      g_signal_connect (texture, "leave-event",
                        G_CALLBACK (texture_leave_cb), drawer);
      g_signal_connect (texture, "button-press-event",
                        G_CALLBACK (texture_clicked_cb), drawer);

      g_free (file);
      files = g_list_delete_link (files, files);
    }
}
Esempio n. 6
0
static void
startup_cb (MxApplication *app)
{
    MxWindow *window;
    ClutterActor *stage, *toggle, *label, *table, *button, *icon;

    window = mx_application_create_window (app, "Test Window");
    stage = (ClutterActor *)mx_window_get_clutter_stage (window);
    mx_window_set_icon_name (window, "window-new");

    clutter_actor_set_size (stage, 480, 320);

    table = mx_table_new ();
    mx_table_set_column_spacing (MX_TABLE (table), 8);
    mx_table_set_row_spacing (MX_TABLE (table), 12);
    mx_window_set_child (window, table);

    toggle = mx_toggle_new ();
    label = mx_label_new_with_text ("Toggle small-screen mode");
    g_signal_connect (toggle, "notify::active",
                      G_CALLBACK (small_screen_cb), window);
    mx_table_insert_actor_with_properties (MX_TABLE (table),
                                           toggle,
                                           0, 0,
                                           "x-expand", TRUE,
                                           "x-align", MX_ALIGN_END,
                                           "x-fill", FALSE,
                                           NULL);
    mx_table_insert_actor_with_properties (MX_TABLE (table),
                                           label,
                                           0, 1,
                                           "x-expand", TRUE,
                                           "x-align", MX_ALIGN_START,
                                           "y-fill", FALSE,
                                           "x-fill", FALSE,
                                           NULL);

    toggle = mx_toggle_new ();
    label = mx_label_new_with_text ("Toggle full-screen mode");
    g_signal_connect (toggle, "notify::active",
                      G_CALLBACK (fullscreen_cb), stage);
    mx_table_insert_actor_with_properties (MX_TABLE (table),
                                           toggle,
                                           1, 0,
                                           "x-expand", TRUE,
                                           "x-align", MX_ALIGN_END,
                                           "x-fill", FALSE,
                                           NULL);
    mx_table_insert_actor_with_properties (MX_TABLE (table),
                                           label,
                                           1, 1,
                                           "x-expand", TRUE,
                                           "x-align", MX_ALIGN_START,
                                           "y-fill", FALSE,
                                           "x-fill", FALSE,
                                           NULL);

    toggle = mx_toggle_new ();
    label = mx_label_new_with_text ("Toggle custom window icon");
    g_signal_connect (toggle, "notify::active",
                      G_CALLBACK (icon_cb), window);
    mx_table_insert_actor_with_properties (MX_TABLE (table),
                                           toggle,
                                           2, 0,
                                           "x-expand", TRUE,
                                           "x-align", MX_ALIGN_END,
                                           "x-fill", FALSE,
                                           NULL);
    mx_table_insert_actor_with_properties (MX_TABLE (table),
                                           label,
                                           2, 1,
                                           "x-expand", TRUE,
                                           "x-align", MX_ALIGN_START,
                                           "y-fill", FALSE,
                                           "x-fill", FALSE,
                                           NULL);

    toggle = mx_toggle_new ();
    mx_toggle_set_active (MX_TOGGLE (toggle), TRUE);
    label = mx_label_new_with_text ("Toggle user-resizable");
    g_signal_connect (toggle, "notify::active",
                      G_CALLBACK (resizable_cb), stage);
    mx_table_insert_actor_with_properties (MX_TABLE (table),
                                           toggle,
                                           3, 0,
                                           "x-expand", TRUE,
                                           "x-align", MX_ALIGN_END,
                                           "x-fill", FALSE,
                                           NULL);
    mx_table_insert_actor_with_properties (MX_TABLE (table),
                                           label,
                                           3, 1,
                                           "x-expand", TRUE,
                                           "x-align", MX_ALIGN_START,
                                           "y-fill", FALSE,
                                           "x-fill", FALSE,
                                           NULL);

    toggle = mx_toggle_new ();
    mx_toggle_set_active (MX_TOGGLE (toggle), TRUE);
    label = mx_label_new_with_text ("Toggle toolbar");
    g_signal_connect (toggle, "notify::active",
                      G_CALLBACK (toolbar_cb), window);
    mx_table_insert_actor_with_properties (MX_TABLE (table),
                                           toggle,
                                           4, 0,
                                           "x-expand", TRUE,
                                           "x-align", MX_ALIGN_END,
                                           "x-fill", FALSE,
                                           NULL);
    mx_table_insert_actor_with_properties (MX_TABLE (table),
                                           label,
                                           4, 1,
                                           "x-expand", TRUE,
                                           "x-align", MX_ALIGN_START,
                                           "y-fill", FALSE,
                                           "x-fill", FALSE,
                                           NULL);

    icon = mx_icon_new ();
    mx_icon_set_icon_name (MX_ICON (icon), "object-rotate-right");
    mx_icon_set_icon_size (MX_ICON (icon), 16);
    button = mx_button_new ();
    mx_bin_set_child (MX_BIN (button), icon);
    g_signal_connect (button, "clicked", G_CALLBACK (rotate_clicked_cb), window);
    clutter_container_add_actor (
        CLUTTER_CONTAINER (mx_window_get_toolbar (window)), button);
    mx_bin_set_alignment (MX_BIN (mx_window_get_toolbar (window)),
                          MX_ALIGN_END, MX_ALIGN_MIDDLE);

    clutter_actor_show (stage);
}