ui/gtk/container.c

Sat, 30 Aug 2014 22:48:46 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 30 Aug 2014 22:48:46 +0200
changeset 58
2b124f8ebd95
parent 52
25e5390cce41
child 59
eb6611be50c7
permissions
-rw-r--r--

added table view (Qt)

4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2014 Olaf Wintermann. All rights reserved.
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
39b9b86ec452 added simple container
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
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #include <stdlib.h>
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 #include "container.h"
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include "../common/context.h"
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
34 #include "../common/object.h"
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
35
4
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 UiContainer* ui_frame_container(UiObject *obj, GtkWidget *frame) {
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38 UiContainer *ct = ucx_mempool_malloc(
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 obj->ctx->mempool,
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 sizeof(UiContainer));
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 ct->widget = frame;
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 ct->add = ui_frame_container_add;
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 return ct;
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 }
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 void ui_frame_container_add(UiContainer *ct, GtkWidget *widget) {
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 gtk_container_add(GTK_CONTAINER(ct->widget), widget);
39b9b86ec452 added simple container
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 }
33
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
49
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
50
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
51 UIWIDGET ui_sidebar(UiObject *obj) {
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
52 #ifdef UI_GTK3
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
53 GtkWidget *paned = gtk_paned_new(GTK_ORIENTATION_HORIZONTAL);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
54 #else
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
55 GtkWidget *paned = gtk_hpaned_new();
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
56 #endif
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
57 gtk_paned_set_position(GTK_PANED(paned), 200);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
58
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
59 GtkWidget *sidebar;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
60 #ifdef UI_GTK3
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
61 sidebar = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
62 #else
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
63 sidebar = gtk_vbox_new(FALSE, 0);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
64 #endif
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
65 gtk_paned_pack1(GTK_PANED(paned), sidebar, TRUE, FALSE);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
66
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
67 UiObject *left = uic_object_new(obj, sidebar);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
68 UiContainer *ct1 = ucx_mempool_malloc(
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
69 obj->ctx->mempool,
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
70 sizeof(UiContainer));
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
71 ct1->widget = sidebar;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
72 ct1->add = ui_box_add;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
73 left->container = ct1;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
74
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
75 UiObject *right = uic_object_new(obj, sidebar);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
76 UiContainer *ct2 = ucx_mempool_malloc(
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
77 obj->ctx->mempool,
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
78 sizeof(UiContainer));
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
79 ct2->widget = paned;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
80 ct2->add = ui_split_container_add2;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
81 right->container = ct2;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
82
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
83 UiContainer *ct = uic_get_current_container(obj);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
84 ct->add(ct, paned);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
85
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
86 uic_obj_add(obj, right);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
87 uic_obj_add(obj, left);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
88
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
89 return sidebar;
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
90 }
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
91
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
92 void ui_split_container_add1(UiContainer *ct, GtkWidget *widget) {
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
93 gtk_paned_pack1(GTK_PANED(ct->widget), widget, TRUE, FALSE);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
94 }
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
95
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
96 void ui_split_container_add2(UiContainer *ct, GtkWidget *widget) {
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
97 gtk_paned_pack2(GTK_PANED(ct->widget), widget, TRUE, FALSE);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
98 }
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
99
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
100
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
101 void ui_box_add(UiContainer *ct, GtkWidget *widget) {
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
102 gtk_box_pack_start(GTK_BOX(ct->widget), widget, TRUE, TRUE, 0);
458831c574f4 added listview, sidebar and toolbar image button (GTK)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 4
diff changeset
103 }
52
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
104
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
105
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
106
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
107
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
108 static void page_change(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer data) {
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
109 GQuark q = g_quark_from_static_string("ui.tab.object");
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
110 UiObject *tab = g_object_get_qdata(G_OBJECT(page), q);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
111 if(!tab) {
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
112 return;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
113 }
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
114
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
115 printf("page_change: %d\n", page_num);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
116 UiContext *ctx = tab->ctx;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
117 ctx->parent->set_document(ctx->parent, ctx->document);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
118 }
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
119
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
120 UiTabbedPane* ui_tabbed_document_view(UiObject *obj) {
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
121 GtkWidget *tabview = gtk_notebook_new();
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
122 gtk_notebook_set_show_border(GTK_NOTEBOOK(tabview), FALSE);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
123
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
124 g_signal_connect(
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
125 tabview,
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
126 "switch-page",
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
127 G_CALLBACK(page_change),
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
128 NULL);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
129
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
130 UiContainer *ct = uic_get_current_container(obj);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
131 ct->add(ct, tabview);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
132
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
133 UiTabbedPane *tabbedpane = ui_malloc(obj->ctx, sizeof(UiTabbedPane));
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
134 tabbedpane->ctx = uic_current_obj(obj)->ctx;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
135 tabbedpane->widget = tabview;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
136 tabbedpane->document = NULL;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
137
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
138 return tabbedpane;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
139 }
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
140
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
141 UiObject* ui_document_tab(UiTabbedPane *view) {
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
142 GtkWidget *frame = gtk_alignment_new(0.5, 0.5, 1, 1);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
143 // TODO: label
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
144 gtk_notebook_append_page(GTK_NOTEBOOK(view->widget), frame, NULL);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
145
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
146 UiObject *tab = ui_malloc(view->ctx, sizeof(UiObject));
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
147 tab->widget = NULL; // initialization for uic_context()
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
148 tab->ctx = uic_context(tab, view->ctx->mempool);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
149 tab->ctx->parent = view->ctx;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
150 tab->ctx->set_document = ui_tab_set_document;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
151 tab->ctx->detach_document = ui_tab_detach_document;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
152 tab->widget = frame;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
153 tab->window = view->ctx->obj->window;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
154 tab->container = ui_frame_container(tab, frame);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
155 tab->next = NULL;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
156
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
157 GQuark q = g_quark_from_static_string("ui.tab.object");
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
158 g_object_set_qdata(G_OBJECT(frame), q, tab);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
159
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
160 return tab;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
161 }
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
162
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
163 void ui_tab_set_document(UiContext *ctx, void *document) {
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
164 if(ctx->parent->document) {
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
165 //ctx->parent->detach_document(ctx->parent, ctx->parent->document);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
166 }
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
167 uic_context_set_document(ctx, document);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
168 //uic_context_set_document(ctx->parent, document);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
169 //ctx->parent->document = document;
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
170 }
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
171
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
172 void ui_tab_detach_document(UiContext *ctx, void *document) {
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
173 uic_context_detach_document(ctx->parent, document);
25e5390cce41 added document tabview (GTK, Motif)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 33
diff changeset
174 }

mercurial