Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
sebastiankrzyszkowiak
megapixels
Commits
07283e56
Commit
07283e56
authored
Feb 22, 2021
by
Benjamin Schaaf
Committed by
Evangelos Ribeiro Tzaras
Apr 27, 2021
Browse files
Use glib to check for a valid URI in bar codes
Fixes #46
parent
9641f30f
Changes
1
Hide whitespace changes
Inline
Side-by-side
main.c
View file @
07283e56
...
...
@@ -444,9 +444,8 @@ on_zbar_code_tapped(GtkWidget *widget, const MPZBarCode *code)
{
GtkWidget
*
dialog
;
GtkDialogFlags
flags
=
GTK_DIALOG_MODAL
|
GTK_DIALOG_DESTROY_WITH_PARENT
;
bool
data_is_url
=
strncmp
(
code
->
data
,
"http://"
,
7
)
==
0
||
strncmp
(
code
->
data
,
"https://"
,
8
)
==
0
||
strncmp
(
code
->
data
,
"gemini://"
,
9
)
==
0
;
bool
data_is_url
=
g_uri_is_valid
(
code
->
data
,
G_URI_FLAGS_PARSE_RELAXED
,
NULL
);
char
*
data
=
strdup
(
code
->
data
);
...
...
@@ -489,7 +488,7 @@ on_zbar_code_tapped(GtkWidget *widget, const MPZBarCode *code)
case
GTK_RESPONSE_YES
:
if
(
!
g_app_info_launch_default_for_uri
(
data
,
NULL
,
&
error
))
{
g_printerr
(
"Could not launch
browser
: %s
\n
"
,
g_printerr
(
"Could not launch
application
: %s
\n
"
,
error
->
message
);
}
case
GTK_RESPONSE_ACCEPT
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment