X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtkscalebutton.c;h=f10bb0308d7787a2ad7e65667520ca9f2e177ff4;hb=0ba92bc26d1b716f2f9c0543593f13cd5a92c521;hp=a688705338e759e129d4aafb93625e00074fbc9e;hpb=2fb1c064020c5db189285b1d5e8b8dcea8e9d09b;p=~andy%2Fgtk diff --git a/gtk/gtkscalebutton.c b/gtk/gtkscalebutton.c index a68870533..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 * @@ -870,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; @@ -902,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; @@ -912,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); @@ -984,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; @@ -1145,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; @@ -1171,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); @@ -1299,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); @@ -1355,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); @@ -1428,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 @@ -1530,7 +1527,6 @@ static void gtk_scale_button_update_icon (GtkScaleButton *button) { GtkScaleButtonPrivate *priv; - GtkRange *range; GtkAdjustment *adjustment; gdouble value; const gchar *name; @@ -1541,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; } @@ -1552,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); @@ -1565,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; } @@ -1598,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