static ClutterActor * factory_func (PengeModelBridge *bridge, ClutterContainer *container, ClutterModel *model, ClutterModelIter *iter) { ClutterActor *actor; SwItem *item; clutter_model_iter_get (iter, 0, &item, -1); actor = g_object_new (PENGE_TYPE_PEOPLE_TILE, "item", item, NULL); clutter_actor_set_size (actor, 140, 95); clutter_container_add_actor (container, actor); if (g_str_equal (item->service, "twitter")) { clutter_layout_manager_child_set (layout, container, actor, "col-span", 2, NULL); } return actor; }
int main (int argc, char *argv[]) { ClutterActor *stage; g_type_init (); g_thread_init (NULL); if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; clutter_threads_init (); GMainLoop *loop; loop = g_main_loop_new (NULL, FALSE); stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "message test"); clutter_actor_set_size (stage, 400, 600); clutter_actor_show_all (stage); #if 1 ClutterActor *message; GnomeAppStore *store; store = gnome_app_store_get_default (); gnome_app_store_set_lock_function (store, clutter_threads_enter); gnome_app_store_set_unlock_function (store, clutter_threads_leave); message = CLUTTER_ACTOR (gnome_app_message_new ()); clutter_container_add (CLUTTER_CONTAINER (stage), message, NULL); #else ClutterActor *page, *actor; ClutterScript *script; GError *error; script = clutter_script_new (); error = NULL; clutter_script_load_from_file (script, "/home/dliang/gnome-app-store/ui/message-info-page.json", &error); // clutter_script_load_from_file (script, "/home/dliang/gnome-app-store/ui/test.json", &error); if (error) printf ("error in load %s\n", error->message); clutter_script_get_objects (script, "message-info-page", &page, "sender_label", &actor, NULL); ClutterLayoutManager *layout; layout = clutter_box_get_layout_manager (page); gint col, row; clutter_layout_manager_child_get (layout, page, actor, "column", &col, "row", &row, NULL); printf ("col %d %d\n", col, row); clutter_layout_manager_child_set (layout, page, actor, "column", 2, "row", 1, NULL); clutter_container_add (CLUTTER_CONTAINER (stage), page, NULL); #endif g_main_loop_run (loop); g_main_loop_unref (loop); return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { ClutterActor *stage; ClutterLayoutManager *box_layout; ClutterActor *box; ClutterActor *yellow; ClutterActor *red; ClutterActor *blue; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; stage = clutter_stage_new (); clutter_actor_set_size (stage, 400, 400); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); /* create a ClutterBoxLayout */ box_layout = clutter_box_layout_new (); /* configure it to lay out actors vertically */ clutter_box_layout_set_vertical (CLUTTER_BOX_LAYOUT (box_layout), TRUE); /* put 5px of spacing between actors */ clutter_box_layout_set_spacing (CLUTTER_BOX_LAYOUT (box_layout), 5); /* actors are packed into this actor; we set its width, but * allow its height to be determined by the children it contains */ box = clutter_actor_new (); clutter_actor_set_layout_manager (box, box_layout); clutter_actor_set_background_color (box, CLUTTER_COLOR_White); clutter_actor_set_position (box, 100, 50); clutter_actor_set_width (box, 200); /* pack an actor into the layout and set all layout properties on it * at the same time */ yellow = clutter_actor_new (); clutter_actor_set_background_color (yellow, CLUTTER_COLOR_Yellow); clutter_actor_set_size (yellow, 100, 100); clutter_box_layout_pack (CLUTTER_BOX_LAYOUT (box_layout), yellow, FALSE, /* expand */ TRUE, /* x-fill */ FALSE, /* y-fill */ CLUTTER_BOX_ALIGNMENT_START, /* x-align */ CLUTTER_BOX_ALIGNMENT_START); /* y-align */ /* add an actor to the box as a container and set layout properties * afterwards; the latter is useful if you want to change properties on * actors already inside a layout, but note that you have to * pass the function both the layout AND the container */ red = clutter_actor_new (); clutter_actor_set_background_color (red, CLUTTER_COLOR_Red); clutter_actor_set_size (red, 100, 100); clutter_actor_add_child (box, red); clutter_layout_manager_child_set (box_layout, CLUTTER_CONTAINER (box), red, "x-fill", TRUE, NULL); blue = clutter_actor_new (); clutter_actor_set_background_color (blue, CLUTTER_COLOR_Blue); clutter_actor_set_size (blue, 100, 100); clutter_actor_add_child (box, blue); clutter_layout_manager_child_set (box_layout, CLUTTER_CONTAINER (box), blue, "x-fill", TRUE, NULL); /* put the box on the stage */ clutter_actor_add_child (stage, box); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }
G_MODULE_EXPORT gint test_text_field_main (gint argc, gchar **argv) { ClutterActor *stage; ClutterActor *box, *label, *entry; ClutterLayoutManager *table; PangoAttrList *entry_attrs; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return EXIT_FAILURE; stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Text Fields"); clutter_actor_set_background_color (stage, CLUTTER_COLOR_Black); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); table = clutter_table_layout_new (); clutter_table_layout_set_column_spacing (CLUTTER_TABLE_LAYOUT (table), 6); clutter_table_layout_set_row_spacing (CLUTTER_TABLE_LAYOUT (table), 6); box = clutter_actor_new (); clutter_actor_set_layout_manager (box, table); clutter_actor_add_constraint (box, clutter_bind_constraint_new (stage, CLUTTER_BIND_WIDTH, -24.0)); clutter_actor_add_constraint (box, clutter_bind_constraint_new (stage, CLUTTER_BIND_HEIGHT, -24.0)); clutter_actor_set_position (box, 12, 12); clutter_actor_add_child (stage, box); label = create_label (CLUTTER_COLOR_White, "<b>Input field:</b>"); g_object_set (label, "min-width", 150.0, NULL); clutter_actor_add_child (box, label); clutter_layout_manager_child_set (table, CLUTTER_CONTAINER (box), label, "row", 0, "column", 0, "x-expand", FALSE, "y-expand", FALSE, NULL); entry_attrs = pango_attr_list_new (); pango_attr_list_insert (entry_attrs, pango_attr_underline_new (PANGO_UNDERLINE_ERROR)); pango_attr_list_insert (entry_attrs, pango_attr_underline_color_new (65535, 0, 0)); entry = create_entry (CLUTTER_COLOR_Black, "somme misspeeled textt", entry_attrs, 0, 0); clutter_actor_add_child (box, entry); clutter_layout_manager_child_set (table, CLUTTER_CONTAINER (box), entry, "row", 0, "column", 1, "x-expand", TRUE, "x-fill", TRUE, "y-expand", FALSE, NULL); clutter_actor_grab_key_focus (entry); label = create_label (CLUTTER_COLOR_White, "<b>A very long password field:</b>"); clutter_actor_add_child (box, label); clutter_layout_manager_child_set (table, CLUTTER_CONTAINER (box), label, "row", 1, "column", 0, "x-expand", FALSE, "y-expand", FALSE, NULL); entry = create_entry (CLUTTER_COLOR_Black, "password", NULL, '*', 8); clutter_actor_add_child (box, entry); clutter_layout_manager_child_set (table, CLUTTER_CONTAINER (box), entry, "row", 1, "column", 1, "x-expand", TRUE, "x-fill", TRUE, "y-expand", FALSE, NULL); clutter_actor_show (stage); clutter_main (); return EXIT_SUCCESS; }