| @@ -0,0 +1,286 @@ | ||
| # CMAKE generated file: DO NOT EDIT! | ||
| # Generated by "Unix Makefiles" Generator, CMake Version 2.8 | ||
|
|
||
| # Default target executed when no arguments are given to make. | ||
| default_target: all | ||
| .PHONY : default_target | ||
|
|
||
| #============================================================================= | ||
| # Special targets provided by cmake. | ||
|
|
||
| # Disable implicit rules so canoncical targets will work. | ||
| .SUFFIXES: | ||
|
|
||
| # Remove some rules from gmake that .SUFFIXES does not remove. | ||
| SUFFIXES = | ||
|
|
||
| .SUFFIXES: .hpux_make_needs_suffix_list | ||
|
|
||
| # Suppress display of executed commands. | ||
| $(VERBOSE).SILENT: | ||
|
|
||
| # A target that is always out of date. | ||
| cmake_force: | ||
| .PHONY : cmake_force | ||
|
|
||
| #============================================================================= | ||
| # Set environment variables for the build. | ||
|
|
||
| # The shell in which to execute make rules. | ||
| SHELL = /bin/sh | ||
|
|
||
| # The CMake executable. | ||
| CMAKE_COMMAND = /usr/bin/cmake | ||
|
|
||
| # The command to remove a file. | ||
| RM = /usr/bin/cmake -E remove -f | ||
|
|
||
| # The top-level source directory on which CMake was run. | ||
| CMAKE_SOURCE_DIR = /home/mefrio/Scrivania/cmake | ||
|
|
||
| # The top-level build directory on which CMake was run. | ||
| CMAKE_BINARY_DIR = /home/mefrio/Scrivania/cmake/cmake | ||
|
|
||
| #============================================================================= | ||
| # Targets provided globally by CMake. | ||
|
|
||
| # Special rule for the target edit_cache | ||
| edit_cache: | ||
| @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running interactive CMake command-line interface..." | ||
| /usr/bin/cmake -i . | ||
| .PHONY : edit_cache | ||
|
|
||
| # Special rule for the target edit_cache | ||
| edit_cache/fast: edit_cache | ||
| .PHONY : edit_cache/fast | ||
|
|
||
| # Special rule for the target install | ||
| install: preinstall | ||
| @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." | ||
| /usr/bin/cmake -P cmake_install.cmake | ||
| .PHONY : install | ||
|
|
||
| # Special rule for the target install | ||
| install/fast: preinstall/fast | ||
| @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." | ||
| /usr/bin/cmake -P cmake_install.cmake | ||
| .PHONY : install/fast | ||
|
|
||
| # Special rule for the target install/local | ||
| install/local: preinstall | ||
| @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..." | ||
| /usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake | ||
| .PHONY : install/local | ||
|
|
||
| # Special rule for the target install/local | ||
| install/local/fast: install/local | ||
| .PHONY : install/local/fast | ||
|
|
||
| # Special rule for the target install/strip | ||
| install/strip: preinstall | ||
| @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..." | ||
| /usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake | ||
| .PHONY : install/strip | ||
|
|
||
| # Special rule for the target install/strip | ||
| install/strip/fast: install/strip | ||
| .PHONY : install/strip/fast | ||
|
|
||
| # Special rule for the target list_install_components | ||
| list_install_components: | ||
| @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\"" | ||
| .PHONY : list_install_components | ||
|
|
||
| # Special rule for the target list_install_components | ||
| list_install_components/fast: list_install_components | ||
| .PHONY : list_install_components/fast | ||
|
|
||
| # Special rule for the target rebuild_cache | ||
| rebuild_cache: | ||
| @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." | ||
| /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) | ||
| .PHONY : rebuild_cache | ||
|
|
||
| # Special rule for the target rebuild_cache | ||
| rebuild_cache/fast: rebuild_cache | ||
| .PHONY : rebuild_cache/fast | ||
|
|
||
| # The main all target | ||
| all: cmake_check_build_system | ||
| $(CMAKE_COMMAND) -E cmake_progress_start /home/mefrio/Scrivania/cmake/cmake/CMakeFiles /home/mefrio/Scrivania/cmake/cmake/CMakeFiles/progress.marks | ||
| $(MAKE) -f CMakeFiles/Makefile2 all | ||
| $(CMAKE_COMMAND) -E cmake_progress_start /home/mefrio/Scrivania/cmake/cmake/CMakeFiles 0 | ||
| .PHONY : all | ||
|
|
||
| # The main clean target | ||
| clean: | ||
| $(MAKE) -f CMakeFiles/Makefile2 clean | ||
| .PHONY : clean | ||
|
|
||
| # The main clean target | ||
| clean/fast: clean | ||
| .PHONY : clean/fast | ||
|
|
||
| # Prepare targets for installation. | ||
| preinstall: all | ||
| $(MAKE) -f CMakeFiles/Makefile2 preinstall | ||
| .PHONY : preinstall | ||
|
|
||
| # Prepare targets for installation. | ||
| preinstall/fast: | ||
| $(MAKE) -f CMakeFiles/Makefile2 preinstall | ||
| .PHONY : preinstall/fast | ||
|
|
||
| # clear depends | ||
| depend: | ||
| $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 | ||
| .PHONY : depend | ||
|
|
||
| #============================================================================= | ||
| # Target rules for targets named scratch | ||
|
|
||
| # Build rule for target. | ||
| scratch: cmake_check_build_system | ||
| $(MAKE) -f CMakeFiles/Makefile2 scratch | ||
| .PHONY : scratch | ||
|
|
||
| # fast build rule for target. | ||
| scratch/fast: | ||
| $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/build | ||
| .PHONY : scratch/fast | ||
|
|
||
| src/entry.o: src/entry.c.o | ||
| .PHONY : src/entry.o | ||
|
|
||
| # target to build an object file | ||
| src/entry.c.o: | ||
| $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/entry.c.o | ||
| .PHONY : src/entry.c.o | ||
|
|
||
| src/entry.i: src/entry.c.i | ||
| .PHONY : src/entry.i | ||
|
|
||
| # target to preprocess a source file | ||
| src/entry.c.i: | ||
| $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/entry.c.i | ||
| .PHONY : src/entry.c.i | ||
|
|
||
| src/entry.s: src/entry.c.s | ||
| .PHONY : src/entry.s | ||
|
|
||
| # target to generate assembly for a file | ||
| src/entry.c.s: | ||
| $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/entry.c.s | ||
| .PHONY : src/entry.c.s | ||
|
|
||
| src/main_window.o: src/main_window.c.o | ||
| .PHONY : src/main_window.o | ||
|
|
||
| # target to build an object file | ||
| src/main_window.c.o: | ||
| $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/main_window.c.o | ||
| .PHONY : src/main_window.c.o | ||
|
|
||
| src/main_window.i: src/main_window.c.i | ||
| .PHONY : src/main_window.i | ||
|
|
||
| # target to preprocess a source file | ||
| src/main_window.c.i: | ||
| $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/main_window.c.i | ||
| .PHONY : src/main_window.c.i | ||
|
|
||
| src/main_window.s: src/main_window.c.s | ||
| .PHONY : src/main_window.s | ||
|
|
||
| # target to generate assembly for a file | ||
| src/main_window.c.s: | ||
| $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/main_window.c.s | ||
| .PHONY : src/main_window.c.s | ||
|
|
||
| src/menu.o: src/menu.c.o | ||
| .PHONY : src/menu.o | ||
|
|
||
| # target to build an object file | ||
| src/menu.c.o: | ||
| $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/menu.c.o | ||
| .PHONY : src/menu.c.o | ||
|
|
||
| src/menu.i: src/menu.c.i | ||
| .PHONY : src/menu.i | ||
|
|
||
| # target to preprocess a source file | ||
| src/menu.c.i: | ||
| $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/menu.c.i | ||
| .PHONY : src/menu.c.i | ||
|
|
||
| src/menu.s: src/menu.c.s | ||
| .PHONY : src/menu.s | ||
|
|
||
| # target to generate assembly for a file | ||
| src/menu.c.s: | ||
| $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/menu.c.s | ||
| .PHONY : src/menu.c.s | ||
|
|
||
| src/notebook.o: src/notebook.c.o | ||
| .PHONY : src/notebook.o | ||
|
|
||
| # target to build an object file | ||
| src/notebook.c.o: | ||
| $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/notebook.c.o | ||
| .PHONY : src/notebook.c.o | ||
|
|
||
| src/notebook.i: src/notebook.c.i | ||
| .PHONY : src/notebook.i | ||
|
|
||
| # target to preprocess a source file | ||
| src/notebook.c.i: | ||
| $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/notebook.c.i | ||
| .PHONY : src/notebook.c.i | ||
|
|
||
| src/notebook.s: src/notebook.c.s | ||
| .PHONY : src/notebook.s | ||
|
|
||
| # target to generate assembly for a file | ||
| src/notebook.c.s: | ||
| $(MAKE) -f CMakeFiles/scratch.dir/build.make CMakeFiles/scratch.dir/src/notebook.c.s | ||
| .PHONY : src/notebook.c.s | ||
|
|
||
| # Help Target | ||
| help: | ||
| @echo "The following are some of the valid targets for this Makefile:" | ||
| @echo "... all (the default if no target is provided)" | ||
| @echo "... clean" | ||
| @echo "... depend" | ||
| @echo "... edit_cache" | ||
| @echo "... install" | ||
| @echo "... install/local" | ||
| @echo "... install/strip" | ||
| @echo "... list_install_components" | ||
| @echo "... rebuild_cache" | ||
| @echo "... scratch" | ||
| @echo "... src/entry.o" | ||
| @echo "... src/entry.i" | ||
| @echo "... src/entry.s" | ||
| @echo "... src/main_window.o" | ||
| @echo "... src/main_window.i" | ||
| @echo "... src/main_window.s" | ||
| @echo "... src/menu.o" | ||
| @echo "... src/menu.i" | ||
| @echo "... src/menu.s" | ||
| @echo "... src/notebook.o" | ||
| @echo "... src/notebook.i" | ||
| @echo "... src/notebook.s" | ||
| .PHONY : help | ||
|
|
||
|
|
||
|
|
||
| #============================================================================= | ||
| # Special targets to cleanup operation of make. | ||
|
|
||
| # Special rule to run CMake to check the build system integrity. | ||
| # No rule that depends on this can have commands that come from listfiles | ||
| # because they might be regenerated. | ||
| cmake_check_build_system: | ||
| $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 | ||
| .PHONY : cmake_check_build_system | ||
|
|
| @@ -0,0 +1,36 @@ | ||
| ## | ||
| # This is a helper Macro to parse optional arguments in Macros/Functions | ||
| # It has been taken from the public CMake wiki. | ||
| # See http://www.cmake.org/Wiki/CMakeMacroParseArguments for documentation and | ||
| # licensing. | ||
| ## | ||
| macro(parse_arguments prefix arg_names option_names) | ||
| set(DEFAULT_ARGS) | ||
| foreach(arg_name ${arg_names}) | ||
| set(${prefix}_${arg_name}) | ||
| endforeach(arg_name) | ||
| foreach(option ${option_names}) | ||
| set(${prefix}_${option} FALSE) | ||
| endforeach(option) | ||
|
|
||
| set(current_arg_name DEFAULT_ARGS) | ||
| set(current_arg_list) | ||
| foreach(arg ${ARGN}) | ||
| set(larg_names ${arg_names}) | ||
| list(FIND larg_names "${arg}" is_arg_name) | ||
| if(is_arg_name GREATER -1) | ||
| set(${prefix}_${current_arg_name} ${current_arg_list}) | ||
| set(current_arg_name ${arg}) | ||
| set(current_arg_list) | ||
| else(is_arg_name GREATER -1) | ||
| set(loption_names ${option_names}) | ||
| list(FIND loption_names "${arg}" is_option) | ||
| if(is_option GREATER -1) | ||
| set(${prefix}_${arg} TRUE) | ||
| else(is_option GREATER -1) | ||
| set(current_arg_list ${current_arg_list} ${arg}) | ||
| endif(is_option GREATER -1) | ||
| endif(is_arg_name GREATER -1) | ||
| endforeach(arg) | ||
| set(${prefix}_${current_arg_name} ${current_arg_list}) | ||
| endmacro(parse_arguments) |
| @@ -0,0 +1,10 @@ | ||
| Elementary CMake modules | ||
|
|
||
| This is a set of CMake modules: Translations, GSettings, and Vala modules. | ||
|
|
||
| For all the Vala related modules see README.Vala.rst: | ||
| - ParseArguments.cmake | ||
| - ValaPrecompile.cmake | ||
| - ValaVersion.cmake | ||
| - FindVala.cmake | ||
|
|
| @@ -0,0 +1,173 @@ | ||
| ========== | ||
| Vala CMake | ||
| ========== | ||
| :Author: | ||
| Jakob Westhoff | ||
| :Version: | ||
| Draft | ||
|
|
||
|
|
||
| Overview | ||
| ======== | ||
|
|
||
| Vala CMake is a collection of macros for the CMake_ build system to allow the | ||
| creation and management of projects developed using the Vala_ programming | ||
| language or its "Genie" flavor (less tested). | ||
|
|
||
|
|
||
| Installation | ||
| ============ | ||
|
|
||
| To use the Vala macros in your own project you need to copy the macro files to | ||
| an arbitrary folder in your projects directory and reference them in your | ||
| ``CMakeLists.txt`` file. | ||
|
|
||
| Assuming the macros are stored under ``cmake/vala`` in your projects folder you | ||
| need to add the following information to your base ``CMakeLists.txt``:: | ||
|
|
||
| list(APPEND CMAKE_MODULE_PATH | ||
| ${CMAKE_SOURCE_DIR}/cmake/vala | ||
| ) | ||
|
|
||
| After the new module path as been added you can simply include the provided | ||
| modules or use the provided find routines. | ||
|
|
||
|
|
||
| Finding Vala | ||
| ============ | ||
|
|
||
| The find module for vala works like any other Find module in CMake. | ||
| You can use it by simply calling the usual ``find_package`` function. Default | ||
| parameters like ``REQUIRED`` and ``QUIETLY`` are supported. | ||
|
|
||
| :: | ||
|
|
||
| find_package(Vala REQUIRED) | ||
|
|
||
| After a successful call to the find_package function the following variables | ||
| will be set: | ||
|
|
||
| VALA_FOUND | ||
| Whether the vala compiler has been found or not | ||
|
|
||
| VALA_EXECUTABLE | ||
| Full path to the valac executable if it has been found | ||
|
|
||
| VALA_VERSION | ||
| Version number of the available valac | ||
|
|
||
|
|
||
| Precompiling Vala sources | ||
| ========================= | ||
|
|
||
| CMake is mainly supposed to handle c or c++ based projects. Luckily every vala | ||
| program is translated into plain c code using the vala compiler, followed by | ||
| normal compilation of the generated c program using gcc. | ||
|
|
||
| The macro ``vala_precompile`` uses that fact to create c files from your .vala | ||
| sources for further CMake processing. | ||
|
|
||
| The first parameter provided is a variable, which will be filled with a list of | ||
| c files outputted by the vala compiler. This list can than be used in | ||
| conjunction with functions like ``add_executable`` or others to create the | ||
| necessary compile rules with CMake. | ||
|
|
||
| The initial variable is followed by a list of .vala files to be compiled. | ||
| Please take care to add every vala file belonging to the currently compiled | ||
| project or library as Vala will otherwise not be able to resolve all | ||
| dependencies. | ||
|
|
||
| The following sections may be specified afterwards to provide certain options | ||
| to the vala compiler: | ||
|
|
||
| PACKAGES | ||
| A list of vala packages/libraries to be used during the compile cycle. The | ||
| package names are exactly the same, as they would be passed to the valac | ||
| "--pkg=" option. | ||
|
|
||
| OPTIONS | ||
| A list of optional options to be passed to the valac executable. This can be | ||
| used to pass "--thread" for example to enable multi-threading support. | ||
|
|
||
| DIRECTORY | ||
| Specify the directory where the output source files will be stored. If | ||
| ommitted, the source files will be stored in CMAKE_CURRENT_BINARY_DIR. | ||
|
|
||
| CUSTOM_VAPIS | ||
| A list of custom vapi files to be included for compilation. This can be | ||
| useful to include freshly created vala libraries without having to install | ||
| them in the system. | ||
|
|
||
| GENERATE_VAPI | ||
| Pass all the needed flags to the compiler to create an internal vapi for | ||
| the compiled library. The provided name will be used for this and a | ||
| <provided_name>.vapi file will be created. | ||
|
|
||
| GENERATE_HEADER | ||
| Let the compiler generate a header file for the compiled code. There will | ||
| be a header file as well as an internal header file being generated called | ||
| <provided_name>.h and <provided_name>_internal.h | ||
|
|
||
| The following call is a simple example to the vala_precompile macro showing an | ||
| example to every of the optional sections:: | ||
|
|
||
| vala_precompile(VALA_C | ||
| source1.vala | ||
| source2.vala | ||
| source3.vala | ||
| PACKAGES | ||
| gtk+-2.0 | ||
| gio-1.0 | ||
| posix | ||
| OPTIONS | ||
| --thread | ||
| CUSTOM_VAPIS | ||
| some_vapi.vapi | ||
| GENERATE_VAPI | ||
| myvapi | ||
| GENERATE_HEADER | ||
| myheader | ||
| ) | ||
|
|
||
| Most important is the variable VALA_C which will contain all the generated c | ||
| file names after the call. The easiest way to use this information is to tell | ||
| CMake to create an executable out of it. | ||
|
|
||
| :: | ||
|
|
||
| add_executable(myexecutable ${VALA_C}) | ||
|
|
||
|
|
||
| Further reading | ||
| =============== | ||
|
|
||
| The `Pdf Presenter Console`__ , which is a vala based project of mine, makes | ||
| heavy usage of the here described macros. To look at a real world example of | ||
| these macros the mentioned project is the right place to take a look. The svn | ||
| trunk of it can be found at:: | ||
|
|
||
| svn://pureenergy.cc/pdf_presenter_console/trunk | ||
|
|
||
|
|
||
| __ http://westhoffswelt.de/projects/pdf_presenter_console.html | ||
|
|
||
|
|
||
| Acknowledgments | ||
| =============== | ||
|
|
||
| Thanks go out to Florian Sowade, a fellow local PHP-Usergroupie, who helped me | ||
| a lot with the initial version of this macros and always answered my mostly | ||
| dumb CMake questions. | ||
|
|
||
| .. _CMake: http://cmake.org | ||
| .. _Vala: http://live.gnome.org/Vala | ||
| .. _Genie: http://live.gnome.org/Genie | ||
|
|
||
|
|
||
|
|
||
| .. | ||
| Local Variables: | ||
| mode: rst | ||
| fill-column: 79 | ||
| End: | ||
| vim: et syn=rst tw=79 |
| @@ -0,0 +1,5 @@ | ||
| # Test macros for Marlin, feel free to re-use them. | ||
|
|
||
| macro(add_test_executable EXE_NAME) | ||
| add_test(${EXE_NAME} gtester ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}) | ||
| endmacro() |
| @@ -0,0 +1,135 @@ | ||
| # Translations.cmake, CMake macros written for Marlin, feel free to re-use them | ||
|
|
||
| macro (add_translations_directory NLS_PACKAGE) | ||
| add_custom_target (i18n ALL COMMENT “Building i18n messages.”) | ||
| find_program (MSGFMT_EXECUTABLE msgfmt) | ||
| # be sure that all languages are present | ||
| # Using all usual languages code from https://www.gnu.org/software/gettext/manual/html_node/Language-Codes.html#Language-Codes | ||
| # Rare language codes should be added on-demand. | ||
| set (LANGUAGES_NEEDED aa ab ae af ak am an ar as ast av ay az ba be bg bh bi bm bn bo br bs ca ce ch ckb co cr cs cu cv cy da de dv dz ee el en_AU en_CA en_GB eo es et eu fa ff fi fj fo fr fr_CA fy ga gd gl gn gu gv ha he hi ho hr ht hu hy hz ia id ie ig ii ik io is it iu ja jv ka kg ki kj kk kl km kn ko kr ks ku kv kw ky la lb lg li ln lo lt lu lv mg mh mi mk ml mn mo mr ms mt my na nb nd ne ng nl nn no nr nv ny oc oj om or os pa pi pl ps pt pt_BR qu rm rn ro ru rue rw sa sc sd se sg si sk sl sm sma sn so sq sr ss st su sv sw ta te tg th ti tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa wo xh yi yo za zh zh_CN zh_HK zh_TW zu) | ||
| foreach (LANGUAGE_NEEDED ${LANGUAGES_NEEDED}) | ||
| create_po_file (${LANGUAGE_NEEDED}) | ||
| endforeach (LANGUAGE_NEEDED ${LANGUAGES_NEEDED}) | ||
| # generate .mo from .po | ||
| file (GLOB PO_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.po) | ||
| foreach (PO_INPUT ${PO_FILES}) | ||
| get_filename_component (PO_INPUT_BASE ${PO_INPUT} NAME_WE) | ||
| set (MO_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PO_INPUT_BASE}.mo) | ||
| add_custom_command (TARGET i18n COMMAND ${MSGFMT_EXECUTABLE} -o ${MO_OUTPUT} ${PO_INPUT}) | ||
|
|
||
| install (FILES ${MO_OUTPUT} DESTINATION | ||
| share/locale-langpack/${PO_INPUT_BASE}/LC_MESSAGES | ||
| RENAME ${NLS_PACKAGE}.mo) | ||
| endforeach (PO_INPUT ${PO_FILES}) | ||
| endmacro (add_translations_directory) | ||
|
|
||
| # Apply the right default template. | ||
| macro (create_po_file LANGUAGE_NEEDED) | ||
| set (FILE ${CMAKE_CURRENT_SOURCE_DIR}/${LANGUAGE_NEEDED}.po) | ||
| if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LANGUAGE_NEEDED}.po) | ||
| file (APPEND ${FILE} "msgid \"\"\n") | ||
| file (APPEND ${FILE} "msgstr \"\"\n") | ||
| file (APPEND ${FILE} "\"MIME-Version: 1.0\\n\"\n") | ||
| file (APPEND ${FILE} "\"Content-Type: text/plain; charset=UTF-8\\n\"\n") | ||
|
|
||
| if ("${LANGUAGE_NEEDED}" STREQUAL "ja" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "vi" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "ko") | ||
| file (APPEND ${FILE} "\"Plural-Forms: nplurals=2; plural=n == 1 ? 0 : 1;\\n\"\n") | ||
| elseif ("${LANGUAGE_NEEDED}" STREQUAL "en" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "de" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "nl" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "sv" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "nb" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "nn" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "nb" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "no" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "fo" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "es" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "pt" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "it" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "bg" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "he" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "fi" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "et" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "eo" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "hu" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "tr" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "es") | ||
| file (APPEND ${FILE} "\"Plural-Forms: nplurals=2; plural=n != 1;\\n\"\n") | ||
| elseif ("${LANGUAGE_NEEDED}" STREQUAL "fr" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "fr_CA" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "pt_BR") | ||
| file (APPEND ${FILE} "\"Plural-Forms: nplurals=2; plural=n>1;\\n\"\n") | ||
| elseif ("${LANGUAGE_NEEDED}" STREQUAL "lv") | ||
| file (APPEND ${FILE} "\"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2;\\n\"\n") | ||
| elseif ("${LANGUAGE_NEEDED}" STREQUAL "ro") | ||
| file (APPEND ${FILE} "\"Plural-Forms: nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2;\\n\"\n") | ||
| elseif ("${LANGUAGE_NEEDED}" STREQUAL "lt") | ||
| file (APPEND ${FILE} "\"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2;\\n\"\n") | ||
| elseif ("${LANGUAGE_NEEDED}" STREQUAL "ru" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "uk" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "be" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "sr" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "hr") | ||
| file (APPEND ${FILE} "\"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\\n\"\n") | ||
| elseif ("${LANGUAGE_NEEDED}" STREQUAL "cs" | ||
| OR "${LANGUAGE_NEEDED}" STREQUAL "sk") | ||
| file (APPEND ${FILE} "\"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\\n\"\n") | ||
| elseif ("${LANGUAGE_NEEDED}" STREQUAL "pl") | ||
| file (APPEND ${FILE} "\"Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\\n\"\n") | ||
| elseif ("${LANGUAGE_NEEDED}" STREQUAL "sl") | ||
| file (APPEND ${FILE} "\"Plural-Forms: nplurals=4; plural=n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3;\\n\"\n") | ||
| endif () | ||
|
|
||
| endif () | ||
| endmacro (create_po_file) | ||
|
|
||
| macro (add_translations_catalog NLS_PACKAGE) | ||
| add_custom_target (pot COMMENT “Building translation catalog.”) | ||
| find_program (XGETTEXT_EXECUTABLE xgettext) | ||
|
|
||
| set(C_SOURCE "") | ||
| set(VALA_SOURCE "") | ||
| set(GLADE_SOURCE "") | ||
|
|
||
| foreach(FILES_INPUT ${ARGN}) | ||
| set(BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT}) | ||
|
|
||
| file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${BASE_DIRECTORY}/*.c) | ||
| foreach(C_FILE ${SOURCE_FILES}) | ||
| set(C_SOURCE ${C_SOURCE} ${C_FILE}) | ||
| endforeach() | ||
|
|
||
| file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${BASE_DIRECTORY}/*.vala) | ||
| foreach(VALA_C_FILE ${SOURCE_FILES}) | ||
| set(VALA_SOURCE ${VALA_SOURCE} ${VALA_C_FILE}) | ||
| endforeach() | ||
|
|
||
| file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${BASE_DIRECTORY}/*.ui) | ||
| foreach(GLADE_C_FILE ${SOURCE_FILES}) | ||
| set(GLADE_SOURCE ${GLADE_SOURCE} ${GLADE_C_FILE}) | ||
| endforeach() | ||
| endforeach() | ||
|
|
||
| set(BASE_XGETTEXT_COMMAND | ||
| ${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE} | ||
| -o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot | ||
| --add-comments="/" --keyword="_" --keyword="N_" --keyword="C_:1c,2" --keyword="NC_:1c,2" --keyword="ngettext:1,2" --keyword="Q_:1g" --from-code=UTF-8) | ||
|
|
||
| set(CONTINUE_FLAG "") | ||
|
|
||
| IF(NOT "${C_SOURCE}" STREQUAL "") | ||
| add_custom_command(TARGET pot WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${BASE_XGETTEXT_COMMAND} ${C_SOURCE}) | ||
| set(CONTINUE_FLAG "-j") | ||
| ENDIF() | ||
|
|
||
| IF(NOT "${VALA_SOURCE}" STREQUAL "") | ||
| add_custom_command(TARGET pot WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${BASE_XGETTEXT_COMMAND} ${CONTINUE_FLAG} -LC\# ${VALA_SOURCE}) | ||
| set(CONTINUE_FLAG "-j") | ||
| ENDIF() | ||
|
|
||
| IF(NOT "${GLADE_SOURCE}" STREQUAL "") | ||
| add_custom_command (TARGET pot WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${BASE_XGETTEXT_COMMAND} ${CONTINUE_FLAG} -LGlade ${GLADE_SOURCE}) | ||
| ENDIF() | ||
| endmacro () |
| @@ -0,0 +1,23 @@ | ||
| if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") | ||
| message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") | ||
| endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") | ||
|
|
||
| file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) | ||
| string(REGEX REPLACE "\n" ";" files "${files}") | ||
| cmake_policy (SET CMP0007 NEW) | ||
| list(REVERSE files) | ||
| foreach (file ${files}) | ||
| message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") | ||
| if (EXISTS "$ENV{DESTDIR}${file}") | ||
| execute_process( | ||
| COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}" | ||
| OUTPUT_VARIABLE rm_out | ||
| RESULT_VARIABLE rm_retval | ||
| ) | ||
| if(NOT ${rm_retval} EQUAL 0) | ||
| message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") | ||
| endif (NOT ${rm_retval} EQUAL 0) | ||
| else (EXISTS "$ENV{DESTDIR}${file}") | ||
| message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") | ||
| endif (EXISTS "$ENV{DESTDIR}${file}") | ||
| endforeach(file) |
| @@ -0,0 +1,249 @@ | ||
| ## | ||
| # Copyright 2009-2010 Jakob Westhoff. All rights reserved. | ||
| # Copyright 2012 elementary. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions are met: | ||
| # | ||
| # 1. Redistributions of source code must retain the above copyright notice, | ||
| # this list of conditions and the following disclaimer. | ||
| # | ||
| # 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| # this list of conditions and the following disclaimer in the documentation | ||
| # and/or other materials provided with the distribution. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY JAKOB WESTHOFF ``AS IS'' AND ANY EXPRESS OR | ||
| # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
| # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | ||
| # EVENT SHALL JAKOB WESTHOFF OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
| # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
| # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
| # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
| # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| # | ||
| # The views and conclusions contained in the software and documentation are those | ||
| # of the authors and should not be interpreted as representing official policies, | ||
| # either expressed or implied, of Jakob Westhoff | ||
| ## | ||
|
|
||
| include(ParseArguments) | ||
| find_package(Vala REQUIRED) | ||
|
|
||
| ## | ||
| # Compile vala files to their c equivalents for further processing. | ||
| # | ||
| # The "vala_precompile" macro takes care of calling the valac executable on the | ||
| # given source to produce c files which can then be processed further using | ||
| # default cmake functions. | ||
| # | ||
| # The first parameter provided is a variable, which will be filled with a list | ||
| # of c files outputted by the vala compiler. This list can than be used in | ||
| # conjuction with functions like "add_executable" or others to create the | ||
| # neccessary compile rules with CMake. | ||
| # | ||
| # The initial variable is followed by a list of .vala files to be compiled. | ||
| # Please take care to add every vala file belonging to the currently compiled | ||
| # project or library as Vala will otherwise not be able to resolve all | ||
| # dependencies. | ||
| # | ||
| # The following sections may be specified afterwards to provide certain options | ||
| # to the vala compiler: | ||
| # | ||
| # PACKAGES | ||
| # A list of vala packages/libraries to be used during the compile cycle. The | ||
| # package names are exactly the same, as they would be passed to the valac | ||
| # "--pkg=" option. | ||
| # | ||
| # OPTIONS | ||
| # A list of optional options to be passed to the valac executable. This can be | ||
| # used to pass "--thread" for example to enable multi-threading support. | ||
| # | ||
| # CUSTOM_VAPIS | ||
| # A list of custom vapi files to be included for compilation. This can be | ||
| # useful to include freshly created vala libraries without having to install | ||
| # them in the system. | ||
| # | ||
| # GENERATE_VAPI | ||
| # Pass all the needed flags to the compiler to create an internal vapi for | ||
| # the compiled library. The provided name will be used for this and a | ||
| # <provided_name>.vapi file will be created. | ||
| # | ||
| # GENERATE_HEADER | ||
| # Let the compiler generate a header file for the compiled code. There will | ||
| # be a header file as well as an internal header file being generated called | ||
| # <provided_name>.h and <provided_name>_internal.h | ||
| # | ||
| # GENERATE_GIR | ||
| # Have the compiler generate a GObject-Introspection repository file with | ||
| # name: <provided_name>.gir. This can be later used to create a binary typelib | ||
| # using the GI compiler. | ||
| # | ||
| # GENERATE_SYMBOLS | ||
| # Output a <provided_name>.symbols file containing all the exported symbols. | ||
| # | ||
| # The following call is a simple example to the vala_precompile macro showing | ||
| # an example to every of the optional sections: | ||
| # | ||
| # vala_precompile(VALA_C mytargetname | ||
| # source1.vala | ||
| # source2.vala | ||
| # source3.vala | ||
| # PACKAGES | ||
| # gtk+-2.0 | ||
| # gio-1.0 | ||
| # posix | ||
| # DIRECTORY | ||
| # gen | ||
| # OPTIONS | ||
| # --thread | ||
| # CUSTOM_VAPIS | ||
| # some_vapi.vapi | ||
| # GENERATE_VAPI | ||
| # myvapi | ||
| # GENERATE_HEADER | ||
| # myheader | ||
| # GENERATE_GIR | ||
| # mygir | ||
| # GENERATE_SYMBOLS | ||
| # mysymbols | ||
| # ) | ||
| # | ||
| # Most important is the variable VALA_C which will contain all the generated c | ||
| # file names after the call. | ||
| ## | ||
|
|
||
| macro(vala_precompile output target_name) | ||
| parse_arguments(ARGS "TARGET;PACKAGES;OPTIONS;DIRECTORY;GENERATE_GIR;GENERATE_SYMBOLS;GENERATE_HEADER;GENERATE_VAPI;CUSTOM_VAPIS" "" ${ARGN}) | ||
|
|
||
| if(ARGS_DIRECTORY) | ||
| set(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${ARGS_DIRECTORY}) | ||
| else(ARGS_DIRECTORY) | ||
| set(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) | ||
| endif(ARGS_DIRECTORY) | ||
| include_directories(${DIRECTORY}) | ||
| set(vala_pkg_opts "") | ||
| foreach(pkg ${ARGS_PACKAGES}) | ||
| list(APPEND vala_pkg_opts "--pkg=${pkg}") | ||
| endforeach(pkg ${ARGS_PACKAGES}) | ||
| set(in_files "") | ||
| set(out_files "") | ||
| set(out_files_display "") | ||
| set(${output} "") | ||
|
|
||
| foreach(src ${ARGS_DEFAULT_ARGS}) | ||
| string(REGEX MATCH "^/" IS_MATCHED ${src}) | ||
| if(${IS_MATCHED} MATCHES "/") | ||
| set(src_file_path ${src}) | ||
| else() | ||
| set(src_file_path ${CMAKE_CURRENT_SOURCE_DIR}/${src}) | ||
| endif() | ||
| list(APPEND in_files ${src_file_path}) | ||
| string(REPLACE ".vala" ".c" src ${src}) | ||
| string(REPLACE ".gs" ".c" src ${src}) | ||
| if(${IS_MATCHED} MATCHES "/") | ||
| get_filename_component(VALA_FILE_NAME ${src} NAME) | ||
| set(out_file "${CMAKE_CURRENT_BINARY_DIR}/${VALA_FILE_NAME}") | ||
| list(APPEND out_files "${CMAKE_CURRENT_BINARY_DIR}/${VALA_FILE_NAME}") | ||
| else() | ||
| set(out_file "${DIRECTORY}/${src}") | ||
| list(APPEND out_files "${DIRECTORY}/${src}") | ||
| endif() | ||
| list(APPEND ${output} ${out_file}) | ||
| list(APPEND out_files_display "${src}") | ||
| endforeach(src ${ARGS_DEFAULT_ARGS}) | ||
|
|
||
| set(custom_vapi_arguments "") | ||
| if(ARGS_CUSTOM_VAPIS) | ||
| foreach(vapi ${ARGS_CUSTOM_VAPIS}) | ||
| if(${vapi} MATCHES ${CMAKE_SOURCE_DIR} OR ${vapi} MATCHES ${CMAKE_BINARY_DIR}) | ||
| list(APPEND custom_vapi_arguments ${vapi}) | ||
| else (${vapi} MATCHES ${CMAKE_SOURCE_DIR} OR ${vapi} MATCHES ${CMAKE_BINARY_DIR}) | ||
| list(APPEND custom_vapi_arguments ${CMAKE_CURRENT_SOURCE_DIR}/${vapi}) | ||
| endif(${vapi} MATCHES ${CMAKE_SOURCE_DIR} OR ${vapi} MATCHES ${CMAKE_BINARY_DIR}) | ||
| endforeach(vapi ${ARGS_CUSTOM_VAPIS}) | ||
| endif(ARGS_CUSTOM_VAPIS) | ||
|
|
||
| set(vapi_arguments "") | ||
| if(ARGS_GENERATE_VAPI) | ||
| list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_VAPI}.vapi") | ||
| list(APPEND out_files_display "${ARGS_GENERATE_VAPI}.vapi") | ||
| set(vapi_arguments "--library=${ARGS_GENERATE_VAPI}" "--vapi=${ARGS_GENERATE_VAPI}.vapi") | ||
|
|
||
| # Header and internal header is needed to generate internal vapi | ||
| if (NOT ARGS_GENERATE_HEADER) | ||
| set(ARGS_GENERATE_HEADER ${ARGS_GENERATE_VAPI}) | ||
| endif(NOT ARGS_GENERATE_HEADER) | ||
| endif(ARGS_GENERATE_VAPI) | ||
|
|
||
| set(header_arguments "") | ||
| if(ARGS_GENERATE_HEADER) | ||
| list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_HEADER}.h") | ||
| list(APPEND out_files_display "${ARGS_GENERATE_HEADER}.h") | ||
| list(APPEND header_arguments "--header=${ARGS_GENERATE_HEADER}.h") | ||
| endif(ARGS_GENERATE_HEADER) | ||
|
|
||
| set(gir_arguments "") | ||
| set(gircomp_command "") | ||
| if(ARGS_GENERATE_GIR) | ||
| list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_GIR}.gir") | ||
| list(APPEND out_files_display "${ARGS_GENERATE_GIR}.gir") | ||
| set(gir_arguments "--gir=${ARGS_GENERATE_GIR}.gir") | ||
|
|
||
| include (FindGirCompiler) | ||
| find_package(GirCompiler REQUIRED) | ||
|
|
||
| set(gircomp_command | ||
| COMMAND | ||
| ${G_IR_COMPILER_EXECUTABLE} | ||
| ARGS | ||
| "${DIRECTORY}/${ARGS_GENERATE_GIR}.gir" | ||
| -o "${DIRECTORY}/${ARGS_GENERATE_GIR}.typelib") | ||
| endif(ARGS_GENERATE_GIR) | ||
|
|
||
| set(symbols_arguments "") | ||
| if(ARGS_GENERATE_SYMBOLS) | ||
| list(APPEND out_files "${DIRECTORY}/${ARGS_GENERATE_SYMBOLS}.symbols") | ||
| list(APPEND out_files_display "${ARGS_GENERATE_SYMBOLS}.symbols") | ||
| set(symbols_arguments "--symbols=${ARGS_GENERATE_SYMBOLS}.symbols") | ||
| endif(ARGS_GENERATE_SYMBOLS) | ||
|
|
||
| # Workaround for a bug that would make valac run twice. This file is written | ||
| # after the vala compiler generates C source code. | ||
| set(OUTPUT_STAMP ${CMAKE_CURRENT_BINARY_DIR}/${target_name}_valac.stamp) | ||
|
|
||
| add_custom_command( | ||
| OUTPUT | ||
| ${OUTPUT_STAMP} | ||
| COMMAND | ||
| ${VALA_EXECUTABLE} | ||
| ARGS | ||
| "-C" | ||
| ${header_arguments} | ||
| ${vapi_arguments} | ||
| ${gir_arguments} | ||
| ${symbols_arguments} | ||
| "-b" ${CMAKE_CURRENT_SOURCE_DIR} | ||
| "-d" ${DIRECTORY} | ||
| ${vala_pkg_opts} | ||
| ${ARGS_OPTIONS} | ||
| "-g" | ||
| ${in_files} | ||
| ${custom_vapi_arguments} | ||
| COMMAND | ||
| touch | ||
| ARGS | ||
| ${OUTPUT_STAMP} | ||
| DEPENDS | ||
| ${in_files} | ||
| ${ARGS_CUSTOM_VAPIS} | ||
| COMMENT | ||
| "Generating ${out_files_display}" | ||
| ${gircomp_command} | ||
| ) | ||
|
|
||
| # This command will be run twice for some reason (pass a non-empty string to COMMENT | ||
| # in order to see it). Since valac is not executed from here, this won't be a problem. | ||
| add_custom_command(OUTPUT ${out_files} DEPENDS ${OUTPUT_STAMP} COMMENT "") | ||
| endmacro(vala_precompile) |
| @@ -0,0 +1,96 @@ | ||
| ## | ||
| # Copyright 2009-2010 Jakob Westhoff. All rights reserved. | ||
| # | ||
| # Redistribution and use in source and binary forms, with or without | ||
| # modification, are permitted provided that the following conditions are met: | ||
| # | ||
| # 1. Redistributions of source code must retain the above copyright notice, | ||
| # this list of conditions and the following disclaimer. | ||
| # | ||
| # 2. Redistributions in binary form must reproduce the above copyright notice, | ||
| # this list of conditions and the following disclaimer in the documentation | ||
| # and/or other materials provided with the distribution. | ||
| # | ||
| # THIS SOFTWARE IS PROVIDED BY JAKOB WESTHOFF ``AS IS'' AND ANY EXPRESS OR | ||
| # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
| # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | ||
| # EVENT SHALL JAKOB WESTHOFF OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
| # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
| # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
| # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
| # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| # | ||
| # The views and conclusions contained in the software and documentation are those | ||
| # of the authors and should not be interpreted as representing official policies, | ||
| # either expressed or implied, of Jakob Westhoff | ||
| ## | ||
|
|
||
| include(ParseArguments) | ||
| find_package(Vala REQUIRED) | ||
|
|
||
| ## | ||
| # Ensure a certain valac version is available | ||
| # | ||
| # The initial argument is the version to check for | ||
| # | ||
| # It may be followed by a optional parameter to specifiy a version range. The | ||
| # following options are valid: | ||
| # | ||
| # EXACT | ||
| # Vala needs to be available in the exact version given | ||
| # | ||
| # MINIMUM | ||
| # The provided version is the minimum version. Therefore Vala needs to be | ||
| # available in the given version or any higher version | ||
| # | ||
| # MAXIMUM | ||
| # The provided version is the maximum. Therefore Vala needs to be available | ||
| # in the given version or any version older than this | ||
| # | ||
| # If no option is specified the version will be treated as a minimal version. | ||
| ## | ||
| macro(ensure_vala_version version) | ||
| parse_arguments(ARGS "" "MINIMUM;MAXIMUM;EXACT" ${ARGN}) | ||
| set(compare_message "") | ||
| set(error_message "") | ||
| if(ARGS_MINIMUM) | ||
| set(compare_message "a minimum ") | ||
| set(error_message "or greater ") | ||
| elseif(ARGS_MAXIMUM) | ||
| set(compare_message "a maximum ") | ||
| set(error_message "or less ") | ||
| endif(ARGS_MINIMUM) | ||
|
|
||
| message(STATUS | ||
| "checking for ${compare_message}Vala version of ${version}" | ||
| ) | ||
|
|
||
| unset(version_accepted) | ||
|
|
||
| # MINIMUM is the default if no option is specified | ||
| if(ARGS_EXACT) | ||
| if(${VALA_VERSION} VERSION_EQUAL ${version} ) | ||
| set(version_accepted TRUE) | ||
| endif(${VALA_VERSION} VERSION_EQUAL ${version}) | ||
| elseif(ARGS_MAXIMUM) | ||
| if(${VALA_VERSION} VERSION_LESS ${version} OR ${VALA_VERSION} VERSION_EQUAL ${version}) | ||
| set(version_accepted TRUE) | ||
| endif(${VALA_VERSION} VERSION_LESS ${version} OR ${VALA_VERSION} VERSION_EQUAL ${version}) | ||
| else(ARGS_MAXIMUM) | ||
| if(${VALA_VERSION} VERSION_GREATER ${version} OR ${VALA_VERSION} VERSION_EQUAL ${version}) | ||
| set(version_accepted TRUE) | ||
| endif(${VALA_VERSION} VERSION_GREATER ${version} OR ${VALA_VERSION} VERSION_EQUAL ${version}) | ||
| endif(ARGS_EXACT) | ||
|
|
||
| if (NOT version_accepted) | ||
| message(FATAL_ERROR | ||
| "Vala version ${version} ${error_message}is required." | ||
| ) | ||
| endif(NOT version_accepted) | ||
|
|
||
| message(STATUS | ||
| " found Vala, version ${VALA_VERSION}" | ||
| ) | ||
| endmacro(ensure_vala_version) |
| @@ -0,0 +1,12 @@ | ||
| install (FILES com.github.bartzaalberg.repositories.desktop DESTINATION share/applications) | ||
| install (FILES com.github.bartzaalberg.repositories.appdata.xml DESTINATION share/metainfo/) | ||
|
|
||
| install (FILES icons/16/com.github.bartzaalberg.repositories.svg DESTINATION share/icons/hicolor/16x16/apps) | ||
| install (FILES icons/24/com.github.bartzaalberg.repositories.svg DESTINATION share/icons/hicolor/24x24/apps) | ||
| install (FILES icons/32/com.github.bartzaalberg.repositories.svg DESTINATION share/icons/hicolor/32x32/apps) | ||
| install (FILES icons/48/com.github.bartzaalberg.repositories.svg DESTINATION share/icons/hicolor/48x48/apps) | ||
| install (FILES icons/32/com.github.bartzaalberg.repositories.svg DESTINATION share/icons/hicolor/32x32/apps) | ||
| install (FILES icons/64/com.github.bartzaalberg.repositories.svg DESTINATION share/icons/hicolor/64x64/apps) | ||
| install (FILES icons/128/com.github.bartzaalberg.repositories.svg DESTINATION share/icons/hicolor/128x128/apps) | ||
|
|
||
| install (FILES icons/64/com.github.bartzaalberg.repositories.svg DESTINATION share/icons/hicolor/scalable/apps) |
| @@ -0,0 +1,29 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <component type="desktop"> | ||
| <id>com.github.bartzaalberg.repositories.desktop</id> | ||
| <metadata_license>CC0</metadata_license> | ||
| <project_license>GPL-3.0+</project_license> | ||
| <name>Repositories</name> | ||
| <summary>Manage your repositories</summary> | ||
| <description> | ||
| <p>A simple tool to manage your repositories.</p> | ||
| <p>Features:</p> | ||
| <ul> | ||
| <li>Easily search through your all your repositories</li> | ||
| <li>Add, remove, and update repositories</li> | ||
| </ul> | ||
| </description> | ||
| <screenshots> | ||
| <screenshot type="default"> | ||
| <image>https://raw.githubusercontent.com/bartzaalberg/repositories-manager/master/screenshot.png</image> | ||
| </screenshot> | ||
| </screenshots> | ||
| <developer_name>Bart Zaalberg</developer_name> | ||
| <custom> | ||
| <value key="x-appcenter-color-primary">rgb(224,247,255)</value> | ||
| <value key="x-appcenter-color-primary-text">#000</value> | ||
| </custom> | ||
| <url type="homepage">https://github.com/bartzaalberg/repositories</url> | ||
| <url type="bugtracker">https://github.com/bartzaalberg/repositories/issues</url> | ||
| <url type="help">https://github.com/bartzaalberg/repositories/issues</url> | ||
| </component> |
| @@ -0,0 +1,32 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- Copyright 2017 Your Name <you@email.com> --> | ||
| <component type="desktop"> | ||
| <id>com.github.bartzaalberg.bookmark-manager.desktop</id> | ||
| <metadata_license>CC0</metadata_license> | ||
| <project_license>GPL-3.0+</project_license> | ||
| <name>Bookmark Manager</name> | ||
| <summary>Manage the .ssh/config file bookmarks</summary> | ||
| <description> | ||
| <p>A simple tool to manage the .ssh/config file bookmarks.</p> | ||
| <p>Features:</p> | ||
| <ul> | ||
| <li>Easily search through your SSH bookmarks</li> | ||
| <li>Simply start a session by clicking on a button</li> | ||
| <li>Add a default parameters for when the config file doesn't contain a variable</li> | ||
| <li>Add, remove, and update bookmarks</li> | ||
| </ul> | ||
| </description> | ||
| <screenshots> | ||
| <screenshot type="default"> | ||
| <image>https://raw.githubusercontent.com/bartzaalberg/Bookmark-Manager/master/screenshot.png</image> | ||
| </screenshot> | ||
| </screenshots> | ||
| <developer_name>Bart Zaalberg</developer_name> | ||
| <custom> | ||
| <value key="x-appcenter-color-primary">rgb(224,247,255)</value> | ||
| <value key="x-appcenter-color-primary-text">#000</value> | ||
| </custom> | ||
| <url type="homepage">https://github.com/bartzaalberg/bookmark-manager</url> | ||
| <url type="bugtracker">https://github.com/bartzaalberg/bookmark-manager/issues</url> | ||
| <url type="help">https://github.com/bartzaalberg/bookmark-manager/issues</url> | ||
| </component> |
| @@ -0,0 +1,11 @@ | ||
| [Desktop Entry] | ||
| Name=Repositories | ||
| GenericName=Bookmark Manager App | ||
| Comment=Application to manage repositories | ||
| Categories=Utility;Network;System; | ||
| Exec=com.github.bartzaalberg.repositories | ||
| Icon=com.github.bartzaalberg.repositories | ||
| Terminal=false | ||
| Type=Application | ||
| X-GNOME-Gettext-Domain=repositories | ||
| Keywords=GUI;Repositories;Manager; |
| @@ -0,0 +1,11 @@ | ||
| [Desktop Entry] | ||
| Name=Bookmark Manager | ||
| GenericName=Bookmark Manager App | ||
| Comment=Application to manage the .ssh/config file | ||
| Categories=Utility;Network;Development; | ||
| Exec=com.github.bartzaalberg.bookmark-manager | ||
| Icon=com.github.bartzaalberg.bookmark-manager | ||
| Terminal=false | ||
| Type=Application | ||
| X-GNOME-Gettext-Domain=bookmark-manager | ||
| Keywords=GUI;SSH;Bookmarks; |
| @@ -0,0 +1,30 @@ | ||
| <schemalist> | ||
| <schema id="com.github.bartzaalberg.repositories" path="/org/example/my-app/" gettext-domain="my-app"> | ||
|
|
||
| <key name="sshname" type="s"> | ||
| <default l10n="messages">""</default> | ||
| <summary>The ssh name</summary> | ||
| <description> | ||
| This is the name used for ssh | ||
| </description> | ||
| </key> | ||
|
|
||
| <key name="bottles-of-beer" type="i"> | ||
| <default>99</default> | ||
| <summary>Bottles of beer</summary> | ||
| <description> | ||
| Number of bottles of beer on the wall | ||
| </description> | ||
| </key> | ||
|
|
||
| <key name="lighting" type="b"> | ||
| <default>false</default> | ||
| <summary>Is the light switched on?</summary> | ||
| <description> | ||
| State of an imaginary light switch. | ||
| </description> | ||
| </key> | ||
|
|
||
| </schema> | ||
| </schemalist> | ||
|
|
| @@ -0,0 +1,30 @@ | ||
| <schemalist> | ||
| <schema id="com.github.bartzaalberg.bookmark-manager" path="/org/example/my-app/" gettext-domain="my-app"> | ||
|
|
||
| <key name="sshname" type="s"> | ||
| <default l10n="messages">""</default> | ||
| <summary>The ssh name</summary> | ||
| <description> | ||
| This is the name used for ssh | ||
| </description> | ||
| </key> | ||
|
|
||
| <key name="bottles-of-beer" type="i"> | ||
| <default>99</default> | ||
| <summary>Bottles of beer</summary> | ||
| <description> | ||
| Number of bottles of beer on the wall | ||
| </description> | ||
| </key> | ||
|
|
||
| <key name="lighting" type="b"> | ||
| <default>false</default> | ||
| <summary>Is the light switched on?</summary> | ||
| <description> | ||
| State of an imaginary light switch. | ||
| </description> | ||
| </key> | ||
|
|
||
| </schema> | ||
| </schemalist> | ||
|
|
| @@ -0,0 +1,95 @@ | ||
| com.github.bartzaalberg.bookmark-manager (1.2.1) UNSTABLE; urgency=low | ||
|
|
||
| * Fixed a bug where proxyCommand would show up without spaces | ||
| * Changed text for when a form is invalid | ||
|
|
||
| -- Bart Zaalberg <bartzaalberg@gmail.com> Sun, 17 Sep 2017 13:39:00 +0200 | ||
|
|
||
| com.github.bartzaalberg.bookmark-manager (1.2.0) UNSTABLE; urgency=low | ||
|
|
||
| * Added edit mode | ||
| * Updated screenshot again | ||
| * config is now loaded straight from the file, so that support is much larger | ||
| * Added AgentForward and ProxyCommand support | ||
|
|
||
| -- Bart Zaalberg <bartzaalberg@gmail.com> Sun, 16 Sep 2017 21:50:00 +0200 | ||
|
|
||
| com.github.bartzaalberg.bookmark-manager (1.1.9) UNSTABLE; urgency=low | ||
|
|
||
| * Updated screenshot | ||
|
|
||
| -- Bart Zaalberg <bartzaalberg@gmail.com> Sun, 16 Sep 2017 18:47:00 +0200 | ||
|
|
||
| com.github.bartzaalberg.bookmark-manager (1.1.8) UNSTABLE; urgency=low | ||
|
|
||
| * Added a fix for the not released granite.messageDialog windows i used | ||
| * Added more entry fields to the AddBookmark form | ||
|
|
||
| -- Bart Zaalberg <bartzaalberg@gmail.com> Sun, 16 Sep 2017 18:26:00 +0200 | ||
|
|
||
| com.github.bartzaalberg.bookmark-manager (1.1.7) UNSTABLE; urgency=low | ||
|
|
||
| * Added Delete option, | ||
| * Added Add option | ||
| * Refactored alot of code | ||
| * Added new icon | ||
| * Added no bookmark found screen when searching wont find anything | ||
|
|
||
| -- Bart Zaalberg <bartzaalberg@gmail.com> Fri, 15 Sep 2017 10:06:00 +0200 | ||
|
|
||
| com.github.bartzaalberg.bookmark-manager (1.1.6) UNSTABLE; urgency=low | ||
|
|
||
| * Fixed a bug where the last bookmark wasn't shown | ||
| * Made preferences more logical.(added save button, tooltip, better naming) | ||
| * Added a workaround for a bug where some hosts wouldn't show up | ||
|
|
||
| -- Bart Zaalberg <bartzaalberg@gmail.com> Tue, 12 Sep 2017 09:44:55 +0200 | ||
|
|
||
| com.github.bartzaalberg.bookmark-manager (1.1.5) UNSTABLE; urgency=low | ||
|
|
||
| * Changed the description and my name | ||
|
|
||
| -- Bart Zaalberg <bartzaalberg@gmail.com> Sun, 10 Sep 2017 21:01:23 +0200 | ||
|
|
||
| com.github.bartzaalberg.bookmark-manager (1.1.4) UNSTABLE; urgency=low | ||
|
|
||
| * Updated screenshot because the last contained a white background | ||
|
|
||
| -- Bart Zaalberg <bartzaalberg@gmail.com> Sun, 10 Sep 2017 03:39:05 +0200 | ||
|
|
||
| com.github.bartzaalberg.bookmark-manager (1.1.3) UNSTABLE; urgency=low | ||
|
|
||
| * Made sure there is always a ~/.ssh directory and config file | ||
| * Added a nice empty file message when the file is empty | ||
|
|
||
| -- Bart Zaalberg <bartzaalberg@gmail.com> Mon, 06 Sep 2017 11:34:05 +0200 | ||
|
|
||
| com.github.bartzaalberg.bookmark-manager (1.1.2) UNSTABLE; urgency=low | ||
|
|
||
| * Fixed scheme loading | ||
|
|
||
| -- Bart Zaalberg <bartzaalberg@gmail.com> Mon, 05 Sep 2017 09:15:05 +0200 | ||
|
|
||
| com.github.bartzaalberg.bookmark-manager (1.1.1) UNSTABLE; urgency=low | ||
|
|
||
| * Added debhelper dependency | ||
|
|
||
| -- Bart Zaalberg <bartzaalberg@gmail.com> Mon, 04 Sep 2017 16:57:02 +0200 | ||
|
|
||
| com.github.bartzaalberg.bookmark-manager (1.1.0) UNSTABLE; urgency=low | ||
|
|
||
| * Added support for use of ssh username and port number | ||
|
|
||
| -- Bart Zaalberg <bartzaalberg@gmail.com> Mon, 04 Sep 2017 09:08:01 +0200 | ||
|
|
||
| com.github.bartzaalberg.bookmark-manager (1.0.1) UNSTABLE; urgency=low | ||
|
|
||
| * Lowered minimal cmake version | ||
|
|
||
| -- Bart Zaalberg <bartzaalberg@gmail.com> Fri, 25 Aug 2017 11:49:08 +0200 | ||
|
|
||
| com.github.bartzaalberg.bookmark-manager (1.0.0) UNSTABLE; urgency=low | ||
|
|
||
| * First release | ||
|
|
||
| -- Bart Zaalberg <bartzaalberg@gmail.com> Fri, 25 Aug 2017 11:27:08 +0200 |
| @@ -0,0 +1 @@ | ||
| 9 |
| @@ -0,0 +1,16 @@ | ||
| Source: com.github.bartzaalberg.bookmark-manager | ||
| Section: utils | ||
| Priority: optional | ||
| Maintainer: Bart Zaalberg <bartzaalberg@gmail.com> | ||
| Build-Depends: cmake (>= 2.6), | ||
| debhelper (>= 9), | ||
| libgranite-dev, | ||
| libgtk-3-dev, | ||
| valac (>= 0.26) | ||
|
|
||
| Package: com.github.bartzaalberg.bookmark-manager | ||
| Architecture: any | ||
| Depends: ${misc:Depends}, ${shlibs:Depends} | ||
| Pre-Depends: dpkg (>= 1.15.6) | ||
| Description: Bookmark Manager | ||
| Simpler Terminal Bookmarks |
| @@ -0,0 +1,32 @@ | ||
| Upstream Author(s): | ||
|
|
||
| Bart Zaalberg <bartzaalberg@gmail.com> | ||
|
|
||
|
|
||
| Copyright: | ||
|
|
||
| Copyright (C) 2017 Bart Zaalberg | ||
|
|
||
| License: | ||
|
|
||
| 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 package 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, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| On Debian systems, the complete text of the GNU General | ||
| Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". | ||
|
|
||
| The Debian packaging is: | ||
|
|
||
| Copyright (C) 2014 Cody Garver <codygarver@gmail.com> | ||
|
|
||
| and is licensed under the GPL version 3, see above. |
| @@ -0,0 +1,24 @@ | ||
| #!/usr/bin/make -f | ||
| # -*- makefile -*- | ||
| # Sample debian/rules that uses debhelper. | ||
| # This file was originally written by Joey Hess and Craig Small. | ||
| # As a special exception, when this file is copied by dh-make into a | ||
| # dh-make output file, you may use that output file without restriction. | ||
| # This special exception was added by Craig Small in version 0.37 of dh-make. | ||
|
|
||
| # Uncomment this to turn on verbose mode. | ||
| #export DH_VERBOSE=1 | ||
|
|
||
| # Enable additional explot mitigation | ||
| # (PIE and *full* RELRO at the time of this writing) | ||
| #export DEB_BUILD_MAINT_OPTIONS=hardening=+all | ||
|
|
||
| %: | ||
| dh $@ | ||
|
|
||
| override_dh_builddeb: | ||
| dh_builddeb -- -Zxz | ||
|
|
||
|
|
||
| override_dh_install: | ||
| dh_install --fail-missing |
| @@ -0,0 +1 @@ | ||
| 3.0 (native) |
| @@ -0,0 +1,35 @@ | ||
| using Granite.Widgets; | ||
|
|
||
| namespace BookmarkManager { | ||
| public class App:Granite.Application{ | ||
|
|
||
| construct { | ||
| application_id = Constants.APPLICATION_ID; | ||
| program_name = Constants.APP_NAME; | ||
| app_years = "2017-2018"; | ||
| exec_name = Constants.EXEC_NAME; | ||
| app_launcher = Constants.DESKTOP_NAME; | ||
|
|
||
| build_version = Constants.VERSION; | ||
| app_icon = "com.github.bartzaalberg.repositories"; | ||
| main_url = "https://github.com/bartzaalberg/repositories"; | ||
| bug_url = "https://github.com/bartzaalberg/repositories/issues"; | ||
| } | ||
|
|
||
| public override void activate() { | ||
| var window = new MainWindow (); | ||
| window.show_all(); | ||
| } | ||
|
|
||
| public static int main(string[] args) { | ||
|
|
||
| new App().run(args); | ||
|
|
||
| Gtk.main(); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| } | ||
| } | ||
|
|
| @@ -0,0 +1,61 @@ | ||
| using Granite.Widgets; | ||
|
|
||
| namespace BookmarkManager { | ||
| public class Bookmark : Object { | ||
|
|
||
| private string name; | ||
| private string ip; | ||
| private string user; | ||
| private int port; | ||
| private string forwardAgent; | ||
| private string proxyCommand; | ||
|
|
||
| public string getName(){ | ||
| return this.name; | ||
| } | ||
|
|
||
| public void setName(string name){ | ||
| this.name = name; | ||
| } | ||
|
|
||
| public string getIp(){ | ||
| return this.ip; | ||
| } | ||
|
|
||
| public void setIp(string ip){ | ||
| this.ip = ip; | ||
| } | ||
|
|
||
| public string getUser(){ | ||
| return this.user; | ||
| } | ||
|
|
||
| public void setUser(string user){ | ||
| this.user = user; | ||
| } | ||
|
|
||
| public int getPort(){ | ||
| return this.port; | ||
| } | ||
|
|
||
| public void setPort(int port){ | ||
| this.port = port; | ||
| } | ||
|
|
||
| public string getForwardAgent(){ | ||
| return this.forwardAgent; | ||
| } | ||
|
|
||
| public void setForwardAgent(string forwardAgent){ | ||
| this.forwardAgent = forwardAgent; | ||
| } | ||
|
|
||
| public string getProxyCommand(){ | ||
| return this.proxyCommand; | ||
| } | ||
|
|
||
| public void setProxyCommand(string proxyCommand){ | ||
| this.proxyCommand = proxyCommand; | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,25 @@ | ||
| namespace BookmarkManager { | ||
| public class BookmarkListManager : Object { | ||
|
|
||
| static BookmarkListManager? instance; | ||
|
|
||
| private ListBox listBox; | ||
|
|
||
| // Private constructor | ||
| BookmarkListManager() { | ||
| listBox = new ListBox (); | ||
| } | ||
|
|
||
| // Public constructor | ||
| public static BookmarkListManager get_instance() { | ||
| if (instance == null) { | ||
| instance = new BookmarkListManager(); | ||
| } | ||
| return instance; | ||
| } | ||
|
|
||
| public ListBox getList() { | ||
| return this.listBox; | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,38 @@ | ||
| using Granite.Widgets; | ||
|
|
||
| namespace BookmarkManager { | ||
| public class HeaderBar : Gtk.HeaderBar { | ||
|
|
||
| StackManager stackManager = StackManager.get_instance(); | ||
| BookmarkListManager bookmarkListManager = BookmarkListManager.get_instance(); | ||
|
|
||
| public HeaderBar(){ | ||
|
|
||
| var searchEntry = new Gtk.SearchEntry (); | ||
| searchEntry.set_placeholder_text("Search repositories"); | ||
| searchEntry.set_tooltip_text("Search for repositories"); | ||
| searchEntry.search_changed.connect (() => { | ||
| bookmarkListManager.getList().getRepositories(searchEntry.text); | ||
| }); | ||
|
|
||
| var settings_button = new Gtk.Button.from_icon_name ("document-properties", Gtk.IconSize.LARGE_TOOLBAR); | ||
| settings_button.set_tooltip_text("Change your preferences"); | ||
| settings_button.clicked.connect (() => { | ||
| new Preferences (); | ||
| }); | ||
|
|
||
| //var add_button = new Gtk.Button.from_icon_name ("document-new", Gtk.IconSize.LARGE_TOOLBAR); | ||
| //add_button.set_tooltip_text("Create a new bookmark"); | ||
| //add_button.clicked.connect (() => { | ||
| // stackManager.getStack().visible_child_name = "add-bookmark-view"; | ||
| //}); | ||
|
|
||
| Granite.Widgets.Utils.set_color_primary (this, Constants.BRAND_COLOR); | ||
|
|
||
| this.show_close_button = true; | ||
| //this.pack_start (add_button); | ||
| this.pack_start (searchEntry); | ||
| this.pack_end (settings_button); | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,10 @@ | ||
| namespace BookmarkManager { | ||
| public class HeaderLabel : Gtk.Label { | ||
|
|
||
| public HeaderLabel (string text) { | ||
| label = text; | ||
| get_style_context ().add_class ("h4"); | ||
| halign = Gtk.Align.START; | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,129 @@ | ||
| using Granite.Widgets; | ||
|
|
||
| namespace BookmarkManager { | ||
| public class ConfigFileReader : Gtk.ListBox{ | ||
|
|
||
| public string[] getRepositories (){ | ||
| string[] repositories = new string[0]; | ||
|
|
||
| var general = getRepositoryFile("sources.list"); | ||
|
|
||
| File[] files = {}; | ||
|
|
||
| var d = Dir.open("/etc/apt/sources.list.d"); | ||
|
|
||
| files += getRepositoryFile("sources.list"); | ||
|
|
||
| while ((name = d.read_name()) != null) { | ||
| files += getRepositoryFile("sources.list.d/" + name); | ||
| } | ||
|
|
||
| foreach (File file in files) { | ||
| try { | ||
| // Open file for reading and wrap returned FileInputStream into a | ||
| // DataInputStream, so we can read line by line | ||
| var lines = new DataInputStream (file.read ()); | ||
| string line; | ||
|
|
||
| // Read lines until end of file (null) is reached | ||
| while ((line = lines.read_line (null)) != null) { | ||
|
|
||
| if(line == ""){ | ||
| continue; | ||
| } | ||
|
|
||
| if(!("deb" in line)){ | ||
| continue; | ||
| } | ||
|
|
||
| repositories += line; | ||
| } | ||
| } catch (Error e) { | ||
| error ("%s", e.message); | ||
| } | ||
| } | ||
|
|
||
| return repositories; | ||
| } | ||
|
|
||
| private File getRepositoryFile(string fileName){ | ||
|
|
||
| var sourcesFolder = File.new_for_path ("/etc/apt"); | ||
| if (!sourcesFolder.query_exists ()) { | ||
| try { | ||
| sourcesFolder.make_directory (); | ||
| } catch (Error e) { | ||
| error ("%s", e.message); | ||
| } | ||
| } | ||
|
|
||
| var file = File.new_for_path ("/etc/apt/" + fileName); | ||
| if (!file.query_exists ()) { | ||
| try { | ||
| file.create (FileCreateFlags.REPLACE_DESTINATION, null); | ||
| getRepositoryFile(fileName); | ||
| } catch (Error e) { | ||
| error ("%s", e.message); | ||
| } | ||
| } | ||
| return file; | ||
| } | ||
|
|
||
| public void writeToFile(string[] repositories){ | ||
| var file = getRepositoryFile("sources.list"); | ||
|
|
||
| try { | ||
| if(file.query_exists() == true){ | ||
| var repositoriesRaw = convertOtherSettingsToString(repositories); | ||
|
|
||
| file.delete(null); | ||
| FileOutputStream fos = file.create (FileCreateFlags.REPLACE_DESTINATION, null); | ||
| DataOutputStream dos = new DataOutputStream (fos); | ||
|
|
||
| dos.put_string (repositoriesRaw, null); | ||
| } | ||
| } catch (Error e) { | ||
| stderr.printf ("Error: %s\n", e.message); | ||
| } | ||
| } | ||
|
|
||
| private string convertOtherSettingsToString(string[] settings){ | ||
| string rawSettingsString = ""; | ||
|
|
||
| foreach (string setting in settings) { | ||
| string rawSetting = setting + "\n"; | ||
| rawSettingsString += rawSetting; | ||
| } | ||
|
|
||
| rawSettingsString += "\n"; | ||
| return rawSettingsString; | ||
| } | ||
|
|
||
| private string convertBookmarktoString(Bookmark bookmark){ | ||
| string rawBookmark = "Host " + bookmark.getName(); | ||
|
|
||
| if(bookmark.getIp() != null){ | ||
| rawBookmark = rawBookmark + "\n HostName " + bookmark.getIp().to_string(); | ||
| } | ||
|
|
||
| if(bookmark.getPort() != 0){ | ||
| rawBookmark = rawBookmark + "\n Port " + bookmark.getPort().to_string(); | ||
| } | ||
|
|
||
| if(bookmark.getUser() != null){ | ||
| rawBookmark = rawBookmark + "\n User " + bookmark.getUser(); | ||
| } | ||
|
|
||
| if(bookmark.getForwardAgent() != null){ | ||
| rawBookmark = rawBookmark + "\n ForwardAgent " + bookmark.getForwardAgent(); | ||
| } | ||
|
|
||
| if(bookmark.getProxyCommand() != null){ | ||
| rawBookmark = rawBookmark + "\n ProxyCommand " + bookmark.getProxyCommand(); | ||
| } | ||
|
|
||
| rawBookmark = rawBookmark + "\n\n"; | ||
| return rawBookmark; | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,114 @@ | ||
| using Granite.Widgets; | ||
|
|
||
| namespace BookmarkManager { | ||
| public class ConfigFileReader : Gtk.ListBox{ | ||
|
|
||
| public string[] getRepositories (){ | ||
| string[] settings = new string[0]; | ||
|
|
||
| var file = getRepositoryFile(); | ||
|
|
||
| try { | ||
| // Open file for reading and wrap returned FileInputStream into a | ||
| // DataInputStream, so we can read line by line | ||
| var lines = new DataInputStream (file.read ()); | ||
| string line; | ||
|
|
||
| // Read lines until end of file (null) is reached | ||
| while ((line = lines.read_line (null)) != null) { | ||
|
|
||
| if(line == ""){ | ||
| continue; | ||
| } | ||
|
|
||
| settings += line; | ||
| } | ||
|
|
||
| return settings; | ||
|
|
||
| } catch (Error e) { | ||
| error ("%s", e.message); | ||
| } | ||
| } | ||
|
|
||
| private File getRepositoryFile(){ | ||
|
|
||
| var sourcesFolder = File.new_for_path ("/etc/apt"); | ||
| if (!sourcesFolder.query_exists ()) { | ||
| try { | ||
| sourcesFolder.make_directory (); | ||
| } catch (Error e) { | ||
| error ("%s", e.message); | ||
| } | ||
| } | ||
|
|
||
| var file = File.new_for_path ("/etc/apt/sources.list"); | ||
| if (!file.query_exists ()) { | ||
| try { | ||
| file.create (FileCreateFlags.REPLACE_DESTINATION, null); | ||
| getRepositoryFile(); | ||
| } catch (Error e) { | ||
| error ("%s", e.message); | ||
| } | ||
| } | ||
| return file; | ||
| } | ||
|
|
||
| public void writeToFile(string[] repositories){ | ||
| var file = getRepositoryFile(); | ||
|
|
||
| try { | ||
| if(file.query_exists() == true){ | ||
| var repositoriesRaw = convertOtherSettingsToString(repositories); | ||
|
|
||
| file.delete(null); | ||
| FileOutputStream fos = file.create (FileCreateFlags.REPLACE_DESTINATION, null); | ||
| DataOutputStream dos = new DataOutputStream (fos); | ||
|
|
||
| dos.put_string (repositoriesRaw, null); | ||
| } | ||
| } catch (Error e) { | ||
| stderr.printf ("Error: %s\n", e.message); | ||
| } | ||
| } | ||
|
|
||
| private string convertOtherSettingsToString(string[] settings){ | ||
| string rawSettingsString = ""; | ||
|
|
||
| foreach (string setting in settings) { | ||
| string rawSetting = setting + "\n"; | ||
| rawSettingsString += rawSetting; | ||
| } | ||
|
|
||
| rawSettingsString += "\n"; | ||
| return rawSettingsString; | ||
| } | ||
|
|
||
| private string convertBookmarktoString(Bookmark bookmark){ | ||
| string rawBookmark = "Host " + bookmark.getName(); | ||
|
|
||
| if(bookmark.getIp() != null){ | ||
| rawBookmark = rawBookmark + "\n HostName " + bookmark.getIp().to_string(); | ||
| } | ||
|
|
||
| if(bookmark.getPort() != 0){ | ||
| rawBookmark = rawBookmark + "\n Port " + bookmark.getPort().to_string(); | ||
| } | ||
|
|
||
| if(bookmark.getUser() != null){ | ||
| rawBookmark = rawBookmark + "\n User " + bookmark.getUser(); | ||
| } | ||
|
|
||
| if(bookmark.getForwardAgent() != null){ | ||
| rawBookmark = rawBookmark + "\n ForwardAgent " + bookmark.getForwardAgent(); | ||
| } | ||
|
|
||
| if(bookmark.getProxyCommand() != null){ | ||
| rawBookmark = rawBookmark + "\n ProxyCommand " + bookmark.getProxyCommand(); | ||
| } | ||
|
|
||
| rawBookmark = rawBookmark + "\n\n"; | ||
| return rawBookmark; | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,10 @@ | ||
| namespace BookmarkManager.Constants { | ||
| public const string APP_NAME = "Repositories"; | ||
| public const string EXEC_NAME = "repositories"; | ||
| public const Gdk.RGBA BRAND_COLOR = { 0, 0.6, 1.1, 1 }; | ||
|
|
||
| public const string DESKTOP_NAME = "com.github.bartzaalberg.repositories.desktop"; | ||
| public const string APPLICATION_ID = "com.github.bartzaalberg.repositories.desktop"; | ||
| public const string VERSION = "0.0.1"; | ||
| public const string VERSION_INFO = "Unstable"; | ||
| } |
| @@ -0,0 +1,52 @@ | ||
| namespace BookmarkManager { | ||
| public class Alert : Gtk.Dialog { | ||
|
|
||
| public Alert(string title, string description){ | ||
| var image = new Gtk.Image.from_icon_name ("dialog-warning", Gtk.IconSize.DIALOG); | ||
| image.valign = Gtk.Align.START; | ||
|
|
||
| var primary_label = new Gtk.Label (title); | ||
| primary_label.selectable = true; | ||
| primary_label.max_width_chars = 50; | ||
| primary_label.wrap = true; | ||
| primary_label.xalign = 0; | ||
|
|
||
| var secondary_label = new Gtk.Label (description); | ||
| secondary_label.use_markup = true; | ||
| secondary_label.selectable = true; | ||
| secondary_label.max_width_chars = 50; | ||
| secondary_label.wrap = true; | ||
| secondary_label.xalign = 0; | ||
|
|
||
| var message_grid = new Gtk.Grid (); | ||
| message_grid.column_spacing = 12; | ||
| message_grid.row_spacing = 6; | ||
| message_grid.margin_left = message_grid.margin_right = 12; | ||
| message_grid.attach (image, 0, 0, 1, 2); | ||
| message_grid.attach (primary_label, 1, 0, 1, 1); | ||
| message_grid.attach (secondary_label, 1, 1, 1, 1); | ||
| message_grid.show_all (); | ||
|
|
||
| get_content_area ().add (message_grid); | ||
|
|
||
| resizable = false; | ||
| deletable = false; | ||
| skip_taskbar_hint = true; | ||
| transient_for = null; | ||
|
|
||
| var close_button = new Gtk.Button.with_label ("Close"); | ||
| close_button.clicked.connect (() => { | ||
| this.destroy (); | ||
| }); | ||
|
|
||
| var button_box = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL); | ||
| button_box.set_layout (Gtk.ButtonBoxStyle.END); | ||
| button_box.pack_start (close_button); | ||
| button_box.margin = 12; | ||
| button_box.margin_bottom = 0; | ||
|
|
||
| get_content_area ().add (button_box); | ||
| this.show_all (); | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,21 @@ | ||
| namespace BookmarkManager { | ||
| public class DeleteConfirm : Gtk.Dialog { | ||
|
|
||
| private BookmarkListManager bookmarkListManager = BookmarkListManager.get_instance(); | ||
| private StackManager stackManager = StackManager.get_instance(); | ||
|
|
||
| // public DeleteConfirm(Bookmark deletedBookmark){ | ||
| // var message_dialog = new Granite.MessageDialog.with_image_from_icon_name ("Delete this bookmark?", "Are you sure you want to delete this bookmark?", "edit-delete", Gtk.ButtonsType.CANCEL); | ||
| // | ||
| // var suggested_button = new Gtk.Button.with_label ("Delete"); | ||
| // suggested_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION); | ||
| // message_dialog.add_action_widget (suggested_button, Gtk.ResponseType.ACCEPT); | ||
| // | ||
| // message_dialog.show_all (); | ||
| // if (message_dialog.run () == Gtk.ResponseType.ACCEPT) { | ||
| // deleteBookmark(deletedBookmark); | ||
| // } | ||
| // message_dialog.destroy (); | ||
| // } | ||
| } | ||
| } |
| @@ -0,0 +1,70 @@ | ||
| namespace BookmarkManager { | ||
| public class Preferences : Gtk.Dialog { | ||
|
|
||
| private Settings settings = new Settings ("com.github.bartzaalberg.bookmark-manager"); | ||
| BookmarkListManager bookmarkListManager = BookmarkListManager.get_instance(); | ||
|
|
||
| public Preferences(){ | ||
| title = "Preferences"; | ||
| set_default_size (630, 430); | ||
| resizable = false; | ||
| deletable = false; | ||
|
|
||
| var general_header = new HeaderLabel ("Preferences"); | ||
|
|
||
| var usernameLabel = new Gtk.Label ("Default Username:"); | ||
| var usernameEntry = new Gtk.Entry (); | ||
| usernameEntry.set_text (settings.get_string ("sshname")); | ||
| usernameEntry.set_tooltip_text ("This variable will be used when no variable is given in the ssh config"); | ||
|
|
||
| var close_button = new Gtk.Button.with_label ("Close"); | ||
| close_button.clicked.connect (() => { | ||
| this.destroy (); | ||
| }); | ||
|
|
||
| var save_button = new Gtk.Button.with_label ("Save"); | ||
| save_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); | ||
| save_button.clicked.connect (() => { | ||
|
|
||
| if(isNotValid(usernameEntry.text)){ | ||
| new Alert("Fields are invalid", "Please correctly fill in all the fields"); | ||
| return; | ||
| } | ||
|
|
||
| settings.set_string("sshname", usernameEntry.text); | ||
| bookmarkListManager.getList().getRepositories(""); | ||
| this.destroy (); | ||
| }); | ||
|
|
||
| var button_box = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL); | ||
| button_box.set_layout (Gtk.ButtonBoxStyle.END); | ||
| button_box.pack_start (close_button); | ||
| button_box.pack_end (save_button); | ||
| button_box.margin = 12; | ||
| button_box.margin_bottom = 0; | ||
|
|
||
| var general_grid = new Gtk.Grid (); | ||
| general_grid.row_spacing = 6; | ||
| general_grid.column_spacing = 12; | ||
| general_grid.margin = 12; | ||
| general_grid.attach (general_header, 0, 0, 2, 1); | ||
|
|
||
| general_grid.attach (usernameLabel, 0, 1, 1, 1); | ||
| general_grid.attach (usernameEntry, 1, 1, 1, 1); | ||
|
|
||
| var main_grid = new Gtk.Grid (); | ||
| main_grid.attach (general_grid, 0, 0, 1, 1); | ||
| main_grid.attach (button_box, 0, 1, 1, 1); | ||
|
|
||
| ((Gtk.Container) get_content_area ()).add (main_grid); | ||
| this.show_all (); | ||
| } | ||
|
|
||
| public bool isNotValid(string inputField){ | ||
| if(inputField == ""){ | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,65 @@ | ||
| using Granite.Widgets; | ||
|
|
||
| namespace BookmarkManager { | ||
| public class ListBox : Gtk.ListBox{ | ||
|
|
||
| private ConfigFileReader configFileReader = new ConfigFileReader (); | ||
| private StackManager stackManager = StackManager.get_instance(); | ||
|
|
||
| public void empty(){ | ||
| this.foreach ((ListBoxRow) => { | ||
| this.remove(ListBoxRow); | ||
| }); | ||
| } | ||
|
|
||
| public void getRepositories(string searchWord = ""){ | ||
| this.empty(); | ||
|
|
||
| stackManager.getStack().visible_child_name = "list-view"; | ||
|
|
||
| var repositories = configFileReader.getRepositories(); | ||
|
|
||
| if(listisEmpty(repositories)) { | ||
| stackManager.getStack().visible_child_name = "empty-view"; | ||
| return; | ||
| } | ||
|
|
||
| if(searchWordDoesntMatchAnyInList(searchWord, repositories)) { | ||
| stackManager.getStack().visible_child_name = "not-found-view"; | ||
| return; | ||
| } | ||
|
|
||
| foreach (string repository in repositories) { | ||
| if(searchWord == ""){ | ||
| this.add (new ListBoxRow (repository)); | ||
| continue; | ||
| } | ||
|
|
||
| if(searchWord in repository){ | ||
| this.add (new ListBoxRow (repository)); | ||
| } | ||
| } | ||
|
|
||
| this.show_all(); | ||
| } | ||
|
|
||
| private bool listisEmpty(string[] repositories){ | ||
| return repositories.length == 0; | ||
| } | ||
|
|
||
| private bool searchWordDoesntMatchAnyInList(string searchWord, string[] repositories){ | ||
| int matchCount = 0; | ||
|
|
||
| if(searchWord == ""){ | ||
| return false; | ||
| } | ||
|
|
||
| foreach (string repository in repositories) { | ||
| if(searchWord in repository){ | ||
| matchCount++; | ||
| } | ||
| } | ||
| return matchCount == 0; | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,91 @@ | ||
| using Granite.Widgets; | ||
|
|
||
| namespace BookmarkManager { | ||
| public class ListBoxRow : Gtk.ListBoxRow { | ||
|
|
||
| StackManager stackManager = StackManager.get_instance(); | ||
|
|
||
| private const int PROGRESS_BAR_HEIGHT = 5; | ||
| private Settings settings = new Settings ("com.github.bartzaalberg.bookmark-manager"); | ||
|
|
||
| // private Gtk.Image edit_image = new Gtk.Image.from_icon_name ("document-properties-symbolic", Gtk.IconSize.SMALL_TOOLBAR); | ||
| // private Gtk.Image delete_image = new Gtk.Image.from_icon_name ("edit-delete-symbolic", Gtk.IconSize.SMALL_TOOLBAR); | ||
|
|
||
| // private Gtk.Image icon = new Gtk.Image.from_icon_name ("terminal", Gtk.IconSize.DND); | ||
| private Gtk.Box vertical_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6); | ||
| private Bookmark bookmark; | ||
|
|
||
| public ListBoxRow (string repository){ | ||
|
|
||
| var splittedLine = repository.split(" "); | ||
|
|
||
| //this.bookmark = bookmark; | ||
| var name_label = generateNameLabel(repository); | ||
| var summary_label = generateSummaryLabel("Some Label"); | ||
|
|
||
| var enabledButton = new Gtk.CheckButton(); | ||
|
|
||
| //var edit_button = generateEditButton(bookmark); | ||
| //var delete_button = generateDeleteButton(); | ||
|
|
||
| string firstCharacter = repository.substring (0, 1); | ||
| stdout.printf(firstCharacter); | ||
|
|
||
| if(firstCharacter != "#"){ | ||
| enabledButton.active = true; | ||
| } | ||
|
|
||
| vertical_box.add (name_label); | ||
| vertical_box.add (summary_label); | ||
|
|
||
| var bookmark_row = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 12); | ||
| bookmark_row.margin = 6; | ||
| bookmark_row.add(enabledButton); | ||
| bookmark_row.add (vertical_box); | ||
| //bookmark_row.pack_end (edit_button, false, false); | ||
| //bookmark_row.pack_end (delete_button, false, false); | ||
|
|
||
| this.add (bookmark_row); | ||
| } | ||
|
|
||
| public Gtk.Label generateNameLabel(string repository){ | ||
| var name_label = new Gtk.Label ("<b>%s</b>".printf (repository)); | ||
| name_label.use_markup = true; | ||
| name_label.halign = Gtk.Align.START; | ||
|
|
||
| return name_label; | ||
| } | ||
|
|
||
| public Gtk.Label generateSummaryLabel(string sshCommand){ | ||
| var summary_label = new Gtk.Label (sshCommand); | ||
| summary_label.halign = Gtk.Align.START; | ||
|
|
||
| return summary_label; | ||
| } | ||
|
|
||
| // public Gtk.EventBox generateDeleteButton(){ | ||
| // var delete_button = new Gtk.EventBox(); | ||
| // delete_button.add(delete_image); | ||
| // delete_button.set_tooltip_text("Remote this bookmark"); | ||
| // delete_button.button_press_event.connect (() => { | ||
| // new DeleteConfirm(bookmark); | ||
| // return true; | ||
| // }); | ||
| // | ||
| // return delete_button; | ||
| // } | ||
|
|
||
| // public Gtk.EventBox generateEditButton(Bookmark bookmark){ | ||
| // var edit_button = new Gtk.EventBox(); | ||
| // edit_button.add(edit_image); | ||
| // edit_button.set_tooltip_text("Edit this bookmark"); | ||
| // edit_button.button_press_event.connect (() => { | ||
| // stackManager.setEditBookmark(bookmark); | ||
| // stackManager.getStack().visible_child_name = "edit-bookmark-view"; | ||
| // return true; | ||
| // }); | ||
| // | ||
| // return edit_button; | ||
| // } | ||
| } | ||
| } |
| @@ -0,0 +1,27 @@ | ||
| using Granite.Widgets; | ||
|
|
||
| namespace BookmarkManager { | ||
| public class MainWindow : Gtk.Window{ | ||
|
|
||
| private Settings settings = new Settings ("com.github.bartzaalberg.bookmark-manager"); | ||
|
|
||
| private BookmarkListManager bookmarkListManager = BookmarkListManager.get_instance(); | ||
| private StackManager stackManager = StackManager.get_instance(); | ||
|
|
||
| construct { | ||
| set_default_size(800, 510); | ||
| set_size_request (800, 510); | ||
| set_titlebar (new HeaderBar()); | ||
|
|
||
| stackManager.loadViews(this); | ||
|
|
||
| bookmarkListManager.getList().getRepositories(""); | ||
|
|
||
| stackManager.getStack().visible_child_name = "list-view"; | ||
|
|
||
| if(settings.get_string ("sshname") == ""){ | ||
| stackManager.getStack().visible_child_name = "welcome-view"; | ||
| } | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,52 @@ | ||
| namespace BookmarkManager { | ||
| public class StackManager : Object { | ||
|
|
||
| static StackManager? instance; | ||
|
|
||
| private Gtk.Stack stack; | ||
| private const string WELCOME_VIEW_ID = "welcome-view"; | ||
| private const string ADD_BOOKMARK_VIEW_ID = "add-bookmark-view"; | ||
| private const string LIST_VIEW_ID = "list-view"; | ||
| private const string EMPTY_VIEW_ID = "empty-view"; | ||
| private const string NOT_FOUND_VIEW_ID = "not-found-view"; | ||
| private const string EDIT_BOOKMARK_VIEW_ID = "edit-bookmark-view"; | ||
|
|
||
| EditBookmark editBookmarkPage; | ||
|
|
||
| // Private constructor | ||
| StackManager() { | ||
| stack = new Gtk.Stack (); | ||
| stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT; | ||
| } | ||
|
|
||
| // Public constructor | ||
| public static StackManager get_instance() { | ||
| if (instance == null) { | ||
| instance = new StackManager(); | ||
| } | ||
| return instance; | ||
| } | ||
|
|
||
| public Gtk.Stack getStack() { | ||
| return this.stack; | ||
| } | ||
|
|
||
| public void loadViews(Gtk.Window window){ | ||
| editBookmarkPage = new EditBookmark(); | ||
|
|
||
| stack.add_named (new EmptyView(), EMPTY_VIEW_ID); | ||
| stack.add_named (new ListBookmarks(), LIST_VIEW_ID); | ||
| stack.add_named (new AddBookmark(), ADD_BOOKMARK_VIEW_ID); | ||
| stack.add_named (new WelcomeView(), WELCOME_VIEW_ID); | ||
| stack.add_named (new NotFoundView(), NOT_FOUND_VIEW_ID); | ||
| stack.add_named (editBookmarkPage, EDIT_BOOKMARK_VIEW_ID); | ||
|
|
||
| window.add(stack); | ||
| window.show_all(); | ||
| } | ||
|
|
||
| public void setEditBookmark(Bookmark bookmark){ | ||
| editBookmarkPage.loadBookmark(bookmark); | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,107 @@ | ||
| namespace BookmarkManager { | ||
| public class AddBookmark : Gtk.Grid{ | ||
|
|
||
| StackManager stackManager = StackManager.get_instance(); | ||
| BookmarkListManager bookmarkListManager = BookmarkListManager.get_instance(); | ||
|
|
||
| private Gtk.Entry hostEntry = new Gtk.Entry (); | ||
| private Gtk.Entry hostNameEntry = new Gtk.Entry (); | ||
| private Gtk.Entry userNameEntry = new Gtk.Entry (); | ||
| private Gtk.Entry portEntry = new Gtk.Entry (); | ||
| private Gtk.CheckButton agentForwardCheckButton = new Gtk.CheckButton(); | ||
| private Gtk.Entry proxyCommandEntry = new Gtk.Entry (); | ||
|
|
||
| public AddBookmark(){ | ||
| var general_header = new HeaderLabel ("Add new bookmark"); | ||
|
|
||
| var hostLabel = new Gtk.Label ("Host:*"); | ||
| hostLabel.set_alignment(0,0); | ||
|
|
||
| var hostNameLabel = new Gtk.Label ("Host name:*"); | ||
| hostNameLabel.set_alignment(0,0); | ||
|
|
||
| var userNameLabel = new Gtk.Label ("Username:"); | ||
| userNameLabel.set_alignment(0,0); | ||
|
|
||
| var portLabel = new Gtk.Label ("Port:"); | ||
| portLabel.set_alignment(0,0); | ||
|
|
||
| var agentForwardLabel = new Gtk.Label ("Use agent forwarding:"); | ||
| agentForwardLabel.set_alignment(0,0); | ||
|
|
||
| var proxyCommandLabel = new Gtk.Label ("Proxy command:"); | ||
| proxyCommandLabel.set_alignment(0,0); | ||
|
|
||
| hostEntry.set_placeholder_text("server1"); | ||
| hostNameEntry.set_placeholder_text("127.0.0.1"); | ||
| userNameEntry.set_placeholder_text("james"); | ||
| portEntry.set_placeholder_text("80"); | ||
| proxyCommandEntry.set_placeholder_text("ssh bookmark nc %h %p"); | ||
|
|
||
| var back_button = new Gtk.Button.with_label ("Back"); | ||
| back_button.clicked.connect (() => { | ||
| stackManager.getStack().visible_child_name = "list-view"; | ||
| bookmarkListManager.getList().getRepositories(""); | ||
| }); | ||
|
|
||
| var create_button = new Gtk.Button.with_label ("Create"); | ||
| create_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); | ||
| create_button.clicked.connect (() => { | ||
| AddBookmarkToFile(); | ||
| }); | ||
|
|
||
| var button_box = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL); | ||
| button_box.set_layout (Gtk.ButtonBoxStyle.END); | ||
| button_box.pack_end (back_button); | ||
| button_box.pack_end (create_button); | ||
| button_box.margin = 12; | ||
| button_box.margin_bottom = 0; | ||
|
|
||
| this.row_spacing = 12; | ||
| this.column_spacing = 12; | ||
| this.margin = 12; | ||
| this.attach (general_header, 0, 0, 2, 1); | ||
| this.attach (hostLabel, 0, 1, 1, 1); | ||
| this.attach (hostEntry, 1, 1, 1, 1); | ||
| this.attach (hostNameLabel, 0, 2, 1, 1); | ||
| this.attach (hostNameEntry, 1, 2, 1, 1); | ||
| this.attach (userNameLabel, 0, 3, 1, 1); | ||
| this.attach (userNameEntry, 1, 3, 1, 1); | ||
| this.attach (portLabel, 0, 4, 1, 1); | ||
| this.attach (portEntry, 1, 4, 1, 1); | ||
| this.attach (agentForwardLabel, 0, 5, 1, 1); | ||
| this.attach (agentForwardCheckButton, 1, 5, 1, 1); | ||
| this.attach (proxyCommandLabel, 0, 6, 1, 1); | ||
| this.attach (proxyCommandEntry, 1, 6, 1, 1); | ||
|
|
||
| this.attach (button_box, 1, 7, 1, 1); | ||
|
|
||
| } | ||
|
|
||
| public void AddBookmarkToFile(){ | ||
| string repository = hostEntry.text; | ||
|
|
||
| var ConfigFileReader = new ConfigFileReader(); | ||
| var repositories = ConfigFileReader.getRepositories(); | ||
|
|
||
| if(isNotValid(repository)){ | ||
| new Alert("Fields are invalid", "Please correctly fill in all the required fields"); | ||
| return; | ||
| } | ||
|
|
||
| repositories += repository; | ||
|
|
||
| ConfigFileReader.writeToFile(repositories); | ||
|
|
||
| stackManager.getStack().visible_child_name = "list-view"; | ||
| bookmarkListManager.getList().getRepositories(""); | ||
| } | ||
|
|
||
| public bool isNotValid(string newRepository){ | ||
| if(newRepository == ""){ | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,152 @@ | ||
| namespace BookmarkManager { | ||
| public class EditBookmark : Gtk.Grid{ | ||
|
|
||
| StackManager stackManager = StackManager.get_instance(); | ||
| BookmarkListManager bookmarkListManager = BookmarkListManager.get_instance(); | ||
|
|
||
| private Gtk.Entry hostEntry = new Gtk.Entry (); | ||
| private Gtk.Entry hostNameEntry = new Gtk.Entry (); | ||
| private Gtk.Entry userNameEntry = new Gtk.Entry (); | ||
| private Gtk.Entry portEntry = new Gtk.Entry (); | ||
| private Gtk.CheckButton agentForwardCheckButton = new Gtk.CheckButton(); | ||
| private Gtk.Entry proxyCommandEntry = new Gtk.Entry (); | ||
|
|
||
| public EditBookmark(){ | ||
| var general_header = new HeaderLabel ("Edit a bookmark"); | ||
|
|
||
| var hostLabel = new Gtk.Label ("Host:*"); | ||
| hostLabel.set_alignment(0,0); | ||
|
|
||
| var hostNameLabel = new Gtk.Label ("Host name:*"); | ||
| hostNameLabel.set_alignment(0,0); | ||
|
|
||
| var userNameLabel = new Gtk.Label ("Username:"); | ||
| userNameLabel.set_alignment(0,0); | ||
|
|
||
| var portLabel = new Gtk.Label ("Port:"); | ||
| portLabel.set_alignment(0,0); | ||
|
|
||
| var agentForwardLabel = new Gtk.Label ("Use agent forwarding:"); | ||
| agentForwardLabel.set_alignment(0,0); | ||
|
|
||
| var proxyCommandLabel = new Gtk.Label ("Proxy command:"); | ||
| proxyCommandLabel.set_alignment(0,0); | ||
|
|
||
| hostEntry.set_placeholder_text("server1"); | ||
| hostEntry.set_sensitive(false); | ||
| hostNameEntry.set_placeholder_text("127.0.0.1"); | ||
| userNameEntry.set_placeholder_text("james"); | ||
| portEntry.set_placeholder_text("80"); | ||
| proxyCommandEntry.set_placeholder_text("ssh bookmark nc %h %p"); | ||
|
|
||
| var back_button = new Gtk.Button.with_label ("Back"); | ||
| back_button.clicked.connect (() => { | ||
| stackManager.getStack().visible_child_name = "list-view"; | ||
| bookmarkListManager.getList().getRepositories(""); | ||
| }); | ||
|
|
||
| var edit_button = new Gtk.Button.with_label ("Edit"); | ||
| edit_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); | ||
| edit_button.clicked.connect (() => { | ||
| EditBookmarkInFile(); | ||
| }); | ||
|
|
||
| var button_box = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL); | ||
| button_box.set_layout (Gtk.ButtonBoxStyle.END); | ||
| button_box.pack_end (back_button); | ||
| button_box.pack_end (edit_button); | ||
| button_box.margin = 12; | ||
| button_box.margin_bottom = 0; | ||
|
|
||
| this.row_spacing = 12; | ||
| this.column_spacing = 12; | ||
| this.margin = 12; | ||
| this.attach (general_header, 0, 0, 2, 1); | ||
| this.attach (hostLabel, 0, 1, 1, 1); | ||
| this.attach (hostEntry, 1, 1, 1, 1); | ||
| this.attach (hostNameLabel, 0, 2, 1, 1); | ||
| this.attach (hostNameEntry, 1, 2, 1, 1); | ||
| this.attach (userNameLabel, 0, 3, 1, 1); | ||
| this.attach (userNameEntry, 1, 3, 1, 1); | ||
| this.attach (portLabel, 0, 4, 1, 1); | ||
| this.attach (portEntry, 1, 4, 1, 1); | ||
| this.attach (agentForwardLabel, 0, 5, 1, 1); | ||
| this.attach (agentForwardCheckButton, 1, 5, 1, 1); | ||
| this.attach (proxyCommandLabel, 0, 6, 1, 1); | ||
| this.attach (proxyCommandEntry, 1, 6, 1, 1); | ||
|
|
||
| this.attach (button_box, 1, 7, 1, 1); | ||
|
|
||
| } | ||
|
|
||
| public void loadBookmark(Bookmark bookmark){ | ||
|
|
||
|
|
||
| hostEntry.text = ""; | ||
| hostNameEntry.text = ""; | ||
| portEntry.text = ""; | ||
| userNameEntry.text = ""; | ||
| agentForwardCheckButton.active = false; | ||
| proxyCommandEntry.text = ""; | ||
|
|
||
|
|
||
| if(bookmark.getName() != null){ | ||
| hostEntry.text = bookmark.getName(); | ||
| } | ||
| if(bookmark.getIp() != null){ | ||
| hostNameEntry.text = bookmark.getIp(); | ||
| } | ||
|
|
||
| if(bookmark.getPort() != 0){ | ||
| portEntry.text = bookmark.getPort().to_string(); | ||
| } | ||
|
|
||
| if(bookmark.getUser() != null){ | ||
| userNameEntry.text = bookmark.getUser(); | ||
| } | ||
|
|
||
| if(bookmark.getForwardAgent() != null){ | ||
| agentForwardCheckButton.active = true; | ||
| } | ||
|
|
||
| if(bookmark.getProxyCommand() != null){ | ||
| proxyCommandEntry.text = bookmark.getProxyCommand(); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| public void EditBookmarkInFile(){ | ||
|
|
||
| string editedRepository = hostEntry.text; | ||
|
|
||
| if(isNotValid(editedRepository)){ | ||
| new Alert("Fields are invalid", "Please correctly fill in all the required fields"); | ||
| return; | ||
| } | ||
|
|
||
| var ConfigFileReader = new ConfigFileReader(); | ||
| var repositories = ConfigFileReader.getRepositories(); | ||
|
|
||
| var i = 0; | ||
|
|
||
| foreach (string repository in repositories) { | ||
| if(repository == editedRepository) { | ||
| break; | ||
| } | ||
| i++; | ||
| } | ||
|
|
||
| ConfigFileReader.writeToFile(repositories); | ||
|
|
||
| stackManager.getStack().visible_child_name = "list-view"; | ||
| bookmarkListManager.getList().getRepositories(""); | ||
| } | ||
|
|
||
| public bool isNotValid(string editedRepository){ | ||
| if(editedRepository == ""){ | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,27 @@ | ||
| using Granite.Widgets; | ||
|
|
||
| namespace BookmarkManager { | ||
| public class EmptyView : Gtk.ScrolledWindow { | ||
|
|
||
| StackManager stackManager = StackManager.get_instance(); | ||
|
|
||
| public EmptyView(){ | ||
| var empty_view = new Welcome("Add some bookmarks", "Your bookmarks file is empty."); | ||
| empty_view.append("document-new", "New bookmark", "add a new bookmark with host, ip, etc.."); | ||
|
|
||
| empty_view.activated.connect ((option) => { | ||
| switch (option) { | ||
| case 0: | ||
| setAddBookmarkView(); | ||
| break; | ||
| } | ||
| }); | ||
|
|
||
| this.add(empty_view); | ||
| } | ||
|
|
||
| private void setAddBookmarkView(){ | ||
| stackManager.getStack().set_visible_child_name ("add-bookmark-view"); | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,40 @@ | ||
| namespace BookmarkManager { | ||
| public class ListBookmarks : Gtk.Grid { | ||
|
|
||
| BookmarkListManager bookmarkListManager = BookmarkListManager.get_instance(); | ||
|
|
||
| public ListBookmarks(){ | ||
|
|
||
| var box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6); | ||
| box.add(bookmarkListManager.getList()); | ||
|
|
||
| var scrolledWindow = new Gtk.ScrolledWindow(null, null); | ||
| scrolledWindow.hscrollbar_policy = Gtk.PolicyType.NEVER; | ||
| scrolledWindow.min_content_height = 300; | ||
| scrolledWindow.add(box); | ||
|
|
||
| var create_button = new Gtk.Button.with_label ("Create"); | ||
| create_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION); | ||
| create_button.margin_right = 12; | ||
| create_button.clicked.connect (() => { | ||
| this.destroy (); | ||
| }); | ||
|
|
||
| var edit_button = new Gtk.Button.with_label ("Edit"); | ||
| edit_button.clicked.connect (() => { | ||
| this.destroy (); | ||
| }); | ||
|
|
||
| var button_box = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL); | ||
| button_box.set_layout (Gtk.ButtonBoxStyle.START); | ||
| button_box.pack_start (create_button); | ||
| button_box.pack_start (edit_button); | ||
| button_box.margin = 12; | ||
|
|
||
| this.attach (scrolledWindow, 0, 0, 1, 1); | ||
| this.attach (button_box, 0, 1, 1, 1); | ||
|
|
||
| this.show_all(); | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,12 @@ | ||
| using Granite.Widgets; | ||
|
|
||
| namespace BookmarkManager { | ||
| public class NotFoundView : Gtk.ScrolledWindow { | ||
|
|
||
| public NotFoundView(){ | ||
| var not_found_view = new Welcome("Nothing was found", "Try searching for something else"); | ||
|
|
||
| this.add(not_found_view); | ||
| } | ||
| } | ||
| } |
| @@ -0,0 +1,27 @@ | ||
| using Granite.Widgets; | ||
|
|
||
| namespace BookmarkManager { | ||
| public class WelcomeView : Gtk.ScrolledWindow { | ||
|
|
||
| StackManager stackManager = StackManager.get_instance(); | ||
|
|
||
| public WelcomeView(){ | ||
| var welcome_view = new Welcome("Welcome!", "We see this is your first time"); | ||
| welcome_view.append("document-properties", "Setup your information", "Change your ssh name, password, etc.."); | ||
|
|
||
| welcome_view.activated.connect ((option) => { | ||
| switch (option) { | ||
| case 0: | ||
| setListView(); | ||
| break; | ||
| } | ||
| }); | ||
| this.add(welcome_view); | ||
| } | ||
|
|
||
| private void setListView(){ | ||
| new Preferences (); | ||
| stackManager.getStack().set_visible_child_name ("list-view"); | ||
| } | ||
| } | ||
| } |