Thu, 10 Sep 2026 17:36:06 +0200
define sourcelist2 widget
|
1244
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2026 Olaf Wintermann. All rights reserved. |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | #include "tree.h" |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | #include "list.h" |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | #include "container.h" |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | #include "../common/context.h" |
|
a29b53f97d1a
add API spec for new treeview
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | |
|
1245
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
35 | UiListView* ui_create_treeview(UiObject *obj, UiTreeArgs *args) { |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
36 | UiListView *treeview = malloc(sizeof(UiListView)); |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
37 | memset(treeview, 0, sizeof(UiListView)); |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
38 | treeview->obj = obj; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
39 | treeview->model = args->model; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
40 | treeview->multiselection = args->multiselection; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
41 | treeview->onactivate = args->onactivate; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
42 | treeview->onactivatedata = args->onactivatedata; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
43 | treeview->onactivate_action = args->onactivate_action ? strdup(args->onactivate_action) : NULL; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
44 | treeview->onselection = args->onselection; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
45 | treeview->onselectiondata = args->onselectiondata; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
46 | treeview->onselection_action = args->onselection_action ? strdup(args->onselection_action) : NULL; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
47 | treeview->ondragstart = args->ondragstart; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
48 | treeview->ondragstartdata = args->ondragstartdata; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
49 | treeview->ondragstart_action = args->ondragstart_action ? strdup(args->ondragstart_action) : NULL; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
50 | treeview->ondragcomplete = args->ondragcomplete; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
51 | treeview->ondragcompletedata = args->ondragcompletedata; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
52 | treeview->ondragcomplete_action = args->ondragcomplete_action ? strdup(args->ondragcomplete_action) : NULL; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
53 | treeview->ondrop = args->ondrop; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
54 | treeview->ondropdata = args->ondropdata; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
55 | treeview->ondrop_action = args->ondrop_action ? strdup(args->ondrop_action) : NULL; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
56 | treeview->selection.count = 0; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
57 | treeview->selection.rows = NULL; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
58 | treeview->current_row = -1; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
59 | |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
60 | #if GTK_CHECK_VERSION(4, 0, 0) |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
61 | treeview->coldata.listview = treeview; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
62 | treeview->coldata.column = 0; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
63 | #endif |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
64 | |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
65 | if(args->getvalue != NULL) { |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
66 | treeview->getvalue = args->getvalue; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
67 | treeview->getvaluedata = args->getvaluedata; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
68 | } else { |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
69 | args->getvalue = ui_null_getvalue; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
70 | } |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
71 | |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
72 | treeview->istreeview = TRUE; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
73 | treeview->getdepth = args->getdepth; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
74 | treeview->getdepthdata = args->getdepthdata; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
75 | |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
76 | return treeview; |
|
4163776eef49
define sourcelist2 widget
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1244
diff
changeset
|
77 | } |