mirror of https://github.com/GNOME/gimp.git
libgimpwidgets/gimpdialog.c app/tools/tool_options_dialog.c
2001-02-06 Simon Budig <simon@gimp.org> * libgimpwidgets/gimpdialog.c * app/tools/tool_options_dialog.c Implemented a way to connect the delete-event of a gimpdialog without adding an extra button. If you pass "_delete_event_" as button text (untranslated) the button will not be created. Removed the tool-options "Close" button. Lots of other Close-Buttons wait for their removal.
This commit is contained in:
parent
f3bc8ec806
commit
2ce2ed61c7
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2001-02-06 Simon Budig <simon@gimp.org>
|
||||||
|
|
||||||
|
* libgimpwidgets/gimpdialog.c
|
||||||
|
* app/tools/tool_options_dialog.c
|
||||||
|
|
||||||
|
Implemented a way to connect the delete-event of a gimpdialog
|
||||||
|
without adding an extra button. If you pass "_delete_event_"
|
||||||
|
as button text (untranslated) the button will not be created.
|
||||||
|
|
||||||
|
Removed the tool-options "Close" button. Lots of other Close-Buttons
|
||||||
|
wait for their removal.
|
||||||
|
|
||||||
2001-02-06 Michael Natterer <mitch@gimp.org>
|
2001-02-06 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
* app/Makefile.am
|
* app/Makefile.am
|
||||||
|
|
|
@ -88,7 +88,7 @@ tool_options_dialog_new (void)
|
||||||
|
|
||||||
_("Reset"), tool_options_reset_callback,
|
_("Reset"), tool_options_reset_callback,
|
||||||
NULL, NULL, &options_reset_button, FALSE, FALSE,
|
NULL, NULL, &options_reset_button, FALSE, FALSE,
|
||||||
_("Close"), tool_options_close_callback,
|
"_delete_event_", tool_options_close_callback,
|
||||||
NULL, NULL, NULL, TRUE, TRUE,
|
NULL, NULL, NULL, TRUE, TRUE,
|
||||||
|
|
||||||
NULL);
|
NULL);
|
||||||
|
|
|
@ -88,7 +88,7 @@ tool_options_dialog_new (void)
|
||||||
|
|
||||||
_("Reset"), tool_options_reset_callback,
|
_("Reset"), tool_options_reset_callback,
|
||||||
NULL, NULL, &options_reset_button, FALSE, FALSE,
|
NULL, NULL, &options_reset_button, FALSE, FALSE,
|
||||||
_("Close"), tool_options_close_callback,
|
"_delete_event_", tool_options_close_callback,
|
||||||
NULL, NULL, NULL, TRUE, TRUE,
|
NULL, NULL, NULL, TRUE, TRUE,
|
||||||
|
|
||||||
NULL);
|
NULL);
|
||||||
|
|
|
@ -88,7 +88,7 @@ tool_options_dialog_new (void)
|
||||||
|
|
||||||
_("Reset"), tool_options_reset_callback,
|
_("Reset"), tool_options_reset_callback,
|
||||||
NULL, NULL, &options_reset_button, FALSE, FALSE,
|
NULL, NULL, &options_reset_button, FALSE, FALSE,
|
||||||
_("Close"), tool_options_close_callback,
|
"_delete_event_", tool_options_close_callback,
|
||||||
NULL, NULL, NULL, TRUE, TRUE,
|
NULL, NULL, NULL, TRUE, TRUE,
|
||||||
|
|
||||||
NULL);
|
NULL);
|
||||||
|
|
|
@ -267,7 +267,21 @@ gimp_dialog_create_action_area (GtkDialog *dialog,
|
||||||
* gimp_dialog_create_action_areav:
|
* gimp_dialog_create_action_areav:
|
||||||
* @dialog: The #GtkDialog you want to create the action_area for.
|
* @dialog: The #GtkDialog you want to create the action_area for.
|
||||||
* @args: A @va_list as obtained with va_start() describing the action_area
|
* @args: A @va_list as obtained with va_start() describing the action_area
|
||||||
* buttons.
|
* buttons. First a label for the new button, then a callback that
|
||||||
|
* will be connected to the buttons "clicked" signal, then some
|
||||||
|
* arbitrary data that will be passed to the callback, a slot
|
||||||
|
* object (???), a pointer to a Widgetpointer, that will return
|
||||||
|
* the widget (usually the button), a boolean that indicates that
|
||||||
|
* this button is able to become the default action of the dialog
|
||||||
|
* when the user presses Return, and a boolean that indicates, that
|
||||||
|
* the delete_event of the dialog will be connected to this
|
||||||
|
* callback.
|
||||||
|
*
|
||||||
|
* Please note that the delete_event will only be connected to the first
|
||||||
|
* button with the "connect_delete" boolean set to true. It is possible
|
||||||
|
* to just connect the delete_event to a callback without adding a new
|
||||||
|
* button with a special label "_delete_event_", connect_delete == true
|
||||||
|
* and callback != NULL.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
|
@ -291,20 +305,8 @@ gimp_dialog_create_action_areav (GtkDialog *dialog,
|
||||||
g_return_if_fail (dialog != NULL);
|
g_return_if_fail (dialog != NULL);
|
||||||
g_return_if_fail (GTK_IS_DIALOG (dialog));
|
g_return_if_fail (GTK_IS_DIALOG (dialog));
|
||||||
|
|
||||||
/* prepare the action_area */
|
|
||||||
label = va_arg (args, const gchar *);
|
label = va_arg (args, const gchar *);
|
||||||
|
|
||||||
if (label)
|
|
||||||
{
|
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 2);
|
|
||||||
gtk_box_set_homogeneous (GTK_BOX (dialog->action_area), FALSE);
|
|
||||||
|
|
||||||
hbbox = gtk_hbutton_box_new ();
|
|
||||||
gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbbox), 4);
|
|
||||||
gtk_box_pack_end (GTK_BOX (dialog->action_area), hbbox, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_show (hbbox);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* the action_area buttons */
|
/* the action_area buttons */
|
||||||
while (label)
|
while (label)
|
||||||
{
|
{
|
||||||
|
@ -315,39 +317,31 @@ gimp_dialog_create_action_areav (GtkDialog *dialog,
|
||||||
default_action = va_arg (args, gboolean);
|
default_action = va_arg (args, gboolean);
|
||||||
connect_delete = va_arg (args, gboolean);
|
connect_delete = va_arg (args, gboolean);
|
||||||
|
|
||||||
button = gtk_button_new_with_label (label);
|
|
||||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
|
|
||||||
|
|
||||||
if (slot_object == (GtkObject *) 1)
|
if (slot_object == (GtkObject *) 1)
|
||||||
slot_object = GTK_OBJECT (dialog);
|
slot_object = GTK_OBJECT (dialog);
|
||||||
|
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
data = dialog;
|
data = dialog;
|
||||||
|
|
||||||
if (callback)
|
/*
|
||||||
{
|
* Dont create a button if the label is "_delete_event_" --
|
||||||
if (slot_object)
|
* some dialogs just need to connect to the delete_event from
|
||||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
* the window...
|
||||||
GTK_SIGNAL_FUNC (callback),
|
*/
|
||||||
slot_object);
|
if (connect_delete &&
|
||||||
else
|
callback &&
|
||||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
!delete_connected &&
|
||||||
GTK_SIGNAL_FUNC (callback),
|
strcmp (label, "_delete_event_") == 0)
|
||||||
data);
|
{
|
||||||
}
|
if (widget_ptr)
|
||||||
|
*widget_ptr = GTK_WIDGET (dialog);
|
||||||
|
|
||||||
if (widget_ptr)
|
|
||||||
*widget_ptr = button;
|
|
||||||
|
|
||||||
if (connect_delete && callback && !delete_connected)
|
|
||||||
{
|
|
||||||
gtk_object_set_data (GTK_OBJECT (dialog),
|
gtk_object_set_data (GTK_OBJECT (dialog),
|
||||||
"gimp_dialog_cancel_callback",
|
"gimp_dialog_cancel_callback",
|
||||||
callback);
|
callback);
|
||||||
gtk_object_set_data (GTK_OBJECT (dialog),
|
gtk_object_set_data (GTK_OBJECT (dialog),
|
||||||
"gimp_dialog_cancel_widget",
|
"gimp_dialog_cancel_widget",
|
||||||
slot_object ? slot_object : GTK_OBJECT (button));
|
slot_object ? slot_object : GTK_OBJECT (dialog));
|
||||||
|
|
||||||
/* catch the WM delete event */
|
/* catch the WM delete event */
|
||||||
gtk_signal_connect (GTK_OBJECT (dialog), "delete_event",
|
gtk_signal_connect (GTK_OBJECT (dialog), "delete_event",
|
||||||
|
@ -357,10 +351,61 @@ gimp_dialog_create_action_areav (GtkDialog *dialog,
|
||||||
delete_connected = TRUE;
|
delete_connected = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (default_action)
|
/* otherwise just create the requested button. */
|
||||||
gtk_widget_grab_default (button);
|
else
|
||||||
gtk_widget_show (button);
|
{
|
||||||
|
if (hbbox == NULL)
|
||||||
|
{
|
||||||
|
/* prepare the action_area */
|
||||||
|
gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 2);
|
||||||
|
gtk_box_set_homogeneous (GTK_BOX (dialog->action_area), FALSE);
|
||||||
|
|
||||||
|
hbbox = gtk_hbutton_box_new ();
|
||||||
|
gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbbox), 4);
|
||||||
|
gtk_box_pack_end (GTK_BOX (dialog->action_area), hbbox, FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (hbbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
button = gtk_button_new_with_label (label);
|
||||||
|
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
if (callback)
|
||||||
|
{
|
||||||
|
if (slot_object)
|
||||||
|
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||||
|
GTK_SIGNAL_FUNC (callback),
|
||||||
|
slot_object);
|
||||||
|
else
|
||||||
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||||
|
GTK_SIGNAL_FUNC (callback),
|
||||||
|
data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (widget_ptr)
|
||||||
|
*widget_ptr = button;
|
||||||
|
|
||||||
|
if (connect_delete && callback && !delete_connected)
|
||||||
|
{
|
||||||
|
gtk_object_set_data (GTK_OBJECT (dialog),
|
||||||
|
"gimp_dialog_cancel_callback",
|
||||||
|
callback);
|
||||||
|
gtk_object_set_data (GTK_OBJECT (dialog),
|
||||||
|
"gimp_dialog_cancel_widget",
|
||||||
|
slot_object ? slot_object : GTK_OBJECT (button));
|
||||||
|
|
||||||
|
/* catch the WM delete event */
|
||||||
|
gtk_signal_connect (GTK_OBJECT (dialog), "delete_event",
|
||||||
|
GTK_SIGNAL_FUNC (gimp_dialog_delete_callback),
|
||||||
|
data);
|
||||||
|
|
||||||
|
delete_connected = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (default_action)
|
||||||
|
gtk_widget_grab_default (button);
|
||||||
|
gtk_widget_show (button);
|
||||||
|
}
|
||||||
label = va_arg (args, gchar *);
|
label = va_arg (args, gchar *);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue