gimp/app/ops_buttons.c
Michael Natterer 0302ed0a10 app/brush_select.[ch] app/gradient.c app/gradient_select.[ch]
1999-11-03  Michael Natterer  <mitch@gimp.org>

	* app/brush_select.[ch]
	* app/gradient.c
	* app/gradient_select.[ch]
	* app/interface.[ch]
	* app/palette.c
	* app/pattern_select.[ch]: allow dragging a brush/pattern/... from
	the selections with mouse2 without changing the active element in
	the dialog.

	* app/channels_dialog.c
	* app/color_area.c
	* app/color_panel.c
	* app/color_select.c
	* app/colormap_dialog.i.c
	* app/devices.c
	* app/gimpcontextpreview.[ch]
	* app/gimphelp.[ch]
	* app/gimpui.[ch]
	* app/indicator_area.c
	* app/interface.[ch]
	* app/layers_dialog.c
	* app/lc_dialog.c
	* app/ops_buttons.[ch]
	* app/paths_dialog.c
	* app/preferences_dialog.c
	* app/tools.[ch]: wrapped gtk_tooltips_set_tip() with
	gimp_help_set_help_data() and moved it to gimphelp.[ch].

	This should (hopefully) be the final state of the help system. The
	New function allows a "private tip" to be set without a visible
	tooltip. This way the tooltips inspector (shift+F1) can search for
	help data in the parent containers of the clicked widget. E.g. the
	ops buttons in the layers dialog have private tips like
	"#new_layer" which gets composed with the help data of the layers
	dialog notebook page resulting in a complete help path.

	Allow mouse2 for all dnd operations. Mouse1 still works like before.
1999-11-03 09:58:46 +00:00

157 lines
4.4 KiB
C

/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; 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 "gimphelp.h"
#include "ops_buttons.h"
#include "libgimp/gimpintl.h"
static void ops_button_pressed_callback (GtkWidget*, GdkEventButton*, gpointer);
static void ops_button_extended_callback (GtkWidget*, gpointer);
GtkWidget *
ops_button_box_new (GtkWidget *parent,
OpsButton *ops_button,
OpsButtonType ops_type)
{
GtkWidget *button;
GtkWidget *button_box;
GtkWidget *pixmap_widget;
GdkPixmap *pixmap;
GdkBitmap *mask;
GtkStyle *style;
GSList *group = NULL;
gtk_widget_realize (parent);
style = gtk_widget_get_style (parent);
button_box = gtk_hbox_new (TRUE, 1);
while (ops_button->xpm_data)
{
pixmap = gdk_pixmap_create_from_xpm_d (parent->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
ops_button->xpm_data);
pixmap_widget = gtk_pixmap_new (pixmap, mask);
switch (ops_type)
{
case OPS_BUTTON_NORMAL :
button = gtk_button_new ();
break;
case OPS_BUTTON_RADIO :
button = gtk_radio_button_new (group);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
gtk_container_set_border_width (GTK_CONTAINER (button), 0);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
break;
default :
button = NULL; /*stop compiler complaints */
g_error ("ops_button_box_new: unknown type %d\n", ops_type);
break;
}
gtk_container_add (GTK_CONTAINER (button), pixmap_widget);
if (ops_button->ext_callbacks == NULL)
{
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) ops_button->callback,
NULL);
}
else
{
gtk_signal_connect (GTK_OBJECT (button), "button_press_event",
(GtkSignalFunc) ops_button_pressed_callback,
ops_button);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) ops_button_extended_callback,
ops_button);
}
gimp_help_set_help_data (button,
gettext (ops_button->tooltip),
ops_button->private_tip);
gtk_box_pack_start (GTK_BOX (button_box), button, TRUE, TRUE, 0);
gtk_widget_show (pixmap_widget);
gtk_widget_show (button);
ops_button->widget = button;
ops_button->modifier = OPS_BUTTON_MODIFIER_NONE;
ops_button++;
}
return (button_box);
}
static void
ops_button_pressed_callback (GtkWidget *widget,
GdkEventButton *bevent,
gpointer client_data)
{
OpsButton *ops_button;
g_return_if_fail (client_data != NULL);
ops_button = (OpsButton*)client_data;
if (bevent->state & GDK_SHIFT_MASK)
{
if (bevent->state & GDK_CONTROL_MASK)
ops_button->modifier = OPS_BUTTON_MODIFIER_SHIFT_CTRL;
else
ops_button->modifier = OPS_BUTTON_MODIFIER_SHIFT;
}
else if (bevent->state & GDK_CONTROL_MASK)
ops_button->modifier = OPS_BUTTON_MODIFIER_CTRL;
else if (bevent->state & GDK_MOD1_MASK)
ops_button->modifier = OPS_BUTTON_MODIFIER_ALT;
else
ops_button->modifier = OPS_BUTTON_MODIFIER_NONE;
}
static void
ops_button_extended_callback (GtkWidget *widget,
gpointer client_data)
{
OpsButton *ops_button;
g_return_if_fail (client_data != NULL);
ops_button = (OpsButton*)client_data;
if (ops_button->modifier > OPS_BUTTON_MODIFIER_NONE &&
ops_button->modifier < OPS_BUTTON_MODIFIER_LAST)
{
if (ops_button->ext_callbacks[ops_button->modifier - 1] != NULL)
(ops_button->ext_callbacks[ops_button->modifier - 1]) (widget, NULL);
else
(ops_button->callback) (widget, NULL);
}
else
(ops_button->callback) (widget, NULL);
ops_button->modifier = OPS_BUTTON_MODIFIER_NONE;
}