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
2535a22d
Commit
2535a22d
authored
Apr 15, 2020
by
Pat Brands
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made constraint of scale slider to step increments optional
* Use option '--enforce-step' to enable the feature
parent
6686e709
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
4 deletions
+10
-4
yad.1
data/yad.1
+3
-0
option.c
src/option.c
+2
-0
scale.c
src/scale.c
+4
-4
yad.h
src/yad.h
+1
-0
No files found.
data/yad.1
View file @
2535a22d
...
@@ -923,6 +923,9 @@ Set maximum value.
...
@@ -923,6 +923,9 @@ Set maximum value.
.B \-\-step=\fIVALUE\fP
.B \-\-step=\fIVALUE\fP
Set step size.
Set step size.
.TP
.TP
.B \-\-enforce-step
Only allow values in step increments.
.TP
.B \-\-page=\fIVALUE\fP
.B \-\-page=\fIVALUE\fP
Set paging size. By default page value is STEP*10.
Set paging size. By default page value is STEP*10.
.TP
.TP
...
...
src/option.c
View file @
2535a22d
...
@@ -580,6 +580,8 @@ static GOptionEntry scale_options[] = {
...
@@ -580,6 +580,8 @@ static GOptionEntry scale_options[] = {
N_
(
"Set maximum value"
),
N_
(
"VALUE"
)
},
N_
(
"Set maximum value"
),
N_
(
"VALUE"
)
},
{
"step"
,
0
,
0
,
G_OPTION_ARG_INT
,
&
options
.
scale_data
.
step
,
{
"step"
,
0
,
0
,
G_OPTION_ARG_INT
,
&
options
.
scale_data
.
step
,
N_
(
"Set step size"
),
N_
(
"VALUE"
)
},
N_
(
"Set step size"
),
N_
(
"VALUE"
)
},
{
"enforce-step"
,
0
,
0
,
G_OPTION_ARG_NONE
,
&
options
.
scale_data
.
enforce_step
,
N_
(
"Only allow values in step increments"
),
NULL
},
{
"page"
,
0
,
0
,
G_OPTION_ARG_INT
,
&
options
.
scale_data
.
page
,
{
"page"
,
0
,
0
,
G_OPTION_ARG_INT
,
&
options
.
scale_data
.
page
,
N_
(
"Set paging size"
),
N_
(
"VALUE"
)
},
N_
(
"Set paging size"
),
N_
(
"VALUE"
)
},
{
"print-partial"
,
0
,
0
,
G_OPTION_ARG_NONE
,
&
options
.
scale_data
.
print_partial
,
{
"print-partial"
,
0
,
0
,
G_OPTION_ARG_NONE
,
&
options
.
scale_data
.
print_partial
,
...
...
src/scale.c
View file @
2535a22d
...
@@ -33,13 +33,13 @@ static GtkWidget *minus_btn = NULL;
...
@@ -33,13 +33,13 @@ static GtkWidget *minus_btn = NULL;
static
void
static
void
value_changed_cb
(
GtkWidget
*
w
,
gpointer
data
)
value_changed_cb
(
GtkWidget
*
w
,
gpointer
data
)
{
{
/* Make sure the new value corresponds to a step in the range. This is needed
if
(
options
.
scale_data
.
enforce_step
)
* since the user can move the slider with the mouse which doesn't obey the
{
* step constraint like the keyboard or buttons
/* Make sure the new value corresponds to a step in the range. */
*/
gdouble
value
=
gtk_adjustment_get_value
((
GtkAdjustment
*
)
adj
);
gdouble
value
=
gtk_adjustment_get_value
((
GtkAdjustment
*
)
adj
);
gdouble
new_value
=
(
gdouble
)
round
(
value
/
options
.
scale_data
.
step
)
*
options
.
scale_data
.
step
;
gdouble
new_value
=
(
gdouble
)
round
(
value
/
options
.
scale_data
.
step
)
*
options
.
scale_data
.
step
;
gtk_adjustment_set_value
((
GtkAdjustment
*
)
adj
,
new_value
);
gtk_adjustment_set_value
((
GtkAdjustment
*
)
adj
,
new_value
);
}
if
(
options
.
scale_data
.
print_partial
)
if
(
options
.
scale_data
.
print_partial
)
g_print
(
"%.0f
\n
"
,
gtk_range_get_value
(
GTK_RANGE
(
scale
)));
g_print
(
"%.0f
\n
"
,
gtk_range_get_value
(
GTK_RANGE
(
scale
)));
...
...
src/yad.h
View file @
2535a22d
...
@@ -432,6 +432,7 @@ typedef struct {
...
@@ -432,6 +432,7 @@ typedef struct {
gboolean
invert
;
gboolean
invert
;
gboolean
buttons
;
gboolean
buttons
;
GSList
*
marks
;
GSList
*
marks
;
gboolean
enforce_step
;
}
YadScaleData
;
}
YadScaleData
;
typedef
struct
{
typedef
struct
{
...
...
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