|
@@ -63,6 +63,9 @@ GtkWidget *scanned_codes;
|
|
GtkWidget *preview_top_box;
|
|
GtkWidget *preview_top_box;
|
|
GtkWidget *preview_bottom_box;
|
|
GtkWidget *preview_bottom_box;
|
|
|
|
|
|
|
|
+GtkWidget *message_box;
|
|
|
|
+GtkWidget *message_label;
|
|
|
|
+
|
|
GtkWidget *flash_button;
|
|
GtkWidget *flash_button;
|
|
GtkWidget *iso_button;
|
|
GtkWidget *iso_button;
|
|
GtkWidget *shutter_button;
|
|
GtkWidget *shutter_button;
|
|
@@ -89,6 +92,13 @@ remap(int value, int input_min, int input_max, int output_min, int output_max)
|
|
return (int)result;
|
|
return (int)result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+static void
|
|
|
|
+display_error(const char *message)
|
|
|
|
+{
|
|
|
|
+ gtk_label_set_label(GTK_LABEL(message_label), message);
|
|
|
|
+ gtk_widget_set_visible(message_box, true);
|
|
|
|
+}
|
|
|
|
+
|
|
bool
|
|
bool
|
|
check_window_active()
|
|
check_window_active()
|
|
{
|
|
{
|
|
@@ -162,8 +172,7 @@ update_state(const mp_state_main *new_state)
|
|
state.focus.max = new_state->focus.max;
|
|
state.focus.max = new_state->focus.max;
|
|
state.focus.manual = new_state->focus.manual;
|
|
state.focus.manual = new_state->focus.manual;
|
|
|
|
|
|
- state.has_auto_focus_continuous =
|
|
|
|
- new_state->has_auto_focus_continuous;
|
|
|
|
|
|
+ state.has_auto_focus_continuous = new_state->has_auto_focus_continuous;
|
|
state.has_auto_focus_start = new_state->has_auto_focus_start;
|
|
state.has_auto_focus_start = new_state->has_auto_focus_start;
|
|
|
|
|
|
state.preview_buffer_width = new_state->preview_buffer_width;
|
|
state.preview_buffer_width = new_state->preview_buffer_width;
|
|
@@ -357,10 +366,8 @@ position_preview(float *offset_x, float *offset_y, float *size_x, float *size_y)
|
|
}
|
|
}
|
|
|
|
|
|
int scale_factor = gtk_widget_get_scale_factor(preview);
|
|
int scale_factor = gtk_widget_get_scale_factor(preview);
|
|
- int top_height =
|
|
|
|
- gtk_widget_get_height(preview_top_box) * scale_factor;
|
|
|
|
- int bottom_height =
|
|
|
|
- gtk_widget_get_height(preview_bottom_box) * scale_factor;
|
|
|
|
|
|
+ int top_height = gtk_widget_get_height(preview_top_box) * scale_factor;
|
|
|
|
+ int bottom_height = gtk_widget_get_height(preview_bottom_box) * scale_factor;
|
|
int inner_height = state.preview_height - top_height - bottom_height;
|
|
int inner_height = state.preview_height - top_height - bottom_height;
|
|
|
|
|
|
float scale = (float)MIN(state.preview_width / (float)buffer_width,
|
|
float scale = (float)MIN(state.preview_width / (float)buffer_width,
|
|
@@ -519,6 +526,8 @@ preview_resize(GtkWidget *widget, int width, int height, gpointer data)
|
|
if (state.preview_width != width || state.preview_height != height) {
|
|
if (state.preview_width != width || state.preview_height != height) {
|
|
state.preview_width = width;
|
|
state.preview_width = width;
|
|
state.preview_height = height;
|
|
state.preview_height = height;
|
|
|
|
+ if (state.configuration->count == 0)
|
|
|
|
+ return TRUE;
|
|
update_io_pipeline();
|
|
update_io_pipeline();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -898,9 +907,11 @@ flash_button_clicked(GtkWidget *button, gpointer user_data)
|
|
static void
|
|
static void
|
|
on_realize(GtkWidget *window, gpointer *data)
|
|
on_realize(GtkWidget *window, gpointer *data)
|
|
{
|
|
{
|
|
|
|
+ if (state.configuration->count == 0) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
GtkNative *native = gtk_widget_get_native(window);
|
|
GtkNative *native = gtk_widget_get_native(window);
|
|
mp_process_pipeline_init_gl(gtk_native_get_surface(native));
|
|
mp_process_pipeline_init_gl(gtk_native_get_surface(native));
|
|
-
|
|
|
|
state.camera = state.configuration->cameras[0];
|
|
state.camera = state.configuration->cameras[0];
|
|
update_io_pipeline();
|
|
update_io_pipeline();
|
|
}
|
|
}
|
|
@@ -988,14 +999,14 @@ static gboolean
|
|
fb_profile_to_state(GValue *value, GVariant *variant, gpointer user_data)
|
|
fb_profile_to_state(GValue *value, GVariant *variant, gpointer user_data)
|
|
{
|
|
{
|
|
const gchar *name;
|
|
const gchar *name;
|
|
- gboolean state = FALSE;
|
|
|
|
|
|
+ gboolean fb_state = FALSE;
|
|
|
|
|
|
name = g_variant_get_string(variant, NULL);
|
|
name = g_variant_get_string(variant, NULL);
|
|
|
|
|
|
if (g_strcmp0(name, "full") == 0)
|
|
if (g_strcmp0(name, "full") == 0)
|
|
- state = TRUE;
|
|
|
|
|
|
+ fb_state = TRUE;
|
|
|
|
|
|
- g_value_set_boolean(value, state);
|
|
|
|
|
|
+ g_value_set_boolean(value, fb_state);
|
|
|
|
|
|
return TRUE;
|
|
return TRUE;
|
|
}
|
|
}
|
|
@@ -1005,9 +1016,9 @@ state_to_fb_profile(const GValue *value,
|
|
const GVariantType *expected_type,
|
|
const GVariantType *expected_type,
|
|
gpointer user_data)
|
|
gpointer user_data)
|
|
{
|
|
{
|
|
- gboolean state = g_value_get_boolean(value);
|
|
|
|
|
|
+ gboolean fb_state = g_value_get_boolean(value);
|
|
|
|
|
|
- return g_variant_new_string(state ? "full" : "silent");
|
|
|
|
|
|
+ return g_variant_new_string(fb_state ? "full" : "silent");
|
|
}
|
|
}
|
|
|
|
|
|
static void
|
|
static void
|
|
@@ -1194,6 +1205,9 @@ activate(GtkApplication *app, gpointer data)
|
|
preview_bottom_box =
|
|
preview_bottom_box =
|
|
GTK_WIDGET(gtk_builder_get_object(builder, "bottom-box"));
|
|
GTK_WIDGET(gtk_builder_get_object(builder, "bottom-box"));
|
|
|
|
|
|
|
|
+ message_box = GTK_WIDGET(gtk_builder_get_object(builder, "message-box"));
|
|
|
|
+ message_label = GTK_WIDGET(gtk_builder_get_object(builder, "message-label"));
|
|
|
|
+
|
|
g_signal_connect(window, "realize", G_CALLBACK(on_realize), NULL);
|
|
g_signal_connect(window, "realize", G_CALLBACK(on_realize), NULL);
|
|
|
|
|
|
g_signal_connect(preview, "realize", G_CALLBACK(preview_realize), NULL);
|
|
g_signal_connect(preview, "realize", G_CALLBACK(preview_realize), NULL);
|
|
@@ -1317,7 +1331,11 @@ activate(GtkApplication *app, gpointer data)
|
|
g_application_get_dbus_connection(G_APPLICATION(app));
|
|
g_application_get_dbus_connection(G_APPLICATION(app));
|
|
mp_flash_gtk_init(conn);
|
|
mp_flash_gtk_init(conn);
|
|
|
|
|
|
- mp_io_pipeline_start();
|
|
|
|
|
|
+ if (state.configuration->count > 0) {
|
|
|
|
+ mp_io_pipeline_start();
|
|
|
|
+ } else {
|
|
|
|
+ display_error("No camera found");
|
|
|
|
+ }
|
|
|
|
|
|
gtk_application_add_window(app, GTK_WINDOW(window));
|
|
gtk_application_add_window(app, GTK_WINDOW(window));
|
|
gtk_widget_set_visible(window, true);
|
|
gtk_widget_set_visible(window, true);
|