Commit d463a5ef authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

removed a useless g_return_if_fail().

2001-11-23  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpcontainer.c: removed a useless g_return_if_fail().

	* app/widgets/gimpcontainereditor.h: removed GimpViewType enum.

	* app/widgets/widgets-types.h: added it here.

	* app/widgets/gimpcontainerview-utils.[ch]: added a utility function
	which gets the GimpContainerView out of a GimpDockable.

	* app/widgets/gimpdialogfactory.[ch]: added support for saving and
	loading of each GimpDockable's preview size. Store the dialog's
	default preview size in the GimpDialogFactoryEntry.  Pass the
	preview_size to each created dialog.

	* app/gui/menus.c: added menu items for setting the preview_size
	and switching between list and grid view. Removed the item
	overkill in the "Add Tab" submenu.

	* app/gui/dialogs-commands.[ch]: added callbacks for the new items.

	* app/widgets/gimpdockbook.c: set the item's state before showing
	the menu.

	* app/errors.c
	* app/gui/dialogs-constructors.[ch]
	* app/gui/dialogs.c
	* app/gui/edit-commands.c
	* app/gui/gui.c
	* app/gui/indicator-area.c
	* app/gui/toolbox.c: changed accordingly.

	* app/tools/selection_options.[ch]: cleaned up the selection
	options and added some tooltips. Much more to do...
parent 5edb473a
2001-11-23 Michael Natterer <mitch@gimp.org>
* app/core/gimpcontainer.c: removed a useless g_return_if_fail().
* app/widgets/gimpcontainereditor.h: removed GimpViewType enum.
* app/widgets/widgets-types.h: added it here.
* app/widgets/gimpcontainerview-utils.[ch]: added a utility function
which gets the GimpContainerView out of a GimpDockable.
* app/widgets/gimpdialogfactory.[ch]: added support for saving and
loading of each GimpDockable's preview size. Store the dialog's
default preview size in the GimpDialogFactoryEntry. Pass the
preview_size to each created dialog.
* app/gui/menus.c: added menu items for setting the preview_size
and switching between list and grid view. Removed the item
overkill in the "Add Tab" submenu.
* app/gui/dialogs-commands.[ch]: added callbacks for the new items.
* app/widgets/gimpdockbook.c: set the item's state before showing
the menu.
* app/errors.c
* app/gui/dialogs-constructors.[ch]
* app/gui/dialogs.c
* app/gui/edit-commands.c
* app/gui/gui.c
* app/gui/indicator-area.c
* app/gui/toolbox.c: changed accordingly.
* app/tools/selection_options.[ch]: cleaned up the selection
options and added some tooltips. Much more to do...
2001-11-23 Rebecca Walter <rjp@mail.tele.dk>
* app/file/*.c: Proofing. only minor changes.
......
......@@ -18,10 +18,14 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "gui-types.h"
#include "widgets/gimpcontainerview.h"
#include "widgets/gimpcontainerview-utils.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdockable.h"
#include "widgets/gimpdockbook.h"
......@@ -43,7 +47,7 @@ dialogs_create_toplevel_cmd_callback (GtkWidget *widget,
identifier = g_quark_to_string ((GQuark) action);
if (identifier)
gimp_dialog_factory_dialog_new (global_dialog_factory, identifier);
gimp_dialog_factory_dialog_new (global_dialog_factory, identifier, -1);
}
}
......@@ -59,7 +63,7 @@ dialogs_create_dockable_cmd_callback (GtkWidget *widget,
identifier = g_quark_to_string ((GQuark) action);
if (identifier)
gimp_dialog_factory_dialog_raise (global_dock_factory, identifier);
gimp_dialog_factory_dialog_raise (global_dock_factory, identifier, -1);
}
}
......@@ -83,7 +87,8 @@ dialogs_add_tab_cmd_callback (GtkWidget *widget,
{
dockable = gimp_dialog_factory_dockable_new (dockbook->dock->factory,
dockbook->dock,
identifier);
identifier,
-1);
/* Maybe gimp_dialog_factory_dockable_new() returned an already
* existing singleton dockable, so check if it already is
......@@ -119,6 +124,134 @@ dialogs_remove_tab_cmd_callback (GtkWidget *widget,
}
}
void
dialogs_toggle_view_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDockbook *dockbook;
GimpViewType view_type;
if (! GTK_CHECK_MENU_ITEM (widget)->active)
return;
dockbook = (GimpDockbook *) gtk_item_factory_popup_data_from_widget (widget);
view_type = (GimpViewType) action;
if (dockbook)
{
GimpDockable *dockable;
gint page_num;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
{
GimpDialogFactoryEntry *entry;
entry = g_object_get_data (G_OBJECT (dockable),
"gimp-dialog-factory-entry");
if (entry)
{
gchar *identifier;
gchar *substring;
identifier = g_strdup (entry->identifier);
if ((substring = strstr (identifier, "grid")) &&
view_type == GIMP_VIEW_TYPE_LIST)
{
memcpy (substring, "list", 4);
}
else if ((substring = strstr (identifier, "list")) &&
view_type == GIMP_VIEW_TYPE_GRID)
{
memcpy (substring, "grid", 4);
}
if (strcmp (entry->identifier, identifier))
{
GimpContainerView *old_view;
GtkWidget *new_dockable;
gint preview_size = -1;
old_view = gimp_container_view_get_by_dockable (dockable);
if (old_view)
preview_size = old_view->preview_size;
new_dockable =
gimp_dialog_factory_dockable_new (dockbook->dock->factory,
dockbook->dock,
identifier,
preview_size);
/* Maybe gimp_dialog_factory_dockable_new() returned
* an already existing singleton dockable, so check
* if it already is attached to a dockbook.
*/
if (new_dockable && ! GIMP_DOCKABLE (new_dockable)->dockbook)
{
gimp_dockbook_add (dockbook, GIMP_DOCKABLE (new_dockable),
page_num);
gimp_dockbook_remove (dockbook, dockable);
gtk_notebook_set_current_page (GTK_NOTEBOOK (dockbook),
page_num);
}
}
g_free (identifier);
}
}
}
}
void
dialogs_preview_size_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpDockbook *dockbook;
gint preview_size;
if (! GTK_CHECK_MENU_ITEM (widget)->active)
return;
dockbook = (GimpDockbook *) gtk_item_factory_popup_data_from_widget (widget);
preview_size = (gint) action;
if (dockbook)
{
GimpDockable *dockable;
gint page_num;
page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (dockbook));
dockable = (GimpDockable *)
gtk_notebook_get_nth_page (GTK_NOTEBOOK (dockbook), page_num);
if (dockable)
{
GimpContainerView *view;
view = gimp_container_view_get_by_dockable (dockable);
if (view)
{
gimp_container_view_set_preview_size (view, preview_size);
}
}
}
}
void
dialogs_toggle_image_menu_cmd_callback (GtkWidget *widget,
gpointer data,
......@@ -167,18 +300,21 @@ dialogs_create_lc_cmd_callback (GtkWidget *widget,
gimp_dock_add_book (GIMP_DOCK (dock), GIMP_DOCKBOOK (dockbook), 0);
dockable = gimp_dialog_factory_dialog_new (global_dock_factory,
"gimp:layer-list");
if (dockable)
"gimp:layer-list", -1);
if (dockable && ! GIMP_DOCKABLE (dockable)->dockbook)
gimp_dock_add (GIMP_DOCK (dock), GIMP_DOCKABLE (dockable), -1, -1);
dockable = gimp_dialog_factory_dialog_new (global_dock_factory,
"gimp:channel-list");
if (dockable)
"gimp:channel-list", -1);
if (dockable && ! GIMP_DOCKABLE (dockable)->dockbook)
gimp_dock_add (GIMP_DOCK (dock), GIMP_DOCKABLE (dockable), -1, -1);
dockable = gimp_dialog_factory_dialog_new (global_dock_factory,
"gimp:path-list");
if (dockable)
"gimp:path-list", -1);
if (dockable && ! GIMP_DOCKABLE (dockable)->dockbook)
gimp_dock_add (GIMP_DOCK (dock), GIMP_DOCKABLE (dockable), -1, -1);
gtk_widget_show (dock);
......
......@@ -33,6 +33,14 @@ void dialogs_add_tab_cmd_callback (GtkWidget *widget,
void dialogs_remove_tab_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void dialogs_toggle_view_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void dialogs_preview_size_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void dialogs_toggle_image_menu_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
......
......@@ -223,7 +223,7 @@ void
edit_named_paste_cmd_callback (GtkWidget *widget,
gpointer data)
{
gimp_dialog_factory_dialog_raise (global_dock_factory, "gimp:buffer-list");
gimp_dialog_factory_dialog_raise (global_dock_factory, "gimp:buffer-list", -1);
}
void
......
......@@ -686,7 +686,6 @@ gimp_container_remove_handler (GimpContainer *container,
GimpContainerHandler *handler;
GList *list;
g_return_if_fail (container != NULL);
g_return_if_fail (GIMP_IS_CONTAINER (container));
g_return_if_fail (id != 0);
......
......@@ -158,77 +158,88 @@ static PaletteEditor *palette_editor_dialog = NULL;
GtkWidget *
dialogs_toolbox_get (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
return toolbox_create (context->gimp);
}
GtkWidget *
dialogs_tool_options_get (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
return tool_options_dialog_create (context->gimp);
}
GtkWidget *
dialogs_device_status_get (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
return device_status_create ();
}
GtkWidget *
dialogs_brush_select_get (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
return brush_dialog_create (context->gimp);
}
GtkWidget *
dialogs_pattern_select_get (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
return pattern_dialog_create (context->gimp);
}
GtkWidget *
dialogs_gradient_select_get (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
return gradient_dialog_create (context->gimp);
}
GtkWidget *
dialogs_palette_select_get (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
return palette_dialog_create (context->gimp);
}
GtkWidget *
dialogs_preferences_get (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
return preferences_dialog_create (context->gimp);
}
GtkWidget *
dialogs_input_devices_get (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
return input_dialog_create ();
}
GtkWidget *
dialogs_module_browser_get (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
return module_browser_new (context->gimp);
}
GtkWidget *
dialogs_undo_history_get (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
GimpImage *gimage;
GtkWidget *undo_history;
......@@ -252,7 +263,8 @@ dialogs_undo_history_get (GimpDialogFactory *factory,
GtkWidget *
dialogs_display_filters_get (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
#ifdef DISPLAY_FILTERS
GimpDisplay *gdisp;
......@@ -273,21 +285,24 @@ dialogs_display_filters_get (GimpDialogFactory *factory,
GtkWidget *
dialogs_tips_get (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
return tips_dialog_create ();
}
GtkWidget *
dialogs_about_get (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
return about_dialog_create ();
}
GtkWidget *
dialogs_brush_editor_get (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
if (! brush_editor_dialog)
{
......@@ -299,7 +314,8 @@ dialogs_brush_editor_get (GimpDialogFactory *factory,
GtkWidget *
dialogs_gradient_editor_get (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
if (! gradient_editor_dialog)
{
......@@ -311,7 +327,8 @@ dialogs_gradient_editor_get (GimpDialogFactory *factory,
GtkWidget *
dialogs_palette_editor_get (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
if (! palette_editor_dialog)
{
......@@ -326,7 +343,8 @@ dialogs_palette_editor_get (GimpDialogFactory *factory,
GtkWidget *
dialogs_dock_new (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
return gimp_image_dock_new (factory, context->gimp->images);
}
......@@ -336,13 +354,14 @@ dialogs_dock_new (GimpDialogFactory *factory,
GtkWidget *
dialogs_image_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
view = gimp_container_list_view_new (context->gimp->images,
context,
32,
preview_size,
FALSE,
5, 3);
......@@ -354,7 +373,8 @@ dialogs_image_list_view_new (GimpDialogFactory *factory,
GtkWidget *
dialogs_brush_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
......@@ -363,7 +383,7 @@ dialogs_brush_list_view_new (GimpDialogFactory *factory,
dialogs_edit_brush_func,
context,
TRUE,
32,
preview_size,
5, 3,
brushes_show_context_menu);
......@@ -375,7 +395,8 @@ dialogs_brush_list_view_new (GimpDialogFactory *factory,
GtkWidget *
dialogs_pattern_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
......@@ -383,7 +404,7 @@ dialogs_pattern_list_view_new (GimpDialogFactory *factory,
context->gimp->pattern_factory,
NULL,
context,
32,
preview_size,
5, 3,
patterns_show_context_menu);
......@@ -395,7 +416,8 @@ dialogs_pattern_list_view_new (GimpDialogFactory *factory,
GtkWidget *
dialogs_gradient_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
......@@ -403,7 +425,7 @@ dialogs_gradient_list_view_new (GimpDialogFactory *factory,
context->gimp->gradient_factory,
dialogs_edit_gradient_func,
context,
32 / 2,
preview_size,
5, 3,
gradients_show_context_menu);
......@@ -415,7 +437,8 @@ dialogs_gradient_list_view_new (GimpDialogFactory *factory,
GtkWidget *
dialogs_palette_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
......@@ -423,7 +446,7 @@ dialogs_palette_list_view_new (GimpDialogFactory *factory,
context->gimp->palette_factory,
dialogs_edit_palette_func,
context,
32,
preview_size,
5, 3,
palettes_show_context_menu);
......@@ -435,13 +458,14 @@ dialogs_palette_list_view_new (GimpDialogFactory *factory,
GtkWidget *
dialogs_tool_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
view = gimp_container_list_view_new (context->gimp->tool_info_list,
context,
22,
preview_size,
FALSE,
5, 3);
......@@ -453,14 +477,15 @@ dialogs_tool_list_view_new (GimpDialogFactory *factory,
GtkWidget *
dialogs_buffer_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
view = gimp_buffer_view_new (GIMP_VIEW_TYPE_LIST,
context->gimp->named_buffers,
context,
32,
preview_size,
5, 3,
buffers_show_context_menu);
......@@ -475,13 +500,14 @@ dialogs_buffer_list_view_new (GimpDialogFactory *factory,
GtkWidget *
dialogs_image_grid_view_new (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
view = gimp_container_grid_view_new (context->gimp->images,
context,
32,
preview_size,
FALSE,
5, 3);
......@@ -493,7 +519,8 @@ dialogs_image_grid_view_new (GimpDialogFactory *factory,
GtkWidget *
dialogs_brush_grid_view_new (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
......@@ -502,7 +529,7 @@ dialogs_brush_grid_view_new (GimpDialogFactory *factory,
dialogs_edit_brush_func,
context,
TRUE,
32,
preview_size,
5, 3,
brushes_show_context_menu);
......@@ -514,7 +541,8 @@ dialogs_brush_grid_view_new (GimpDialogFactory *factory,
GtkWidget *
dialogs_pattern_grid_view_new (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
......@@ -522,7 +550,7 @@ dialogs_pattern_grid_view_new (GimpDialogFactory *factory,
context->gimp->pattern_factory,
NULL,
context,
32,
preview_size,
5, 3,
patterns_show_context_menu);
......@@ -534,7 +562,8 @@ dialogs_pattern_grid_view_new (GimpDialogFactory *factory,
GtkWidget *
dialogs_gradient_grid_view_new (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
......@@ -542,7 +571,7 @@ dialogs_gradient_grid_view_new (GimpDialogFactory *factory,
context->gimp->gradient_factory,
dialogs_edit_gradient_func,
context,
32,
preview_size,
5, 3,
gradients_show_context_menu);
......@@ -554,7 +583,8 @@ dialogs_gradient_grid_view_new (GimpDialogFactory *factory,
GtkWidget *
dialogs_palette_grid_view_new (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
......@@ -562,7 +592,7 @@ dialogs_palette_grid_view_new (GimpDialogFactory *factory,
context->gimp->palette_factory,
dialogs_edit_palette_func,
context,
32,
preview_size,
5, 3,
palettes_show_context_menu);
......@@ -574,13 +604,14 @@ dialogs_palette_grid_view_new (GimpDialogFactory *factory,
GtkWidget *
dialogs_tool_grid_view_new (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
view = gimp_container_grid_view_new (context->gimp->tool_info_list,
context,
22,
preview_size,
FALSE,
5, 3);
......@@ -592,14 +623,15 @@ dialogs_tool_grid_view_new (GimpDialogFactory *factory,
GtkWidget *
dialogs_buffer_grid_view_new (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
view = gimp_buffer_view_new (GIMP_VIEW_TYPE_GRID,
context->gimp->named_buffers,
context,
32,
preview_size,
5, 3,
buffers_show_context_menu);
......@@ -614,7 +646,8 @@ dialogs_buffer_grid_view_new (GimpDialogFactory *factory,
GtkWidget *
dialogs_layer_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
GimpImage *gimage;
GtkWidget *view;
......@@ -623,7 +656,7 @@ dialogs_layer_list_view_new (GimpDialogFactory *factory,
gimage = gimp_context_get_image (context);
view = gimp_drawable_list_view_new
(gimprc.preview_size,
(preview_size,
gimage,
GIMP_TYPE_LAYER,
"active_layer_changed",
......@@ -650,7 +683,8 @@ dialogs_layer_list_view_new (GimpDialogFactory *factory,
GtkWidget *
dialogs_channel_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
GimpImage *gimage;
GtkWidget *view;
......@@ -659,7 +693,7 @@ dialogs_channel_list_view_new (GimpDialogFactory *factory,
gimage = gimp_context_get_image (context);
view = gimp_drawable_list_view_new
(gimprc.preview_size,
(preview_size,
gimage,
GIMP_TYPE_CHANNEL,
"active_channel_changed",
......@@ -686,7 +720,8 @@ dialogs_channel_list_view_new (GimpDialogFactory *factory,
GtkWidget *
dialogs_path_list_view_new (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
static GtkWidget *view = NULL;
......@@ -711,7 +746,8 @@ dialogs_path_list_view_new (GimpDialogFactory *factory,
GtkWidget *
dialogs_indexed_palette_new (GimpDialogFactory *factory,
GimpContext *context)
GimpContext *context,
gint preview_size)
{
GimpImage *gimage;
GtkWidget *view;
......@@ -740,14 +776,15 @@ dialogs_indexed_palette_new (GimpDialogFactory *factory,
GtkWidget *