static GPtrArray *create_rows(PyObject *resultset){ assert(resultset); //Now the resultset has been checked in create_fields. PyObject *res_rows = PyDict_GetItemString(resultset, "rows"); if(!res_rows) return NULL; if(!PySequence_Check(res_rows)){ PyErr_SetString(PyExc_ValueError, "proxy.response.resultset.rows .." " should be a sequence"); return NULL; } GPtrArray *rows = g_ptr_array_new(); int i = 0; for(i = 0; i < PySequence_Size(res_rows); i++){ PyObject *item = PySequence_GetItem(res_rows, i); if(!item) goto failed; if(!PySequence_Check(item)){ PyErr_SetString(PyExc_ValueError, "proxy.response.resultset.rows' " "items should be sequences"); Py_DECREF(item); goto failed; } GPtrArray *row = create_row(item); Py_DECREF(item); if(!row) goto failed; g_ptr_array_add(rows, row); } return rows; failed: g_ptr_array_clear_r(rows); return NULL; }
int main (int argc, char *argv[]) { GtkWidget *window, *list, *sw, *row; GtkWidget *hbox, *vbox, *combo, *button; gint i; gchar *text; gtk_init (NULL, NULL); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (window), -1, 300); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); gtk_container_add (GTK_CONTAINER (window), hbox); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); g_object_set (vbox, "margin", 12, NULL); gtk_container_add (GTK_CONTAINER (hbox), vbox); list = gtk_list_box_new (); gtk_list_box_set_selection_mode (GTK_LIST_BOX (list), GTK_SELECTION_NONE); g_signal_connect (list, "row-activated", G_CALLBACK (on_row_activated), NULL); g_signal_connect (list, "selected-rows-changed", G_CALLBACK (on_selected_children_changed), NULL); g_signal_connect (gtk_widget_get_accessible (list), "selection-changed", G_CALLBACK (a11y_selection_changed), NULL); sw = gtk_scrolled_window_new (NULL, NULL); gtk_widget_set_hexpand (sw, TRUE); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); gtk_container_add (GTK_CONTAINER (hbox), sw); gtk_container_add (GTK_CONTAINER (sw), list); button = gtk_check_button_new_with_label ("Activate on single click"); g_object_bind_property (list, "activate-on-single-click", button, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); gtk_container_add (GTK_CONTAINER (vbox), button); combo = gtk_combo_box_text_new (); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "None"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "Single"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "Browse"); gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "Multiple"); g_signal_connect (combo, "changed", G_CALLBACK (selection_mode_changed), list); gtk_container_add (GTK_CONTAINER (vbox), combo); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), gtk_list_box_get_selection_mode (GTK_LIST_BOX (list))); for (i = 0; i < 20; i++) { text = g_strdup_printf ("Row %d", i); row = create_row (text); gtk_list_box_insert (GTK_LIST_BOX (list), row, -1); } gtk_widget_show_all (window); gtk_main (); return 0; }
QStandardItem* mail_item_model::insert_msg(mail_msg* msg, QStandardItem* parent/*=NULL*/) { QList<QStandardItem*> items; create_row(msg, items); if (parent) parent->appendRow(items); else appendRow(items); items_map.insert(msg->get_id(), items[0]); return items[0]; }
void hippo_canvas_open_test_window(void) { GtkWidget *window; GtkWidget *canvas; HippoCanvasItem *root; HippoCanvasItem *shape1; HippoCanvasItem *shape2; int i; window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width(GTK_CONTAINER(window), 10); canvas = hippo_canvas_new(); gtk_widget_show(canvas); gtk_container_add(GTK_CONTAINER(window), canvas); root = HIPPO_CANVAS_ITEM(hippo_canvas_box_new()); #if 0 shape1 = g_object_new(HIPPO_TYPE_CANVAS_SHAPE, "width", 50, "height", 100, NULL); shape2 = g_object_new(HIPPO_TYPE_CANVAS_SHAPE, "width", 70, "height", 40, "color", 0x00ff00ff, NULL); hippo_canvas_box_append(HIPPO_CANVAS_BOX(root), shape1, 0); g_object_unref(shape1); hippo_canvas_box_append(HIPPO_CANVAS_BOX(root), shape2, 0); g_object_unref(shape2); #endif for (i = 0; i < (int) G_N_ELEMENTS(box_rows); ++i) { HippoCanvasItem *row = create_row(box_rows[i]); hippo_canvas_box_append(HIPPO_CANVAS_BOX(root), row, 0); g_object_unref(row); } hippo_canvas_set_root(HIPPO_CANVAS(canvas), root); g_object_unref(root); gtk_widget_show(window); }
QStandardItem* mail_item_model::insert_msg_sorted(mail_msg* msg, QStandardItem* parent, int column, Qt::SortOrder order) { DBG_PRINTF(4, "insert_msg_sorted order=%d column=%d", (int)order, column); QList<QStandardItem*> items; create_row(msg, items); QStandardItem* item = items[0]; int row = insertion_point(items, parent, column, order); DBG_PRINTF(4, "insertion point=%d", row); if (parent) { parent->insertRow(row, items); } else { insertRow(row, items); } items_map.insert(msg->get_id(), item); return item; }
HippoCanvasItem* hippo_canvas_test_get_root(void) { HippoCanvasItem *root; HippoCanvasItem *shape2; HippoCanvasItem *text; #if 0 HippoCanvasItem *image; HippoCanvasItem *row; HippoCanvasItem *shape1; int i; root = g_object_new(HIPPO_TYPE_CANVAS_STACK, "box-width", 400, "spacing", 8, NULL); row = g_object_new(HIPPO_TYPE_CANVAS_BLOCK, NULL); hippo_canvas_box_append(HIPPO_CANVAS_BOX(root), row, 0); row = g_object_new(HIPPO_TYPE_CANVAS_BLOCK, NULL); hippo_canvas_box_append(HIPPO_CANVAS_BOX(root), row, 0); #if 0 #if 1 shape1 = g_object_new(HIPPO_TYPE_CANVAS_SHAPE, "width", 50, "height", 30, "color", 0xaeaeaeff, "padding", 20, NULL); shape2 = g_object_new(HIPPO_TYPE_CANVAS_SHAPE, "width", 50, "height", 30, "color", 0x00ff00ff, "padding", 10, NULL); hippo_canvas_box_append(HIPPO_CANVAS_BOX(root), shape1, 0); hippo_canvas_box_append(HIPPO_CANVAS_BOX(root), shape2, 0); #endif for (i = 0; i < (int) G_N_ELEMENTS(box_rows); ++i) { row = create_row(box_rows[i]); hippo_canvas_box_append(HIPPO_CANVAS_BOX(root), row, 0); } text = g_object_new(HIPPO_TYPE_CANVAS_LINK, "text", "Click here", "background-color", 0x990000ff, NULL); hippo_canvas_box_append(HIPPO_CANVAS_BOX(root), text, HIPPO_PACK_EXPAND); row = g_object_new(HIPPO_TYPE_CANVAS_BOX, "orientation", HIPPO_ORIENTATION_HORIZONTAL, "spacing", 5, NULL); hippo_canvas_box_append(HIPPO_CANVAS_BOX(root), row, HIPPO_PACK_EXPAND); image = g_object_new(HIPPO_TYPE_CANVAS_IMAGE, "image-name", "chaticon", "xalign", HIPPO_ALIGNMENT_START, "yalign", HIPPO_ALIGNMENT_END, "background-color", 0xffff00ff, NULL); hippo_canvas_box_append(HIPPO_CANVAS_BOX(row), image, 0); image = g_object_new(HIPPO_TYPE_CANVAS_IMAGE, "image-name", "ignoreicon", "xalign", HIPPO_ALIGNMENT_FILL, "yalign", HIPPO_ALIGNMENT_FILL, "background-color", 0x00ff00ff, NULL); hippo_canvas_box_append(HIPPO_CANVAS_BOX(row), image, HIPPO_PACK_EXPAND); text = g_object_new(HIPPO_TYPE_CANVAS_TEXT, "size-mode", HIPPO_CANVAS_SIZE_WRAP_WORD, "text", "This is some long text that may help in testing resize behavior. It goes " "on for a while, so don't get impatient. More and more and more text. " "Text text text. Lorem ipsum! Text! This is the story of text.", "background-color", 0x0000ff00, "yalign", HIPPO_ALIGNMENT_END, NULL); hippo_canvas_box_append(HIPPO_CANVAS_BOX(root), text, HIPPO_PACK_EXPAND); #endif #endif root = g_object_new(HIPPO_TYPE_CANVAS_BOX, "orientation", HIPPO_ORIENTATION_VERTICAL, "border", 15, "border-color", 0xff0000ff, "padding", 25, "background-color", 0x00ff00ff, NULL); #if 0 text = g_object_new(HIPPO_TYPE_CANVAS_TEXT, "text", "Click here", "color", 0xffffffff, "background-color", 0x0000ffff, NULL); #else text = g_object_new(HIPPO_TYPE_CANVAS_IMAGE, "image-name", "nophoto", "background-color", 0x0000ffff, "xalign", HIPPO_ALIGNMENT_CENTER, "yalign", HIPPO_ALIGNMENT_CENTER, NULL); #endif #if 0 { GtkWidget *widget = gtk_label_new("FOOO! GtkLabel"); gtk_widget_show(widget); shape1 = g_object_new(HIPPO_TYPE_CANVAS_WIDGET, "widget", widget, "background-color", 0x0000ffff, "xalign", HIPPO_ALIGNMENT_CENTER, "yalign", HIPPO_ALIGNMENT_CENTER, NULL); } hippo_canvas_box_append(HIPPO_CANVAS_BOX(root), shape1, HIPPO_PACK_EXPAND); text = g_object_new(HIPPO_TYPE_CANVAS_LINK, "text", "Fixed link inside label item", "background-color", 0xffffffff, NULL); hippo_canvas_box_append(HIPPO_CANVAS_BOX(shape1), text, HIPPO_PACK_FIXED); hippo_canvas_box_move(HIPPO_CANVAS_BOX(shape1), text, 50, 50); #endif #if 0 /* Item that changes on hover */ text = g_object_new(HIPPO_TYPE_CANVAS_TEXT, "text", "Text item packed end", "color", 0xffffffff, "background-color", 0x0000ffff, NULL); hippo_canvas_box_append(HIPPO_CANVAS_BOX(root), text, HIPPO_PACK_END); g_signal_connect(G_OBJECT(text), "hovering-changed", G_CALLBACK(change_text_on_hovering), NULL); #endif #if 0 /* Fixed items */ text = g_object_new(HIPPO_TYPE_CANVAS_LINK, "text", "Fixed position link item", "background-color", 0xffffffff, NULL); hippo_canvas_box_append(HIPPO_CANVAS_BOX(root), text, HIPPO_PACK_FIXED); hippo_canvas_box_move(HIPPO_CANVAS_BOX(root), text, HIPPO_GRAVITY_NORTH_WEST, 150, 150); #endif #if 0 /* For get_natural_width testing */ shape2 = create_test_box_layout_root(); hippo_canvas_box_append(HIPPO_CANVAS_BOX(root), shape2, HIPPO_PACK_END | HIPPO_PACK_EXPAND); #endif #if 0 /* For float testing */ shape2 = create_floated_box_layout_root(); hippo_canvas_box_append(HIPPO_CANVAS_BOX(root), shape2, HIPPO_PACK_EXPAND); #endif shape2 = create_test_click_release_root(); hippo_canvas_box_append(HIPPO_CANVAS_BOX(root), shape2, HIPPO_PACK_EXPAND); #if 0 /* A box with nothing expandable in it */ shape2 = g_object_new(HIPPO_TYPE_CANVAS_BOX, "orientation", HIPPO_ORIENTATION_HORIZONTAL, NULL); hippo_canvas_box_append(HIPPO_CANVAS_BOX(root), shape2, HIPPO_PACK_END); text = g_object_new(HIPPO_TYPE_CANVAS_TEXT, "text", "No expand/ellipse", "background-color", 0xaaaaaaff, NULL); hippo_canvas_box_append(HIPPO_CANVAS_BOX(shape2), text, 0); #endif return root; }