Progress on GTK4 port
This commit is contained in:
parent
91817b167a
commit
d42ee3e1c0
155
data/camera.ui
155
data/camera.ui
|
@ -18,9 +18,8 @@
|
||||||
<object class="GtkStackPage">
|
<object class="GtkStackPage">
|
||||||
<property name="name">main</property>
|
<property name="name">main</property>
|
||||||
<property name="child">
|
<property name="child">
|
||||||
<object class="GtkBox" id="page_main">
|
<object class="GtkOverlay" id="page_main">
|
||||||
<property name="can-focus">0</property>
|
<property name="can-focus">0</property>
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkGLArea" id="preview">
|
<object class="GtkGLArea" id="preview">
|
||||||
<property name="vexpand">1</property>
|
<property name="vexpand">1</property>
|
||||||
|
@ -28,7 +27,7 @@
|
||||||
<property name="use-es">1</property>
|
<property name="use-es">1</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child type="overlay">
|
||||||
<object class="GtkBox" id="control_box">
|
<object class="GtkBox" id="control_box">
|
||||||
<property name="visible">0</property>
|
<property name="visible">0</property>
|
||||||
<property name="can-focus">0</property>
|
<property name="can-focus">0</property>
|
||||||
|
@ -68,10 +67,23 @@
|
||||||
</style>
|
</style>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child type="overlay">
|
||||||
<object class="GtkActionBar" id="controls_box">
|
<object class="GtkBox" id="controls_box">
|
||||||
|
<property name="orientation">horizontal</property>
|
||||||
|
<property name="hexpand">1</property>
|
||||||
|
<property name="valign">end</property>
|
||||||
|
<property name="homogeneous">0</property>
|
||||||
<property name="can-focus">0</property>
|
<property name="can-focus">0</property>
|
||||||
<child type="start">
|
<property name="margin-bottom">5</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">horizontal</property>
|
||||||
|
<property name="hexpand">1</property>
|
||||||
|
<property name="valign">end</property>
|
||||||
|
<property name="can-focus">0</property>
|
||||||
|
<property name="margin-start">5</property>
|
||||||
|
<property name="spacing">5</property>
|
||||||
|
<child>
|
||||||
<object class="GtkButton" id="settings">
|
<object class="GtkButton" id="settings">
|
||||||
<property name="receives-default">1</property>
|
<property name="receives-default">1</property>
|
||||||
<child>
|
<child>
|
||||||
|
@ -82,7 +94,7 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child type="start">
|
<child>
|
||||||
<object class="GtkButton" id="switch_camera">
|
<object class="GtkButton" id="switch_camera">
|
||||||
<property name="receives-default">1</property>
|
<property name="receives-default">1</property>
|
||||||
<child>
|
<child>
|
||||||
|
@ -93,13 +105,15 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child type="center">
|
</object>
|
||||||
<object class="GtkButton" id="shutter">
|
</child>
|
||||||
<property name="width-request">48</property>
|
<child>
|
||||||
<property name="height-request">48</property>
|
<object class="GtkButton">
|
||||||
|
<property name="action-name">app.capture</property>
|
||||||
<property name="receives-default">1</property>
|
<property name="receives-default">1</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkImage">
|
<object class="GtkImage">
|
||||||
|
<property name="pixel-size">60</property>
|
||||||
<property name="can-focus">0</property>
|
<property name="can-focus">0</property>
|
||||||
<property name="resource">/org/postmarketos/Megapixels/shutter-button.svg</property>
|
<property name="resource">/org/postmarketos/Megapixels/shutter-button.svg</property>
|
||||||
</object>
|
</object>
|
||||||
|
@ -109,7 +123,16 @@
|
||||||
</style>
|
</style>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child type="end">
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">horizontal</property>
|
||||||
|
<property name="hexpand">1</property>
|
||||||
|
<property name="halign">end</property>
|
||||||
|
<property name="valign">end</property>
|
||||||
|
<property name="can-focus">0</property>
|
||||||
|
<property name="margin-end">5</property>
|
||||||
|
<property name="spacing">5</property>
|
||||||
|
<child>
|
||||||
<object class="GtkButton" id="open_directory">
|
<object class="GtkButton" id="open_directory">
|
||||||
<property name="receives-default">1</property>
|
<property name="receives-default">1</property>
|
||||||
<child>
|
<child>
|
||||||
|
@ -120,7 +143,7 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child type="end">
|
<child>
|
||||||
<object class="GtkButton" id="open_last">
|
<object class="GtkButton" id="open_last">
|
||||||
<property name="receives-default">1</property>
|
<property name="receives-default">1</property>
|
||||||
<child>
|
<child>
|
||||||
|
@ -146,7 +169,9 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
</object>
|
||||||
|
</child>
|
||||||
|
<child type="overlay">
|
||||||
<object class="GtkBox" id="error_box">
|
<object class="GtkBox" id="error_box">
|
||||||
<property name="visible">0</property>
|
<property name="visible">0</property>
|
||||||
<property name="can-focus">0</property>
|
<property name="can-focus">0</property>
|
||||||
|
@ -184,18 +209,15 @@
|
||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<!-- <child>
|
<child>
|
||||||
<object class="GtkStackPage">
|
<object class="GtkStackPage">
|
||||||
<property name="name">settings</property>
|
<property name="name">settings</property>
|
||||||
<property name="title" translatable="yes">page1</property>
|
<property name="title" translatable="yes">page1</property>
|
||||||
<property name="position">1</property>
|
|
||||||
<property name="child">
|
<property name="child">
|
||||||
<object class="GtkScrolledWindow" id="page_settings">
|
<object class="GtkScrolledWindow" id="page_settings">
|
||||||
<property name="shadow-type">in</property>
|
|
||||||
<property name="child">
|
<property name="child">
|
||||||
<object class="GtkViewport">
|
<object class="GtkViewport">
|
||||||
<property name="can-focus">0</property>
|
<property name="can-focus">0</property>
|
||||||
<property name="shadow-type">none</property>
|
|
||||||
<property name="child">
|
<property name="child">
|
||||||
<object class="GtkBox">
|
<object class="GtkBox">
|
||||||
<property name="can-focus">0</property>
|
<property name="can-focus">0</property>
|
||||||
|
@ -227,101 +249,6 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkBox">
|
|
||||||
<property name="can-focus">0</property>
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<property name="spacing">4</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel">
|
|
||||||
<property name="can-focus">0</property>
|
|
||||||
<property name="halign">start</property>
|
|
||||||
<property name="label" translatable="yes">Photos</property>
|
|
||||||
<style>
|
|
||||||
<class name="heading"/>
|
|
||||||
</style>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkFrame">
|
|
||||||
<property name="can-focus">0</property>
|
|
||||||
<property name="shadow-type">in</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkAlignment">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">False</property>
|
|
||||||
<property name="left-padding">12</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkBox">
|
|
||||||
<property name="can-focus">0</property>
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<property name="spacing">6</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel">
|
|
||||||
<property name="can-focus">0</property>
|
|
||||||
<property name="halign">start</property>
|
|
||||||
<property name="label" translatable="yes">Resolution</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkComboBox">
|
|
||||||
<property name="can-focus">0</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkLabel">
|
|
||||||
<property name="can-focus">0</property>
|
|
||||||
<property name="halign">start</property>
|
|
||||||
<property name="label" translatable="yes">Storage mode</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkBox">
|
|
||||||
<property name="can-focus">0</property>
|
|
||||||
<property name="orientation">vertical</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkCheckButton" id="store_vng">
|
|
||||||
<property name="label" translatable="yes">Debayer with VNG (slowest)</property>
|
|
||||||
<property name="active">1</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkCheckButton" id="store_simple">
|
|
||||||
<property name="label" translatable="yes">Debayer with linear interpolation</property>
|
|
||||||
<property name="group">store_vng</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkCheckButton" id="store_raw">
|
|
||||||
<property name="label" translatable="yes">Raw</property>
|
|
||||||
<property name="group">store_vng</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child type="label_item">
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
<style>
|
|
||||||
<class name="view"/>
|
|
||||||
</style>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
|
@ -329,7 +256,7 @@
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
</child> -->
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
</object>
|
</object>
|
||||||
|
|
125
src/main.c
125
src/main.c
|
@ -51,6 +51,8 @@ static bool has_auto_focus_continuous;
|
||||||
static bool has_auto_focus_start;
|
static bool has_auto_focus_start;
|
||||||
|
|
||||||
static MPProcessPipelineBuffer *current_preview_buffer = NULL;
|
static MPProcessPipelineBuffer *current_preview_buffer = NULL;
|
||||||
|
static int preview_buffer_width = -1;
|
||||||
|
static int preview_buffer_height = -1;
|
||||||
|
|
||||||
static cairo_surface_t *status_surface = NULL;
|
static cairo_surface_t *status_surface = NULL;
|
||||||
static char last_path[260] = "";
|
static char last_path[260] = "";
|
||||||
|
@ -130,6 +132,9 @@ update_state(const struct mp_main_state *state)
|
||||||
has_auto_focus_start = state->has_auto_focus_start;
|
has_auto_focus_start = state->has_auto_focus_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
preview_buffer_width = state->image_width;
|
||||||
|
preview_buffer_height = state->image_height;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,6 +386,12 @@ preview_draw(GtkGLArea *area, GdkGLContext *ctx, gpointer data)
|
||||||
glClearColor(0, 0, 0, 1);
|
glClearColor(0, 0, 0, 1);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
double ratio = preview_buffer_height / (double)preview_buffer_width;
|
||||||
|
glViewport(0,
|
||||||
|
preview_height - preview_width * ratio,
|
||||||
|
preview_width,
|
||||||
|
preview_width * ratio);
|
||||||
|
|
||||||
if (current_preview_buffer) {
|
if (current_preview_buffer) {
|
||||||
glUseProgram(blit_program);
|
glUseProgram(blit_program);
|
||||||
|
|
||||||
|
@ -488,18 +499,18 @@ on_open_directory_clicked(GtkWidget *widget, gpointer user_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
on_shutter_clicked(GtkWidget *widget, gpointer user_data)
|
run_capture_action(GSimpleAction *action, GVariant *param, gpointer user_data)
|
||||||
{
|
{
|
||||||
gtk_spinner_start(GTK_SPINNER(process_spinner));
|
gtk_spinner_start(GTK_SPINNER(process_spinner));
|
||||||
gtk_stack_set_visible_child(GTK_STACK(open_last_stack), process_spinner);
|
gtk_stack_set_visible_child(GTK_STACK(open_last_stack), process_spinner);
|
||||||
mp_io_pipeline_capture();
|
mp_io_pipeline_capture();
|
||||||
}
|
}
|
||||||
|
|
||||||
// void
|
void
|
||||||
// on_capture_shortcut(void)
|
run_quit_action(GSimpleAction *action, GVariant *param, GApplication *app)
|
||||||
// {
|
{
|
||||||
// on_shutter_clicked(NULL, NULL);
|
g_application_quit(app);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// static bool
|
// static bool
|
||||||
// check_point_inside_bounds(int x, int y, int *bounds_x, int *bounds_y)
|
// check_point_inside_bounds(int x, int y, int *bounds_x, int *bounds_y)
|
||||||
|
@ -584,13 +595,10 @@ on_shutter_clicked(GtkWidget *widget, gpointer user_data)
|
||||||
// gtk_widget_destroy(dialog);
|
// gtk_widget_destroy(dialog);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// void
|
void
|
||||||
// on_preview_tap(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
|
preview_pressed(GtkGestureClick *gesture, int n_press, double x, double y)
|
||||||
// {
|
{
|
||||||
// if (event->type != GDK_BUTTON_PRESS)
|
// Handle taps on the controls
|
||||||
// return;
|
|
||||||
|
|
||||||
// // Handle taps on the controls
|
|
||||||
// if (event->y < 32) {
|
// if (event->y < 32) {
|
||||||
// if (gtk_widget_is_visible(control_box)) {
|
// if (gtk_widget_is_visible(control_box)) {
|
||||||
// gtk_widget_hide(control_box);
|
// gtk_widget_hide(control_box);
|
||||||
|
@ -623,7 +631,7 @@ on_shutter_clicked(GtkWidget *widget, gpointer user_data)
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// // Tapped zbar result
|
// Tapped zbar result
|
||||||
// if (zbar_result) {
|
// if (zbar_result) {
|
||||||
// // Transform the event coordinates to the image
|
// // Transform the event coordinates to the image
|
||||||
// int width = cairo_image_surface_get_width(surface);
|
// int width = cairo_image_surface_get_width(surface);
|
||||||
|
@ -642,11 +650,11 @@ on_shutter_clicked(GtkWidget *widget, gpointer user_data)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// // Tapped preview image itself, try focussing
|
// Tapped preview image itself, try focussing
|
||||||
// if (has_auto_focus_start) {
|
if (has_auto_focus_start) {
|
||||||
// mp_io_pipeline_focus();
|
mp_io_pipeline_focus();
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
on_error_close_clicked(GtkWidget *widget, gpointer user_data)
|
on_error_close_clicked(GtkWidget *widget, gpointer user_data)
|
||||||
|
@ -770,21 +778,9 @@ on_realize(GtkWidget *window, gpointer *data)
|
||||||
update_io_pipeline();
|
update_io_pipeline();
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
GtkApplication parent_instance;
|
|
||||||
} MegapixelsApp;
|
|
||||||
|
|
||||||
typedef GtkApplicationClass MegapixelsAppClass;
|
|
||||||
|
|
||||||
GType megapixels_app_get_type (void);
|
|
||||||
G_DEFINE_TYPE(MegapixelsApp, megapixels_app, GTK_TYPE_APPLICATION)
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
startup(GApplication *app)
|
activate(GtkApplication *app, gpointer data)
|
||||||
{
|
{
|
||||||
G_APPLICATION_CLASS(megapixels_app_parent_class)->startup(app);
|
|
||||||
|
|
||||||
g_object_set(gtk_settings_get_default(), "gtk-application-prefer-dark-theme",
|
g_object_set(gtk_settings_get_default(), "gtk-application-prefer-dark-theme",
|
||||||
TRUE, NULL);
|
TRUE, NULL);
|
||||||
|
|
||||||
|
@ -794,7 +790,6 @@ startup(GApplication *app)
|
||||||
"/org/postmarketos/Megapixels/camera.ui");
|
"/org/postmarketos/Megapixels/camera.ui");
|
||||||
|
|
||||||
GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder, "window"));
|
GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder, "window"));
|
||||||
GtkWidget *shutter = GTK_WIDGET(gtk_builder_get_object(builder, "shutter"));
|
|
||||||
GtkWidget *switch_btn =
|
GtkWidget *switch_btn =
|
||||||
GTK_WIDGET(gtk_builder_get_object(builder, "switch_camera"));
|
GTK_WIDGET(gtk_builder_get_object(builder, "switch_camera"));
|
||||||
GtkWidget *settings_btn =
|
GtkWidget *settings_btn =
|
||||||
|
@ -820,8 +815,6 @@ startup(GApplication *app)
|
||||||
GTK_ADJUSTMENT(gtk_builder_get_object(builder, "control_adj"));
|
GTK_ADJUSTMENT(gtk_builder_get_object(builder, "control_adj"));
|
||||||
control_auto = GTK_WIDGET(gtk_builder_get_object(builder, "control_auto"));
|
control_auto = GTK_WIDGET(gtk_builder_get_object(builder, "control_auto"));
|
||||||
g_signal_connect(window, "realize", G_CALLBACK(on_realize), NULL);
|
g_signal_connect(window, "realize", G_CALLBACK(on_realize), NULL);
|
||||||
// g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
|
|
||||||
g_signal_connect(shutter, "clicked", G_CALLBACK(on_shutter_clicked), NULL);
|
|
||||||
g_signal_connect(error_close, "clicked", G_CALLBACK(on_error_close_clicked),
|
g_signal_connect(error_close, "clicked", G_CALLBACK(on_error_close_clicked),
|
||||||
NULL);
|
NULL);
|
||||||
g_signal_connect(switch_btn, "clicked", G_CALLBACK(on_camera_switch_clicked),
|
g_signal_connect(switch_btn, "clicked", G_CALLBACK(on_camera_switch_clicked),
|
||||||
|
@ -834,15 +827,14 @@ startup(GApplication *app)
|
||||||
NULL);
|
NULL);
|
||||||
g_signal_connect(open_directory, "clicked",
|
g_signal_connect(open_directory, "clicked",
|
||||||
G_CALLBACK(on_open_directory_clicked), NULL);
|
G_CALLBACK(on_open_directory_clicked), NULL);
|
||||||
|
|
||||||
g_signal_connect(preview, "realize", G_CALLBACK(preview_realize), NULL);
|
g_signal_connect(preview, "realize", G_CALLBACK(preview_realize), NULL);
|
||||||
g_signal_connect(preview, "render", G_CALLBACK(preview_draw), NULL);
|
g_signal_connect(preview, "render", G_CALLBACK(preview_draw), NULL);
|
||||||
g_signal_connect(preview, "resize", G_CALLBACK(preview_resize),
|
g_signal_connect(preview, "resize", G_CALLBACK(preview_resize), NULL);
|
||||||
NULL);
|
GtkGesture *click = gtk_gesture_click_new();
|
||||||
// gtk_widget_set_events(preview, gtk_widget_get_events(preview) |
|
g_signal_connect(click, "pressed", G_CALLBACK(preview_pressed), NULL);
|
||||||
// GDK_BUTTON_PRESS_MASK |
|
gtk_widget_add_controller(preview, GTK_EVENT_CONTROLLER(click));
|
||||||
// GDK_POINTER_MOTION_MASK);
|
|
||||||
// g_signal_connect(preview, "button-press-event", G_CALLBACK(on_preview_tap),
|
|
||||||
// NULL);
|
|
||||||
g_signal_connect(control_auto, "toggled",
|
g_signal_connect(control_auto, "toggled",
|
||||||
G_CALLBACK(on_control_auto_toggled), NULL);
|
G_CALLBACK(on_control_auto_toggled), NULL);
|
||||||
g_signal_connect(control_slider, "value-changed",
|
g_signal_connect(control_slider, "value-changed",
|
||||||
|
@ -858,46 +850,35 @@ startup(GApplication *app)
|
||||||
gtk_style_context_add_provider(context, GTK_STYLE_PROVIDER(provider),
|
gtk_style_context_add_provider(context, GTK_STYLE_PROVIDER(provider),
|
||||||
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
GTK_STYLE_PROVIDER_PRIORITY_USER);
|
||||||
|
|
||||||
// GClosure* capture_shortcut = g_cclosure_new(on_capture_shortcut, 0, 0);
|
// Setup capture action
|
||||||
|
GSimpleAction *capture_action = g_simple_action_new("capture", NULL);
|
||||||
|
g_signal_connect(capture_action, "activate", G_CALLBACK(run_capture_action), NULL);
|
||||||
|
g_action_map_add_action(G_ACTION_MAP(app), G_ACTION(capture_action));
|
||||||
|
|
||||||
// GtkAccelGroup* accel_group = gtk_accel_group_new();
|
const char *capture_accels[] = { "space", NULL };
|
||||||
// gtk_accel_group_connect(accel_group,
|
gtk_application_set_accels_for_action(app, "app.capture", capture_accels);
|
||||||
// GDK_KEY_space,
|
|
||||||
// 0,
|
|
||||||
// 0,
|
|
||||||
// capture_shortcut);
|
|
||||||
|
|
||||||
// gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
|
// Setup quit action
|
||||||
|
GSimpleAction *quit_action = g_simple_action_new("quit", NULL);
|
||||||
|
g_signal_connect(quit_action, "activate", G_CALLBACK(run_quit_action), app);
|
||||||
|
g_action_map_add_action(G_ACTION_MAP(app), G_ACTION(quit_action));
|
||||||
|
|
||||||
|
const char *quit_accels[] = { "<Ctrl>q", "<Ctrl>w", NULL };
|
||||||
|
gtk_application_set_accels_for_action(app, "app.quit", quit_accels);
|
||||||
|
|
||||||
mp_io_pipeline_start();
|
mp_io_pipeline_start();
|
||||||
|
|
||||||
gtk_application_add_window(GTK_APPLICATION(app), GTK_WINDOW(window));
|
gtk_application_add_window(app, GTK_WINDOW(window));
|
||||||
gtk_widget_show(window);
|
gtk_widget_show(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
shutdown(GApplication *app)
|
shutdown(GApplication *app, gpointer data)
|
||||||
{
|
{
|
||||||
// Only do cleanup in development, let the OS clean up otherwise
|
// Only do cleanup in development, let the OS clean up otherwise
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
mp_io_pipeline_stop();
|
mp_io_pipeline_stop();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
G_APPLICATION_CLASS(megapixels_app_parent_class)->shutdown(app);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
megapixels_app_init(MegapixelsApp *app)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
megapixels_app_class_init(MegapixelsAppClass *class)
|
|
||||||
{
|
|
||||||
GApplicationClass *application_class = G_APPLICATION_CLASS(class);
|
|
||||||
|
|
||||||
application_class->startup = startup;
|
|
||||||
application_class->shutdown = shutdown;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -924,10 +905,10 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
setenv("LC_NUMERIC", "C", 1);
|
setenv("LC_NUMERIC", "C", 1);
|
||||||
|
|
||||||
MegapixelsApp *app = g_object_new(
|
GtkApplication *app = gtk_application_new("org.postmarketos.Megapixels", 0);
|
||||||
megapixels_app_get_type(),
|
|
||||||
"application-id", "org.postmarketos.Megapixels",
|
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
|
||||||
NULL);
|
g_signal_connect(app, "shutdown", G_CALLBACK(shutdown), NULL);
|
||||||
|
|
||||||
g_application_run(G_APPLICATION(app), argc, argv);
|
g_application_run(G_APPLICATION(app), argc, argv);
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,9 @@ struct mp_main_state {
|
||||||
const struct mp_camera_config *camera;
|
const struct mp_camera_config *camera;
|
||||||
MPCameraMode mode;
|
MPCameraMode mode;
|
||||||
|
|
||||||
|
int image_width;
|
||||||
|
int image_height;
|
||||||
|
|
||||||
bool gain_is_manual;
|
bool gain_is_manual;
|
||||||
int gain;
|
int gain;
|
||||||
int gain_max;
|
int gain_max;
|
||||||
|
|
|
@ -675,11 +675,14 @@ mp_process_pipeline_capture()
|
||||||
mp_pipeline_invoke(pipeline, capture, NULL, 0);
|
mp_pipeline_invoke(pipeline, capture, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int output_buffer_width = -1;
|
||||||
|
static int output_buffer_height = -1;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_output_changed()
|
on_output_changed()
|
||||||
{
|
{
|
||||||
int output_buffer_width = mode.width / 2;
|
output_buffer_width = mode.width / 2;
|
||||||
int output_buffer_height = mode.height / 2;
|
output_buffer_height = mode.height / 2;
|
||||||
|
|
||||||
if (camera->rotate != 0 || camera->rotate != 180) {
|
if (camera->rotate != 0 || camera->rotate != 180) {
|
||||||
int tmp = output_buffer_width;
|
int tmp = output_buffer_width;
|
||||||
|
@ -730,6 +733,8 @@ update_state(MPPipeline *pipeline, const struct mp_process_pipeline_state *state
|
||||||
struct mp_main_state main_state = {
|
struct mp_main_state main_state = {
|
||||||
.camera = camera,
|
.camera = camera,
|
||||||
.mode = mode,
|
.mode = mode,
|
||||||
|
.image_width = output_buffer_width,
|
||||||
|
.image_height = output_buffer_height,
|
||||||
.gain_is_manual = state->gain_is_manual,
|
.gain_is_manual = state->gain_is_manual,
|
||||||
.gain = gain,
|
.gain = gain,
|
||||||
.gain_max = gain_max,
|
.gain_max = gain_max,
|
||||||
|
|
Loading…
Reference in New Issue