X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=blobdiff_plain;f=src%2Fbar_keywords.c;h=febed425236449547ace70739db955355ab3617f;hp=f58f348ead3743d6b7ee3eeca6adaabb54728251;hb=36d2e8e15cf7e6e230664cea85a6ddf492f766fe;hpb=db38d12f83128e9890ce2d2c7acc5ad62062bc7e diff --git a/src/bar_keywords.c b/src/bar_keywords.c index f58f348e..febed425 100644 --- a/src/bar_keywords.c +++ b/src/bar_keywords.c @@ -1,13 +1,22 @@ /* - * Geeqie - * (C) 2004 John Ellis - * Copyright (C) 2008 - 2012 The Geeqie Team + * Copyright (C) 2004 John Ellis + * Copyright (C) 2008 - 2016 The Geeqie Team * * Author: John Ellis * - * This software is released under the GNU General Public License (GNU GPL). - * Please read the included file COPYING for more information. - * This software comes with no warranty of any kind, use at your own risk! + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include @@ -113,6 +122,7 @@ struct _PaneKeywordsData guint idle_id; /* event source id */ FileData *fd; gchar *key; + gint height; }; typedef struct _ConfDialogData ConfDialogData; @@ -237,19 +247,69 @@ void bar_pane_keywords_set_fd(GtkWidget *pane, FileData *fd) bar_pane_keywords_update(pkd); } +void bar_keyword_tree_get_expanded_cb(GtkTreeView *keyword_treeview, GtkTreePath *path, gpointer data) +{ + GList **expanded = data; + GtkTreeModel *model; + GtkTreeIter iter; + gchar *path_string; + + model = gtk_tree_view_get_model(GTK_TREE_VIEW(keyword_treeview)); + gtk_tree_model_get_iter(model, &iter, path); + + path_string = gtk_tree_model_get_string_from_iter(model, &iter); + + *expanded = g_list_append(*expanded, g_strdup(path_string)); + g_free(path_string); +} + +static void bar_pane_keywords_entry_write_config(gchar *entry, GString *outstr, gint indent) +{ + struct { + gchar *path; + } expand; + + expand.path = entry; + + WRITE_NL(); WRITE_STRING(""); +} + static void bar_pane_keywords_write_config(GtkWidget *pane, GString *outstr, gint indent) { PaneKeywordsData *pkd; + GList *path_expanded = NULL; pkd = g_object_get_data(G_OBJECT(pane), "pane_data"); if (!pkd) return; + pkd->height = options->info_keywords.height; + WRITE_NL(); WRITE_STRING("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("/>"); + WRITE_INT(*pkd, height); + WRITE_STRING(">"); + indent++; + + gtk_tree_view_map_expanded_rows(GTK_TREE_VIEW(pkd->keyword_treeview), + (bar_keyword_tree_get_expanded_cb), &path_expanded); + + g_list_first(path_expanded); + while (path_expanded) + { + bar_pane_keywords_entry_write_config(path_expanded->data, outstr, indent); + g_free(path_expanded->data); + path_expanded = path_expanded->next; + } + g_list_free(path_expanded); + + indent--; + WRITE_NL(); + WRITE_STRING(""); } gint bar_pane_keywords_event(GtkWidget *bar, GdkEvent *event) @@ -870,14 +930,14 @@ static void bar_pane_keywords_edit_dialog(PaneKeywordsData *pkd, gboolean edit_e pkd->click_tpath = NULL; cdd->edit_existing = edit_existing; - cdd->gd = gd = generic_dialog_new(name ? _("Edit keyword") : _("Add keywords"), "keyword_edit", + cdd->gd = gd = generic_dialog_new(name ? _("Edit keyword") : _("New keyword"), "keyword_edit", pkd->widget, TRUE, bar_pane_keywords_edit_cancel_cb, cdd); g_signal_connect(G_OBJECT(gd->dialog), "destroy", G_CALLBACK(bar_pane_keywords_edit_destroy_cb), cdd); - generic_dialog_add_message(gd, NULL, name ? _("Configure keyword") : _("Add keyword"), NULL); + generic_dialog_add_message(gd, NULL, name ? _("Configure keyword") : _("New keyword"), NULL); generic_dialog_add_button(gd, GTK_STOCK_OK, NULL, bar_pane_keywords_edit_ok_cb, TRUE); @@ -1138,7 +1198,7 @@ static void bar_pane_keywords_menu_popup(GtkWidget *widget, PaneKeywordsData *pk menu = popup_menu_short_lived(); - menu_item_add_stock(menu, _("Add keyword"), GTK_STOCK_EDIT, G_CALLBACK(bar_pane_keywords_add_dialog_cb), pkd); + menu_item_add_stock(menu, _("New keyword"), GTK_STOCK_EDIT, G_CALLBACK(bar_pane_keywords_add_dialog_cb), pkd); menu_item_add_divider(menu); @@ -1263,7 +1323,7 @@ static void bar_pane_keywords_destroy(GtkWidget *widget, gpointer data) } -static GtkWidget *bar_pane_keywords_new(const gchar *id, const gchar *title, const gchar *key, gboolean expanded) +static GtkWidget *bar_pane_keywords_new(const gchar *id, const gchar *title, const gchar *key, gboolean expanded, gint height) { PaneKeywordsData *pkd; GtkWidget *hbox; @@ -1285,6 +1345,7 @@ static GtkWidget *bar_pane_keywords_new(const gchar *id, const gchar *title, con pkd->pane.expanded = expanded; + pkd->height = height; pkd->key = g_strdup(key); pkd->expand_checked = TRUE; @@ -1295,6 +1356,7 @@ static GtkWidget *bar_pane_keywords_new(const gchar *id, const gchar *title, con g_object_set_data(G_OBJECT(pkd->widget), "pane_data", pkd); g_signal_connect(G_OBJECT(pkd->widget), "destroy", G_CALLBACK(bar_pane_keywords_destroy), pkd); + gtk_widget_set_size_request(pkd->widget, -1, height); gtk_widget_show(hbox); scrolled = gtk_scrolled_window_new(NULL, NULL); @@ -1417,6 +1479,7 @@ GtkWidget *bar_pane_keywords_new_from_config(const gchar **attribute_names, cons gchar *title = NULL; gchar *key = g_strdup(COMMENT_KEY); gboolean expanded = TRUE; + gint height = 200; GtkWidget *ret; while (*attribute_names) @@ -1428,13 +1491,15 @@ GtkWidget *bar_pane_keywords_new_from_config(const gchar **attribute_names, cons if (READ_CHAR_FULL("title", title)) continue; if (READ_CHAR_FULL("key", key)) continue; if (READ_BOOL_FULL("expanded", expanded)) continue; + if (READ_INT_FULL("height", height)) continue; log_printf("unknown attribute %s = %s\n", option, value); } + options->info_keywords.height = height; bar_pane_translate_title(PANE_KEYWORDS, id, &title); - ret = bar_pane_keywords_new(id, title, key, expanded); + ret = bar_pane_keywords_new(id, title, key, expanded, height); g_free(id); g_free(title); g_free(key); @@ -1476,4 +1541,27 @@ void bar_pane_keywords_update_from_config(GtkWidget *pane, const gchar **attribu } +void bar_pane_keywords_entry_add_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values) +{ + PaneKeywordsData *pkd; + gchar *path = NULL; + GtkTreePath *tree_path; + + pkd = g_object_get_data(G_OBJECT(pane), "pane_data"); + if (!pkd) return; + + while (*attribute_names) + { + const gchar *option = *attribute_names++; + const gchar *value = *attribute_values++; + + if (READ_CHAR_FULL("path", path)) + { + tree_path = gtk_tree_path_new_from_string(path); + gtk_tree_view_expand_to_path(GTK_TREE_VIEW(pkd->keyword_treeview), tree_path); + continue; + } + log_printf("unknown attribute %s = %s\n", option, value); + } +} /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */