Include glade file in binary

This commit is contained in:
Markus Koch 2018-03-17 17:38:32 +01:00
parent a9b9232dd5
commit 30569fe1a5
3 changed files with 15 additions and 1 deletions

View File

@ -14,6 +14,14 @@ INCLUDE_DIRECTORIES (${GLIB2_INCLUDE_DIRS} ${GOBJECT2_INCLUDE_DIRS} ${GTK3_INCLU
LINK_DIRECTORIES (${GLIB2_LIBRARY_DIRS} ${GOBJECT2_LIBRARY_DIRS} ${GTK3_LIBRARY_DIRS} ${WEBKIT_LIBRARY_DIRS})
add_definitions(${GLIB2_CFLAGS_OTHER} ${GOBJECT2_CFLAGS_OTHER} ${GTK3_CFLAGS_OTHER} ${WEBKIT_CFLAGS_OTHER})
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/resources.c"
COMMAND glib-compile-resources "${CMAKE_CURRENT_SOURCE_DIR}/mdiary.gresource.xml" --target="${CMAKE_CURRENT_BINARY_DIR}/resources.c" --generate-source
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/glade/mainWindow.glade" "${CMAKE_CURRENT_SOURCE_DIR}/mdiary.gresource.xml"
COMMENT "Generating resources"
)
aux_source_directory(./src SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})
target_sources(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/resources.c")
target_link_libraries(${PROJECT_NAME} ${GTK3_LIBRARIES} ${WEBKIT_LIBRARIES})

6
mdiary.gresource.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gtk/mdiary">
<file preprocess="xml-stripblanks">glade/mainWindow.glade</file>
</gresource>
</gresources>

View File

@ -620,7 +620,7 @@ struct mainWindow *mainWindow_new()
GtkBuilder *builder;
struct mainWindow *mainWindow;
builder = gtk_builder_new_from_file("glade/mainWindow.glade");
builder = gtk_builder_new_from_resource("/org/gtk/mdiary/glade/mainWindow.glade");
mainWindow = malloc(sizeof(struct mainWindow));
mainWindow->mainWindow = GTK_WIDGET(gtk_builder_get_object(builder, "mainWindow"));