Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
www/netsurf: Fix preferences dialog bug and fix build warnings
PR: 254702 Submitted by: waitman AT waitman DOT net
- Loading branch information
1 parent
0bea3f1
commit c7d7125
Showing
8 changed files
with
218 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#! | ||
# | ||
# Create ui files for each language listed in FatMessages | ||
|
||
my $inputfn = $ARGV[0]; # path to FatMessages | ||
my $templatefn = $ARGV[1]; # path to UI Template | ||
my $output = $ARGV[2]; # output path | ||
my $stub = $ARGV[3]; # filename stub. like options.gtk3.ui will become enoptions.gtk3.ui | ||
|
||
if (length($stub)<3) { | ||
print "invalid stub.\n"; | ||
exit; | ||
} | ||
|
||
my $template; | ||
my %langs = {'en'=>1}; | ||
my %trans; | ||
$trans{'en'}{'foo'}='bar'; | ||
|
||
open(my $fh, '<', $templatefn) or die "cannot open template file $templatefn"; | ||
{ | ||
local $/; | ||
$template = <$fh>; | ||
} | ||
close($fh); | ||
|
||
$template =~ s/translatable="yes"/translatable="no"/g; | ||
|
||
open(my $input, '<', $inputfn) or die "cannot open FatMessages file $inputfn"; | ||
|
||
while (<$input>) | ||
{ | ||
# skip comment and empty lines | ||
/^#/ && next; | ||
/^\s*$/ && next; | ||
|
||
# only parsing things that look like message lines: | ||
if( /^([a-z]{2}).([^.]+).([^:]+):(.*)/ ) | ||
{ | ||
my( $lang, $plat, $key, $val ) = ( $1, $2, $3, $4 ); | ||
if ($plat == 'gtk') | ||
{ | ||
$val =~ s|<.+?>||g; #remove HTML | ||
$langs{$lang}=1; | ||
$trans{$lang}{$key}=$val; | ||
} | ||
} | ||
|
||
} | ||
|
||
# load up langs hash with copy of the template for each lang | ||
|
||
foreach $key (keys %langs) | ||
{ | ||
if (length($key)==2) | ||
{ | ||
$langs{$key} = $template | ||
} | ||
} | ||
|
||
# iterate through each and key replace with translated text | ||
|
||
foreach my $tran (keys %trans) | ||
{ | ||
foreach my $key (keys %{$trans{$tran}}) | ||
{ | ||
$langs{$tran} =~ s/\>$key\</\>$trans{$tran}{$key}\</g; | ||
} | ||
} | ||
|
||
# save the ui file for each language | ||
|
||
foreach $key (keys %langs) | ||
{ | ||
if (length($key)==2) | ||
{ | ||
open (OFN, '>', $output.'/'.$key.$stub) or die "cannot open output file ".$output.'/'.$key.$stub; | ||
print OFN $langs{$key}; | ||
close (OFN); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,58 @@ | ||
--- Makefile.orig 2020-05-24 20:55:29 UTC | ||
+++ Makefile | ||
@@ -547,7 +547,6 @@ ifeq ($(HOST),mint) | ||
@@ -484,16 +484,6 @@ ifneq ($(CC_MAJOR),2) | ||
COMMON_WARNFLAGS += -Wno-unused-parameter | ||
endif | ||
|
||
-# deal with lots of unwanted warnings from javascript | ||
-ifeq ($(call cc_ver_ge,4,6),1) | ||
- COMMON_WARNFLAGS += -Wno-unused-but-set-variable | ||
-endif | ||
- | ||
-# Implicit fallthrough warnings suppressed by comment | ||
-ifeq ($(call cc_ver_ge,7,1),1) | ||
- COMMON_WARNFLAGS += -Wimplicit-fallthrough=3 | ||
-endif | ||
- | ||
# deal with chaging warning flags for different platforms | ||
ifeq ($(HOST),OpenBSD) | ||
# OpenBSD headers are not compatible with redundant declaration warning | ||
@@ -547,7 +537,6 @@ ifeq ($(HOST),mint) | ||
else | ||
$(eval $(call pkg_config_find_and_add_enabled,CURL,libcurl,Curl)) | ||
endif | ||
-$(eval $(call pkg_config_find_and_add_enabled,OPENSSL,openssl,OpenSSL)) | ||
|
||
$(eval $(call pkg_config_find_and_add_enabled,UTF8PROC,libutf8proc,utf8)) | ||
$(eval $(call pkg_config_find_and_add_enabled,WEBP,libwebp,WEBP)) | ||
@@ -680,14 +669,21 @@ $$(MESSAGES_TARGET)/$(1)/Messages: resources/FatMessag | ||
$$(Q)$$(SPLIT_MESSAGES) -l $(1) -p $$(MESSAGES_FILTER) -f messages -o $$@ -z $$< | ||
|
||
CLEAN_MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages | ||
+CLEAN_MESSAGES += $$(MESSAGES_TARGET)/$(1)options.gtk3.ui | ||
MESSAGES += $$(MESSAGES_TARGET)/$(1)/Messages | ||
|
||
endef | ||
|
||
+buildui: | ||
+ @echo "BUILDUI: options ui for each language in resources/FatMessages" | ||
+ @$(PERL) utils/buildui.pl resources/FatMessages frontends/gtk/res/options.gtk3.ui $(MESSAGES_TARGET) options.gtk3.ui | ||
+ | ||
# generate the message file rules | ||
$(eval $(foreach LANG,$(MESSAGES_LANGUAGES), \ | ||
$(call split_messages,$(LANG)))) | ||
|
||
+MESSAGES += buildui | ||
+ | ||
clean-messages: | ||
$(VQ)echo " CLEAN: $(CLEAN_MESSAGES)" | ||
$(Q)$(RM) $(CLEAN_MESSAGES) | ||
@@ -710,7 +706,7 @@ OBJECTS := $(sort $(addprefix $(OBJROOT)/,$(subst /,_, | ||
# Include directory flags | ||
IFLAGS = $(addprefix -I,$(INCLUDE_DIRS)) | ||
|
||
-$(EXETARGET): $(OBJECTS) $(RESOURCES) $(MESSAGES) | ||
+$(EXETARGET): $(OBJECTS) $(RESOURCES) $(MESSAGES) | ||
$(VQ)echo " LINK: $(EXETARGET)" | ||
ifneq ($(TARGET)$(SUBTARGET),riscos-elf) | ||
$(Q)$(CC) -o $(EXETARGET) $(OBJECTS) $(LDFLAGS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- frontends/gtk/preferences.c.orig 2021-04-01 17:51:28 UTC | ||
+++ frontends/gtk/preferences.c | ||
@@ -962,11 +962,26 @@ GtkWidget* nsgtk_preferences(struct browser_window *bw | ||
return GTK_WIDGET(priv->dialog); | ||
} | ||
|
||
- res = nsgtk_builder_new_from_resname("options", &preferences_builder); | ||
- if (res != NSERROR_OK) { | ||
- NSLOG(netsurf, INFO, "Preferences UI builder init failed"); | ||
- return NULL; | ||
+ const char *client_lang; | ||
+ char ui_lang[10] = "en"; | ||
+ client_lang = getenv("LANG"); | ||
+ | ||
+ if (strlen(client_lang)>1) | ||
+ { | ||
+ strncpy(ui_lang,client_lang,2); | ||
} | ||
+ | ||
+ strcat(ui_lang,"options"); | ||
+ | ||
+ res = nsgtk_builder_new_from_resname(ui_lang, &preferences_builder); | ||
+ if (res != NSERROR_OK) { | ||
+ //LANG not found, so fall back to english i guess | ||
+ res = nsgtk_builder_new_from_resname("enoption", &preferences_builder); | ||
+ } | ||
+ if (res != NSERROR_OK) { | ||
+ NSLOG(netsurf, INFO, "Preferences UI builder init failed"); | ||
+ return NULL; | ||
+ } | ||
|
||
priv->dialog = gtk_builder_get_object(preferences_builder, | ||
"dialogPreferences"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- frontends/gtk/resources.c.orig 2021-04-01 19:00:43 UTC | ||
+++ frontends/gtk/resources.c | ||
@@ -82,6 +82,11 @@ static struct nsgtk_resource_s ui_resource[] = { | ||
RES_ENTRY("globalhistory"), | ||
RES_ENTRY("localhistory"), | ||
RES_ENTRY("options"), | ||
+ RES_ENTRY("deoptions"), | ||
+ RES_ENTRY("enoptions"), | ||
+ RES_ENTRY("froptions"), | ||
+ RES_ENTRY("itoptions"), | ||
+ RES_ENTRY("nloptions"), | ||
RES_ENTRY("hotlist"), | ||
RES_ENTRY("cookies"), | ||
RES_ENTRY("viewdata"), | ||
@@ -552,6 +557,7 @@ nsgtk_builder_new_from_resname(const char *resname, Gt | ||
error->message); | ||
g_error_free(error); | ||
g_object_unref(G_OBJECT(new_builder)); | ||
+ | ||
return NSERROR_INIT_FAILED; | ||
} | ||
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters