comparison src/bar.c @ 1317:cd7204a18f14

simplified and improved bar configuration
author nadvornik
date Tue, 24 Feb 2009 20:34:39 +0000
parents 8cca18bce950
children 45bcfcb69f56
comparison
equal deleted inserted replaced
1316:732083928afb 1317:cd7204a18f14
41 FileData *fd; 41 FileData *fd;
42 GtkWidget *label_file_name; 42 GtkWidget *label_file_name;
43 43
44 GList *(*list_func)(gpointer); 44 GList *(*list_func)(gpointer);
45 gpointer list_data; 45 gpointer list_data;
46 gint width;
46 }; 47 };
47 48
48 static void bar_expander_move(GtkWidget *widget, gpointer data, gboolean up) 49 static void bar_expander_move(GtkWidget *widget, gpointer data, gboolean up)
49 { 50 {
50 GtkWidget *expander = data; 51 GtkWidget *expander = data;
154 GList *list, *work; 155 GList *list, *work;
155 if (!bar) return; 156 if (!bar) return;
156 bd = g_object_get_data(G_OBJECT(bar), "bar_data"); 157 bd = g_object_get_data(G_OBJECT(bar), "bar_data");
157 if (!bd) return; 158 if (!bd) return;
158 159
159 WRITE_STRING("<bar>\n"); 160 WRITE_STRING("<bar\n");
161 indent++;
162 write_bool_option(outstr, indent, "enabled", GTK_WIDGET_VISIBLE(bar));
163 write_uint_option(outstr, indent, "width", bd->width);
164 indent--;
165 WRITE_STRING(">\n");
160 166
161 list = gtk_container_get_children(GTK_CONTAINER(bd->vbox)); 167 list = gtk_container_get_children(GTK_CONTAINER(bd->vbox));
162 work = list; 168 work = list;
163 while (work) 169 while (work)
164 { 170 {
248 if (bd->list_func) bar_pane_set_selection_func(pane, bd->list_func, bd->list_data); 254 if (bd->list_func) bar_pane_set_selection_func(pane, bd->list_func, bd->list_data);
249 if (bd->fd && pd && pd->pane_set_fd) pd->pane_set_fd(pane, bd->fd); 255 if (bd->fd && pd && pd->pane_set_fd) pd->pane_set_fd(pane, bd->fd);
250 256
251 } 257 }
252 258
253 void bar_populate_default(GtkWidget *bar) 259 static void bar_populate_default(GtkWidget *bar)
254 { 260 {
255 GtkWidget *widget; 261 GtkWidget *widget;
256 widget = bar_pane_histogram_new(_("Histogram"), 80, TRUE); 262 widget = bar_pane_histogram_new(_("Histogram"), 80, TRUE);
257 bar_add(bar, widget); 263 bar_add(bar, widget);
258 264
267 273
268 widget = bar_pane_exif_new(_("Exif"), TRUE); 274 widget = bar_pane_exif_new(_("Exif"), TRUE);
269 bar_add(bar, widget); 275 bar_add(bar, widget);
270 } 276 }
271 277
278 static void bar_sized(GtkWidget *widget, GtkAllocation *allocation, gpointer data)
279 {
280 BarData *bd = data;
281 bd->width = allocation->width;
282 }
283
284
272 static void bar_width(BarData *bd, gint val) 285 static void bar_width(BarData *bd, gint val)
273 { 286 {
274 gint size; 287 gint size;
275 288
276 size = bd->widget->allocation.width; 289 size = bd->widget->allocation.width;
277 size = CLAMP(size + val, BAR_SIZE_INCREMENT * 2, BAR_SIZE_INCREMENT * 16); 290 size = CLAMP(size + val, BAR_SIZE_INCREMENT * 2, BAR_SIZE_INCREMENT * 16);
278 291
279 gtk_widget_set_size_request(bd->widget, size, -1); 292 gtk_widget_set_size_request(bd->widget, size, -1);
280 options->layout.panels.info.width = bd->widget->allocation.width;
281 } 293 }
282 294
283 static void bar_larger(GtkWidget *widget, gpointer data) 295 static void bar_larger(GtkWidget *widget, gpointer data)
284 { 296 {
285 BarData *bd = data; 297 BarData *bd = data;
326 338
327 bd->widget = gtk_vbox_new(FALSE, PREF_PAD_GAP); 339 bd->widget = gtk_vbox_new(FALSE, PREF_PAD_GAP);
328 g_object_set_data(G_OBJECT(bd->widget), "bar_data", bd); 340 g_object_set_data(G_OBJECT(bd->widget), "bar_data", bd);
329 g_signal_connect(G_OBJECT(bd->widget), "destroy", 341 g_signal_connect(G_OBJECT(bd->widget), "destroy",
330 G_CALLBACK(bar_destroy), bd); 342 G_CALLBACK(bar_destroy), bd);
343
344 g_signal_connect(G_OBJECT(bd->widget), "size_allocate",
345 G_CALLBACK(bar_sized), bd);
346
347 bd->width = PANEL_DEFAULT_WIDTH;
348 gtk_widget_set_size_request(bd->widget, bd->width, -1);
331 349
332 box = gtk_hbox_new(FALSE, 0); 350 box = gtk_hbox_new(FALSE, 0);
333 351
334 sizer = sizer_new(bd->widget, bounding_widget, SIZER_POS_LEFT); 352 sizer = sizer_new(bd->widget, bounding_widget, SIZER_POS_LEFT);
335 sizer_set_limits(sizer, BAR_SIZE_INCREMENT * 2, -1, -1 , -1); 353 sizer_set_limits(sizer, BAR_SIZE_INCREMENT * 2, -1, -1 , -1);
386 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_NONE); 404 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_NONE);
387 gtk_widget_show(bd->vbox); 405 gtk_widget_show(bd->vbox);
388 return bd->widget; 406 return bd->widget;
389 } 407 }
390 408
409 GtkWidget *bar_new_default(GtkWidget *bounding_widget)
410 {
411 GtkWidget *bar = bar_new(bounding_widget);
412
413 bar_populate_default(bar);
414
415 gtk_widget_show(bar);
416
417 return bar;
418 }
419
420 GtkWidget *bar_new_from_config(GtkWidget *bounding_widget, const gchar **attribute_names, const gchar **attribute_values)
421 {
422 GtkWidget *bar = bar_new(bounding_widget);
423
424 gboolean enabled = TRUE;
425 gint width = PANEL_DEFAULT_WIDTH;
426
427 while (*attribute_names)
428 {
429 const gchar *option = *attribute_names++;
430 const gchar *value = *attribute_values++;
431
432 if (READ_BOOL_FULL("enabled", enabled)) continue;
433 if (READ_INT_FULL("width", width)) continue;
434
435
436 DEBUG_1("unknown attribute %s = %s", option, value);
437 }
438
439 gtk_widget_set_size_request(bar, width, -1);
440 if (enabled) gtk_widget_show(bar);
441 return bar;
442 }
443
391 444
392 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ 445 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */