* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/*
#include "config.h"
+#include "gtkscalebutton.h"
+
#ifndef _WIN32
#define _GNU_SOURCE
#endif
#include <stdlib.h>
#include <string.h>
+#include "gtkadjustment.h"
#include "gtkbindings.h"
#include "gtkframe.h"
#include "gtkmain.h"
#include "gtkorientable.h"
#include "gtkprivate.h"
#include "gtkscale.h"
-#include "gtkscalebutton.h"
#include "gtkstock.h"
-#include "gtkvbox.h"
+#include "gtkbox.h"
#include "gtkwindow.h"
#include "gtktypebuiltins.h"
#include "gtkintl.h"
+#include "a11y/gtkscalebuttonaccessible.h"
/**
* SECTION:gtkscalebutton
"popup", 0);
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0,
"popdown", 0);
+
+ gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_SCALE_BUTTON_ACCESSIBLE);
}
static void
/* the scale */
priv->scale = gtk_scale_button_scale_new (button);
gtk_container_add (GTK_CONTAINER (priv->box), priv->scale);
+
+ gtk_widget_add_events (GTK_WIDGET (button), GDK_SCROLL_MASK);
}
static GObject *
* @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)
- * @icons: (allow-none): a %NULL-terminated array of icon names, or %NULL if
- * you want to set the list later with gtk_scale_button_set_icons()
+ * @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()
*
* Creates a #GtkScaleButton, with a range between @min and @max, with
* a stepping of @step.
/**
* gtk_scale_button_set_icons:
* @button: a #GtkScaleButton
- * @icons: a %NULL-terminated array of icon names
+ * @icons: (array zero-terminated=1): a %NULL-terminated array of icon names
*
* Sets the icons to be used by the scale button.
* For details, see the #GtkScaleButton:icons property.
GtkScaleButton *button = (GtkScaleButton *) widget;
GtkScaleButtonPrivate *priv;
GdkScreen *screen;
- GValue value = { 0, };
+ GValue value = G_VALUE_INIT;
if (gtk_widget_has_screen (widget) == FALSE)
return;
gint x, y, m, dx, dy, sx, sy, startoff;
gint min_slider_size;
gdouble v;
- GdkDisplay *display;
GdkScreen *screen;
gboolean is_moved;
GdkDevice *device, *keyboard, *pointer;
priv = button->priv;
adjustment = priv->adjustment;
- display = gtk_widget_get_display (widget);
screen = gtk_widget_get_screen (widget);
gtk_widget_get_allocation (widget, &allocation);
monitor = gdk_screen_get_monitor_at_point (screen,
button_event->x_root,
button_event->y_root);
- gdk_screen_get_monitor_geometry (screen, monitor, &rect);
+ gdk_screen_get_monitor_workarea (screen, monitor, &rect);
if (priv->orientation == GTK_ORIENTATION_VERTICAL)
y += button_event->y;
* either the dock, or the scale itself */
static void
gtk_scale_button_grab_notify (GtkScaleButton *button,
- gboolean was_grabbed)
+ gboolean was_grabbed)
{
- GdkDisplay *display;
GtkScaleButtonPrivate *priv;
GtkWidget *toplevel, *grab_widget;
GtkWindowGroup *group;
gtk_widget_is_ancestor (grab_widget, priv->dock))
return;
- display = gtk_widget_get_display (priv->dock);
gdk_device_ungrab (priv->grab_keyboard, GDK_CURRENT_TIME);
gdk_device_ungrab (priv->grab_pointer, GDK_CURRENT_TIME);
gtk_device_grab_remove (priv->dock, priv->grab_pointer);
return FALSE;
}
-/*
- * Scale callbacks.
- */
+/* Scale callbacks */
static void
gtk_scale_button_release_grab (GtkScaleButton *button,
- GdkEventButton *event)
+ GdkEventButton *event)
{
GdkEventButton *e;
- GdkDisplay *display;
GtkScaleButtonPrivate *priv;
priv = button->priv;
/* ungrab focus */
- display = gtk_widget_get_display (GTK_WIDGET (button));
gdk_device_ungrab (priv->grab_keyboard, event->time);
gdk_device_ungrab (priv->grab_pointer, event->time);
gtk_device_grab_remove (priv->dock, priv->grab_pointer);
{
GtkScaleButton *button;
GtkScaleButtonPrivate *priv;
- GdkDisplay *display;
button = GTK_SCALE_BUTTON (widget);
priv = button->priv;
/* ungrab focus */
- display = gtk_widget_get_display (widget);
gdk_device_ungrab (priv->grab_keyboard, GDK_CURRENT_TIME);
gdk_device_ungrab (priv->grab_pointer, GDK_CURRENT_TIME);
gtk_device_grab_remove (priv->dock, priv->grab_pointer);
static gboolean gtk_scale_button_scale_release (GtkWidget *widget,
GdkEventButton *event);
+GType _gtk_scale_button_scale_get_type (void);
+
G_DEFINE_TYPE (GtkScaleButtonScale, _gtk_scale_button_scale, GTK_TYPE_SCALE)
static void
gtk_scale_button_update_icon (GtkScaleButton *button)
{
GtkScaleButtonPrivate *priv;
- GtkRange *range;
GtkAdjustment *adjustment;
gdouble value;
const gchar *name;
if (!priv->icon_list || priv->icon_list[0] == '\0')
{
gtk_image_set_from_stock (GTK_IMAGE (priv->image),
- GTK_STOCK_MISSING_IMAGE,
- priv->size);
+ GTK_STOCK_MISSING_IMAGE,
+ priv->size);
return;
}
if (num_icons == 1)
{
gtk_image_set_from_icon_name (GTK_IMAGE (priv->image),
- priv->icon_list[0],
- priv->size);
+ priv->icon_list[0],
+ priv->size);
return;
}
- range = GTK_RANGE (priv->scale);
adjustment = priv->adjustment;
value = gtk_scale_button_get_value (button);
if (num_icons == 2)
{
gdouble limit;
+
limit = (gtk_adjustment_get_upper (adjustment) - gtk_adjustment_get_lower (adjustment)) / 2 + gtk_adjustment_get_lower (adjustment);
if (value < limit)
- name = priv->icon_list[0];
+ name = priv->icon_list[0];
else
- name = priv->icon_list[1];
+ name = priv->icon_list[1];
gtk_image_set_from_icon_name (GTK_IMAGE (priv->image),
- name,
- priv->size);
+ name,
+ priv->size);
return;
}
}
gtk_image_set_from_icon_name (GTK_IMAGE (priv->image),
- name,
- priv->size);
+ name,
+ priv->size);
}
static void