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
244919df
You need to sign in or sign up before continuing.
Commit
244919df
authored
Apr 25, 2020
by
Victor Ananjevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use pango style font definition for text view. affected popup menu must be fixed in a future
parent
b003286f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
112 additions
and
7 deletions
+112
-7
text.c
src/text.c
+20
-7
util.c
src/util.c
+90
-0
yad.h
src/yad.h
+2
-0
No files found.
src/text.c
View file @
244919df
...
...
@@ -441,7 +441,6 @@ text_create_widget (GtkWidget * dlg)
gtk_text_view_set_justification
(
GTK_TEXT_VIEW
(
text_view
),
options
.
text_data
.
justify
);
gtk_text_view_set_left_margin
(
GTK_TEXT_VIEW
(
text_view
),
options
.
text_data
.
margins
);
gtk_text_view_set_right_margin
(
GTK_TEXT_VIEW
(
text_view
),
options
.
text_data
.
margins
);
gtk_text_view_set_monospace
(
GTK_TEXT_VIEW
(
text_view
),
TRUE
);
gtk_text_view_set_editable
(
GTK_TEXT_VIEW
(
text_view
),
options
.
common_data
.
editable
);
if
(
!
options
.
common_data
.
editable
&&
options
.
text_data
.
hide_cursor
)
gtk_text_view_set_cursor_visible
(
GTK_TEXT_VIEW
(
text_view
),
FALSE
);
...
...
@@ -453,22 +452,36 @@ text_create_widget (GtkWidget * dlg)
{
GtkCssProvider
*
provider
;
GtkStyleContext
*
context
;
GtkSettings
*
gst
;
gchar
*
font
,
*
df
;
GString
*
css
;
css
=
g_string_new
(
"
textview, text
view text {
\n
"
);
css
=
g_string_new
(
"
.view, .
view text {
\n
"
);
if
(
options
.
common_data
.
font
)
g_string_append_printf
(
css
,
" font: %s;
\n
"
,
options
.
common_data
.
font
);
{
font
=
pango_to_css
(
options
.
common_data
.
font
);
g_string_append_printf
(
css
,
"font: %s;
\n
"
,
font
);
g_free
(
font
);
}
if
(
options
.
text_data
.
fore
)
g_string_append_printf
(
css
,
"
color: %s;
\n
"
,
options
.
text_data
.
fore
);
g_string_append_printf
(
css
,
"color: %s;
\n
"
,
options
.
text_data
.
fore
);
if
(
options
.
text_data
.
back
)
g_string_append_printf
(
css
,
"
background-color: %s;
\n
"
,
options
.
text_data
.
back
);
g_string_append_printf
(
css
,
"background-color: %s;
\n
"
,
options
.
text_data
.
back
);
g_string_append
(
css
,
"}
\n
"
);
/* set normal font for popup menu */
gst
=
gtk_settings_get_default
();
g_object_get
(
G_OBJECT
(
gst
),
"gtk-font-name"
,
&
df
,
NULL
);
font
=
pango_to_css
(
df
);
g_string_append_printf
(
css
,
".view window.popup {
\n
font: %s;
\n
}
\n
"
,
font
);
g_free
(
font
);
printf
(
css
->
str
);
provider
=
gtk_css_provider_new
();
gtk_css_provider_load_from_data
(
provider
,
css
->
str
,
-
1
,
NULL
);
context
=
gtk_widget_get_style_context
(
text_view
);
gtk_style_context_add_provider
(
context
,
GTK_STYLE_PROVIDER
(
provider
),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
);
gtk_style_context_add_provider
(
context
,
GTK_STYLE_PROVIDER
(
provider
),
GTK_STYLE_PROVIDER_PRIORITY_USER
);
g_string_free
(
css
,
TRUE
);
}
...
...
src/util.c
View file @
244919df
...
...
@@ -666,6 +666,96 @@ run_command_async (gchar *cmd)
g_free
(
full_cmd
);
}
gchar
*
pango_to_css
(
gchar
*
font
)
{
PangoFontDescription
*
desc
;
PangoFontMask
mask
;
GString
*
str
;
gchar
*
res
;
str
=
g_string_new
(
NULL
);
desc
=
pango_font_description_from_string
(
font
);
mask
=
pango_font_description_get_set_fields
(
desc
);
if
(
mask
&
PANGO_FONT_MASK_STYLE
)
{
switch
(
pango_font_description_get_style
(
desc
))
{
case
PANGO_STYLE_OBLIQUE
:
g_string_append
(
str
,
"oblique "
);
break
;
case
PANGO_STYLE_ITALIC
:
g_string_append
(
str
,
"italic "
);
break
;
}
}
if
(
mask
&
PANGO_FONT_MASK_VARIANT
)
{
if
(
pango_font_description_get_variant
(
desc
)
==
PANGO_VARIANT_SMALL_CAPS
)
g_string_append
(
str
,
"small-caps "
);
}
if
(
mask
&
PANGO_FONT_MASK_WEIGHT
)
{
switch
(
pango_font_description_get_weight
(
desc
))
{
case
PANGO_WEIGHT_THIN
:
g_string_append
(
str
,
"Thin "
);
break
;
case
PANGO_WEIGHT_ULTRALIGHT
:
g_string_append
(
str
,
"Ultralight "
);
break
;
case
PANGO_WEIGHT_LIGHT
:
g_string_append
(
str
,
"Light "
);
break
;
case
PANGO_WEIGHT_SEMILIGHT
:
g_string_append
(
str
,
"Semilight "
);
break
;
case
PANGO_WEIGHT_BOOK
:
g_string_append
(
str
,
"Book "
);
break
;
case
PANGO_WEIGHT_MEDIUM
:
g_string_append
(
str
,
"Medium "
);
break
;
case
PANGO_WEIGHT_SEMIBOLD
:
g_string_append
(
str
,
"Semibold "
);
break
;
case
PANGO_WEIGHT_BOLD
:
g_string_append
(
str
,
"Bold "
);
break
;
case
PANGO_WEIGHT_ULTRABOLD
:
g_string_append
(
str
,
"Ultrabold "
);
break
;
case
PANGO_WEIGHT_HEAVY
:
g_string_append
(
str
,
"Heavy "
);
break
;
case
PANGO_WEIGHT_ULTRAHEAVY
:
g_string_append
(
str
,
"Ultraheavy "
);
break
;
}
}
if
(
mask
&
PANGO_FONT_MASK_SIZE
)
{
if
(
pango_font_description_get_size_is_absolute
(
desc
))
g_string_append_printf
(
str
,
"%dpx "
,
pango_font_description_get_size
(
desc
)
/
PANGO_SCALE
);
else
g_string_append_printf
(
str
,
"%dpt "
,
pango_font_description_get_size
(
desc
)
/
PANGO_SCALE
);
}
if
(
mask
&
PANGO_FONT_MASK_FAMILY
)
g_string_append
(
str
,
pango_font_description_get_family
(
desc
));
if
(
str
->
str
)
res
=
str
->
str
;
else
res
=
g_strdup
(
font
);
return
res
;
}
#ifdef HAVE_SPELL
void
show_langs
()
...
...
src/yad.h
View file @
244919df
...
...
@@ -660,6 +660,8 @@ gchar *print_bool_val (gboolean val);
gint
run_command_sync
(
gchar
*
cmd
,
gchar
**
out
);
void
run_command_async
(
gchar
*
cmd
);
gchar
*
pango_to_css
(
gchar
*
font
);
#ifdef HAVE_SPELL
void
show_langs
();
#endif
...
...
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