Add postprocessor setting dropdown (MR 18)
This commit is contained in:
@@ -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>
|
||||
|
21
src/main.c
21
src/main.c
@@ -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 =
|
||||
@@ -1050,26 +1054,35 @@ activate(GtkApplication *app, gpointer data)
|
||||
|
||||
// Setup settings
|
||||
settings = g_settings_new("org.postmarketos.Megapixels");
|
||||
char* setting_postproc = g_settings_get_string(settings, "postprocessor");
|
||||
char *setting_postproc = g_settings_get_string(settings, "postprocessor");
|
||||
|
||||
// Initialize the postprocessing gsetting to the old processor if
|
||||
// it was not set yet
|
||||
if(setting_postproc == NULL || setting_postproc[0] == '\0') {
|
||||
if (setting_postproc == NULL || setting_postproc[0] == '\0') {
|
||||
printf("Initializing postprocessor gsetting\n");
|
||||
setting_postproc = malloc(512);
|
||||
if(!mp_process_find_processor(setting_postproc)) {
|
||||
if (!mp_process_find_processor(setting_postproc)) {
|
||||
printf("No processor found\n");
|
||||
exit(1);
|
||||
}
|
||||
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 =
|
||||
|
@@ -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)
|
||||
{
|
||||
@@ -651,7 +718,7 @@ process_capture_burst(GdkTexture *thumb)
|
||||
}
|
||||
|
||||
bool save_dng = g_settings_get_boolean(settings, "save-raw");
|
||||
char* postprocessor = g_settings_get_string(settings, "postprocessor");
|
||||
char *postprocessor = g_settings_get_string(settings, "postprocessor");
|
||||
|
||||
char save_dng_s[2] = "0";
|
||||
if (save_dng) {
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user