Mercurial > hg > forks > geeqie
changeset 2496:724b89562e09
Additional keyword menu entries
1. Revert all hidden
2. Collapse all
3. Revert (see Help file)
author | Colin Clark <colin.clark@cclark.uk> |
---|---|
date | Mon, 05 Jun 2017 16:55:14 +0100 |
parents | 33571d08bc37 |
children | 7412fb344215 |
files | doc/docbook/GuideSidebarsInfo.xml src/bar_keywords.c src/metadata.c src/metadata.h |
diffstat | 4 files changed, 112 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/docbook/GuideSidebarsInfo.xml Sat Jun 03 10:04:14 2017 +0100 +++ b/doc/docbook/GuideSidebarsInfo.xml Mon Jun 05 16:55:14 2017 +0100 @@ -128,6 +128,36 @@ <link linkend="GuideOptionsMetadata" endterm="titleGuideOptionsMetadata" /> . </para> + <para> + If the right-click menu item + <guimenu>Revert</guimenu> + is executed at any time after a + <guimenu>Show all</guimenu> + or + <guimenu>Collapse all</guimenu> + , the keyword layout will be restored to the state prior to the + <guimenu>Show all</guimenu> + or + <guimenu>Collapse all</guimenu> + . + <para /> + If the right-click menu item + <guimenu>Revert</guimenu> + is executed at any time before a + <guimenu>Show all</guimenu> + or + <guimenu>Collapse all</guimenu> + , the keyword layout will be restored to the state existing at start-up. + </para> + <note> + <para> + The selections in the sub-menu + <guimenu>On any change</guimenu> + will affect the operation of the + <guimenu>Revert</guimenu> + option. + </para> + </note> <para /> </section> <section id="Listpanes-ExifFileinfoCopyrightLocationandGPS">
--- a/src/bar_keywords.c Sat Jun 03 10:04:14 2017 +0100 +++ b/src/bar_keywords.c Mon Jun 05 16:55:14 2017 +0100 @@ -123,6 +123,8 @@ FileData *fd; gchar *key; gint height; + + GList *expanded_rows; }; typedef struct _ConfDialogData ConfDialogData; @@ -1062,6 +1064,11 @@ GtkTreeModel *keyword_tree; + string_list_free(pkd->expanded_rows); + pkd->expanded_rows = NULL; + gtk_tree_view_map_expanded_rows(GTK_TREE_VIEW(pkd->keyword_treeview), + (bar_keyword_tree_get_expanded_cb), &pkd->expanded_rows); + pkd->hide_unchecked = FALSE; model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview)); @@ -1073,6 +1080,28 @@ bar_keyword_tree_sync(pkd); } +static void bar_pane_keywords_revert_cb(GtkWidget *menu_widget, gpointer data) +{ + PaneKeywordsData *pkd = data; + GList *work; + GtkTreePath *tree_path; + gchar *path; + + gtk_tree_view_collapse_all(GTK_TREE_VIEW(pkd->keyword_treeview)); + + work = pkd->expanded_rows; + while (work) + { + path = work->data; + tree_path = gtk_tree_path_new_from_string(path); + gtk_tree_view_expand_to_path(GTK_TREE_VIEW(pkd->keyword_treeview), tree_path); + work = work->next; + gtk_tree_path_free(tree_path); + } + + bar_keyword_tree_sync(pkd); +} + static void bar_pane_keywords_expand_checked_cb(GtkWidget *menu_widget, gpointer data) { PaneKeywordsData *pkd = data; @@ -1082,6 +1111,34 @@ gtk_tree_model_foreach(model, bar_keyword_tree_expand_if_set_cb, pkd); } +static void bar_pane_keywords_collapse_all_cb(GtkWidget *menu_widget, gpointer data) +{ + PaneKeywordsData *pkd = data; + + string_list_free(pkd->expanded_rows); + pkd->expanded_rows = NULL; + gtk_tree_view_map_expanded_rows(GTK_TREE_VIEW(pkd->keyword_treeview), + (bar_keyword_tree_get_expanded_cb), &pkd->expanded_rows); + + gtk_tree_view_collapse_all(GTK_TREE_VIEW(pkd->keyword_treeview)); + + bar_keyword_tree_sync(pkd); +} + +static void bar_pane_keywords_revert_hidden_cb(GtkWidget *menu_widget, gpointer data) +{ + PaneKeywordsData *pkd = data; + GtkTreeModel *model; + GtkTreeModel *keyword_tree; + + model = gtk_tree_view_get_model(GTK_TREE_VIEW(pkd->keyword_treeview)); + keyword_tree = gtk_tree_model_filter_get_model(GTK_TREE_MODEL_FILTER(model)); + + keyword_revert_hidden_in(GTK_TREE_STORE(keyword_tree), model); + + bar_keyword_tree_sync(pkd); +} + static void bar_pane_keywords_collapse_unchecked_cb(GtkWidget *menu_widget, gpointer data) { PaneKeywordsData *pkd = data; @@ -1266,7 +1323,12 @@ menu_item_add(menu, _("Expand checked"), G_CALLBACK(bar_pane_keywords_expand_checked_cb), pkd); menu_item_add(menu, _("Collapse unchecked"), G_CALLBACK(bar_pane_keywords_collapse_unchecked_cb), pkd); menu_item_add(menu, _("Hide unchecked"), G_CALLBACK(bar_pane_keywords_hide_unchecked_cb), pkd); + menu_item_add(menu, _("Revert all hidden"), G_CALLBACK(bar_pane_keywords_revert_hidden_cb), pkd); + menu_item_add_divider(menu); menu_item_add(menu, _("Show all"), G_CALLBACK(bar_pane_keywords_show_all_cb), pkd); + menu_item_add(menu, _("Collapse all"), G_CALLBACK(bar_pane_keywords_collapse_all_cb), pkd); + menu_item_add(menu, _("Revert"), G_CALLBACK(bar_pane_keywords_revert_cb), pkd); + menu_item_add_divider(menu); submenu = gtk_menu_new(); item = menu_item_add(menu, _("On any change"), NULL, NULL); @@ -1312,7 +1374,8 @@ { PaneKeywordsData *pkd = data; - if (pkd->click_tpath) gtk_tree_path_free(pkd->click_tpath); + string_list_free(pkd->expanded_rows); + if (pkd->click_tpath) gtk_tree_path_free(pkd->click_tpath); if (pkd->idle_id) g_source_remove(pkd->idle_id); file_data_unregister_notify_func(bar_pane_keywords_notify_cb, pkd); @@ -1349,6 +1412,7 @@ pkd->key = g_strdup(key); pkd->expand_checked = TRUE; + pkd->expanded_rows = NULL; hbox = gtk_hbox_new(FALSE, PREF_PAD_GAP); @@ -1559,6 +1623,8 @@ { tree_path = gtk_tree_path_new_from_string(path); gtk_tree_view_expand_to_path(GTK_TREE_VIEW(pkd->keyword_treeview), tree_path); + gtk_tree_path_free(tree_path); + pkd->expanded_rows = g_list_append(pkd->expanded_rows, g_strdup(path)); continue; } log_printf("unknown attribute %s = %s\n", option, value);
--- a/src/metadata.c Sat Jun 03 10:04:14 2017 +0100 +++ b/src/metadata.c Mon Jun 05 16:55:14 2017 +0100 @@ -1605,6 +1605,20 @@ gtk_tree_model_foreach(GTK_TREE_MODEL(keyword_tree), keyword_show_all_in_cb, id); } +static gboolean keyword_revert_hidden_in_cb(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) +{ + if (keyword_is_hidden_in(GTK_TREE_MODEL(keyword_tree), iter, data)) + { + keyword_show_in(GTK_TREE_STORE(model), iter, data); + } + return FALSE; +} + +void keyword_revert_hidden_in(GtkTreeStore *keyword_tree, gpointer id) +{ + gtk_tree_model_foreach(GTK_TREE_MODEL(keyword_tree), keyword_revert_hidden_in_cb, id); +} + static void keyword_hide_unset_in_recursive(GtkTreeStore *keyword_tree, GtkTreeIter *iter_ptr, gpointer id, GList *keywords) { GtkTreeIter iter = *iter_ptr;
--- a/src/metadata.h Sat Jun 03 10:04:14 2017 +0100 +++ b/src/metadata.h Mon Jun 05 16:55:14 2017 +0100 @@ -100,6 +100,7 @@ void keyword_show_in(GtkTreeStore *keyword_tree, GtkTreeIter *iter, gpointer id); gboolean keyword_is_hidden_in(GtkTreeModel *keyword_tree, GtkTreeIter *iter, gpointer id); void keyword_show_all_in(GtkTreeStore *keyword_tree, gpointer id); +void keyword_revert_hidden_in(GtkTreeStore *keyword_tree, gpointer id); void keyword_hide_unset_in(GtkTreeStore *keyword_tree, gpointer id, GList *keywords); void keyword_show_set_in(GtkTreeStore *keyword_tree, gpointer id, GList *keywords);