Add postprocessor setting dropdown (MR 18)

This commit is contained in:
Martijn Braam
2022-06-24 14:53:30 +02:00
parent 46b07c6c4d
commit ee26b8e6f7
4 changed files with 126 additions and 17 deletions

View File

@@ -1,6 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<object class="GtkListStore" id="list-postprocessors">
<columns>
<column type="gchararray"/>
<column type="gchararray"/>
</columns>
</object>
<object class="GtkWindow" id="window">
<property name="can-focus">0</property>
<property name="default-width">360</property>
@@ -247,6 +253,27 @@
</child>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="halign">start</property>
<property name="label">Postprocessor</property>
</object>
</child>
<child>
<object class="GtkComboBox" id="setting-processor">
<property name="visible">True</property>
<property name="model">list-postprocessors</property>
<property name="entry-text-column">1</property>
<property name="id-column">0</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkCheckButton" id="setting-raw">
<property name="label">Save raw files</property>

View File

@@ -1001,6 +1001,10 @@ activate(GtkApplication *app, gpointer data)
GTK_WIDGET(gtk_builder_get_object(builder, "flash-controls-button"));
GtkWidget *setting_dng_button =
GTK_WIDGET(gtk_builder_get_object(builder, "setting-raw"));
GtkWidget *setting_postprocessor_combo =
GTK_WIDGET(gtk_builder_get_object(builder, "setting-processor"));
GtkListStore *setting_postprocessor_list = GTK_LIST_STORE(
gtk_builder_get_object(builder, "list-postprocessors"));
preview = GTK_WIDGET(gtk_builder_get_object(builder, "preview"));
main_stack = GTK_WIDGET(gtk_builder_get_object(builder, "main_stack"));
open_last_stack =
@@ -1064,12 +1068,21 @@ activate(GtkApplication *app, gpointer data)
g_settings_set_string(settings, "postprocessor", setting_postproc);
printf("Initialized postprocessor to %s\n", setting_postproc);
}
// Find all postprocessors for the settings list
mp_process_find_all_processors(setting_postprocessor_list);
// Bind settings widgets to the actual settings
g_settings_bind(settings,
"save-raw",
setting_dng_button,
"active",
G_SETTINGS_BIND_DEFAULT);
g_settings_bind(settings,
"postprocessor",
setting_postprocessor_combo,
"active-id",
G_SETTINGS_BIND_DEFAULT);
// Listen for phosh rotation
GDBusConnection *conn =

View File

@@ -76,6 +76,73 @@ register_custom_tiff_tags(TIFF *tif)
sizeof(custom_fields) / sizeof(custom_fields[0]));
}
void
mp_process_find_all_processors(GtkListStore *store)
{
GtkTreeIter iter;
char buffer[512];
// Find all the original postprocess.sh locations
// Check postprocess.sh in the current working directory
if (access("./data/postprocess.sh", F_OK) != -1) {
gtk_list_store_insert(store, &iter, -1);
gtk_list_store_set(store,
&iter,
0,
"./data/postprocess.sh",
1,
"(cwd) postprocess.sh",
-1);
}
// Check for a script in XDG_CONFIG_HOME
sprintf(buffer, "%s/megapixels/postprocess.sh", g_get_user_config_dir());
if (access(buffer, F_OK) != -1) {
gtk_list_store_insert(store, &iter, -1);
gtk_list_store_set(
store, &iter, 0, buffer, 1, "(user) postprocess.sh", -1);
}
// Check user overridden /etc/megapixels/postprocessor.sh
sprintf(buffer, "%s/megapixels/postprocess.sh", SYSCONFDIR);
if (access(buffer, F_OK) != -1) {
gtk_list_store_insert(store, &iter, -1);
gtk_list_store_set(
store, &iter, 0, buffer, 1, "(system) postprocess.sh", -1);
}
// Check user overridden /usr/share/megapixels/postprocessor.sh
sprintf(buffer, "%s/megapixels/postprocess.sh", DATADIR);
if (access(buffer, F_OK) != -1) {
gtk_list_store_insert(store, &iter, -1);
gtk_list_store_set(
store, &iter, 0, buffer, 1, "(built-in) postprocess.sh", -1);
}
// Find extra packaged postprocessor scripts
// These should be packaged in
// /usr/share/megapixels/postprocessor.d/executable
sprintf(buffer, "%s/megapixels/postprocessor.d", DATADIR);
DIR *d;
struct dirent *dir;
d = opendir(buffer);
if (d) {
while ((dir = readdir(d)) != NULL) {
if (dir->d_name[0] == '.') {
continue;
}
sprintf(buffer,
"%s/megapixels/postprocessor.d/%s",
DATADIR,
dir->d_name);
gtk_list_store_insert(store, &iter, -1);
gtk_list_store_set(
store, &iter, 0, buffer, 1, dir->d_name, -1);
}
closedir(d);
}
}
bool
mp_process_find_processor(char *script)
{

View File

@@ -2,6 +2,7 @@
#include "camera.h"
#include "camera_config.h"
#include <gtk/gtk.h>
typedef struct _GdkSurface GdkSurface;
@@ -30,6 +31,7 @@ struct mp_process_pipeline_state {
};
bool mp_process_find_processor(char *script);
void mp_process_find_all_processors(GtkListStore *store);
void mp_process_pipeline_start();
void mp_process_pipeline_stop();