diff --git a/src/libs/colorpicker.c b/src/libs/colorpicker.c index f829b43b9039..b346884a4cbe 100644 --- a/src/libs/colorpicker.c +++ b/src/libs/colorpicker.c @@ -736,6 +736,8 @@ void gui_init(dt_lib_module_t *self) data->display_samples_check_box = gtk_check_button_new_with_label(_("display samples on image/vectorscope")); + dt_action_define(DT_ACTION(self), NULL, N_("display samples"), + data->display_samples_check_box, &dt_action_def_toggle); gtk_label_set_ellipsize (GTK_LABEL(gtk_bin_get_child(GTK_BIN(data->display_samples_check_box))), PANGO_ELLIPSIZE_MIDDLE); @@ -747,6 +749,8 @@ void gui_init(dt_lib_module_t *self) GtkWidget *restrict_button = gtk_check_button_new_with_label(_("restrict scope to selection")); + dt_action_define(DT_ACTION(self), NULL, N_("restrict scope"), + restrict_button, &dt_action_def_toggle); gtk_label_set_ellipsize (GTK_LABEL(gtk_bin_get_child(GTK_BIN(restrict_button))), PANGO_ELLIPSIZE_MIDDLE); diff --git a/src/libs/image.c b/src/libs/image.c index 3aba49177db8..717952a4d322 100644 --- a/src/libs/image.c +++ b/src/libs/image.c @@ -54,7 +54,7 @@ typedef struct dt_lib_image_t GtkWidget *group_button, *ungroup_button, *cache_button, *uncache_button; GtkWidget *refresh_button, *set_monochrome_button, *set_color_button; GtkWidget *copy_metadata_button, *paste_metadata_button, *clear_metadata_button; - GtkWidget *ratings_flag, *colors_flag, *metadata_flag, *geotags_flag, *tags_flag; + GtkWidget *rating_flag, *colors_flag, *metadata_flag, *geotags_flag, *tags_flag; GtkWidget *page1; // saved here for lua extensions dt_imgid_t imageid; } dt_lib_image_t; @@ -434,11 +434,11 @@ static void set_color_callback(GtkWidget *widget, dt_control_monochrome_images(0); } -static void ratings_flag_callback(GtkWidget *widget, - dt_lib_module_t *self) +static void rating_flag_callback(GtkWidget *widget, + dt_lib_module_t *self) { dt_lib_image_t *d = (dt_lib_image_t *)self->data; - const gboolean flag = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(d->ratings_flag)); + const gboolean flag = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(d->rating_flag)); dt_conf_set_bool("plugins/lighttable/copy_metadata/rating", flag); } @@ -594,63 +594,34 @@ void gui_init(dt_lib_module_t *self) grid = GTK_GRID(gtk_grid_new()); gtk_container_add(GTK_CONTAINER(page2), GTK_WIDGET(grid)); gtk_grid_set_column_homogeneous(grid, TRUE); - line = 0; - - GtkWidget *flag = gtk_check_button_new_with_label(_("ratings")); - d->ratings_flag = flag; - gtk_widget_set_tooltip_text(flag, _("select ratings metadata")); - ellipsize_button(flag); - gtk_grid_attach(grid, flag, 0, line, 3, 1); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flag), - dt_conf_get_bool("plugins/lighttable/copy_metadata/rating")); - g_signal_connect(G_OBJECT(flag), "clicked", G_CALLBACK(ratings_flag_callback), self); - - flag = gtk_check_button_new_with_label(_("colors")); - d->colors_flag = flag; - gtk_widget_set_tooltip_text(flag, _("select colors metadata")); - ellipsize_button(flag); - gtk_grid_attach(grid, flag, 3, line++, 3, 1); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flag), - dt_conf_get_bool("plugins/lighttable/copy_metadata/colors")); - g_signal_connect(G_OBJECT(flag), "clicked", G_CALLBACK(colors_flag_callback), self); - - flag = gtk_check_button_new_with_label(_("tags")); - d->tags_flag = flag; - gtk_widget_set_tooltip_text(flag, _("select tags metadata")); - ellipsize_button(flag); - gtk_grid_attach(grid, flag, 0, line, 3, 1); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flag), - dt_conf_get_bool("plugins/lighttable/copy_metadata/tags")); - g_signal_connect(G_OBJECT(flag), "clicked", G_CALLBACK(tags_flag_callback), self); - - flag = gtk_check_button_new_with_label(_("geo tags")); - d->geotags_flag = flag; - gtk_widget_set_tooltip_text(flag, _("select geo tags metadata")); - ellipsize_button(flag); - gtk_grid_attach(grid, flag, 3, line++, 3, 1); - gtk_toggle_button_set_active - (GTK_TOGGLE_BUTTON(flag), - dt_conf_get_bool("plugins/lighttable/copy_metadata/geotags")); - g_signal_connect(G_OBJECT(flag), "clicked", G_CALLBACK(geotags_flag_callback), self); - - flag = gtk_check_button_new_with_label(_("metadata")); - d->metadata_flag = flag; - gtk_widget_set_tooltip_text(flag, - _("select darktable metadata (from metadata editor module)")); - ellipsize_button(flag); - gtk_grid_attach(grid, flag, 0, line++, 3, 1); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flag), - dt_conf_get_bool("plugins/lighttable/copy_metadata/metadata")); - g_signal_connect(G_OBJECT(flag), "clicked", - G_CALLBACK(metadata_flag_callback), self); dt_lib_module_t *meta = (dt_lib_module_t *)dt_action_section(DT_ACTION(self), N_("metadata")); + line = -1; +#define META_FLAG_BUTTON(label, item, left, tooltip) { \ + GtkWidget *flag = gtk_check_button_new_with_label(_(label)); \ + d->item##_flag = flag; \ + gtk_widget_set_tooltip_text(flag, tooltip); \ + ellipsize_button(flag); \ + gtk_grid_attach(grid, flag, left, !left ? ++line : line, 3, 1); \ + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(flag), \ + dt_conf_get_bool("plugins/lighttable/copy_metadata/" #item)); \ + dt_action_define(DT_ACTION(meta), N_("flags"), \ + label, flag, &dt_action_def_toggle); \ + g_signal_connect(G_OBJECT(flag), "clicked", \ + G_CALLBACK(item##_flag_callback), self); } + + META_FLAG_BUTTON(N_("ratings"), rating, 0, _("select ratings metadata")); + META_FLAG_BUTTON(N_("colors"), colors, 3, _("select colors metadata")); + META_FLAG_BUTTON(N_("tags"), tags, 0, _("select tags metadata")); + META_FLAG_BUTTON(N_("geo tags"), geotags, 3, _("select geo tags metadata")); + META_FLAG_BUTTON(N_("metadata"), metadata, 0, _("select darktable metadata (from metadata editor module)")); + d->copy_metadata_button = dt_action_button_new (meta, N_("copy"), copy_metadata_callback, self, _("set the selected image as source of metadata"), 0, 0); - gtk_grid_attach(grid, d->copy_metadata_button, 0, line, 2, 1); + gtk_grid_attach(grid, d->copy_metadata_button, 0, ++line, 2, 1); g_signal_connect(G_OBJECT(d->copy_metadata_button), "clicked", G_CALLBACK(copy_metadata_callback), self); @@ -666,7 +637,7 @@ void gui_init(dt_lib_module_t *self) GtkWidget *pastemode = NULL; DT_BAUHAUS_COMBOBOX_NEW_FULL - (pastemode, self, NULL, N_("mode"), + (pastemode, meta, NULL, N_("mode"), _("how to handle existing metadata"), dt_conf_get_int("plugins/lighttable/copy_metadata/pastemode"), pastemode_combobox_changed, self, @@ -674,16 +645,16 @@ void gui_init(dt_lib_module_t *self) gtk_grid_attach(grid, pastemode, 0, line++, 6, 1); d->refresh_button = dt_action_button_new - (self, N_("refresh EXIF"), button_clicked, GINT_TO_POINTER(14), + (meta, N_("refresh EXIF"), button_clicked, GINT_TO_POINTER(14), _("update image information to match changes to file"), 0, 0); gtk_grid_attach(grid, d->refresh_button, 0, line++, 6, 1); d->set_monochrome_button = dt_action_button_new - (self, N_("monochrome"), set_monochrome_callback, self, + (meta, N_("monochrome"), set_monochrome_callback, self, _("set selection as monochrome images and activate monochrome workflow"), 0, 0); gtk_grid_attach(grid, d->set_monochrome_button, 0, line, 3, 1); - d->set_color_button = dt_action_button_new(self, N_("color"), set_color_callback, self, + d->set_color_button = dt_action_button_new(meta, N_("color"), set_color_callback, self, _("set selection as color images"), 0, 0); gtk_grid_attach(grid, d->set_color_button, 3, line++, 3, 1); diff --git a/src/libs/styles.c b/src/libs/styles.c index 865751394ced..9e419c0be542 100644 --- a/src/libs/styles.c +++ b/src/libs/styles.c @@ -883,6 +883,8 @@ void gui_init(dt_lib_module_t *self) FALSE, FALSE, 0); d->duplicate = gtk_check_button_new_with_label(_("create duplicate")); + dt_action_define(DT_ACTION(self), NULL, N_("create duplicate"), + d->duplicate, &dt_action_def_toggle); gtk_label_set_ellipsize(GTK_LABEL(gtk_bin_get_child(GTK_BIN(d->duplicate))), PANGO_ELLIPSIZE_START); gtk_box_pack_start(GTK_BOX(self->widget), GTK_WIDGET(d->duplicate), TRUE, FALSE, 0); g_signal_connect(d->duplicate, "toggled", G_CALLBACK(_duplicate_callback), d);