Пример #1
0
int main(int argc, char *argv[])
{
    clutter_init(&argc, &argv);

    ClutterActor *stage = NULL;
    ClutterColor black = { 0x00, 0x00, 0x00, 0xff };
    stage = clutter_stage_get_default();
    clutter_stage_set_title(CLUTTER_STAGE(stage), "Mx test");
    clutter_stage_set_color(CLUTTER_STAGE(stage), &black);
    clutter_actor_set_size(stage, WIN_W, WIN_H);

    Assistant *assistant = g_new0(Assistant, 1);
    assistant->script = require_script(GUI_SCRIPT);
    assistant->stage = stage;
    ClutterActor *root = CLUTTER_ACTOR(require_object_from_script(assistant->script, "root"));
    assistant->slider = CLUTTER_ACTOR(require_object_from_script(assistant->script, "slider"));
    assistant->combo_box = CLUTTER_ACTOR(require_object_from_script(assistant->script, "combo_box"));
    clutter_container_add_actor(CLUTTER_CONTAINER(stage), root);

    // Combo box contents:
    MxComboBox *combo_box = MX_COMBO_BOX(assistant->combo_box);
    mx_combo_box_append_text(combo_box, "Foo");
    mx_combo_box_append_text(combo_box, "Spam");
    mx_combo_box_append_text(combo_box, "Lorem ipsum");
    mx_combo_box_set_index(combo_box, 0);

    // DONE
    g_signal_connect(stage, "key-press-event", G_CALLBACK(key_event_cb), assistant);
    clutter_script_connect_signals(assistant->script, assistant);
    assistant->ready_ = TRUE;
    clutter_actor_show(stage);
    clutter_main();
    return 0;
}
Пример #2
0
static void
create_new_chooser (MnbPeoplePanel *self)
{
  MnbPeoplePanelPrivate *priv = GET_PRIVATE (self);

  priv->new_chooser = mx_combo_box_new ();
  mx_combo_box_append_text (MX_COMBO_BOX (priv->new_chooser), _("New contact"));
  mx_combo_box_append_text (MX_COMBO_BOX (priv->new_chooser), _("New group chat"));

  mx_combo_box_set_active_text (MX_COMBO_BOX (priv->new_chooser), _("New"));

  g_signal_connect (priv->new_chooser,
                    "notify::index",
                    G_CALLBACK (new_index_changed_cb),
                    self);
}
Пример #3
0
static void
create_sort_by_chooser (MnbPeoplePanel *self)
{
  MnbPeoplePanelPrivate *priv = GET_PRIVATE (self);

  priv->sort_by_chooser = mx_combo_box_new ();
  mx_combo_box_append_text (MX_COMBO_BOX (priv->sort_by_chooser), _("Sort by:"));
  mx_combo_box_append_text (MX_COMBO_BOX (priv->sort_by_chooser), _("- Presence"));
  mx_combo_box_append_text (MX_COMBO_BOX (priv->sort_by_chooser), _("- Name"));
  mx_combo_box_append_text (MX_COMBO_BOX (priv->sort_by_chooser), _("Show:"));
  mx_combo_box_append_text (MX_COMBO_BOX (priv->sort_by_chooser), _("- Only online"));
  mx_combo_box_append_text (MX_COMBO_BOX (priv->sort_by_chooser), _("- All contacts"));

  mx_combo_box_set_active_text (MX_COMBO_BOX (priv->sort_by_chooser), _("Sort by"));

  g_signal_connect (priv->sort_by_chooser,
                    "notify::index",
                    G_CALLBACK (sort_by_index_changed_cb),
                    self);
}
Пример #4
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;
}