Exemplo n.º 1
0
void
toggle_main (ClutterContainer *stage)
{
  ClutterActor *toggle;

  toggle = mx_toggle_new ();
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), toggle);
  clutter_actor_set_position (toggle, 50, 50);

}
Exemplo n.º 2
0
static void
create_network_row (MpdComputerTile *tile,
                    const gchar     *label_text,
                    gint             row)
{
  MpdComputerTilePrivate *priv = tile->priv;
  ClutterActor *label, *toggle, *frame;

  label = mx_label_new_with_text (label_text);
  mx_table_add_actor_with_properties (MX_TABLE (tile), label,
                                      row, 0,
                                      "x-expand", FALSE,
                                      "y-align", MX_ALIGN_MIDDLE,
                                      "y-fill", FALSE,
                                      NULL);

  frame = mx_frame_new ();
  toggle = mx_toggle_new ();

  mx_bin_set_child (MX_BIN (frame), toggle);
  mx_table_add_actor_with_properties (MX_TABLE (tile), frame,
                                      row, 1,
                                      "x-expand", FALSE,
                                      "x-fill", FALSE,
                                      "x-align", MX_ALIGN_START,
                                      NULL);

  priv->toggled_data[row].tile = tile;
  priv->toggled_data[row].row = row;
  g_signal_connect (toggle,
                    "notify::active",
                    G_CALLBACK (on_switch_toggled),
                    &priv->toggled_data[row]);

  priv->rows[row].label = label;
  priv->rows[row].frame = frame;
  priv->rows[row].toggle = toggle;
}
Exemplo n.º 3
0
static ClutterActor *
create_property_editor (GObject    *object,
                        GParamSpec *pspec)
{
  ClutterActor *box, *label, *value;
  gint i;

  /* skip properties that are not writable */
  if (!(pspec->flags & G_PARAM_WRITABLE))
    return NULL;

  /* skip other properties */
  for (i = 0; i < G_N_ELEMENTS (skip_properties); i++)
    {
      if (g_str_equal (pspec->name, skip_properties[i]))
        return NULL;
    }


  box = mx_box_layout_new ();

  label = mx_label_new_with_text (pspec->name);
  clutter_actor_set_width (label, 150);
  clutter_actor_add_child (box, label);

  if (pspec->value_type == G_TYPE_BOOLEAN)
    {
      value = mx_toggle_new ();

      g_object_bind_property (object, pspec->name, value, "active",
                              G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
    }
  else if (pspec->value_type == G_TYPE_STRING)
    {
      value = mx_entry_new ();

      g_object_bind_property (object, pspec->name, value, "text",
                              G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
    }
  else if (pspec->value_type == G_TYPE_INT || pspec->value_type == G_TYPE_UINT
           || pspec->value_type == G_TYPE_FLOAT
           || pspec->value_type == G_TYPE_DOUBLE)
    {
      value = mx_entry_new ();

      g_object_bind_property_full (object, pspec->name, value, "text",
                                   G_BINDING_BIDIRECTIONAL
                                   | G_BINDING_SYNC_CREATE,
                                   num_to_string,
                                   string_to_num,
                                   NULL, NULL);
    }
  else if (g_type_is_a (pspec->value_type, G_TYPE_ENUM))
    {
      GEnumValue *evalue;
      GEnumClass *eclass;
      gint init = 0;

      value = mx_combo_box_new ();
      clutter_actor_set_width (value, 100);

      eclass = g_type_class_ref (pspec->value_type);

      while ((evalue = g_enum_get_value (eclass, init)))
        {
          mx_combo_box_append_text (MX_COMBO_BOX (value), evalue->value_nick);
          init++;
        }

      g_type_class_unref (eclass);

      g_object_bind_property (object, pspec->name, value, "index",
                              G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);

    }
  else
    value = NULL;

  if (value)
    {
      clutter_actor_add_child (box, value);
      return box;
    }
  else
    return NULL;
}
Exemplo n.º 4
0
void
scroll_view_main (ClutterContainer *stage)
{
  gint width, height;
  MxAdjustment *hadjust, *vadjust;
  ClutterActor *label, *elastic, *overshoot, *scroll, *kinetic, *view, *texture;

  scroll = mx_scroll_view_new ();

  /* Make sure something underneath the kinetic scroll view swallows events
   * so that we don't end up moving the window.
   */
  g_signal_connect (scroll, "button-press-event", G_CALLBACK (true_cb), NULL);

  kinetic = mx_kinetic_scroll_view_new ();

  clutter_container_add_actor (stage, scroll);
  clutter_actor_set_position (scroll, 10, 10);
  clutter_actor_set_size (scroll, 300, 300);

  view = mx_viewport_new ();
  mx_viewport_set_sync_adjustments (MX_VIEWPORT (view), FALSE);
  clutter_container_add_actor (CLUTTER_CONTAINER (kinetic), view);
  clutter_container_add_actor (CLUTTER_CONTAINER (scroll), kinetic);


  texture = clutter_texture_new_from_file ("redhand.png", NULL);
  clutter_container_add_actor (CLUTTER_CONTAINER (view), texture);
  g_object_set (texture, "repeat-x", TRUE, "repeat-y", TRUE, NULL);
  clutter_actor_set_size (texture, 1280, 1280);

  clutter_texture_get_base_size (CLUTTER_TEXTURE (texture),
                                 &width, &height);
  mx_scrollable_get_adjustments (MX_SCROLLABLE (view),
                                 &hadjust, &vadjust);
  mx_adjustment_set_values (hadjust,
                            0,
                            0,
                            1280,
                            width,
                            width * 3,
                            300);
  mx_adjustment_set_values (vadjust,
                            0,
                            0,
                            1280,
                            height,
                            height * 3,
                            300);

  label = mx_label_new_with_text ("Toggle over-shooting:");
  overshoot = mx_toggle_new ();
  clutter_actor_set_position (label, 320, 10);
  clutter_actor_set_position (overshoot, 330 + clutter_actor_get_width (label),
                              10);
  clutter_container_add (stage, label, overshoot, NULL);

  g_signal_connect (overshoot, "notify::active",
                    G_CALLBACK (notify_overshoot_cb), kinetic);

  label = mx_label_new_with_text ("Toggle elasticity:");
  elastic = mx_toggle_new ();
  clutter_actor_set_position (label, 320,
                              20 + clutter_actor_get_height (overshoot));
  clutter_actor_set_position (elastic, clutter_actor_get_x (overshoot),
                              clutter_actor_get_y (label));
  clutter_container_add (stage, label, elastic, NULL);

  g_signal_connect (elastic, "notify::active",
                    G_CALLBACK (notify_elastic_cb), kinetic);
}
Exemplo n.º 5
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);
}
Exemplo n.º 6
0
static void
dawati_bt_shell_init (DawatiBtShell *shell)
{
  ClutterActor *label, *active_label, *active_box, *settings_button;
  DawatiBtShellPrivate *priv = GET_PRIVATE (shell);

  priv->devices = g_hash_table_new_full (g_str_hash, g_str_equal,
                                         g_free, NULL);
  priv->requests = g_hash_table_new_full (g_str_hash, g_str_equal,
                                         g_free, NULL);

  priv->notification = notify_notification_new ("", NULL, icon);
  notify_notification_set_timeout (priv->notification,
                                   NOTIFY_EXPIRES_NEVER);
  /* TRANSLATORS: button in a notification, will open the
   * bluetooth panel */
  notify_notification_add_action (priv->notification,
                                  "show",
                                  _("Show"),
                                  (NotifyActionCallback)_notify_action_cb,
                                  shell, NULL);

  mx_box_layout_set_orientation (MX_BOX_LAYOUT (shell),
                                 MX_ORIENTATION_VERTICAL);

  label = mx_label_new_with_text (_("Bluetooth"));
  mx_stylable_set_style_class (MX_STYLABLE (label), "titleBar");
  mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (shell),
                                              label, -1,
                                              "expand", TRUE,
                                              "x-fill", TRUE,
                                              "x-align", MX_ALIGN_START,
                                              NULL);

  priv->content = mx_box_layout_new ();
  clutter_actor_set_name (priv->content, "bt-panel-content");
  mx_box_layout_set_enable_animations (MX_BOX_LAYOUT (priv->content), TRUE);
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->content), MX_ORIENTATION_VERTICAL);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (shell), priv->content, -1);

  active_box = mx_box_layout_new ();
  clutter_actor_set_name (active_box, "bt-panel-active-box");
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->content), active_box, -1);

  /* TRANSLATORS: Label for bluetooth enable/disable toggle */
  active_label = mx_label_new_with_text (_("Active"));
  mx_stylable_set_style_class (MX_STYLABLE (active_label), "BtTitle");
  mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (active_box),
                                              active_label, -1,
                                              "expand", TRUE,
                                              "x-fill", TRUE,
                                              "x-align", MX_ALIGN_START,
                                              "y-fill", FALSE,
                                              "y-align", MX_ALIGN_MIDDLE,
                                              NULL);

  priv->kill_toggle = mx_toggle_new ();
  priv->kill_handler = g_signal_connect (priv->kill_toggle, "notify::active",
                                         G_CALLBACK (_toggle_active_cb), shell);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (active_box),
                              priv->kill_toggle, -1);

  /* devices that are requesting something go here */
  priv->request_box = mx_box_layout_new ();
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->request_box),
                                 MX_ORIENTATION_VERTICAL);
  mx_box_layout_set_enable_animations (MX_BOX_LAYOUT (priv->request_box),
                                       TRUE);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->content),
                              priv->request_box, -1);


  /* connected devices go here */
  priv->device_panelbox = g_object_ref (mx_box_layout_new ());
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->device_panelbox),
                                 MX_ORIENTATION_VERTICAL);
  mx_stylable_set_style_class (MX_STYLABLE (priv->device_panelbox),
                               "contentPanel");

  priv->info_label = mx_label_new_with_text (_("Nothing connected"));
  mx_stylable_set_style_class (MX_STYLABLE (priv->info_label), "BtTitle");
  clutter_actor_hide (priv->info_label);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->device_panelbox),
                              priv->info_label, -1);

  priv->device_box = mx_box_layout_new ();
  mx_box_layout_set_orientation (MX_BOX_LAYOUT (priv->device_box),
                                 MX_ORIENTATION_VERTICAL);

  mx_box_layout_set_enable_animations (MX_BOX_LAYOUT (priv->device_box),
                                       TRUE);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->device_panelbox),
                              priv->device_box, -1);

  /* button row */
  priv->button_box = mx_box_layout_new ();
  clutter_actor_set_name (priv->button_box, "bt-panel-button-box");
  mx_box_layout_set_enable_animations (MX_BOX_LAYOUT (priv->button_box), TRUE);
  mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (priv->content),
                                              priv->button_box, -1,
                                              "expand", TRUE,
                                              "x-fill", TRUE,
                                              NULL);

  mx_box_layout_insert_actor_with_properties (MX_BOX_LAYOUT (priv->button_box),
                                              mx_box_layout_new (), 0,
                                              "expand", TRUE,
                                              NULL);

  priv->send_button = mx_button_new_with_label (_("Send file"));
  g_signal_connect (priv->send_button, "clicked",
                    G_CALLBACK (_send_clicked_cb), shell);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->button_box),
                              priv->send_button, 1);

  priv->add_button = mx_button_new_with_label (_("Add new"));
  g_signal_connect (priv->add_button, "clicked",
                    G_CALLBACK (_add_clicked_cb), shell);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->button_box),
                              priv->add_button, 2);

  settings_button = mx_button_new_with_label (_("Settings"));
  g_signal_connect (settings_button, "clicked",
                    G_CALLBACK (_settings_clicked_cb), shell);
  mx_box_layout_insert_actor (MX_BOX_LAYOUT (priv->button_box), settings_button, 3);

  dawati_bt_shell_init_applet (shell);

  priv->cm = carrick_connman_manager_new ();
  g_signal_connect (priv->cm, "notify::available-technologies",
                    G_CALLBACK (_available_techs_changed), shell);
  g_signal_connect (priv->cm, "notify::enabled-technologies",
                    G_CALLBACK (_enabled_techs_changed), shell);

#ifdef TEST_WITH_BOGUS_DATA
  g_debug ("TEST_WITH_BOGUS_DATA: Adding false devices & requests, "
           "and setting Bluetooth available even if connman is not there");
  /* Dummies for quick testing without bluetooth devices or connman */
  dawati_bt_shell_add_device (shell, "TestDeviceA", "a");
  dawati_bt_shell_add_device (shell, "TestDeviceB", "b");
  dawati_bt_shell_add_request (shell, "TestDeviceC", "c", DAWATI_BT_REQUEST_TYPE_PIN, NULL);
  dawati_bt_shell_add_request (shell, "TestDeviceD", "d", DAWATI_BT_REQUEST_TYPE_CONFIRM, "001234");
  dawati_bt_shell_add_request (shell, "TestDeviceE", "e", DAWATI_BT_REQUEST_TYPE_AUTH, "0000111f-0000-1000-8000-00805f9b34fb");
  priv->enabled = priv->available = TRUE;
  dawati_bt_shell_update (shell);
#endif
}