X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtkscalebutton.c;h=f10bb0308d7787a2ad7e65667520ca9f2e177ff4;hb=6f1476edd3fbe31259e59ca3f03a01bf0f8ff67b;hp=7be5660ead839710458b8bf5f380303ab6347394;hpb=920e8b434367f9aa8aab306721cc024e66892e2e;p=~andy%2Fgtk diff --git a/gtk/gtkscalebutton.c b/gtk/gtkscalebutton.c index 7be5660ea..f10bb0308 100644 --- a/gtk/gtkscalebutton.c +++ b/gtk/gtkscalebutton.c @@ -21,9 +21,7 @@ * 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 . */ /* @@ -35,6 +33,8 @@ #include "config.h" +#include "gtkscalebutton.h" + #ifndef _WIN32 #define _GNU_SOURCE #endif @@ -42,6 +42,7 @@ #include #include +#include "gtkadjustment.h" #include "gtkbindings.h" #include "gtkframe.h" #include "gtkmain.h" @@ -49,12 +50,12 @@ #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 @@ -343,6 +344,8 @@ gtk_scale_button_class_init (GtkScaleButtonClass *klass) "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 @@ -414,6 +417,8 @@ gtk_scale_button_init (GtkScaleButton *button) /* 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 * @@ -559,8 +564,9 @@ gtk_scale_button_dispose (GObject *object) * @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. @@ -640,7 +646,7 @@ gtk_scale_button_set_value (GtkScaleButton *button, /** * 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. @@ -869,7 +875,7 @@ gtk_scale_button_screen_changed (GtkWidget *widget, GtkScaleButton *button = (GtkScaleButton *) widget; GtkScaleButtonPrivate *priv; GdkScreen *screen; - GValue value = { 0, }; + GValue value = G_VALUE_INIT; if (gtk_widget_has_screen (widget) == FALSE) return; @@ -901,7 +907,6 @@ gtk_scale_popup (GtkWidget *widget, 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; @@ -911,7 +916,6 @@ gtk_scale_popup (GtkWidget *widget, priv = button->priv; adjustment = priv->adjustment; - display = gtk_widget_get_display (widget); screen = gtk_widget_get_screen (widget); gtk_widget_get_allocation (widget, &allocation); @@ -983,7 +987,7 @@ gtk_scale_popup (GtkWidget *widget, 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; @@ -1144,9 +1148,8 @@ gtk_scale_button_key_release (GtkWidget *widget, * 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; @@ -1170,7 +1173,6 @@ gtk_scale_button_grab_notify (GtkScaleButton *button, 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); @@ -1298,22 +1300,18 @@ cb_dock_grab_broken_event (GtkWidget *widget, 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); @@ -1354,13 +1352,11 @@ gtk_scale_button_popdown (GtkWidget *widget) { 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); @@ -1427,6 +1423,8 @@ static gboolean gtk_scale_button_scale_press (GtkWidget *widget, 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 @@ -1529,7 +1527,6 @@ static void gtk_scale_button_update_icon (GtkScaleButton *button) { GtkScaleButtonPrivate *priv; - GtkRange *range; GtkAdjustment *adjustment; gdouble value; const gchar *name; @@ -1540,8 +1537,8 @@ gtk_scale_button_update_icon (GtkScaleButton *button) 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; } @@ -1551,12 +1548,11 @@ gtk_scale_button_update_icon (GtkScaleButton *button) 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); @@ -1564,15 +1560,16 @@ gtk_scale_button_update_icon (GtkScaleButton *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; } @@ -1597,8 +1594,8 @@ gtk_scale_button_update_icon (GtkScaleButton *button) } gtk_image_set_from_icon_name (GTK_IMAGE (priv->image), - name, - priv->size); + name, + priv->size); } static void