return ret;
}
+GtkWidget *bar_find_pane_by_id(GtkWidget *bar, PaneType type, const gchar *id)
+{
+ BarData *bd;
+ GList *list, *work;
+ GtkWidget *ret = NULL;
+
+ if (!id || !id[0]) return NULL;
+
+ bd = g_object_get_data(G_OBJECT(bar), "bar_data");
+ if (!bd) return NULL;
+
+ list = gtk_container_get_children(GTK_CONTAINER(bd->vbox));
+
+ work = list;
+ while (work)
+ {
+ GtkWidget *widget = gtk_bin_get_child(GTK_BIN(work->data));
+ PaneData *pd = g_object_get_data(G_OBJECT(widget), "pane_data");
+ if (!pd) continue;
+
+ if (type == pd->type && strcmp(id, pd->id) == 0)
+ {
+ ret = widget;
+ break;
+ }
+ work = work->next;
+ }
+ g_list_free(list);
+ return ret;
+}
+
+void bar_clear(GtkWidget *bar)
+{
+ BarData *bd;
+ GList *list, *work;
+
+ bd = g_object_get_data(G_OBJECT(bar), "bar_data");
+ if (!bd) return;
+
+ list = gtk_container_get_children(GTK_CONTAINER(bd->vbox));
+
+ work = list;
+ while (work)
+ {
+ GtkWidget *widget = work->data;
+ gtk_widget_destroy(widget);
+ work = work->next;
+ }
+ g_list_free(list);
+}
+
void bar_write_config(GtkWidget *bar, GString *outstr, gint indent)
{
BarData *bd;
write_bool_option(outstr, indent, "enabled", GTK_WIDGET_VISIBLE(bar));
write_uint_option(outstr, indent, "width", bd->width);
WRITE_STRING(">");
+
+ indent++;
+ WRITE_NL(); WRITE_STRING("<clear/>");
list = gtk_container_get_children(GTK_CONTAINER(bd->vbox));
work = list;
pd->expanded = gtk_expander_get_expanded(GTK_EXPANDER(expander));
if (pd->pane_write_config)
- pd->pane_write_config(widget, outstr, indent + 1);
+ pd->pane_write_config(widget, outstr, indent);
work = work->next;
}
g_list_free(list);
-
+ indent--;
WRITE_NL(); WRITE_STRING("</bar>");
}
+void bar_update_expander(GtkWidget *pane)
+{
+ PaneData *pd = g_object_get_data(G_OBJECT(pane), "pane_data");
+ GtkWidget *expander;
+
+ if (!pd) return;
+
+ expander = pane->parent;
+
+ gtk_expander_set_expanded(GTK_EXPANDER(expander), pd->expanded);
+}
void bar_add(GtkWidget *bar, GtkWidget *pane)
{
{
GtkWidget *widget;
- widget = bar_pane_histogram_new(_("Histogram"), 80, TRUE, HCHAN_RGB, 0);
+ widget = bar_pane_histogram_new("histogram", _("Histogram"), 80, TRUE, HCHAN_RGB, 0);
bar_add(bar, widget);
- widget = bar_pane_comment_new(_("Title"), "Xmp.dc.title", TRUE, 40);
+ widget = bar_pane_comment_new("title", _("Title"), "Xmp.dc.title", TRUE, 40);
bar_add(bar, widget);
- widget = bar_pane_keywords_new(_("Keywords"), KEYWORD_KEY, TRUE);
+ widget = bar_pane_keywords_new("keywords", _("Keywords"), KEYWORD_KEY, TRUE);
bar_add(bar, widget);
- widget = bar_pane_comment_new(_("Comment"), "Xmp.dc.description", TRUE, 150);
+ widget = bar_pane_comment_new("comment", _("Comment"), "Xmp.dc.description", TRUE, 150);
bar_add(bar, widget);
- widget = bar_pane_exif_new(_("Exif"), TRUE, TRUE);
+ widget = bar_pane_exif_new("exif", _("Exif"), TRUE, TRUE);
bar_add(bar, widget);
}
return bar;
}
-GtkWidget *bar_new_from_config(LayoutWindow *lw, const gchar **attribute_names, const gchar **attribute_values)
+GtkWidget *bar_update_from_config(GtkWidget *bar, const gchar **attribute_names, const gchar **attribute_values)
{
- GtkWidget *bar = bar_new(lw);
-
gboolean enabled = TRUE;
gint width = SIDEBAR_DEFAULT_WIDTH;
}
gtk_widget_set_size_request(bar, width, -1);
- if (enabled) gtk_widget_show(bar);
+ if (enabled)
+ {
+ gtk_widget_show(bar);
+ }
+ else
+ {
+ gtk_widget_hide(bar);
+ }
return bar;
}
+GtkWidget *bar_new_from_config(LayoutWindow *lw, const gchar **attribute_names, const gchar **attribute_values)
+{
+ GtkWidget *bar = bar_new(lw);
+ return bar_update_from_config(bar, attribute_names, attribute_values);
+}
+
GtkWidget *bar_pane_expander_title(const gchar *title)
{
GtkWidget *widget = gtk_label_new(title);
#ifndef BAR_H
#define BAR_H
+typedef enum {
+ PANE_COMMENT,
+ PANE_EXIF,
+ PANE_HISTOGRAM,
+ PANE_KEYWORDS
+} PaneType;
+
typedef struct _PaneData PaneData;
struct _PaneData {
void (*pane_write_config)(GtkWidget *pane, GString *outstr, gint indent);
GtkWidget *title;
gboolean expanded;
+ gchar *id;
+ PaneType type;
/* filled in by bar */
GtkWidget *bar;
+
GtkWidget *bar_new(LayoutWindow *lw);
GtkWidget *bar_new_default(LayoutWindow *lw);
GtkWidget *bar_new_from_config(LayoutWindow *lw, const gchar **attribute_names, const gchar **attribute_values);
+GtkWidget *bar_update_from_config(GtkWidget *bar, const gchar **attribute_names, const gchar **attribute_values);
void bar_close(GtkWidget *bar);
void bar_write_config(GtkWidget *bar, GString *outstr, gint indent);
void bar_add(GtkWidget *bar, GtkWidget *pane);
+GtkWidget *bar_find_pane_by_id(GtkWidget *bar, PaneType type, const gchar *id);
+void bar_clear(GtkWidget *bar);
void bar_set_fd(GtkWidget *bar, FileData *fd);
gboolean bar_event(GtkWidget *bar, GdkEvent *event);
gint bar_get_width(GtkWidget *bar);
GtkWidget *bar_pane_expander_title(const gchar *title);
-
+void bar_update_expander(GtkWidget *pane);
#endif
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
if (!pcd) return;
WRITE_NL(); WRITE_STRING("<pane_comment ");
- write_char_option(outstr, indent, "pane.title", gtk_label_get_text(GTK_LABEL(pcd->pane.title)));
- WRITE_BOOL(*pcd, pane.expanded);
+ write_char_option(outstr, indent, "id", pcd->pane.id);
+ write_char_option(outstr, indent, "title", gtk_label_get_text(GTK_LABEL(pcd->pane.title)));
+ WRITE_BOOL(pcd->pane, expanded);
WRITE_CHAR(*pcd, key);
WRITE_INT(*pcd, height);
WRITE_STRING("/>");
file_data_unref(pcd->fd);
g_free(pcd->key);
-
+
+ g_free(pcd->pane.id);
g_free(pcd);
}
-GtkWidget *bar_pane_comment_new(const gchar *title, const gchar *key, gboolean expanded, gint height)
+GtkWidget *bar_pane_comment_new(const gchar *id, const gchar *title, const gchar *key, gboolean expanded, gint height)
{
PaneCommentData *pcd;
GtkWidget *scrolled;
pcd->pane.pane_event = bar_pane_comment_event;
pcd->pane.pane_write_config = bar_pane_comment_write_config;
pcd->pane.title = bar_pane_expander_title(title);
+ pcd->pane.id = g_strdup(id);
+ pcd->pane.type = PANE_COMMENT;
pcd->pane.expanded = expanded;
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- gtk_widget_set_size_request(scrolled, -1, height);
+ gtk_widget_set_size_request(pcd->widget, -1, height);
gtk_widget_show(scrolled);
pcd->comment_view = gtk_text_view_new();
GtkWidget *bar_pane_comment_new_from_config(const gchar **attribute_names, const gchar **attribute_values)
{
- gchar *title = g_strdup(_("NoName"));
+ gchar *title = g_strdup(_("Comment"));
gchar *key = g_strdup(COMMENT_KEY);
gboolean expanded = TRUE;
gint height = 50;
+ gchar *id = g_strdup("comment");
+ GtkWidget *ret;
while (*attribute_names)
{
const gchar *option = *attribute_names++;
const gchar *value = *attribute_values++;
- if (READ_CHAR_FULL("pane.title", title)) continue;
+ if (READ_CHAR_FULL("title", title)) continue;
if (READ_CHAR_FULL("key", key)) continue;
- if (READ_BOOL_FULL("pane.expanded", expanded)) continue;
+ if (READ_BOOL_FULL("expanded", expanded)) continue;
if (READ_INT_FULL("height", height)) continue;
+ if (READ_CHAR_FULL("id", id)) continue;
log_printf("unknown attribute %s = %s\n", option, value);
}
- return bar_pane_comment_new(title, key, expanded, height);
+ ret = bar_pane_comment_new(id, title, key, expanded, height);
+ g_free(title);
+ g_free(key);
+ g_free(id);
+ return ret;
+}
+
+void bar_pane_comment_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values)
+{
+ PaneCommentData *pcd;
+
+ pcd = g_object_get_data(G_OBJECT(pane), "pane_data");
+ if (!pcd) return;
+
+ gchar *title = NULL;
+
+ while (*attribute_names)
+ {
+ const gchar *option = *attribute_names++;
+ const gchar *value = *attribute_values++;
+
+ if (READ_CHAR_FULL("title", title)) continue;
+ if (READ_CHAR_FULL("key", pcd->key)) continue;
+ if (READ_BOOL_FULL("expanded", pcd->pane.expanded)) continue;
+ if (READ_INT_FULL("height", pcd->height)) continue;
+ if (READ_CHAR_FULL("id", pcd->pane.id)) continue;
+
+
+ log_printf("unknown attribute %s = %s\n", option, value);
+ }
+
+ if (title)
+ {
+ gtk_label_set_text(GTK_LABEL(pcd->pane.title), title);
+ g_free(title);
+ }
+ gtk_widget_set_size_request(pcd->widget, -1, pcd->height);
+ bar_update_expander(pane);
+ bar_pane_comment_update(pcd);
}
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
#ifndef BAR_COMMENT_H
#define BAR_COMMENT_H
-GtkWidget *bar_pane_comment_new(const gchar *title, const gchar *key, gboolean expanded, gint height);
+GtkWidget *bar_pane_comment_new(const gchar *id, const gchar *title, const gchar *key, gboolean expanded, gint height);
GtkWidget *bar_pane_comment_new_from_config(const gchar **attribute_names, const gchar **attribute_values);
+void bar_pane_comment_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values);
#endif
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
if (!ped) return;
WRITE_NL(); WRITE_STRING("<pane_exif ");
- write_char_option(outstr, indent, "pane.title", gtk_label_get_text(GTK_LABEL(ped->pane.title)));
- WRITE_BOOL(*ped, pane.expanded);
+ write_char_option(outstr, indent, "id", ped->pane.id);
+ write_char_option(outstr, indent, "title", gtk_label_get_text(GTK_LABEL(ped->pane.title)));
+ WRITE_BOOL(ped->pane, expanded);
WRITE_STRING(">");
indent++;
file_data_unregister_notify_func(bar_pane_exif_notify_cb, ped);
g_object_unref(ped->size_group);
file_data_unref(ped->fd);
+ g_free(ped->pane.id);
g_free(ped);
}
ped->min_height = alloc->height;
}
-GtkWidget *bar_pane_exif_new(const gchar *title, gboolean expanded, gboolean populate)
+GtkWidget *bar_pane_exif_new(const gchar *id, const gchar *title, gboolean expanded, gboolean populate)
{
PaneExifData *ped;
ped->pane.pane_write_config = bar_pane_exif_write_config;
ped->pane.pane_event = bar_pane_exif_event;
ped->pane.title = bar_pane_expander_title(title);
+ ped->pane.id = g_strdup(id);
ped->pane.expanded = expanded;
+ ped->pane.type = PANE_EXIF;
ped->size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
ped->widget = gtk_event_box_new();
GtkWidget *bar_pane_exif_new_from_config(const gchar **attribute_names, const gchar **attribute_values)
{
- gchar *title = g_strdup(_("NoName"));
+ gchar *title = g_strdup(_("Exif"));
+ gchar *id = g_strdup("exif");
gboolean expanded = TRUE;
+ GtkWidget *ret;
while (*attribute_names)
{
const gchar *option = *attribute_names++;
const gchar *value = *attribute_values++;
- if (READ_CHAR_FULL("pane.title", title)) continue;
- if (READ_BOOL_FULL("pane.expanded", expanded)) continue;
+ if (READ_CHAR_FULL("id", id)) continue;
+ if (READ_CHAR_FULL("title", title)) continue;
+ if (READ_BOOL_FULL("expanded", expanded)) continue;
log_printf("unknown attribute %s = %s\n", option, value);
}
- return bar_pane_exif_new(title, expanded, FALSE);
+ ret = bar_pane_exif_new(id, title, expanded, FALSE);
+ g_free(title);
+ g_free(id);
+ return ret;
+}
+
+void bar_pane_exif_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values)
+{
+ PaneExifData *ped;
+
+ ped = g_object_get_data(G_OBJECT(pane), "pane_data");
+ if (!ped) return;
+
+ gchar *title = NULL;
+
+ while (*attribute_names)
+ {
+ const gchar *option = *attribute_names++;
+ const gchar *value = *attribute_values++;
+
+ if (READ_CHAR_FULL("title", title)) continue;
+ if (READ_BOOL_FULL("expanded", ped->pane.expanded)) continue;
+ if (READ_CHAR_FULL("id", ped->pane.id)) continue;
+
+
+ log_printf("unknown attribute %s = %s\n", option, value);
+ }
+
+ if (title)
+ {
+ gtk_label_set_text(GTK_LABEL(ped->pane.title), title);
+ g_free(title);
+ }
+
+ bar_update_expander(pane);
+ bar_pane_exif_update(ped);
}
+
void bar_pane_exif_entry_add_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values)
{
PaneExifData *ped;
#ifndef BAR_EXIF_H
#define BAR_EXIF_H
-GtkWidget *bar_pane_exif_new(const gchar *title, gboolean expanded, gboolean populate);
+GtkWidget *bar_pane_exif_new(const gchar *id, const gchar *title, gboolean expanded, gboolean populate);
GtkWidget *bar_pane_exif_new_from_config(const gchar **attribute_names, const gchar **attribute_values);
+void bar_pane_exif_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values);
+
void bar_pane_exif_entry_add_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values);
/* these are exposed for when duplication of the exif bar's text is needed */
if (!phd) return;
WRITE_NL(); WRITE_STRING("<pane_histogram ");
- write_char_option(outstr, indent, "pane.title", gtk_label_get_text(GTK_LABEL(phd->pane.title)));
- WRITE_BOOL(*phd, pane.expanded);
+ write_char_option(outstr, indent, "id", phd->pane.id);
+ write_char_option(outstr, indent, "title", gtk_label_get_text(GTK_LABEL(phd->pane.title)));
+ WRITE_BOOL(phd->pane, expanded);
WRITE_INT(*phd->histogram, histogram_channel);
WRITE_INT(*phd->histogram, histogram_mode);
WRITE_STRING("/>");
file_data_unref(phd->fd);
histogram_free(phd->histogram);
if (phd->pixbuf) g_object_unref(phd->pixbuf);
+ g_free(phd->pane.id);
g_free(phd);
}
}
-GtkWidget *bar_pane_histogram_new(const gchar *title, gint height, gboolean expanded, gint histogram_channel, gint histogram_mode)
+GtkWidget *bar_pane_histogram_new(const gchar *id, const gchar *title, gint height, gboolean expanded, gint histogram_channel, gint histogram_mode)
{
PaneHistogramData *phd;
phd->pane.pane_set_fd = bar_pane_histogram_set_fd;
phd->pane.pane_write_config = bar_pane_histogram_write_config;
phd->pane.title = bar_pane_expander_title(title);
+ phd->pane.id = g_strdup(id);
+ phd->pane.type = PANE_HISTOGRAM;
phd->pane.expanded = expanded;
phd->idle_id = -1;
GtkWidget *bar_pane_histogram_new_from_config(const gchar **attribute_names, const gchar **attribute_values)
{
gchar *title = g_strdup(_("NoName"));
+ gchar *id = g_strdup("histogram");
gboolean expanded = TRUE;
gint height = 80;
gint histogram_channel = HCHAN_RGB;
gint histogram_mode = 0;
+ GtkWidget *ret;
while (*attribute_names)
{
const gchar *option = *attribute_names++;
const gchar *value = *attribute_values++;
- if (READ_CHAR_FULL("pane.title", title)) continue;
- if (READ_BOOL_FULL("pane.expanded", expanded)) continue;
+ if (READ_CHAR_FULL("id", id)) continue;
+ if (READ_CHAR_FULL("title", title)) continue;
+ if (READ_BOOL_FULL("expanded", expanded)) continue;
if (READ_INT_FULL("histogram_channel", histogram_channel)) continue;
if (READ_INT_FULL("histogram_mode", histogram_mode)) continue;
log_printf("unknown attribute %s = %s\n", option, value);
}
- return bar_pane_histogram_new(title, height, expanded, histogram_channel, histogram_mode);
+ ret = bar_pane_histogram_new(id, title, height, expanded, histogram_channel, histogram_mode);
+ g_free(title);
+ g_free(id);
+ return ret;
}
+void bar_pane_histogram_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values)
+{
+ PaneHistogramData *phd;
+
+ phd = g_object_get_data(G_OBJECT(pane), "pane_data");
+ if (!phd) return;
+
+ gint histogram_channel = phd->histogram->histogram_channel;
+ gint histogram_mode = phd->histogram->histogram_mode;
+
+ while (*attribute_names)
+ {
+ const gchar *option = *attribute_names++;
+ const gchar *value = *attribute_values++;
+
+ if (READ_CHAR_FULL("id", phd->pane.id)) continue;
+// if (READ_CHAR_FULL("pane.title", title)) continue;
+ if (READ_BOOL_FULL("expanded", phd->pane.expanded)) continue;
+ if (READ_INT_FULL("histogram_channel", histogram_channel)) continue;
+ if (READ_INT_FULL("histogram_mode", histogram_mode)) continue;
+
+
+ log_printf("unknown attribute %s = %s\n", option, value);
+ }
+
+ histogram_set_channel(phd->histogram, histogram_channel);
+ histogram_set_mode(phd->histogram, histogram_mode);
+
+ bar_update_expander(pane);
+ bar_pane_histogram_update(phd);
+}
+
+
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
#ifndef BAR_HISTOGRAM_H
#define BAR_HISTOGRAM_H
-GtkWidget *bar_pane_histogram_new(const gchar *title, gint height, gboolean expanded, gint histogram_channel, gint histogram_mode);
+GtkWidget *bar_pane_histogram_new(const gchar *id, const gchar *title, gint height, gboolean expanded, gint histogram_channel, gint histogram_mode);
GtkWidget *bar_pane_histogram_new_from_config(const gchar **attribute_names, const gchar **attribute_values);
+void bar_pane_histogram_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values);
#endif
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
if (!pkd) return;
WRITE_NL(); WRITE_STRING("<pane_keywords ");
- write_char_option(outstr, indent, "pane.title", gtk_label_get_text(GTK_LABEL(pkd->pane.title)));
- WRITE_BOOL(*pkd, pane.expanded);
+ write_char_option(outstr, indent, "id", pkd->pane.id);
+ write_char_option(outstr, indent, "title", gtk_label_get_text(GTK_LABEL(pkd->pane.title)));
+ WRITE_BOOL(pkd->pane, expanded);
WRITE_CHAR(*pkd, key);
WRITE_STRING("/>");
}
pkd = g_object_get_data(G_OBJECT(bar), "pane_data");
if (!pkd) return;
-
+
+ g_free(pkd->pane.id);
gtk_widget_destroy(pkd->widget);
}
}
-GtkWidget *bar_pane_keywords_new(const gchar *title, const gchar *key, gboolean expanded)
+GtkWidget *bar_pane_keywords_new(const gchar *id, const gchar *title, const gchar *key, gboolean expanded)
{
PaneKeywordsData *pkd;
GtkWidget *hbox;
pkd->pane.pane_event = bar_pane_keywords_event;
pkd->pane.pane_write_config = bar_pane_keywords_write_config;
pkd->pane.title = bar_pane_expander_title(title);
+ pkd->pane.id = g_strdup(id);
+ pkd->pane.type = PANE_KEYWORDS;
pkd->pane.expanded = expanded;
GtkWidget *bar_pane_keywords_new_from_config(const gchar **attribute_names, const gchar **attribute_values)
{
- gchar *title = g_strdup(_("NoName"));
+ gchar *id = g_strdup("keywords");
+ gchar *title = g_strdup(_("Keywords"));
gchar *key = g_strdup(COMMENT_KEY);
gboolean expanded = TRUE;
+ GtkWidget *ret;
while (*attribute_names)
{
const gchar *option = *attribute_names++;
const gchar *value = *attribute_values++;
- if (READ_CHAR_FULL("pane.title", title)) continue;
+ if (READ_CHAR_FULL("id", id)) continue;
+ if (READ_CHAR_FULL("title", title)) continue;
if (READ_CHAR_FULL("key", key)) continue;
- if (READ_BOOL_FULL("pane.expanded", expanded)) continue;
+ if (READ_BOOL_FULL("expanded", expanded)) continue;
log_printf("unknown attribute %s = %s\n", option, value);
}
- return bar_pane_keywords_new(title, key, expanded);
+ ret = bar_pane_keywords_new(id, title, key, expanded);
+ g_free(id);
+ g_free(title);
+ g_free(key);
+ return ret;
+}
+
+void bar_pane_keywords_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values)
+{
+ PaneKeywordsData *pkd;
+
+ pkd = g_object_get_data(G_OBJECT(pane), "pane_data");
+ if (!pkd) return;
+
+ gchar *title = NULL;
+
+ while (*attribute_names)
+ {
+ const gchar *option = *attribute_names++;
+ const gchar *value = *attribute_values++;
+
+ if (READ_CHAR_FULL("title", title)) continue;
+ if (READ_CHAR_FULL("key", pkd->key)) continue;
+ if (READ_BOOL_FULL("expanded", pkd->pane.expanded)) continue;
+ if (READ_CHAR_FULL("id", pkd->pane.id)) continue;
+
+
+ log_printf("unknown attribute %s = %s\n", option, value);
+ }
+
+ if (title)
+ {
+ gtk_label_set_text(GTK_LABEL(pkd->pane.title), title);
+ g_free(title);
+ }
+
+ bar_update_expander(pane);
+ bar_pane_keywords_update(pkd);
}
+
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
#ifndef BAR_KEYWORDS_H
#define BAR_KEYWORDS_H
-GtkWidget *bar_pane_keywords_new(const gchar *title, const gchar *key, gboolean expanded);
+GtkWidget *bar_pane_keywords_new(const gchar *id, const gchar *title, const gchar *key, gboolean expanded);
GtkWidget *bar_pane_keywords_new_from_config(const gchar **attribute_names, const gchar **attribute_values);
+void bar_pane_keywords_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values);
/* used in search.c */
GList *keyword_list_pull(GtkWidget *text_widget);
void layout_toolbar_add(LayoutWindow *lw, const gchar *action)
{
if (!action || !lw->ui_manager) return;
+
+ if (g_list_find_custom(lw->toolbar_actions, action, (GCompareFunc)strcmp)) return;
+
gtk_ui_manager_add_ui(lw->ui_manager, lw->toolbar_merge_id, "/ToolBar", action, action, GTK_UI_MANAGER_TOOLITEM, FALSE);
lw->toolbar_actions = g_list_append(lw->toolbar_actions, g_strdup(action));
}
GList *work = lw->toolbar_actions;
WRITE_NL(); WRITE_STRING("<toolbar>");
indent++;
+ WRITE_NL(); WRITE_STRING("<clear/>");
while (work)
{
gchar *action = work->data;
GtkWidget *bar = data;
if (g_ascii_strcasecmp(element_name, "pane_comment") == 0)
{
- GtkWidget *pane = bar_pane_comment_new_from_config(attribute_names, attribute_values);
- bar_add(bar, pane);
+ GtkWidget *pane = bar_find_pane_by_id(bar, PANE_COMMENT, options_get_id(attribute_names, attribute_values));
+ if (pane)
+ {
+ bar_pane_comment_update_from_config(pane, attribute_names, attribute_values);
+ }
+ else
+ {
+ pane = bar_pane_comment_new_from_config(attribute_names, attribute_values);
+ bar_add(bar, pane);
+ }
options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
}
else if (g_ascii_strcasecmp(element_name, "pane_exif") == 0)
{
- GtkWidget *pane = bar_pane_exif_new_from_config(attribute_names, attribute_values);
- bar_add(bar, pane);
+ GtkWidget *pane = bar_find_pane_by_id(bar, PANE_EXIF, options_get_id(attribute_names, attribute_values));
+ if (pane)
+ {
+ bar_pane_exif_update_from_config(pane, attribute_names, attribute_values);
+ }
+ else
+ {
+ pane = bar_pane_exif_new_from_config(attribute_names, attribute_values);
+ bar_add(bar, pane);
+ }
options_parse_func_push(parser_data, options_parse_pane_exif, NULL, pane);
}
else if (g_ascii_strcasecmp(element_name, "pane_histogram") == 0)
{
- GtkWidget *pane = bar_pane_histogram_new_from_config(attribute_names, attribute_values);
- bar_add(bar, pane);
+ GtkWidget *pane = bar_find_pane_by_id(bar, PANE_HISTOGRAM, options_get_id(attribute_names, attribute_values));
+ if (pane)
+ {
+ bar_pane_histogram_update_from_config(pane, attribute_names, attribute_values);
+ }
+ else
+ {
+ pane = bar_pane_histogram_new_from_config(attribute_names, attribute_values);
+ bar_add(bar, pane);
+ }
options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
}
else if (g_ascii_strcasecmp(element_name, "pane_keywords") == 0)
{
- GtkWidget *pane = bar_pane_keywords_new_from_config(attribute_names, attribute_values);
- bar_add(bar, pane);
+ GtkWidget *pane = bar_find_pane_by_id(bar, PANE_KEYWORDS, options_get_id(attribute_names, attribute_values));
+ if (pane)
+ {
+ bar_pane_keywords_update_from_config(pane, attribute_names, attribute_values);
+ }
+ else
+ {
+ pane = bar_pane_keywords_new_from_config(attribute_names, attribute_values);
+ bar_add(bar, pane);
+ }
+ options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
+ }
+ else if (g_ascii_strcasecmp(element_name, "clear") == 0)
+ {
+ bar_clear(bar);
options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
}
else
layout_toolbar_add_from_config(lw, attribute_names, attribute_values);
options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
}
+ else if (g_ascii_strcasecmp(element_name, "clear") == 0)
+ {
+ layout_toolbar_clear(lw);
+ options_parse_func_push(parser_data, options_parse_leaf, NULL, NULL);
+ }
else
{
log_printf("unexpected in <toolbar>: <%s>\n", element_name);
LayoutWindow *lw = data;
if (g_ascii_strcasecmp(element_name, "bar") == 0)
{
- GtkWidget *bar = bar_new_from_config(lw, attribute_names, attribute_values);
- layout_bar_set(lw, bar);
+ if (!lw->bar)
+ {
+ GtkWidget *bar = bar_new_from_config(lw, attribute_names, attribute_values);
+ layout_bar_set(lw, bar);
+ }
+ else
+ {
+ bar_update_from_config(lw->bar, attribute_names, attribute_values);
+ }
+
options_parse_func_push(parser_data, options_parse_bar, NULL, lw->bar);
}
else if (g_ascii_strcasecmp(element_name, "bar_sort") == 0)
}
else if (g_ascii_strcasecmp(element_name, "toolbar") == 0)
{
- layout_toolbar_clear(lw);
options_parse_func_push(parser_data, options_parse_toolbar, NULL, lw);
}
else