Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
xfce4-dict
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Apps
xfce4-dict
Commits
4224d2c3
Commit
4224d2c3
authored
7 years ago
by
Andre Miranda
Browse files
Options
Downloads
Patches
Plain Diff
Append web search link to successful queries (bug #12154)
parent
e55b586e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/dictd.c
+26
-16
26 additions, 16 deletions
lib/dictd.c
with
26 additions
and
16 deletions
lib/dictd.c
+
26
−
16
View file @
4224d2c3
...
@@ -371,6 +371,28 @@ static void clear_query_buffer(DictData *dd)
...
@@ -371,6 +371,28 @@ static void clear_query_buffer(DictData *dd)
}
}
static
void
append_web_search_link
(
DictData
*
dd
,
gboolean
prepend_whitespace
)
{
gchar
*
label
=
_
(
dict_prefs_get_web_url_label
(
dd
));
gchar
*
text
=
g_strdup_printf
(
/* for translators: the first wildcard is the search term, the second wildcard
* is the name of the preferred web search engine */
_
(
"Search
\"
%s
\"
using
\"
%s
\"
"
),
dd
->
searched_word
,
label
);
if
(
prepend_whitespace
)
gtk_text_buffer_insert
(
dd
->
main_textbuffer
,
&
dd
->
textiter
,
"
\n\n
"
,
2
);
gtk_text_buffer_insert_with_tags_by_name
(
dd
->
main_textbuffer
,
&
dd
->
textiter
,
_
(
"Web Search:"
),
-
1
,
TAG_HEADING
,
NULL
);
gtk_text_buffer_insert
(
dd
->
main_textbuffer
,
&
dd
->
textiter
,
"
\n
"
,
1
);
gtk_text_buffer_insert_with_tags_by_name
(
dd
->
main_textbuffer
,
&
dd
->
textiter
,
text
,
-
1
,
TAG_LINK
,
NULL
);
g_free
(
text
);
}
static
gboolean
process_server_response
(
DictData
*
dd
)
static
gboolean
process_server_response
(
DictData
*
dd
)
{
{
gint
max_lines
,
i
;
gint
max_lines
,
i
;
...
@@ -434,23 +456,8 @@ static gboolean process_server_response(DictData *dd)
...
@@ -434,23 +456,8 @@ static gboolean process_server_response(DictData *dd)
/* if we had no luck searching a word, maybe we have a typo so try searching with
/* if we had no luck searching a word, maybe we have a typo so try searching with
* spell check and offer a Web search*/
* spell check and offer a Web search*/
if
(
NZV
(
dd
->
web_url
))
if
(
NZV
(
dd
->
web_url
))
{
append_web_search_link
(
dd
,
TRUE
);
gchar
*
label
=
_
(
dict_prefs_get_web_url_label
(
dd
));
gchar
*
text
=
g_strdup_printf
(
/* for translators: the first wildcard is the search term, the second wildcard
* is the name of the preferred web search engine */
_
(
"Search
\"
%s
\"
using
\"
%s
\"
"
),
dd
->
searched_word
,
label
);
gtk_text_buffer_insert
(
dd
->
main_textbuffer
,
&
dd
->
textiter
,
"
\n\n
"
,
2
);
gtk_text_buffer_insert_with_tags_by_name
(
dd
->
main_textbuffer
,
&
dd
->
textiter
,
_
(
"Web Search:"
),
-
1
,
TAG_HEADING
,
NULL
);
gtk_text_buffer_insert
(
dd
->
main_textbuffer
,
&
dd
->
textiter
,
"
\n
"
,
1
);
gtk_text_buffer_insert_with_tags_by_name
(
dd
->
main_textbuffer
,
&
dd
->
textiter
,
text
,
-
1
,
TAG_LINK
,
NULL
);
g_free
(
text
);
}
if
(
NZV
(
dd
->
spell_bin
))
if
(
NZV
(
dd
->
spell_bin
))
{
{
gtk_text_buffer_insert
(
dd
->
main_textbuffer
,
&
dd
->
textiter
,
"
\n
"
,
1
);
gtk_text_buffer_insert
(
dd
->
main_textbuffer
,
&
dd
->
textiter
,
"
\n
"
,
1
);
...
@@ -492,6 +499,9 @@ static gboolean process_server_response(DictData *dd)
...
@@ -492,6 +499,9 @@ static gboolean process_server_response(DictData *dd)
{
{
i
=
process_response_content
(
dd
,
lines
,
i
,
max_lines
,
header
,
body
);
i
=
process_response_content
(
dd
,
lines
,
i
,
max_lines
,
header
,
body
);
}
}
append_web_search_link
(
dd
,
FALSE
);
g_strfreev
(
lines
);
g_strfreev
(
lines
);
clear_query_buffer
(
dd
);
clear_query_buffer
(
dd
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment