Skip to content

Commit 01877d8

Browse files
committed
update gui for batch export
Keep the batch export section completely separate from the other export settings. This has the advantage that the batch export settings can always remain set, which is saved in the darktable preferences.
1 parent b96945c commit 01877d8

File tree

1 file changed

+33
-42
lines changed

1 file changed

+33
-42
lines changed

src/libs/export.c

Lines changed: 33 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ typedef struct dt_lib_export_t
6969
GtkWidget *upscale, *profile, *intent, *style, *style_mode;
7070
dt_gui_collapsible_section_t cs;
7171
GtkWidget *batch_treeview;
72-
GtkButton *export_button;
72+
GtkButton *export_button, *batch_export_button;
7373
GtkWidget *storage_extra_container, *format_extra_container;
7474
GtkWidget *high_quality;
7575
GtkWidget *export_masks;
@@ -100,7 +100,6 @@ static void _get_max_output_dimension(dt_lib_export_t *d,
100100
uint32_t *height);
101101
static void _resync_print_dimensions(dt_lib_export_t *self);
102102
static void _resync_pixel_dimensions(dt_lib_export_t *self);
103-
static gboolean _batch_preset_active(dt_lib_module_t *self);
104103

105104
#define INCH_TO_CM (2.54f)
106105

@@ -217,7 +216,7 @@ void gui_update(dt_lib_module_t *self)
217216
has_act_on
218217
&& format_index != -1
219218
&& storage_index != -1
220-
&& (export_enabled || _batch_preset_active(self)));
219+
&& export_enabled);
221220
}
222221

223222
static void _image_selection_changed_callback(gpointer instance,
@@ -456,12 +455,16 @@ static void _export_with_preset(const gchar *preset_name, dt_lib_module_t *self)
456455
}
457456

458457
static void _export_button_clicked(GtkWidget *widget, dt_lib_module_t *self)
458+
{
459+
_export_with_current_settings(self);
460+
}
461+
462+
static void _batch_export_button_clicked(GtkWidget *widget, dt_lib_module_t *self)
459463
{
460464
dt_lib_export_t *d = (dt_lib_export_t *)self->data;
461465

462466
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(d->batch_treeview));
463467
GtkTreeIter iter;
464-
gboolean batch_used = FALSE;
465468

466469
gboolean valid = gtk_tree_model_get_iter_first(model, &iter);
467470
while(valid)
@@ -475,16 +478,10 @@ static void _export_button_clicked(GtkWidget *widget, dt_lib_module_t *self)
475478
-1);
476479

477480
if(active)
478-
{
479481
_export_with_preset(preset_name, self);
480-
batch_used = TRUE;
481-
}
482482

483483
valid = gtk_tree_model_iter_next(model, &iter);
484484
}
485-
486-
if(!batch_used)
487-
_export_with_current_settings(self);
488485
}
489486

490487
static void _scale_changed(GtkEntry *spin,
@@ -1291,22 +1288,6 @@ static gboolean _batch_preset_active(dt_lib_module_t *self)
12911288
return batch_preset_active;
12921289
}
12931290

1294-
static void _set_export_button_label(dt_lib_module_t *self)
1295-
{
1296-
dt_lib_export_t *d = self->data;
1297-
1298-
if(_batch_preset_active(self))
1299-
{
1300-
gtk_button_set_label(d->export_button, _("batch export"));
1301-
gtk_widget_set_tooltip_text(GTK_WIDGET(d->export_button), _("batch export with all selected presets"));
1302-
}
1303-
else
1304-
{
1305-
gtk_button_set_label(d->export_button, _("export"));
1306-
gtk_widget_set_tooltip_text(GTK_WIDGET(d->export_button), _("export with current settings"));
1307-
}
1308-
}
1309-
13101291
static void _batch_export_toggled_callback(GtkCellRendererToggle *cell_renderer,
13111292
gchar *path_str,
13121293
gpointer user_data)
@@ -1331,8 +1312,8 @@ static void _batch_export_toggled_callback(GtkCellRendererToggle *cell_renderer,
13311312
gchar *setting = g_strdup_printf(CONFIG_PREFIX "batch_%s", name);
13321313
dt_conf_set_bool(setting, toggle);
13331314
g_free(setting);
1334-
_set_export_button_label(self);
1335-
dt_lib_gui_queue_update(self);
1315+
1316+
gtk_widget_set_sensitive(GTK_WIDGET(d->batch_export_button), _batch_preset_active(self));
13361317
}
13371318

13381319
static void _fill_batch_export_list(dt_lib_module_t *self)
@@ -1342,6 +1323,7 @@ static void _fill_batch_export_list(dt_lib_module_t *self)
13421323
GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(d->batch_treeview)));
13431324
gtk_list_store_clear(store);
13441325
GtkTreeIter iter;
1326+
gboolean has_active = FALSE;
13451327

13461328
sqlite3_stmt *stmt;
13471329
DT_DEBUG_SQLITE3_PREPARE_V2(
@@ -1365,9 +1347,11 @@ static void _fill_batch_export_list(dt_lib_module_t *self)
13651347
DT_EXPORT_BATCH_COL_ACTIVE, active,
13661348
DT_EXPORT_BATCH_COL_NAME, name,
13671349
-1);
1350+
has_active |= active;
13681351
}
13691352
sqlite3_finalize(stmt);
1370-
_set_export_button_label(self);
1353+
1354+
gtk_widget_set_sensitive(GTK_WIDGET(d->batch_export_button), has_active);
13711355
}
13721356

13731357
static void _export_presets_changed_callback(gpointer instance, gpointer module, dt_lib_module_t *self)
@@ -1661,22 +1645,10 @@ void gui_init(dt_lib_module_t *self)
16611645
g_signal_connect(G_OBJECT(d->profile), "value-changed",
16621646
G_CALLBACK(_profile_changed), (gpointer)d);
16631647

1664-
1665-
GtkBox *hbox = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
1666-
gtk_box_pack_end(GTK_BOX(self->widget), GTK_WIDGET(hbox), FALSE, TRUE, 0);
1667-
1668-
// Export button
1669-
d->export_button = GTK_BUTTON(dt_action_button_new
1670-
(self, NC_("actionbutton", "export"),
1671-
_export_button_clicked, self,
1672-
NULL,
1673-
GDK_KEY_e, GDK_CONTROL_MASK));
1674-
gtk_box_pack_start(hbox, GTK_WIDGET(d->export_button), TRUE, TRUE, 0);
1675-
16761648
// batch export
16771649
dt_gui_new_collapsible_section(&d->cs,
16781650
"plugins/lighttable/export/batch_export_expanded",
1679-
_("batch presets"),
1651+
_("batch export"),
16801652
GTK_BOX(self->widget),
16811653
DT_ACTION(self));
16821654
gtk_widget_set_tooltip_text(d->cs.expander, _("export the selected images with multiple presets"));
@@ -1704,9 +1676,28 @@ void gui_init(dt_lib_module_t *self)
17041676
gtk_tree_view_column_add_attribute(column, renderer, "text", DT_EXPORT_BATCH_COL_NAME);
17051677

17061678
gtk_box_pack_start(d->cs.container, view, FALSE, FALSE, 0);
1679+
1680+
// Batch export button
1681+
GtkBox *hbox = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
1682+
gtk_box_pack_start(GTK_BOX(d->cs.container), GTK_WIDGET(hbox), FALSE, TRUE, 0);
1683+
d->batch_export_button = GTK_BUTTON(gtk_button_new_with_label(_("export")));
1684+
gtk_box_pack_start(hbox, GTK_WIDGET(d->batch_export_button), TRUE, TRUE, 0);
1685+
g_signal_connect(G_OBJECT(d->batch_export_button), "clicked",
1686+
G_CALLBACK(_batch_export_button_clicked), self);
1687+
17071688
d->batch_treeview = view;
17081689
_fill_batch_export_list(self);
17091690

1691+
// Export button
1692+
hbox = GTK_BOX(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
1693+
gtk_box_pack_end(GTK_BOX(self->widget), GTK_WIDGET(hbox), FALSE, TRUE, 0);
1694+
d->export_button = GTK_BUTTON(dt_action_button_new
1695+
(self, NC_("actionbutton", "export"),
1696+
_export_button_clicked, self,
1697+
NULL,
1698+
GDK_KEY_e, GDK_CONTROL_MASK));
1699+
gtk_box_pack_start(hbox, GTK_WIDGET(d->export_button), TRUE, TRUE, 0);
1700+
17101701
gtk_widget_add_events(d->width, GDK_BUTTON_PRESS_MASK);
17111702
gtk_widget_add_events(d->height, GDK_BUTTON_PRESS_MASK);
17121703
gtk_widget_add_events(d->print_width, GDK_BUTTON_PRESS_MASK);

0 commit comments

Comments
 (0)