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

app/widgets/Makefile.am new file containing

2002-03-22  Michael Natterer  <mitch@gimp.org>

	* app/widgets/Makefile.am
	* app/widgets/gimppreview-utils.[ch]: new file containing
	gimp_preview_type_from_viewable() so we don't need to include
	*all* vieable and preview subclasses in gimppreview.c

	* app/widgets/gimppreview.c: gimp_preview_set_viewable: never
	unset the drag source if the viewable is set to NULL (fixes dock
	tabs, thanks to sjburges), also check the passed viweable's type.

	* themes/Default/gtkrc: set the paned handle_size to 6 pixels, so
	it has the same size as the dock_separator.

	* etc/gtkrc_user: set both to 5 here, also fiddle around with
	the global focus padding and the GtkOptionMenu indicator.
parent a226586d
2002-03-22 Michael Natterer <mitch@gimp.org>
* app/widgets/Makefile.am
* app/widgets/gimppreview-utils.[ch]: new file containing
gimp_preview_type_from_viewable() so we don't need to include
*all* vieable and preview subclasses in gimppreview.c
* app/widgets/gimppreview.c: gimp_preview_set_viewable: never
unset the drag source if the viewable is set to NULL (fixes dock
tabs, thanks to sjburges), also check the passed viweable's type.
* themes/Default/gtkrc: set the paned handle_size to 6 pixels, so
it has the same size as the dock_separator.
* etc/gtkrc_user: set both to 5 here, also fiddle around with
the global focus padding and the GtkOptionMenu indicator.
2002-03-22 Sven Neumann <sven@gimp.org>
 
* app/plug-in/plug-in-rc.c
......
......@@ -127,6 +127,8 @@ libappwidgets_a_sources = @STRIP_BEGIN@ \
gimppatternpreview.h \
gimppreview.c \
gimppreview.h \
gimppreview-utils.c \
gimppreview-utils.h \
gimptoolbox.c \
gimptoolbox.h \
gimptoolbox-color-area.c \
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimppreview-utils.c
* Copyright (C) 2001-2002 Michael Natterer <mitch@gimp.org>
*
* 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"
#include <gtk/gtk.h>
#include "widgets-types.h"
#include "core/gimpbrush.h"
#include "core/gimpbuffer.h"
#include "core/gimpdrawable.h"
#include "core/gimpgradient.h"
#include "core/gimpimage.h"
#include "core/gimpimagefile.h"
#include "core/gimppalette.h"
#include "core/gimppattern.h"
#include "core/gimptoolinfo.h"
#include "gimpbrushpreview.h"
#include "gimpbufferpreview.h"
#include "gimpdrawablepreview.h"
#include "gimpgradientpreview.h"
#include "gimpimagepreview.h"
#include "gimpimagefilepreview.h"
#include "gimppalettepreview.h"
#include "gimppatternpreview.h"
#include "gimptoolinfopreview.h"
GType
gimp_preview_type_from_viewable (GimpViewable *viewable)
{
GType type = GIMP_TYPE_PREVIEW;
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), G_TYPE_NONE);
if (GIMP_IS_BRUSH (viewable))
{
type = GIMP_TYPE_BRUSH_PREVIEW;
}
else if (GIMP_IS_DRAWABLE (viewable))
{
type = GIMP_TYPE_DRAWABLE_PREVIEW;
}
else if (GIMP_IS_IMAGE (viewable))
{
type = GIMP_TYPE_IMAGE_PREVIEW;
}
else if (GIMP_IS_PATTERN (viewable))
{
type = GIMP_TYPE_PATTERN_PREVIEW;
}
else if (GIMP_IS_GRADIENT (viewable))
{
type = GIMP_TYPE_GRADIENT_PREVIEW;
}
else if (GIMP_IS_PALETTE (viewable))
{
type = GIMP_TYPE_PALETTE_PREVIEW;
}
else if (GIMP_IS_BUFFER (viewable))
{
type = GIMP_TYPE_BUFFER_PREVIEW;
}
else if (GIMP_IS_TOOL_INFO (viewable))
{
type = GIMP_TYPE_TOOL_INFO_PREVIEW;
}
else if (GIMP_IS_IMAGEFILE (viewable))
{
type = GIMP_TYPE_IMAGEFILE_PREVIEW;
}
return type;
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimppreview.h
* Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
*
* 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.
*/
#ifndef __GIMP_PREVIEW_UTILS_H__
#define __GIMP_PREVIEW_UTILS_H__
GType gimp_preview_type_from_viewable (GimpViewable *viewable);
#endif /* __GIMP_PREVIEW_UTILS_H__ */
......@@ -34,30 +34,14 @@
#include "base/temp-buf.h"
#include "core/gimpbrush.h"
#include "core/gimpbuffer.h"
#include "core/gimpdrawable.h"
#include "core/gimpgradient.h"
#include "core/gimpimage.h"
#include "core/gimpimagefile.h"
#include "core/gimpmarshal.h"
#include "core/gimppalette.h"
#include "core/gimppattern.h"
#include "core/gimptoolinfo.h"
#include "core/gimpviewable.h"
#include "display/gimpdisplayshell-render.h"
#include "gimpbrushpreview.h"
#include "gimpbufferpreview.h"
#include "gimpdnd.h"
#include "gimpdrawablepreview.h"
#include "gimpgradientpreview.h"
#include "gimpimagepreview.h"
#include "gimpimagefilepreview.h"
#include "gimppalettepreview.h"
#include "gimppatternpreview.h"
#include "gimppreview.h"
#include "gimptoolinfopreview.h"
#include "gimppreview-utils.h"
#define PREVIEW_BYTES 3
......@@ -350,7 +334,7 @@ gimp_preview_expose_event (GtkWidget *widget,
extern gboolean gimp_debug_memsize;
#endif
static gint
static gboolean
gimp_preview_button_press_event (GtkWidget *widget,
GdkEventButton *bevent)
{
......@@ -413,7 +397,7 @@ gimp_preview_button_press_event (GtkWidget *widget,
return TRUE;
}
static gint
static gboolean
gimp_preview_button_release_event (GtkWidget *widget,
GdkEventButton *bevent)
{
......@@ -461,7 +445,7 @@ gimp_preview_button_release_event (GtkWidget *widget,
return TRUE;
}
static gint
static gboolean
gimp_preview_enter_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
{
......@@ -480,7 +464,7 @@ gimp_preview_enter_notify_event (GtkWidget *widget,
return FALSE;
}
static gint
static gboolean
gimp_preview_leave_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
{
......@@ -499,51 +483,6 @@ gimp_preview_leave_notify_event (GtkWidget *widget,
return FALSE;
}
static GimpPreview *
gimp_preview_new_by_type (GimpViewable *viewable)
{
GType type = GIMP_TYPE_PREVIEW;
if (GIMP_IS_BRUSH (viewable))
{
type = GIMP_TYPE_BRUSH_PREVIEW;
}
else if (GIMP_IS_DRAWABLE (viewable))
{
type = GIMP_TYPE_DRAWABLE_PREVIEW;
}
else if (GIMP_IS_IMAGE (viewable))
{
type = GIMP_TYPE_IMAGE_PREVIEW;
}
else if (GIMP_IS_PATTERN (viewable))
{
type = GIMP_TYPE_PATTERN_PREVIEW;
}
else if (GIMP_IS_GRADIENT (viewable))
{
type = GIMP_TYPE_GRADIENT_PREVIEW;
}
else if (GIMP_IS_PALETTE (viewable))
{
type = GIMP_TYPE_PALETTE_PREVIEW;
}
else if (GIMP_IS_BUFFER (viewable))
{
type = GIMP_TYPE_BUFFER_PREVIEW;
}
else if (GIMP_IS_TOOL_INFO (viewable))
{
type = GIMP_TYPE_TOOL_INFO_PREVIEW;
}
else if (GIMP_IS_IMAGEFILE (viewable))
{
type = GIMP_TYPE_IMAGEFILE_PREVIEW;
}
return g_object_new (type, NULL);
}
/* public functions */
......@@ -559,7 +498,7 @@ gimp_preview_new (GimpViewable *viewable,
g_return_val_if_fail (size > 0 && size <= 256, NULL);
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
preview = gimp_preview_new_by_type (viewable);
preview = g_object_new (gimp_preview_type_from_viewable (viewable), NULL);
preview->is_popup = is_popup;
......@@ -586,7 +525,7 @@ gimp_preview_new_full (GimpViewable *viewable,
g_return_val_if_fail (height > 0 && height <= 256, NULL);
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
preview = gimp_preview_new_by_type (viewable);
preview = g_object_new (gimp_preview_type_from_viewable (viewable), NULL);
preview->is_popup = is_popup;
preview->clickable = clickable;
......@@ -605,16 +544,11 @@ gimp_preview_set_viewable (GimpPreview *preview,
{
g_return_if_fail (GIMP_IS_PREVIEW (preview));
g_return_if_fail (! viewable || GIMP_IS_VIEWABLE (viewable));
g_return_if_fail (! viewable || (gimp_preview_type_from_viewable (viewable) ==
G_TYPE_FROM_INSTANCE (preview)));
if (preview->viewable)
{
if (! preview->is_popup)
{
gtk_drag_source_unset (GTK_WIDGET (preview));
gimp_dnd_viewable_source_unset (GTK_WIDGET (preview),
G_TYPE_FROM_INSTANCE (preview->viewable));
}
g_object_remove_weak_pointer (G_OBJECT (preview->viewable),
(gpointer *) &preview->viewable);
......@@ -627,23 +561,22 @@ gimp_preview_set_viewable (GimpPreview *preview,
preview);
}
else if (viewable && ! preview->is_popup)
{
gimp_gtk_drag_source_set_by_type (GTK_WIDGET (preview),
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
G_TYPE_FROM_INSTANCE (viewable),
GDK_ACTION_COPY);
gimp_dnd_viewable_source_set (GTK_WIDGET (preview),
G_TYPE_FROM_INSTANCE (viewable),
gimp_preview_drag_viewable,
NULL);
}
preview->viewable = viewable;
if (preview->viewable)
{
if (! preview->is_popup)
{
gimp_gtk_drag_source_set_by_type (GTK_WIDGET (preview),
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
G_TYPE_FROM_INSTANCE (preview->viewable),
GDK_ACTION_COPY);
gimp_dnd_viewable_source_set (GTK_WIDGET (preview),
G_TYPE_FROM_INSTANCE (preview->viewable),
gimp_preview_drag_viewable,
NULL);
}
g_object_add_weak_pointer (G_OBJECT (preview->viewable),
(gpointer *) &preview->viewable);
......
......@@ -34,30 +34,14 @@
#include "base/temp-buf.h"
#include "core/gimpbrush.h"
#include "core/gimpbuffer.h"
#include "core/gimpdrawable.h"
#include "core/gimpgradient.h"
#include "core/gimpimage.h"
#include "core/gimpimagefile.h"
#include "core/gimpmarshal.h"
#include "core/gimppalette.h"
#include "core/gimppattern.h"
#include "core/gimptoolinfo.h"
#include "core/gimpviewable.h"
#include "display/gimpdisplayshell-render.h"
#include "gimpbrushpreview.h"
#include "gimpbufferpreview.h"
#include "gimpdnd.h"
#include "gimpdrawablepreview.h"
#include "gimpgradientpreview.h"
#include "gimpimagepreview.h"
#include "gimpimagefilepreview.h"
#include "gimppalettepreview.h"
#include "gimppatternpreview.h"
#include "gimppreview.h"
#include "gimptoolinfopreview.h"
#include "gimppreview-utils.h"
#define PREVIEW_BYTES 3
......@@ -350,7 +334,7 @@ gimp_preview_expose_event (GtkWidget *widget,
extern gboolean gimp_debug_memsize;
#endif
static gint
static gboolean
gimp_preview_button_press_event (GtkWidget *widget,
GdkEventButton *bevent)
{
......@@ -413,7 +397,7 @@ gimp_preview_button_press_event (GtkWidget *widget,
return TRUE;
}
static gint
static gboolean
gimp_preview_button_release_event (GtkWidget *widget,
GdkEventButton *bevent)
{
......@@ -461,7 +445,7 @@ gimp_preview_button_release_event (GtkWidget *widget,
return TRUE;
}
static gint
static gboolean
gimp_preview_enter_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
{
......@@ -480,7 +464,7 @@ gimp_preview_enter_notify_event (GtkWidget *widget,
return FALSE;
}
static gint
static gboolean
gimp_preview_leave_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
{
......@@ -499,51 +483,6 @@ gimp_preview_leave_notify_event (GtkWidget *widget,
return FALSE;
}
static GimpPreview *
gimp_preview_new_by_type (GimpViewable *viewable)
{
GType type = GIMP_TYPE_PREVIEW;
if (GIMP_IS_BRUSH (viewable))
{
type = GIMP_TYPE_BRUSH_PREVIEW;
}
else if (GIMP_IS_DRAWABLE (viewable))
{
type = GIMP_TYPE_DRAWABLE_PREVIEW;
}
else if (GIMP_IS_IMAGE (viewable))
{
type = GIMP_TYPE_IMAGE_PREVIEW;
}
else if (GIMP_IS_PATTERN (viewable))
{
type = GIMP_TYPE_PATTERN_PREVIEW;
}
else if (GIMP_IS_GRADIENT (viewable))
{
type = GIMP_TYPE_GRADIENT_PREVIEW;
}
else if (GIMP_IS_PALETTE (viewable))
{
type = GIMP_TYPE_PALETTE_PREVIEW;
}
else if (GIMP_IS_BUFFER (viewable))
{
type = GIMP_TYPE_BUFFER_PREVIEW;
}
else if (GIMP_IS_TOOL_INFO (viewable))
{
type = GIMP_TYPE_TOOL_INFO_PREVIEW;
}
else if (GIMP_IS_IMAGEFILE (viewable))
{
type = GIMP_TYPE_IMAGEFILE_PREVIEW;
}
return g_object_new (type, NULL);
}
/* public functions */
......@@ -559,7 +498,7 @@ gimp_preview_new (GimpViewable *viewable,
g_return_val_if_fail (size > 0 && size <= 256, NULL);
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
preview = gimp_preview_new_by_type (viewable);
preview = g_object_new (gimp_preview_type_from_viewable (viewable), NULL);
preview->is_popup = is_popup;
......@@ -586,7 +525,7 @@ gimp_preview_new_full (GimpViewable *viewable,
g_return_val_if_fail (height > 0 && height <= 256, NULL);
g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL);
preview = gimp_preview_new_by_type (viewable);
preview = g_object_new (gimp_preview_type_from_viewable (viewable), NULL);
preview->is_popup = is_popup;
preview->clickable = clickable;
......@@ -605,16 +544,11 @@ gimp_preview_set_viewable (GimpPreview *preview,
{
g_return_if_fail (GIMP_IS_PREVIEW (preview));
g_return_if_fail (! viewable || GIMP_IS_VIEWABLE (viewable));
g_return_if_fail (! viewable || (gimp_preview_type_from_viewable (viewable) ==
G_TYPE_FROM_INSTANCE (preview)));
if (preview->viewable)
{
if (! preview->is_popup)
{
gtk_drag_source_unset (GTK_WIDGET (preview));
gimp_dnd_viewable_source_unset (GTK_WIDGET (preview),
G_TYPE_FROM_INSTANCE (preview->viewable));
}
g_object_remove_weak_pointer (G_OBJECT (preview->viewable),
(gpointer *) &preview->viewable);
......@@ -627,23 +561,22 @@ gimp_preview_set_viewable (GimpPreview *preview,
preview);
}
else if (viewable && ! preview->is_popup)
{
gimp_gtk_drag_source_set_by_type (GTK_WIDGET (preview),
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
G_TYPE_FROM_INSTANCE (viewable),
GDK_ACTION_COPY);
gimp_dnd_viewable_source_set (GTK_WIDGET (preview),
G_TYPE_FROM_INSTANCE (viewable),
gimp_preview_drag_viewable,
NULL);
}
preview->viewable = viewable;
if (preview->viewable)
{
if (! preview->is_popup)
{
gimp_gtk_drag_source_set_by_type (GTK_WIDGET (preview),
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
G_TYPE_FROM_INSTANCE (preview->viewable),
GDK_ACTION_COPY);
gimp_dnd_viewable_source_set (GTK_WIDGET (preview),
G_TYPE_FROM_INSTANCE (preview->viewable),
gimp_preview_drag_viewable,
NULL);
}
g_object_add_weak_pointer (G_OBJECT (preview->viewable),
(gpointer *) &preview->viewable);
......
......@@ -34,30 +34,14 @@
#include "base/temp-buf.h"
#include "core/gimpbrush.h"
#include "core/gimpbuffer.h"
#include "core/gimpdrawable.h"
#include "core/gimpgradient.h"
#include "core/gimpimage.h"
#include "core/gimpimagefile.h"
#include "core/gimpmarshal.h"
#include "core/gimppalette.h"
#include "core/gimppattern.h"
#include "core/gimptoolinfo.h"
#include "core/gimpviewable.h"
#include "display/gimpdisplayshell-render.h"
#include "gimpbrushpreview.h"
#include "gimpbufferpreview.h"
#include "gimpdnd.h"
#include "gimpdrawablepreview.h"
#include "gimpgradientpreview.h"
#include "gimpimagepreview.h"
#include "gimpimagefilepreview.h"
#include "gimppalettepreview.h"
#include "gimppatternpreview.h"
#include "gimppreview.h"
#include "gimptoolinfopreview.h"
#include "gimppreview-utils.h"
#define PREVIEW_BYTES 3
......@@ -350,7 +334,7 @@ gimp_preview_expose_event (GtkWidget *widget,
extern gboolean gimp_debug_memsize;
#endif
static gint
static gboolean
gimp_preview_button_press_event (GtkWidget *widget,
GdkEventButton *bevent)
{
......@@ -413,7 +397,7 @@ gimp_preview_button_press_event (GtkWidget *widget,
return TRUE;
}
static gint
static gboolean
gimp_preview_button_release_event (GtkWidget *widget,
GdkEventButton *bevent)
{
......@@ -461,7 +445,7 @@ gimp_preview_button_release_event (GtkWidget *widget,
return TRUE;
}
static gint
static gboolean
gimp_preview_enter_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
{
......@@ -480,7 +464,7 @@ gimp_preview_enter_notify_event (GtkWidget *widget,
return FALSE;
}
static gint
static gboolean
gimp_preview_leave_notify_event (GtkWidget *widget,
GdkEventCrossing *event)
{
......@@ -499,51 +483,6 @@ gimp_preview_leave_notify_event (GtkWidget *widget,
return FALSE;
}
static GimpPreview *
gimp_preview_new_by_type (GimpViewable *viewable)
{
GType type = GIMP_TYPE_PREVIEW;
if (GIMP_IS_BRUSH (viewable))
{
type = GIMP_TYPE_BRUSH_PREVIEW;
}
else if (GIMP_IS_DRAWABLE (viewable))
{
type = GIMP_TYPE_DRAWABLE_PREVIEW;
}
else if (GIMP_IS_IMAGE (viewable))
{
type = GIMP_TYPE_IMAGE_PREVIEW;
}
else if (GIMP_IS_PATTERN (viewable))
{
type = GIMP_TYPE_PATTERN_PREVIEW;
}
else if (GIMP_IS_GRADIENT (viewable))
{
type = GIMP_TYPE_GRADIENT_PREVIEW;