
2001-12-29 Michael Natterer <mitch@gimp.org> * app/gimpprogress.c * app/nav_window.c * app/ops_buttons.c * app/undo_history.c * app/display/gimpdisplayshell.c * app/gui/about-dialog.c * app/gui/brush-editor.c * app/gui/channels-commands.c * app/gui/color-area.c * app/gui/color-notebook.c * app/gui/color-select.c * app/gui/colormap-dialog.c * app/gui/convert-dialog.c * app/gui/device-status-dialog.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/info-dialog.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-editor.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/toolbox.c * app/gui/user-install-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c * app/tools/gimprotatetool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcolorpanel.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpconstrainedhwrapbox.c * app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainerlistview.c * app/widgets/gimpcontainermenuimpl.c * app/widgets/gimpdialogfactory.c * app/widgets/gimpdnd.c * app/widgets/gimpdock.c * app/widgets/gimpdockbook.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.c * app/widgets/gimpfontselection-dialog.c * app/widgets/gimphistogramview.c * app/widgets/gimpitemfactory.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplistitem.[ch] * app/widgets/gimpmenuitem.c * app/widgets/gimppreview.[ch] * app/widgets/gtkhwrapbox.c * app/widgets/gtkvwrapbox.c * app/widgets/gtkwrapbox.c * libgimp/gimpbrushmenu.c * libgimp/gimpexport.c * libgimp/gimpgradientmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * libgimpwidgets/gimpbutton.c * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.h * libgimpwidgets/gimpcolorbutton.c * libgimpwidgets/gimpfileselection.c * libgimpwidgets/gimphelpui.c * libgimpwidgets/gimpoffsetarea.c * libgimpwidgets/gimppatheditor.c * libgimpwidgets/gimppixmap.h * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpstock.[ch] * libgimpwidgets/gimpwidgets.h * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/Events.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_ui.c * plug-ins/bmp/bmpwrite.c * plug-ins/dbbrowser/dbbrowser_utils.c * plug-ins/fits/fits.c * plug-ins/flame/flame.c * plug-ins/fp/fp_gtk.c * plug-ins/fp/fp_misc.c * plug-ins/gfig/gfig.c * plug-ins/gflare/gflare.c * plug-ins/gfli/gfli.c * plug-ins/gimpressionist/*.c * plug-ins/imagemap/*.[ch] * plug-ins/maze/maze_face.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/print/print_gimp.h * plug-ins/rcm/rcm_callback.c * plug-ins/rcm/rcm_dialog.c * plug-ins/rcm/rcm_misc.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-server.c * plug-ins/sel2path/sel2path.c * plug-ins/sel2path/sel2path_adv_dialog.c * plug-ins/sgi/sgi.c * plug-ins/webbrowser/webbrowser.c * plug-ins/xjt/xjt.c * plug-ins/common/[A-n]*.c: compile with GTK_DISABLE_DEPRECATED defined. Not everything is fully ported yet, had to #undef GTK_DISABLE_DEPRECATED in many places and added #warnings when doing so. * pixmaps/Makefile.am * pixmaps/chain.xpm: removed. * themes/Default/Makefile.am * themes/Default/images/Makefile.am * themes/Default/images/stock-button-hchain-broken.png * themes/Default/images/stock-button-hchain.png * themes/Default/images/stock-button-vchain-broken.png * themes/Default/images/stock-button-vchain.png: new stock icons.
219 lines
5.4 KiB
C
219 lines
5.4 KiB
C
/* LIBGIMP - The GIMP Library
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
|
*
|
|
* gimpbutton.c
|
|
* Copyright (C) 2000 Michael Natterer <mitch@gimp.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
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
* Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include "gimpwidgetstypes.h"
|
|
|
|
#include "gimpbutton.h"
|
|
|
|
|
|
enum
|
|
{
|
|
EXTENDED_CLICKED,
|
|
LAST_SIGNAL
|
|
};
|
|
|
|
|
|
static void gimp_button_class_init (GimpButtonClass *klass);
|
|
static void gimp_button_init (GimpButton *button);
|
|
|
|
static gboolean gimp_button_button_press (GtkWidget *widget,
|
|
GdkEventButton *event);
|
|
static gboolean gimp_button_button_release (GtkWidget *widget,
|
|
GdkEventButton *event);
|
|
|
|
|
|
static guint button_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
static GtkButtonClass *parent_class = NULL;
|
|
|
|
|
|
GType
|
|
gimp_button_get_type (void)
|
|
{
|
|
static GType button_type = 0;
|
|
|
|
if (! button_type)
|
|
{
|
|
static const GTypeInfo button_info =
|
|
{
|
|
sizeof (GimpButtonClass),
|
|
(GBaseInitFunc) NULL,
|
|
(GBaseFinalizeFunc) NULL,
|
|
(GClassInitFunc) gimp_button_class_init,
|
|
NULL, /* class_finalize */
|
|
NULL, /* class_data */
|
|
sizeof (GimpButton),
|
|
0, /* n_preallocs */
|
|
(GInstanceInitFunc) gimp_button_init,
|
|
};
|
|
|
|
button_type = g_type_register_static (GTK_TYPE_BUTTON,
|
|
"GimpButton",
|
|
&button_info, 0);
|
|
}
|
|
|
|
return button_type;
|
|
}
|
|
|
|
static void
|
|
gimp_button_class_init (GimpButtonClass *klass)
|
|
{
|
|
GObjectClass *object_class;
|
|
GtkWidgetClass *widget_class;
|
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
|
|
|
button_signals[EXTENDED_CLICKED] =
|
|
g_signal_new ("extended_clicked",
|
|
G_TYPE_FROM_CLASS (klass),
|
|
G_SIGNAL_RUN_FIRST,
|
|
G_STRUCT_OFFSET (GimpButtonClass, extended_clicked),
|
|
NULL, NULL,
|
|
g_cclosure_marshal_VOID__UINT,
|
|
G_TYPE_NONE, 1,
|
|
G_TYPE_UINT);
|
|
|
|
widget_class->button_press_event = gimp_button_button_press;
|
|
widget_class->button_release_event = gimp_button_button_release;
|
|
}
|
|
|
|
static void
|
|
gimp_button_init (GimpButton *button)
|
|
{
|
|
button->press_state = 0;
|
|
}
|
|
|
|
/**
|
|
* gimp_button_new:
|
|
*
|
|
* Creates a new #GimpButton widget.
|
|
*
|
|
* Returns: A pointer to the new #GimpButton widget.
|
|
**/
|
|
GtkWidget *
|
|
gimp_button_new (void)
|
|
{
|
|
GimpButton *button;
|
|
|
|
button = g_object_new (GIMP_TYPE_BUTTON, NULL);
|
|
|
|
return GTK_WIDGET (button);
|
|
}
|
|
|
|
/**
|
|
* gimp_button_extended_clicked:
|
|
* @button: a #GimpButton.
|
|
* @state: a state as found in #GdkEventButton->state, e.g. #GDK_SHIFT_MASK.
|
|
*
|
|
* Emits the button's "extended_clicked" signal.
|
|
**/
|
|
void
|
|
gimp_button_extended_clicked (GimpButton *button,
|
|
guint state)
|
|
{
|
|
g_return_if_fail (GIMP_IS_BUTTON (button));
|
|
|
|
g_signal_emit (G_OBJECT (button), button_signals[EXTENDED_CLICKED], 0,
|
|
state);
|
|
}
|
|
|
|
static gboolean
|
|
gimp_button_button_press (GtkWidget *widget,
|
|
GdkEventButton *bevent)
|
|
{
|
|
GimpButton *button;
|
|
|
|
g_return_val_if_fail (GIMP_IS_BUTTON (widget), FALSE);
|
|
g_return_val_if_fail (bevent != NULL, FALSE);
|
|
|
|
button = GIMP_BUTTON (widget);
|
|
|
|
if (bevent->type == GDK_BUTTON_PRESS && bevent->button == 1)
|
|
{
|
|
button->press_state = bevent->state;
|
|
}
|
|
else
|
|
{
|
|
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 FALSE;
|
|
}
|
|
|
|
static gboolean
|
|
gimp_button_button_release (GtkWidget *widget,
|
|
GdkEventButton *bevent)
|
|
{
|
|
GtkButton *button;
|
|
gboolean extended_clicked = FALSE;
|
|
|
|
g_return_val_if_fail (GIMP_IS_BUTTON (widget), FALSE);
|
|
g_return_val_if_fail (bevent != NULL, FALSE);
|
|
|
|
button = GTK_BUTTON (widget);
|
|
|
|
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 (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);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|