Commit bd8fb257 authored by Sven Neumann's avatar Sven Neumann
Browse files

Added some power-user functionality to the L&C-dialog.


--Sven
parent d07ad24d
Mon Mar 15 01:34:08 MET 1999 Sven Neumann <sven@gimp.org>
* app/ops_buttons.[c|h]: implemented a way to catch the
modifier key that was pressed when the button was clicked
* app/[layers|channels|paths]_dialog.c: changed the ops_button
arrays to reflect the changes described above and implemented
a few power-user features in the dialogs:
( Shift->Layer Up / Layer Down moves to top/bottom
Shift->Channel To Selection adds the channel to the sel
Ctrl->Channel To Selectio subtracts from the selection )
1999-03-14 Michael Natterer <mitschel@cs.tu-berlin.de>
* gimprc.in: removed two unused directories from plug-in-path.
......
......@@ -174,16 +174,22 @@ static MenuItem channels_ops[] =
{ NULL, 0, 0, NULL, NULL, NULL, NULL },
};
/* the ops buttons */
static OpsButtonCallback to_selection_ext_callbacks[] =
{ channels_dialog_add_channel_to_sel_callback,
channels_dialog_sub_channel_from_sel_callback, NULL };
static OpsButton channels_ops_buttons[] =
{
{ new_xpm, channels_dialog_new_channel_callback, N_("New Channel"), NULL },
{ raise_xpm, channels_dialog_raise_channel_callback, N_("Raise Channel"), NULL },
{ lower_xpm, channels_dialog_lower_channel_callback, N_("Lower Channel"), NULL },
{ duplicate_xpm, channels_dialog_duplicate_channel_callback, N_("Duplicate Channel"), NULL },
{ delete_xpm, channels_dialog_delete_channel_callback, N_("Delete Channel"), NULL },
{ toselection_xpm, channels_dialog_channel_to_sel_callback, N_("Channel To Selection"), NULL },
{ NULL, NULL, NULL, NULL }
{ new_xpm, channels_dialog_new_channel_callback, NULL, N_("New Channel"), NULL, 0 },
{ raise_xpm, channels_dialog_raise_channel_callback, NULL, N_("Raise Channel"), NULL, 0 },
{ lower_xpm, channels_dialog_lower_channel_callback, NULL, N_("Lower Channel"), NULL, 0 },
{ duplicate_xpm, channels_dialog_duplicate_channel_callback, NULL, N_("Duplicate Channel"), NULL, 0 },
{ delete_xpm, channels_dialog_delete_channel_callback, NULL, N_("Delete Channel"), NULL, 0 },
{ toselection_xpm, channels_dialog_channel_to_sel_callback, to_selection_ext_callbacks, N_("Channel To Selection"), NULL, 0 },
{ NULL, NULL, NULL, NULL, NULL, 0 }
};
/**************************************/
......
......@@ -174,16 +174,22 @@ static MenuItem channels_ops[] =
{ NULL, 0, 0, NULL, NULL, NULL, NULL },
};
/* the ops buttons */
static OpsButtonCallback to_selection_ext_callbacks[] =
{ channels_dialog_add_channel_to_sel_callback,
channels_dialog_sub_channel_from_sel_callback, NULL };
static OpsButton channels_ops_buttons[] =
{
{ new_xpm, channels_dialog_new_channel_callback, N_("New Channel"), NULL },
{ raise_xpm, channels_dialog_raise_channel_callback, N_("Raise Channel"), NULL },
{ lower_xpm, channels_dialog_lower_channel_callback, N_("Lower Channel"), NULL },
{ duplicate_xpm, channels_dialog_duplicate_channel_callback, N_("Duplicate Channel"), NULL },
{ delete_xpm, channels_dialog_delete_channel_callback, N_("Delete Channel"), NULL },
{ toselection_xpm, channels_dialog_channel_to_sel_callback, N_("Channel To Selection"), NULL },
{ NULL, NULL, NULL, NULL }
{ new_xpm, channels_dialog_new_channel_callback, NULL, N_("New Channel"), NULL, 0 },
{ raise_xpm, channels_dialog_raise_channel_callback, NULL, N_("Raise Channel"), NULL, 0 },
{ lower_xpm, channels_dialog_lower_channel_callback, NULL, N_("Lower Channel"), NULL, 0 },
{ duplicate_xpm, channels_dialog_duplicate_channel_callback, NULL, N_("Duplicate Channel"), NULL, 0 },
{ delete_xpm, channels_dialog_delete_channel_callback, NULL, N_("Delete Channel"), NULL, 0 },
{ toselection_xpm, channels_dialog_channel_to_sel_callback, to_selection_ext_callbacks, N_("Channel To Selection"), NULL, 0 },
{ NULL, NULL, NULL, NULL, NULL, 0 }
};
/**************************************/
......
......@@ -284,16 +284,24 @@ static MenuItem option_items[] =
{ NULL, 0, 0, NULL, NULL, NULL, NULL }
};
/* the ops buttons */
static OpsButtonCallback raise_layers_ext_callbacks[] =
{ layers_dialog_raise_layer_to_top_callback, NULL, NULL };
static OpsButtonCallback lower_layers_ext_callbacks[] =
{ layers_dialog_lower_layer_to_bottom_callback, NULL, NULL };
static OpsButton layers_ops_buttons[] =
{
{ new_xpm, layers_dialog_new_layer_callback, N_("New Layer"), NULL },
{ raise_xpm, layers_dialog_raise_layer_callback, N_("Raise Layer"), NULL },
{ lower_xpm, layers_dialog_lower_layer_callback, N_("Lower Layer"), NULL },
{ duplicate_xpm, layers_dialog_duplicate_layer_callback, N_("Duplicate Layer"), NULL },
{ delete_xpm, layers_dialog_delete_layer_callback, N_("Delete Layer"), NULL },
{ anchor_xpm, layers_dialog_anchor_layer_callback, N_("Anchor Layer"), NULL },
{ NULL, NULL, NULL, NULL }
{ new_xpm, layers_dialog_new_layer_callback, NULL, N_("New Layer"), NULL, 0 },
{ raise_xpm, layers_dialog_raise_layer_callback, raise_layers_ext_callbacks, N_("Raise Layer"), NULL, 0 },
{ lower_xpm, layers_dialog_lower_layer_callback, lower_layers_ext_callbacks, N_("Lower Layer"), NULL, 0 },
{ duplicate_xpm, layers_dialog_duplicate_layer_callback, NULL, N_("Duplicate Layer"), NULL, 0 },
{ delete_xpm, layers_dialog_delete_layer_callback, NULL, N_("Delete Layer"), NULL, 0 },
{ anchor_xpm, layers_dialog_anchor_layer_callback, NULL, N_("Anchor Layer"), NULL, 0 },
{ NULL, NULL, NULL, NULL, NULL, 0 }
};
......
......@@ -154,12 +154,12 @@ static MenuItem paths_ops[] =
static OpsButton paths_ops_buttons[] =
{
{ new_xpm, paths_dialog_new_path_callback, N_("New Path"), NULL },
{ duplicate_xpm, paths_dialog_dup_path_callback, N_("Duplicate Path"), NULL },
{ toselection_xpm, paths_dialog_path_to_sel_callback, N_("Path to Selection"), NULL },
{ penstroke_xpm, paths_dialog_stroke_path_callback, N_("Stroke Path"), NULL },
{ delete_xpm, paths_dialog_delete_path_callback, N_("Delete Path"), NULL },
{ NULL, NULL, NULL, NULL }
{ new_xpm, paths_dialog_new_path_callback, NULL, N_("New Path"), NULL, 0 },
{ duplicate_xpm, paths_dialog_dup_path_callback, NULL, N_("Duplicate Path"), NULL, 0 },
{ toselection_xpm, paths_dialog_path_to_sel_callback, NULL, N_("Path to Selection"), NULL, 0 },
{ penstroke_xpm, paths_dialog_stroke_path_callback, NULL, N_("Stroke Path"), NULL, 0 },
{ delete_xpm, paths_dialog_delete_path_callback, NULL, N_("Delete Path"), NULL, 0 },
{ NULL, NULL, NULL, NULL, NULL, 0 }
};
#define POINT_NEW_BUTTON 1
......@@ -169,11 +169,11 @@ static OpsButton paths_ops_buttons[] =
static OpsButton point_ops_buttons[] =
{
{ pennorm_xpm, paths_dialog_new_point_callback, N_("New Point"), NULL },
{ penadd_xpm, paths_dialog_add_point_callback, N_("Add Point"), NULL },
{ pendel_xpm, paths_dialog_delete_point_callback, N_("Delete Point"), NULL },
{ penedit_xpm, paths_dialog_edit_point_callback, N_("Edit Point"), NULL },
{ NULL, NULL, NULL, NULL }
{ pennorm_xpm, paths_dialog_new_point_callback, NULL, N_("New Point"), NULL, 0 },
{ penadd_xpm, paths_dialog_add_point_callback, NULL, N_("Add Point"), NULL, 0 },
{ pendel_xpm, paths_dialog_delete_point_callback, NULL, N_("Delete Point"), NULL, 0 },
{ penedit_xpm, paths_dialog_edit_point_callback, NULL, N_("Edit Point"), NULL, 0 },
{ NULL, NULL, NULL, NULL, NULL, 0 }
};
static void
......
......@@ -284,16 +284,24 @@ static MenuItem option_items[] =
{ NULL, 0, 0, NULL, NULL, NULL, NULL }
};
/* the ops buttons */
static OpsButtonCallback raise_layers_ext_callbacks[] =
{ layers_dialog_raise_layer_to_top_callback, NULL, NULL };
static OpsButtonCallback lower_layers_ext_callbacks[] =
{ layers_dialog_lower_layer_to_bottom_callback, NULL, NULL };
static OpsButton layers_ops_buttons[] =
{
{ new_xpm, layers_dialog_new_layer_callback, N_("New Layer"), NULL },
{ raise_xpm, layers_dialog_raise_layer_callback, N_("Raise Layer"), NULL },
{ lower_xpm, layers_dialog_lower_layer_callback, N_("Lower Layer"), NULL },
{ duplicate_xpm, layers_dialog_duplicate_layer_callback, N_("Duplicate Layer"), NULL },
{ delete_xpm, layers_dialog_delete_layer_callback, N_("Delete Layer"), NULL },
{ anchor_xpm, layers_dialog_anchor_layer_callback, N_("Anchor Layer"), NULL },
{ NULL, NULL, NULL, NULL }
{ new_xpm, layers_dialog_new_layer_callback, NULL, N_("New Layer"), NULL, 0 },
{ raise_xpm, layers_dialog_raise_layer_callback, raise_layers_ext_callbacks, N_("Raise Layer"), NULL, 0 },
{ lower_xpm, layers_dialog_lower_layer_callback, lower_layers_ext_callbacks, N_("Lower Layer"), NULL, 0 },
{ duplicate_xpm, layers_dialog_duplicate_layer_callback, NULL, N_("Duplicate Layer"), NULL, 0 },
{ delete_xpm, layers_dialog_delete_layer_callback, NULL, N_("Delete Layer"), NULL, 0 },
{ anchor_xpm, layers_dialog_anchor_layer_callback, NULL, N_("Anchor Layer"), NULL, 0 },
{ NULL, NULL, NULL, NULL, NULL, 0 }
};
......
......@@ -21,11 +21,13 @@
#include "gimprc.h"
#include "ops_buttons.h"
#include "libgimp/gimpintl.h"
void ops_button_pressed_callback (GtkWidget*, GdkEventButton*, gpointer);
void ops_button_extended_callback (GtkWidget*, gpointer);
GtkWidget *ops_button_box_new (GtkWidget *parent,
GtkTooltips *tool_tips,
OpsButton *ops_buttons,
OpsButton *ops_button,
OpsButtonType ops_type)
{
GtkWidget *button;
......@@ -42,7 +44,7 @@ GtkWidget *ops_button_box_new (GtkWidget *parent,
button_box = gtk_hbox_new (FALSE, 1);
while (ops_buttons->xpm_data)
while (ops_button->xpm_data)
{
box = gtk_hbox_new (FALSE, 0);
gtk_container_border_width (GTK_CONTAINER (box), 0);
......@@ -50,7 +52,7 @@ GtkWidget *ops_button_box_new (GtkWidget *parent,
pixmap = gdk_pixmap_create_from_xpm_d (parent->window,
&mask,
&style->bg[GTK_STATE_NORMAL],
ops_buttons->xpm_data);
ops_button->xpm_data);
pixmapwid = gtk_pixmap_new (pixmap, mask);
gtk_box_pack_start (GTK_BOX (box), pixmapwid, TRUE, TRUE, 3);
......@@ -75,35 +77,92 @@ GtkWidget *ops_button_box_new (GtkWidget *parent,
}
gtk_container_add (GTK_CONTAINER (button), box);
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) ops_buttons->callback,
GTK_OBJECT (parent));
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);
}
if (tool_tips != NULL)
gtk_tooltips_set_tip (tool_tips, button, gettext(ops_buttons->tooltip), NULL);
gtk_tooltips_set_tip (tool_tips, button, ops_button->tooltip, NULL);
gtk_box_pack_start (GTK_BOX(button_box), button, TRUE, TRUE, 0);
gtk_widget_show (button);
ops_buttons->widget = button;
ops_button->widget = button;
ops_button->modifier = OPS_BUTTON_MODIFIER_NONE;
ops_buttons++;
ops_button++;
}
return (button_box);
}
void
ops_button_box_set_insensitive (OpsButton *ops_buttons)
ops_button_box_set_insensitive (OpsButton *ops_button)
{
while (ops_buttons->widget)
g_return_if_fail (ops_button != NULL);
while (ops_button->widget)
{
gtk_widget_set_sensitive (ops_buttons->widget, FALSE);
ops_buttons++;
gtk_widget_set_sensitive (ops_button->widget, FALSE);
ops_button++;
}
}
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)
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;
}
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 < 1 || ops_button->modifier > 3)
(ops_button->callback) (widget, NULL);
else {
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);
}
ops_button->modifier = OPS_BUTTON_MODIFIER_NONE;
}
......@@ -19,28 +19,35 @@
#ifndef __OPS_BUTTONS_H__
#define __OPS_BUTTONS_H__
/* Structures */
typedef struct _OpsButton OpsButton;
typedef void (*OpsButtonCallback) (GtkWidget *widget,
gpointer user_data);
// typedef OpsButtonCallback OpsButtonExtCallbacks;
typedef enum {
OPS_BUTTON_MODIFIER_NONE,
OPS_BUTTON_MODIFIER_SHIFT,
OPS_BUTTON_MODIFIER_CTRL,
OPS_BUTTON_MODIFIER_ALT,
} OpsButtonModifier;
typedef enum {
OPS_BUTTON_NORMAL,
OPS_BUTTON_RADIO,
} OpsButtonType;
struct _OpsButton
{
gchar **xpm_data; /* xpm data for the button */
OpsButtonCallback callback;
OpsButtonCallback callback;
OpsButtonCallback *ext_callbacks;
char *tooltip;
GtkWidget *widget; /* the button widget */
gint modifier;
};
typedef enum {
OPS_BUTTON_NORMAL,
OPS_BUTTON_RADIO,
} OpsButtonType;
/* Function declarations */
GtkWidget * ops_button_box_new (GtkWidget *, /* parent widget */
......@@ -51,4 +58,3 @@ void ops_button_box_set_insensitive (OpsButton *);
#endif /* __OPS_BUTTONS_H__ */
......@@ -154,12 +154,12 @@ static MenuItem paths_ops[] =
static OpsButton paths_ops_buttons[] =
{
{ new_xpm, paths_dialog_new_path_callback, N_("New Path"), NULL },
{ duplicate_xpm, paths_dialog_dup_path_callback, N_("Duplicate Path"), NULL },
{ toselection_xpm, paths_dialog_path_to_sel_callback, N_("Path to Selection"), NULL },
{ penstroke_xpm, paths_dialog_stroke_path_callback, N_("Stroke Path"), NULL },
{ delete_xpm, paths_dialog_delete_path_callback, N_("Delete Path"), NULL },
{ NULL, NULL, NULL, NULL }
{ new_xpm, paths_dialog_new_path_callback, NULL, N_("New Path"), NULL, 0 },
{ duplicate_xpm, paths_dialog_dup_path_callback, NULL, N_("Duplicate Path"), NULL, 0 },
{ toselection_xpm, paths_dialog_path_to_sel_callback, NULL, N_("Path to Selection"), NULL, 0 },
{ penstroke_xpm, paths_dialog_stroke_path_callback, NULL, N_("Stroke Path"), NULL, 0 },
{ delete_xpm, paths_dialog_delete_path_callback, NULL, N_("Delete Path"), NULL, 0 },
{ NULL, NULL, NULL, NULL, NULL, 0 }
};
#define POINT_NEW_BUTTON 1
......@@ -169,11 +169,11 @@ static OpsButton paths_ops_buttons[] =
static OpsButton point_ops_buttons[] =
{
{ pennorm_xpm, paths_dialog_new_point_callback, N_("New Point"), NULL },
{ penadd_xpm, paths_dialog_add_point_callback, N_("Add Point"), NULL },
{ pendel_xpm, paths_dialog_delete_point_callback, N_("Delete Point"), NULL },
{ penedit_xpm, paths_dialog_edit_point_callback, N_("Edit Point"), NULL },
{ NULL, NULL, NULL, NULL }
{ pennorm_xpm, paths_dialog_new_point_callback, NULL, N_("New Point"), NULL, 0 },
{ penadd_xpm, paths_dialog_add_point_callback, NULL, N_("Add Point"), NULL, 0 },
{ pendel_xpm, paths_dialog_delete_point_callback, NULL, N_("Delete Point"), NULL, 0 },
{ penedit_xpm, paths_dialog_edit_point_callback, NULL, N_("Edit Point"), NULL, 0 },
{ NULL, NULL, NULL, NULL, NULL, 0 }
};
static void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment