Commit ce956702 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

GimpViewableDialogs everywhere, cleanup:

2002-09-01  Michael Natterer  <mitch@gimp.org>

	GimpViewableDialogs everywhere, cleanup:

	* libgimpwidgets/gimpstock.c: added texts for the RESIZE, SCALE
	and CROP stock items.

	* app/widgets/gimpviewabledialog.c: update the title when the
	viewable's name changes.

	* app/gui/color-notebook.[ch]: added color_notebook_viewable_new()
	which creates a GimpViewableDialog.

	* app/widgets/gimpgradienteditor.[ch]
	* app/gui/colormap-editor-commands.c
	* app/gui/file-new-dialog.c
	* app/gui/gradient-editor-commands.c
	* app/gui/palette-editor-commands.c
	* app/undo_history.c: use GimpViewableDialogs and the new
	color_notebook constructor.

	* app/gui/convert-dialog.c: #include "widgets/gimpviewabledialog.h"

	* app/gui/image-commands.c
	* app/gui/info-dialog.c
	* app/gui/resize-dialog.c: minor cleanups.

	* app/gui/info-window.c: cleaned up the whole thing, esp. the
	"Extended" page. Added HSV color display to the color picker
	frame.  Set the icons as frame titles, stuff...

	* app/tools/gimpimagemaptool.[ch]: removed "shell_title",
	"shell_name" and "stock_id" from the GimpImageMapTool struct
	because they can be obtained from the tool's GimpToolInfo object.

	* app/tools/gimpbrightnesscontrasttool.c
	* app/tools/gimpcolorbalancetool.c
	* app/tools/gimpcurvestool.c
	* app/tools/gimphuesaturationtool.c
	* app/tools/gimplevelstool.c
	* app/tools/gimpposterizetool.c
	* app/tools/gimpthresholdtool.c: changed accordingly.

	* app/tools/gimphistogramtool.c: same here: take values from
	tool->tool_info instead of hardcoding them.

	* app/tools/gimpcroptool.[ch]: removed the static crop dialog
	variables and added them to the GimpCropTool struct. Feels safer
	and makes the callback code much simpler. Use stock items for the
	dialog's "Resize" and "Crop" buttons.

	* app/tools/gimpmeasuretool.c
	* app/tools/gimprotatetool.c: for consistency don't name the tools
	"Blah Tool", also the dialog titles need to match the menu
	entries.

	Unrelated:

	* libgimpwidgets/gimpwidgets.c: the recently changed, gtk-doc
	comment was correct, as gtk-doc takes the parameter names from
	the header, not the .c file.

	* app/tools/gimptransformtool.c: set the transform tool's state to
	TRANSFORM_CREATING after changing displays, so the initial matrix
	components are saved correctly for the "Reset" function.
parent 97427f3f
2002-09-01 Michael Natterer <mitch@gimp.org>
GimpViewableDialogs everywhere, cleanup:
* libgimpwidgets/gimpstock.c: added texts for the RESIZE, SCALE
and CROP stock items.
* app/widgets/gimpviewabledialog.c: update the title when the
viewable's name changes.
* app/gui/color-notebook.[ch]: added color_notebook_viewable_new()
which creates a GimpViewableDialog.
* app/widgets/gimpgradienteditor.[ch]
* app/gui/colormap-editor-commands.c
* app/gui/file-new-dialog.c
* app/gui/gradient-editor-commands.c
* app/gui/palette-editor-commands.c
* app/undo_history.c: use GimpViewableDialogs and the new
color_notebook constructor.
* app/gui/convert-dialog.c: #include "widgets/gimpviewabledialog.h"
* app/gui/image-commands.c
* app/gui/info-dialog.c
* app/gui/resize-dialog.c: minor cleanups.
* app/gui/info-window.c: cleaned up the whole thing, esp. the
"Extended" page. Added HSV color display to the color picker
frame. Set the icons as frame titles, stuff...
* app/tools/gimpimagemaptool.[ch]: removed "shell_title",
"shell_name" and "stock_id" from the GimpImageMapTool struct
because they can be obtained from the tool's GimpToolInfo object.
* app/tools/gimpbrightnesscontrasttool.c
* app/tools/gimpcolorbalancetool.c
* app/tools/gimpcurvestool.c
* app/tools/gimphuesaturationtool.c
* app/tools/gimplevelstool.c
* app/tools/gimpposterizetool.c
* app/tools/gimpthresholdtool.c: changed accordingly.
* app/tools/gimphistogramtool.c: same here: take values from
tool->tool_info instead of hardcoding them.
* app/tools/gimpcroptool.[ch]: removed the static crop dialog
variables and added them to the GimpCropTool struct. Feels safer
and makes the callback code much simpler. Use stock items for the
dialog's "Resize" and "Crop" buttons.
* app/tools/gimpmeasuretool.c
* app/tools/gimprotatetool.c: for consistency don't name the tools
"Blah Tool", also the dialog titles need to match the menu
entries.
Unrelated:
* libgimpwidgets/gimpwidgets.c: the recently changed, gtk-doc
comment was correct, as gtk-doc takes the parameter names from
the header, not the .c file.
* app/tools/gimptransformtool.c: set the transform tool's state to
TRANSFORM_CREATING after changing displays, so the initial matrix
components are saved correctly for the "Reset" function.
2002-09-01 Manish Singh <yosh@gimp.org>
 
* modules/Makefile.am: use AM_CPPFLAGS instead of CPPFLAGS
......
......@@ -104,13 +104,19 @@ colormap_editor_edit_color_cmd_callback (GtkWidget *widget,
if (! editor->color_notebook)
{
editor->color_notebook =
color_notebook_new (_("Edit Indexed Color"),
(const GimpRGB *) &color,
colormap_editor_color_notebook_callback, editor,
FALSE, FALSE);
color_notebook_viewable_new (GIMP_VIEWABLE (gimage),
_("Edit Indexed Color"),
GIMP_STOCK_CONVERT_INDEXED,
_("Edit Indexed Image Palette Color"),
(const GimpRGB *) &color,
colormap_editor_color_notebook_callback,
editor,
FALSE, FALSE);
}
else
{
color_notebook_set_viewable (editor->color_notebook,
GIMP_VIEWABLE (gimage));
color_notebook_show (editor->color_notebook);
color_notebook_set_color (editor->color_notebook, &color);
}
......
......@@ -104,13 +104,19 @@ colormap_editor_edit_color_cmd_callback (GtkWidget *widget,
if (! editor->color_notebook)
{
editor->color_notebook =
color_notebook_new (_("Edit Indexed Color"),
(const GimpRGB *) &color,
colormap_editor_color_notebook_callback, editor,
FALSE, FALSE);
color_notebook_viewable_new (GIMP_VIEWABLE (gimage),
_("Edit Indexed Color"),
GIMP_STOCK_CONVERT_INDEXED,
_("Edit Indexed Image Palette Color"),
(const GimpRGB *) &color,
colormap_editor_color_notebook_callback,
editor,
FALSE, FALSE);
}
else
{
color_notebook_set_viewable (editor->color_notebook,
GIMP_VIEWABLE (gimage));
color_notebook_show (editor->color_notebook);
color_notebook_set_color (editor->color_notebook, &color);
}
......
......@@ -30,6 +30,7 @@
#include "widgets/gimpgradienteditor.h"
#include "widgets/gimpitemfactory.h"
#include "widgets/gimpviewabledialog.h"
#include "widgets/gimpwidgets-utils.h"
#include "color-notebook.h"
......@@ -82,12 +83,16 @@ gradient_editor_left_color_cmd_callback (GtkWidget *widget,
editor->left_saved_dirty = GIMP_DATA (gradient)->dirty;
editor->left_saved_segments = gradient_editor_save_selection (editor);
color_notebook_new (_("Left Endpoint Color"),
&editor->control_sel_l->left_color,
gradient_editor_left_color_changed,
editor,
editor->instant_update,
TRUE);
editor->color_notebook =
color_notebook_viewable_new (GIMP_VIEWABLE (gradient),
_("Left Endpoint Color"),
GIMP_STOCK_TOOL_BLEND,
_("Gradient Segment's Left Endpoint Color"),
&editor->control_sel_l->left_color,
gradient_editor_left_color_changed,
editor,
editor->instant_update,
TRUE);
gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE);
}
......@@ -205,12 +210,16 @@ gradient_editor_right_color_cmd_callback (GtkWidget *widget,
editor->right_saved_dirty = GIMP_DATA (gradient)->dirty;
editor->right_saved_segments = gradient_editor_save_selection (editor);
color_notebook_new (_("Right Endpoint Color"),
&editor->control_sel_l->right_color,
gradient_editor_right_color_changed,
editor,
editor->instant_update,
TRUE);
editor->color_notebook =
color_notebook_viewable_new (GIMP_VIEWABLE (gradient),
_("Right Endpoint Color"),
GIMP_STOCK_TOOL_BLEND,
_("Gradient Segment's Right Endpoint Color"),
&editor->control_sel_l->right_color,
gradient_editor_right_color_changed,
editor,
editor->instant_update,
TRUE);
gtk_widget_set_sensitive (GTK_WIDGET (editor), FALSE);
}
......@@ -529,29 +538,41 @@ gradient_editor_replicate_cmd_callback (GtkWidget *widget,
GtkWidget *label;
GtkWidget *scale;
GtkObject *scale_data;
const gchar *title;
const gchar *desc;
editor = (GimpGradientEditor *) gimp_widget_get_callback_context (widget);
if (! editor)
return;
if (editor->control_sel_l == editor->control_sel_r)
{
title = _("Replicate Segment");
desc = _("Replicate Gradient Segment");
}
else
{
title = _("Replicate Selection");
desc = _("Replicate Gradient Selection");
}
dialog =
gimp_dialog_new ((editor->control_sel_l == editor->control_sel_r) ?
_("Replicate segment") :
_("Replicate selection"),
"gradient_segment_replicate",
gimp_standard_help_func,
"dialogs/gradient_editor/replicate_segment.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
gimp_viewable_dialog_new (GIMP_VIEWABLE (GIMP_DATA_EDITOR (editor)->data),
title, "gradient_segment_replicate",
GIMP_STOCK_TOOL_BLEND, desc,
gimp_standard_help_func,
"dialogs/gradient_editor/replicate_segment.html",
GTK_STOCK_CANCEL, gradient_editor_dialog_cancel_callback,
editor, NULL, NULL, TRUE, TRUE,
GTK_STOCK_CANCEL,
gradient_editor_dialog_cancel_callback,
editor, NULL, NULL, TRUE, TRUE,
_("Replicate"), gradient_editor_replicate_callback,
editor, NULL, NULL, FALSE, FALSE,
_("Replicate"),
gradient_editor_replicate_callback,
editor, NULL, NULL, FALSE, FALSE,
NULL);
NULL);
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
......@@ -592,7 +613,7 @@ gradient_editor_split_midpoint_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpGradientEditor *editor;
GimpGradientEditor *editor;
GimpGradient *gradient;
GimpGradientSegment *seg, *lseg, *rseg;
......@@ -631,30 +652,42 @@ gradient_editor_split_uniformly_cmd_callback (GtkWidget *widget,
GtkWidget *label;
GtkWidget *scale;
GtkObject *scale_data;
const gchar *title;
const gchar *desc;
editor = (GimpGradientEditor *) gimp_widget_get_callback_context (widget);
if (! editor)
return;
if (editor->control_sel_l == editor->control_sel_r)
{
title = _("Split Segment Uniformly");
desc = _("Split Gradient Segment Uniformly");
}
else
{
title = _("Split Segments Uniformly");
desc = _("Split Gradient Segments Uniformly");
}
/* Create dialog window */
dialog =
gimp_dialog_new ((editor->control_sel_l == editor->control_sel_r) ?
_("Split Segment Uniformly") :
_("Split Segments Uniformly"),
"gradient_segment_split_uniformly",
gimp_standard_help_func,
"dialogs/gradient_editor/split_segments_uniformly.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
gimp_viewable_dialog_new (GIMP_VIEWABLE (GIMP_DATA_EDITOR (editor)->data),
title, "gradient_segment_split_uniformly",
GIMP_STOCK_TOOL_BLEND, desc,
gimp_standard_help_func,
"dialogs/gradient_editor/split_segments_uniformly.html",
GTK_STOCK_CANCEL, gradient_editor_dialog_cancel_callback,
editor, NULL, NULL, FALSE, TRUE,
GTK_STOCK_CANCEL,
gradient_editor_dialog_cancel_callback,
editor, NULL, NULL, FALSE, TRUE,
_("Split"), gradient_editor_split_uniform_callback,
editor, NULL, NULL, TRUE, FALSE,
_("Split"),
gradient_editor_split_uniform_callback,
editor, NULL, NULL, TRUE, FALSE,
NULL);
NULL);
/* The main vbox */
vbox = gtk_vbox_new (FALSE, 0);
......@@ -1059,24 +1092,26 @@ gradient_editor_menu_update (GtkItemFactory *factory,
if (! selection)
{
SET_LABEL ("/flip", _("Flip Segment"));
SET_LABEL ("/replicate", _("Replicate Segment"));
SET_LABEL ("/blendingfunction", _("Blending Function for Segment"));
SET_LABEL ("/coloringtype", _("Coloring Type for Segment"));
SET_LABEL ("/flip", _("Flip Segment"));
SET_LABEL ("/replicate", _("Replicate Segment..."));
SET_LABEL ("/splitmidpoint", _("Split Segment at Midpoint"));
SET_LABEL ("/splituniformly", _("Split Segment Uniformly"));
SET_LABEL ("/splituniformly", _("Split Segment Uniformly..."));
SET_LABEL ("/delete", _("Delete Segment"));
SET_LABEL ("/recenter", _("Re-center Segment's Midpoint"));
SET_LABEL ("/redistribute", _("Re-distribute Handles in Segment"));
}
else
{
SET_LABEL ("/flip", _("Flip Selection"));
SET_LABEL ("/replicate", _("Replicate Selection"));
SET_LABEL ("/blendingfunction", _("Blending Function for Selection"));
SET_LABEL ("/coloringtype", _("Coloring Type for Selection"));
SET_LABEL ("/flip", _("Flip Selection"));
SET_LABEL ("/replicate", _("Replicate Selection..."));
SET_LABEL ("/splitmidpoint", _("Split Segments at Midpoints"));
SET_LABEL ("/splituniformly", _("Split Segments Uniformly"));
SET_LABEL ("/splituniformly", _("Split Segments Uniformly..."));
SET_LABEL ("/delete", _("Delete Selection"));
SET_LABEL ("/recenter", _("Re-center Midpoints in Selection"));
SET_LABEL ("/redistribute", _("Re-distribute Handles in Selection"));
......@@ -1163,25 +1198,26 @@ gradient_editor_left_color_changed (ColorNotebook *cnb,
switch (state)
{
case COLOR_NOTEBOOK_OK:
case COLOR_NOTEBOOK_UPDATE:
gimp_gradient_segments_blend_endpoints (editor->control_sel_l,
editor->control_sel_r,
(GimpRGB *) color,
&editor->control_sel_r->right_color,
TRUE, TRUE);
gimp_gradient_segments_free (editor->left_saved_segments);
gimp_data_dirty (GIMP_DATA (gradient));
color_notebook_free (cnb);
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
break;
case COLOR_NOTEBOOK_UPDATE:
case COLOR_NOTEBOOK_OK:
gimp_gradient_segments_blend_endpoints (editor->control_sel_l,
editor->control_sel_r,
(GimpRGB *) color,
&editor->control_sel_r->right_color,
TRUE, TRUE);
gimp_gradient_segments_free (editor->left_saved_segments);
gimp_data_dirty (GIMP_DATA (gradient));
color_notebook_free (cnb);
editor->color_notebook = NULL;
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
break;
case COLOR_NOTEBOOK_CANCEL:
......@@ -1189,6 +1225,7 @@ gradient_editor_left_color_changed (ColorNotebook *cnb,
GIMP_DATA (gradient)->dirty = editor->left_saved_dirty;
gimp_gradient_editor_update (editor, GRAD_UPDATE_GRADIENT);
color_notebook_free (cnb);
editor->color_notebook = NULL;
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
break;
}
......@@ -1229,6 +1266,7 @@ gradient_editor_right_color_changed (ColorNotebook *cnb,
gimp_gradient_segments_free (editor->right_saved_segments);
gimp_data_dirty (GIMP_DATA (gradient));
color_notebook_free (cnb);
editor->color_notebook = NULL;
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
break;
......@@ -1236,6 +1274,7 @@ gradient_editor_right_color_changed (ColorNotebook *cnb,
gradient_editor_replace_selection (editor, editor->right_saved_segments);
GIMP_DATA (gradient)->dirty = editor->right_saved_dirty;
color_notebook_free (cnb);
editor->color_notebook = NULL;
gtk_widget_set_sensitive (GTK_WIDGET (editor), TRUE);
break;
}
......
......@@ -313,22 +313,25 @@ image_layers_merge_query (GimpImage *gimage,
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
vbox);
frame = gimp_radio_group_new2 (TRUE,
merge_visible ?
_("Final, Merged Layer should be:") :
_("Final, Anchored Layer should be:"),
G_CALLBACK (gimp_radio_button_update),
&options->merge_type,
GINT_TO_POINTER (options->merge_type),
_("Expanded as necessary"),
GINT_TO_POINTER (GIMP_EXPAND_AS_NECESSARY), NULL,
_("Clipped to image"),
GINT_TO_POINTER (GIMP_CLIP_TO_IMAGE), NULL,
_("Clipped to bottom layer"),
GINT_TO_POINTER (GIMP_CLIP_TO_BOTTOM_LAYER), NULL,
NULL);
frame =
gimp_radio_group_new2 (TRUE,
merge_visible ?
_("Final, Merged Layer should be:") :
_("Final, Anchored Layer should be:"),
G_CALLBACK (gimp_radio_button_update),
&options->merge_type,
GINT_TO_POINTER (options->merge_type),
_("Expanded as necessary"),
GINT_TO_POINTER (GIMP_EXPAND_AS_NECESSARY), NULL,
_("Clipped to image"),
GINT_TO_POINTER (GIMP_CLIP_TO_IMAGE), NULL,
_("Clipped to bottom layer"),
GINT_TO_POINTER (GIMP_CLIP_TO_BOTTOM_LAYER), NULL,
NULL);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
......
......@@ -100,18 +100,22 @@ palette_editor_edit_color_cmd_callback (GtkWidget *widget,
if (! editor->color_notebook)
{
editor->color_notebook =
color_notebook_new (_("Edit Palette Color"),
(const GimpRGB *) &editor->color->color,
palette_editor_color_notebook_callback,
editor,
FALSE,
FALSE);
color_notebook_viewable_new (GIMP_VIEWABLE (palette),
_("Edit Palette Color"),
GTK_STOCK_SELECT_COLOR,
_("Edit Color Palette Entry"),
(const GimpRGB *) &editor->color->color,
palette_editor_color_notebook_callback,
editor,
FALSE, FALSE);
editor->color_notebook_active = TRUE;
}
else
{
if (! editor->color_notebook_active)
{
color_notebook_set_viewable (editor->color_notebook,
GIMP_VIEWABLE (palette));
color_notebook_show (editor->color_notebook);
editor->color_notebook_active = TRUE;
}
......
......@@ -34,6 +34,8 @@
#include "gui-types.h"
#include "widgets/gimpviewabledialog.h"
#include "color-notebook.h"
#include "libgimp/gimpintl.h"
......@@ -116,6 +118,18 @@ struct _ColorNotebook
};
static ColorNotebook *
color_notebook_new_internal (GimpViewable *viewable,
const gchar *title,
const gchar *wmclass_name,
const gchar *stock_id,
const gchar *desc,
const GimpRGB *color,
ColorNotebookCallback callback,
gpointer client_data,
gboolean wants_updates,
gboolean show_alpha);
static void color_notebook_ok_callback (GtkWidget *widget,
gpointer data);
static void color_notebook_cancel_callback (GtkWidget *widget,
......@@ -177,11 +191,65 @@ static gboolean color_history_initialized = FALSE;
ColorNotebook *
color_notebook_new (const gchar *title,
const GimpRGB *color,
ColorNotebookCallback callback,
gpointer client_data,
gboolean wants_updates,
gboolean show_alpha)
const GimpRGB *color,
ColorNotebookCallback callback,
gpointer client_data,
gboolean wants_updates,
gboolean show_alpha)
{
return color_notebook_new_internal (NULL,
title,
"color_selection",
NULL,
NULL,
color,
callback, client_data,
wants_updates, show_alpha);
}
ColorNotebook *
color_notebook_viewable_new (GimpViewable *viewable,
const gchar *title,
const gchar *stock_id,
const gchar *desc,
const GimpRGB *color,
ColorNotebookCallback callback,
gpointer client_data,
gboolean wants_updates,
gboolean show_alpha)
{
return color_notebook_new_internal (viewable,
title,
"color_selection",
stock_id,
desc,
color,
callback, client_data,
wants_updates, show_alpha);
}
void
color_notebook_set_viewable (ColorNotebook *cnb,
GimpViewable *viewable)
{
g_return_if_fail (cnb != NULL);
if (GIMP_IS_VIEWABLE_DIALOG (cnb->shell))
gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (cnb->shell),
viewable);
}
static ColorNotebook *
color_notebook_new_internal (GimpViewable *viewable,
const gchar *title,
const gchar *wmclass_name,
const gchar *stock_id,
const gchar *desc,
const GimpRGB *color,
ColorNotebookCallback callback,
gpointer client_data,
gboolean wants_updates,
gboolean show_alpha)
{
ColorNotebook *cnp;
GtkWidget *main_vbox;
......@@ -255,37 +323,53 @@ color_notebook_new (const gchar *title,
color_notebook_update_hsv_values (cnp);
if (desc)
{
cnp->shell = gimp_viewable_dialog_new (viewable,
title, wmclass_name,
stock_id, desc,
color_notebook_help_func,
(const gchar *) cnp,
NULL);
gtk_window_set_resizable (GTK_WINDOW (cnp->shell), FALSE);
}
else
{
cnp->shell = gimp_dialog_new (title, wmclass_name,
color_notebook_help_func,
(const gchar *) cnp,
GTK_WIN_POS_NONE,
FALSE, TRUE, TRUE,
NULL);
}
if (wants_updates)
{
cnp->shell =
gimp_dialog_new (title, "color_selection",
color_notebook_help_func, (const gchar *) cnp,
GTK_WIN_POS_NONE,
FALSE, TRUE, TRUE,
gimp_dialog_create_action_area (GIMP_DIALOG (cnp->shell),
"_delete_event_", color_notebook_ok_callback,
cnp, NULL, NULL, TRUE, TRUE,
"_delete_event_",
color_notebook_ok_callback,
cnp, NULL, NULL, TRUE, TRUE,
NULL);
NULL);
gtk_dialog_set_has_separator (GTK_DIALOG (cnp->shell), FALSE);
gtk_widget_hide (GTK_DIALOG (cnp->shell)->action_area);
}
else
{
cnp->shell =
gimp_dialog_new (title, "color_selection",
color_notebook_help_func, (const gchar *) cnp,
GTK_WIN_POS_NONE,
FALSE, TRUE, TRUE,
gimp_dialog_create_action_area (GIMP_DIALOG (cnp->shell),
GTK_STOCK_CANCEL, color_notebook_cancel_callback,
cnp, NULL, NULL, FALSE, TRUE,
GTK_STOCK_CANCEL,
color_notebook_cancel_callback,
cnp, NULL, NULL, FALSE, TRUE,
GTK_STOCK_OK, color_notebook_ok_callback,
cnp, NULL, NULL, TRUE, FALSE,
GTK_STOCK_OK,
color_notebook_ok_callback,