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
3038f19c
Unverified
Commit
3038f19c
authored
Apr 17, 2020
by
Victor Ananjevsky
Committed by
GitHub
Apr 17, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #53 from PatrickGMM/constrain-scale-to-steps
Updated scale dialog so slider snaps to steps
parents
a5b1a7a3
2535a22d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
1 deletion
+18
-1
configure.ac
configure.ac
+2
-0
yad.1
data/yad.1
+3
-0
option.c
src/option.c
+2
-0
scale.c
src/scale.c
+10
-1
yad.h
src/yad.h
+1
-0
No files found.
configure.ac
View file @
3038f19c
...
...
@@ -121,6 +121,8 @@ AM_CONDITIONAL([BUILD_IB], [test x$build_ib = xyes])
# GSettings
GLIB_GSETTINGS
AC_SEARCH_LIBS(round, m)
# *******************************
# Internationalization
# *******************************
...
...
data/yad.1
View file @
3038f19c
...
...
@@ -923,6 +923,9 @@ Set maximum value.
.B \-\-step=\fIVALUE\fP
Set step size.
.TP
.B \-\-enforce-step
Only allow values in step increments.
.TP
.B \-\-page=\fIVALUE\fP
Set paging size. By default page value is STEP*10.
.TP
...
...
src/option.c
View file @
3038f19c
...
...
@@ -580,6 +580,8 @@ static GOptionEntry scale_options[] = {
N_
(
"Set maximum value"
),
N_
(
"VALUE"
)
},
{
"step"
,
0
,
0
,
G_OPTION_ARG_INT
,
&
options
.
scale_data
.
step
,
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
,
N_
(
"Set paging size"
),
N_
(
"VALUE"
)
},
{
"print-partial"
,
0
,
0
,
G_OPTION_ARG_NONE
,
&
options
.
scale_data
.
print_partial
,
...
...
src/scale.c
View file @
3038f19c
...
...
@@ -18,12 +18,14 @@
*/
#include "yad.h"
#include <math.h>
enum
{
PLUS_BTN
=
0
,
MINUS_BTN
,
};
static
GtkAdjustment
*
adj
;
static
GtkWidget
*
scale
;
static
GtkWidget
*
plus_btn
=
NULL
;
static
GtkWidget
*
minus_btn
=
NULL
;
...
...
@@ -31,6 +33,14 @@ static GtkWidget *minus_btn = NULL;
static
void
value_changed_cb
(
GtkWidget
*
w
,
gpointer
data
)
{
if
(
options
.
scale_data
.
enforce_step
)
{
/* Make sure the new value corresponds to a step in the range. */
gdouble
value
=
gtk_adjustment_get_value
((
GtkAdjustment
*
)
adj
);
gdouble
new_value
=
(
gdouble
)
round
(
value
/
options
.
scale_data
.
step
)
*
options
.
scale_data
.
step
;
gtk_adjustment_set_value
((
GtkAdjustment
*
)
adj
,
new_value
);
}
if
(
options
.
scale_data
.
print_partial
)
g_print
(
"%.0f
\n
"
,
gtk_range_get_value
(
GTK_RANGE
(
scale
)));
...
...
@@ -72,7 +82,6 @@ GtkWidget *
scale_create_widget
(
GtkWidget
*
dlg
)
{
GtkWidget
*
w
;
GtkAdjustment
*
adj
;
gint
page
;
if
(
options
.
scale_data
.
min_value
>=
options
.
scale_data
.
max_value
)
...
...
src/yad.h
View file @
3038f19c
...
...
@@ -432,6 +432,7 @@ typedef struct {
gboolean
invert
;
gboolean
buttons
;
GSList
*
marks
;
gboolean
enforce_step
;
}
YadScaleData
;
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