From 48d334acbeb665aae9c2f9f4867ff0afe836e7d3 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Mon, 3 Jul 2017 12:40:55 +0200 Subject: gui: use glib-resources to bake in UI --- bin/gui/CMakeLists.txt | 53 +- bin/gui/config.h.in | 1 - bin/gui/control.glade | 1402 ------------------------------ bin/gui/uca-camera-control.c | 37 +- bin/gui/uca-camera-control.glade | 1402 ++++++++++++++++++++++++++++++ bin/gui/uca-camera-control.gresource.xml | 6 + 6 files changed, 1467 insertions(+), 1434 deletions(-) delete mode 100644 bin/gui/config.h.in delete mode 100644 bin/gui/control.glade create mode 100644 bin/gui/uca-camera-control.glade create mode 100644 bin/gui/uca-camera-control.gresource.xml (limited to 'bin/gui') diff --git a/bin/gui/CMakeLists.txt b/bin/gui/CMakeLists.txt index e722ab0..a8869dd 100644 --- a/bin/gui/CMakeLists.txt +++ b/bin/gui/CMakeLists.txt @@ -1,44 +1,55 @@ cmake_minimum_required(VERSION 2.6) -#{{{ Variables -set(CMAKE_INSTALL_GLADEDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/libuca") -#}}} -#{{{ Configure find_package(PkgConfig) +find_program(GLIB_COMPILE_RESOURCES glib-compile-resources REQUIRED) pkg_check_modules(GTK2 gtk+-2.0>=2.22) pkg_check_modules(GTHREAD2 gthread-2.0) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in - ${CMAKE_CURRENT_BINARY_DIR}/config.h) - -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/control.glade - ${CMAKE_CURRENT_BINARY_DIR}) -#}}} -#{{{ Target if (GTK2_FOUND) + set(GRESOURCES_XML "${CMAKE_CURRENT_SOURCE_DIR}/uca-camera-control.gresource.xml") + set(GRESOURCES_H "${CMAKE_CURRENT_BINARY_DIR}/resources.h") + set(GRESOURCES_C "${CMAKE_CURRENT_BINARY_DIR}/resources.c") + + add_custom_command( + OUTPUT ${GRESOURCES_H} + COMMAND ${GLIB_COMPILE_RESOURCES} + --target ${GRESOURCES_H} + --generate-header ${GRESOURCES_XML} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/uca-camera-control.glade" ${GRESOURCES_XML} + ) + + add_custom_command( + OUTPUT ${GRESOURCES_C} + COMMAND ${GLIB_COMPILE_RESOURCES} + --target ${GRESOURCES_C} + --generate-source ${GRESOURCES_XML} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/uca-camera-control.glade" ${GRESOURCES_XML} + ) + include_directories(${GTK2_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}) - set(BINARY "uca-camera-control") - add_executable(${BINARY} + add_executable(uca-camera-control uca-camera-control.c egg-property-cell-renderer.c egg-property-tree-view.c - egg-histogram-view.c) + egg-histogram-view.c + ${GRESOURCES_C} + ) + + add_custom_target(resources DEPENDS ${GRESOURCES_C} ${GRESOURCES_H}) + add_dependencies(uca-camera-control resources) - target_link_libraries(${BINARY} + target_link_libraries(uca-camera-control m uca ${GTK2_LIBRARIES} ${GTHREAD2_LIBRARIES}) - install(TARGETS ${BINARY} + install(TARGETS uca-camera-control RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT executables) - - install(FILES control.glade - DESTINATION ${CMAKE_INSTALL_GLADEDIR} - COMPONENT executables) endif() -#}}} diff --git a/bin/gui/config.h.in b/bin/gui/config.h.in deleted file mode 100644 index 7d4d5a0..0000000 --- a/bin/gui/config.h.in +++ /dev/null @@ -1 +0,0 @@ -#define CONTROL_GLADE_PATH "${CMAKE_INSTALL_GLADEDIR}/control.glade" diff --git a/bin/gui/control.glade b/bin/gui/control.glade deleted file mode 100644 index 967fdf0..0000000 --- a/bin/gui/control.glade +++ /dev/null @@ -1,1402 +0,0 @@ - - - - - - 1 - 10 - - - - - - - - - - - - - - - - - - - False - 6 - - - True - False - 2 - - - True - True - automatic - automatic - - - True - True - camera-types - False - 0 - - - Choose camera - - - - 0 - - - - - - - - - True - True - 0 - - - - - True - False - 6 - end - - - gtk-quit - False - True - True - True - True - - - - False - False - 0 - - - - - gtk-ok - False - True - True - True - True - - - False - False - 1 - - - - - False - True - 6 - 1 - - - - - - - - - - - - - - - grayscale - 1 - - - jet - 2 - - - - - 100 - 1 - 10 - 10 - - - False - 5 - normal - - - True - False - 2 - - - True - False - end - - - gtk-close - False - True - True - True - True - - - False - False - 0 - - - - - False - False - end - 0 - - - - - True - False - 10 - 6 - - - True - False - 0 - Downloading Frames … - - - False - False - 0 - - - - - True - False - download-adjustment - - - False - True - 1 - - - - - True - True - 1 - - - - - - download-close-button - - - - 100 - 0.01 - 10 - - - 1 - 10 - - - 100 - 1 - 10 - - - 65535 - 256 - 1 - 10 - - - 100 - 1 - 10 - - - 65535 - 1 - 10 - - - 100 - 1 - 10 - - - 65535 - 1 - 10 - - - False - Camera Control - 1024 - 768 - - - - True - False - - - True - False - - - False - True - False - _File - True - - - True - False - - - gtk-new - False - True - False - True - True - - - - - gtk-open - False - True - False - True - True - - - - - gtk-save-as - False - True - False - True - True - - - - - True - False - - - - - gtk-quit - False - True - False - True - True - - - - - - - - - - False - True - False - _Help - True - - - True - False - - - gtk-about - False - True - False - True - True - - - - - - - - - False - True - 0 - - - - - True - False - - - False - True - False - Run - True - gtk-media-play - - - False - True - - - - - False - True - False - Record - True - gtk-media-record - - - False - True - - - - - False - True - False - Stop - True - gtk-media-stop - - - False - True - - - - - False - True - False - Download - True - network-receive - - - False - True - - - - - False - True - False - - - False - True - - - - - False - True - False - Zoom in - True - gtk-zoom-in - - - False - True - - - - - False - True - False - Zoom out - True - gtk-zoom-out - - - False - True - - - - - False - True - False - 100 % - True - gtk-zoom-100 - - - False - True - - - - - False - True - False - rectangle color - True - gtk-color-picker - - - False - True - - - - - False - True - 1 - - - - - True - True - 6 - - - 640 - 480 - True - True - hadjustment - vadjustment - automatic - automatic - - - True - False - queue - - - True - True - False - GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK - queue - True - - - True - False - GDK_POINTER_MOTION_MASK | GDK_STRUCTURE_MASK - gtk-missing-image - - - - - - - - - True - True - - - - - True - False - - - True - True - True - - - True - False - 12 - - - True - False - 0 - Settings - - - - - - False - False - 0 - - - - - True - False - 6 - 3 - 2 - - - True - False - 0 - Exposure time: - - - GTK_FILL - - 6 - - - - - True - False - 0 - Acquire: - - - 1 - 2 - GTK_FILL - - 6 - - - - - True - False - 6 - - - True - True - - False - False - True - True - exposure-adjustment - 6 - - - False - True - 0 - - - - - True - False - 0 - seconds - - - True - True - 1 - - - - - 1 - 2 - 6 - 6 - - - - - True - False - 6 - - - True - True - - 6 - False - False - True - True - acquisitions-adjustment - - - False - True - 0 - - - - - True - False - 0 - frames - - - True - True - 1 - - - - - 1 - 2 - 1 - 2 - 6 - - - - - Repeat - False - True - True - False - 0 - True - - - 2 - 3 - GTK_FILL - - 6 - 3 - - - - - True - False - False - 6 - - - True - True - - 6 - False - False - True - True - - - False - True - 0 - - - - - True - False - 0 - times - - - True - True - 1 - - - - - 1 - 2 - 2 - 3 - - 6 - - - - - False - True - 1 - - - - - True - False - 0 - 0 - 6 - Frames - - - - - - False - False - 2 - - - - - True - False - 0 - 12 - - - True - True - frames-adjustment - 0 - - - - - True - True - 3 - - - - - - - True - False - Acquisition - - - - - - - - False - True - 0 - - - - - True - True - True - - - True - False - 12 - - - True - False - 0 - Histogram - - - - - - False - False - 0 - - - - - True - False - 12 - - - True - False - - - True - False - 0 - Minimum: - - - False - False - 0 - - - - - 100 - True - True - - False - False - True - True - min-bin-value-adjustment - - - False - False - 6 - 1 - - - - - True - False - 0 - Maximum: - - - False - False - 2 - - - - - 100 - True - True - - False - False - True - True - max-bin-value-adjustment - - - False - False - 6 - 3 - - - - - False - False - 6 - 0 - - - - - - - - Live Update - False - True - True - False - 6 - 0 - True - True - - - False - False - 2 - - - - - True - True - 1 - - - - - True - False - 12 - 2 - 2 - 6 - 6 - - - - - - True - False - 0 - Distribution: - - - GTK_FILL - - - - - True - False - 6 - - - True - False - 0 - µ = 0.0 - - - True - True - 0 - - - - - True - False - 0 - σ = 0.0 - - - True - True - 1 - - - - - True - False - 0 - min = 0 - - - True - True - 2 - - - - - True - False - 0 - max = 0 - - - True - True - 3 - - - - - 1 - 2 - - - - - - True - False - 6 - - - True - False - 0 - x = 0 - - - True - True - 0 - - - - - True - False - 0 - y = 0 - - - True - True - 1 - - - - - True - False - 0 - val = 0 - - - True - True - 2 - - - - - - - - 1 - 2 - 1 - 2 - GTK_FILL - - - - - - True - True - 2 - - - - - - - True - False - Statistics - - - - - - - - False - True - 1 - - - - - True - True - - - True - False - - - True - False - 12 - 6 - - - True - False - 0 - Colormap: - - - False - False - 0 - - - - - True - False - colormaps - - - - 0 - - - - - False - False - 1 - - - - - True - True - 0 - - - - - True - False - 12 - 2 - 6 - 6 - - - True - False - 0 - ROI: - - - GTK_FILL - - - - - True - False - 6 - - - True - False - 0 - x = 0 - - - True - True - 0 - - - - - True - False - 0 - y = 0 - - - True - True - 1 - - - - - True - False - 0 - width = 0 - - - True - True - 2 - - - - - True - False - 0 - height = 0 - - - True - True - 3 - - - - - 1 - 2 - - - - - - True - True - 1 - - - - - Logarithm - False - True - True - False - 10 - 0 - True - - - False - False - 2 - - - - - - - True - False - Preview - - - - - - - - False - False - 2 - - - - - True - True - - - True - True - automatic - automatic - - - - - - - - True - False - Properties - - - - - - - - True - True - 3 - - - - - True - True - - - - - True - True - 2 - - - - - - - 65535 - 1 - 10 - - - 65535 - 1 - 10 - - - - - - - - - - - 400 % - 4 - - - 200 % - 2 - - - 100 % - 1 - - - 50 % - 0.5 - - - 25 % - 0.25 - - - - diff --git a/bin/gui/uca-camera-control.c b/bin/gui/uca-camera-control.c index f59460d..375de2f 100644 --- a/bin/gui/uca-camera-control.c +++ b/bin/gui/uca-camera-control.c @@ -23,12 +23,12 @@ #include #include -#include "config.h" #include "uca-camera.h" #include "uca-plugin-manager.h" #include "uca-ring-buffer.h" #include "egg-property-tree-view.h" #include "egg-histogram-view.h" +#include "resources.h" typedef enum { IDLE, @@ -1548,6 +1548,29 @@ create_choice_window (GtkBuilder *builder) g_list_free (camera_types); } +static gboolean +builder_add_from_resource (GtkBuilder *builder, const gchar *resource_path, GError **error) +{ + GBytes *data; + const gchar *buffer; + gsize length; + gboolean ret; + + g_assert (error && *error == NULL); + data = g_resources_lookup_data (resource_path, 0, error); + + if (data == NULL) + return FALSE; + + length = 0; + buffer = g_bytes_get_data (data, &length); + g_assert (buffer != NULL); + + ret = gtk_builder_add_from_string (builder, buffer, length, error) > 0; + g_bytes_unref (data); + return ret; +} + int main (int argc, char *argv[]) { @@ -1578,15 +1601,9 @@ main (int argc, char *argv[]) builder = gtk_builder_new (); - if (!gtk_builder_add_from_file (builder, CONTROL_GLADE_PATH, &error)) { - g_warning ("Cannot load UI: `%s'. Trying in current working directory.", error->message); - g_error_free (error); - error = NULL; - - if (!gtk_builder_add_from_file (builder, "control.glade", &error)) { - g_warning ("Cannot load UI: `%s'.", error->message); - return 1; - } + if (!builder_add_from_resource (builder, "/edu/kit/ipe/uca-camera-control/uca-camera-control.glade", &error)) { + g_warning ("Could not load UI: %s", error->message); + return 1; } plugin_manager = uca_plugin_manager_new (); diff --git a/bin/gui/uca-camera-control.glade b/bin/gui/uca-camera-control.glade new file mode 100644 index 0000000..967fdf0 --- /dev/null +++ b/bin/gui/uca-camera-control.glade @@ -0,0 +1,1402 @@ + + + + + + 1 + 10 + + + + + + + + + + + + + + + + + + + False + 6 + + + True + False + 2 + + + True + True + automatic + automatic + + + True + True + camera-types + False + 0 + + + Choose camera + + + + 0 + + + + + + + + + True + True + 0 + + + + + True + False + 6 + end + + + gtk-quit + False + True + True + True + True + + + + False + False + 0 + + + + + gtk-ok + False + True + True + True + True + + + False + False + 1 + + + + + False + True + 6 + 1 + + + + + + + + + + + + + + + grayscale + 1 + + + jet + 2 + + + + + 100 + 1 + 10 + 10 + + + False + 5 + normal + + + True + False + 2 + + + True + False + end + + + gtk-close + False + True + True + True + True + + + False + False + 0 + + + + + False + False + end + 0 + + + + + True + False + 10 + 6 + + + True + False + 0 + Downloading Frames … + + + False + False + 0 + + + + + True + False + download-adjustment + + + False + True + 1 + + + + + True + True + 1 + + + + + + download-close-button + + + + 100 + 0.01 + 10 + + + 1 + 10 + + + 100 + 1 + 10 + + + 65535 + 256 + 1 + 10 + + + 100 + 1 + 10 + + + 65535 + 1 + 10 + + + 100 + 1 + 10 + + + 65535 + 1 + 10 + + + False + Camera Control + 1024 + 768 + + + + True + False + + + True + False + + + False + True + False + _File + True + + + True + False + + + gtk-new + False + True + False + True + True + + + + + gtk-open + False + True + False + True + True + + + + + gtk-save-as + False + True + False + True + True + + + + + True + False + + + + + gtk-quit + False + True + False + True + True + + + + + + + + + + False + True + False + _Help + True + + + True + False + + + gtk-about + False + True + False + True + True + + + + + + + + + False + True + 0 + + + + + True + False + + + False + True + False + Run + True + gtk-media-play + + + False + True + + + + + False + True + False + Record + True + gtk-media-record + + + False + True + + + + + False + True + False + Stop + True + gtk-media-stop + + + False + True + + + + + False + True + False + Download + True + network-receive + + + False + True + + + + + False + True + False + + + False + True + + + + + False + True + False + Zoom in + True + gtk-zoom-in + + + False + True + + + + + False + True + False + Zoom out + True + gtk-zoom-out + + + False + True + + + + + False + True + False + 100 % + True + gtk-zoom-100 + + + False + True + + + + + False + True + False + rectangle color + True + gtk-color-picker + + + False + True + + + + + False + True + 1 + + + + + True + True + 6 + + + 640 + 480 + True + True + hadjustment + vadjustment + automatic + automatic + + + True + False + queue + + + True + True + False + GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK + queue + True + + + True + False + GDK_POINTER_MOTION_MASK | GDK_STRUCTURE_MASK + gtk-missing-image + + + + + + + + + True + True + + + + + True + False + + + True + True + True + + + True + False + 12 + + + True + False + 0 + Settings + + + + + + False + False + 0 + + + + + True + False + 6 + 3 + 2 + + + True + False + 0 + Exposure time: + + + GTK_FILL + + 6 + + + + + True + False + 0 + Acquire: + + + 1 + 2 + GTK_FILL + + 6 + + + + + True + False + 6 + + + True + True + + False + False + True + True + exposure-adjustment + 6 + + + False + True + 0 + + + + + True + False + 0 + seconds + + + True + True + 1 + + + + + 1 + 2 + 6 + 6 + + + + + True + False + 6 + + + True + True + + 6 + False + False + True + True + acquisitions-adjustment + + + False + True + 0 + + + + + True + False + 0 + frames + + + True + True + 1 + + + + + 1 + 2 + 1 + 2 + 6 + + + + + Repeat + False + True + True + False + 0 + True + + + 2 + 3 + GTK_FILL + + 6 + 3 + + + + + True + False + False + 6 + + + True + True + + 6 + False + False + True + True + + + False + True + 0 + + + + + True + False + 0 + times + + + True + True + 1 + + + + + 1 + 2 + 2 + 3 + + 6 + + + + + False + True + 1 + + + + + True + False + 0 + 0 + 6 + Frames + + + + + + False + False + 2 + + + + + True + False + 0 + 12 + + + True + True + frames-adjustment + 0 + + + + + True + True + 3 + + + + + + + True + False + Acquisition + + + + + + + + False + True + 0 + + + + + True + True + True + + + True + False + 12 + + + True + False + 0 + Histogram + + + + + + False + False + 0 + + + + + True + False + 12 + + + True + False + + + True + False + 0 + Minimum: + + + False + False + 0 + + + + + 100 + True + True + + False + False + True + True + min-bin-value-adjustment + + + False + False + 6 + 1 + + + + + True + False + 0 + Maximum: + + + False + False + 2 + + + + + 100 + True + True + + False + False + True + True + max-bin-value-adjustment + + + False + False + 6 + 3 + + + + + False + False + 6 + 0 + + + + + + + + Live Update + False + True + True + False + 6 + 0 + True + True + + + False + False + 2 + + + + + True + True + 1 + + + + + True + False + 12 + 2 + 2 + 6 + 6 + + + + + + True + False + 0 + Distribution: + + + GTK_FILL + + + + + True + False + 6 + + + True + False + 0 + µ = 0.0 + + + True + True + 0 + + + + + True + False + 0 + σ = 0.0 + + + True + True + 1 + + + + + True + False + 0 + min = 0 + + + True + True + 2 + + + + + True + False + 0 + max = 0 + + + True + True + 3 + + + + + 1 + 2 + + + + + + True + False + 6 + + + True + False + 0 + x = 0 + + + True + True + 0 + + + + + True + False + 0 + y = 0 + + + True + True + 1 + + + + + True + False + 0 + val = 0 + + + True + True + 2 + + + + + + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + + True + True + 2 + + + + + + + True + False + Statistics + + + + + + + + False + True + 1 + + + + + True + True + + + True + False + + + True + False + 12 + 6 + + + True + False + 0 + Colormap: + + + False + False + 0 + + + + + True + False + colormaps + + + + 0 + + + + + False + False + 1 + + + + + True + True + 0 + + + + + True + False + 12 + 2 + 6 + 6 + + + True + False + 0 + ROI: + + + GTK_FILL + + + + + True + False + 6 + + + True + False + 0 + x = 0 + + + True + True + 0 + + + + + True + False + 0 + y = 0 + + + True + True + 1 + + + + + True + False + 0 + width = 0 + + + True + True + 2 + + + + + True + False + 0 + height = 0 + + + True + True + 3 + + + + + 1 + 2 + + + + + + True + True + 1 + + + + + Logarithm + False + True + True + False + 10 + 0 + True + + + False + False + 2 + + + + + + + True + False + Preview + + + + + + + + False + False + 2 + + + + + True + True + + + True + True + automatic + automatic + + + + + + + + True + False + Properties + + + + + + + + True + True + 3 + + + + + True + True + + + + + True + True + 2 + + + + + + + 65535 + 1 + 10 + + + 65535 + 1 + 10 + + + + + + + + + + + 400 % + 4 + + + 200 % + 2 + + + 100 % + 1 + + + 50 % + 0.5 + + + 25 % + 0.25 + + + + diff --git a/bin/gui/uca-camera-control.gresource.xml b/bin/gui/uca-camera-control.gresource.xml new file mode 100644 index 0000000..5c84a0d --- /dev/null +++ b/bin/gui/uca-camera-control.gresource.xml @@ -0,0 +1,6 @@ + + + + uca-camera-control.glade + + -- cgit v1.2.3