Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yad
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav
yad
Commits
11d80073
You need to sign in or sign up before continuing.
Commit
11d80073
authored
Dec 16, 2022
by
Victor Ananjevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve stdin handler for html dialog
parent
7b137e0b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
22 deletions
+48
-22
html.c
src/html.c
+48
-22
No files found.
src/html.c
View file @
11d80073
...
...
@@ -366,35 +366,61 @@ icon_cb (GObject *obj, GParamSpec *spec, GtkWindow *dlg)
}
static
gboolean
handle_stdin
(
GIOChannel
*
ch
,
GIOCondition
cond
,
gpointer
d
)
handle_stdin
(
GIOChannel
*
ch
,
GIOCondition
cond
,
gpointer
d
)
{
gchar
*
buf
;
GBytes
*
data
;
GError
*
err
=
NULL
;
switch
(
g_io_channel_read_line
(
ch
,
&
buf
,
NULL
,
NULL
,
&
err
))
if
((
cond
==
G_IO_IN
)
||
(
cond
==
G_IO_IN
+
G_IO_HUP
))
{
case
G_IO_STATUS_NORMAL
:
g_string_append
(
inbuf
,
buf
);
return
TRUE
;
GError
*
err
=
NULL
;
GString
*
string
=
g_string_new
(
NULL
);
case
G_IO_STATUS_ERROR
:
g_printerr
(
"yad_html_handle_stdin(): %s
\n
"
,
err
->
message
);
g_error_free
(
err
);
return
FALSE
;
while
(
ch
->
is_readable
!=
TRUE
)
usleep
(
100
);
case
G_IO_STATUS_EOF
:
data
=
g_bytes_new
(
inbuf
->
str
,
inbuf
->
len
);
/*g_string_free (inbuf, TRUE); */
/* FIXME: IS THAT NEEDED ??? (and where) */
webkit_web_view_load_bytes
(
view
,
data
,
options
.
common_data
.
mime
,
options
.
html_data
.
encoding
,
NULL
);
g_bytes_unref
(
data
);
return
FALSE
;
do
{
gint
status
;
case
G_IO_STATUS_AGAIN
:
return
TRUE
;
do
status
=
g_io_channel_read_line_string
(
ch
,
string
,
NULL
,
&
err
);
while
(
status
==
G_IO_STATUS_AGAIN
);
if
(
status
!=
G_IO_STATUS_NORMAL
)
{
if
(
err
)
{
g_printerr
(
"yad_html_handle_stdin(): %s
\n
"
,
err
->
message
);
g_error_free
(
err
);
err
=
NULL
;
}
/* stop handling */
g_io_channel_shutdown
(
ch
,
TRUE
,
NULL
);
return
FALSE
;
}
if
(
string
->
str
[
0
]
==
'\014'
)
g_string_truncate
(
inbuf
,
0
);
else
g_string_append
(
inbuf
,
string
->
str
);
}
while
(
g_io_channel_get_buffer_condition
(
ch
)
==
G_IO_IN
);
g_string_free
(
string
,
TRUE
);
if
(
inbuf
->
len
)
{
GBytes
*
data
=
g_bytes_new
(
inbuf
->
str
,
inbuf
->
len
);
is_loaded
=
FALSE
;
webkit_web_view_load_bytes
(
view
,
data
,
options
.
common_data
.
mime
,
options
.
html_data
.
encoding
,
NULL
);
g_bytes_unref
(
data
);
}
}
return
FALSE
;
if
((
cond
!=
G_IO_IN
)
&&
(
cond
!=
G_IO_IN
+
G_IO_HUP
))
{
g_io_channel_shutdown
(
ch
,
TRUE
,
NULL
);
return
FALSE
;
}
return
TRUE
;
}
static
void
...
...
Write
Preview
Markdown
is supported
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