2 * Copyright (C) 2004 John Ellis
3 * Copyright (C) 2008 - 2016 The Geeqie Team
5 * Author: Vladimir Nadvornik
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "history-list.h"
29 #include "ui-fileops.h"
31 #include "ui-utildlg.h"
34 #include "bar-comment.h"
35 #include "bar-keywords.h"
37 #include "bar-histogram.h"
38 #include "histogram.h"
42 #include <gdk/gdkkeysyms.h>
44 typedef struct _KnownPanes KnownPanes;
53 static const gchar default_config_histogram[] =
55 " <layout id = '_current_'>"
57 " <pane_histogram id = 'histogram' expanded = 'true' histogram_channel = '4' histogram_mode = '0' />"
62 static const gchar default_config_title[] =
64 " <layout id = '_current_'>"
66 " <pane_comment id = 'title' expanded = 'true' key = 'Xmp.dc.title' height = '40' />"
71 static const gchar default_config_headline[] =
73 " <layout id = '_current_'>"
75 " <pane_comment id = 'headline' expanded = 'true' key = 'Xmp.photoshop.Headline' height = '40' />"
80 static const gchar default_config_keywords[] =
82 " <layout id = '_current_'>"
84 " <pane_keywords id = 'keywords' expanded = 'true' key = '" KEYWORD_KEY "' />"
89 static const gchar default_config_comment[] =
91 " <layout id = '_current_'>"
93 " <pane_comment id = 'comment' expanded = 'true' key = '" COMMENT_KEY "' height = '150' />"
97 static const gchar default_config_rating[] =
99 " <layout id = '_current_'>"
101 " <pane_rating id = 'rating' expanded = 'true' />"
106 static const gchar default_config_exif[] =
108 " <layout id = '_current_'>"
110 " <pane_exif id = 'exif' expanded = 'true' >"
111 " <entry key = 'formatted.Camera' if_set = 'true' editable = 'false' />"
112 " <entry key = 'formatted.DateTime' if_set = 'true' editable = 'false' />"
113 " <entry key = 'formatted.localtime' if_set = 'true' editable = 'false' />"
114 " <entry key = 'formatted.ShutterSpeed' if_set = 'true' editable = 'false' />"
115 " <entry key = 'formatted.Aperture' if_set = 'true' editable = 'false' />"
116 " <entry key = 'formatted.ExposureBias' if_set = 'true' editable = 'false' />"
117 " <entry key = 'formatted.ISOSpeedRating' if_set = 'true' editable = 'false' />"
118 " <entry key = 'formatted.FocalLength' if_set = 'true' editable = 'false' />"
119 " <entry key = 'formatted.FocalLength35mmFilm' if_set = 'true' editable = 'false' />"
120 " <entry key = 'formatted.Flash' if_set = 'true' editable = 'false' />"
121 " <entry key = 'Exif.Photo.ExposureProgram' if_set = 'true' editable = 'false' />"
122 " <entry key = 'Exif.Photo.MeteringMode' if_set = 'true' editable = 'false' />"
123 " <entry key = 'Exif.Photo.LightSource' if_set = 'true' editable = 'false' />"
124 " <entry key = 'formatted.ColorProfile' if_set = 'true' editable = 'false' />"
125 " <entry key = 'formatted.SubjectDistance' if_set = 'true' editable = 'false' />"
126 " <entry key = 'formatted.Resolution' if_set = 'true' editable = 'false' />"
127 " <entry key = '" ORIENTATION_KEY "' if_set = 'true' editable = 'false' />"
128 " <entry key = 'formatted.star_rating' if_set = 'true' editable = 'false' />"
134 static const gchar default_config_file_info[] =
136 " <layout id = '_current_'>"
138 " <pane_exif id = 'file_info' expanded = 'true' >"
139 " <entry key = 'file.mode' if_set = 'false' editable = 'false' />"
140 " <entry key = 'file.date' if_set = 'false' editable = 'false' />"
141 " <entry key = 'file.size' if_set = 'false' editable = 'false' />"
142 " <entry key = 'file.owner' if_set = 'false' editable = 'false' />"
143 " <entry key = 'file.group' if_set = 'false' editable = 'false' />"
144 " <entry key = 'file.class' if_set = 'false' editable = 'false' />"
145 " <entry key = 'file.link' if_set = 'false' editable = 'false' />"
151 static const gchar default_config_location[] =
153 " <layout id = '_current_'>"
155 " <pane_exif id = 'location' expanded = 'true' >"
156 " <entry key = 'formatted.GPSPosition' if_set = 'true' editable = 'false' />"
157 " <entry key = 'formatted.GPSAltitude' if_set = 'true' editable = 'false' />"
158 " <entry key = 'formatted.timezone' if_set = 'true' editable = 'false' />"
159 " <entry key = 'Xmp.photoshop.Country' if_set = 'false' editable = 'true' />"
160 " <entry key = 'Xmp.iptc.CountryCode' if_set = 'false' editable = 'true' />"
161 " <entry key = 'Xmp.photoshop.State' if_set = 'false' editable = 'true' />"
162 " <entry key = 'Xmp.photoshop.City' if_set = 'false' editable = 'true' />"
163 " <entry key = 'Xmp.iptc.Location' if_set = 'false' editable = 'true' />"
169 static const gchar default_config_copyright[] =
171 " <layout id = '_current_'>"
173 " <pane_exif id = 'copyright' expanded = 'true' >"
174 " <entry key = 'Xmp.dc.creator' if_set = 'true' editable = 'false' />"
175 " <entry key = 'Xmp.dc.contributor' if_set = 'true' editable = 'false' />"
176 " <entry key = 'Xmp.dc.rights' if_set = 'false' editable = 'false' />"
182 #ifdef HAVE_LIBCHAMPLAIN
183 #ifdef HAVE_LIBCHAMPLAIN_GTK
184 static const gchar default_config_gps[] =
186 " <layout id = '_current_'>"
188 " <pane_gps id = 'gps' expanded = 'true'"
189 " map-id = 'osm-mapnik'"
191 " latitude = '50116666'"
192 " longitude = '8683333' />"
199 static const KnownPanes known_panes[] = {
200 /* default sidebar */
201 {PANE_HISTOGRAM, "histogram", N_("Histogram"), default_config_histogram},
202 {PANE_COMMENT, "title", N_("Title"), default_config_title},
203 {PANE_KEYWORDS, "keywords", N_("Keywords"), default_config_keywords},
204 {PANE_COMMENT, "comment", N_("Comment"), default_config_comment},
205 {PANE_RATING, "rating", N_("Star Rating"), default_config_rating},
206 {PANE_COMMENT, "headline", N_("Headline"), default_config_headline},
207 {PANE_EXIF, "exif", N_("Exif"), default_config_exif},
208 /* other pre-configured panes */
209 {PANE_EXIF, "file_info", N_("File info"), default_config_file_info},
210 {PANE_EXIF, "location", N_("Location and GPS"), default_config_location},
211 {PANE_EXIF, "copyright", N_("Copyright"), default_config_copyright},
212 #ifdef HAVE_LIBCHAMPLAIN
213 #ifdef HAVE_LIBCHAMPLAIN_GTK
214 {PANE_GPS, "gps", N_("GPS Map"), default_config_gps},
217 {PANE_UNDEF, NULL, NULL, NULL}
220 typedef struct _BarData BarData;
226 GtkWidget *label_file_name;
227 GtkWidget *add_button;
233 static void bar_expander_move(GtkWidget *UNUSED(widget), gpointer data, gboolean up, gboolean single_step)
235 GtkWidget *expander = data;
239 if (!expander) return;
240 box = gtk_widget_get_ancestor(expander, GTK_TYPE_BOX);
243 gtk_container_child_get(GTK_CONTAINER(box), expander, "position", &pos, NULL);
247 pos = up ? (pos - 1) : (pos + 1);
248 if (pos < 0) pos = 0;
255 gtk_box_reorder_child(GTK_BOX(box), expander, pos);
259 static void bar_expander_move_up_cb(GtkWidget *widget, gpointer data)
261 bar_expander_move(widget, data, TRUE, TRUE);
264 static void bar_expander_move_down_cb(GtkWidget *widget, gpointer data)
266 bar_expander_move(widget, data, FALSE, TRUE);
269 static void bar_expander_move_top_cb(GtkWidget *widget, gpointer data)
271 bar_expander_move(widget, data, TRUE, FALSE);
274 static void bar_expander_move_bottom_cb(GtkWidget *widget, gpointer data)
276 bar_expander_move(widget, data, FALSE, FALSE);
279 static void height_spin_changed_cb(GtkSpinButton *spin, gpointer data)
282 gtk_widget_set_size_request(GTK_WIDGET(data), -1, gtk_spin_button_get_value_as_int(spin));
285 static void height_spin_key_press_cb(GtkEventControllerKey *UNUSED(controller), gint keyval, guint UNUSED(keycode), GdkModifierType UNUSED(state), gpointer data)
287 if ((keyval == GDK_KEY_Return || keyval == GDK_KEY_Escape))
289 gtk_widget_destroy(GTK_WIDGET(data));
293 static void bar_expander_height_cb(GtkWidget *UNUSED(widget), gpointer data)
295 GtkWidget *expander = data;
305 GtkEventController *controller;
307 display = gdk_display_get_default();
308 seat = gdk_display_get_default_seat(display);
309 device = gdk_seat_get_pointer(seat);
310 gdk_device_get_position(device, NULL, &x, &y);
312 list = gtk_container_get_children(GTK_CONTAINER(expander));
313 data_box = list->data;
315 window = gtk_window_new(GTK_WINDOW_POPUP);
317 gtk_window_set_modal(GTK_WINDOW(window), TRUE);
318 gtk_window_set_keep_above(GTK_WINDOW(window), TRUE);
319 gtk_window_set_default_size(GTK_WINDOW(window), 50, 30); //** @FIXME set these values in a more sensible way */
321 gtk_window_move(GTK_WINDOW(window), x, y);
322 gtk_widget_show(window);
324 gtk_widget_get_size_request(GTK_WIDGET(data_box), &w, &h);
326 spin = gtk_spin_button_new_with_range(1, 1000, 1);
327 g_signal_connect(G_OBJECT(spin), "value-changed", G_CALLBACK(height_spin_changed_cb), data_box);
328 controller = gtk_event_controller_key_new(spin);
329 g_signal_connect(controller, "key-pressed", G_CALLBACK(height_spin_key_press_cb), window);
331 gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), h);
332 gtk_container_add(GTK_CONTAINER(window), spin);
333 gtk_widget_show(spin);
334 gtk_widget_grab_focus(GTK_WIDGET(spin));
339 static void bar_expander_delete_cb(GtkWidget *UNUSED(widget), gpointer data)
341 GtkWidget *expander = data;
342 gtk_widget_destroy(expander);
345 static void bar_expander_add_cb(GtkWidget *widget, gpointer UNUSED(data))
347 //GtkWidget *bar = data;
348 const KnownPanes *pane = known_panes;
349 const gchar *id = g_object_get_data(G_OBJECT(widget), "pane_add_id");
356 if (strcmp(pane->id, id) == 0) break;
359 if (!pane->id) return;
361 config = bar_pane_get_default_config(id);
362 if (config) load_config_from_buf(config, strlen(config), FALSE);
367 static void bar_menu_popup(GtkWidget *widget)
373 gboolean display_height_option = FALSE;
376 label = gtk_expander_get_label(GTK_EXPANDER(widget));
377 display_height_option = (g_strcmp0(label, "Comment") == 0) ||
378 (g_strcmp0(label, "Rating") == 0) ||
379 (g_strcmp0(label, "Title") == 0) ||
380 (g_strcmp0(label, "Headline") == 0) ||
381 (g_strcmp0(label, "Keywords") == 0) ||
382 (g_strcmp0(label, "GPS Map") == 0);
384 bd = g_object_get_data(G_OBJECT(widget), "bar_data");
393 bar = gtk_widget_get_parent(widget);
394 while (bar && !g_object_get_data(G_OBJECT(bar), "bar_data"))
395 bar = gtk_widget_get_parent(bar);
399 menu = popup_menu_short_lived();
403 menu_item_add_stock(menu, _("Move to _top"), GTK_STOCK_GOTO_TOP, G_CALLBACK(bar_expander_move_top_cb), expander);
404 menu_item_add_stock(menu, _("Move _up"), GTK_STOCK_GO_UP, G_CALLBACK(bar_expander_move_up_cb), expander);
405 menu_item_add_stock(menu, _("Move _down"), GTK_STOCK_GO_DOWN, G_CALLBACK(bar_expander_move_down_cb), expander);
406 menu_item_add_stock(menu, _("Move to _bottom"), GTK_STOCK_GOTO_BOTTOM, G_CALLBACK(bar_expander_move_bottom_cb), expander);
407 menu_item_add_divider(menu);
409 if (gtk_expander_get_expanded(GTK_EXPANDER(expander)) && display_height_option)
411 menu_item_add_stock(menu, _("Height..."), GTK_STOCK_PREFERENCES, G_CALLBACK(bar_expander_height_cb), expander);
412 menu_item_add_divider(menu);
415 menu_item_add_stock(menu, _("Remove"), GTK_STOCK_DELETE, G_CALLBACK(bar_expander_delete_cb), expander);
416 menu_item_add_divider(menu);
419 gtk_menu_popup_at_pointer(GTK_MENU(menu), NULL);
422 static void bar_menu_add_popup(GtkWidget *widget)
426 const KnownPanes *pane = known_panes;
430 menu = popup_menu_short_lived();
435 item = menu_item_add_stock(menu, _(pane->title), GTK_STOCK_ADD, G_CALLBACK(bar_expander_add_cb), bar);
436 g_object_set_data(G_OBJECT(item), "pane_add_id", pane->id);
440 gtk_menu_popup_at_pointer(GTK_MENU(menu), NULL);
444 static gboolean bar_menu_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer UNUSED(data))
446 if (bevent->button == MOUSE_BUTTON_RIGHT)
448 bar_menu_popup(widget);
454 static void bar_expander_cb(GObject *object, GParamSpec *UNUSED(param_spec), gpointer UNUSED(data))
456 GtkExpander *expander;
459 expander = GTK_EXPANDER(object);
460 child = gtk_bin_get_child(GTK_BIN(expander));
462 if (gtk_expander_get_expanded(expander))
464 gtk_widget_show_all(child);
468 gtk_widget_hide(child);
472 static gboolean bar_menu_add_cb(GtkWidget *widget, GdkEventButton *UNUSED(bevent), gpointer UNUSED(data))
474 bar_menu_add_popup(widget);
479 static void bar_pane_set_fd_cb(GtkWidget *expander, gpointer data)
481 GtkWidget *widget = gtk_bin_get_child(GTK_BIN(expander));
482 PaneData *pd = g_object_get_data(G_OBJECT(widget), "pane_data");
484 if (pd->pane_set_fd) pd->pane_set_fd(widget, data);
487 void bar_set_fd(GtkWidget *bar, FileData *fd)
490 bd = g_object_get_data(G_OBJECT(bar), "bar_data");
493 file_data_unref(bd->fd);
494 bd->fd = file_data_ref(fd);
496 gtk_container_foreach(GTK_CONTAINER(bd->vbox), bar_pane_set_fd_cb, fd);
498 gtk_label_set_text(GTK_LABEL(bd->label_file_name), (bd->fd) ? bd->fd->name : "");
502 static void bar_pane_notify_selection_cb(GtkWidget *expander, gpointer data)
504 GtkWidget *widget = gtk_bin_get_child(GTK_BIN(expander));
505 PaneData *pd = g_object_get_data(G_OBJECT(widget), "pane_data");
507 if (pd->pane_notify_selection) pd->pane_notify_selection(widget, GPOINTER_TO_INT(data));
510 void bar_notify_selection(GtkWidget *bar, gint count)
513 bd = g_object_get_data(G_OBJECT(bar), "bar_data");
516 gtk_container_foreach(GTK_CONTAINER(bd->vbox), bar_pane_notify_selection_cb, GINT_TO_POINTER(count));
519 gboolean bar_event(GtkWidget *bar, GdkEvent *event)
523 gboolean ret = FALSE;
525 bd = g_object_get_data(G_OBJECT(bar), "bar_data");
526 if (!bd) return FALSE;
528 list = gtk_container_get_children(GTK_CONTAINER(bd->vbox));
533 GtkWidget *widget = gtk_bin_get_child(GTK_BIN(work->data));
534 PaneData *pd = g_object_get_data(G_OBJECT(widget), "pane_data");
537 if (pd->pane_event && pd->pane_event(widget, event))
548 GtkWidget *bar_find_pane_by_id(GtkWidget *bar, PaneType type, const gchar *id)
552 GtkWidget *ret = NULL;
554 if (!id || !id[0]) return NULL;
556 bd = g_object_get_data(G_OBJECT(bar), "bar_data");
557 if (!bd) return NULL;
559 list = gtk_container_get_children(GTK_CONTAINER(bd->vbox));
564 GtkWidget *widget = gtk_bin_get_child(GTK_BIN(work->data));
565 PaneData *pd = g_object_get_data(G_OBJECT(widget), "pane_data");
568 if (type == pd->type && strcmp(id, pd->id) == 0)
579 void bar_clear(GtkWidget *bar)
584 bd = g_object_get_data(G_OBJECT(bar), "bar_data");
587 list = gtk_container_get_children(GTK_CONTAINER(bd->vbox));
592 GtkWidget *widget = work->data;
593 gtk_widget_destroy(widget);
599 void bar_write_config(GtkWidget *bar, GString *outstr, gint indent)
606 bd = g_object_get_data(G_OBJECT(bar), "bar_data");
609 WRITE_NL(); WRITE_STRING("<bar ");
610 write_bool_option(outstr, indent, "enabled", gtk_widget_get_visible(bar));
611 write_uint_option(outstr, indent, "width", bd->width);
615 WRITE_NL(); WRITE_STRING("<clear/>");
617 list = gtk_container_get_children(GTK_CONTAINER(bd->vbox));
621 GtkWidget *expander = work->data;
622 GtkWidget *widget = gtk_bin_get_child(GTK_BIN(expander));
623 PaneData *pd = g_object_get_data(G_OBJECT(widget), "pane_data");
626 pd->expanded = gtk_expander_get_expanded(GTK_EXPANDER(expander));
628 if (pd->pane_write_config)
629 pd->pane_write_config(widget, outstr, indent);
635 WRITE_NL(); WRITE_STRING("</bar>");
638 void bar_update_expander(GtkWidget *pane)
640 PaneData *pd = g_object_get_data(G_OBJECT(pane), "pane_data");
645 expander = gtk_widget_get_parent(pane);
647 gtk_expander_set_expanded(GTK_EXPANDER(expander), pd->expanded);
650 void bar_add(GtkWidget *bar, GtkWidget *pane)
653 BarData *bd = g_object_get_data(G_OBJECT(bar), "bar_data");
654 PaneData *pd = g_object_get_data(G_OBJECT(pane), "pane_data");
661 expander = gtk_expander_new(NULL);
662 DEBUG_NAME(expander);
665 gtk_expander_set_label_widget(GTK_EXPANDER(expander), pd->title);
666 gtk_widget_show(pd->title);
669 gtk_box_pack_start(GTK_BOX(bd->vbox), expander, FALSE, TRUE, 0);
671 g_signal_connect(expander, "button_release_event", G_CALLBACK(bar_menu_cb), bd);
672 g_signal_connect(expander, "notify::expanded", G_CALLBACK(bar_expander_cb), pd);
674 gtk_container_add(GTK_CONTAINER(expander), pane);
676 gtk_expander_set_expanded(GTK_EXPANDER(expander), pd->expanded);
678 gtk_widget_show(expander);
680 if (bd->fd && pd && pd->pane_set_fd) pd->pane_set_fd(pane, bd->fd);
684 void bar_populate_default(GtkWidget *UNUSED(bar))
686 const gchar *populate_id[] = {"histogram", "title", "keywords", "comment", "rating", "exif", NULL};
687 const gchar **id = populate_id;
691 const gchar *config = bar_pane_get_default_config(*id);
692 if (config) load_config_from_buf(config, strlen(config), FALSE);
697 static void bar_size_allocate(GtkWidget *UNUSED(widget), GtkAllocation *UNUSED(allocation), gpointer data)
701 bd->width = gtk_paned_get_position(GTK_PANED(bd->lw->utility_paned));
704 gint bar_get_width(GtkWidget *bar)
708 bd = g_object_get_data(G_OBJECT(bar), "bar_data");
714 void bar_close(GtkWidget *bar)
718 bd = g_object_get_data(G_OBJECT(bar), "bar_data");
721 gtk_widget_destroy(bd->widget);
724 static void bar_destroy(GtkWidget *UNUSED(widget), gpointer data)
728 file_data_unref(bd->fd);
732 #ifdef HAVE_LIBCHAMPLAIN_GTK
734 @FIXME this is an ugly hack that works around this bug:
735 https://bugzilla.gnome.org/show_bug.cgi?id=590692
736 http://bugzilla.openedhand.com/show_bug.cgi?id=1751
737 it should be removed as soon as a better solution exists
740 static void bar_unrealize_clutter_fix_cb(GtkWidget *widget, gpointer UNUSED(data))
742 GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget));
743 if (child) gtk_widget_unrealize(child);
747 GtkWidget *bar_new(LayoutWindow *lw)
755 bd = g_new0(BarData, 1);
759 bd->widget = gtk_box_new(GTK_ORIENTATION_VERTICAL, PREF_PAD_GAP);
760 DEBUG_NAME(bd->widget);
761 g_object_set_data(G_OBJECT(bd->widget), "bar_data", bd);
762 g_signal_connect(G_OBJECT(bd->widget), "destroy",
763 G_CALLBACK(bar_destroy), bd);
765 g_signal_connect(G_OBJECT(bd->widget), "size-allocate",
766 G_CALLBACK(bar_size_allocate), bd);
768 g_signal_connect(G_OBJECT(bd->widget), "button_release_event", G_CALLBACK(bar_menu_cb), bd);
770 bd->width = SIDEBAR_DEFAULT_WIDTH;
772 box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
775 bd->label_file_name = gtk_label_new("");
776 gtk_label_set_ellipsize(GTK_LABEL(bd->label_file_name), PANGO_ELLIPSIZE_END);
777 gtk_label_set_selectable(GTK_LABEL(bd->label_file_name), TRUE);
778 gtk_label_set_xalign(GTK_LABEL(bd->label_file_name), 0.5);
779 gtk_label_set_yalign(GTK_LABEL(bd->label_file_name), 0.5);
781 gtk_box_pack_start(GTK_BOX(box), bd->label_file_name, TRUE, TRUE, 0);
782 gtk_widget_show(bd->label_file_name);
784 gtk_box_pack_start(GTK_BOX(bd->widget), box, FALSE, FALSE, 0);
785 gtk_widget_show(box);
787 scrolled = gtk_scrolled_window_new(NULL, NULL);
788 DEBUG_NAME(scrolled);
789 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
790 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
791 gtk_box_pack_start(GTK_BOX(bd->widget), scrolled, TRUE, TRUE, 0);
792 gtk_widget_show(scrolled);
795 bd->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
796 gtk_container_add(GTK_CONTAINER(scrolled), bd->vbox);
797 gtk_viewport_set_shadow_type(GTK_VIEWPORT(gtk_bin_get_child(GTK_BIN(scrolled))), GTK_SHADOW_NONE);
799 add_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
801 gtk_box_pack_end(GTK_BOX(bd->widget), add_box, FALSE, FALSE, 0);
802 tbar = pref_toolbar_new(add_box, GTK_TOOLBAR_ICONS);
803 bd->add_button = pref_toolbar_button(tbar, GTK_STOCK_ADD, NULL, FALSE,
805 G_CALLBACK(bar_menu_add_cb), bd);
806 gtk_widget_show(add_box);
808 #ifdef HAVE_LIBCHAMPLAIN_GTK
809 g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN(scrolled))), "unrealize", G_CALLBACK(bar_unrealize_clutter_fix_cb), NULL);
812 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), GTK_SHADOW_NONE);
813 gtk_widget_show(bd->vbox);
818 GtkWidget *bar_update_from_config(GtkWidget *bar, const gchar **attribute_names, const gchar **attribute_values, LayoutWindow *lw, gboolean startup)
820 gboolean enabled = TRUE;
821 gint width = SIDEBAR_DEFAULT_WIDTH;
823 while (*attribute_names)
825 const gchar *option = *attribute_names++;
826 const gchar *value = *attribute_values++;
828 if (READ_BOOL_FULL("enabled", enabled)) continue;
829 if (READ_INT_FULL("width", width)) continue;
832 log_printf("unknown attribute %s = %s\n", option, value);
837 gtk_paned_set_position(GTK_PANED(lw->utility_paned), width);
842 gtk_widget_show(bar);
846 gtk_widget_hide(bar);
851 GtkWidget *bar_new_from_config(LayoutWindow *lw, const gchar **attribute_names, const gchar **attribute_values)
853 GtkWidget *bar = bar_new(lw);
854 return bar_update_from_config(bar, attribute_names, attribute_values, lw, TRUE);
857 GtkWidget *bar_pane_expander_title(const gchar *title)
859 GtkWidget *widget = gtk_label_new(title);
861 pref_label_bold(widget, TRUE, FALSE);
862 //gtk_label_set_ellipsize(GTK_LABEL(widget), PANGO_ELLIPSIZE_END);
863 /** @FIXME do not work */
868 gboolean bar_pane_translate_title(PaneType type, const gchar *id, gchar **title)
870 const KnownPanes *pane = known_panes;
872 if (!title) return FALSE;
875 if (pane->type == type && strcmp(pane->id, id) == 0) break;
878 if (!pane->id) return FALSE;
880 if (*title && **title && strcmp(pane->title, *title) != 0) return FALSE;
883 *title = g_strdup(_(pane->title));
887 const gchar *bar_pane_get_default_config(const gchar *id)
889 const KnownPanes *pane = known_panes;
893 if (strcmp(pane->id, id) == 0) break;
896 if (!pane->id) return NULL;
900 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */