ui/gtk/list.c

changeset 88
e27526429d85
parent 80
1a908b060122
child 90
f501f0efc9a8
equal deleted inserted replaced
87:5360027fb282 88:e27526429d85
35 #include "../common/object.h" 35 #include "../common/object.h"
36 #include "container.h" 36 #include "container.h"
37 37
38 #include "list.h" 38 #include "list.h"
39 #include "icon.h" 39 #include "icon.h"
40 #include "menu.h"
40 41
41 42
42 void* ui_strmodel_getvalue(void *elm, int column) { 43 void* ui_strmodel_getvalue(void *elm, int column) {
43 return column == 0 ? elm : NULL; 44 return column == 0 ? elm : NULL;
44 } 45 }
233 selection, 234 selection,
234 "changed", 235 "changed",
235 G_CALLBACK(ui_listview_selection_event), 236 G_CALLBACK(ui_listview_selection_event),
236 event); 237 event);
237 } 238 }
239 if(args.contextmenu) {
240 UIMENU menu = ui_contextmenu_create(args.contextmenu, obj, view);
241 ui_widget_set_contextmenu(view, menu);
242 }
238 243
239 244
240 // add widget to the current container 245 // add widget to the current container
241 GtkWidget *scroll_area = SCROLLEDWINDOW_NEW(); 246 GtkWidget *scroll_area = SCROLLEDWINDOW_NEW();
242 gtk_scrolled_window_set_policy( 247 gtk_scrolled_window_set_policy(
368 tableview); 373 tableview);
369 374
370 // bind var 375 // bind var
371 list->update = ui_listview_update; 376 list->update = ui_listview_update;
372 list->getselection = ui_listview_getselection; 377 list->getselection = ui_listview_getselection;
378 list->setselection = ui_listview_setselection;
373 list->obj = tableview; 379 list->obj = tableview;
374 380
375 // add callback 381 // add callback
376 UiTreeEventData *event = ui_malloc(obj->ctx, sizeof(UiTreeEventData)); 382 UiTreeEventData *event = ui_malloc(obj->ctx, sizeof(UiTreeEventData));
377 event->obj = obj; 383 event->obj = obj;
394 "changed", 400 "changed",
395 G_CALLBACK(ui_listview_selection_event), 401 G_CALLBACK(ui_listview_selection_event),
396 event); 402 event);
397 } 403 }
398 // TODO: destroy callback 404 // TODO: destroy callback
399 405
400 406
401 GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view)); 407 GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
402 if(args.multiselection) { 408 if(args.multiselection) {
403 gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE); 409 gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
404 } 410 }
405 411
408 gtk_scrolled_window_set_policy( 414 gtk_scrolled_window_set_policy(
409 GTK_SCROLLED_WINDOW(scroll_area), 415 GTK_SCROLLED_WINDOW(scroll_area),
410 GTK_POLICY_AUTOMATIC, 416 GTK_POLICY_AUTOMATIC,
411 GTK_POLICY_AUTOMATIC); // GTK_POLICY_ALWAYS 417 GTK_POLICY_AUTOMATIC); // GTK_POLICY_ALWAYS
412 SCROLLEDWINDOW_SET_CHILD(scroll_area, view); 418 SCROLLEDWINDOW_SET_CHILD(scroll_area, view);
419
420 if(args.contextmenu) {
421 UIMENU menu = ui_contextmenu_create(args.contextmenu, obj, scroll_area);
422 ui_widget_set_contextmenu(scroll_area, menu);
423 }
413 424
414 UI_APPLY_LAYOUT1(current, args); 425 UI_APPLY_LAYOUT1(current, args);
415 current->container->add(current->container, scroll_area, FALSE); 426 current->container->add(current->container, scroll_area, FALSE);
416 427
417 // ct->current should point to view, not scroll_area, to make it possible 428 // ct->current should point to view, not scroll_area, to make it possible

mercurial