app: move the follow-theme toggle to GimpDataFactoryView.

By being in GimpContainerIconView, the toggle was only being shown in
grid view, even though it also affected the list view. So we move it up
to the container, next to the query tag entry.

Also I am adding a function to make this toggle visible only when
requested. And so far, we only request it for the Brushes dockable,
because it doesn't do anything on other data dockables (we added some
code to follow theme, for instance in Palettes dockable, but it doesn't
depend on this setting, because it doesn't touch data render, only GUI
render where it's normal to follow theme).

The latter function fixes issue #14260.
This commit is contained in:
Jehan 2025-06-16 12:13:15 +02:00
parent 8628ad77c1
commit 1b9c78dc12
4 changed files with 70 additions and 57 deletions

View file

@ -109,6 +109,8 @@ gimp_brush_factory_view_init (GimpBrushFactoryView *view)
g_signal_connect (view->spacing_adjustment, "value-changed",
G_CALLBACK (gimp_brush_factory_view_spacing_update),
view);
gimp_data_factory_view_show_follow_theme_toggle (GIMP_DATA_FACTORY_VIEW (view), TRUE);
}
static void

View file

@ -46,7 +46,6 @@
struct _GimpContainerIconViewPrivate
{
GimpViewRenderer *dnd_renderer;
GtkWidget *theme_button;
gulong color_scheme_handler_id;
};
@ -375,42 +374,8 @@ gimp_container_icon_view_set_context (GimpContainerView *view,
gimp_container_tree_store_set_context (GIMP_CONTAINER_TREE_STORE (icon_view->model),
context);
g_clear_pointer (&icon_view->priv->theme_button, gtk_widget_destroy);
if (context != NULL)
{
GtkWidget *top_box;
GtkWidget *button;
GtkWidget *image;
GtkIconSize button_icon_size;
GtkReliefStyle button_relief;
#define GIMP_ICON_FOLLOW_THEME "gimp-prefs-theme"
gtk_widget_style_get (GTK_WIDGET (view),
"button-icon-size", &button_icon_size,
"button-relief", &button_relief,
NULL);
top_box = gimp_editor_get_top_box (GIMP_EDITOR (view));
button = gimp_prop_toggle_new (G_OBJECT (context->gimp->config),
"viewables-follow-theme",
GIMP_ICON_FOLLOW_THEME, NULL,
&image);
gtk_button_set_relief (GTK_BUTTON (button), button_relief);
/* Re-setting the image to make sure we use the correct size from
* the theme.
*/
gtk_image_set_from_icon_name (GTK_IMAGE (image), GIMP_ICON_FOLLOW_THEME,
button_icon_size);
gtk_widget_set_visible (button, TRUE);
gtk_box_pack_start (GTK_BOX (top_box), button, FALSE, FALSE, 0);
#undef GIMP_ICON_FOLLOW_THEME
icon_view->priv->theme_button = button;
g_signal_connect_object (button, "toggled",
G_CALLBACK (gimp_container_icon_view_trigger_redraw),
view, G_CONNECT_SWAPPED);
if (icon_view->priv->color_scheme_handler_id == 0)
icon_view->priv->color_scheme_handler_id = g_signal_connect_object (context->gimp->config,
"notify::theme-color-scheme",

View file

@ -73,6 +73,9 @@ struct _GimpDataFactoryViewPrivate
GtkWidget *assign_tag_entry;
GList *selected_items;
GtkWidget *follow_theme_toggle;
gboolean show_follow_theme_toggle;
GtkWidget *edit_button;
GtkWidget *new_button;
GtkWidget *duplicate_button;
@ -167,6 +170,8 @@ gimp_data_factory_view_init (GimpDataFactoryView *view)
view->priv->duplicate_button = NULL;
view->priv->delete_button = NULL;
view->priv->refresh_button = NULL;
view->priv->show_follow_theme_toggle = FALSE;
}
static void
@ -218,7 +223,12 @@ gimp_data_factory_view_constructed (GObject *object)
GimpDataFactoryViewPrivate *priv = factory_view->priv;
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (object);
GimpUIManager *manager;
GimpContext *context;
GtkWidget *image;
GtkWidget *hbox;
gchar *str;
GtkIconSize button_icon_size;
GtkReliefStyle button_relief;
G_OBJECT_CLASS (parent_class)->constructed (object);
@ -279,17 +289,39 @@ gimp_data_factory_view_constructed (GObject *object)
str, NULL);
g_free (str);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 1);
gtk_box_pack_start (GTK_BOX (editor->view), hbox, FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (editor->view), hbox, 0);
gtk_widget_set_visible (hbox, TRUE);
/* Query tag entry */
priv->query_tag_entry =
gimp_combo_tag_entry_new (GIMP_TAGGED_CONTAINER (priv->tagged_container),
GIMP_TAG_ENTRY_MODE_QUERY);
gtk_box_pack_start (GTK_BOX (editor->view),
priv->query_tag_entry,
FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (editor->view),
priv->query_tag_entry, 0);
gtk_box_pack_start (GTK_BOX (hbox), priv->query_tag_entry, TRUE, TRUE, 0);
gtk_widget_show (priv->query_tag_entry);
/* Follow Theme toggle */
g_object_get (object,
"context", &context,
NULL);
gtk_widget_style_get (GTK_WIDGET (editor->view),
"button-icon-size", &button_icon_size,
"button-relief", &button_relief,
NULL);
#define GIMP_ICON_FOLLOW_THEME "gimp-prefs-theme"
priv->follow_theme_toggle = gimp_prop_toggle_new (G_OBJECT (context->gimp->config),
"viewables-follow-theme",
GIMP_ICON_FOLLOW_THEME, NULL,
&image);
gtk_button_set_relief (GTK_BUTTON (priv->follow_theme_toggle), button_relief);
/* Re-setting the image to make sure we use the correct size from theme. */
gtk_image_set_from_icon_name (GTK_IMAGE (image), GIMP_ICON_FOLLOW_THEME, button_icon_size);
#undef GIMP_ICON_FOLLOW_THEME
gtk_box_pack_start (GTK_BOX (hbox), priv->follow_theme_toggle, FALSE, FALSE, 0);
gtk_widget_set_visible (priv->follow_theme_toggle, priv->show_follow_theme_toggle);
g_object_unref (context);
/* Assign tag entry */
priv->assign_tag_entry =
gimp_combo_tag_entry_new (GIMP_TAGGED_CONTAINER (priv->tagged_container),
@ -461,6 +493,16 @@ gimp_data_factory_view_new (GimpViewType view_type,
NULL);
}
void
gimp_data_factory_view_show_follow_theme_toggle (GimpDataFactoryView *view,
gboolean show)
{
view->priv->show_follow_theme_toggle = show;
if (view->priv->follow_theme_toggle != NULL)
gtk_widget_set_visible (view->priv->follow_theme_toggle, show);
}
GtkWidget *
gimp_data_factory_view_get_edit_button (GimpDataFactoryView *factory_view)
{

View file

@ -49,25 +49,29 @@ struct _GimpDataFactoryViewClass
};
GType gimp_data_factory_view_get_type (void) G_GNUC_CONST;
GType gimp_data_factory_view_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_data_factory_view_new (GimpViewType view_type,
GimpDataFactory *factory,
GimpContext *context,
gint view_size,
gint view_border_width,
GimpMenuFactory *menu_factory,
const gchar *menu_identifier,
const gchar *ui_path,
const gchar *action_group);
GtkWidget * gimp_data_factory_view_new (GimpViewType view_type,
GimpDataFactory *factory,
GimpContext *context,
gint view_size,
gint view_border_width,
GimpMenuFactory *menu_factory,
const gchar *menu_identifier,
const gchar *ui_path,
const gchar *action_group);
GtkWidget * gimp_data_factory_view_get_edit_button (GimpDataFactoryView *factory_view);
GtkWidget * gimp_data_factory_view_get_duplicate_button (GimpDataFactoryView *factory_view);
GimpDataFactory * gimp_data_factory_view_get_data_factory (GimpDataFactoryView *factory_view);
GType gimp_data_factory_view_get_children_type (GimpDataFactoryView *factory_view);
gboolean gimp_data_factory_view_has_data_new_func (GimpDataFactoryView *factory_view);
gboolean gimp_data_factory_view_have (GimpDataFactoryView *factory_view,
GimpObject *object);
void gimp_data_factory_view_show_follow_theme_toggle (GimpDataFactoryView *view,
gboolean show);
GtkWidget * gimp_data_factory_view_get_edit_button (GimpDataFactoryView *factory_view);
GtkWidget * gimp_data_factory_view_get_duplicate_button (GimpDataFactoryView *factory_view);
GimpDataFactory * gimp_data_factory_view_get_data_factory (GimpDataFactoryView *factory_view);
GType gimp_data_factory_view_get_children_type (GimpDataFactoryView *factory_view);
gboolean gimp_data_factory_view_has_data_new_func (GimpDataFactoryView *factory_view);
gboolean gimp_data_factory_view_have (GimpDataFactoryView *factory_view,
GimpObject *object);
#endif /* __GIMP_DATA_FACTORY_VIEW_H__ */