/* Scrolls list vertically. This supposes that the list is packed into a * scrolled window or something similar, and adjustments are well set. Step * and page increment are those from the vertical adjustment of list. * Backward means up, and forward down. Out of bounds values are truncated. * scroll_type may be any valid GtkScrollType. If scroll_type is GTK_SCROLL_NONE, * nothing is done. If it's GTK_SCROLL_JUMP, the list scrolls to the ratio * position: 0 is top, 1 is bottom. */ int clip_GTK_LISTSCROLLVERTICAL(ClipMachine * ClipMachineMemory) { C_widget *clst = _fetch_cw_arg(ClipMachineMemory); GtkScrollType scroll_type = _clip_parni(ClipMachineMemory, 2); gfloat position = _clip_parnd(ClipMachineMemory, 3); CHECKCWID(clst, GTK_IS_LIST); CHECKOPT(2, NUMERIC_type_of_ClipVarType); CHECKOPT(3, NUMERIC_type_of_ClipVarType); gtk_list_scroll_vertical(GTK_LIST(clst->widget), scroll_type, position); return 0; err: return 1; }
static void add_message(GtkWidget *list, const char *str, ...) { static int line = 0; va_list ap; char buf[BUFSIZ]; GList *items = NULL; GtkWidget *item; va_start(ap, str); vsnprintf(buf, sizeof(buf), str, ap); va_end(ap); item = gtk_list_item_new_with_label(buf); gtk_widget_show(item); items = g_list_append(items, item); gtk_list_append_items(GTK_LIST(list), items); line++; gtk_list_scroll_vertical(GTK_LIST(list), GTK_SCROLL_JUMP, 1.0); }