Commit a8df7ead authored by Stepan Salenikovich's avatar Stepan Salenikovich

gnome: cmake module to build gresource file

Refs #66678

Change-Id: I5cba2390f31485aae9f2acea59afa017dc8e8347
parent d81ef291
......@@ -15,8 +15,10 @@ ADD_DEFINITIONS("-std=c++1y")
PROJECT(ring-client-gnome)
SET(LOCAL_CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LOCAL_CMAKE_MODULE_PATH})
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# the GResources.cmake module isn't automatically detected
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/GResources.cmake)
# make sure we're using Qt5
SET(ENABLE_QT5 true)
......@@ -108,6 +110,12 @@ SET( SRC_FILES
src/ring_client_options.c
)
# compile glib resource files to c code
GLIB_COMPILE_RESOURCES( GLIB_RESOURCES_RING
SOURCE
pixmaps/pixmaps.gresource.xml
)
# IF(${ENABLE_TEST} MATCHES true)
# ADD_SUBDIRECTORY( src/test)
# ENDIF()
......@@ -116,6 +124,6 @@ SET( SRC_FILES
# FIND_PACKAGE ( Gettext REQUIRED )
# ADD_SUBDIRECTORY( po )
ADD_EXECUTABLE(ring-gnome ${SRC_FILES})
ADD_EXECUTABLE(ring-gnome ${GLIB_RESOURCES_RING} ${SRC_FILES})
TARGET_LINK_LIBRARIES(ring-gnome ${LIB_RING_CLIENT_LIBRARY} ${GTK3_LIBRARIES} Qt5::Core)
# The code below was taken from the Venom project which is released under the
# GNU General Public License, version 3
#
# Copyright (C) 2013 Venom authors and contributors
#
# See https://github.com/naxuroqa/Venom for a list of contributors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Additional permission under GNU GPL version 3 section 7:
#
# If you modify this program, or any covered work, by linking or
# combining it with the OpenSSL project's OpenSSL library (or a
# modified version of that library), containing parts covered by the
# terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
# grants you additional permission to convey the resulting work.
# Corresponding Source for a non-source form of such a combination
# shall include the source code for the parts of OpenSSL used as well
# as that of the covered work.
#
FIND_PROGRAM(GLIB_COMPILE_RESOURCES_EXECUTABLE NAMES glib-compile-resources)
MARK_AS_ADVANCED(GLIB_COMPILE_RESOURCES_EXECUTABLE)
INCLUDE(CMakeParseArguments)
FUNCTION(GLIB_COMPILE_RESOURCES output)
CMAKE_PARSE_ARGUMENTS(ARGS "" "SOURCE" ${ARGN})
SET(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
SET(out_files "")
FOREACH(src ${ARGS_SOURCE} ${ARGS_UNPARSED_ARGUMENTS})
SET(in_file "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
GET_FILENAME_COMPONENT(WORKING_DIR ${in_file} PATH)
STRING(REPLACE ".xml" ".c" src ${src})
SET(out_file "${DIRECTORY}/${src}")
GET_FILENAME_COMPONENT(OUPUT_DIR ${out_file} PATH)
FILE(MAKE_DIRECTORY ${OUPUT_DIR})
LIST(APPEND out_files "${DIRECTORY}/${src}")
#FIXME implicit depends currently not working
EXECUTE_PROCESS(
COMMAND
${GLIB_COMPILE_RESOURCES_EXECUTABLE}
"--generate-dependencies"
${in_file}
WORKING_DIRECTORY ${WORKING_DIR}
OUTPUT_VARIABLE in_file_dep
)
STRING(REGEX REPLACE "(\r?\n)" ";" in_file_dep "${in_file_dep}")
SET(in_file_dep_path "")
FOREACH(dep ${in_file_dep})
LIST(APPEND in_file_dep_path "${WORKING_DIR}/${dep}")
ENDFOREACH(dep ${in_file_dep})
ADD_CUSTOM_COMMAND(
OUTPUT ${out_file}
WORKING_DIRECTORY ${WORKING_DIR}
COMMAND
${GLIB_COMPILE_RESOURCES_EXECUTABLE}
ARGS
"--generate-source"
"--target=${out_file}"
${in_file}
DEPENDS
${in_file};${in_file_dep_path}
)
ENDFOREACH(src ${ARGS_SOURCES} ${ARGS_UNPARSED_ARGUMENTS})
SET(${output} ${out_files} PARENT_SCOPE)
ENDFUNCTION(GLIB_COMPILE_RESOURCES)
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/cx/ring/RingGnome">
<file alias="ring-symbol-blue">symbole-ring-coul.svg</file>
<file alias="ring-logo-blue">logo-ring-standard-coul.svg</file>
</gresource>
</gresources>
\ No newline at end of file
This diff is collapsed.
......@@ -107,6 +107,15 @@ ring_client_command_line(GApplication *app, GApplicationCommandLine *cmdline)
/* create an empty window */
priv->win = gtk_application_window_new(GTK_APPLICATION(app));
/* test gresources */
GdkPixbuf* icon = gdk_pixbuf_new_from_resource("/cx/ring/RingGnome/ring-symbol-blue", &error);
if (icon == NULL) {
g_debug("Could not load icon: %s", error->message);
g_error_free(error);
} else
gtk_window_set_icon(GTK_WINDOW(priv->win), icon);
gtk_window_present(GTK_WINDOW(priv->win));
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment