2008-07-01 22:57:50 +00:00
|
|
|
|
/* GTK - The GIMP Toolkit
|
2007-05-19 23:08:02 +00:00
|
|
|
|
* Copyright (C) 2005 Ronald S. Bultje
|
|
|
|
|
* Copyright (C) 2006, 2007 Christian Persch
|
|
|
|
|
* Copyright (C) 2006 Jan Arne Petersen
|
|
|
|
|
* Copyright (C) 2005-2007 Red Hat, Inc.
|
2014-01-30 02:20:22 +00:00
|
|
|
|
* Copyright (C) 2014 Red Hat, Inc.
|
2007-05-19 23:08:02 +00:00
|
|
|
|
*
|
|
|
|
|
* Authors:
|
|
|
|
|
* - Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
|
|
|
|
* - Bastien Nocera <bnocera@redhat.com>
|
|
|
|
|
* - Jan Arne Petersen <jpetersen@jpetersen.org>
|
|
|
|
|
* - Christian Persch <chpe@svn.gnome.org>
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* 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
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* 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/>.
|
2007-05-19 23:08:02 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Modified by the GTK+ Team and others 2007. See the AUTHORS
|
|
|
|
|
* 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-06-26 17:14:27 +00:00
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
2007-05-19 23:08:02 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
|
#include "config.h"
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
2012-03-03 18:41:55 +00:00
|
|
|
|
#include "gtkscalebutton.h"
|
|
|
|
|
|
|
|
|
|
#include "gtkadjustment.h"
|
2018-02-08 23:42:38 +00:00
|
|
|
|
#include "gtkbox.h"
|
|
|
|
|
#include "gtkbuttonprivate.h"
|
2020-04-10 00:24:23 +00:00
|
|
|
|
#include "gtktogglebutton.h"
|
2018-02-08 23:42:38 +00:00
|
|
|
|
#include "gtkeventcontrollerscroll.h"
|
2007-05-19 23:08:02 +00:00
|
|
|
|
#include "gtkframe.h"
|
2018-02-08 23:42:38 +00:00
|
|
|
|
#include "gtkgesture.h"
|
|
|
|
|
#include "gtkintl.h"
|
2009-02-19 15:10:34 +00:00
|
|
|
|
#include "gtkmain.h"
|
2007-05-19 23:08:02 +00:00
|
|
|
|
#include "gtkmarshalers.h"
|
2009-02-19 15:10:34 +00:00
|
|
|
|
#include "gtkorientable.h"
|
2014-01-30 02:20:22 +00:00
|
|
|
|
#include "gtkpopover.h"
|
2007-06-10 01:26:28 +00:00
|
|
|
|
#include "gtkprivate.h"
|
2017-12-13 03:21:43 +00:00
|
|
|
|
#include "gtkrangeprivate.h"
|
2018-02-08 23:42:38 +00:00
|
|
|
|
#include "gtkscale.h"
|
|
|
|
|
#include "gtktypebuiltins.h"
|
2020-04-10 00:24:23 +00:00
|
|
|
|
#include "gtkwidgetprivate.h"
|
2014-07-04 05:06:31 +00:00
|
|
|
|
#include "gtkwindowprivate.h"
|
2019-05-04 17:14:06 +00:00
|
|
|
|
#include "gtknative.h"
|
2018-02-08 23:42:38 +00:00
|
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2010-05-15 22:32:05 +00:00
|
|
|
|
/**
|
|
|
|
|
* SECTION:gtkscalebutton
|
|
|
|
|
* @Short_description: A button which pops up a scale
|
|
|
|
|
* @Title: GtkScaleButton
|
|
|
|
|
*
|
|
|
|
|
* #GtkScaleButton provides a button which pops up a scale widget.
|
|
|
|
|
* This kind of widget is commonly used for volume controls in multimedia
|
2020-09-12 16:01:04 +00:00
|
|
|
|
* applications, and GTK provides a #GtkVolumeButton subclass that
|
2010-05-15 22:32:05 +00:00
|
|
|
|
* is tailored for this use case.
|
2015-10-30 04:51:13 +00:00
|
|
|
|
*
|
|
|
|
|
* # CSS nodes
|
|
|
|
|
*
|
|
|
|
|
* GtkScaleButton has a single CSS node with name button. To differentiate
|
|
|
|
|
* it from a plain #GtkButton, it gets the .scale style class.
|
2010-05-15 22:32:05 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2007-05-19 23:08:02 +00:00
|
|
|
|
#define SCALE_SIZE 100
|
|
|
|
|
|
2007-06-10 15:32:02 +00:00
|
|
|
|
enum
|
|
|
|
|
{
|
2007-05-19 23:08:02 +00:00
|
|
|
|
VALUE_CHANGED,
|
|
|
|
|
POPUP,
|
|
|
|
|
POPDOWN,
|
2007-06-10 15:32:02 +00:00
|
|
|
|
|
2007-05-19 23:08:02 +00:00
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
2007-06-10 15:32:02 +00:00
|
|
|
|
enum
|
|
|
|
|
{
|
2007-05-19 23:08:02 +00:00
|
|
|
|
PROP_0,
|
2008-06-26 17:14:27 +00:00
|
|
|
|
|
2008-06-27 09:33:32 +00:00
|
|
|
|
PROP_ORIENTATION,
|
2007-05-19 23:08:02 +00:00
|
|
|
|
PROP_VALUE,
|
|
|
|
|
PROP_SIZE,
|
2007-06-10 01:26:28 +00:00
|
|
|
|
PROP_ADJUSTMENT,
|
|
|
|
|
PROP_ICONS
|
2007-05-19 23:08:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
2018-07-08 07:39:05 +00:00
|
|
|
|
typedef struct
|
2007-06-10 15:32:02 +00:00
|
|
|
|
{
|
2020-04-10 00:24:23 +00:00
|
|
|
|
GtkWidget *button;
|
|
|
|
|
|
2010-07-08 01:13:10 +00:00
|
|
|
|
GtkWidget *plus_button;
|
|
|
|
|
GtkWidget *minus_button;
|
2007-06-10 15:32:02 +00:00
|
|
|
|
GtkWidget *dock;
|
2009-02-19 15:10:34 +00:00
|
|
|
|
GtkWidget *box;
|
2007-06-10 15:32:02 +00:00
|
|
|
|
GtkWidget *scale;
|
2014-01-30 02:20:22 +00:00
|
|
|
|
GtkWidget *active_button;
|
2007-06-10 15:32:02 +00:00
|
|
|
|
|
2008-06-27 09:33:32 +00:00
|
|
|
|
GtkOrientation orientation;
|
2014-07-04 05:06:31 +00:00
|
|
|
|
GtkOrientation applied_orientation;
|
2008-06-26 17:14:27 +00:00
|
|
|
|
|
2017-12-13 03:21:43 +00:00
|
|
|
|
guint autoscroll_timeout;
|
|
|
|
|
GtkScrollType autoscroll_step;
|
|
|
|
|
gboolean autoscrolling;
|
|
|
|
|
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char **icon_list;
|
2008-06-27 09:33:32 +00:00
|
|
|
|
|
|
|
|
|
GtkAdjustment *adjustment; /* needed because it must be settable in init() */
|
2018-07-08 07:39:05 +00:00
|
|
|
|
} GtkScaleButtonPrivate;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
static void gtk_scale_button_constructed (GObject *object);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
static void gtk_scale_button_dispose (GObject *object);
|
2007-06-10 15:32:02 +00:00
|
|
|
|
static void gtk_scale_button_finalize (GObject *object);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
static void gtk_scale_button_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
static void gtk_scale_button_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
2019-05-04 17:14:06 +00:00
|
|
|
|
static void gtk_scale_button_size_allocate (GtkWidget *widget,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
int baseline);
|
2020-04-10 00:24:23 +00:00
|
|
|
|
static void gtk_scale_button_measure (GtkWidget *widget,
|
|
|
|
|
GtkOrientation orientation,
|
|
|
|
|
int for_size,
|
|
|
|
|
int *minimum,
|
|
|
|
|
int *natural,
|
|
|
|
|
int *minimum_baseline,
|
|
|
|
|
int *natural_baseline);
|
2009-03-18 21:19:07 +00:00
|
|
|
|
static void gtk_scale_button_set_orientation_private (GtkScaleButton *button,
|
|
|
|
|
GtkOrientation orientation);
|
2008-07-03 13:13:23 +00:00
|
|
|
|
static void gtk_scale_button_popup (GtkWidget *widget);
|
|
|
|
|
static void gtk_scale_button_popdown (GtkWidget *widget);
|
2014-01-30 02:20:22 +00:00
|
|
|
|
static void cb_button_clicked (GtkWidget *button,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
static void gtk_scale_button_update_icon (GtkScaleButton *button);
|
|
|
|
|
static void cb_scale_value_changed (GtkRange *range,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
static void cb_popup_mapped (GtkWidget *popup,
|
|
|
|
|
gpointer user_data);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
2018-07-18 13:34:39 +00:00
|
|
|
|
static gboolean gtk_scale_button_scroll_controller_scroll (GtkEventControllerScroll *scroll,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double dx,
|
|
|
|
|
double dy,
|
2017-09-15 11:54:20 +00:00
|
|
|
|
GtkScaleButton *button);
|
|
|
|
|
|
2020-04-10 00:24:23 +00:00
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkScaleButton, gtk_scale_button, GTK_TYPE_WIDGET,
|
2013-06-27 19:02:52 +00:00
|
|
|
|
G_ADD_PRIVATE (GtkScaleButton)
|
2020-04-10 00:24:23 +00:00
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL))
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
2009-01-13 15:24:03 +00:00
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0, };
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_scale_button_class_init (GtkScaleButtonClass *klass)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
gobject_class->constructed = gtk_scale_button_constructed;
|
2007-06-10 15:32:02 +00:00
|
|
|
|
gobject_class->finalize = gtk_scale_button_finalize;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
gobject_class->dispose = gtk_scale_button_dispose;
|
|
|
|
|
gobject_class->set_property = gtk_scale_button_set_property;
|
|
|
|
|
gobject_class->get_property = gtk_scale_button_get_property;
|
2008-06-26 17:14:27 +00:00
|
|
|
|
|
2020-04-10 00:24:23 +00:00
|
|
|
|
widget_class->measure = gtk_scale_button_measure;
|
2019-05-04 17:14:06 +00:00
|
|
|
|
widget_class->size_allocate = gtk_scale_button_size_allocate;
|
2020-04-10 00:24:23 +00:00
|
|
|
|
widget_class->focus = gtk_widget_focus_child;
|
|
|
|
|
widget_class->grab_focus = gtk_widget_grab_focus_child;
|
2019-05-04 17:14:06 +00:00
|
|
|
|
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
2008-06-30 23:41:10 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkScaleButton:orientation:
|
|
|
|
|
*
|
|
|
|
|
* The orientation of the #GtkScaleButton's popup window.
|
|
|
|
|
*
|
2020-09-12 16:01:04 +00:00
|
|
|
|
* Note that #GtkScaleButton implements the #GtkOrientable interface
|
|
|
|
|
* which has its own @orientation property. However, we redefine the
|
|
|
|
|
* property here in order to override its default horizontal orientation.
|
2008-06-30 23:41:10 +00:00
|
|
|
|
**/
|
2009-01-13 15:24:03 +00:00
|
|
|
|
g_object_class_override_property (gobject_class,
|
|
|
|
|
PROP_ORIENTATION,
|
|
|
|
|
"orientation");
|
2008-06-27 09:33:32 +00:00
|
|
|
|
|
2007-05-19 23:08:02 +00:00
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
|
PROP_VALUE,
|
|
|
|
|
g_param_spec_double ("value",
|
|
|
|
|
P_("Value"),
|
|
|
|
|
P_("The value of the scale"),
|
|
|
|
|
-G_MAXDOUBLE,
|
|
|
|
|
G_MAXDOUBLE,
|
|
|
|
|
0,
|
2014-06-09 13:22:05 +00:00
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
|
PROP_ADJUSTMENT,
|
|
|
|
|
g_param_spec_object ("adjustment",
|
|
|
|
|
P_("Adjustment"),
|
|
|
|
|
P_("The GtkAdjustment that contains the current value of this scale button object"),
|
|
|
|
|
GTK_TYPE_ADJUSTMENT,
|
2007-06-10 01:26:28 +00:00
|
|
|
|
GTK_PARAM_READWRITE));
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
2007-06-10 01:26:28 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkScaleButton:icons:
|
|
|
|
|
*
|
2008-06-26 17:14:27 +00:00
|
|
|
|
* The names of the icons to be used by the scale button.
|
|
|
|
|
* The first item in the array will be used in the button
|
|
|
|
|
* when the current value is the lowest value, the second
|
|
|
|
|
* item for the highest value. All the subsequent icons will
|
|
|
|
|
* be used for all the other values, spread evenly over the
|
2007-06-10 01:26:28 +00:00
|
|
|
|
* range of values.
|
|
|
|
|
*
|
2008-06-26 17:14:27 +00:00
|
|
|
|
* If there's only one icon name in the @icons array, it will
|
|
|
|
|
* be used for all the values. If only two icon names are in
|
|
|
|
|
* the @icons array, the first one will be used for the bottom
|
2007-06-10 01:26:28 +00:00
|
|
|
|
* 50% of the scale, and the second one for the top 50%.
|
|
|
|
|
*
|
2008-06-26 17:14:27 +00:00
|
|
|
|
* It is recommended to use at least 3 icons so that the
|
|
|
|
|
* #GtkScaleButton reflects the current value of the scale
|
2007-06-10 01:26:28 +00:00
|
|
|
|
* better for the users.
|
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
|
PROP_ICONS,
|
|
|
|
|
g_param_spec_boxed ("icons",
|
|
|
|
|
P_("Icons"),
|
|
|
|
|
P_("List of icon names"),
|
|
|
|
|
G_TYPE_STRV,
|
|
|
|
|
GTK_PARAM_READWRITE));
|
2007-07-16 15:00:05 +00:00
|
|
|
|
|
2007-05-19 23:08:02 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkScaleButton::value-changed:
|
2007-07-16 15:00:05 +00:00
|
|
|
|
* @button: the object which received the signal
|
|
|
|
|
* @value: the new value
|
2007-05-19 23:08:02 +00:00
|
|
|
|
*
|
2007-07-16 15:00:05 +00:00
|
|
|
|
* The ::value-changed signal is emitted when the value field has
|
|
|
|
|
* changed.
|
2007-05-19 23:08:02 +00:00
|
|
|
|
*/
|
|
|
|
|
signals[VALUE_CHANGED] =
|
|
|
|
|
g_signal_new (I_("value-changed"),
|
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (GtkScaleButtonClass, value_changed),
|
|
|
|
|
NULL, NULL,
|
2016-08-29 14:00:17 +00:00
|
|
|
|
NULL,
|
2007-05-19 23:08:02 +00:00
|
|
|
|
G_TYPE_NONE, 1, G_TYPE_DOUBLE);
|
2008-06-26 17:14:27 +00:00
|
|
|
|
|
2007-07-16 15:00:05 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkScaleButton::popup:
|
|
|
|
|
* @button: the object which received the signal
|
|
|
|
|
*
|
2008-06-26 17:14:27 +00:00
|
|
|
|
* The ::popup signal is a
|
2020-11-17 03:58:53 +00:00
|
|
|
|
* [keybinding signal][GtkSignalAction]
|
2007-07-16 15:00:05 +00:00
|
|
|
|
* which gets emitted to popup the scale widget.
|
|
|
|
|
*
|
|
|
|
|
* The default bindings for this signal are Space, Enter and Return.
|
|
|
|
|
*/
|
2007-05-19 23:08:02 +00:00
|
|
|
|
signals[POPUP] =
|
2008-07-21 09:48:20 +00:00
|
|
|
|
g_signal_new_class_handler (I_("popup"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (klass),
|
|
|
|
|
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (gtk_scale_button_popup),
|
|
|
|
|
NULL, NULL,
|
2019-05-29 20:05:19 +00:00
|
|
|
|
NULL,
|
2008-07-21 09:48:20 +00:00
|
|
|
|
G_TYPE_NONE, 0);
|
2007-07-16 15:00:05 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkScaleButton::popdown:
|
|
|
|
|
* @button: the object which received the signal
|
|
|
|
|
*
|
2008-06-26 17:14:27 +00:00
|
|
|
|
* The ::popdown signal is a
|
2020-11-17 03:58:53 +00:00
|
|
|
|
* [keybinding signal][GtkSignalAction]
|
2007-07-16 15:00:05 +00:00
|
|
|
|
* which gets emitted to popdown the scale widget.
|
|
|
|
|
*
|
|
|
|
|
* The default binding for this signal is Escape.
|
|
|
|
|
*/
|
2007-05-19 23:08:02 +00:00
|
|
|
|
signals[POPDOWN] =
|
2008-07-21 09:48:20 +00:00
|
|
|
|
g_signal_new_class_handler (I_("popdown"),
|
|
|
|
|
G_OBJECT_CLASS_TYPE (klass),
|
|
|
|
|
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (gtk_scale_button_popdown),
|
|
|
|
|
NULL, NULL,
|
2019-05-29 20:05:19 +00:00
|
|
|
|
NULL,
|
2008-07-21 09:48:20 +00:00
|
|
|
|
G_TYPE_NONE, 0);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
|
|
|
|
/* Key bindings */
|
2018-08-12 13:50:45 +00:00
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_space, 0,
|
|
|
|
|
"popup",
|
|
|
|
|
NULL);
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_KP_Space, 0,
|
|
|
|
|
"popup",
|
|
|
|
|
NULL);
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_Return, 0,
|
|
|
|
|
"popup",
|
|
|
|
|
NULL);
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_ISO_Enter, 0,
|
|
|
|
|
"popup",
|
|
|
|
|
NULL);
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_KP_Enter, 0,
|
|
|
|
|
"popup",
|
|
|
|
|
NULL);
|
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_Escape, 0,
|
|
|
|
|
"popdown",
|
|
|
|
|
NULL);
|
2011-06-29 02:45:42 +00:00
|
|
|
|
|
2013-03-23 11:17:15 +00:00
|
|
|
|
/* Bind class to template
|
|
|
|
|
*/
|
|
|
|
|
gtk_widget_class_set_template_from_resource (widget_class,
|
2014-01-23 23:59:20 +00:00
|
|
|
|
"/org/gtk/libgtk/ui/gtkscalebutton.ui");
|
2013-03-23 11:17:15 +00:00
|
|
|
|
|
2020-04-10 00:24:23 +00:00
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkScaleButton, button);
|
2013-07-26 20:29:12 +00:00
|
|
|
|
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkScaleButton, plus_button);
|
|
|
|
|
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkScaleButton, minus_button);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkScaleButton, dock);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkScaleButton, box);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkScaleButton, scale);
|
2013-07-26 17:49:49 +00:00
|
|
|
|
|
2014-01-30 02:20:22 +00:00
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, cb_button_clicked);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, cb_scale_value_changed);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, cb_popup_mapped);
|
2013-03-23 11:17:15 +00:00
|
|
|
|
|
2020-04-10 00:24:23 +00:00
|
|
|
|
gtk_widget_class_set_css_name (widget_class, I_("scalebutton"));
|
2007-05-19 23:08:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-13 03:21:43 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
start_autoscroll (gpointer data)
|
|
|
|
|
{
|
|
|
|
|
GtkScaleButton *button = data;
|
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
|
|
|
|
|
|
|
|
|
gtk_range_start_autoscroll (GTK_RANGE (priv->scale), priv->autoscroll_step);
|
|
|
|
|
|
|
|
|
|
priv->autoscrolling = TRUE;
|
|
|
|
|
priv->autoscroll_timeout = 0;
|
|
|
|
|
|
|
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
button_pressed_cb (GtkGesture *gesture,
|
|
|
|
|
int n_press,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
GtkScaleButton *button)
|
|
|
|
|
{
|
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
|
|
|
|
|
widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture));
|
|
|
|
|
if (widget == priv->plus_button)
|
|
|
|
|
priv->autoscroll_step = GTK_SCROLL_PAGE_FORWARD;
|
|
|
|
|
else
|
|
|
|
|
priv->autoscroll_step = GTK_SCROLL_PAGE_BACKWARD;
|
|
|
|
|
priv->autoscroll_timeout = g_timeout_add (200, start_autoscroll, button);
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-10 00:24:23 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_scale_button_toggled (GtkScaleButton *button)
|
|
|
|
|
{
|
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
|
|
|
|
gboolean active;
|
|
|
|
|
|
|
|
|
|
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->button));
|
|
|
|
|
|
|
|
|
|
if (active)
|
|
|
|
|
gtk_popover_popup (GTK_POPOVER (priv->dock));
|
|
|
|
|
else
|
|
|
|
|
gtk_popover_popdown (GTK_POPOVER (priv->dock));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_scale_button_closed (GtkScaleButton *button)
|
|
|
|
|
{
|
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
|
|
|
|
|
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button), FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-19 23:08:02 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_scale_button_init (GtkScaleButton *button)
|
|
|
|
|
{
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
2018-03-10 17:29:57 +00:00
|
|
|
|
GtkEventController *controller;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
2008-06-30 23:41:10 +00:00
|
|
|
|
priv->orientation = GTK_ORIENTATION_VERTICAL;
|
2014-07-04 05:06:31 +00:00
|
|
|
|
priv->applied_orientation = GTK_ORIENTATION_VERTICAL;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
2013-03-23 11:17:15 +00:00
|
|
|
|
gtk_widget_init_template (GTK_WIDGET (button));
|
2020-02-24 12:21:46 +00:00
|
|
|
|
gtk_widget_set_parent (priv->dock, GTK_WIDGET (button));
|
2013-03-23 11:17:15 +00:00
|
|
|
|
|
|
|
|
|
/* Need a local reference to the adjustment */
|
2016-11-28 20:00:10 +00:00
|
|
|
|
priv->adjustment = gtk_adjustment_new (0, 0, 100, 2, 20, 0);
|
|
|
|
|
g_object_ref_sink (priv->adjustment);
|
|
|
|
|
gtk_range_set_adjustment (GTK_RANGE (priv->scale), priv->adjustment);
|
2012-02-23 13:47:13 +00:00
|
|
|
|
|
2020-10-11 15:46:06 +00:00
|
|
|
|
gtk_accessible_update_property (GTK_ACCESSIBLE (button),
|
|
|
|
|
GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, gtk_adjustment_get_upper (priv->adjustment),
|
|
|
|
|
GTK_ACCESSIBLE_PROPERTY_VALUE_MIN, gtk_adjustment_get_lower (priv->adjustment),
|
|
|
|
|
GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, gtk_adjustment_get_value (priv->adjustment),
|
|
|
|
|
-1);
|
|
|
|
|
|
2020-02-06 16:32:26 +00:00
|
|
|
|
gtk_widget_add_css_class (GTK_WIDGET (button), "scale");
|
2017-09-15 11:54:20 +00:00
|
|
|
|
|
2018-03-10 17:29:57 +00:00
|
|
|
|
controller = gtk_event_controller_scroll_new (GTK_EVENT_CONTROLLER_SCROLL_VERTICAL);
|
|
|
|
|
g_signal_connect (controller, "scroll",
|
2017-09-15 11:54:20 +00:00
|
|
|
|
G_CALLBACK (gtk_scale_button_scroll_controller_scroll),
|
|
|
|
|
button);
|
2018-03-10 17:29:57 +00:00
|
|
|
|
gtk_widget_add_controller (GTK_WIDGET (button), controller);
|
2017-12-13 03:21:43 +00:00
|
|
|
|
|
2020-04-10 00:24:23 +00:00
|
|
|
|
g_signal_connect_swapped (priv->dock, "closed",
|
|
|
|
|
G_CALLBACK (gtk_scale_button_closed), button);
|
|
|
|
|
g_signal_connect_swapped (priv->button, "toggled",
|
|
|
|
|
G_CALLBACK (gtk_scale_button_toggled), button);
|
|
|
|
|
|
2017-12-13 03:21:43 +00:00
|
|
|
|
g_signal_connect (gtk_button_get_gesture (GTK_BUTTON (priv->plus_button)),
|
|
|
|
|
"pressed", G_CALLBACK (button_pressed_cb), button);
|
|
|
|
|
g_signal_connect (gtk_button_get_gesture (GTK_BUTTON (priv->minus_button)),
|
|
|
|
|
"pressed", G_CALLBACK (button_pressed_cb), button);
|
2008-06-27 09:33:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_scale_button_constructed (GObject *object)
|
2008-06-27 09:33:32 +00:00
|
|
|
|
{
|
2014-06-26 22:22:42 +00:00
|
|
|
|
GtkScaleButton *button = GTK_SCALE_BUTTON (object);
|
2008-06-27 09:33:32 +00:00
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_scale_button_parent_class)->constructed (object);
|
2008-06-27 09:33:32 +00:00
|
|
|
|
|
2007-05-19 23:08:02 +00:00
|
|
|
|
/* set button text and size */
|
|
|
|
|
gtk_scale_button_update_icon (button);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_scale_button_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
2008-06-30 23:41:10 +00:00
|
|
|
|
GtkScaleButton *button = GTK_SCALE_BUTTON (object);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
2008-06-27 09:33:32 +00:00
|
|
|
|
case PROP_ORIENTATION:
|
2009-03-18 21:19:07 +00:00
|
|
|
|
gtk_scale_button_set_orientation_private (button, g_value_get_enum (value));
|
2008-06-27 09:33:32 +00:00
|
|
|
|
break;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
case PROP_VALUE:
|
|
|
|
|
gtk_scale_button_set_value (button, g_value_get_double (value));
|
|
|
|
|
break;
|
|
|
|
|
case PROP_ADJUSTMENT:
|
|
|
|
|
gtk_scale_button_set_adjustment (button, g_value_get_object (value));
|
|
|
|
|
break;
|
2007-06-10 01:26:28 +00:00
|
|
|
|
case PROP_ICONS:
|
2008-06-26 17:14:27 +00:00
|
|
|
|
gtk_scale_button_set_icons (button,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
(const char **)g_value_get_boxed (value));
|
2007-06-10 01:26:28 +00:00
|
|
|
|
break;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-06-26 17:14:27 +00:00
|
|
|
|
static void
|
2007-05-19 23:08:02 +00:00
|
|
|
|
gtk_scale_button_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
2008-06-30 23:41:10 +00:00
|
|
|
|
GtkScaleButton *button = GTK_SCALE_BUTTON (object);
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
2008-06-27 09:33:32 +00:00
|
|
|
|
case PROP_ORIENTATION:
|
|
|
|
|
g_value_set_enum (value, priv->orientation);
|
|
|
|
|
break;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
case PROP_VALUE:
|
2007-09-13 21:25:48 +00:00
|
|
|
|
g_value_set_double (value, gtk_scale_button_get_value (button));
|
2007-05-19 23:08:02 +00:00
|
|
|
|
break;
|
|
|
|
|
case PROP_ADJUSTMENT:
|
|
|
|
|
g_value_set_object (value, gtk_scale_button_get_adjustment (button));
|
|
|
|
|
break;
|
2007-06-10 01:26:28 +00:00
|
|
|
|
case PROP_ICONS:
|
|
|
|
|
g_value_set_boxed (value, priv->icon_list);
|
|
|
|
|
break;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2007-06-10 15:32:02 +00:00
|
|
|
|
gtk_scale_button_finalize (GObject *object)
|
2007-05-19 23:08:02 +00:00
|
|
|
|
{
|
2007-06-10 15:32:02 +00:00
|
|
|
|
GtkScaleButton *button = GTK_SCALE_BUTTON (object);
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
2008-06-26 17:14:27 +00:00
|
|
|
|
|
2020-04-27 09:56:55 +00:00
|
|
|
|
g_clear_pointer (&priv->icon_list, g_strfreev);
|
|
|
|
|
g_clear_object (&priv->adjustment);
|
|
|
|
|
g_clear_handle_id (&priv->autoscroll_timeout, g_source_remove);
|
2017-12-13 03:21:43 +00:00
|
|
|
|
|
2007-06-10 15:32:02 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_scale_button_parent_class)->finalize (object);
|
|
|
|
|
}
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
2007-06-10 15:32:02 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_scale_button_dispose (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GtkScaleButton *button = GTK_SCALE_BUTTON (object);
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
2019-03-22 02:12:22 +00:00
|
|
|
|
g_clear_pointer (&priv->dock, gtk_widget_unparent);
|
2020-04-10 00:24:23 +00:00
|
|
|
|
g_clear_pointer (&priv->button, gtk_widget_unparent);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
2007-06-10 15:32:02 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_scale_button_parent_class)->dispose (object);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2008-06-20 14:22:26 +00:00
|
|
|
|
* gtk_scale_button_new:
|
2007-05-26 20:22:51 +00:00
|
|
|
|
* @min: the minimum value of the scale (usually 0)
|
|
|
|
|
* @max: the maximum value of the scale (usually 100)
|
|
|
|
|
* @step: the stepping of value when a scroll-wheel event,
|
|
|
|
|
* or up/down arrow event occurs (usually 2)
|
2011-01-18 09:10:30 +00:00
|
|
|
|
* @icons: (allow-none) (array zero-terminated=1): a %NULL-terminated
|
|
|
|
|
* array of icon names, or %NULL if you want to set the list
|
|
|
|
|
* later with gtk_scale_button_set_icons()
|
2007-05-19 23:08:02 +00:00
|
|
|
|
*
|
2007-05-26 20:22:51 +00:00
|
|
|
|
* Creates a #GtkScaleButton, with a range between @min and @max, with
|
|
|
|
|
* a stepping of @step.
|
2007-05-19 23:08:02 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: a new #GtkScaleButton
|
2007-05-19 23:08:02 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkWidget *
|
2020-07-24 20:32:16 +00:00
|
|
|
|
gtk_scale_button_new (double min,
|
|
|
|
|
double max,
|
|
|
|
|
double step,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char **icons)
|
2007-05-19 23:08:02 +00:00
|
|
|
|
{
|
|
|
|
|
GtkScaleButton *button;
|
2011-01-05 22:02:10 +00:00
|
|
|
|
GtkAdjustment *adjustment;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
2011-01-05 22:02:10 +00:00
|
|
|
|
adjustment = gtk_adjustment_new (min, min, max, step, 10 * step, 0);
|
2008-06-26 17:14:27 +00:00
|
|
|
|
|
|
|
|
|
button = g_object_new (GTK_TYPE_SCALE_BUTTON,
|
2011-01-05 22:02:10 +00:00
|
|
|
|
"adjustment", adjustment,
|
2007-06-10 01:26:28 +00:00
|
|
|
|
"icons", icons,
|
|
|
|
|
NULL);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
|
|
|
|
return GTK_WIDGET (button);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2008-06-20 14:22:26 +00:00
|
|
|
|
* gtk_scale_button_get_value:
|
2007-05-19 23:08:02 +00:00
|
|
|
|
* @button: a #GtkScaleButton
|
|
|
|
|
*
|
|
|
|
|
* Gets the current value of the scale button.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: current value of the scale button
|
2007-05-19 23:08:02 +00:00
|
|
|
|
*/
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double
|
2007-05-19 23:08:02 +00:00
|
|
|
|
gtk_scale_button_get_value (GtkScaleButton * button)
|
|
|
|
|
{
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_SCALE_BUTTON (button), 0);
|
|
|
|
|
|
2008-06-27 09:33:32 +00:00
|
|
|
|
return gtk_adjustment_get_value (priv->adjustment);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2008-06-20 14:22:26 +00:00
|
|
|
|
* gtk_scale_button_set_value:
|
2007-05-19 23:08:02 +00:00
|
|
|
|
* @button: a #GtkScaleButton
|
|
|
|
|
* @value: new value of the scale button
|
|
|
|
|
*
|
2008-06-26 17:14:27 +00:00
|
|
|
|
* Sets the current value of the scale; if the value is outside
|
|
|
|
|
* the minimum or maximum range values, it will be clamped to fit
|
|
|
|
|
* inside them. The scale button emits the #GtkScaleButton::value-changed
|
2007-06-10 01:26:28 +00:00
|
|
|
|
* signal if the value changes.
|
2007-05-19 23:08:02 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_scale_button_set_value (GtkScaleButton *button,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double value)
|
2007-05-19 23:08:02 +00:00
|
|
|
|
{
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_SCALE_BUTTON (button));
|
|
|
|
|
|
|
|
|
|
gtk_range_set_value (GTK_RANGE (priv->scale), value);
|
2014-06-09 13:22:05 +00:00
|
|
|
|
g_object_notify (G_OBJECT (button), "value");
|
2007-05-19 23:08:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2008-06-20 14:22:26 +00:00
|
|
|
|
* gtk_scale_button_set_icons:
|
2007-05-19 23:08:02 +00:00
|
|
|
|
* @button: a #GtkScaleButton
|
2011-01-18 09:10:30 +00:00
|
|
|
|
* @icons: (array zero-terminated=1): a %NULL-terminated array of icon names
|
2007-05-19 23:08:02 +00:00
|
|
|
|
*
|
2008-06-26 17:14:27 +00:00
|
|
|
|
* Sets the icons to be used by the scale button.
|
2007-06-10 01:26:28 +00:00
|
|
|
|
* For details, see the #GtkScaleButton:icons property.
|
2007-05-19 23:08:02 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_scale_button_set_icons (GtkScaleButton *button,
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char **icons)
|
2007-05-19 23:08:02 +00:00
|
|
|
|
{
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
2020-07-24 18:40:36 +00:00
|
|
|
|
char **tmp;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_SCALE_BUTTON (button));
|
|
|
|
|
|
2007-06-10 01:26:28 +00:00
|
|
|
|
tmp = priv->icon_list;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
priv->icon_list = g_strdupv ((char **) icons);
|
2007-06-10 01:26:28 +00:00
|
|
|
|
g_strfreev (tmp);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
gtk_scale_button_update_icon (button);
|
2007-06-10 01:26:28 +00:00
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (button), "icons");
|
2007-05-19 23:08:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2007-06-10 01:26:28 +00:00
|
|
|
|
* gtk_scale_button_get_adjustment:
|
2007-05-19 23:08:02 +00:00
|
|
|
|
* @button: a #GtkScaleButton
|
|
|
|
|
*
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* Gets the #GtkAdjustment associated with the #GtkScaleButton’s scale.
|
2007-05-19 23:08:02 +00:00
|
|
|
|
* See gtk_range_get_adjustment() for details.
|
|
|
|
|
*
|
2010-09-21 04:18:11 +00:00
|
|
|
|
* Returns: (transfer none): the adjustment associated with the scale
|
2007-05-19 23:08:02 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkAdjustment*
|
|
|
|
|
gtk_scale_button_get_adjustment (GtkScaleButton *button)
|
|
|
|
|
{
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
|
|
|
|
|
2007-05-19 23:08:02 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_SCALE_BUTTON (button), NULL);
|
|
|
|
|
|
2018-07-08 07:39:05 +00:00
|
|
|
|
return priv->adjustment;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2008-06-20 14:22:26 +00:00
|
|
|
|
* gtk_scale_button_set_adjustment:
|
2007-05-19 23:08:02 +00:00
|
|
|
|
* @button: a #GtkScaleButton
|
|
|
|
|
* @adjustment: a #GtkAdjustment
|
|
|
|
|
*
|
2008-06-26 17:14:27 +00:00
|
|
|
|
* Sets the #GtkAdjustment to be used as a model
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* for the #GtkScaleButton’s scale.
|
2007-05-19 23:08:02 +00:00
|
|
|
|
* See gtk_range_set_adjustment() for details.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_scale_button_set_adjustment (GtkScaleButton *button,
|
|
|
|
|
GtkAdjustment *adjustment)
|
|
|
|
|
{
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
|
|
|
|
|
2007-05-19 23:08:02 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_SCALE_BUTTON (button));
|
2010-09-27 13:10:12 +00:00
|
|
|
|
|
2008-10-09 16:19:06 +00:00
|
|
|
|
if (!adjustment)
|
2010-09-27 13:10:12 +00:00
|
|
|
|
adjustment = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
2008-10-09 16:19:06 +00:00
|
|
|
|
else
|
|
|
|
|
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
2018-07-08 07:39:05 +00:00
|
|
|
|
if (priv->adjustment != adjustment)
|
2008-10-09 16:19:06 +00:00
|
|
|
|
{
|
2018-07-08 07:39:05 +00:00
|
|
|
|
if (priv->adjustment)
|
|
|
|
|
g_object_unref (priv->adjustment);
|
|
|
|
|
priv->adjustment = g_object_ref_sink (adjustment);
|
2008-06-27 09:33:32 +00:00
|
|
|
|
|
2018-07-08 07:39:05 +00:00
|
|
|
|
if (priv->scale)
|
|
|
|
|
gtk_range_set_adjustment (GTK_RANGE (priv->scale), adjustment);
|
2007-06-10 01:26:28 +00:00
|
|
|
|
|
2008-10-09 16:19:06 +00:00
|
|
|
|
g_object_notify (G_OBJECT (button), "adjustment");
|
2020-10-11 15:46:06 +00:00
|
|
|
|
|
|
|
|
|
gtk_accessible_update_property (GTK_ACCESSIBLE (button),
|
|
|
|
|
GTK_ACCESSIBLE_PROPERTY_VALUE_MAX, gtk_adjustment_get_upper (adjustment),
|
|
|
|
|
GTK_ACCESSIBLE_PROPERTY_VALUE_MIN, gtk_adjustment_get_lower (adjustment),
|
|
|
|
|
GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, gtk_adjustment_get_value (adjustment),
|
|
|
|
|
-1);
|
|
|
|
|
|
2008-10-09 16:19:06 +00:00
|
|
|
|
}
|
2007-05-19 23:08:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-07-04 09:02:20 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_scale_button_get_plus_button:
|
|
|
|
|
* @button: a #GtkScaleButton
|
|
|
|
|
*
|
|
|
|
|
* Retrieves the plus button of the #GtkScaleButton.
|
|
|
|
|
*
|
2015-11-30 14:09:19 +00:00
|
|
|
|
* Returns: (transfer none) (type Gtk.Button): the plus button of the #GtkScaleButton as a #GtkButton
|
2008-07-04 09:02:20 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_scale_button_get_plus_button (GtkScaleButton *button)
|
|
|
|
|
{
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
|
|
|
|
|
2008-07-04 09:02:20 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_SCALE_BUTTON (button), NULL);
|
|
|
|
|
|
2018-07-08 07:39:05 +00:00
|
|
|
|
return priv->plus_button;
|
2008-07-04 09:02:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_scale_button_get_minus_button:
|
|
|
|
|
* @button: a #GtkScaleButton
|
|
|
|
|
*
|
|
|
|
|
* Retrieves the minus button of the #GtkScaleButton.
|
|
|
|
|
*
|
2015-11-30 14:09:19 +00:00
|
|
|
|
* Returns: (transfer none) (type Gtk.Button): the minus button of the #GtkScaleButton as a #GtkButton
|
2008-07-04 09:02:20 +00:00
|
|
|
|
*/
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_scale_button_get_minus_button (GtkScaleButton *button)
|
|
|
|
|
{
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
|
|
|
|
|
2008-07-04 09:02:20 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_SCALE_BUTTON (button), NULL);
|
|
|
|
|
|
2018-07-08 07:39:05 +00:00
|
|
|
|
return priv->minus_button;
|
2008-07-04 09:02:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-07-03 18:03:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_scale_button_get_popup:
|
|
|
|
|
* @button: a #GtkScaleButton
|
|
|
|
|
*
|
|
|
|
|
* Retrieves the popup of the #GtkScaleButton.
|
|
|
|
|
*
|
2010-09-21 04:18:11 +00:00
|
|
|
|
* Returns: (transfer none): the popup of the #GtkScaleButton
|
2008-07-03 18:03:13 +00:00
|
|
|
|
*/
|
2008-07-04 09:02:20 +00:00
|
|
|
|
GtkWidget *
|
2008-07-03 18:03:13 +00:00
|
|
|
|
gtk_scale_button_get_popup (GtkScaleButton *button)
|
|
|
|
|
{
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
|
|
|
|
|
2008-07-04 05:05:45 +00:00
|
|
|
|
g_return_val_if_fail (GTK_IS_SCALE_BUTTON (button), NULL);
|
2008-07-03 18:03:13 +00:00
|
|
|
|
|
2018-07-08 07:39:05 +00:00
|
|
|
|
return priv->dock;
|
2008-07-03 18:03:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-04 05:06:31 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_scale_button_set_orientation_private (GtkScaleButton *button,
|
|
|
|
|
GtkOrientation orientation)
|
|
|
|
|
{
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
2009-03-18 21:19:07 +00:00
|
|
|
|
|
2014-07-04 05:06:31 +00:00
|
|
|
|
if (priv->orientation != orientation)
|
|
|
|
|
{
|
|
|
|
|
priv->orientation = orientation;
|
2009-03-18 21:19:07 +00:00
|
|
|
|
g_object_notify (G_OBJECT (button), "orientation");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-18 13:34:39 +00:00
|
|
|
|
static gboolean
|
2017-09-15 11:54:20 +00:00
|
|
|
|
gtk_scale_button_scroll_controller_scroll (GtkEventControllerScroll *scroll,
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double dx,
|
|
|
|
|
double dy,
|
2017-09-15 11:54:20 +00:00
|
|
|
|
GtkScaleButton *button)
|
2007-05-19 23:08:02 +00:00
|
|
|
|
{
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
2011-01-05 22:02:10 +00:00
|
|
|
|
GtkAdjustment *adjustment;
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double d;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
2011-01-05 22:02:10 +00:00
|
|
|
|
adjustment = priv->adjustment;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
2017-09-15 11:54:20 +00:00
|
|
|
|
d = CLAMP (gtk_scale_button_get_value (button) -
|
|
|
|
|
(dy * gtk_adjustment_get_step_increment (adjustment)),
|
|
|
|
|
gtk_adjustment_get_lower (adjustment),
|
|
|
|
|
gtk_adjustment_get_upper (adjustment));
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
|
|
|
|
gtk_scale_button_set_value (button, d);
|
2018-07-18 13:34:39 +00:00
|
|
|
|
|
|
|
|
|
return GDK_EVENT_STOP;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-15 11:54:20 +00:00
|
|
|
|
/*
|
|
|
|
|
* button callbacks.
|
|
|
|
|
*/
|
|
|
|
|
|
2020-04-10 00:24:23 +00:00
|
|
|
|
static void
|
2014-01-30 02:20:22 +00:00
|
|
|
|
gtk_scale_popup (GtkWidget *widget)
|
2007-05-19 23:08:02 +00:00
|
|
|
|
{
|
2014-01-30 02:20:22 +00:00
|
|
|
|
GtkScaleButton *button = GTK_SCALE_BUTTON (widget);
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
2014-07-04 05:06:31 +00:00
|
|
|
|
|
2020-04-10 00:24:23 +00:00
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button), TRUE);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2014-01-30 02:20:22 +00:00
|
|
|
|
gtk_scale_button_popdown (GtkWidget *widget)
|
2007-05-19 23:08:02 +00:00
|
|
|
|
{
|
2014-01-30 02:20:22 +00:00
|
|
|
|
GtkScaleButton *button = GTK_SCALE_BUTTON (widget);
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2020-04-10 00:24:23 +00:00
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button), FALSE);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2014-01-30 02:20:22 +00:00
|
|
|
|
gtk_scale_button_popup (GtkWidget *widget)
|
2007-05-19 23:08:02 +00:00
|
|
|
|
{
|
2014-01-30 02:20:22 +00:00
|
|
|
|
gtk_scale_popup (widget);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* +/- button callbacks.
|
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
2014-01-30 02:20:22 +00:00
|
|
|
|
button_click (GtkScaleButton *button,
|
|
|
|
|
GtkWidget *active)
|
2007-05-19 23:08:02 +00:00
|
|
|
|
{
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
2014-01-30 02:20:22 +00:00
|
|
|
|
GtkAdjustment *adjustment = priv->adjustment;
|
|
|
|
|
gboolean can_continue = TRUE;
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double val;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
2014-01-30 02:20:22 +00:00
|
|
|
|
val = gtk_scale_button_get_value (button);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
2014-01-30 02:20:22 +00:00
|
|
|
|
if (active == priv->plus_button)
|
|
|
|
|
val += gtk_adjustment_get_page_increment (adjustment);
|
|
|
|
|
else
|
|
|
|
|
val -= gtk_adjustment_get_page_increment (adjustment);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
2011-01-05 22:02:10 +00:00
|
|
|
|
if (val <= gtk_adjustment_get_lower (adjustment))
|
2007-05-19 23:08:02 +00:00
|
|
|
|
{
|
2014-01-30 02:20:22 +00:00
|
|
|
|
can_continue = FALSE;
|
2011-01-05 22:02:10 +00:00
|
|
|
|
val = gtk_adjustment_get_lower (adjustment);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
}
|
2011-01-05 22:02:10 +00:00
|
|
|
|
else if (val > gtk_adjustment_get_upper (adjustment))
|
2007-05-19 23:08:02 +00:00
|
|
|
|
{
|
2014-01-30 02:20:22 +00:00
|
|
|
|
can_continue = FALSE;
|
2011-01-05 22:02:10 +00:00
|
|
|
|
val = gtk_adjustment_get_upper (adjustment);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
}
|
2014-01-30 02:20:22 +00:00
|
|
|
|
|
2007-05-19 23:08:02 +00:00
|
|
|
|
gtk_scale_button_set_value (button, val);
|
|
|
|
|
|
2014-01-30 02:20:22 +00:00
|
|
|
|
return can_continue;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-13 03:21:43 +00:00
|
|
|
|
static void
|
|
|
|
|
cb_button_clicked (GtkWidget *widget,
|
|
|
|
|
gpointer user_data)
|
2014-01-30 02:20:22 +00:00
|
|
|
|
{
|
|
|
|
|
GtkScaleButton *button = GTK_SCALE_BUTTON (user_data);
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
2014-01-30 02:20:22 +00:00
|
|
|
|
|
2017-12-13 03:21:43 +00:00
|
|
|
|
if (priv->autoscroll_timeout)
|
2007-05-19 23:08:02 +00:00
|
|
|
|
{
|
2017-12-13 03:21:43 +00:00
|
|
|
|
g_source_remove (priv->autoscroll_timeout);
|
|
|
|
|
priv->autoscroll_timeout = 0;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-13 03:21:43 +00:00
|
|
|
|
if (priv->autoscrolling)
|
2007-05-19 23:08:02 +00:00
|
|
|
|
{
|
2017-12-13 03:21:43 +00:00
|
|
|
|
gtk_range_stop_autoscroll (GTK_RANGE (priv->scale));
|
|
|
|
|
priv->autoscrolling = FALSE;
|
|
|
|
|
return;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-30 02:20:22 +00:00
|
|
|
|
button_click (button, widget);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_scale_button_update_icon (GtkScaleButton *button)
|
|
|
|
|
{
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
2011-01-05 22:02:10 +00:00
|
|
|
|
GtkAdjustment *adjustment;
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double value;
|
2020-07-24 18:40:36 +00:00
|
|
|
|
const char *name;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
guint num_icons;
|
|
|
|
|
|
2017-10-08 18:15:39 +00:00
|
|
|
|
if (!priv->icon_list || priv->icon_list[0][0] == '\0')
|
2007-05-19 23:08:02 +00:00
|
|
|
|
{
|
2020-04-10 00:24:23 +00:00
|
|
|
|
gtk_button_set_icon_name (GTK_BUTTON (priv->button), "image-missing");
|
2007-05-19 23:08:02 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2008-06-26 17:14:27 +00:00
|
|
|
|
|
2007-06-10 15:32:02 +00:00
|
|
|
|
num_icons = g_strv_length (priv->icon_list);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
|
|
|
|
/* The 1-icon special case */
|
|
|
|
|
if (num_icons == 1)
|
|
|
|
|
{
|
2020-04-10 00:24:23 +00:00
|
|
|
|
gtk_button_set_icon_name (GTK_BUTTON (priv->button), priv->icon_list[0]);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-05 22:02:10 +00:00
|
|
|
|
adjustment = priv->adjustment;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
value = gtk_scale_button_get_value (button);
|
|
|
|
|
|
|
|
|
|
/* The 2-icons special case */
|
|
|
|
|
if (num_icons == 2)
|
|
|
|
|
{
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double limit;
|
2011-01-24 02:50:39 +00:00
|
|
|
|
|
2011-01-05 22:02:10 +00:00
|
|
|
|
limit = (gtk_adjustment_get_upper (adjustment) - gtk_adjustment_get_lower (adjustment)) / 2 + gtk_adjustment_get_lower (adjustment);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
if (value < limit)
|
2011-01-24 02:50:39 +00:00
|
|
|
|
name = priv->icon_list[0];
|
2007-05-19 23:08:02 +00:00
|
|
|
|
else
|
2011-01-24 02:50:39 +00:00
|
|
|
|
name = priv->icon_list[1];
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
2020-04-10 00:24:23 +00:00
|
|
|
|
gtk_button_set_icon_name (GTK_BUTTON (priv->button), name);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* With 3 or more icons */
|
2011-01-05 22:02:10 +00:00
|
|
|
|
if (value == gtk_adjustment_get_lower (adjustment))
|
2007-05-19 23:08:02 +00:00
|
|
|
|
{
|
|
|
|
|
name = priv->icon_list[0];
|
|
|
|
|
}
|
2011-01-05 22:02:10 +00:00
|
|
|
|
else if (value == gtk_adjustment_get_upper (adjustment))
|
2007-05-19 23:08:02 +00:00
|
|
|
|
{
|
|
|
|
|
name = priv->icon_list[1];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double step;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
guint i;
|
|
|
|
|
|
2014-01-30 02:20:22 +00:00
|
|
|
|
step = (gtk_adjustment_get_upper (adjustment) - gtk_adjustment_get_lower (adjustment)) / (num_icons - 2); i = (guint) ((value - gtk_adjustment_get_lower (adjustment)) / step) + 2;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
g_assert (i < num_icons);
|
|
|
|
|
name = priv->icon_list[i];
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-10 00:24:23 +00:00
|
|
|
|
gtk_button_set_icon_name (GTK_BUTTON (priv->button), name);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2014-01-30 02:20:22 +00:00
|
|
|
|
cb_scale_value_changed (GtkRange *range,
|
|
|
|
|
gpointer user_data)
|
2007-05-19 23:08:02 +00:00
|
|
|
|
{
|
2014-01-30 02:20:22 +00:00
|
|
|
|
GtkScaleButton *button = user_data;
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
2020-07-24 20:32:16 +00:00
|
|
|
|
double value;
|
|
|
|
|
double upper, lower;
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
|
|
|
|
value = gtk_range_get_value (range);
|
2018-07-08 07:39:05 +00:00
|
|
|
|
upper = gtk_adjustment_get_upper (priv->adjustment);
|
|
|
|
|
lower = gtk_adjustment_get_lower (priv->adjustment);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
|
|
|
|
|
gtk_scale_button_update_icon (button);
|
|
|
|
|
|
2018-07-08 07:39:05 +00:00
|
|
|
|
gtk_widget_set_sensitive (priv->plus_button, value < upper);
|
|
|
|
|
gtk_widget_set_sensitive (priv->minus_button, lower < value);
|
2014-07-08 14:27:30 +00:00
|
|
|
|
|
2007-05-19 23:08:02 +00:00
|
|
|
|
g_signal_emit (button, signals[VALUE_CHANGED], 0, value);
|
|
|
|
|
g_object_notify (G_OBJECT (button), "value");
|
2020-10-11 15:46:06 +00:00
|
|
|
|
|
|
|
|
|
gtk_accessible_update_property (GTK_ACCESSIBLE (button),
|
|
|
|
|
GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, value,
|
|
|
|
|
-1);
|
2007-05-19 23:08:02 +00:00
|
|
|
|
}
|
2014-01-30 02:20:22 +00:00
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
cb_popup_mapped (GtkWidget *popup,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GtkScaleButton *button = user_data;
|
2018-07-08 07:39:05 +00:00
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
2014-01-30 02:20:22 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_grab_focus (priv->scale);
|
|
|
|
|
}
|
2019-05-04 17:14:06 +00:00
|
|
|
|
|
2020-04-10 00:24:23 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_scale_button_measure (GtkWidget *widget,
|
|
|
|
|
GtkOrientation orientation,
|
|
|
|
|
int for_size,
|
|
|
|
|
int *minimum,
|
|
|
|
|
int *natural,
|
|
|
|
|
int *minimum_baseline,
|
|
|
|
|
int *natural_baseline)
|
|
|
|
|
{
|
|
|
|
|
GtkScaleButton *button = GTK_SCALE_BUTTON (widget);
|
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
|
|
|
|
|
|
|
|
|
gtk_widget_measure (priv->button,
|
|
|
|
|
orientation,
|
|
|
|
|
for_size,
|
|
|
|
|
minimum, natural,
|
|
|
|
|
minimum_baseline, natural_baseline);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-04 17:14:06 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_scale_button_size_allocate (GtkWidget *widget,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
int baseline)
|
|
|
|
|
{
|
|
|
|
|
GtkScaleButton *button = GTK_SCALE_BUTTON (widget);
|
|
|
|
|
GtkScaleButtonPrivate *priv = gtk_scale_button_get_instance_private (button);
|
|
|
|
|
|
2020-04-10 00:24:23 +00:00
|
|
|
|
gtk_widget_size_allocate (priv->button,
|
|
|
|
|
&(GtkAllocation) { 0, 0, width, height },
|
|
|
|
|
baseline);
|
2019-05-04 17:14:06 +00:00
|
|
|
|
|
|
|
|
|
gtk_native_check_resize (GTK_NATIVE (priv->dock));
|
|
|
|
|
}
|