From: Colin Clark Date: Wed, 8 Sep 2021 09:15:19 +0000 (+0100) Subject: Info sidebar pane heights X-Git-Tag: v1.7~60 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=17e1716b05f5ccb3bf8d5715e748e69acd52716d Info sidebar pane heights Move the setting of info sidebar pane heights from the Preferences dialog to a right-click action on the pane. Also remove the Add Pane entries from the right-click pop-up - they are available from a button at the bottom of the sidebar. --- diff --git a/doc/docbook/GuideOptionsGeneral.xml b/doc/docbook/GuideOptionsGeneral.xml index 7e71320e..bd613fa7 100644 --- a/doc/docbook/GuideOptionsGeneral.xml +++ b/doc/docbook/GuideOptionsGeneral.xml @@ -246,21 +246,6 @@ Geeqie must be restarted for changes to take effect. -
- Info Sidebar component heights - - The heights of the following components can be set individually: - - Keywords - Title - Comments - - - - Geeqie must be restarted for changes to take effect. - - -
Show predefined keyword tree Deselecting this option will hide the list of predefined keywords on the right-hand side of the keywords pane of the info sidebar. diff --git a/src/bar.c b/src/bar.c index fc22b6dc..11b41689 100644 --- a/src/bar.c +++ b/src/bar.c @@ -39,6 +39,8 @@ #include "rcfile.h" #include "bar_gps.h" +#include + typedef struct _KnownPanes KnownPanes; struct _KnownPanes { @@ -274,6 +276,72 @@ static void bar_expander_move_bottom_cb(GtkWidget *widget, gpointer data) bar_expander_move(widget, data, FALSE, FALSE); } +static void height_spin_changed_cb(GtkSpinButton *spin, gpointer data) +{ + + gtk_widget_set_size_request(GTK_WIDGET(data), -1, gtk_spin_button_get_value_as_int(spin)); +} + +static gboolean height_spin_key_press_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) +{ + if ((event->keyval == GDK_KEY_Return || event->keyval == GDK_KEY_Escape)) + { + gtk_widget_destroy(GTK_WIDGET(data)); + } + + return TRUE; +} + +static void bar_expander_height_cb(GtkWidget *widget, gpointer data) +{ + GtkWidget *expander = data; + GtkWidget *spin; + GtkWidget *window; + GtkWidget *data_box; + GList *list; + gint x, y; + gint w, h; +#if GTK_CHECK_VERSION(3,0,0) + GdkDisplay *display; + GdkDeviceManager *device_manager; + GdkDevice *device; +#endif + +#if GTK_CHECK_VERSION(3,0,0) + display = gdk_display_get_default(); + device_manager = gdk_display_get_device_manager(display); + device = gdk_device_manager_get_client_pointer(device_manager); + gdk_device_get_position(device, NULL, &x, &y); +#else + gdk_window_get_pointer(NULL, &x, &y, NULL); +#endif + + list = gtk_container_get_children(GTK_CONTAINER(expander)); + data_box = list->data; + + window = gtk_window_new(GTK_WINDOW_POPUP); + + gtk_window_set_modal(GTK_WINDOW(window), TRUE); + gtk_window_set_keep_above(GTK_WINDOW(window), TRUE); + gtk_window_set_default_size(GTK_WINDOW(window), 50, 30); //** @FIXME set these values in a more sensible way */ + + gtk_window_move(GTK_WINDOW(window), x, y); + gtk_widget_show(window); + + gtk_widget_get_size_request(GTK_WIDGET(data_box), &w, &h); + + spin = gtk_spin_button_new_with_range(1, 1000, 1); + g_signal_connect(G_OBJECT(spin), "value-changed", G_CALLBACK(height_spin_changed_cb), data_box); + g_signal_connect(G_OBJECT(spin), "key-press-event", G_CALLBACK(height_spin_key_press_cb), window); + + gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), h); + gtk_container_add(GTK_CONTAINER(window), spin); + gtk_widget_show(spin); + gtk_widget_grab_focus(GTK_WIDGET(spin)); + + g_list_free(list); +} + static void bar_expander_delete_cb(GtkWidget *widget, gpointer data) { GtkWidget *expander = data; @@ -307,8 +375,17 @@ static void bar_menu_popup(GtkWidget *widget) GtkWidget *menu; GtkWidget *bar; GtkWidget *expander; - const KnownPanes *pane = known_panes; BarData *bd; + gboolean display_height_option = FALSE; + gchar const *label; + + label = gtk_expander_get_label(GTK_EXPANDER(widget)); + display_height_option = (g_strcmp0(label, "Comment") == 0) || + (g_strcmp0(label, "Rating") == 0) || + (g_strcmp0(label, "Title") == 0) || + (g_strcmp0(label, "Headline") == 0) || + (g_strcmp0(label, "Keywords") == 0) || + (g_strcmp0(label, "GPS Map") == 0); bd = g_object_get_data(G_OBJECT(widget), "bar_data"); if (bd) @@ -334,18 +411,17 @@ static void bar_menu_popup(GtkWidget *widget) menu_item_add_stock(menu, _("Move _down"), GTK_STOCK_GO_DOWN, G_CALLBACK(bar_expander_move_down_cb), expander); menu_item_add_stock(menu, _("Move to _bottom"), GTK_STOCK_GOTO_BOTTOM, G_CALLBACK(bar_expander_move_bottom_cb), expander); menu_item_add_divider(menu); + + if (gtk_expander_get_expanded(GTK_EXPANDER(expander)) && display_height_option) + { + menu_item_add_stock(menu, _("Height..."), GTK_STOCK_PREFERENCES, G_CALLBACK(bar_expander_height_cb), expander); + menu_item_add_divider(menu); + } + menu_item_add_stock(menu, _("Remove"), GTK_STOCK_DELETE, G_CALLBACK(bar_expander_delete_cb), expander); menu_item_add_divider(menu); } - while (pane->id) - { - GtkWidget *item; - item = menu_item_add_stock(menu, _(pane->title), GTK_STOCK_ADD, G_CALLBACK(bar_expander_add_cb), bar); - g_object_set_data(G_OBJECT(item), "pane_add_id", pane->id); - pane++; - } - gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, bar, 0, GDK_CURRENT_TIME); } diff --git a/src/bar_comment.c b/src/bar_comment.c index 4bee4d2d..50470773 100644 --- a/src/bar_comment.c +++ b/src/bar_comment.c @@ -172,21 +172,28 @@ static gint bar_pane_comment_event(GtkWidget *bar, GdkEvent *event) static void bar_pane_comment_write_config(GtkWidget *pane, GString *outstr, gint indent) { PaneCommentData *pcd; + gint w, h; pcd = g_object_get_data(G_OBJECT(pane), "pane_data"); if (!pcd) return; + gtk_widget_get_size_request(GTK_WIDGET(pane), &w, &h); + if (!g_strcmp0(pcd->pane.id, "title")) { - pcd->height = options->info_title.height; + pcd->height = h; } if (!g_strcmp0(pcd->pane.id, "comment")) { - pcd->height = options->info_comment.height; + pcd->height = h; } if (!g_strcmp0(pcd->pane.id, "rating")) { - pcd->height = options->info_rating.height; + pcd->height = h; + } + if (!g_strcmp0(pcd->pane.id, "headline")) + { + pcd->height = h; } WRITE_NL(); WRITE_STRING("info_rating.height = height; } + if (!g_strcmp0(id, "headline")) + { + options->info_headline.height = height; + } bar_pane_translate_title(PANE_COMMENT, id, &title); ret = bar_pane_comment_new(id, title, key, expanded, height); diff --git a/src/bar_gps.c b/src/bar_gps.c index bfcd7b36..61a22755 100644 --- a/src/bar_gps.c +++ b/src/bar_gps.c @@ -674,6 +674,7 @@ static void bar_pane_gps_write_config(GtkWidget *pane, GString *outstr, gint ind GString *buffer = g_string_new(str); gdouble position; gint int_position; + gint w, h; pgd = g_object_get_data(G_OBJECT(pane), "pane_data"); if (!pgd) return; @@ -683,6 +684,10 @@ static void bar_pane_gps_write_config(GtkWidget *pane, GString *outstr, gint ind write_char_option(outstr, indent, "id", pgd->pane.id); write_char_option(outstr, indent, "title", gtk_label_get_text(GTK_LABEL(pgd->pane.title))); WRITE_BOOL(pgd->pane, expanded); + + gtk_widget_get_size_request(GTK_WIDGET(pane), &w, &h); + pgd->height = h; + WRITE_INT(*pgd, height); indent++; diff --git a/src/bar_keywords.c b/src/bar_keywords.c index 09c58a64..1d8ca943 100644 --- a/src/bar_keywords.c +++ b/src/bar_keywords.c @@ -303,11 +303,13 @@ static void bar_pane_keywords_write_config(GtkWidget *pane, GString *outstr, gin { PaneKeywordsData *pkd; GList *path_expanded = NULL; + gint w, h; pkd = g_object_get_data(G_OBJECT(pane), "pane_data"); if (!pkd) return; - pkd->height = options->info_keywords.height; + gtk_widget_get_size_request(GTK_WIDGET(pane), &w, &h); + pkd->height = h; WRITE_NL(); WRITE_STRING("pane.id); diff --git a/src/options.h b/src/options.h index c9623d9d..ce050551 100644 --- a/src/options.h +++ b/src/options.h @@ -111,6 +111,14 @@ struct _ConfOptions gint height; } info_rating; + /** + * @struct info_headline + * info sidebar component height + */ + struct { + gint height; + } info_headline; + /* file ops */ struct { gboolean enable_in_place_rename; diff --git a/src/preferences.c b/src/preferences.c index 559c55a1..1a2250d4 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -2130,31 +2130,6 @@ static void config_tab_general(GtkWidget *notebook) pref_spacer(group, PREF_PAD_GROUP); - group = pref_group_new(vbox, FALSE, _("Info sidebar heights"), GTK_ORIENTATION_VERTICAL); - pref_label_new(group, _("NOTE! Geeqie must be restarted for changes to take effect")); - hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE); - pref_spin_new_int(hbox, _("Keywords:"), NULL, - 1, 9999, 1, - options->info_keywords.height, &c_options->info_keywords.height); - pref_spin_new_int(hbox, _("Title:"), NULL, - 1, 9999, 1, - options->info_title.height, &c_options->info_title.height); - pref_spin_new_int(hbox, _("Comment:"), NULL, - 1, 9999, 1, - options->info_comment.height, &c_options->info_comment.height); - pref_spin_new_int(hbox, _("Rating:"), NULL, - 1, 9999, 1, - options->info_rating.height, &c_options->info_rating.height); - - pref_spacer(group, PREF_PAD_GROUP); - - group = pref_group_new(vbox, FALSE, _("Show predefined keyword tree"), GTK_ORIENTATION_VERTICAL); - - pref_checkbox_new_int(group, _("Show predefined keyword tree (NOTE! Geeqie must be restarted for change to take effect)"), - options->show_predefined_keyword_tree, &c_options->show_predefined_keyword_tree); - - pref_spacer(group, PREF_PAD_GROUP); - net_mon = g_network_monitor_get_default(); geeqie_org = g_network_address_parse_uri(GQ_WEBSITE, 80, NULL); internet_available = g_network_monitor_can_reach(net_mon, geeqie_org, NULL, NULL);