gimp/app/ops_buttons.c

151 lines
4.1 KiB
C
Raw Normal View History

/* 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"
new ui for the "Layer Offset" dialog. 1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de> * app/channel_ops.[ch]: new ui for the "Layer Offset" dialog. * app/channels_dialog.c * app/layers_dialog.c: major code cleanup: Folded some callbacks into common ones, "widget" instead of "w", indentation, ... * app/commands.c * app/interface.[ch] * app/global_edit.c: the query boxes must be shown by the caller now. There's no need to split up the string for the message box manually as the Gtk 1.2 label widget handles newlines corectly. Added the "edge_lock" toggle to the "Shrink Selection" dialog. Nicer spacings for the query and message boxes. * app/ink.c: tried to grab the pointer in the blob preview but failed. Left the code there as a reminder (commented out). * app/menus.c: reordered <Image>/Select. I was bored and grep-ed the sources for ancient or deprecated stuff: * app/about_dialog.[ch] * app/actionarea.[ch] * app/app_procs.c * app/brush_edit.c * app/brush_select.c * app/color_select.c * app/convert.c * app/devices.c * app/gdisplay.c * app/gdisplay_ops.c * app/histogram_tool.[ch] * app/info_window.c * app/install.c * app/ops_buttons.c * app/palette.c * app/palette_select.c * app/paths_dialog.c * app/pattern_select.c * app/resize.c * app/scale_toolc.c * app/text_tool.c: s/container_border_width/container_set_border_width/g, s/sprintf/g_snprintf/g, replaced some constant string lengths with strlen(x). * app/bezier_select.c * app/blend.c * app/boundary.c * app/errors.[ch] * app/free_select.c * app/gimpbrushlist.c * app/gimprc.c * app/iscissors.c * app/main.c * app/patterns.[ch] * app/text_tool.c: namespace fanaticism: prefixed all gimp error functions with "gimp_" and formated the messages more uniformly. * app/gradient.c * app/gradient_select.c: same stuff as above for the ui code. There are still some sub-dialogs which need cleanup. Did some cleanup in most of these files: prototypes, removed tons of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
#include <gtk/gtk.h>
#include "gimphelp.h"
#include "ops_buttons.h"
#include "libgimp/gimppixmap.h"
#include "libgimp/gimpintl.h"
static void ops_button_pressed_callback (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data);
static void ops_button_extended_callback (GtkWidget *widget,
gpointer data);
1999-07-20 03:46:05 +08:00
GtkWidget *
ops_button_box_new (OpsButton *ops_button,
1999-07-20 03:46:05 +08:00
OpsButtonType ops_type)
{
GtkWidget *button;
GtkWidget *button_box;
GtkWidget *pixmap;
GSList *group = NULL;
button_box = gtk_hbox_new (TRUE, 1);
while (ops_button->xpm_data)
{
pixmap = gimp_pixmap_new (ops_button->xpm_data);
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_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
break;
default:
g_warning ("ops_button_box_new: unknown type %d\n", ops_type);
continue;
}
gtk_container_add (GTK_CONTAINER (button), pixmap);
if (ops_button->ext_callbacks == NULL)
{
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (ops_button->callback),
NULL);
}
else
{
gtk_signal_connect (GTK_OBJECT (button), "button_press_event",
GTK_SIGNAL_FUNC (ops_button_pressed_callback),
ops_button);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (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);
gtk_widget_show (button);
ops_button->widget = button;
ops_button->modifier = OPS_BUTTON_MODIFIER_NONE;
ops_button++;
}
return button_box;
}
static void
1999-07-20 03:46:05 +08:00
ops_button_pressed_callback (GtkWidget *widget,
GdkEventButton *bevent,
gpointer data)
{
OpsButton *ops_button;
g_return_if_fail (data != NULL);
ops_button = (OpsButton *) 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 data)
{
OpsButton *ops_button;
g_return_if_fail (data != NULL);
ops_button = (OpsButton *) 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;
}