2008-07-01 22:57:50 +00:00
|
|
|
|
/* GTK - The GIMP Toolkit
|
1997-11-24 22:37:52 +00:00
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
* Copyright (C) 2001 Red Hat, Inc.
|
1997-11-24 22:37:52 +00:00
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1997-11-24 22:37:52 +00:00
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* Lesser General Public License for more details.
|
1997-11-24 22:37:52 +00:00
|
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
1997-11-24 22:37:52 +00:00
|
|
|
|
*/
|
1999-02-24 07:37:18 +00:00
|
|
|
|
|
|
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:37:18 +00:00
|
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
|
* files for a list of changes. These files are distributed with
|
2008-11-11 17:47:13 +00:00
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
1999-02-24 07:37:18 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
|
#include "config.h"
|
2008-11-11 17:47:13 +00:00
|
|
|
|
|
2018-02-08 13:39:45 +00:00
|
|
|
|
#include "gtkscale.h"
|
2012-03-03 18:41:55 +00:00
|
|
|
|
|
|
|
|
|
#include "gtkadjustment.h"
|
|
|
|
|
#include "gtkbuildable.h"
|
|
|
|
|
#include "gtkbuilderprivate.h"
|
2018-02-08 13:39:45 +00:00
|
|
|
|
#include "gtkgizmoprivate.h"
|
2009-01-20 05:10:27 +00:00
|
|
|
|
#include "gtkicontheme.h"
|
2018-02-08 13:39:45 +00:00
|
|
|
|
#include "gtklabel.h"
|
2001-11-17 23:28:51 +00:00
|
|
|
|
#include "gtkmarshalers.h"
|
2010-08-12 23:38:35 +00:00
|
|
|
|
#include "gtkorientable.h"
|
2005-03-22 02:14:55 +00:00
|
|
|
|
#include "gtkprivate.h"
|
2018-02-08 13:39:45 +00:00
|
|
|
|
#include "gtkrangeprivate.h"
|
|
|
|
|
#include "gtktypebuiltins.h"
|
2020-04-08 11:43:28 +00:00
|
|
|
|
#include "gtkwidgetprivate.h"
|
2002-01-29 11:35:28 +00:00
|
|
|
|
|
2018-02-08 13:39:45 +00:00
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
2010-09-01 18:18:22 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 12:01:55 +00:00
|
|
|
|
* GtkScale:
|
2010-09-01 18:18:22 +00:00
|
|
|
|
*
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* A `GtkScale` is a slider control used to select a numeric value.
|
|
|
|
|
*
|
|
|
|
|
* ![An example GtkScale](scales.png)
|
|
|
|
|
*
|
|
|
|
|
* To use it, you’ll probably want to investigate the methods on its base
|
|
|
|
|
* class, [class@GtkRange], in addition to the methods for `GtkScale` itself.
|
|
|
|
|
* To set the value of a scale, you would normally use [method@Gtk.Range.set_value].
|
2010-09-01 18:18:22 +00:00
|
|
|
|
* To detect changes to the value, you would normally use the
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* [signal@Gtk.Range::value-changed] signal.
|
2010-09-01 18:18:22 +00:00
|
|
|
|
*
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* Note that using the same upper and lower bounds for the `GtkScale` (through
|
|
|
|
|
* the `GtkRange` methods) will hide the slider itself. This is useful for
|
2010-11-22 17:46:25 +00:00
|
|
|
|
* applications that want to show an undeterminate value on the scale, without
|
|
|
|
|
* changing the layout of the application (such as movie or music players).
|
|
|
|
|
*
|
2014-02-05 02:00:58 +00:00
|
|
|
|
* # GtkScale as GtkBuildable
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* `GtkScale` supports a custom <marks> element, which can contain multiple
|
|
|
|
|
* <mark\> elements. The “value” and “position” attributes have the same
|
|
|
|
|
* meaning as [method@Gtk.Scale.add_mark] parameters of the same name. If
|
|
|
|
|
* the element is not empty, its content is taken as the markup to show at
|
2014-02-09 22:24:06 +00:00
|
|
|
|
* the mark. It can be translated with the usual ”translatable” and
|
2014-02-05 18:07:34 +00:00
|
|
|
|
* “context” attributes.
|
2015-11-04 04:11:52 +00:00
|
|
|
|
*
|
|
|
|
|
* # CSS nodes
|
|
|
|
|
*
|
2021-02-28 01:04:56 +00:00
|
|
|
|
* ```
|
2016-05-19 13:44:25 +00:00
|
|
|
|
* scale[.fine-tune][.marks-before][.marks-after]
|
2020-06-26 06:00:04 +00:00
|
|
|
|
* ├── [value][.top][.right][.bottom][.left]
|
2015-11-05 11:45:24 +00:00
|
|
|
|
* ├── marks.top
|
|
|
|
|
* │ ├── mark
|
2016-02-29 18:43:12 +00:00
|
|
|
|
* │ ┊ ├── [label]
|
|
|
|
|
* │ ┊ ╰── indicator
|
2015-12-16 15:55:52 +00:00
|
|
|
|
* ┊ ┊
|
|
|
|
|
* │ ╰── mark
|
2020-06-26 06:00:04 +00:00
|
|
|
|
* ├── marks.bottom
|
|
|
|
|
* │ ├── mark
|
|
|
|
|
* │ ┊ ├── indicator
|
|
|
|
|
* │ ┊ ╰── [label]
|
|
|
|
|
* ┊ ┊
|
|
|
|
|
* │ ╰── mark
|
|
|
|
|
* ╰── trough
|
|
|
|
|
* ├── [fill]
|
|
|
|
|
* ├── [highlight]
|
|
|
|
|
* ╰── slider
|
2021-02-28 01:04:56 +00:00
|
|
|
|
* ```
|
2015-11-04 04:11:52 +00:00
|
|
|
|
*
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* `GtkScale` has a main CSS node with name scale and a subnode for its contents,
|
2016-02-29 18:43:12 +00:00
|
|
|
|
* with subnodes named trough and slider.
|
2015-11-06 12:51:15 +00:00
|
|
|
|
*
|
|
|
|
|
* The main node gets the style class .fine-tune added when the scale is in
|
|
|
|
|
* 'fine-tuning' mode.
|
|
|
|
|
*
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* If the scale has an origin (see [method@Gtk.Scale.set_has_origin]), there is
|
|
|
|
|
* a subnode with name highlight below the trough node that is used for rendering
|
2015-11-07 00:38:50 +00:00
|
|
|
|
* the highlighted part of the trough.
|
|
|
|
|
*
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* If the scale is showing a fill level (see [method@Gtk.Range.set_show_fill_level]),
|
2015-11-07 00:38:50 +00:00
|
|
|
|
* there is a subnode with name fill below the trough node that is used for
|
|
|
|
|
* rendering the filled in part of the trough.
|
|
|
|
|
*
|
2017-05-07 14:44:13 +00:00
|
|
|
|
* If marks are present, there is a marks subnode before or after the trough
|
2015-11-06 12:51:15 +00:00
|
|
|
|
* node, below which each mark gets a node with name mark. The marks nodes get
|
|
|
|
|
* either the .top or .bottom style class.
|
2016-02-29 18:43:12 +00:00
|
|
|
|
*
|
|
|
|
|
* The mark node has a subnode named indicator. If the mark has text, it also
|
|
|
|
|
* has a subnode named label. When the mark is either above or left of the
|
|
|
|
|
* scale, the label subnode is the first when present. Otherwise, the indicator
|
|
|
|
|
* subnode is the first.
|
2016-05-18 16:59:39 +00:00
|
|
|
|
*
|
2016-05-19 13:44:25 +00:00
|
|
|
|
* The main CSS node gets the 'marks-before' and/or 'marks-after' style classes
|
|
|
|
|
* added depending on what marks are present.
|
2016-05-18 16:59:39 +00:00
|
|
|
|
*
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* If the scale is displaying the value (see [property@Gtk.Scale:draw-value]),
|
|
|
|
|
* there is subnode with name value. This node will get the .top or .bottom style
|
|
|
|
|
* classes similar to the marks node.
|
2020-07-27 14:46:52 +00:00
|
|
|
|
*
|
|
|
|
|
* # Accessibility
|
|
|
|
|
*
|
2021-02-28 01:04:56 +00:00
|
|
|
|
* `GtkScale` uses the %GTK_ACCESSIBLE_ROLE_SLIDER role.
|
2010-09-01 18:18:22 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2002-01-29 11:35:28 +00:00
|
|
|
|
#define MAX_DIGITS (64) /* don't change this,
|
|
|
|
|
* a) you don't need to and
|
|
|
|
|
* b) you might cause buffer owerflows in
|
|
|
|
|
* unrelated code portions otherwise
|
|
|
|
|
*/
|
|
|
|
|
|
2009-01-20 05:10:27 +00:00
|
|
|
|
typedef struct _GtkScaleMark GtkScaleMark;
|
|
|
|
|
|
2019-05-27 03:17:28 +00:00
|
|
|
|
typedef struct _GtkScalePrivate GtkScalePrivate;
|
2010-08-26 17:15:37 +00:00
|
|
|
|
struct _GtkScalePrivate
|
2010-07-08 02:04:24 +00:00
|
|
|
|
{
|
2012-01-15 19:09:54 +00:00
|
|
|
|
GSList *marks;
|
2010-07-08 02:04:24 +00:00
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
GtkWidget *value_widget;
|
|
|
|
|
GtkWidget *top_marks_widget;
|
|
|
|
|
GtkWidget *bottom_marks_widget;
|
2015-11-04 04:11:52 +00:00
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int digits;
|
2010-07-08 02:04:24 +00:00
|
|
|
|
|
2020-07-25 02:57:34 +00:00
|
|
|
|
guint draw_value : 1;
|
|
|
|
|
guint value_pos : 2;
|
|
|
|
|
|
2019-08-09 11:32:24 +00:00
|
|
|
|
GtkScaleFormatValueFunc format_value_func;
|
|
|
|
|
gpointer format_value_func_user_data;
|
2019-08-15 15:21:47 +00:00
|
|
|
|
GDestroyNotify format_value_func_destroy_notify;
|
2010-07-08 02:04:24 +00:00
|
|
|
|
};
|
|
|
|
|
|
2009-01-20 05:10:27 +00:00
|
|
|
|
struct _GtkScaleMark
|
|
|
|
|
{
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double value;
|
2016-02-28 21:45:48 +00:00
|
|
|
|
int stop_position;
|
2020-07-25 02:57:34 +00:00
|
|
|
|
GtkPositionType position; /* always GTK_POS_TOP or GTK_POS_BOTTOM */
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *markup;
|
2017-05-13 14:13:22 +00:00
|
|
|
|
GtkWidget *label_widget;
|
|
|
|
|
GtkWidget *indicator_widget;
|
|
|
|
|
GtkWidget *widget;
|
2009-01-20 05:10:27 +00:00
|
|
|
|
};
|
|
|
|
|
|
1999-01-18 19:42:59 +00:00
|
|
|
|
enum {
|
2001-05-13 22:41:30 +00:00
|
|
|
|
PROP_0,
|
|
|
|
|
PROP_DIGITS,
|
|
|
|
|
PROP_DRAW_VALUE,
|
2011-12-14 16:16:09 +00:00
|
|
|
|
PROP_HAS_ORIGIN,
|
2015-09-06 14:43:34 +00:00
|
|
|
|
PROP_VALUE_POS,
|
|
|
|
|
LAST_PROP
|
1999-01-18 19:42:59 +00:00
|
|
|
|
};
|
|
|
|
|
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
2015-09-06 14:43:34 +00:00
|
|
|
|
static GParamSpec *properties[LAST_PROP];
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2008-11-11 17:47:13 +00:00
|
|
|
|
static void gtk_scale_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
static void gtk_scale_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
2016-10-22 14:06:14 +00:00
|
|
|
|
static void gtk_scale_measure (GtkWidget *widget,
|
|
|
|
|
GtkOrientation orientation,
|
|
|
|
|
int for_size,
|
|
|
|
|
int *minimum,
|
|
|
|
|
int *natural,
|
|
|
|
|
int *minimum_baseline,
|
|
|
|
|
int *natural_baseline);
|
2008-11-11 17:47:13 +00:00
|
|
|
|
static void gtk_scale_get_range_border (GtkRange *range,
|
|
|
|
|
GtkBorder *border);
|
|
|
|
|
static void gtk_scale_finalize (GObject *object);
|
|
|
|
|
static void gtk_scale_real_get_layout_offsets (GtkScale *scale,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int *x,
|
|
|
|
|
int *y);
|
2019-08-29 13:21:20 +00:00
|
|
|
|
static void gtk_scale_buildable_interface_init (GtkBuildableIface *iface);
|
|
|
|
|
static gboolean gtk_scale_buildable_custom_tag_start (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *tagname,
|
2019-08-29 13:21:20 +00:00
|
|
|
|
GtkBuildableParser *parser,
|
|
|
|
|
gpointer *data);
|
|
|
|
|
static void gtk_scale_buildable_custom_finished (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *tagname,
|
2019-08-29 13:21:20 +00:00
|
|
|
|
gpointer user_data);
|
2020-07-24 18:40:36 +00:00
|
|
|
|
static char * gtk_scale_format_value (GtkScale *scale,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double value);
|
2009-05-03 01:02:12 +00:00
|
|
|
|
|
|
|
|
|
|
2010-05-25 22:55:15 +00:00
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkScale, gtk_scale, GTK_TYPE_RANGE,
|
2013-06-27 19:02:52 +00:00
|
|
|
|
G_ADD_PRIVATE (GtkScale)
|
2010-05-25 22:55:15 +00:00
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
|
|
|
|
gtk_scale_buildable_interface_init))
|
2008-11-11 17:47:13 +00:00
|
|
|
|
|
2020-07-24 13:54:49 +00:00
|
|
|
|
static int
|
2012-01-15 19:09:54 +00:00
|
|
|
|
compare_marks (gconstpointer a, gconstpointer b, gpointer data)
|
|
|
|
|
{
|
|
|
|
|
gboolean inverted = GPOINTER_TO_INT (data);
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int val;
|
2012-01-15 19:09:54 +00:00
|
|
|
|
const GtkScaleMark *ma, *mb;
|
|
|
|
|
|
|
|
|
|
val = inverted ? -1 : 1;
|
|
|
|
|
|
|
|
|
|
ma = a; mb = b;
|
|
|
|
|
|
|
|
|
|
return (ma->value > mb->value) ? val : ((ma->value < mb->value) ? -val : 0);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
static void
|
|
|
|
|
update_label_request (GtkScale *scale)
|
|
|
|
|
{
|
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
|
|
|
|
GtkAdjustment *adjustment = gtk_range_get_adjustment (GTK_RANGE (scale));
|
|
|
|
|
double lowest_value, highest_value;
|
|
|
|
|
char *text;
|
|
|
|
|
int size = 0;
|
|
|
|
|
int min;
|
|
|
|
|
|
|
|
|
|
g_assert (priv->value_widget != NULL);
|
|
|
|
|
|
|
|
|
|
lowest_value = gtk_adjustment_get_lower (adjustment);
|
|
|
|
|
highest_value = gtk_adjustment_get_upper (adjustment);
|
|
|
|
|
|
2019-08-09 12:26:57 +00:00
|
|
|
|
gtk_widget_set_size_request (priv->value_widget, -1, -1);
|
2017-05-13 14:13:22 +00:00
|
|
|
|
|
|
|
|
|
text = gtk_scale_format_value (scale, lowest_value);
|
|
|
|
|
gtk_label_set_label (GTK_LABEL (priv->value_widget), text);
|
|
|
|
|
|
|
|
|
|
gtk_widget_measure (priv->value_widget, GTK_ORIENTATION_HORIZONTAL, -1,
|
|
|
|
|
&min, NULL, NULL, NULL);
|
|
|
|
|
size = MAX (size, min);
|
|
|
|
|
g_free (text);
|
|
|
|
|
|
|
|
|
|
text = gtk_scale_format_value (scale, highest_value);
|
|
|
|
|
gtk_label_set_label (GTK_LABEL (priv->value_widget), text);
|
|
|
|
|
|
|
|
|
|
gtk_widget_measure (priv->value_widget, GTK_ORIENTATION_HORIZONTAL, -1,
|
|
|
|
|
&min, NULL, NULL, NULL);
|
|
|
|
|
size = MAX (size, min);
|
|
|
|
|
g_free (text);
|
|
|
|
|
|
2022-09-06 17:27:38 +00:00
|
|
|
|
text = gtk_scale_format_value (scale, gtk_adjustment_get_value (adjustment));
|
2017-05-13 14:13:22 +00:00
|
|
|
|
gtk_widget_set_size_request (priv->value_widget, size, -1);
|
2022-09-06 17:27:38 +00:00
|
|
|
|
gtk_label_set_label (GTK_LABEL (priv->value_widget), text);
|
|
|
|
|
g_free (text);
|
2017-05-13 14:13:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-01-15 19:09:54 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_scale_notify (GObject *object,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScale *scale = GTK_SCALE (object);
|
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
|
|
|
|
|
2014-11-21 06:26:19 +00:00
|
|
|
|
if (strcmp (pspec->name, "inverted") == 0)
|
2012-01-15 19:09:54 +00:00
|
|
|
|
{
|
2012-01-18 05:57:20 +00:00
|
|
|
|
GtkScaleMark *mark;
|
|
|
|
|
GSList *m;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int i, n;
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double *values;
|
2012-01-15 19:09:54 +00:00
|
|
|
|
|
2018-02-27 11:39:04 +00:00
|
|
|
|
priv->marks = g_slist_sort_with_data (priv->marks,
|
|
|
|
|
compare_marks,
|
|
|
|
|
GINT_TO_POINTER (gtk_range_get_inverted (GTK_RANGE (scale))));
|
2012-01-18 05:57:20 +00:00
|
|
|
|
|
2018-02-27 11:39:04 +00:00
|
|
|
|
n = g_slist_length (priv->marks);
|
2020-07-24 20:32:16 +00:00
|
|
|
|
values = g_new (double, n);
|
2018-02-27 11:39:04 +00:00
|
|
|
|
for (m = priv->marks, i = 0; m; m = m->next, i++)
|
2012-01-18 05:57:20 +00:00
|
|
|
|
{
|
|
|
|
|
mark = m->data;
|
|
|
|
|
values[i] = mark->value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_gtk_range_set_stop_values (GTK_RANGE (scale), values, n);
|
|
|
|
|
|
2019-08-09 17:36:01 +00:00
|
|
|
|
if (priv->top_marks_widget)
|
|
|
|
|
gtk_widget_queue_resize (priv->top_marks_widget);
|
|
|
|
|
|
|
|
|
|
if (priv->bottom_marks_widget)
|
|
|
|
|
gtk_widget_queue_resize (priv->bottom_marks_widget);
|
|
|
|
|
|
2012-01-18 05:57:20 +00:00
|
|
|
|
g_free (values);
|
2012-01-15 19:09:54 +00:00
|
|
|
|
}
|
2017-05-13 14:13:22 +00:00
|
|
|
|
else if (strcmp (pspec->name, "adjustment"))
|
|
|
|
|
{
|
2018-02-27 11:39:04 +00:00
|
|
|
|
if (priv->value_widget)
|
2017-05-13 14:13:22 +00:00
|
|
|
|
update_label_request (scale);
|
|
|
|
|
}
|
2012-01-16 23:05:44 +00:00
|
|
|
|
|
|
|
|
|
if (G_OBJECT_CLASS (gtk_scale_parent_class)->notify)
|
2012-01-15 19:09:54 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_scale_parent_class)->notify (object, pspec);
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-06 05:08:47 +00:00
|
|
|
|
static void
|
2018-03-31 19:02:28 +00:00
|
|
|
|
gtk_scale_allocate_value (GtkScale *scale)
|
2016-03-06 05:08:47 +00:00
|
|
|
|
{
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
2016-03-06 05:08:47 +00:00
|
|
|
|
GtkWidget *widget = GTK_WIDGET (scale);
|
|
|
|
|
GtkRange *range = GTK_RANGE (widget);
|
2017-05-07 19:39:37 +00:00
|
|
|
|
GtkWidget *slider_widget;
|
2018-04-07 11:37:24 +00:00
|
|
|
|
GtkAllocation value_alloc;
|
2017-08-14 10:12:09 +00:00
|
|
|
|
int range_width, range_height;
|
2018-04-07 11:37:24 +00:00
|
|
|
|
graphene_rect_t slider_bounds;
|
2016-03-06 05:08:47 +00:00
|
|
|
|
|
2017-12-04 11:42:52 +00:00
|
|
|
|
range_width = gtk_widget_get_width (widget);
|
|
|
|
|
range_height = gtk_widget_get_height (widget);
|
2016-03-06 05:08:47 +00:00
|
|
|
|
|
2017-05-07 19:39:37 +00:00
|
|
|
|
slider_widget = gtk_range_get_slider_widget (range);
|
2019-02-20 03:53:47 +00:00
|
|
|
|
if (!gtk_widget_compute_bounds (slider_widget, widget, &slider_bounds))
|
|
|
|
|
graphene_rect_init (&slider_bounds, 0, 0, gtk_widget_get_width (widget), gtk_widget_get_height (widget));
|
2016-03-06 05:08:47 +00:00
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
gtk_widget_measure (priv->value_widget,
|
|
|
|
|
GTK_ORIENTATION_HORIZONTAL, -1,
|
|
|
|
|
&value_alloc.width, NULL,
|
|
|
|
|
NULL, NULL);
|
|
|
|
|
gtk_widget_measure (priv->value_widget,
|
|
|
|
|
GTK_ORIENTATION_VERTICAL, -1,
|
|
|
|
|
&value_alloc.height, NULL,
|
|
|
|
|
NULL, NULL);
|
2016-03-06 05:08:47 +00:00
|
|
|
|
|
|
|
|
|
if (gtk_orientable_get_orientation (GTK_ORIENTABLE (range)) == GTK_ORIENTATION_HORIZONTAL)
|
|
|
|
|
{
|
|
|
|
|
switch (priv->value_pos)
|
|
|
|
|
{
|
|
|
|
|
case GTK_POS_LEFT:
|
2017-06-16 16:16:27 +00:00
|
|
|
|
value_alloc.x = 0;
|
2017-08-14 10:12:09 +00:00
|
|
|
|
value_alloc.y = (range_height - value_alloc.height) / 2;
|
2016-03-06 05:08:47 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GTK_POS_RIGHT:
|
2017-08-14 10:12:09 +00:00
|
|
|
|
value_alloc.x = range_width - value_alloc.width;
|
|
|
|
|
value_alloc.y = (range_height - value_alloc.height) / 2;
|
2016-03-06 05:08:47 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GTK_POS_TOP:
|
2018-04-07 11:37:24 +00:00
|
|
|
|
value_alloc.x = slider_bounds.origin.x + (slider_bounds.size.width - value_alloc.width) / 2;
|
2019-08-26 16:58:42 +00:00
|
|
|
|
value_alloc.y = slider_bounds.origin.y - value_alloc.height;
|
2016-03-06 05:08:47 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GTK_POS_BOTTOM:
|
2018-04-07 11:37:24 +00:00
|
|
|
|
value_alloc.x = slider_bounds.origin.x + (slider_bounds.size.width - value_alloc.width) / 2;
|
2017-08-14 10:12:09 +00:00
|
|
|
|
value_alloc.y = range_height - value_alloc.height;
|
2016-03-06 05:08:47 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
g_return_if_reached ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-08-01 09:34:23 +00:00
|
|
|
|
else /* VERTICAL */
|
2016-03-06 05:08:47 +00:00
|
|
|
|
{
|
|
|
|
|
switch (priv->value_pos)
|
|
|
|
|
{
|
|
|
|
|
case GTK_POS_LEFT:
|
2017-06-16 16:16:27 +00:00
|
|
|
|
value_alloc.x = 0;
|
2018-04-07 11:37:24 +00:00
|
|
|
|
value_alloc.y = (slider_bounds.origin.y + (slider_bounds.size.height / 2)) - value_alloc.height / 2;
|
2016-03-06 05:08:47 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GTK_POS_RIGHT:
|
2017-08-14 10:12:09 +00:00
|
|
|
|
value_alloc.x = range_width - value_alloc.width;
|
2018-04-07 11:37:24 +00:00
|
|
|
|
value_alloc.y = (slider_bounds.origin.y + (slider_bounds.size.height / 2)) - value_alloc.height / 2;
|
2016-03-06 05:08:47 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GTK_POS_TOP:
|
2017-08-14 10:12:09 +00:00
|
|
|
|
value_alloc.x = (range_width - value_alloc.width) / 2;
|
2017-06-16 16:16:27 +00:00
|
|
|
|
value_alloc.y = 0;
|
2016-03-06 05:08:47 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GTK_POS_BOTTOM:
|
2017-08-14 10:12:09 +00:00
|
|
|
|
value_alloc.x = (range_width - value_alloc.width) / 2;
|
|
|
|
|
value_alloc.y = range_height - value_alloc.height;
|
2016-03-06 05:08:47 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
g_return_if_reached ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-31 19:02:28 +00:00
|
|
|
|
gtk_widget_size_allocate (priv->value_widget, &value_alloc, -1);
|
2016-03-06 05:08:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-29 05:13:54 +00:00
|
|
|
|
static void
|
2018-08-16 04:53:03 +00:00
|
|
|
|
gtk_scale_allocate_mark (GtkGizmo *gizmo,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
int baseline)
|
2016-02-29 05:13:54 +00:00
|
|
|
|
{
|
2017-05-13 14:13:22 +00:00
|
|
|
|
GtkWidget *widget = GTK_WIDGET (gizmo);
|
|
|
|
|
GtkScale *scale = GTK_SCALE (gtk_widget_get_parent (gtk_widget_get_parent (widget)));
|
|
|
|
|
GtkScaleMark *mark = g_object_get_data (G_OBJECT (gizmo), "mark");
|
2016-02-29 05:13:54 +00:00
|
|
|
|
int indicator_width, indicator_height;
|
2017-05-13 14:13:22 +00:00
|
|
|
|
GtkAllocation indicator_alloc;
|
2016-02-29 05:13:54 +00:00
|
|
|
|
GtkOrientation orientation;
|
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (scale));
|
|
|
|
|
gtk_widget_measure (mark->indicator_widget,
|
|
|
|
|
GTK_ORIENTATION_HORIZONTAL, -1,
|
|
|
|
|
&indicator_width, NULL,
|
|
|
|
|
NULL, NULL);
|
|
|
|
|
gtk_widget_measure (mark->indicator_widget,
|
|
|
|
|
GTK_ORIENTATION_VERTICAL, -1,
|
|
|
|
|
&indicator_height, NULL,
|
|
|
|
|
NULL, NULL);
|
2016-02-29 05:13:54 +00:00
|
|
|
|
|
|
|
|
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
|
|
|
{
|
2018-08-16 04:53:03 +00:00
|
|
|
|
indicator_alloc.x = (width - indicator_width) / 2;
|
2016-02-29 05:13:54 +00:00
|
|
|
|
if (mark->position == GTK_POS_TOP)
|
2018-08-16 04:53:03 +00:00
|
|
|
|
indicator_alloc.y = height - indicator_height;
|
2016-02-29 05:13:54 +00:00
|
|
|
|
else
|
2018-08-16 04:53:03 +00:00
|
|
|
|
indicator_alloc.y = 0;
|
|
|
|
|
|
2016-02-29 05:13:54 +00:00
|
|
|
|
indicator_alloc.width = indicator_width;
|
|
|
|
|
indicator_alloc.height = indicator_height;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (mark->position == GTK_POS_TOP)
|
2018-08-16 04:53:03 +00:00
|
|
|
|
indicator_alloc.x = width - indicator_width;
|
2016-02-29 05:13:54 +00:00
|
|
|
|
else
|
2018-08-16 04:53:03 +00:00
|
|
|
|
indicator_alloc.x = 0;
|
|
|
|
|
indicator_alloc.y = (height - indicator_height) / 2;
|
2016-02-29 05:13:54 +00:00
|
|
|
|
indicator_alloc.width = indicator_width;
|
|
|
|
|
indicator_alloc.height = indicator_height;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-31 19:02:28 +00:00
|
|
|
|
gtk_widget_size_allocate (mark->indicator_widget, &indicator_alloc, baseline);
|
2016-02-29 05:13:54 +00:00
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if (mark->label_widget)
|
2016-02-29 05:13:54 +00:00
|
|
|
|
{
|
2018-03-31 19:02:28 +00:00
|
|
|
|
GtkAllocation label_alloc;
|
2016-02-29 05:13:54 +00:00
|
|
|
|
|
2018-08-16 04:53:03 +00:00
|
|
|
|
label_alloc = (GtkAllocation) {0, 0, width, height};
|
2016-02-29 05:13:54 +00:00
|
|
|
|
|
|
|
|
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
|
|
|
{
|
2018-08-16 04:53:03 +00:00
|
|
|
|
label_alloc.height = height - indicator_alloc.height;
|
2016-02-29 05:13:54 +00:00
|
|
|
|
if (mark->position == GTK_POS_BOTTOM)
|
|
|
|
|
label_alloc.y = indicator_alloc.y + indicator_alloc.height;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-08-16 04:53:03 +00:00
|
|
|
|
label_alloc.width = width - indicator_alloc.width;
|
2016-02-29 05:13:54 +00:00
|
|
|
|
if (mark->position == GTK_POS_BOTTOM)
|
|
|
|
|
label_alloc.x = indicator_alloc.x + indicator_alloc.width;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-31 19:02:28 +00:00
|
|
|
|
gtk_widget_size_allocate (mark->label_widget, &label_alloc, baseline);
|
2016-02-29 05:13:54 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-28 21:45:48 +00:00
|
|
|
|
static void
|
2018-08-16 04:53:03 +00:00
|
|
|
|
gtk_scale_allocate_marks (GtkGizmo *gizmo,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
int baseline)
|
2016-02-28 21:45:48 +00:00
|
|
|
|
{
|
2017-05-13 14:13:22 +00:00
|
|
|
|
GtkWidget *widget = GTK_WIDGET (gizmo);
|
|
|
|
|
GtkScale *scale = GTK_SCALE (gtk_widget_get_parent (widget));
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
2016-02-28 21:45:48 +00:00
|
|
|
|
GtkOrientation orientation;
|
|
|
|
|
int *marks;
|
|
|
|
|
int i;
|
|
|
|
|
GSList *m;
|
|
|
|
|
|
|
|
|
|
orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (scale));
|
|
|
|
|
_gtk_range_get_stop_positions (GTK_RANGE (scale), &marks);
|
|
|
|
|
|
|
|
|
|
for (m = priv->marks, i = 0; m; m = m->next, i++)
|
|
|
|
|
{
|
|
|
|
|
GtkScaleMark *mark = m->data;
|
2018-03-31 19:02:28 +00:00
|
|
|
|
GtkAllocation mark_alloc;
|
2016-02-28 21:45:48 +00:00
|
|
|
|
int mark_size;
|
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if ((mark->position == GTK_POS_TOP && widget == priv->bottom_marks_widget) ||
|
|
|
|
|
(mark->position == GTK_POS_BOTTOM && widget == priv->top_marks_widget))
|
2016-02-28 21:45:48 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
gtk_widget_measure (mark->widget,
|
|
|
|
|
orientation, -1,
|
|
|
|
|
&mark_size, NULL,
|
|
|
|
|
NULL, NULL);
|
2016-02-28 21:45:48 +00:00
|
|
|
|
mark->stop_position = marks[i];
|
|
|
|
|
|
|
|
|
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
|
|
|
{
|
2017-05-13 14:13:22 +00:00
|
|
|
|
mark_alloc.x = mark->stop_position;
|
2018-08-16 04:53:03 +00:00
|
|
|
|
mark_alloc.y = 0;
|
2016-02-28 21:45:48 +00:00
|
|
|
|
mark_alloc.width = mark_size;
|
2018-08-16 04:53:03 +00:00
|
|
|
|
mark_alloc.height = height;
|
2016-02-28 21:45:48 +00:00
|
|
|
|
|
|
|
|
|
mark_alloc.x -= mark_size / 2;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-08-16 04:53:03 +00:00
|
|
|
|
mark_alloc.x = 0;
|
2017-05-13 14:13:22 +00:00
|
|
|
|
mark_alloc.y = mark->stop_position;
|
2018-08-16 04:53:03 +00:00
|
|
|
|
mark_alloc.width = width;
|
2016-02-28 21:45:48 +00:00
|
|
|
|
mark_alloc.height = mark_size;
|
|
|
|
|
|
|
|
|
|
mark_alloc.y -= mark_size / 2;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-31 19:02:28 +00:00
|
|
|
|
gtk_widget_size_allocate (mark->widget, &mark_alloc, baseline);
|
2016-02-28 21:45:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_free (marks);
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-28 08:12:22 +00:00
|
|
|
|
static void
|
2018-08-16 04:53:03 +00:00
|
|
|
|
gtk_scale_size_allocate (GtkWidget *widget,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
int baseline)
|
2016-02-28 08:12:22 +00:00
|
|
|
|
{
|
|
|
|
|
GtkScale *scale = GTK_SCALE (widget);
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
2018-03-31 19:02:28 +00:00
|
|
|
|
GtkAllocation range_rect, marks_rect;
|
2016-02-28 08:12:22 +00:00
|
|
|
|
GtkOrientation orientation;
|
|
|
|
|
|
2018-08-16 04:53:03 +00:00
|
|
|
|
GTK_WIDGET_CLASS (gtk_scale_parent_class)->size_allocate (widget, width, height, baseline);
|
2016-02-28 08:12:22 +00:00
|
|
|
|
|
|
|
|
|
orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget));
|
|
|
|
|
gtk_range_get_range_rect (GTK_RANGE (scale), &range_rect);
|
|
|
|
|
|
|
|
|
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
|
|
|
{
|
|
|
|
|
int marks_height = 0;
|
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if (priv->top_marks_widget)
|
2016-02-28 08:12:22 +00:00
|
|
|
|
{
|
2017-05-13 14:13:22 +00:00
|
|
|
|
gtk_widget_measure (priv->top_marks_widget,
|
|
|
|
|
GTK_ORIENTATION_VERTICAL, -1,
|
|
|
|
|
&marks_height, NULL,
|
|
|
|
|
NULL, NULL);
|
2018-01-10 08:29:05 +00:00
|
|
|
|
marks_rect.x = 0;
|
2017-06-30 11:40:23 +00:00
|
|
|
|
marks_rect.y = 0;
|
2018-01-10 08:29:05 +00:00
|
|
|
|
marks_rect.width = range_rect.width;
|
2016-02-28 08:12:22 +00:00
|
|
|
|
marks_rect.height = marks_height;
|
2018-03-31 19:02:28 +00:00
|
|
|
|
gtk_widget_size_allocate (priv->top_marks_widget, &marks_rect, -1);
|
2016-02-28 08:12:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if (priv->bottom_marks_widget)
|
2016-02-28 08:12:22 +00:00
|
|
|
|
{
|
2017-05-13 14:13:22 +00:00
|
|
|
|
gtk_widget_measure (priv->bottom_marks_widget,
|
|
|
|
|
GTK_ORIENTATION_VERTICAL, -1,
|
|
|
|
|
&marks_height, NULL,
|
|
|
|
|
NULL, NULL);
|
2018-01-10 08:29:05 +00:00
|
|
|
|
marks_rect.x = 0;
|
|
|
|
|
marks_rect.y = range_rect.y + range_rect.height;
|
|
|
|
|
marks_rect.width = range_rect.width;
|
2016-02-28 08:12:22 +00:00
|
|
|
|
marks_rect.height = marks_height;
|
2018-03-31 19:02:28 +00:00
|
|
|
|
gtk_widget_size_allocate (priv->bottom_marks_widget, &marks_rect, -1);
|
2016-02-28 08:12:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int marks_width = 0;
|
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if (priv->top_marks_widget)
|
2016-02-28 08:12:22 +00:00
|
|
|
|
{
|
2017-05-13 14:13:22 +00:00
|
|
|
|
gtk_widget_measure (priv->top_marks_widget,
|
|
|
|
|
GTK_ORIENTATION_HORIZONTAL, -1,
|
|
|
|
|
&marks_width, NULL,
|
|
|
|
|
NULL, NULL);
|
2019-08-09 08:35:10 +00:00
|
|
|
|
marks_rect.x = range_rect.x - marks_width;
|
2018-01-10 08:29:05 +00:00
|
|
|
|
marks_rect.y = 0;
|
2016-02-28 08:12:22 +00:00
|
|
|
|
marks_rect.width = marks_width;
|
2019-08-09 08:33:43 +00:00
|
|
|
|
marks_rect.height = range_rect.height;
|
2018-03-31 19:02:28 +00:00
|
|
|
|
gtk_widget_size_allocate (priv->top_marks_widget, &marks_rect, -1);
|
2016-02-28 08:12:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if (priv->bottom_marks_widget)
|
2016-02-28 08:12:22 +00:00
|
|
|
|
{
|
2017-05-13 14:13:22 +00:00
|
|
|
|
gtk_widget_measure (priv->bottom_marks_widget,
|
|
|
|
|
GTK_ORIENTATION_HORIZONTAL, -1,
|
|
|
|
|
&marks_width, NULL,
|
|
|
|
|
NULL, NULL);
|
2016-02-28 08:12:22 +00:00
|
|
|
|
marks_rect = range_rect;
|
2018-01-10 08:29:05 +00:00
|
|
|
|
marks_rect.x = range_rect.x + range_rect.width;
|
|
|
|
|
marks_rect.y = 0;
|
2016-02-28 08:12:22 +00:00
|
|
|
|
marks_rect.width = marks_width;
|
2018-01-10 08:29:05 +00:00
|
|
|
|
marks_rect.height = range_rect.height;
|
2018-03-31 19:02:28 +00:00
|
|
|
|
gtk_widget_size_allocate (priv->bottom_marks_widget, &marks_rect, -1);
|
2016-02-28 08:12:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if (priv->value_widget)
|
2016-03-06 05:08:47 +00:00
|
|
|
|
{
|
2018-03-31 19:02:28 +00:00
|
|
|
|
gtk_scale_allocate_value (scale);
|
2016-03-06 05:08:47 +00:00
|
|
|
|
}
|
2016-02-28 08:12:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-12 13:53:45 +00:00
|
|
|
|
#define add_slider_binding(binding_set, keyval, mask, scroll) \
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class, \
|
|
|
|
|
keyval, mask, \
|
|
|
|
|
I_("move-slider"), \
|
|
|
|
|
"(i)", scroll)
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_scale_value_changed (GtkRange *range)
|
|
|
|
|
{
|
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (GTK_SCALE (range));
|
|
|
|
|
GtkAdjustment *adjustment = gtk_range_get_adjustment (range);
|
|
|
|
|
|
|
|
|
|
if (priv->value_widget)
|
|
|
|
|
{
|
|
|
|
|
char *text = gtk_scale_format_value (GTK_SCALE (range),
|
|
|
|
|
gtk_adjustment_get_value (adjustment));
|
|
|
|
|
gtk_label_set_label (GTK_LABEL (priv->value_widget), text);
|
|
|
|
|
|
|
|
|
|
g_free (text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_scale_class_init (GtkScaleClass *class)
|
|
|
|
|
{
|
2001-05-13 22:41:30 +00:00
|
|
|
|
GObjectClass *gobject_class;
|
1998-11-06 22:05:02 +00:00
|
|
|
|
GtkWidgetClass *widget_class;
|
2002-10-04 22:49:28 +00:00
|
|
|
|
GtkRangeClass *range_class;
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
|
2001-05-13 22:41:30 +00:00
|
|
|
|
gobject_class = G_OBJECT_CLASS (class);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
range_class = (GtkRangeClass*) class;
|
1998-11-06 22:05:02 +00:00
|
|
|
|
widget_class = (GtkWidgetClass*) class;
|
1999-01-18 19:42:59 +00:00
|
|
|
|
|
2001-05-15 14:14:19 +00:00
|
|
|
|
gobject_class->set_property = gtk_scale_set_property;
|
|
|
|
|
gobject_class->get_property = gtk_scale_get_property;
|
2012-01-15 19:09:54 +00:00
|
|
|
|
gobject_class->notify = gtk_scale_notify;
|
2004-02-12 23:58:46 +00:00
|
|
|
|
gobject_class->finalize = gtk_scale_finalize;
|
2001-05-15 14:14:19 +00:00
|
|
|
|
|
2016-02-28 08:12:22 +00:00
|
|
|
|
widget_class->size_allocate = gtk_scale_size_allocate;
|
2016-10-22 14:06:14 +00:00
|
|
|
|
widget_class->measure = gtk_scale_measure;
|
2020-04-08 11:43:28 +00:00
|
|
|
|
widget_class->grab_focus = gtk_widget_grab_focus_self;
|
|
|
|
|
widget_class->focus = gtk_widget_focus_self;
|
2001-05-15 14:14:19 +00:00
|
|
|
|
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
range_class->get_range_border = gtk_scale_get_range_border;
|
2017-05-13 14:13:22 +00:00
|
|
|
|
range_class->value_changed = gtk_scale_value_changed;
|
2008-11-11 17:47:13 +00:00
|
|
|
|
|
|
|
|
|
class->get_layout_offsets = gtk_scale_real_get_layout_offsets;
|
|
|
|
|
|
2021-02-20 04:31:23 +00:00
|
|
|
|
/**
|
2021-02-25 02:57:55 +00:00
|
|
|
|
* GtkScale:digits: (attributes org.gtk.Method.get=gtk_scale_get_digits org.gtk.Method.set=gtk_scale_set_digits)
|
2021-02-20 04:31:23 +00:00
|
|
|
|
*
|
|
|
|
|
* The number of decimal places that are displayed in the value.
|
|
|
|
|
*/
|
2015-09-06 14:43:34 +00:00
|
|
|
|
properties[PROP_DIGITS] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_int ("digits", NULL, NULL,
|
2015-09-06 14:43:34 +00:00
|
|
|
|
-1, MAX_DIGITS,
|
|
|
|
|
1,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
|
2021-02-20 04:31:23 +00:00
|
|
|
|
/**
|
2021-02-25 02:57:55 +00:00
|
|
|
|
* GtkScale:draw-value: (attributes org.gtk.Method.get=gtk_scale_get_draw_value org.gtk.Method.set=gtk_scale_set_draw_value)
|
2021-02-20 04:31:23 +00:00
|
|
|
|
*
|
|
|
|
|
* Whether the current value is displayed as a string next to the slider.
|
|
|
|
|
*/
|
2015-09-06 14:43:34 +00:00
|
|
|
|
properties[PROP_DRAW_VALUE] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_boolean ("draw-value", NULL, NULL,
|
2020-10-04 00:08:29 +00:00
|
|
|
|
FALSE,
|
2015-09-06 14:43:34 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
|
2021-02-20 04:31:23 +00:00
|
|
|
|
/**
|
2021-02-25 02:57:55 +00:00
|
|
|
|
* GtkScale:has-origin: (attributes org.gtk.Method.get=gtk_scale_get_has_origin org.gtk.Method.set=gtk_scale_set_has_origin)
|
2021-02-20 04:31:23 +00:00
|
|
|
|
*
|
|
|
|
|
* Whether the scale has an origin.
|
|
|
|
|
*/
|
2015-09-06 14:43:34 +00:00
|
|
|
|
properties[PROP_HAS_ORIGIN] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_boolean ("has-origin", NULL, NULL,
|
2015-09-06 14:43:34 +00:00
|
|
|
|
TRUE,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
|
2021-02-20 04:31:23 +00:00
|
|
|
|
/**
|
2021-02-25 02:57:55 +00:00
|
|
|
|
* GtkScale:value-pos: (attributes org.gtk.Method.get=gtk_scale_get_value_pos org.gtk.Method.set=gtk_scale_set_value_pos)
|
2021-02-20 04:31:23 +00:00
|
|
|
|
*
|
|
|
|
|
* The position in which the current value is displayed.
|
|
|
|
|
*/
|
2015-09-06 14:43:34 +00:00
|
|
|
|
properties[PROP_VALUE_POS] =
|
2022-05-11 12:19:39 +00:00
|
|
|
|
g_param_spec_enum ("value-pos", NULL, NULL,
|
2015-09-06 14:43:34 +00:00
|
|
|
|
GTK_TYPE_POSITION_TYPE,
|
|
|
|
|
GTK_POS_TOP,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
|
|
|
|
|
g_object_class_install_properties (gobject_class, LAST_PROP, properties);
|
1999-01-18 19:42:59 +00:00
|
|
|
|
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
/* All bindings (even arrow keys) are on both h/v scale, because
|
|
|
|
|
* blind users etc. don't care about scale orientation.
|
|
|
|
|
*/
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_Left, 0,
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GTK_SCROLL_STEP_LEFT);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_Left, GDK_CONTROL_MASK,
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GTK_SCROLL_PAGE_LEFT);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_KP_Left, 0,
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GTK_SCROLL_STEP_LEFT);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_KP_Left, GDK_CONTROL_MASK,
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GTK_SCROLL_PAGE_LEFT);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_Right, 0,
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GTK_SCROLL_STEP_RIGHT);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_Right, GDK_CONTROL_MASK,
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GTK_SCROLL_PAGE_RIGHT);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_KP_Right, 0,
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GTK_SCROLL_STEP_RIGHT);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_KP_Right, GDK_CONTROL_MASK,
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GTK_SCROLL_PAGE_RIGHT);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_Up, 0,
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GTK_SCROLL_STEP_UP);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_Up, GDK_CONTROL_MASK,
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GTK_SCROLL_PAGE_UP);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_KP_Up, 0,
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GTK_SCROLL_STEP_UP);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_KP_Up, GDK_CONTROL_MASK,
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GTK_SCROLL_PAGE_UP);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_Down, 0,
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GTK_SCROLL_STEP_DOWN);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_Down, GDK_CONTROL_MASK,
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GTK_SCROLL_PAGE_DOWN);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_KP_Down, 0,
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GTK_SCROLL_STEP_DOWN);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_KP_Down, GDK_CONTROL_MASK,
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GTK_SCROLL_PAGE_DOWN);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_Page_Up, GDK_CONTROL_MASK,
|
2001-06-06 20:39:02 +00:00
|
|
|
|
GTK_SCROLL_PAGE_LEFT);
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_KP_Page_Up, GDK_CONTROL_MASK,
|
2001-06-06 20:39:02 +00:00
|
|
|
|
GTK_SCROLL_PAGE_LEFT);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_Page_Up, 0,
|
2001-06-06 20:39:02 +00:00
|
|
|
|
GTK_SCROLL_PAGE_UP);
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_KP_Page_Up, 0,
|
2001-06-06 20:39:02 +00:00
|
|
|
|
GTK_SCROLL_PAGE_UP);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_Page_Down, GDK_CONTROL_MASK,
|
2001-06-06 20:39:02 +00:00
|
|
|
|
GTK_SCROLL_PAGE_RIGHT);
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_KP_Page_Down, GDK_CONTROL_MASK,
|
2001-06-06 20:39:02 +00:00
|
|
|
|
GTK_SCROLL_PAGE_RIGHT);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_Page_Down, 0,
|
2001-06-06 20:39:02 +00:00
|
|
|
|
GTK_SCROLL_PAGE_DOWN);
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_KP_Page_Down, 0,
|
2001-06-06 20:39:02 +00:00
|
|
|
|
GTK_SCROLL_PAGE_DOWN);
|
|
|
|
|
|
|
|
|
|
/* Logical bindings (vs. visual bindings above) */
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_plus, 0,
|
2001-06-06 20:39:02 +00:00
|
|
|
|
GTK_SCROLL_STEP_FORWARD);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_minus, 0,
|
2001-06-06 20:39:02 +00:00
|
|
|
|
GTK_SCROLL_STEP_BACKWARD);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_plus, GDK_CONTROL_MASK,
|
2001-06-06 20:39:02 +00:00
|
|
|
|
GTK_SCROLL_PAGE_FORWARD);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_minus, GDK_CONTROL_MASK,
|
2001-06-06 20:39:02 +00:00
|
|
|
|
GTK_SCROLL_PAGE_BACKWARD);
|
|
|
|
|
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_KP_Add, 0,
|
2001-06-06 20:39:02 +00:00
|
|
|
|
GTK_SCROLL_STEP_FORWARD);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_KP_Subtract, 0,
|
2001-06-06 20:39:02 +00:00
|
|
|
|
GTK_SCROLL_STEP_BACKWARD);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_KP_Add, GDK_CONTROL_MASK,
|
2001-06-06 20:39:02 +00:00
|
|
|
|
GTK_SCROLL_PAGE_FORWARD);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_KP_Subtract, GDK_CONTROL_MASK,
|
2001-06-06 20:39:02 +00:00
|
|
|
|
GTK_SCROLL_PAGE_BACKWARD);
|
2020-05-05 18:57:21 +00:00
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_Home, 0,
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GTK_SCROLL_START);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_KP_Home, 0,
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GTK_SCROLL_START);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_End, 0,
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GTK_SCROLL_END);
|
|
|
|
|
|
2010-09-08 17:35:51 +00:00
|
|
|
|
add_slider_binding (binding_set, GDK_KEY_KP_End, 0,
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GTK_SCROLL_END);
|
2004-02-12 23:58:46 +00:00
|
|
|
|
|
2017-11-18 03:49:57 +00:00
|
|
|
|
gtk_widget_class_set_css_name (widget_class, I_("scale"));
|
2020-07-13 15:22:44 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_class_set_accessible_role (widget_class, GTK_ACCESSIBLE_ROLE_SLIDER);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-11-11 17:47:13 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_scale_init (GtkScale *scale)
|
|
|
|
|
{
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
2008-11-11 17:47:13 +00:00
|
|
|
|
GtkRange *range = GTK_RANGE (scale);
|
|
|
|
|
|
2020-05-05 18:57:21 +00:00
|
|
|
|
gtk_widget_set_focusable (GTK_WIDGET (scale), TRUE);
|
|
|
|
|
|
2016-03-06 05:08:47 +00:00
|
|
|
|
priv->value_pos = GTK_POS_TOP;
|
|
|
|
|
priv->digits = 1;
|
|
|
|
|
|
2010-08-12 23:38:35 +00:00
|
|
|
|
gtk_range_set_slider_size_fixed (range, TRUE);
|
2008-11-11 17:47:13 +00:00
|
|
|
|
|
2011-12-14 16:16:09 +00:00
|
|
|
|
_gtk_range_set_has_origin (range, TRUE);
|
|
|
|
|
|
2020-10-25 04:29:30 +00:00
|
|
|
|
gtk_range_set_round_digits (range, -1);
|
2008-11-11 17:47:13 +00:00
|
|
|
|
|
2014-11-21 06:26:19 +00:00
|
|
|
|
gtk_range_set_flippable (range, TRUE);
|
2008-11-11 17:47:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-01-18 19:42:59 +00:00
|
|
|
|
static void
|
2001-05-13 22:41:30 +00:00
|
|
|
|
gtk_scale_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
1999-01-18 19:42:59 +00:00
|
|
|
|
{
|
|
|
|
|
GtkScale *scale;
|
|
|
|
|
|
|
|
|
|
scale = GTK_SCALE (object);
|
|
|
|
|
|
2001-05-13 22:41:30 +00:00
|
|
|
|
switch (prop_id)
|
1999-01-18 19:42:59 +00:00
|
|
|
|
{
|
2001-05-13 22:41:30 +00:00
|
|
|
|
case PROP_DIGITS:
|
|
|
|
|
gtk_scale_set_digits (scale, g_value_get_int (value));
|
1999-01-18 19:42:59 +00:00
|
|
|
|
break;
|
2001-05-13 22:41:30 +00:00
|
|
|
|
case PROP_DRAW_VALUE:
|
|
|
|
|
gtk_scale_set_draw_value (scale, g_value_get_boolean (value));
|
1999-01-18 19:42:59 +00:00
|
|
|
|
break;
|
2011-12-14 16:16:09 +00:00
|
|
|
|
case PROP_HAS_ORIGIN:
|
|
|
|
|
gtk_scale_set_has_origin (scale, g_value_get_boolean (value));
|
|
|
|
|
break;
|
2001-05-13 22:41:30 +00:00
|
|
|
|
case PROP_VALUE_POS:
|
|
|
|
|
gtk_scale_set_value_pos (scale, g_value_get_enum (value));
|
1999-01-18 19:42:59 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2001-05-13 22:41:30 +00:00
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
1999-01-18 19:42:59 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2001-05-13 22:41:30 +00:00
|
|
|
|
gtk_scale_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
1999-01-18 19:42:59 +00:00
|
|
|
|
{
|
2010-07-08 02:04:24 +00:00
|
|
|
|
GtkScale *scale = GTK_SCALE (object);
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
1999-01-18 19:42:59 +00:00
|
|
|
|
|
2001-05-13 22:41:30 +00:00
|
|
|
|
switch (prop_id)
|
1999-01-18 19:42:59 +00:00
|
|
|
|
{
|
2001-05-13 22:41:30 +00:00
|
|
|
|
case PROP_DIGITS:
|
2010-07-08 02:04:24 +00:00
|
|
|
|
g_value_set_int (value, priv->digits);
|
1999-01-18 19:42:59 +00:00
|
|
|
|
break;
|
2001-05-13 22:41:30 +00:00
|
|
|
|
case PROP_DRAW_VALUE:
|
2010-07-08 02:04:24 +00:00
|
|
|
|
g_value_set_boolean (value, priv->draw_value);
|
1999-01-18 19:42:59 +00:00
|
|
|
|
break;
|
2011-12-14 16:16:09 +00:00
|
|
|
|
case PROP_HAS_ORIGIN:
|
|
|
|
|
g_value_set_boolean (value, gtk_scale_get_has_origin (scale));
|
|
|
|
|
break;
|
2001-05-13 22:41:30 +00:00
|
|
|
|
case PROP_VALUE_POS:
|
2010-07-08 02:04:24 +00:00
|
|
|
|
g_value_set_enum (value, priv->value_pos);
|
1999-01-18 19:42:59 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2001-05-13 22:41:30 +00:00
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
1999-01-18 19:42:59 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-11 17:47:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_scale_new:
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* @orientation: the scale’s orientation.
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* @adjustment: (nullable): the [class@Gtk.Adjustment] which sets
|
|
|
|
|
* the range of the scale, or %NULL to create a new adjustment.
|
2008-11-11 17:47:13 +00:00
|
|
|
|
*
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* Creates a new `GtkScale`.
|
2008-11-11 17:47:13 +00:00
|
|
|
|
*
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* Returns: a new `GtkScale`
|
|
|
|
|
*/
|
2008-11-11 17:47:13 +00:00
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_scale_new (GtkOrientation orientation,
|
|
|
|
|
GtkAdjustment *adjustment)
|
1998-11-06 22:05:02 +00:00
|
|
|
|
{
|
2008-11-11 17:47:13 +00:00
|
|
|
|
g_return_val_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment),
|
|
|
|
|
NULL);
|
1998-11-06 22:05:02 +00:00
|
|
|
|
|
2008-11-11 17:47:13 +00:00
|
|
|
|
return g_object_new (GTK_TYPE_SCALE,
|
|
|
|
|
"orientation", orientation,
|
|
|
|
|
"adjustment", adjustment,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
1998-11-06 22:05:02 +00:00
|
|
|
|
|
2008-11-11 17:47:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_scale_new_with_range:
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* @orientation: the scale’s orientation.
|
2008-11-11 17:47:13 +00:00
|
|
|
|
* @min: minimum value
|
|
|
|
|
* @max: maximum value
|
|
|
|
|
* @step: step increment (tick size) used with keyboard shortcuts
|
|
|
|
|
*
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* Creates a new scale widget with a range from @min to @max.
|
|
|
|
|
*
|
|
|
|
|
* The returns scale will have the given orientation and will let the
|
2008-11-11 17:47:13 +00:00
|
|
|
|
* user input a number between @min and @max (including @min and @max)
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* with the increment @step. @step must be nonzero; it’s the distance
|
2008-11-11 17:47:13 +00:00
|
|
|
|
* the slider moves when using the arrow keys to adjust the scale
|
|
|
|
|
* value.
|
|
|
|
|
*
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* Note that the way in which the precision is derived works best if
|
|
|
|
|
* @step is a power of ten. If the resulting precision is not suitable
|
|
|
|
|
* for your needs, use [method@Gtk.Scale.set_digits] to correct it.
|
2008-11-11 17:47:13 +00:00
|
|
|
|
*
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* Returns: a new `GtkScale`
|
2010-05-25 22:55:15 +00:00
|
|
|
|
*/
|
2008-11-11 17:47:13 +00:00
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_scale_new_with_range (GtkOrientation orientation,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double min,
|
|
|
|
|
double max,
|
|
|
|
|
double step)
|
2008-11-11 17:47:13 +00:00
|
|
|
|
{
|
2010-09-27 12:48:26 +00:00
|
|
|
|
GtkAdjustment *adj;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int digits;
|
2008-11-11 17:47:13 +00:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (min < max, NULL);
|
|
|
|
|
g_return_val_if_fail (step != 0.0, NULL);
|
|
|
|
|
|
|
|
|
|
adj = gtk_adjustment_new (min, min, max, step, 10 * step, 0);
|
|
|
|
|
|
|
|
|
|
if (fabs (step) >= 1.0 || step == 0.0)
|
|
|
|
|
{
|
|
|
|
|
digits = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
digits = abs ((int) floor (log10 (fabs (step))));
|
2008-11-11 17:47:13 +00:00
|
|
|
|
if (digits > 5)
|
|
|
|
|
digits = 5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return g_object_new (GTK_TYPE_SCALE,
|
|
|
|
|
"orientation", orientation,
|
|
|
|
|
"adjustment", adj,
|
|
|
|
|
"digits", digits,
|
|
|
|
|
NULL);
|
1998-11-06 22:05:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-12-29 02:36:39 +00:00
|
|
|
|
/**
|
2021-02-25 02:57:55 +00:00
|
|
|
|
* gtk_scale_set_digits: (attributes org.gtk.Method.set_property=digits)
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* @scale: a `GtkScale`
|
2017-04-26 11:18:12 +00:00
|
|
|
|
* @digits: the number of decimal places to display,
|
2021-05-18 21:05:26 +00:00
|
|
|
|
* e.g. use 1 to display 1.0, 2 to display 1.00, etc
|
2010-05-25 22:55:15 +00:00
|
|
|
|
*
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* Sets the number of decimal places that are displayed in the value.
|
|
|
|
|
*
|
|
|
|
|
* Also causes the value of the adjustment to be rounded to this number
|
|
|
|
|
* of digits, so the retrieved value matches the displayed one, if
|
|
|
|
|
* [property@GtkScale:draw-value] is %TRUE when the value changes. If
|
|
|
|
|
* you want to enforce rounding the value when [property@GtkScale:draw-value]
|
|
|
|
|
* is %FALSE, you can set [property@GtkRange:round-digits] instead.
|
2016-08-24 16:58:54 +00:00
|
|
|
|
*
|
|
|
|
|
* Note that rounding to a small number of digits can interfere with
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* the smooth autoscrolling that is built into `GtkScale`. As an alternative,
|
|
|
|
|
* you can use [method@Gtk.Scale.set_format_value_func] to format the displayed
|
2016-08-24 16:58:54 +00:00
|
|
|
|
* value yourself.
|
2008-12-29 02:36:39 +00:00
|
|
|
|
*/
|
1997-11-24 22:37:52 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_scale_set_digits (GtkScale *scale,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int digits)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GtkRange *range;
|
2010-07-08 02:04:24 +00:00
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_SCALE (scale));
|
|
|
|
|
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
range = GTK_RANGE (scale);
|
|
|
|
|
|
2002-01-30 19:29:59 +00:00
|
|
|
|
digits = CLAMP (digits, -1, MAX_DIGITS);
|
1999-01-18 19:42:59 +00:00
|
|
|
|
|
2010-07-08 02:04:24 +00:00
|
|
|
|
if (priv->digits != digits)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2010-07-08 02:04:24 +00:00
|
|
|
|
priv->digits = digits;
|
2017-04-26 10:18:09 +00:00
|
|
|
|
if (priv->draw_value)
|
|
|
|
|
gtk_range_set_round_digits (range, digits);
|
2010-08-12 23:50:09 +00:00
|
|
|
|
|
2022-09-06 17:27:38 +00:00
|
|
|
|
if (priv->value_widget)
|
|
|
|
|
update_label_request (scale);
|
|
|
|
|
|
1999-01-18 19:42:59 +00:00
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (scale));
|
2001-05-13 22:41:30 +00:00
|
|
|
|
|
2015-09-06 14:43:34 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (scale), properties[PROP_DIGITS]);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-29 02:36:39 +00:00
|
|
|
|
/**
|
2021-02-25 02:57:55 +00:00
|
|
|
|
* gtk_scale_get_digits: (attributes org.gtk.Method.get_property=digits)
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* @scale: a `GtkScale`
|
2008-12-29 02:36:39 +00:00
|
|
|
|
*
|
2017-04-26 11:18:12 +00:00
|
|
|
|
* Gets the number of decimal places that are displayed in the value.
|
2008-12-29 02:36:39 +00:00
|
|
|
|
*
|
2017-04-26 11:18:12 +00:00
|
|
|
|
* Returns: the number of decimal places that are displayed
|
2008-12-29 02:36:39 +00:00
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
gtk_scale_get_digits (GtkScale *scale)
|
|
|
|
|
{
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
|
|
|
|
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_SCALE (scale), -1);
|
|
|
|
|
|
2018-02-27 11:39:04 +00:00
|
|
|
|
return priv->digits;
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-06 05:08:47 +00:00
|
|
|
|
static void
|
|
|
|
|
update_value_position (GtkScale *scale)
|
|
|
|
|
{
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
2016-03-06 05:08:47 +00:00
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if (!priv->value_widget)
|
2016-03-06 05:08:47 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-08-13 23:49:02 +00:00
|
|
|
|
gtk_widget_remove_css_class (priv->value_widget, "top");
|
|
|
|
|
gtk_widget_remove_css_class (priv->value_widget, "right");
|
|
|
|
|
gtk_widget_remove_css_class (priv->value_widget, "bottom");
|
|
|
|
|
gtk_widget_remove_css_class (priv->value_widget, "left");
|
2019-08-26 16:56:04 +00:00
|
|
|
|
|
|
|
|
|
switch (priv->value_pos)
|
2016-03-06 05:08:47 +00:00
|
|
|
|
{
|
2020-08-13 23:49:02 +00:00
|
|
|
|
case GTK_POS_TOP:
|
|
|
|
|
gtk_widget_add_css_class (priv->value_widget, "top");
|
|
|
|
|
break;
|
|
|
|
|
case GTK_POS_RIGHT:
|
|
|
|
|
gtk_widget_add_css_class (priv->value_widget, "right");
|
|
|
|
|
break;
|
|
|
|
|
case GTK_POS_BOTTOM:
|
|
|
|
|
gtk_widget_add_css_class (priv->value_widget, "bottom");
|
|
|
|
|
break;
|
|
|
|
|
case GTK_POS_LEFT:
|
|
|
|
|
gtk_widget_add_css_class (priv->value_widget, "left");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
break;
|
2016-03-06 05:08:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-29 02:36:39 +00:00
|
|
|
|
/**
|
2021-02-25 02:57:55 +00:00
|
|
|
|
* gtk_scale_set_draw_value: (attributes org.gtk.Method.set_property=draw-value)
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @scale: a `GtkScale`
|
2008-12-29 04:35:10 +00:00
|
|
|
|
* @draw_value: %TRUE to draw the value
|
2020-02-20 09:30:14 +00:00
|
|
|
|
*
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* Specifies whether the current value is displayed as a string next
|
2008-12-29 02:36:39 +00:00
|
|
|
|
* to the slider.
|
|
|
|
|
*/
|
1997-11-24 22:37:52 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_scale_set_draw_value (GtkScale *scale,
|
2020-02-20 09:30:14 +00:00
|
|
|
|
gboolean draw_value)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
2010-07-08 02:04:24 +00:00
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_SCALE (scale));
|
|
|
|
|
|
1999-01-18 19:42:59 +00:00
|
|
|
|
draw_value = draw_value != FALSE;
|
|
|
|
|
|
2010-07-08 02:04:24 +00:00
|
|
|
|
if (priv->draw_value != draw_value)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2010-07-08 02:04:24 +00:00
|
|
|
|
priv->draw_value = draw_value;
|
2002-01-30 01:47:27 +00:00
|
|
|
|
if (draw_value)
|
2016-03-06 05:08:47 +00:00
|
|
|
|
{
|
2017-05-13 14:13:22 +00:00
|
|
|
|
priv->value_widget = g_object_new (GTK_TYPE_LABEL,
|
|
|
|
|
"css-name", "value",
|
|
|
|
|
NULL);
|
2016-03-06 05:08:47 +00:00
|
|
|
|
|
2020-06-26 06:00:04 +00:00
|
|
|
|
gtk_widget_insert_after (priv->value_widget, GTK_WIDGET (scale), NULL);
|
2017-04-26 10:18:09 +00:00
|
|
|
|
gtk_range_set_round_digits (GTK_RANGE (scale), priv->digits);
|
2016-03-06 05:08:47 +00:00
|
|
|
|
update_value_position (scale);
|
2017-05-13 14:13:22 +00:00
|
|
|
|
update_label_request (scale);
|
2016-03-06 05:08:47 +00:00
|
|
|
|
}
|
2017-05-13 14:13:22 +00:00
|
|
|
|
else if (priv->value_widget)
|
2016-03-06 05:08:47 +00:00
|
|
|
|
{
|
2018-11-13 19:53:14 +00:00
|
|
|
|
g_clear_pointer (&priv->value_widget, gtk_widget_unparent);
|
2017-04-26 10:18:09 +00:00
|
|
|
|
gtk_range_set_round_digits (GTK_RANGE (scale), -1);
|
2016-03-06 05:08:47 +00:00
|
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2015-09-06 14:43:34 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (scale), properties[PROP_DRAW_VALUE]);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-29 02:36:39 +00:00
|
|
|
|
/**
|
2021-02-25 02:57:55 +00:00
|
|
|
|
* gtk_scale_get_draw_value: (attributes org.gtk.Method.get_property=draw-value)
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* @scale: a `GtkScale`
|
2008-12-29 02:36:39 +00:00
|
|
|
|
*
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* Returns whether the current value is displayed as a string
|
2008-12-29 02:36:39 +00:00
|
|
|
|
* next to the slider.
|
|
|
|
|
*
|
|
|
|
|
* Returns: whether the current value is displayed as a string
|
|
|
|
|
*/
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_scale_get_draw_value (GtkScale *scale)
|
|
|
|
|
{
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
|
|
|
|
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_SCALE (scale), FALSE);
|
|
|
|
|
|
2018-02-27 11:39:04 +00:00
|
|
|
|
return priv->draw_value;
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-12-14 16:16:09 +00:00
|
|
|
|
/**
|
2021-02-25 02:57:55 +00:00
|
|
|
|
* gtk_scale_set_has_origin: (attributes org.gtk.Method.set_property=has-origin)
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* @scale: a `GtkScale`
|
2011-12-14 16:16:09 +00:00
|
|
|
|
* @has_origin: %TRUE if the scale has an origin
|
2021-02-20 04:31:23 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets whether the scale has an origin.
|
|
|
|
|
*
|
|
|
|
|
* If [property@GtkScale:has-origin] is set to %TRUE (the default),
|
|
|
|
|
* the scale will highlight the part of the trough between the origin
|
|
|
|
|
* (bottom or left side) and the current value.
|
2011-12-14 16:16:09 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_scale_set_has_origin (GtkScale *scale,
|
|
|
|
|
gboolean has_origin)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_SCALE (scale));
|
|
|
|
|
|
|
|
|
|
has_origin = has_origin != FALSE;
|
|
|
|
|
|
|
|
|
|
if (_gtk_range_get_has_origin (GTK_RANGE (scale)) != has_origin)
|
|
|
|
|
{
|
|
|
|
|
_gtk_range_set_has_origin (GTK_RANGE (scale), has_origin);
|
|
|
|
|
|
|
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (scale));
|
|
|
|
|
|
2015-09-06 14:43:34 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (scale), properties[PROP_HAS_ORIGIN]);
|
2011-12-14 16:16:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 02:57:55 +00:00
|
|
|
|
* gtk_scale_get_has_origin: (attributes org.gtk.Method.get_property=has-origin)
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* @scale: a `GtkScale`
|
2011-12-14 16:16:09 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns whether the scale has an origin.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the scale has an origin.
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_scale_get_has_origin (GtkScale *scale)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_SCALE (scale), FALSE);
|
|
|
|
|
|
|
|
|
|
return _gtk_range_get_has_origin (GTK_RANGE (scale));
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-29 02:36:39 +00:00
|
|
|
|
/**
|
2021-02-25 02:57:55 +00:00
|
|
|
|
* gtk_scale_set_value_pos: (attributes org.gtk.Method.set_property=value-pos)
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* @scale: a `GtkScale`
|
2008-12-29 02:36:39 +00:00
|
|
|
|
* @pos: the position in which the current value is displayed
|
2019-08-09 10:08:51 +00:00
|
|
|
|
*
|
2008-12-29 02:36:39 +00:00
|
|
|
|
* Sets the position in which the current value is displayed.
|
|
|
|
|
*/
|
1997-11-24 22:37:52 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_scale_set_value_pos (GtkScale *scale,
|
2019-08-09 10:08:51 +00:00
|
|
|
|
GtkPositionType pos)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
2010-03-01 06:47:38 +00:00
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_SCALE (scale));
|
|
|
|
|
|
2010-07-08 02:04:24 +00:00
|
|
|
|
if (priv->value_pos != pos)
|
1997-11-24 22:37:52 +00:00
|
|
|
|
{
|
2010-07-08 02:04:24 +00:00
|
|
|
|
priv->value_pos = pos;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
2016-03-06 05:08:47 +00:00
|
|
|
|
update_value_position (scale);
|
2019-08-09 17:24:32 +00:00
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (scale));
|
2001-05-13 22:41:30 +00:00
|
|
|
|
|
2015-09-06 14:43:34 +00:00
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (scale), properties[PROP_VALUE_POS]);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-29 02:36:39 +00:00
|
|
|
|
/**
|
2021-02-25 02:57:55 +00:00
|
|
|
|
* gtk_scale_get_value_pos: (attributes org.gtk.Method.get_property=value-pos)
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* @scale: a `GtkScale`
|
2008-12-29 02:36:39 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the position in which the current value is displayed.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the position in which the current value is displayed
|
|
|
|
|
*/
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
GtkPositionType
|
|
|
|
|
gtk_scale_get_value_pos (GtkScale *scale)
|
|
|
|
|
{
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
|
|
|
|
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_SCALE (scale), 0);
|
|
|
|
|
|
2018-02-27 11:39:04 +00:00
|
|
|
|
return priv->value_pos;
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_scale_get_range_border (GtkRange *range,
|
|
|
|
|
GtkBorder *border)
|
|
|
|
|
{
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScale *scale = GTK_SCALE (range);
|
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
|
|
|
|
|
border->left = 0;
|
|
|
|
|
border->right = 0;
|
|
|
|
|
border->top = 0;
|
|
|
|
|
border->bottom = 0;
|
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if (priv->value_widget)
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
{
|
2016-03-06 05:08:47 +00:00
|
|
|
|
int value_size;
|
|
|
|
|
GtkOrientation value_orientation;
|
|
|
|
|
|
|
|
|
|
if (priv->value_pos == GTK_POS_LEFT || priv->value_pos == GTK_POS_RIGHT)
|
|
|
|
|
value_orientation = GTK_ORIENTATION_HORIZONTAL;
|
|
|
|
|
else
|
|
|
|
|
value_orientation = GTK_ORIENTATION_VERTICAL;
|
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
gtk_widget_measure (priv->value_widget,
|
|
|
|
|
value_orientation, -1,
|
|
|
|
|
&value_size, NULL,
|
|
|
|
|
NULL, NULL);
|
2016-03-06 05:08:47 +00:00
|
|
|
|
|
2010-07-08 02:04:24 +00:00
|
|
|
|
switch (priv->value_pos)
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
{
|
|
|
|
|
case GTK_POS_LEFT:
|
2016-03-06 05:08:47 +00:00
|
|
|
|
border->left += value_size;
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_POS_RIGHT:
|
2016-03-06 05:08:47 +00:00
|
|
|
|
border->right += value_size;
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_POS_TOP:
|
2016-03-06 05:08:47 +00:00
|
|
|
|
border->top += value_size;
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_POS_BOTTOM:
|
2016-03-06 05:08:47 +00:00
|
|
|
|
border->bottom += value_size;
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
break;
|
2017-10-06 19:19:42 +00:00
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
break;
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2009-01-20 05:10:27 +00:00
|
|
|
|
|
2016-02-27 23:24:32 +00:00
|
|
|
|
if (gtk_orientable_get_orientation (GTK_ORIENTABLE (range)) == GTK_ORIENTATION_HORIZONTAL)
|
2009-01-20 05:10:27 +00:00
|
|
|
|
{
|
2016-02-27 23:24:32 +00:00
|
|
|
|
int height;
|
2009-01-20 05:10:27 +00:00
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if (priv->top_marks_widget)
|
2016-02-27 23:24:32 +00:00
|
|
|
|
{
|
2017-05-13 14:13:22 +00:00
|
|
|
|
gtk_widget_measure (priv->top_marks_widget,
|
|
|
|
|
GTK_ORIENTATION_VERTICAL, -1,
|
|
|
|
|
&height, NULL,
|
|
|
|
|
NULL, NULL);
|
2016-02-27 23:24:32 +00:00
|
|
|
|
if (height > 0)
|
2016-03-06 05:08:47 +00:00
|
|
|
|
border->top += height;
|
2016-02-27 23:24:32 +00:00
|
|
|
|
}
|
2009-01-20 05:10:27 +00:00
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if (priv->bottom_marks_widget)
|
2016-02-27 23:24:32 +00:00
|
|
|
|
{
|
2017-05-13 14:13:22 +00:00
|
|
|
|
gtk_widget_measure (priv->bottom_marks_widget,
|
|
|
|
|
GTK_ORIENTATION_VERTICAL, -1,
|
|
|
|
|
&height, NULL,
|
|
|
|
|
NULL, NULL);
|
2016-02-27 23:24:32 +00:00
|
|
|
|
if (height > 0)
|
2016-03-06 05:08:47 +00:00
|
|
|
|
border->bottom += height;
|
2016-02-27 23:24:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int width;
|
2011-03-03 21:30:21 +00:00
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if (priv->top_marks_widget)
|
2009-01-20 05:10:27 +00:00
|
|
|
|
{
|
2017-05-13 14:13:22 +00:00
|
|
|
|
gtk_widget_measure (priv->top_marks_widget,
|
|
|
|
|
GTK_ORIENTATION_HORIZONTAL, -1,
|
|
|
|
|
&width, NULL,
|
|
|
|
|
NULL, NULL);
|
2016-02-27 23:24:32 +00:00
|
|
|
|
if (width > 0)
|
2016-03-06 05:08:47 +00:00
|
|
|
|
border->left += width;
|
2009-01-20 05:10:27 +00:00
|
|
|
|
}
|
2016-02-27 23:24:32 +00:00
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if (priv->bottom_marks_widget)
|
2009-01-20 05:10:27 +00:00
|
|
|
|
{
|
2017-05-13 14:13:22 +00:00
|
|
|
|
gtk_widget_measure (priv->bottom_marks_widget,
|
|
|
|
|
GTK_ORIENTATION_HORIZONTAL, -1,
|
|
|
|
|
&width, NULL,
|
|
|
|
|
NULL, NULL);
|
2016-02-27 23:24:32 +00:00
|
|
|
|
if (width > 0)
|
2016-03-06 05:08:47 +00:00
|
|
|
|
border->right += width;
|
2009-01-20 05:10:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
make this special-case hscale/vscale details, so we can use it for
2001-06-03 Havoc Pennington <hp@pobox.com>
* gtk/gtkstyle.c (gtk_default_draw_slider): make this special-case
hscale/vscale details, so we can use it for scrollbar as well.
* tests/testgtk.c (reformat_value): honor digits from GtkScale
* gtk/gtkenums.h (GtkTroughType): Remove this enum
(GtkScrollType): add START and END from GtkTroughType
* gtk/gtkstyle.c (gtk_default_draw_slider): was not properly using
its x/y arguments
* gtk/gtkrange.h, gtk/gtkrange.c, gtk/gtkscrollbar.h,
gtk/gtkscrollbar.c, gtk/gtkscale.h, gtk/gtkscale.c,
gtk/gtkhscrollbar.h, gtk/gtkhscrollbar.c, gtk/gtkvscrollbar.h,
gtk/gtkvscrollbar.c, gtk/gtkhscale.h, gtk/gtkhscale.c,
gtk/gtkvscale.h, gtk/gtkvscale.c: Rewrite GtkRange and subclasses.
Notable changes in the process:
- stepper_size style property is the height for vertical
ranges, width for horizontal; the other dimension matches
the trough size
- add ability to do NeXT-style steppers (and several other styles
that don't make any sense)
- added min_slider_length, fixed_slider_length properties to
GtkScrollbar
- cleaned some private (or at least useless) functions out of
gtkscale.h
- moved bindings to GtkScale from subclasses, even arrow keys,
since blind users don't know scale orientation.
- change move_slider action signal to use new GtkScrollType,
remove GtkTroughType argument
- digits rounds the values a range will input to the given
number of decimals, but will not try to force adjustment
values set by other controllers. That is, we no longer
modify adjustment->value inside a value_changed handler.
- added getters for GtkScale setters
- middle-click begins a slider drag
2001-06-04 02:31:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2017-05-13 14:13:22 +00:00
|
|
|
|
gtk_scale_measure_mark (GtkGizmo *gizmo,
|
2016-02-29 05:13:54 +00:00
|
|
|
|
GtkOrientation orientation,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int for_size,
|
|
|
|
|
int *minimum,
|
|
|
|
|
int *natural,
|
|
|
|
|
int *minimum_baseline,
|
|
|
|
|
int *natural_baseline)
|
2016-02-29 05:13:54 +00:00
|
|
|
|
{
|
2017-05-13 14:13:22 +00:00
|
|
|
|
GtkScaleMark *mark = g_object_get_data (G_OBJECT (gizmo), "mark");
|
2016-02-29 05:13:54 +00:00
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
gtk_widget_measure (mark->indicator_widget,
|
|
|
|
|
orientation, -1,
|
|
|
|
|
minimum, natural,
|
|
|
|
|
NULL, NULL);
|
2016-02-29 05:13:54 +00:00
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if (mark->label_widget)
|
2016-02-29 05:13:54 +00:00
|
|
|
|
{
|
|
|
|
|
int label_min, label_nat;
|
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
gtk_widget_measure (mark->label_widget,
|
|
|
|
|
orientation, -1,
|
|
|
|
|
&label_min, &label_nat,
|
|
|
|
|
NULL, NULL);
|
2016-02-29 05:13:54 +00:00
|
|
|
|
*minimum += label_min;
|
|
|
|
|
*natural += label_nat;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-27 23:24:32 +00:00
|
|
|
|
static void
|
2017-05-13 14:13:22 +00:00
|
|
|
|
gtk_scale_measure_marks (GtkGizmo *gizmo,
|
2016-02-27 23:24:32 +00:00
|
|
|
|
GtkOrientation orientation,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int for_size,
|
|
|
|
|
int *minimum,
|
|
|
|
|
int *natural,
|
|
|
|
|
int *minimum_baseline,
|
|
|
|
|
int *natural_baseline)
|
2016-02-27 23:24:32 +00:00
|
|
|
|
{
|
2017-05-13 14:13:22 +00:00
|
|
|
|
GtkWidget *widget = GTK_WIDGET (gizmo);
|
|
|
|
|
GtkScale *scale = GTK_SCALE (gtk_widget_get_parent (widget));;
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
2016-02-27 23:24:32 +00:00
|
|
|
|
GtkOrientation scale_orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (scale));
|
2016-02-28 21:45:48 +00:00
|
|
|
|
GSList *m;
|
|
|
|
|
|
|
|
|
|
*minimum = *natural = 0;
|
|
|
|
|
|
|
|
|
|
for (m = priv->marks; m; m = m->next)
|
2016-02-27 23:24:32 +00:00
|
|
|
|
{
|
2016-02-28 21:45:48 +00:00
|
|
|
|
GtkScaleMark *mark = m->data;
|
|
|
|
|
int mark_size;
|
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if ((mark->position == GTK_POS_TOP && widget == priv->bottom_marks_widget) ||
|
|
|
|
|
(mark->position == GTK_POS_BOTTOM && widget == priv->top_marks_widget))
|
2016-02-28 21:45:48 +00:00
|
|
|
|
continue;
|
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
gtk_widget_measure (mark->widget,
|
|
|
|
|
orientation, -1,
|
|
|
|
|
&mark_size, NULL,
|
|
|
|
|
NULL, NULL);
|
2016-02-28 21:45:48 +00:00
|
|
|
|
|
|
|
|
|
if (scale_orientation == orientation)
|
2016-02-27 23:24:32 +00:00
|
|
|
|
{
|
2016-02-28 21:45:48 +00:00
|
|
|
|
*minimum += mark_size;
|
|
|
|
|
*natural += mark_size;
|
2016-02-27 23:24:32 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-02-28 21:45:48 +00:00
|
|
|
|
*minimum = MAX (*minimum, mark_size);
|
|
|
|
|
*natural = MAX (*natural, mark_size);
|
2016-02-27 23:24:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-20 05:10:27 +00:00
|
|
|
|
static void
|
2016-10-22 14:06:14 +00:00
|
|
|
|
gtk_scale_measure (GtkWidget *widget,
|
|
|
|
|
GtkOrientation orientation,
|
|
|
|
|
int for_size,
|
|
|
|
|
int *minimum,
|
|
|
|
|
int *natural,
|
|
|
|
|
int *minimum_baseline,
|
|
|
|
|
int *natural_baseline)
|
2010-10-27 14:32:58 +00:00
|
|
|
|
{
|
2016-02-27 23:24:32 +00:00
|
|
|
|
GtkScale *scale = GTK_SCALE (widget);
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
2019-08-09 10:08:51 +00:00
|
|
|
|
GtkOrientation scale_orientation;
|
2010-10-27 14:32:58 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
GTK_WIDGET_CLASS (gtk_scale_parent_class)->measure (widget,
|
|
|
|
|
orientation,
|
|
|
|
|
for_size,
|
|
|
|
|
minimum, natural,
|
|
|
|
|
minimum_baseline, natural_baseline);
|
2010-10-27 14:32:58 +00:00
|
|
|
|
|
2019-08-09 10:08:51 +00:00
|
|
|
|
scale_orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget));
|
|
|
|
|
|
|
|
|
|
if (scale_orientation == orientation)
|
2009-01-20 05:10:27 +00:00
|
|
|
|
{
|
2016-10-22 14:06:14 +00:00
|
|
|
|
int top_marks_size = 0, bottom_marks_size = 0, marks_size;
|
2016-02-27 23:24:32 +00:00
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if (priv->top_marks_widget)
|
|
|
|
|
gtk_widget_measure (priv->top_marks_widget,
|
|
|
|
|
orientation, for_size,
|
|
|
|
|
&top_marks_size, NULL,
|
|
|
|
|
NULL, NULL);
|
|
|
|
|
if (priv->bottom_marks_widget)
|
|
|
|
|
gtk_widget_measure (priv->bottom_marks_widget,
|
|
|
|
|
orientation, for_size,
|
|
|
|
|
&bottom_marks_size, NULL,
|
|
|
|
|
NULL, NULL);
|
2016-02-27 23:24:32 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
marks_size = MAX (top_marks_size, bottom_marks_size);
|
2016-02-27 23:24:32 +00:00
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
*minimum = MAX (*minimum, marks_size);
|
|
|
|
|
*natural = MAX (*natural, marks_size);
|
2009-01-20 05:10:27 +00:00
|
|
|
|
}
|
2019-08-09 10:08:51 +00:00
|
|
|
|
|
|
|
|
|
if (priv->value_widget)
|
|
|
|
|
{
|
|
|
|
|
int min, nat;
|
|
|
|
|
|
|
|
|
|
gtk_widget_measure (priv->value_widget, orientation, -1, &min, &nat, NULL, NULL);
|
|
|
|
|
|
|
|
|
|
if (priv->value_pos == GTK_POS_TOP ||
|
|
|
|
|
priv->value_pos == GTK_POS_BOTTOM)
|
|
|
|
|
{
|
|
|
|
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
|
|
|
{
|
|
|
|
|
*minimum = MAX (*minimum, min);
|
|
|
|
|
*natural = MAX (*natural, nat);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*minimum += min;
|
|
|
|
|
*natural += nat;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
|
|
|
{
|
|
|
|
|
*minimum += min;
|
|
|
|
|
*natural += nat;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*minimum = MAX (*minimum, min);
|
|
|
|
|
*natural = MAX (*natural, nat);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-01-20 05:10:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-11-11 17:47:13 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_scale_real_get_layout_offsets (GtkScale *scale,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int *x,
|
|
|
|
|
int *y)
|
2008-11-11 17:47:13 +00:00
|
|
|
|
{
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
2018-04-07 11:37:24 +00:00
|
|
|
|
graphene_rect_t value_bounds;
|
2008-11-11 17:47:13 +00:00
|
|
|
|
|
2019-02-20 03:53:47 +00:00
|
|
|
|
if (!priv->value_widget ||
|
|
|
|
|
!gtk_widget_compute_bounds (priv->value_widget, GTK_WIDGET (scale), &value_bounds))
|
2008-11-11 17:47:13 +00:00
|
|
|
|
{
|
|
|
|
|
*x = 0;
|
|
|
|
|
*y = 0;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-04-07 11:37:24 +00:00
|
|
|
|
*x = value_bounds.origin.x;
|
|
|
|
|
*y = value_bounds.origin.y;
|
2008-11-11 17:47:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
|
static char *
|
|
|
|
|
weed_out_neg_zero (char *str,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int digits)
|
2016-06-08 03:04:40 +00:00
|
|
|
|
{
|
|
|
|
|
if (str[0] == '-')
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char neg_zero[8];
|
2016-06-27 03:53:30 +00:00
|
|
|
|
g_snprintf (neg_zero, 8, "%0.*f", digits, -0.0);
|
2016-06-08 03:04:40 +00:00
|
|
|
|
if (strcmp (neg_zero, str) == 0)
|
2019-06-03 00:22:20 +00:00
|
|
|
|
memmove (str, str + 1, strlen (str));
|
2016-06-08 03:04:40 +00:00
|
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-09 11:32:24 +00:00
|
|
|
|
static char *
|
2015-09-19 15:33:38 +00:00
|
|
|
|
gtk_scale_format_value (GtkScale *scale,
|
2019-08-09 11:32:24 +00:00
|
|
|
|
double value)
|
2001-05-07 15:58:47 +00:00
|
|
|
|
{
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
2001-05-07 15:58:47 +00:00
|
|
|
|
|
2019-08-09 11:32:24 +00:00
|
|
|
|
if (priv->format_value_func)
|
|
|
|
|
{
|
|
|
|
|
return priv->format_value_func (scale, value, priv->format_value_func_user_data);
|
|
|
|
|
}
|
2001-05-07 15:58:47 +00:00
|
|
|
|
else
|
2016-06-08 03:04:40 +00:00
|
|
|
|
{
|
2019-08-09 11:32:24 +00:00
|
|
|
|
char *fmt = g_strdup_printf ("%0.*f", priv->digits, value);
|
2018-02-27 11:39:04 +00:00
|
|
|
|
return weed_out_neg_zero (fmt, priv->digits);
|
2016-06-08 03:04:40 +00:00
|
|
|
|
}
|
2001-05-07 15:58:47 +00:00
|
|
|
|
}
|
2004-02-12 23:58:46 +00:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_scale_finalize (GObject *object)
|
|
|
|
|
{
|
2008-02-07 16:59:42 +00:00
|
|
|
|
GtkScale *scale = GTK_SCALE (object);
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
2004-02-12 23:58:46 +00:00
|
|
|
|
|
2009-01-20 05:10:27 +00:00
|
|
|
|
gtk_scale_clear_marks (scale);
|
2004-02-12 23:58:46 +00:00
|
|
|
|
|
2018-11-13 19:53:14 +00:00
|
|
|
|
g_clear_pointer (&priv->value_widget, gtk_widget_unparent);
|
2016-03-06 05:08:47 +00:00
|
|
|
|
|
2019-08-15 15:21:47 +00:00
|
|
|
|
if (priv->format_value_func_destroy_notify)
|
|
|
|
|
priv->format_value_func_destroy_notify (priv->format_value_func_user_data);
|
|
|
|
|
|
2006-05-02 23:56:43 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_scale_parent_class)->finalize (object);
|
2004-02-12 23:58:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_scale_get_layout:
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* @scale: A `GtkScale`
|
|
|
|
|
*
|
|
|
|
|
* Gets the `PangoLayout` used to display the scale.
|
2004-02-12 23:58:46 +00:00
|
|
|
|
*
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* The returned object is owned by the scale so does not need
|
|
|
|
|
* to be freed by the caller.
|
2010-09-21 04:18:11 +00:00
|
|
|
|
*
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* Returns: (transfer none) (nullable): the [class@Pango.Layout]
|
|
|
|
|
* for this scale, or %NULL if the [property@GtkScale:draw-value]
|
|
|
|
|
* property is %FALSE.
|
2008-12-29 02:36:39 +00:00
|
|
|
|
*/
|
2004-02-12 23:58:46 +00:00
|
|
|
|
PangoLayout *
|
|
|
|
|
gtk_scale_get_layout (GtkScale *scale)
|
|
|
|
|
{
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
|
|
|
|
|
2004-02-12 23:58:46 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_SCALE (scale), NULL);
|
|
|
|
|
|
2018-02-27 11:39:04 +00:00
|
|
|
|
if (priv->value_widget)
|
|
|
|
|
return gtk_label_get_layout (GTK_LABEL (priv->value_widget));
|
2004-02-12 23:58:46 +00:00
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
return NULL;
|
2004-02-12 23:58:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_scale_get_layout_offsets:
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @scale: a `GtkScale`
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* @x: (out) (optional): location to store X offset of layout
|
|
|
|
|
* @y: (out) (optional): location to store Y offset of layout
|
2004-02-12 23:58:46 +00:00
|
|
|
|
*
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* Obtains the coordinates where the scale will draw the
|
|
|
|
|
* `PangoLayout` representing the text in the scale.
|
|
|
|
|
*
|
|
|
|
|
* Remember when using the `PangoLayout` function you need to
|
|
|
|
|
* convert to and from pixels using `PANGO_PIXELS()` or `PANGO_SCALE`.
|
2004-02-12 23:58:46 +00:00
|
|
|
|
*
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* If the [property@GtkScale:draw-value] property is %FALSE, the return
|
2007-06-10 02:53:17 +00:00
|
|
|
|
* values are undefined.
|
2008-12-29 02:36:39 +00:00
|
|
|
|
*/
|
2004-02-12 23:58:46 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_scale_get_layout_offsets (GtkScale *scale,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int *x,
|
|
|
|
|
int *y)
|
2004-02-12 23:58:46 +00:00
|
|
|
|
{
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int local_x = 0;
|
|
|
|
|
int local_y = 0;
|
2004-02-12 23:58:46 +00:00
|
|
|
|
|
2004-02-13 13:21:10 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_SCALE (scale));
|
2004-02-12 23:58:46 +00:00
|
|
|
|
|
|
|
|
|
if (GTK_SCALE_GET_CLASS (scale)->get_layout_offsets)
|
|
|
|
|
(GTK_SCALE_GET_CLASS (scale)->get_layout_offsets) (scale, &local_x, &local_y);
|
|
|
|
|
|
|
|
|
|
if (x)
|
|
|
|
|
*x = local_x;
|
|
|
|
|
|
|
|
|
|
if (y)
|
|
|
|
|
*y = local_y;
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-20 05:10:27 +00:00
|
|
|
|
static void
|
2012-01-15 19:09:54 +00:00
|
|
|
|
gtk_scale_mark_free (gpointer data)
|
2009-01-20 05:10:27 +00:00
|
|
|
|
{
|
2012-01-15 19:09:54 +00:00
|
|
|
|
GtkScaleMark *mark = data;
|
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if (mark->label_widget)
|
|
|
|
|
gtk_widget_unparent (mark->label_widget);
|
|
|
|
|
|
|
|
|
|
gtk_widget_unparent (mark->indicator_widget);
|
|
|
|
|
gtk_widget_unparent (mark->widget);
|
2009-01-20 05:10:27 +00:00
|
|
|
|
g_free (mark->markup);
|
|
|
|
|
g_free (mark);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_scale_clear_marks:
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* @scale: a `GtkScale`
|
|
|
|
|
*
|
|
|
|
|
* Removes any marks that have been added.
|
2009-01-20 05:10:27 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_scale_clear_marks (GtkScale *scale)
|
|
|
|
|
{
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
2009-01-20 05:10:27 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_SCALE (scale));
|
|
|
|
|
|
2012-01-15 19:09:54 +00:00
|
|
|
|
g_slist_free_full (priv->marks, gtk_scale_mark_free);
|
2009-01-20 05:10:27 +00:00
|
|
|
|
priv->marks = NULL;
|
|
|
|
|
|
2018-11-13 19:53:14 +00:00
|
|
|
|
g_clear_pointer (&priv->top_marks_widget, gtk_widget_unparent);
|
|
|
|
|
g_clear_pointer (&priv->bottom_marks_widget, gtk_widget_unparent);
|
2015-11-04 04:11:52 +00:00
|
|
|
|
|
2020-02-06 16:32:26 +00:00
|
|
|
|
gtk_widget_remove_css_class (GTK_WIDGET (scale), "marks-before");
|
|
|
|
|
gtk_widget_remove_css_class (GTK_WIDGET (scale), "marks-after");
|
2016-05-18 16:59:39 +00:00
|
|
|
|
|
2009-01-20 05:10:27 +00:00
|
|
|
|
_gtk_range_set_stop_values (GTK_RANGE (scale), NULL, 0);
|
2009-04-16 04:50:46 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (scale));
|
2009-01-20 05:10:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_scale_add_mark:
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* @scale: a `GtkScale`
|
2011-03-03 21:30:21 +00:00
|
|
|
|
* @value: the value at which the mark is placed, must be between
|
2014-02-07 18:26:12 +00:00
|
|
|
|
* the lower and upper limits of the scales’ adjustment
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* @position: where to draw the mark. For a horizontal scale, %GTK_POS_TOP
|
2011-03-03 21:30:21 +00:00
|
|
|
|
* and %GTK_POS_LEFT are drawn above the scale, anything else below.
|
2021-05-20 13:17:04 +00:00
|
|
|
|
* For a vertical scale, %GTK_POS_LEFT and %GTK_POS_TOP are drawn to
|
2011-03-03 21:30:21 +00:00
|
|
|
|
* the left of the scale, anything else to the right.
|
2021-05-21 00:45:06 +00:00
|
|
|
|
* @markup: (nullable): Text to be shown at the mark, using Pango markup
|
2009-01-20 05:10:27 +00:00
|
|
|
|
*
|
2011-03-03 21:30:21 +00:00
|
|
|
|
* Adds a mark at @value.
|
2009-01-20 05:10:27 +00:00
|
|
|
|
*
|
2011-03-03 21:30:21 +00:00
|
|
|
|
* A mark is indicated visually by drawing a tick mark next to the scale,
|
2020-09-12 16:01:04 +00:00
|
|
|
|
* and GTK makes it easy for the user to position the scale exactly at the
|
2009-01-20 05:10:27 +00:00
|
|
|
|
* marks value.
|
|
|
|
|
*
|
2011-03-03 21:30:21 +00:00
|
|
|
|
* If @markup is not %NULL, text is shown next to the tick mark.
|
2009-01-20 05:10:27 +00:00
|
|
|
|
*
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* To remove marks from a scale, use [method@Gtk.Scale.clear_marks].
|
2009-01-20 05:10:27 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_scale_add_mark (GtkScale *scale,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double value,
|
2009-01-20 05:10:27 +00:00
|
|
|
|
GtkPositionType position,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *markup)
|
2009-01-20 05:10:27 +00:00
|
|
|
|
{
|
2016-03-06 18:36:43 +00:00
|
|
|
|
GtkWidget *widget;
|
2018-02-27 11:39:04 +00:00
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
2009-01-20 05:10:27 +00:00
|
|
|
|
GtkScaleMark *mark;
|
2012-01-15 19:09:54 +00:00
|
|
|
|
GSList *m;
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double *values;
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int n, i;
|
2017-05-13 14:13:22 +00:00
|
|
|
|
GtkWidget *marks_widget;
|
2009-01-20 05:10:27 +00:00
|
|
|
|
|
2010-07-08 02:04:24 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_SCALE (scale));
|
|
|
|
|
|
2016-03-06 18:36:43 +00:00
|
|
|
|
widget = GTK_WIDGET (scale);
|
2010-07-08 02:04:24 +00:00
|
|
|
|
|
2016-02-29 05:13:54 +00:00
|
|
|
|
mark = g_new0 (GtkScaleMark, 1);
|
2009-01-20 05:10:27 +00:00
|
|
|
|
mark->value = value;
|
|
|
|
|
mark->markup = g_strdup (markup);
|
2011-03-03 21:30:21 +00:00
|
|
|
|
if (position == GTK_POS_LEFT ||
|
|
|
|
|
position == GTK_POS_TOP)
|
|
|
|
|
mark->position = GTK_POS_TOP;
|
|
|
|
|
else
|
|
|
|
|
mark->position = GTK_POS_BOTTOM;
|
2011-03-03 21:47:55 +00:00
|
|
|
|
|
2012-01-18 05:57:20 +00:00
|
|
|
|
priv->marks = g_slist_insert_sorted_with_data (priv->marks, mark,
|
|
|
|
|
compare_marks,
|
|
|
|
|
GINT_TO_POINTER (gtk_range_get_inverted (GTK_RANGE (scale))));
|
2009-01-20 05:10:27 +00:00
|
|
|
|
|
2015-11-05 11:45:24 +00:00
|
|
|
|
if (mark->position == GTK_POS_TOP)
|
2015-11-04 04:11:52 +00:00
|
|
|
|
{
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if (!priv->top_marks_widget)
|
2015-11-05 11:45:24 +00:00
|
|
|
|
{
|
2020-10-21 18:53:17 +00:00
|
|
|
|
priv->top_marks_widget = gtk_gizmo_new_with_role ("marks",
|
|
|
|
|
GTK_ACCESSIBLE_ROLE_NONE,
|
|
|
|
|
gtk_scale_measure_marks,
|
|
|
|
|
gtk_scale_allocate_marks,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL, NULL);
|
2017-05-13 14:13:22 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_insert_after (priv->top_marks_widget,
|
|
|
|
|
GTK_WIDGET (scale),
|
2020-06-26 06:00:04 +00:00
|
|
|
|
priv->value_widget);
|
2020-08-13 23:49:02 +00:00
|
|
|
|
gtk_widget_add_css_class (priv->top_marks_widget, "top");
|
2015-11-05 11:45:24 +00:00
|
|
|
|
}
|
2017-05-13 14:13:22 +00:00
|
|
|
|
marks_widget = priv->top_marks_widget;
|
2015-11-05 11:45:24 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if (!priv->bottom_marks_widget)
|
2015-11-05 11:45:24 +00:00
|
|
|
|
{
|
2020-10-21 18:53:17 +00:00
|
|
|
|
priv->bottom_marks_widget = gtk_gizmo_new_with_role ("marks",
|
|
|
|
|
GTK_ACCESSIBLE_ROLE_NONE,
|
|
|
|
|
gtk_scale_measure_marks,
|
|
|
|
|
gtk_scale_allocate_marks,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL, NULL);
|
2017-05-13 14:13:22 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_insert_before (priv->bottom_marks_widget,
|
|
|
|
|
GTK_WIDGET (scale),
|
2020-06-26 06:00:04 +00:00
|
|
|
|
gtk_range_get_trough_widget (GTK_RANGE (scale)));
|
2020-08-13 23:49:02 +00:00
|
|
|
|
gtk_widget_add_css_class (priv->bottom_marks_widget, "bottom");
|
2015-11-05 11:45:24 +00:00
|
|
|
|
}
|
2017-05-13 14:13:22 +00:00
|
|
|
|
marks_widget = priv->bottom_marks_widget;
|
2015-11-04 04:11:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-08 11:34:38 +00:00
|
|
|
|
mark->widget = gtk_gizmo_new ("mark", gtk_scale_measure_mark, gtk_scale_allocate_mark, NULL, NULL, NULL, NULL);
|
2017-05-13 14:13:22 +00:00
|
|
|
|
g_object_set_data (G_OBJECT (mark->widget), "mark", mark);
|
|
|
|
|
|
2020-04-08 11:34:38 +00:00
|
|
|
|
mark->indicator_widget = gtk_gizmo_new ("indicator", NULL, NULL, NULL, NULL, NULL, NULL);
|
2017-05-13 14:13:22 +00:00
|
|
|
|
gtk_widget_set_parent (mark->indicator_widget, mark->widget);
|
2016-03-02 19:16:39 +00:00
|
|
|
|
if (mark->markup && *mark->markup)
|
2016-06-03 04:30:59 +00:00
|
|
|
|
{
|
2017-05-13 14:13:22 +00:00
|
|
|
|
mark->label_widget = g_object_new (GTK_TYPE_LABEL,
|
|
|
|
|
"use-markup", TRUE,
|
|
|
|
|
"label", mark->markup,
|
|
|
|
|
NULL);
|
2017-05-22 12:15:39 +00:00
|
|
|
|
if (marks_widget == priv->top_marks_widget)
|
|
|
|
|
gtk_widget_insert_after (mark->label_widget, mark->widget, NULL);
|
|
|
|
|
else
|
|
|
|
|
gtk_widget_insert_before (mark->label_widget, mark->widget, NULL);
|
2016-06-03 04:30:59 +00:00
|
|
|
|
}
|
2016-02-29 05:13:54 +00:00
|
|
|
|
|
2015-11-05 11:45:24 +00:00
|
|
|
|
m = g_slist_find (priv->marks, mark);
|
|
|
|
|
m = m->next;
|
|
|
|
|
while (m)
|
|
|
|
|
{
|
|
|
|
|
GtkScaleMark *next = m->data;
|
|
|
|
|
if (next->position == mark->position)
|
|
|
|
|
break;
|
|
|
|
|
m = m->next;
|
|
|
|
|
}
|
2015-11-04 04:11:52 +00:00
|
|
|
|
|
2015-11-05 11:45:24 +00:00
|
|
|
|
if (m)
|
2015-11-04 04:11:52 +00:00
|
|
|
|
{
|
2015-11-05 11:45:24 +00:00
|
|
|
|
GtkScaleMark *next = m->data;
|
2017-05-13 14:13:22 +00:00
|
|
|
|
gtk_widget_insert_before (mark->widget, marks_widget, next->widget);
|
2015-11-04 04:11:52 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-05-13 14:13:22 +00:00
|
|
|
|
gtk_widget_set_parent (mark->widget, marks_widget);
|
2015-11-04 04:11:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-01-15 19:09:54 +00:00
|
|
|
|
n = g_slist_length (priv->marks);
|
2020-07-24 20:32:16 +00:00
|
|
|
|
values = g_new (double, n);
|
2009-01-20 05:10:27 +00:00
|
|
|
|
for (m = priv->marks, i = 0; m; m = m->next, i++)
|
|
|
|
|
{
|
|
|
|
|
mark = m->data;
|
|
|
|
|
values[i] = mark->value;
|
|
|
|
|
}
|
2011-03-03 21:47:55 +00:00
|
|
|
|
|
2009-01-20 05:10:27 +00:00
|
|
|
|
_gtk_range_set_stop_values (GTK_RANGE (scale), values, n);
|
|
|
|
|
|
|
|
|
|
g_free (values);
|
2009-04-16 04:50:46 +00:00
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if (priv->top_marks_widget)
|
2020-02-06 16:32:26 +00:00
|
|
|
|
gtk_widget_add_css_class (GTK_WIDGET (scale), "marks-before");
|
2020-01-29 11:11:39 +00:00
|
|
|
|
|
2017-05-13 14:13:22 +00:00
|
|
|
|
if (priv->bottom_marks_widget)
|
2020-02-06 16:32:26 +00:00
|
|
|
|
gtk_widget_add_css_class (GTK_WIDGET (scale), "marks-after");
|
2016-05-18 16:59:39 +00:00
|
|
|
|
|
2016-03-06 18:36:43 +00:00
|
|
|
|
gtk_widget_queue_resize (widget);
|
2009-01-20 05:10:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-05-03 01:02:12 +00:00
|
|
|
|
static GtkBuildableIface *parent_buildable_iface;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_scale_buildable_interface_init (GtkBuildableIface *iface)
|
|
|
|
|
{
|
|
|
|
|
parent_buildable_iface = g_type_interface_peek_parent (iface);
|
|
|
|
|
iface->custom_tag_start = gtk_scale_buildable_custom_tag_start;
|
|
|
|
|
iface->custom_finished = gtk_scale_buildable_custom_finished;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
GtkScale *scale;
|
|
|
|
|
GtkBuilder *builder;
|
2012-01-15 19:09:54 +00:00
|
|
|
|
GSList *marks;
|
2009-05-03 01:02:12 +00:00
|
|
|
|
} MarksSubparserData;
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double value;
|
2009-05-03 01:02:12 +00:00
|
|
|
|
GtkPositionType position;
|
|
|
|
|
GString *markup;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char *context;
|
2009-05-03 01:02:12 +00:00
|
|
|
|
gboolean translatable;
|
|
|
|
|
} MarkData;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
mark_data_free (MarkData *data)
|
|
|
|
|
{
|
|
|
|
|
g_string_free (data->markup, TRUE);
|
|
|
|
|
g_free (data->context);
|
|
|
|
|
g_slice_free (MarkData, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-08-29 13:21:20 +00:00
|
|
|
|
marks_start_element (GtkBuildableParseContext *context,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *element_name,
|
|
|
|
|
const char **names,
|
|
|
|
|
const char **values,
|
2019-08-29 13:21:20 +00:00
|
|
|
|
gpointer user_data,
|
|
|
|
|
GError **error)
|
2009-05-03 01:02:12 +00:00
|
|
|
|
{
|
2015-04-25 15:22:30 +00:00
|
|
|
|
MarksSubparserData *data = (MarksSubparserData*)user_data;
|
2009-05-03 01:02:12 +00:00
|
|
|
|
|
|
|
|
|
if (strcmp (element_name, "marks") == 0)
|
2015-04-25 15:22:30 +00:00
|
|
|
|
{
|
|
|
|
|
if (!_gtk_builder_check_parent (data->builder, context, "object", error))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!g_markup_collect_attributes (element_name, names, values, error,
|
|
|
|
|
G_MARKUP_COLLECT_INVALID, NULL, NULL,
|
|
|
|
|
G_MARKUP_COLLECT_INVALID))
|
|
|
|
|
_gtk_builder_prefix_error (data->builder, context, error);
|
|
|
|
|
}
|
2009-05-03 01:02:12 +00:00
|
|
|
|
else if (strcmp (element_name, "mark") == 0)
|
|
|
|
|
{
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *value_str;
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double value = 0;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *position_str = NULL;
|
2009-05-03 01:02:12 +00:00
|
|
|
|
GtkPositionType position = GTK_POS_BOTTOM;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *msg_context = NULL;
|
2009-05-03 01:02:12 +00:00
|
|
|
|
gboolean translatable = FALSE;
|
|
|
|
|
MarkData *mark;
|
|
|
|
|
|
2015-04-25 15:22:30 +00:00
|
|
|
|
if (!_gtk_builder_check_parent (data->builder, context, "marks", error))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!g_markup_collect_attributes (element_name, names, values, error,
|
|
|
|
|
G_MARKUP_COLLECT_STRING, "value", &value_str,
|
|
|
|
|
G_MARKUP_COLLECT_BOOLEAN|G_MARKUP_COLLECT_OPTIONAL, "translatable", &translatable,
|
|
|
|
|
G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "comments", NULL,
|
|
|
|
|
G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "context", &msg_context,
|
|
|
|
|
G_MARKUP_COLLECT_STRING|G_MARKUP_COLLECT_OPTIONAL, "position", &position_str,
|
|
|
|
|
G_MARKUP_COLLECT_INVALID))
|
2009-05-03 01:02:12 +00:00
|
|
|
|
{
|
2015-04-25 15:22:30 +00:00
|
|
|
|
_gtk_builder_prefix_error (data->builder, context, error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-05-03 01:02:12 +00:00
|
|
|
|
|
2015-04-25 15:22:30 +00:00
|
|
|
|
if (value_str != NULL)
|
|
|
|
|
{
|
|
|
|
|
GValue gvalue = G_VALUE_INIT;
|
2009-05-03 01:02:12 +00:00
|
|
|
|
|
2015-04-25 15:22:30 +00:00
|
|
|
|
if (!gtk_builder_value_from_string_type (data->builder, G_TYPE_DOUBLE, value_str, &gvalue, error))
|
2009-05-03 01:02:12 +00:00
|
|
|
|
{
|
2015-04-25 15:22:30 +00:00
|
|
|
|
_gtk_builder_prefix_error (data->builder, context, error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2009-05-03 01:02:12 +00:00
|
|
|
|
|
2015-04-25 15:22:30 +00:00
|
|
|
|
value = g_value_get_double (&gvalue);
|
|
|
|
|
}
|
2009-05-03 01:02:12 +00:00
|
|
|
|
|
2015-04-25 15:22:30 +00:00
|
|
|
|
if (position_str != NULL)
|
|
|
|
|
{
|
|
|
|
|
GValue gvalue = G_VALUE_INIT;
|
|
|
|
|
|
|
|
|
|
if (!gtk_builder_value_from_string_type (data->builder, GTK_TYPE_POSITION_TYPE, position_str, &gvalue, error))
|
2009-05-03 01:02:12 +00:00
|
|
|
|
{
|
2015-04-25 15:22:30 +00:00
|
|
|
|
_gtk_builder_prefix_error (data->builder, context, error);
|
2009-05-03 01:02:12 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-25 15:22:30 +00:00
|
|
|
|
position = g_value_get_enum (&gvalue);
|
2009-05-03 01:02:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mark = g_slice_new (MarkData);
|
|
|
|
|
mark->value = value;
|
2015-04-25 15:22:30 +00:00
|
|
|
|
if (position == GTK_POS_LEFT || position == GTK_POS_TOP)
|
2011-03-03 21:30:21 +00:00
|
|
|
|
mark->position = GTK_POS_TOP;
|
|
|
|
|
else
|
|
|
|
|
mark->position = GTK_POS_BOTTOM;
|
2009-05-03 01:02:12 +00:00
|
|
|
|
mark->markup = g_string_new ("");
|
|
|
|
|
mark->context = g_strdup (msg_context);
|
|
|
|
|
mark->translatable = translatable;
|
|
|
|
|
|
2015-04-25 15:22:30 +00:00
|
|
|
|
data->marks = g_slist_prepend (data->marks, mark);
|
2009-05-03 01:02:12 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-04-25 15:22:30 +00:00
|
|
|
|
_gtk_builder_error_unhandled_tag (data->builder, context,
|
|
|
|
|
"GtkScale", element_name,
|
|
|
|
|
error);
|
2009-05-03 01:02:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-08-29 13:21:20 +00:00
|
|
|
|
marks_text (GtkBuildableParseContext *context,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *text,
|
2019-08-29 13:21:20 +00:00
|
|
|
|
gsize text_len,
|
|
|
|
|
gpointer user_data,
|
|
|
|
|
GError **error)
|
2009-05-03 01:02:12 +00:00
|
|
|
|
{
|
|
|
|
|
MarksSubparserData *data = (MarksSubparserData*)user_data;
|
|
|
|
|
|
2019-08-29 13:21:20 +00:00
|
|
|
|
if (strcmp (gtk_buildable_parse_context_get_element (context), "mark") == 0)
|
2009-05-03 01:02:12 +00:00
|
|
|
|
{
|
|
|
|
|
MarkData *mark = data->marks->data;
|
|
|
|
|
|
|
|
|
|
g_string_append_len (mark->markup, text, text_len);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 13:21:20 +00:00
|
|
|
|
static const GtkBuildableParser marks_parser =
|
2009-05-03 01:02:12 +00:00
|
|
|
|
{
|
|
|
|
|
marks_start_element,
|
|
|
|
|
NULL,
|
|
|
|
|
marks_text,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2019-08-29 13:21:20 +00:00
|
|
|
|
gtk_scale_buildable_custom_tag_start (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *tagname,
|
2019-08-29 13:21:20 +00:00
|
|
|
|
GtkBuildableParser *parser,
|
|
|
|
|
gpointer *parser_data)
|
2009-05-03 01:02:12 +00:00
|
|
|
|
{
|
2015-04-25 15:22:30 +00:00
|
|
|
|
MarksSubparserData *data;
|
2009-05-03 01:02:12 +00:00
|
|
|
|
|
|
|
|
|
if (child)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (strcmp (tagname, "marks") == 0)
|
|
|
|
|
{
|
2015-04-25 15:22:30 +00:00
|
|
|
|
data = g_slice_new0 (MarksSubparserData);
|
|
|
|
|
data->scale = GTK_SCALE (buildable);
|
|
|
|
|
data->builder = builder;
|
|
|
|
|
data->marks = NULL;
|
2009-05-03 01:02:12 +00:00
|
|
|
|
|
|
|
|
|
*parser = marks_parser;
|
2015-04-25 15:22:30 +00:00
|
|
|
|
*parser_data = data;
|
|
|
|
|
|
2009-05-03 01:02:12 +00:00
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return parent_buildable_iface->custom_tag_start (buildable, builder, child,
|
2015-04-25 15:22:30 +00:00
|
|
|
|
tagname, parser, parser_data);
|
2009-05-03 01:02:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_scale_buildable_custom_finished (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *tagname,
|
2009-05-03 01:02:12 +00:00
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GtkScale *scale = GTK_SCALE (buildable);
|
|
|
|
|
MarksSubparserData *marks_data;
|
|
|
|
|
|
|
|
|
|
if (strcmp (tagname, "marks") == 0)
|
|
|
|
|
{
|
2012-01-15 19:09:54 +00:00
|
|
|
|
GSList *m;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *markup;
|
2009-05-03 01:02:12 +00:00
|
|
|
|
|
|
|
|
|
marks_data = (MarksSubparserData *)user_data;
|
|
|
|
|
|
|
|
|
|
for (m = marks_data->marks; m; m = m->next)
|
|
|
|
|
{
|
|
|
|
|
MarkData *mdata = m->data;
|
|
|
|
|
|
|
|
|
|
if (mdata->translatable && mdata->markup->len)
|
|
|
|
|
markup = _gtk_builder_parser_translate (gtk_builder_get_translation_domain (builder),
|
|
|
|
|
mdata->context,
|
|
|
|
|
mdata->markup->str);
|
|
|
|
|
else
|
|
|
|
|
markup = mdata->markup->str;
|
|
|
|
|
|
|
|
|
|
gtk_scale_add_mark (scale, mdata->value, mdata->position, markup);
|
|
|
|
|
|
|
|
|
|
mark_data_free (mdata);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-15 19:09:54 +00:00
|
|
|
|
g_slist_free (marks_data->marks);
|
2009-05-03 01:02:12 +00:00
|
|
|
|
g_slice_free (MarksSubparserData, marks_data);
|
|
|
|
|
}
|
2013-04-08 12:04:50 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
parent_buildable_iface->custom_finished (buildable, builder, child,
|
|
|
|
|
tagname, user_data);
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-03 01:02:12 +00:00
|
|
|
|
}
|
2019-08-09 11:32:24 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_scale_set_format_value_func:
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* @scale: a `GtkScale`
|
2019-08-09 11:32:24 +00:00
|
|
|
|
* @func: (nullable): function that formats the value
|
2020-01-13 01:26:50 +00:00
|
|
|
|
* @user_data: (closure): user data to pass to @func
|
2019-08-15 15:21:47 +00:00
|
|
|
|
* @destroy_notify: (nullable): destroy function for @user_data
|
2019-08-09 11:32:24 +00:00
|
|
|
|
*
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* @func allows you to change how the scale value is displayed.
|
|
|
|
|
*
|
|
|
|
|
* The given function will return an allocated string representing
|
|
|
|
|
* @value. That string will then be used to display the scale's value.
|
2019-08-09 11:32:24 +00:00
|
|
|
|
*
|
|
|
|
|
* If #NULL is passed as @func, the value will be displayed on
|
2021-02-20 04:31:23 +00:00
|
|
|
|
* its own, rounded according to the value of the
|
|
|
|
|
* [property@GtkScale:digits] property.
|
2019-08-09 11:32:24 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_scale_set_format_value_func (GtkScale *scale,
|
|
|
|
|
GtkScaleFormatValueFunc func,
|
2019-08-15 15:21:47 +00:00
|
|
|
|
gpointer user_data,
|
|
|
|
|
GDestroyNotify destroy_notify)
|
2019-08-09 11:32:24 +00:00
|
|
|
|
{
|
|
|
|
|
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_SCALE (scale));
|
|
|
|
|
|
2019-08-15 15:21:47 +00:00
|
|
|
|
if (priv->format_value_func_destroy_notify)
|
|
|
|
|
priv->format_value_func_destroy_notify (priv->format_value_func_user_data);
|
|
|
|
|
|
2019-08-09 11:32:24 +00:00
|
|
|
|
priv->format_value_func = func;
|
|
|
|
|
priv->format_value_func_user_data = user_data;
|
2019-08-15 15:21:47 +00:00
|
|
|
|
priv->format_value_func_destroy_notify = destroy_notify;
|
2019-08-09 11:32:24 +00:00
|
|
|
|
|
2022-09-06 17:27:38 +00:00
|
|
|
|
if (priv->value_widget)
|
|
|
|
|
update_label_request (scale);
|
2019-08-09 11:32:24 +00:00
|
|
|
|
}
|