Merge branch 'dev' into japanese-translations
This commit is contained in:
commit
c497a41ca6
@ -30,7 +30,7 @@ pkg_search_module(GLIB REQUIRED glib-2.0)
|
||||
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
|
||||
pkg_check_modules(CAIRO REQUIRED cairo)
|
||||
|
||||
add_compile_options(-Wall -Wold-style-declaration -Wuninitialized -Wmaybe-uninitialized -Wunused-parameter)
|
||||
add_compile_options(-Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitialized -Wunused-parameter)
|
||||
|
||||
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
message("${Yellow}Debug mode for translations used!${ColorReset}")
|
||||
|
@ -759,6 +759,10 @@ static void auto_naming_clicked(GtkWidget *button, gpointer user_data)
|
||||
|
||||
gui = RENDERER_GUI(user_data);
|
||||
|
||||
/* Don't do anything if the selector is empty. */
|
||||
if (!layer_selector_contains_elements(gui->layer_selector))
|
||||
return;
|
||||
|
||||
/* Ask for overwrite */
|
||||
dialog = GTK_DIALOG(gtk_message_dialog_new(gui->main_window, GTK_DIALOG_USE_HEADER_BAR, GTK_MESSAGE_QUESTION,
|
||||
GTK_BUTTONS_YES_NO, "Overwrite existing layer names?"));
|
||||
|
@ -118,6 +118,18 @@ void layer_selector_auto_color_layers(LayerSelector *layer_selector, ColorPalett
|
||||
*/
|
||||
void layer_selector_auto_name_layers(LayerSelector *layer_selector, gboolean overwrite);
|
||||
|
||||
/**
|
||||
* @brief Check if the given layer selector contains layer elements.
|
||||
*
|
||||
* This function checks whether there are elements present.
|
||||
* If an invalid object pointer \p layer_selector is passed,
|
||||
* the function returns FALSE
|
||||
*
|
||||
* @param[in] layer_selector Selector to check
|
||||
* @return True, if there is at least one layer present inside the selector
|
||||
*/
|
||||
gboolean layer_selector_contains_elements(LayerSelector *layer_selector);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __LAYER_SELECTOR_H__ */
|
||||
|
@ -106,13 +106,13 @@ static int color_palette_fill_with_resource(ColorPalette *palette, char *resourc
|
||||
char_array = (const char *)g_bytes_get_data(data, &byte_count);
|
||||
|
||||
if (!char_array || !byte_count)
|
||||
goto ret_unref;
|
||||
goto ret_unref_data;
|
||||
|
||||
/* Get maximum lenght of color palette, assuming all entries are valid */
|
||||
lines = count_non_empty_lines_in_array(char_array, byte_count);
|
||||
|
||||
if (lines <= 0)
|
||||
goto ret_unref;
|
||||
goto ret_unref_data;
|
||||
|
||||
palette->color_array = (GdkRGBA *)malloc(sizeof(GdkRGBA) * (unsigned int)lines);
|
||||
|
||||
@ -128,18 +128,17 @@ static int color_palette_fill_with_resource(ColorPalette *palette, char *resourc
|
||||
color_idx = 0;
|
||||
|
||||
/* interate over lines and match */
|
||||
for (idx = 0 ; idx < byte_count; idx++) {
|
||||
for (idx = 0 ; (unsigned int)idx < byte_count; idx++) {
|
||||
/* Fillup line. */
|
||||
line[line_idx] = char_array[idx];
|
||||
|
||||
|
||||
/* If end of line/string is reached, process */
|
||||
if (line[line_idx] == '\n' || line[line_idx] == '\0') {
|
||||
line[line_idx] = '\0';
|
||||
|
||||
/* Match the line */
|
||||
g_regex_match(regex, line, 0, &mi);
|
||||
if (g_match_info_matches(mi) && color_idx < lines) {
|
||||
if (g_match_info_matches(mi) && color_idx < (unsigned int)lines) {
|
||||
match = g_match_info_fetch_named(mi, "red");
|
||||
palette->color_array[color_idx].red =
|
||||
(double)g_ascii_strtoll(match, NULL, 16) / 255.0;
|
||||
@ -169,10 +168,10 @@ static int color_palette_fill_with_resource(ColorPalette *palette, char *resourc
|
||||
continue;
|
||||
}
|
||||
|
||||
/* increment line index. If end is reached write all bytes to the line end
|
||||
* line is longer than required for parsing. This ensures, that everything works as expected
|
||||
/* increment line index. If end is reached write all bytes to the line end.
|
||||
* Line is longer than required for parsing. This ensures, that everything works as expected
|
||||
*/
|
||||
line_idx += (line_idx < sizeof(line)-1 ? 1 : 0);
|
||||
line_idx += ((unsigned int)line_idx < sizeof(line)-1 ? 1 : 0);
|
||||
}
|
||||
|
||||
/* Data read; Shrink array in case of invalid lines */
|
||||
@ -180,7 +179,7 @@ static int color_palette_fill_with_resource(ColorPalette *palette, char *resourc
|
||||
palette->color_array_length = color_idx;
|
||||
|
||||
g_regex_unref(regex);
|
||||
ret_unref:
|
||||
ret_unref_data:
|
||||
g_bytes_unref(data);
|
||||
|
||||
return 0;
|
||||
|
@ -883,4 +883,19 @@ void layer_selector_auto_name_layers(LayerSelector *layer_selector, gboolean ove
|
||||
g_list_free(le_list);
|
||||
}
|
||||
|
||||
gboolean layer_selector_contains_elements(LayerSelector *layer_selector)
|
||||
{
|
||||
GList *layer_element_list;
|
||||
|
||||
/* Check objects */
|
||||
g_return_val_if_fail(LAYER_IS_SELECTOR(layer_selector), FALSE);
|
||||
g_return_val_if_fail(GTK_IS_LIST_BOX(layer_selector->list_box), FALSE);
|
||||
|
||||
/* Get a list of the child elements inside the list boy associated with this selector */
|
||||
layer_element_list = gtk_container_get_children(GTK_CONTAINER(layer_selector->list_box));
|
||||
|
||||
/* Return TRUE if there is an element in the list, else return FALSE */
|
||||
return (layer_element_list ? TRUE : FALSE);
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
@ -1,4 +1,16 @@
|
||||
add_custom_target(translations ALL
|
||||
add_custom_target(translations
|
||||
DEPENDS
|
||||
"${PROJECT_BINARY_DIR}/translations/output/"
|
||||
)
|
||||
|
||||
add_custom_command(DEPENDS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pot/po/*"
|
||||
OUTPUT
|
||||
"${PROJECT_BINARY_DIR}/translations/output/"
|
||||
COMMAND
|
||||
COMMAND ./generate-mo.sh "${PROJECT_BINARY_DIR}/translations/output"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT "Generating translation locales")
|
||||
WORKING_DIRECTORY
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMENT
|
||||
"Generating translation locales"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user