Mercurial > geeqie
comparison src/layout.c @ 1466:6e020d3ab168
added possibility to update existing layout window from config
author | nadvornik |
---|---|
date | Fri, 20 Mar 2009 14:36:59 +0000 |
parents | 1b3751ac4743 |
children | 38925ff71a46 |
comparison
equal
deleted
inserted
replaced
1465:400ecfc3d8b1 | 1466:6e020d3ab168 |
---|---|
112 } | 112 } |
113 | 113 |
114 return NULL; | 114 return NULL; |
115 } | 115 } |
116 | 116 |
117 LayoutWindow *layout_find_by_layout_id(const gchar *id) | |
118 { | |
119 GList *work; | |
120 | |
121 if (!id || !id[0]) return NULL; | |
122 work = layout_window_list; | |
123 while (work) | |
124 { | |
125 LayoutWindow *lw = work->data; | |
126 work = work->next; | |
127 | |
128 if (lw->options.id && strcmp(id, lw->options.id) == 0) | |
129 return lw; | |
130 } | |
131 | |
132 return NULL; | |
133 } | |
134 | |
135 static void layout_set_unique_id(LayoutWindow *lw) | |
136 { | |
137 char id[10]; | |
138 gint i; | |
139 if (lw->options.id && lw->options.id[0]) return; /* id is already set */ | |
140 | |
141 g_free(lw->options.id); | |
142 lw->options.id = NULL; | |
143 | |
144 if (!layout_find_by_layout_id("main")) | |
145 { | |
146 lw->options.id = g_strdup("main"); | |
147 return; | |
148 } | |
149 | |
150 i = 1; | |
151 while (TRUE) | |
152 { | |
153 g_snprintf(id, sizeof(id), "lw%d", i); | |
154 if (!layout_find_by_layout_id(id)) | |
155 { | |
156 lw->options.id = g_strdup(id); | |
157 return; | |
158 } | |
159 i++; | |
160 } | |
161 } | |
162 | |
117 /* | 163 /* |
118 *----------------------------------------------------------------------------- | 164 *----------------------------------------------------------------------------- |
119 * menu, toolbar, and dir view | 165 * menu, toolbar, and dir view |
120 *----------------------------------------------------------------------------- | 166 *----------------------------------------------------------------------------- |
121 */ | 167 */ |
2208 init_layout_options(&lw->options); | 2254 init_layout_options(&lw->options); |
2209 | 2255 |
2210 lw->sort_method = SORT_NAME; | 2256 lw->sort_method = SORT_NAME; |
2211 lw->sort_ascend = TRUE; | 2257 lw->sort_ascend = TRUE; |
2212 | 2258 |
2259 layout_set_unique_id(lw); | |
2213 // lw->options.tools_float = popped; | 2260 // lw->options.tools_float = popped; |
2214 // lw->options.tools_hidden = hidden; | 2261 // lw->options.tools_hidden = hidden; |
2215 // lw->bar_sort_enabled = options->panels.sort.enabled; | 2262 // lw->bar_sort_enabled = options->panels.sort.enabled; |
2216 // lw->bar_enabled = options->panels.info.enabled; | 2263 // lw->bar_enabled = options->panels.info.enabled; |
2217 | 2264 |
2326 return lw; | 2373 return lw; |
2327 } | 2374 } |
2328 | 2375 |
2329 void layout_write_attributes(LayoutOptions *layout, GString *outstr, gint indent) | 2376 void layout_write_attributes(LayoutOptions *layout, GString *outstr, gint indent) |
2330 { | 2377 { |
2378 WRITE_NL(); WRITE_CHAR(*layout, id); | |
2379 | |
2331 WRITE_NL(); WRITE_INT(*layout, style); | 2380 WRITE_NL(); WRITE_INT(*layout, style); |
2332 WRITE_NL(); WRITE_CHAR(*layout, order); | 2381 WRITE_NL(); WRITE_CHAR(*layout, order); |
2333 WRITE_NL(); WRITE_UINT(*layout, dir_view_type); | 2382 WRITE_NL(); WRITE_UINT(*layout, dir_view_type); |
2334 WRITE_NL(); WRITE_UINT(*layout, file_view_type); | 2383 WRITE_NL(); WRITE_UINT(*layout, file_view_type); |
2335 WRITE_NL(); WRITE_BOOL(*layout, show_marks); | 2384 WRITE_NL(); WRITE_BOOL(*layout, show_marks); |
2393 { | 2442 { |
2394 const gchar *option = *attribute_names++; | 2443 const gchar *option = *attribute_names++; |
2395 const gchar *value = *attribute_values++; | 2444 const gchar *value = *attribute_values++; |
2396 | 2445 |
2397 /* layout options */ | 2446 /* layout options */ |
2447 if (READ_CHAR(*layout, id)) continue; | |
2398 | 2448 |
2399 if (READ_INT(*layout, style)) continue; | 2449 if (READ_INT(*layout, style)) continue; |
2400 if (READ_CHAR(*layout, order)) continue; | 2450 if (READ_CHAR(*layout, order)) continue; |
2401 | 2451 |
2402 if (READ_UINT(*layout, dir_view_type)) continue; | 2452 if (READ_UINT(*layout, dir_view_type)) continue; |
2507 g_free(path); | 2557 g_free(path); |
2508 free_layout_options_content(&lop); | 2558 free_layout_options_content(&lop); |
2509 return lw; | 2559 return lw; |
2510 } | 2560 } |
2511 | 2561 |
2562 void layout_update_from_config(LayoutWindow *lw, const gchar **attribute_names, const gchar **attribute_values) | |
2563 { | |
2564 LayoutOptions lop; | |
2565 | |
2566 init_layout_options(&lop); | |
2567 | |
2568 if (attribute_names) layout_load_attributes(&lop, attribute_names, attribute_values); | |
2569 | |
2570 layout_apply_options(lw, &lop); | |
2571 | |
2572 free_layout_options_content(&lop); | |
2573 } | |
2574 | |
2512 | 2575 |
2513 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ | 2576 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |