massively simplified. Don't fiddle in GtkButton's internals (like setting
2008-09-03 Michael Natterer <mitch@gimp.org> * libgimpwidgets/gimpbutton.c: massively simplified. Don't fiddle in GtkButton's internals (like setting "in_button" and forcing redraws). Instead, simply remember the modifier state in button_press() and check it in clicked(); if the state is != 0, stop the "clicked" emission and emit "extended-clicked" instead. svn path=/trunk/; revision=26842
This commit is contained in:

committed by
Michael Natterer

parent
dabd966106
commit
5357d42ab3
@ -1,3 +1,11 @@
|
|||||||
|
2008-09-03 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
|
* libgimpwidgets/gimpbutton.c: massively simplified. Don't fiddle
|
||||||
|
in GtkButton's internals (like setting "in_button" and forcing
|
||||||
|
redraws). Instead, simply remember the modifier state in
|
||||||
|
button_press() and check it in clicked(); if the state is != 0,
|
||||||
|
stop the "clicked" emission and emit "extended-clicked" instead.
|
||||||
|
|
||||||
2008-09-03 Michael Schumacher <schumaml@cvs.gnome.org>
|
2008-09-03 Michael Schumacher <schumaml@cvs.gnome.org>
|
||||||
|
|
||||||
* configure.in: bumped minimum required Python version to 2.5.0,
|
* configure.in: bumped minimum required Python version to 2.5.0,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||||
*
|
*
|
||||||
* gimpbutton.c
|
* gimpbutton.c
|
||||||
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>
|
* Copyright (C) 2000-2008 Michael Natterer <mitch@gimp.org>
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -38,8 +38,7 @@ enum
|
|||||||
|
|
||||||
static gboolean gimp_button_button_press (GtkWidget *widget,
|
static gboolean gimp_button_button_press (GtkWidget *widget,
|
||||||
GdkEventButton *event);
|
GdkEventButton *event);
|
||||||
static gboolean gimp_button_button_release (GtkWidget *widget,
|
static void gimp_button_clicked (GtkButton *button);
|
||||||
GdkEventButton *event);
|
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE (GimpButton, gimp_button, GTK_TYPE_BUTTON)
|
G_DEFINE_TYPE (GimpButton, gimp_button, GTK_TYPE_BUTTON)
|
||||||
@ -53,6 +52,7 @@ static void
|
|||||||
gimp_button_class_init (GimpButtonClass *klass)
|
gimp_button_class_init (GimpButtonClass *klass)
|
||||||
{
|
{
|
||||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
|
GtkButtonClass *button_class = GTK_BUTTON_CLASS (klass);
|
||||||
|
|
||||||
button_signals[EXTENDED_CLICKED] =
|
button_signals[EXTENDED_CLICKED] =
|
||||||
g_signal_new ("extended-clicked",
|
g_signal_new ("extended-clicked",
|
||||||
@ -65,7 +65,8 @@ gimp_button_class_init (GimpButtonClass *klass)
|
|||||||
GDK_TYPE_MODIFIER_TYPE);
|
GDK_TYPE_MODIFIER_TYPE);
|
||||||
|
|
||||||
widget_class->button_press_event = gimp_button_button_press;
|
widget_class->button_press_event = gimp_button_button_press;
|
||||||
widget_class->button_release_event = gimp_button_button_release;
|
|
||||||
|
button_class->clicked = gimp_button_clicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -118,52 +119,18 @@ gimp_button_button_press (GtkWidget *widget,
|
|||||||
button->press_state = 0;
|
button->press_state = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GTK_WIDGET_CLASS (parent_class)->button_press_event)
|
|
||||||
return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, bevent);
|
return GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, bevent);
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
gimp_button_button_release (GtkWidget *widget,
|
gimp_button_clicked (GtkButton *button)
|
||||||
GdkEventButton *bevent)
|
|
||||||
{
|
{
|
||||||
GtkButton *button = GTK_BUTTON (widget);
|
if (GIMP_BUTTON (button)->press_state &
|
||||||
gboolean extended_clicked = FALSE;
|
(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK))
|
||||||
|
{
|
||||||
|
g_signal_stop_emission_by_name (button, "clicked");
|
||||||
|
|
||||||
if (bevent->button == 1)
|
|
||||||
{
|
|
||||||
if (button->in_button &&
|
|
||||||
(GIMP_BUTTON (button)->press_state &
|
|
||||||
(GDK_SHIFT_MASK | GDK_CONTROL_MASK | GDK_MOD1_MASK)))
|
|
||||||
{
|
|
||||||
gimp_button_extended_clicked (GIMP_BUTTON (button),
|
gimp_button_extended_clicked (GIMP_BUTTON (button),
|
||||||
GIMP_BUTTON (button)->press_state);
|
GIMP_BUTTON (button)->press_state);
|
||||||
|
|
||||||
extended_clicked = TRUE;
|
|
||||||
|
|
||||||
/* HACK: don't let GtkButton emit "clicked" by telling it that
|
|
||||||
* the mouse pointer is outside the widget
|
|
||||||
*/
|
|
||||||
button->in_button = FALSE;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (GTK_WIDGET_CLASS (parent_class)->button_release_event)
|
|
||||||
GTK_WIDGET_CLASS (parent_class)->button_release_event (widget, bevent);
|
|
||||||
|
|
||||||
if (extended_clicked)
|
|
||||||
{
|
|
||||||
/* revert the above HACK and let the button draw itself in the
|
|
||||||
* correct state, because upchaining with "in_button" == FALSE
|
|
||||||
* messed it up
|
|
||||||
*/
|
|
||||||
button->in_button = TRUE;
|
|
||||||
|
|
||||||
gtk_widget_set_state (widget, GTK_STATE_PRELIGHT);
|
|
||||||
gtk_widget_queue_draw (widget);
|
|
||||||
gdk_window_process_updates (widget->window, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user