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
d087ec86
Commit
d087ec86
authored
Jan 19, 2021
by
Victor Ananjevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix text-align option
parent
cea946c1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
25 deletions
+29
-25
main.c
src/main.c
+16
-2
option.c
src/option.c
+12
-22
yad.h
src/yad.h
+1
-1
No files found.
src/main.c
View file @
d087ec86
...
...
@@ -205,14 +205,28 @@ create_layout (GtkWidget *dlg)
gtk_widget_set_name
(
text
,
"yad-dialog-label"
);
gtk_label_set_line_wrap
(
GTK_LABEL
(
text
),
TRUE
);
gtk_label_set_selectable
(
GTK_LABEL
(
text
),
options
.
data
.
selectable_labels
);
gtk_label_set_justify
(
GTK_LABEL
(
text
),
options
.
data
.
text_align
);
gtk_widget_set_state_flags
(
text
,
GTK_STATE_FLAG_NORMAL
,
FALSE
);
gtk_label_set_xalign
(
GTK_LABEL
(
text
),
options
.
data
.
text_align
);
gtk_widget_set_can_focus
(
text
,
FALSE
);
if
(
options
.
data
.
text_width
>
0
)
gtk_label_set_width_chars
(
GTK_LABEL
(
text
),
options
.
data
.
text_width
);
/* set label align and justification */
switch
(
options
.
data
.
text_align
)
{
case
GTK_JUSTIFY_LEFT
:
case
GTK_JUSTIFY_FILL
:
gtk_label_set_xalign
(
GTK_LABEL
(
text
),
0
.
0
);
break
;
case
GTK_JUSTIFY_RIGHT
:
gtk_label_set_xalign
(
GTK_LABEL
(
text
),
0
.
5
);
break
;
case
GTK_JUSTIFY_CENTER
:
gtk_label_set_xalign
(
GTK_LABEL
(
text
),
1
.
0
);
break
;
}
gtk_label_set_justify
(
GTK_LABEL
(
text
),
options
.
data
.
text_align
);
if
(
!
options
.
data
.
no_markup
)
{
gtk_label_set_markup
(
GTK_LABEL
(
text
),
buf
);
...
...
src/option.c
View file @
d087ec86
...
...
@@ -114,7 +114,7 @@ static GOptionEntry general_options[] = {
N_
(
"Set the dialog text"
),
N_
(
"TEXT"
)
},
{
"text-width"
,
0
,
G_OPTION_FLAG_NOALIAS
,
G_OPTION_ARG_INT
,
&
options
.
data
.
text_width
,
N_
(
"Set the dialog text width in characters"
),
N_
(
"NUMBER"
)
},
{
"text-align"
,
0
,
G_OPTION_FLAG_NOALIAS
,
G_OPTION_ARG_CALLBACK
,
set_
text_align
,
{
"text-align"
,
0
,
G_OPTION_FLAG_NOALIAS
,
G_OPTION_ARG_CALLBACK
,
set_
justify
,
N_
(
"Set the dialog text alignment (left, center, right, fill)"
),
N_
(
"TYPE"
)
},
{
"image"
,
0
,
G_OPTION_FLAG_NOALIAS
,
G_OPTION_ARG_FILENAME
,
&
options
.
data
.
dialog_image
,
N_
(
"Set the dialog image"
),
N_
(
"IMAGE"
)
},
...
...
@@ -703,23 +703,6 @@ add_button (const gchar * option_name, const gchar * value, gpointer data, GErro
}
static
gboolean
set_text_align
(
const
gchar
*
option_name
,
const
gchar
*
value
,
gpointer
data
,
GError
**
err
)
{
if
(
strcasecmp
(
value
,
"left"
)
==
0
)
options
.
data
.
text_align
=
0
.
0
;
else
if
(
strcasecmp
(
value
,
"right"
)
==
0
)
options
.
data
.
text_align
=
1
.
0
;
else
if
(
strcasecmp
(
value
,
"center"
)
==
0
)
options
.
data
.
text_align
=
0
.
5
;
else
if
(
strcasecmp
(
value
,
"fill"
)
==
0
)
options
.
data
.
text_align
=
0
.
0
;
else
g_printerr
(
_
(
"Unknown align type: %s
\n
"
),
value
);
return
TRUE
;
}
static
gboolean
add_column
(
const
gchar
*
option_name
,
const
gchar
*
value
,
gpointer
data
,
GError
**
err
)
{
YadColumn
*
col
;
...
...
@@ -1046,14 +1029,21 @@ set_align (const gchar * option_name, const gchar * value, gpointer data, GError
static
gboolean
set_justify
(
const
gchar
*
option_name
,
const
gchar
*
value
,
gpointer
data
,
GError
**
err
)
{
GtkJustification
*
just
;
if
(
strcasecmp
(
option_name
,
"justify"
)
==
0
)
just
=
&
options
.
text_data
.
justify
;
else
just
=
&
options
.
data
.
text_align
;
if
(
strcasecmp
(
value
,
"left"
)
==
0
)
options
.
text_data
.
justify
=
GTK_JUSTIFY_LEFT
;
*
just
=
GTK_JUSTIFY_LEFT
;
else
if
(
strcasecmp
(
value
,
"right"
)
==
0
)
options
.
text_data
.
justify
=
GTK_JUSTIFY_RIGHT
;
*
just
=
GTK_JUSTIFY_RIGHT
;
else
if
(
strcasecmp
(
value
,
"center"
)
==
0
)
options
.
text_data
.
justify
=
GTK_JUSTIFY_CENTER
;
*
just
=
GTK_JUSTIFY_CENTER
;
else
if
(
strcasecmp
(
value
,
"fill"
)
==
0
)
options
.
text_data
.
justify
=
GTK_JUSTIFY_FILL
;
*
just
=
GTK_JUSTIFY_FILL
;
else
g_printerr
(
_
(
"Unknown justification type: %s
\n
"
),
value
);
...
...
src/yad.h
View file @
d087ec86
...
...
@@ -222,7 +222,7 @@ typedef struct {
gchar
*
to_indicator
;
gchar
*
dialog_text
;
guint
text_width
;
gdouble
text_align
;
GtkJustification
text_align
;
gchar
*
dialog_image
;
gchar
*
icon_theme
;
gchar
*
expander
;
...
...
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