| 26 * POSSIBILITY OF SUCH DAMAGE. |
26 * POSSIBILITY OF SUCH DAMAGE. |
| 27 */ |
27 */ |
| 28 |
28 |
| 29 #include <stdio.h> |
29 #include <stdio.h> |
| 30 #include <stdlib.h> |
30 #include <stdlib.h> |
| |
31 #include <string.h> |
| 31 #include <limits.h> |
32 #include <limits.h> |
| 32 |
33 |
| 33 #include "container.h" |
34 #include "container.h" |
| 34 #include "toolkit.h" |
35 #include "toolkit.h" |
| 35 #include "headerbar.h" |
36 #include "headerbar.h" |
| 36 |
37 |
| 37 #include "../common/context.h" |
38 #include "../common/context.h" |
| 38 #include "../common/object.h" |
39 #include "../common/object.h" |
| |
40 |
| |
41 #include "../ui/properties.h" |
| 39 |
42 |
| 40 |
43 |
| 41 void ui_container_begin_close(UiObject *obj) { |
44 void ui_container_begin_close(UiObject *obj) { |
| 42 UiContainer *ct = uic_get_current_container(obj); |
45 UiContainer *ct = uic_get_current_container(obj); |
| 43 ct->close = 1; |
46 ct->close = 1; |
| 1065 } |
1068 } |
| 1066 #endif |
1069 #endif |
| 1067 return NULL; |
1070 return NULL; |
| 1068 } |
1071 } |
| 1069 |
1072 |
| 1070 |
1073 static void save_pane_pos(GtkWidget *widget, char *property_name) { |
| |
1074 int pos = gtk_paned_get_position(GTK_PANED(widget)); |
| |
1075 char buf[32]; |
| |
1076 snprintf(buf, 32, "%d", pos); |
| |
1077 ui_set_property(property_name, buf); |
| |
1078 free(property_name); |
| |
1079 } |
| 1071 |
1080 |
| 1072 static UIWIDGET splitpane_create(UiObject *obj, UiOrientation orientation, UiSplitPaneArgs *args) { |
1081 static UIWIDGET splitpane_create(UiObject *obj, UiOrientation orientation, UiSplitPaneArgs *args) { |
| 1073 UiObject* current = uic_current_obj(obj); |
1082 UiObject* current = uic_current_obj(obj); |
| 1074 |
1083 |
| 1075 GtkWidget *pane0 = create_paned(orientation); |
1084 GtkWidget *pane0 = create_paned(orientation); |
| 1076 |
1085 |
| 1077 UI_APPLY_LAYOUT2(current, args); |
1086 UI_APPLY_LAYOUT2(current, args); |
| 1078 current->container->add(current->container, pane0); |
1087 current->container->add(current->container, pane0); |
| 1079 |
1088 |
| 1080 int max = args->max_panes == 0 ? 2 : args->max_panes; |
1089 int max = args->max_panes == 0 ? 2 : args->max_panes; |
| |
1090 |
| |
1091 if(args->position_property) { |
| |
1092 const char *pos_str = ui_get_property(args->position_property); |
| |
1093 if(pos_str) { |
| |
1094 char *end; |
| |
1095 long pos = strtol(pos_str, &end, 10); |
| |
1096 if(*end = '\0') { |
| |
1097 args->initial_position = (int)pos; |
| |
1098 } |
| |
1099 } |
| |
1100 |
| |
1101 g_signal_connect( |
| |
1102 pane0, |
| |
1103 "destroy", |
| |
1104 G_CALLBACK(save_pane_pos), |
| |
1105 strdup(args->position_property)); |
| |
1106 } |
| 1081 |
1107 |
| 1082 UiObject *newobj = uic_object_new(obj, pane0); |
1108 UiObject *newobj = uic_object_new(obj, pane0); |
| 1083 newobj->container = ui_splitpane_container(obj, pane0, orientation, max, args->initial_position); |
1109 newobj->container = ui_splitpane_container(obj, pane0, orientation, max, args->initial_position); |
| 1084 uic_obj_add(obj, newobj); |
1110 uic_obj_add(obj, newobj); |
| 1085 |
1111 |