diff --git a/ChangeLog b/ChangeLog index 9c63e4b111..10f172cc2d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,59 @@ +2001-04-11 Michael Natterer + + * configure.in + * app/widgets/*: new directory containing all widgets. Some of them + will go to libgimpwidgets. + + * app/color_panel.[ch] + * app/gimpbrushpreview.[ch] + * app/gimpconstrainedhwrapbox.[ch] + * app/gimpcontainergridview.[ch] + * app/gimpcontainerlistview.[ch] + * app/gimpcontainerview.[ch] + * app/gimpdatafactoryview.[ch] + * app/gimpdock.[ch] + * app/gimpdockable.[ch] + * app/gimpdockbook.[ch] + * app/gimpdrawablelistitem.[ch] + * app/gimpdrawablelistview.[ch] + * app/gimpdrawablepreview.[ch] + * app/gimpgradientpreview.[ch] + * app/gimpimagepreview.[ch] + * app/gimplayerlistitem.[ch] + * app/gimplayerlistview.{ch] + * app/gimplistitem.[ch] + * app/gimppalettepreview.[ch] + * app/gimppatternpreview.[ch] + * app/gimppreview.[ch] + * app/gimptoolinfopreview.[ch] + * app/gtkhwrapbox.[ch] + * app/gtkvwrapbox.[ch] + * app/gtkwrapbox.[ch] + * app/histogramwidget.[ch]: removed from here. + + * app/Makefile.am + * app/appenums.h + * app/brush_select.c + * app/channels_dialog.c + * app/devices.c + * app/gimpdnd.c + * app/gimpdrawable-preview.c + * app/gimphistogram.h + * app/gradient_editor.c + * app/gradient_select.c + * app/indicator_area.c + * app/info_window.c + * app/palette.c + * app/palette_select.c + * app/pattern_select.c + * app/qmask.c + * app/test_commands.c + * app/toolbox.c + * app/pdb/color_cmds.c + * app/tools/paint_options.c + * app/tools/tool_options_dialog.c + * tools/pdbgen/pdb/color.pdb: changed accordingly. + 2001-04-10 Michael Natterer * app/gimpdock.c: started to add some more separator event handling. diff --git a/app/Makefile.am b/app/Makefile.am index ff87d159e0..0d688aab67 100644 --- a/app/Makefile.am +++ b/app/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in -SUBDIRS = paint-funcs pdb tools +SUBDIRS = paint-funcs pdb tools widgets scriptdata = @@ -51,8 +51,6 @@ gimp_SOURCES = \ color_area.h \ color_notebook.c \ color_notebook.h \ - color_panel.c \ - color_panel.h \ color_select.c \ color_select.h \ color_transfer.c \ @@ -305,57 +303,6 @@ gimp_SOURCES = \ tile_swap.c \ tile_swap.h \ \ - gimpbrushpreview.c \ - gimpbrushpreview.h \ - gimpcontainergridview.h \ - gimpcontainergridview.c \ - gimpcontainerlistview.h \ - gimpcontainerlistview.c \ - gimpcontainerview.h \ - gimpcontainerview.c \ - gimpdatafactoryview.h \ - gimpdatafactoryview.c \ - gimpdock.c \ - gimpdock.h \ - gimpdockable.c \ - gimpdockable.h \ - gimpdockbook.c \ - gimpdockbook.h \ - gimpdrawablelistitem.c \ - gimpdrawablelistitem.h \ - gimpdrawablelistview.c \ - gimpdrawablelistview.h \ - gimpdrawablepreview.c \ - gimpdrawablepreview.h \ - gimpgradientpreview.h \ - gimpgradientpreview.c \ - gimpimagepreview.h \ - gimpimagepreview.c \ - gimplayerlistitem.h \ - gimplayerlistitem.c \ - gimplayerlistview.h \ - gimplayerlistview.c \ - gimplistitem.h \ - gimplistitem.c \ - gimppalettepreview.h \ - gimppalettepreview.c \ - gimppatternpreview.h \ - gimppatternpreview.c \ - gimppreview.h \ - gimppreview.c \ - gimptoolinfopreview.h \ - gimptoolinfopreview.c \ - gtkwrapbox.c \ - gtkwrapbox.h \ - gtkhwrapbox.c \ - gtkhwrapbox.h \ - gtkvwrapbox.c \ - gtkvwrapbox.h \ - gimpconstrainedhwrapbox.c \ - gimpconstrainedhwrapbox.h \ - histogramwidget.c \ - histogramwidget.h \ - \ marching_ants.h \ pixmaps2.h @@ -390,6 +337,7 @@ gimp_LDADD = \ paint-funcs/libapppaint-funcs.la \ pdb/libapppdb.la \ tools/libapptools.la \ + widgets/libappwidgets.la \ $(top_builddir)/libgimpcolor/libgimpcolor-$(LT_RELEASE).la \ $(top_builddir)/libgimpmath/libgimpmath-$(LT_RELEASE).la \ $(top_builddir)/libgimpwidgets/libgimpwidgets-$(LT_RELEASE).la \ diff --git a/app/actions/qmask-commands.c b/app/actions/qmask-commands.c index 95cfd79672..95822059ff 100644 --- a/app/actions/qmask-commands.c +++ b/app/actions/qmask-commands.c @@ -29,7 +29,8 @@ #include "apptypes.h" -#include "color_panel.h" +#include "widgets/gimpcolorpanel.h" + #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" diff --git a/app/actions/quick-mask-commands.c b/app/actions/quick-mask-commands.c index 95cfd79672..95822059ff 100644 --- a/app/actions/quick-mask-commands.c +++ b/app/actions/quick-mask-commands.c @@ -29,7 +29,8 @@ #include "apptypes.h" -#include "color_panel.h" +#include "widgets/gimpcolorpanel.h" + #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" diff --git a/app/appenums.h b/app/appenums.h index 2e39c3fefa..b8fbefc156 100644 --- a/app/appenums.h +++ b/app/appenums.h @@ -263,6 +263,16 @@ typedef enum /*< skip >*/ CURSOR_MODE_CROSSHAIR } CursorMode; +typedef enum /*< skip >*/ +{ + GIMP_HISTOGRAM_VALUE = 0, + GIMP_HISTOGRAM_RED = 1, + GIMP_HISTOGRAM_GREEN = 2, + GIMP_HISTOGRAM_BLUE = 3, + GIMP_HISTOGRAM_ALPHA = 4 +} GimpHistogramChannel; + + typedef enum /*< skip >*/ { GIMP_TOOL_CURSOR_NONE, diff --git a/app/base/gimphistogram.h b/app/base/gimphistogram.h index 073e5f4ec6..670b578f40 100644 --- a/app/base/gimphistogram.h +++ b/app/base/gimphistogram.h @@ -22,16 +22,6 @@ #define __GIMP_HISTOGRAM_H__ -typedef enum -{ - GIMP_HISTOGRAM_VALUE = 0, - GIMP_HISTOGRAM_RED = 1, - GIMP_HISTOGRAM_GREEN = 2, - GIMP_HISTOGRAM_BLUE = 3, - GIMP_HISTOGRAM_ALPHA = 4 -} GimpHistogramChannel; - - GimpHistogram * gimp_histogram_new (void); void gimp_histogram_free (GimpHistogram *histogram); void gimp_histogram_calculate (GimpHistogram *historgam, diff --git a/app/brush_select.c b/app/brush_select.c index c3ff253581..beca142f84 100644 --- a/app/brush_select.c +++ b/app/brush_select.c @@ -26,6 +26,8 @@ #include "apptypes.h" +#include "widgets/gimpdatafactoryview.h" + #include "appenv.h" #include "context_manager.h" #include "brush_edit.h" @@ -33,7 +35,6 @@ #include "dialog_handler.h" #include "gimpbrushgenerated.h" #include "gimpcontainer.h" -#include "gimpdatafactoryview.h" #include "gimpcontext.h" #include "gimpdata.h" #include "gimpdatafactory.h" diff --git a/app/channels_dialog.c b/app/channels_dialog.c index 235544d26e..152bf03147 100644 --- a/app/channels_dialog.c +++ b/app/channels_dialog.c @@ -29,9 +29,10 @@ #include "paint-funcs/paint-funcs.h" +#include "widgets/gimpcolorpanel.h" + #include "appenv.h" #include "channels_dialog.h" -#include "color_panel.h" #include "drawable.h" #include "gdisplay.h" #include "gimage.h" diff --git a/app/color_panel.c b/app/color_panel.c deleted file mode 100644 index c9bf08a6b2..0000000000 --- a/app/color_panel.c +++ /dev/null @@ -1,220 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * 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 - -#include - -#include "apptypes.h" - -#include "appenv.h" -#include "color_panel.h" -#include "color_notebook.h" - - -struct _GimpColorPanel -{ - GimpColorButton parent; - - ColorNotebook *color_notebook; - gboolean color_notebook_active; -}; - -/* local function prototypes */ -static void gimp_color_panel_class_init (GimpColorPanelClass *klass); -static void gimp_color_panel_init (GimpColorPanel *panel); -static void gimp_color_panel_destroy (GtkObject *object); -static void gimp_color_panel_color_changed (GimpColorButton *button); -static void gimp_color_panel_clicked (GtkButton *button); - -static void gimp_color_panel_select_callback (ColorNotebook *notebook, - const GimpRGB *color, - ColorNotebookState state, - gpointer data); - - -static GimpColorButtonClass *parent_class = NULL; - - -GtkType -gimp_color_panel_get_type (void) -{ - static guint panel_type = 0; - - if (!panel_type) - { - GtkTypeInfo panel_info = - { - "GimpColorPanel", - sizeof (GimpColorPanel), - sizeof (GimpColorPanelClass), - (GtkClassInitFunc) gimp_color_panel_class_init, - (GtkObjectInitFunc) gimp_color_panel_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL - }; - - panel_type = gtk_type_unique (GIMP_TYPE_COLOR_BUTTON, &panel_info); - } - - return panel_type; -} - -static void -gimp_color_panel_class_init (GimpColorPanelClass *klass) -{ - GtkObjectClass *object_class; - GtkButtonClass *button_class; - GimpColorButtonClass *color_button_class; - - object_class = (GtkObjectClass *) klass; - button_class = (GtkButtonClass *) klass; - color_button_class = (GimpColorButtonClass *) klass; - - parent_class = gtk_type_class (GIMP_TYPE_COLOR_BUTTON); - - object_class->destroy = gimp_color_panel_destroy; - button_class->clicked = gimp_color_panel_clicked; - color_button_class->color_changed = gimp_color_panel_color_changed; -} - -static void -gimp_color_panel_init (GimpColorPanel *panel) -{ - panel->color_notebook = NULL; - panel->color_notebook_active = FALSE; -} - -static void -gimp_color_panel_destroy (GtkObject *object) -{ - GimpColorPanel *panel; - - g_return_if_fail (object != NULL); - g_return_if_fail (GIMP_IS_COLOR_PANEL (object)); - - panel = GIMP_COLOR_PANEL (object); - - /* make sure we hide and free color_notebook */ - if (panel->color_notebook) - { - color_notebook_hide (panel->color_notebook); - color_notebook_free (panel->color_notebook); - } - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gimp_color_panel_new (const gchar *title, - const GimpRGB *color, - GimpColorAreaType type, - gint width, - gint height) -{ - GimpColorPanel *panel; - - g_return_val_if_fail (color != NULL, NULL); - - panel = gtk_type_new (GIMP_TYPE_COLOR_PANEL); - - GIMP_COLOR_BUTTON (panel)->title = g_strdup (title); - - gimp_color_button_set_type (GIMP_COLOR_BUTTON (panel), type); - gimp_color_button_set_color (GIMP_COLOR_BUTTON (panel), color); - gtk_widget_set_usize (GTK_WIDGET (panel), width, height); - - return GTK_WIDGET (panel); -} - -static void -gimp_color_panel_color_changed (GimpColorButton *button) -{ - GimpColorPanel *panel; - GimpRGB color; - - panel = GIMP_COLOR_PANEL (button); - - if (panel->color_notebook_active) - { - gimp_color_button_get_color (GIMP_COLOR_BUTTON (button), &color); - color_notebook_set_color (panel->color_notebook, &color); - } -} - -static void -gimp_color_panel_clicked (GtkButton *button) -{ - GimpColorPanel *panel; - GimpRGB color; - - panel = GIMP_COLOR_PANEL (button); - - gimp_color_button_get_color (GIMP_COLOR_BUTTON (button), &color); - - if (! panel->color_notebook) - { - panel->color_notebook = - color_notebook_new (GIMP_COLOR_BUTTON (button)->title, - (const GimpRGB *) &color, - gimp_color_panel_select_callback, - panel, - FALSE, - gimp_color_button_has_alpha (GIMP_COLOR_BUTTON (button))); - panel->color_notebook_active = TRUE; - } - else - { - if (! panel->color_notebook_active) - { - color_notebook_show (panel->color_notebook); - panel->color_notebook_active = TRUE; - } - color_notebook_set_color (panel->color_notebook, &color); - } -} - -static void -gimp_color_panel_select_callback (ColorNotebook *notebook, - const GimpRGB *color, - ColorNotebookState state, - gpointer data) -{ - GimpColorPanel *panel; - - panel = GIMP_COLOR_PANEL (data); - - if (panel->color_notebook) - { - switch (state) - { - case COLOR_NOTEBOOK_UPDATE: - break; - case COLOR_NOTEBOOK_OK: - gimp_color_button_set_color (GIMP_COLOR_BUTTON (panel), color); - /* Fallthrough */ - case COLOR_NOTEBOOK_CANCEL: - color_notebook_hide (panel->color_notebook); - panel->color_notebook_active = FALSE; - } - } -} diff --git a/app/color_panel.h b/app/color_panel.h deleted file mode 100644 index 7d7fa5fb68..0000000000 --- a/app/color_panel.h +++ /dev/null @@ -1,48 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * 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 __COLOR_PANEL_H__ -#define __COLOR_PANEL_H__ - - -#include "libgimpwidgets/gimpcolorbutton.h" - - -#define GIMP_TYPE_COLOR_PANEL (gimp_color_panel_get_type ()) -#define GIMP_COLOR_PANEL(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_COLOR_PANEL, GimpColorPanel)) -#define GIMP_COLOR_PANEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_PANEL, GimpColorPanelClass)) -#define GIMP_IS_COLOR_PANEL(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_COLOR_PANEL)) -#define GIMP_IS_COLOR_PANEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_PANEL)) - -typedef struct _GimpColorPanel GimpColorPanel; -typedef struct _GimpColorPanelClass GimpColorPanelClass; - -struct _GimpColorPanelClass -{ - GimpColorButtonClass parent_class; -}; - -GtkType gimp_color_panel_get_type (void); -GtkWidget * gimp_color_panel_new (const gchar *title, - const GimpRGB *color, - GimpColorAreaType type, - gint width, - gint height); - - -#endif /* __COLOR_PANEL_H__ */ diff --git a/app/core/gimpdrawable-preview.c b/app/core/gimpdrawable-preview.c index da78afeb51..0d7a2bdb00 100644 --- a/app/core/gimpdrawable-preview.c +++ b/app/core/gimpdrawable-preview.c @@ -28,10 +28,11 @@ #include "paint-funcs/paint-funcs.h" +#include "widgets/gimpdrawablepreview.h" + #include "gimpchannel.h" #include "gimpimage.h" #include "gimpdrawable.h" -#include "gimpdrawablepreview.h" #include "gimplayer.h" #include "gimppreviewcache.h" #include "pixel_region.h" diff --git a/app/core/gimpimage-qmask.c b/app/core/gimpimage-qmask.c index 95cfd79672..95822059ff 100644 --- a/app/core/gimpimage-qmask.c +++ b/app/core/gimpimage-qmask.c @@ -29,7 +29,8 @@ #include "apptypes.h" -#include "color_panel.h" +#include "widgets/gimpcolorpanel.h" + #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" diff --git a/app/core/gimpimage-quick-mask.c b/app/core/gimpimage-quick-mask.c index 95cfd79672..95822059ff 100644 --- a/app/core/gimpimage-quick-mask.c +++ b/app/core/gimpimage-quick-mask.c @@ -29,7 +29,8 @@ #include "apptypes.h" -#include "color_panel.h" +#include "widgets/gimpcolorpanel.h" + #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" diff --git a/app/devices.c b/app/devices.c index a4abfbef48..4089368eb9 100644 --- a/app/devices.c +++ b/app/devices.c @@ -31,6 +31,8 @@ #include "tools/gimptoolinfo.h" #include "tools/tool_manager.h" +#include "widgets/gimppreview.h" + #include "appenv.h" #include "context_manager.h" #include "devices.h" @@ -41,7 +43,6 @@ #include "gimpdnd.h" #include "gimpgradient.h" #include "gimppattern.h" -#include "gimppreview.h" #include "gimplist.h" #include "gimprc.h" #include "session.h" diff --git a/app/dialogs/info-window.c b/app/dialogs/info-window.c index d4c679805c..0590fb3ea2 100644 --- a/app/dialogs/info-window.c +++ b/app/dialogs/info-window.c @@ -28,13 +28,14 @@ #include "tools/gimpcolorpickertool.h" #include "tools/tool_manager.h" +#include "widgets/gimppreview.h" + #include "context_manager.h" #include "colormaps.h" #include "gdisplay.h" #include "gimpcontainer.h" #include "gimpcontext.h" #include "gimpimage.h" -#include "gimppreview.h" #include "info_dialog.h" #include "info_window.h" diff --git a/app/display/gimpdisplayshell-qmask.c b/app/display/gimpdisplayshell-qmask.c index 95cfd79672..95822059ff 100644 --- a/app/display/gimpdisplayshell-qmask.c +++ b/app/display/gimpdisplayshell-qmask.c @@ -29,7 +29,8 @@ #include "apptypes.h" -#include "color_panel.h" +#include "widgets/gimpcolorpanel.h" + #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" diff --git a/app/gimpbrushpreview.c b/app/gimpbrushpreview.c deleted file mode 100644 index b1188ece58..0000000000 --- a/app/gimpbrushpreview.c +++ /dev/null @@ -1,363 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * GimpBrushPreview Widget - * Copyright (C) 2001 Michael Natterer - * - * 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 - -#include "apptypes.h" - -#include "gimpbrush.h" -#include "gimpbrushpipe.h" -#include "gimpbrushpreview.h" -#include "gimpdnd.h" -#include "temp_buf.h" - - -static void gimp_brush_preview_class_init (GimpBrushPreviewClass *klass); -static void gimp_brush_preview_init (GimpBrushPreview *preview); - -static void gimp_brush_preview_destroy (GtkObject *object); -static void gimp_brush_preview_render (GimpPreview *preview); -static GtkWidget * gimp_brush_preview_create_popup (GimpPreview *preview); -static gboolean gimp_brush_preview_needs_popup (GimpPreview *preview); - -static gboolean gimp_brush_preview_render_timeout_func (GimpBrushPreview *preview); - - -static GimpPreviewClass *parent_class = NULL; - - -GtkType -gimp_brush_preview_get_type (void) -{ - static GtkType preview_type = 0; - - if (! preview_type) - { - GtkTypeInfo preview_info = - { - "GimpBrushPreview", - sizeof (GimpBrushPreview), - sizeof (GimpBrushPreviewClass), - (GtkClassInitFunc) gimp_brush_preview_class_init, - (GtkObjectInitFunc) gimp_brush_preview_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL - }; - - preview_type = gtk_type_unique (GIMP_TYPE_PREVIEW, &preview_info); - } - - return preview_type; -} - -static void -gimp_brush_preview_class_init (GimpBrushPreviewClass *klass) -{ - GtkObjectClass *object_class; - GimpPreviewClass *preview_class; - - object_class = (GtkObjectClass *) klass; - preview_class = (GimpPreviewClass *) klass; - - parent_class = gtk_type_class (GIMP_TYPE_PREVIEW); - - object_class->destroy = gimp_brush_preview_destroy; - - preview_class->render = gimp_brush_preview_render; - preview_class->create_popup = gimp_brush_preview_create_popup; - preview_class->needs_popup = gimp_brush_preview_needs_popup; -} - -static void -gimp_brush_preview_init (GimpBrushPreview *brush_preview) -{ - brush_preview->pipe_timeout_id = 0; - brush_preview->pipe_animation_index = 0; -} - -static void -gimp_brush_preview_destroy (GtkObject *object) -{ - GimpBrushPreview *brush_preview; - - brush_preview = GIMP_BRUSH_PREVIEW (object); - - if (brush_preview->pipe_timeout_id) - { - g_source_remove (brush_preview->pipe_timeout_id); - - brush_preview->pipe_timeout_id = 0; - brush_preview->pipe_animation_index = 0; - } - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -#define indicator_width 7 -#define indicator_height 7 - -#define WHT { 255, 255, 255 } -#define BLK { 0, 0, 0 } -#define RED { 255, 127, 127 } - -static void -gimp_brush_preview_render (GimpPreview *preview) -{ - GimpBrushPreview *brush_preview; - GimpBrush *brush; - TempBuf *temp_buf; - gint width; - gint height; - gint brush_width; - gint brush_height; - guchar *buf; - guchar *b; - gint x, y; - gint offset_x; - gint offset_y; - - brush_preview = GIMP_BRUSH_PREVIEW (preview); - - if (brush_preview->pipe_timeout_id) - { - g_source_remove (brush_preview->pipe_timeout_id); - - brush_preview->pipe_timeout_id = 0; - } - - brush = GIMP_BRUSH (preview->viewable); - brush_width = brush->mask->width; - brush_height = brush->mask->height; - - width = preview->width; - height = preview->height; - - temp_buf = gimp_viewable_get_new_preview (preview->viewable, - width, - height); - - if (preview->is_popup) - { - gimp_preview_render_and_flush (preview, - temp_buf, - -1); - - temp_buf_free (temp_buf); - - if (GIMP_IS_BRUSH_PIPE (brush)) - { - if (width != brush_width || - height != brush_height) - { - g_warning ("%s(): non-fullsize pipe popups are not supported yet.", - G_GNUC_FUNCTION); - return; - } - - brush_preview->pipe_animation_index = 0; - brush_preview->pipe_timeout_id = - g_timeout_add (300, - (GSourceFunc) gimp_brush_preview_render_timeout_func, - brush_preview); - } - - return; - } - - buf = temp_buf_data (temp_buf); - - if (width < brush_width || height < brush_height) - { - static const guchar scale_indicator_bits[7][7][3] = - { - { WHT, WHT, WHT, WHT, WHT, WHT, WHT }, - { WHT, WHT, WHT, BLK, WHT, WHT, WHT }, - { WHT, WHT, WHT, BLK, WHT, WHT, WHT }, - { WHT, BLK, BLK, BLK, BLK, BLK, WHT }, - { WHT, WHT, WHT, BLK, WHT, WHT, WHT }, - { WHT, WHT, WHT, BLK, WHT, WHT, WHT }, - { WHT, WHT, WHT, WHT, WHT, WHT, WHT } - }; - - static const guchar scale_pipe_indicator_bits[7][7][3] = - { - { WHT, WHT, WHT, WHT, WHT, WHT, WHT }, - { WHT, WHT, WHT, BLK, WHT, WHT, RED }, - { WHT, WHT, WHT, BLK, WHT, RED, RED }, - { WHT, BLK, BLK, BLK, BLK, BLK, RED }, - { WHT, WHT, WHT, BLK, RED, RED, RED }, - { WHT, WHT, RED, BLK, RED, RED, RED }, - { WHT, RED, RED, RED, RED, RED, RED } - }; - - offset_x = width - indicator_width; - offset_y = height - indicator_height; - - b = buf + (offset_y * width + offset_x) * temp_buf->bytes; - - for (y = 0; y < indicator_height; y++) - { - for (x = 0; x < indicator_height; x++) - { - if (GIMP_IS_BRUSH_PIPE (brush)) - { - *b++ = scale_pipe_indicator_bits[y][x][0]; - *b++ = scale_pipe_indicator_bits[y][x][1]; - *b++ = scale_pipe_indicator_bits[y][x][2]; - } - else - { - *b++ = scale_indicator_bits[y][x][0]; - *b++ = scale_indicator_bits[y][x][1]; - *b++ = scale_indicator_bits[y][x][2]; - } - } - - b += (width - indicator_width) * temp_buf->bytes; - } - } - else if (GIMP_IS_BRUSH_PIPE (brush)) - { - static const guchar pipe_indicator_bits[7][7][3] = - { - { WHT, WHT, WHT, WHT, WHT, WHT, WHT }, - { WHT, WHT, WHT, WHT, WHT, WHT, RED }, - { WHT, WHT, WHT, WHT, WHT, RED, RED }, - { WHT, WHT, WHT, WHT, RED, RED, RED }, - { WHT, WHT, WHT, RED, RED, RED, RED }, - { WHT, WHT, RED, RED, RED, RED, RED }, - { WHT, RED, RED, RED, RED, RED, RED } - }; - - offset_x = width - indicator_width; - offset_y = height - indicator_height; - - b = buf + (offset_y * width + offset_x) * temp_buf->bytes; - - for (y = 0; y < indicator_height; y++) - { - for (x = 0; x < indicator_height; x++) - { - *b++ = pipe_indicator_bits[y][x][0]; - *b++ = pipe_indicator_bits[y][x][1]; - *b++ = pipe_indicator_bits[y][x][2]; - } - - b += (width - indicator_width) * temp_buf->bytes; - } - } - -#undef indicator_width -#undef indicator_height - -#undef WHT -#undef BLK -#undef RED - - gimp_preview_render_and_flush (preview, - temp_buf, - -1); - - temp_buf_free (temp_buf); -} - -static GtkWidget * -gimp_brush_preview_create_popup (GimpPreview *preview) -{ - gint popup_width; - gint popup_height; - - popup_width = GIMP_BRUSH (preview->viewable)->mask->width; - popup_height = GIMP_BRUSH (preview->viewable)->mask->height; - - return gimp_preview_new_full (preview->viewable, - popup_width, - popup_height, - 0, - TRUE, FALSE, FALSE); -} - -static gboolean -gimp_brush_preview_needs_popup (GimpPreview *preview) -{ - GimpBrush *brush; - gint brush_width; - gint brush_height; - - brush = GIMP_BRUSH (preview->viewable); - brush_width = brush->mask->width; - brush_height = brush->mask->height; - - if (GIMP_IS_BRUSH_PIPE (brush) || - brush_width > preview->width || - brush_height > preview->height) - return TRUE; - - return FALSE; -} - -static gboolean -gimp_brush_preview_render_timeout_func (GimpBrushPreview *brush_preview) -{ - GimpPreview *preview; - GimpBrushPipe *brush_pipe; - GimpBrush *brush; - TempBuf *temp_buf; - gint brush_width; - gint brush_height; - - preview = GIMP_PREVIEW (brush_preview); - - if (! preview->viewable) - { - brush_preview->pipe_timeout_id = 0; - brush_preview->pipe_animation_index = 0; - - return FALSE; - } - - brush_pipe = GIMP_BRUSH_PIPE (preview->viewable); - brush_width = brush->mask->width; - brush_height = brush->mask->height; - - brush_preview->pipe_animation_index++; - - if (brush_preview->pipe_animation_index >= brush_pipe->nbrushes) - brush_preview->pipe_animation_index = 0; - - brush = GIMP_BRUSH (brush_pipe->brushes[brush_preview->pipe_animation_index]); - - temp_buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (brush), - preview->width, - preview->height); - - gimp_preview_render_and_flush (preview, - temp_buf, - -1); - - temp_buf_free (temp_buf); - - return TRUE; -} diff --git a/app/gimpbrushpreview.h b/app/gimpbrushpreview.h deleted file mode 100644 index dce102a208..0000000000 --- a/app/gimpbrushpreview.h +++ /dev/null @@ -1,64 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * GimpBrushPreview Widget - * Copyright (C) 2001 Michael Natterer - * - * 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_BRUSH_PREVIEW_H__ -#define __GIMP_BRUSH_PREVIEW_H__ - - -#include "gimppreview.h" - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -#define GIMP_TYPE_BRUSH_PREVIEW (gimp_brush_preview_get_type ()) -#define GIMP_BRUSH_PREVIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_BRUSH_PREVIEW, GimpBrushPreview)) -#define GIMP_BRUSH_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_BRUSH_PREVIEW, GimpBrushPreviewClass)) -#define GIMP_IS_BRUSH_PREVIEW(obj) (GTK_CHECK_TYPE (obj, GIMP_TYPE_BRUSH_PREVIEW)) -#define GIMP_IS_BRUSH_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_BRUSH_PREVIEW)) - - -typedef struct _GimpBrushPreviewClass GimpBrushPreviewClass; - -struct _GimpBrushPreview -{ - GimpPreview parent_instance; - - guint pipe_timeout_id; - gint pipe_animation_index; -}; - -struct _GimpBrushPreviewClass -{ - GimpPreviewClass parent_class; -}; - - -GtkType gimp_brush_preview_get_type (void); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __GIMP_BRUSH_PREVIEW_H__ */ diff --git a/app/gimpconstrainedhwrapbox.c b/app/gimpconstrainedhwrapbox.c deleted file mode 100644 index 2e975f4392..0000000000 --- a/app/gimpconstrainedhwrapbox.c +++ /dev/null @@ -1,214 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * GtkHWrapBox: Horizontal wrapping box widget - * Copyright (C) 1999 Tim Janik - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include - -#include "gimpconstrainedhwrapbox.h" - - -static void gimp_constrained_hwrap_box_class_init (GimpConstrainedHWrapBoxClass *klass); -static void gimp_constrained_hwrap_box_init (GimpConstrainedHWrapBox *hwbox); -static void gimp_constrained_hwrap_box_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void gimp_constrained_hwrap_box_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); - - -static GtkHWrapBoxClass *parent_class = NULL; - - -GtkType -gimp_constrained_hwrap_box_get_type (void) -{ - static GtkType constrained_hwrap_box_type = 0; - - if (! constrained_hwrap_box_type) - { - static const GtkTypeInfo constrained_hwrap_box_info = - { - "GimpConstrainedHWrapBox", - sizeof (GimpConstrainedHWrapBox), - sizeof (GimpConstrainedHWrapBoxClass), - (GtkClassInitFunc) gimp_constrained_hwrap_box_class_init, - (GtkObjectInitFunc) gimp_constrained_hwrap_box_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - constrained_hwrap_box_type = gtk_type_unique (GTK_TYPE_HWRAP_BOX, - &constrained_hwrap_box_info); - } - - return constrained_hwrap_box_type; -} - -static void -gimp_constrained_hwrap_box_class_init (GimpConstrainedHWrapBoxClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = GTK_OBJECT_CLASS (class); - widget_class = GTK_WIDGET_CLASS (class); - - parent_class = gtk_type_class (GTK_TYPE_HWRAP_BOX); - - widget_class->size_request = gimp_constrained_hwrap_box_size_request; - widget_class->size_allocate = gimp_constrained_hwrap_box_size_allocate; -} - -static void -gimp_constrained_hwrap_box_init (GimpConstrainedHWrapBox *hwbox) -{ - hwbox->rows = 1; - hwbox->columns = 1; -} - -GtkWidget* -gimp_constrained_hwrap_box_new (gboolean homogeneous) -{ - GimpConstrainedHWrapBox *hwbox; - - hwbox = GIMP_CONSTRAINED_HWRAP_BOX (gtk_widget_new (GIMP_TYPE_CONSTRAINED_HWRAP_BOX, NULL)); - - GTK_WRAP_BOX (hwbox)->homogeneous = homogeneous ? TRUE : FALSE; - - return GTK_WIDGET (hwbox); -} - -static void -gimp_constrained_hwrap_box_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GtkWrapBox *wbox = GTK_WRAP_BOX (widget); - - g_return_if_fail (requisition != NULL); - - if (widget->parent && - GTK_IS_VIEWPORT (widget->parent) && - widget->parent->parent && - GTK_IS_SCROLLED_WINDOW (widget->parent->parent) && - wbox->children && - wbox->children->widget) - { - GtkWidget *scrolled_win; - gint child_width; - gint child_height; - gint viewport_width; - gint columns; - gint rows; - - scrolled_win = widget->parent->parent; - - child_width = wbox->children->widget->requisition.width; - child_height = wbox->children->widget->requisition.height; - - viewport_width = - (scrolled_win->allocation.width - - GTK_SCROLLED_WINDOW (scrolled_win)->vscrollbar->allocation.width - - GTK_SCROLLED_WINDOW_CLASS (GTK_OBJECT (scrolled_win)->klass)->scrollbar_spacing - - scrolled_win->style->klass->xthickness * 2); - - columns = - (viewport_width + wbox->hspacing) / (child_width + wbox->hspacing); - - columns = MAX (1, columns); - - requisition->width = (child_width + wbox->hspacing) * columns; - - rows = wbox->n_children / columns; - - if (rows * columns < wbox->n_children) - rows++; - - requisition->height = (child_height + wbox->vspacing) * rows; - - GIMP_CONSTRAINED_HWRAP_BOX (wbox)->columns = columns; - GIMP_CONSTRAINED_HWRAP_BOX (wbox)->rows = rows; - } - else if (GTK_WIDGET_CLASS (parent_class)->size_request) - { - GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition); - - GIMP_CONSTRAINED_HWRAP_BOX (wbox)->columns = 1; - GIMP_CONSTRAINED_HWRAP_BOX (wbox)->rows = 1; - } -} - -static void -gimp_constrained_hwrap_box_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkWrapBox *wbox = GTK_WRAP_BOX (widget); - - g_return_if_fail (allocation != NULL); - - if (widget->parent && - GTK_IS_VIEWPORT (widget->parent) && - widget->parent->parent && - GTK_IS_SCROLLED_WINDOW (widget->parent->parent) && - wbox->children && - wbox->children->widget) - { - GtkWidget *scrolled_win; - gint child_width; - gint child_height; - gint viewport_width; - gint columns; - gint rows; - - scrolled_win = widget->parent->parent; - - child_width = wbox->children->widget->requisition.width; - child_height = wbox->children->widget->requisition.height; - - viewport_width = - (scrolled_win->allocation.width - - GTK_SCROLLED_WINDOW (scrolled_win)->vscrollbar->allocation.width - - GTK_SCROLLED_WINDOW_CLASS (GTK_OBJECT (scrolled_win)->klass)->scrollbar_spacing - - scrolled_win->style->klass->xthickness * 2); - - allocation->width = viewport_width; - - columns = - (viewport_width + wbox->hspacing) / (child_width + wbox->hspacing); - - columns = MAX (1, columns); - - rows = wbox->n_children / columns; - - if (rows * columns < wbox->n_children) - rows++; - - GIMP_CONSTRAINED_HWRAP_BOX (wbox)->columns = columns; - GIMP_CONSTRAINED_HWRAP_BOX (wbox)->rows = rows; - } - else - { - GIMP_CONSTRAINED_HWRAP_BOX (wbox)->columns = 1; - GIMP_CONSTRAINED_HWRAP_BOX (wbox)->rows = 1; - } - - if (GTK_WIDGET_CLASS (parent_class)->size_allocate) - GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation); -} diff --git a/app/gimpconstrainedhwrapbox.h b/app/gimpconstrainedhwrapbox.h deleted file mode 100644 index 825925a044..0000000000 --- a/app/gimpconstrainedhwrapbox.h +++ /dev/null @@ -1,68 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * GtkHWrapBox: Horizontal wrapping box widget - * Copyright (C) 1999 Tim Janik - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __GIMP_CONSTRAINED_HWRAP_BOX_H__ -#define __GIMP_CONSTRAINED_HWRAP_BOX_H__ - - -#include "gtkhwrapbox.h" - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -#define GIMP_TYPE_CONSTRAINED_HWRAP_BOX (gimp_constrained_hwrap_box_get_type ()) -#define GIMP_CONSTRAINED_HWRAP_BOX(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_CONSTRAINED_HWRAP_BOX, GimpConstrainedHWrapBox)) -#define GIMP_CONSTRAINED_HWRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CONSTRAINED_HWRAP_BOX, GimpConstrainedHWrapBoxClass)) -#define GIMP_IS_CONSTRAINED_HWRAP_BOX(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_CONSTRAINED_HWRAP_BOX)) -#define GIMP_IS_CONSTRAINED_HWRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONSTRAINED_HWRAP_BOX)) -#define GIMP_CONSTRAINED_HWRAP_BOX_GET_CLASS(obj) (GIMP_CONSTRAINED_HWRAP_BOX_CLASS (((GtkObject *) (obj))->klass)) - - -typedef struct _GimpConstrainedHWrapBox GimpConstrainedHWrapBox; -typedef struct _GimpConstrainedHWrapBoxClass GimpConstrainedHWrapBoxClass; - -struct _GimpConstrainedHWrapBox -{ - GtkHWrapBox parent_instance; - - gint rows; - gint columns; -}; - -struct _GimpConstrainedHWrapBoxClass -{ - GtkHWrapBoxClass parent_class; -}; - - -GtkType gimp_constrained_hwrap_box_get_type (void); -GtkWidget * gimp_constrained_hwrap_box_new (gboolean homogeneous); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __GTK_CONSTRAINED_HWRAP_BOX_H__ */ diff --git a/app/gimpcontainergridview.c b/app/gimpcontainergridview.c deleted file mode 100644 index b31b013f63..0000000000 --- a/app/gimpcontainergridview.c +++ /dev/null @@ -1,408 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * 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 - -#include - -#include "libgimpcolor/gimpcolor.h" - -#include "apptypes.h" - -#include "appenv.h" -#include "colormaps.h" -#include "gimpcontainer.h" -#include "gimpcontainergridview.h" -#include "gimpcontext.h" -#include "gimppreview.h" -#include "gimpconstrainedhwrapbox.h" - - -static void gimp_container_grid_view_class_init (GimpContainerGridViewClass *klass); -static void gimp_container_grid_view_init (GimpContainerGridView *panel); -static void gimp_container_grid_view_destroy (GtkObject *object); - -static gpointer gimp_container_grid_view_insert_item (GimpContainerView *view, - GimpViewable *viewable, - gint index); -static void gimp_container_grid_view_remove_item (GimpContainerView *view, - GimpViewable *viewable, - gpointer insert_data); -static void gimp_container_grid_view_reorder_item (GimpContainerView *view, - GimpViewable *viewable, - gint new_index, - gpointer insert_data); -static void gimp_container_grid_view_select_item (GimpContainerView *view, - GimpViewable *viewable, - gpointer insert_data); -static void gimp_container_grid_view_clear_items (GimpContainerView *view); -static void gimp_container_grid_view_set_preview_size (GimpContainerView *view); -static void gimp_container_grid_view_item_selected (GtkWidget *widget, - gpointer data); -static void gimp_container_grid_view_item_activated (GtkWidget *widget, - gpointer data); -static void gimp_container_grid_view_highlight_item (GimpContainerView *view, - GimpViewable *viewable, - gpointer insert_data); - - -static GimpContainerViewClass *parent_class = NULL; - -static GimpRGB white_color; -static GimpRGB black_color; - - -GtkType -gimp_container_grid_view_get_type (void) -{ - static guint grid_view_type = 0; - - if (! grid_view_type) - { - GtkTypeInfo grid_view_info = - { - "GimpContainerGridView", - sizeof (GimpContainerGridView), - sizeof (GimpContainerGridViewClass), - (GtkClassInitFunc) gimp_container_grid_view_class_init, - (GtkObjectInitFunc) gimp_container_grid_view_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL - }; - - grid_view_type = gtk_type_unique (GIMP_TYPE_CONTAINER_VIEW, - &grid_view_info); - } - - return grid_view_type; -} - -static void -gimp_container_grid_view_class_init (GimpContainerGridViewClass *klass) -{ - GtkObjectClass *object_class; - GimpContainerViewClass *container_view_class; - - object_class = (GtkObjectClass *) klass; - container_view_class = (GimpContainerViewClass *) klass; - - parent_class = gtk_type_class (GIMP_TYPE_CONTAINER_VIEW); - - object_class->destroy = gimp_container_grid_view_destroy; - - container_view_class->insert_item = gimp_container_grid_view_insert_item; - container_view_class->remove_item = gimp_container_grid_view_remove_item; - container_view_class->reorder_item = gimp_container_grid_view_reorder_item; - container_view_class->select_item = gimp_container_grid_view_select_item; - container_view_class->clear_items = gimp_container_grid_view_clear_items; - container_view_class->set_preview_size = gimp_container_grid_view_set_preview_size; - - klass->white_style = gtk_style_copy (gtk_widget_get_default_style ()); - klass->white_style->bg[GTK_STATE_NORMAL].red = 0xffff; - klass->white_style->bg[GTK_STATE_NORMAL].green = 0xffff; - klass->white_style->bg[GTK_STATE_NORMAL].blue = 0xffff; - klass->white_style->bg[GTK_STATE_NORMAL].pixel = g_white_pixel; - - gimp_rgba_set (&white_color, 1.0, 1.0, 1.0, 1.0); - gimp_rgba_set (&black_color, 0.0, 0.0, 0.0, 1.0); -} - -static void -gimp_container_grid_view_init (GimpContainerGridView *grid_view) -{ - grid_view->scrolled_win = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (grid_view->scrolled_win), - GTK_POLICY_NEVER, - GTK_POLICY_ALWAYS); - gtk_box_pack_start (GTK_BOX (grid_view), grid_view->scrolled_win, - TRUE, TRUE, 0); - - grid_view->wrap_box = gimp_constrained_hwrap_box_new (FALSE); - - gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (grid_view->wrap_box), - 1.0 / 256.0); - - gtk_scrolled_window_add_with_viewport - (GTK_SCROLLED_WINDOW (grid_view->scrolled_win), - grid_view->wrap_box); - - gtk_widget_set_style - (grid_view->wrap_box->parent, - GIMP_CONTAINER_GRID_VIEW_CLASS (GTK_OBJECT (grid_view)->klass)->white_style); - - gtk_container_set_focus_vadjustment - (GTK_CONTAINER (grid_view->wrap_box->parent), - gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW - (grid_view->scrolled_win))); - - GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW - (grid_view->scrolled_win)->vscrollbar, - GTK_CAN_FOCUS); - - GTK_WIDGET_SET_FLAGS (grid_view->wrap_box->parent, GTK_CAN_FOCUS); - - gtk_widget_show (grid_view->wrap_box); - gtk_widget_show (grid_view->scrolled_win); -} - -static void -gimp_container_grid_view_destroy (GtkObject *object) -{ - GimpContainerGridView *grid_view; - - grid_view = GIMP_CONTAINER_GRID_VIEW (object); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gimp_container_grid_view_new (GimpContainer *container, - GimpContext *context, - gint preview_size, - gint min_items_x, - gint min_items_y) -{ - GimpContainerGridView *grid_view; - GimpContainerView *view; - gint window_border; - - g_return_val_if_fail (! container || GIMP_IS_CONTAINER (container), NULL); - g_return_val_if_fail (! context || GIMP_IS_CONTEXT (context), NULL); - g_return_val_if_fail (preview_size > 0 && preview_size <= 64, NULL); - g_return_val_if_fail (min_items_x > 0 && min_items_x <= 64, NULL); - g_return_val_if_fail (min_items_y > 0 && min_items_y <= 64, NULL); - - grid_view = gtk_type_new (GIMP_TYPE_CONTAINER_GRID_VIEW); - - view = GIMP_CONTAINER_VIEW (grid_view); - - view->preview_size = preview_size; - - window_border = - GTK_SCROLLED_WINDOW (grid_view->scrolled_win)->vscrollbar->requisition.width + - GTK_SCROLLED_WINDOW_CLASS (GTK_OBJECT (grid_view->scrolled_win)->klass)->scrollbar_spacing + - grid_view->scrolled_win->style->klass->xthickness * 4; - - gtk_widget_set_usize (grid_view->scrolled_win, - (preview_size + 2) * min_items_x + window_border, - (preview_size + 2) * min_items_y + window_border); - - if (container) - gimp_container_view_set_container (view, container); - - gimp_container_view_set_context (view, context); - - return GTK_WIDGET (grid_view); -} - -static gpointer -gimp_container_grid_view_insert_item (GimpContainerView *view, - GimpViewable *viewable, - gint index) -{ - GimpContainerGridView *grid_view; - GtkWidget *preview; - - grid_view = GIMP_CONTAINER_GRID_VIEW (view); - - preview = gimp_preview_new_full (viewable, - view->preview_size, - view->preview_size, - 1, - FALSE, TRUE, TRUE); - - GIMP_PREVIEW (preview)->border_color = white_color; - - gtk_wrap_box_pack (GTK_WRAP_BOX (grid_view->wrap_box), preview, - FALSE, FALSE, FALSE, FALSE); - - if (index != -1) - gtk_wrap_box_reorder_child (GTK_WRAP_BOX (grid_view->wrap_box), - preview, index); - - gtk_widget_show (preview); - - gtk_signal_connect (GTK_OBJECT (preview), "clicked", - GTK_SIGNAL_FUNC (gimp_container_grid_view_item_selected), - view); - - gtk_signal_connect (GTK_OBJECT (preview), "double_clicked", - GTK_SIGNAL_FUNC (gimp_container_grid_view_item_activated), - view); - - return (gpointer) preview; -} - -static void -gimp_container_grid_view_remove_item (GimpContainerView *view, - GimpViewable *viewable, - gpointer insert_data) -{ - GimpContainerGridView *grid_view; - GtkWidget *preview; - - grid_view = GIMP_CONTAINER_GRID_VIEW (view); - preview = GTK_WIDGET (insert_data); - - if (preview) - { - if (gtk_object_get_data (GTK_OBJECT (view), - "last_selected_item") == preview) - { - gtk_object_set_data (GTK_OBJECT (view), "last_selected_item", NULL); - } - - gtk_container_remove (GTK_CONTAINER (grid_view->wrap_box), preview); - } -} - -static void -gimp_container_grid_view_reorder_item (GimpContainerView *view, - GimpViewable *viewable, - gint new_index, - gpointer insert_data) -{ - GimpContainerGridView *grid_view; - GtkWidget *preview; - - grid_view = GIMP_CONTAINER_GRID_VIEW (view); - preview = GTK_WIDGET (insert_data); - - gtk_wrap_box_reorder_child (GTK_WRAP_BOX (grid_view->wrap_box), - preview, new_index); -} - -static void -gimp_container_grid_view_select_item (GimpContainerView *view, - GimpViewable *viewable, - gpointer insert_data) -{ - gimp_container_grid_view_highlight_item (view, viewable, insert_data); -} - -static void -gimp_container_grid_view_clear_items (GimpContainerView *view) -{ - GimpContainerGridView *grid_view; - - grid_view = GIMP_CONTAINER_GRID_VIEW (view); - - gtk_object_set_data (GTK_OBJECT (view), "last_selected_item", NULL); - - while (GTK_WRAP_BOX (grid_view->wrap_box)->children) - gtk_container_remove (GTK_CONTAINER (grid_view->wrap_box), - GTK_WRAP_BOX (grid_view->wrap_box)->children->widget); - - if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->clear_items) - GIMP_CONTAINER_VIEW_CLASS (parent_class)->clear_items (view); -} - -static void -gimp_container_grid_view_set_preview_size (GimpContainerView *view) -{ - GimpContainerGridView *grid_view; - GtkWrapBoxChild *child; - - grid_view = GIMP_CONTAINER_GRID_VIEW (view); - - for (child = GTK_WRAP_BOX (grid_view->wrap_box)->children; - child; - child = child->next) - { - GimpPreview *preview; - - preview = GIMP_PREVIEW (child->widget); - - gimp_preview_set_size (preview, view->preview_size, preview->border_width); - } - - gtk_widget_queue_resize (grid_view->wrap_box); -} - -static void -gimp_container_grid_view_item_selected (GtkWidget *widget, - gpointer data) -{ - gimp_container_view_item_selected (GIMP_CONTAINER_VIEW (data), - GIMP_PREVIEW (widget)->viewable); -} - -static void -gimp_container_grid_view_item_activated (GtkWidget *widget, - gpointer data) -{ - gimp_container_view_item_activated (GIMP_CONTAINER_VIEW (data), - GIMP_PREVIEW (widget)->viewable); -} - -static void -gimp_container_grid_view_highlight_item (GimpContainerView *view, - GimpViewable *viewable, - gpointer insert_data) -{ - GimpContainerGridView *grid_view; - GimpPreview *preview; - - grid_view = GIMP_CONTAINER_GRID_VIEW (view); - - preview = gtk_object_get_data (GTK_OBJECT (view), "last_selected_item"); - - if (preview) - gimp_preview_set_border_color (preview, &white_color); - - if (insert_data) - preview = GIMP_PREVIEW (insert_data); - else - preview = NULL; - - if (preview) - { - GtkAdjustment *adj; - gint item_height; - gint index; - gint row; - - adj = gtk_scrolled_window_get_vadjustment - (GTK_SCROLLED_WINDOW (grid_view->scrolled_win)); - - item_height = GTK_WIDGET (preview)->allocation.height; - - index = gimp_container_get_child_index (view->container, - GIMP_OBJECT (viewable)); - - row = index / GIMP_CONSTRAINED_HWRAP_BOX (grid_view->wrap_box)->columns; - - if (row * item_height < adj->value) - { - gtk_adjustment_set_value (adj, row * item_height); - } - else if ((row + 1) * item_height > adj->value + adj->page_size) - { - gtk_adjustment_set_value (adj, - (row + 1) * item_height - adj->page_size); - } - - gimp_preview_set_border_color (preview, &black_color); - } - - gtk_object_set_data (GTK_OBJECT (view), "last_selected_item", preview); -} diff --git a/app/gimpcontainergridview.h b/app/gimpcontainergridview.h deleted file mode 100644 index a5c4ff83eb..0000000000 --- a/app/gimpcontainergridview.h +++ /dev/null @@ -1,59 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * 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_CONTAINER_GRID_VIEW_H__ -#define __GIMP_CONTAINER_GRID_VIEW_H__ - - -#include "gimpcontainerview.h" - - -#define GIMP_TYPE_CONTAINER_GRID_VIEW (gimp_container_grid_view_get_type ()) -#define GIMP_CONTAINER_GRID_VIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_CONTAINER_GRID_VIEW, GimpContainerGridView)) -#define GIMP_CONTAINER_GRID_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CONTAINER_GRID_VIEW, GimpContainerGridViewClass)) -#define GIMP_IS_CONTAINER_GRID_VIEW(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_CONTAINER_GRID_VIEW)) -#define GIMP_IS_CONTAINER_GRID_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONTAINER_GRID_VIEW)) - - -typedef struct _GimpContainerGridViewClass GimpContainerGridViewClass; - -struct _GimpContainerGridView -{ - GimpContainerView parent_instance; - - GtkWidget *scrolled_win; - GtkWidget *wrap_box; -}; - -struct _GimpContainerGridViewClass -{ - GimpContainerViewClass parent_class; - - GtkStyle *white_style; -}; - - -GtkType gimp_container_grid_view_get_type (void); -GtkWidget * gimp_container_grid_view_new (GimpContainer *container, - GimpContext *context, - gint preview_size, - gint min_items_x, - gint min_items_y); - - -#endif /* __GIMP_CONTAINER_GRID_VIEW_H__ */ diff --git a/app/gimpcontainerlistview.c b/app/gimpcontainerlistview.c deleted file mode 100644 index 64b0e3d1f2..0000000000 --- a/app/gimpcontainerlistview.c +++ /dev/null @@ -1,424 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * 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 - -#include - -#include "apptypes.h" - -#include "appenv.h" -#include "gimpcontainer.h" -#include "gimpcontainerlistview.h" -#include "gimpcontext.h" -#include "gimpdnd.h" -#include "gimplist.h" -#include "gimplistitem.h" -#include "gimppreview.h" - - -static void gimp_container_list_view_class_init (GimpContainerListViewClass *klass); -static void gimp_container_list_view_init (GimpContainerListView *panel); -static void gimp_container_list_view_destroy (GtkObject *object); - -static gpointer gimp_container_list_view_insert_item (GimpContainerView *view, - GimpViewable *viewable, - gint index); -static void gimp_container_list_view_remove_item (GimpContainerView *view, - GimpViewable *viewable, - gpointer insert_data); -static void gimp_container_list_view_reorder_item (GimpContainerView *view, - GimpViewable *viewable, - gint new_index, - gpointer insert_data); -static void gimp_container_list_view_select_item (GimpContainerView *view, - GimpViewable *viewable, - gpointer insert_data); -static void gimp_container_list_view_clear_items (GimpContainerView *view); -static void gimp_container_list_view_set_preview_size (GimpContainerView *view); - -static void gimp_container_list_view_item_selected (GtkWidget *widget, - GtkWidget *child, - gpointer data); -static gint gimp_container_list_view_item_activated (GtkWidget *widget, - GdkEventButton *bevent, - gpointer data); - - -static GimpContainerViewClass *parent_class = NULL; - - -GtkType -gimp_container_list_view_get_type (void) -{ - static guint list_view_type = 0; - - if (! list_view_type) - { - GtkTypeInfo list_view_info = - { - "GimpContainerListView", - sizeof (GimpContainerListView), - sizeof (GimpContainerListViewClass), - (GtkClassInitFunc) gimp_container_list_view_class_init, - (GtkObjectInitFunc) gimp_container_list_view_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL - }; - - list_view_type = gtk_type_unique (GIMP_TYPE_CONTAINER_VIEW, - &list_view_info); - } - - return list_view_type; -} - -static void -gimp_container_list_view_class_init (GimpContainerListViewClass *klass) -{ - GtkObjectClass *object_class; - GimpContainerViewClass *container_view_class; - - object_class = (GtkObjectClass *) klass; - container_view_class = (GimpContainerViewClass *) klass; - - parent_class = gtk_type_class (GIMP_TYPE_CONTAINER_VIEW); - - object_class->destroy = gimp_container_list_view_destroy; - - container_view_class->insert_item = gimp_container_list_view_insert_item; - container_view_class->remove_item = gimp_container_list_view_remove_item; - container_view_class->reorder_item = gimp_container_list_view_reorder_item; - container_view_class->select_item = gimp_container_list_view_select_item; - container_view_class->clear_items = gimp_container_list_view_clear_items; - container_view_class->set_preview_size = gimp_container_list_view_set_preview_size; -} - -static void -gimp_container_list_view_init (GimpContainerListView *list_view) -{ - list_view->scrolled_win = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (list_view->scrolled_win), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_ALWAYS); - gtk_box_pack_start (GTK_BOX (list_view), list_view->scrolled_win, - TRUE, TRUE, 0); - - list_view->gtk_list = gtk_list_new (); - gtk_scrolled_window_add_with_viewport - (GTK_SCROLLED_WINDOW (list_view->scrolled_win), - list_view->gtk_list); - - gtk_list_set_selection_mode (GTK_LIST (list_view->gtk_list), - GTK_SELECTION_SINGLE); - - gtk_container_set_focus_vadjustment - (GTK_CONTAINER (list_view->gtk_list), - gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW - (list_view->scrolled_win))); - - GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW - (list_view->scrolled_win)->vscrollbar, - GTK_CAN_FOCUS); - - gtk_signal_connect_while_alive - (GTK_OBJECT (list_view->gtk_list), "select_child", - GTK_SIGNAL_FUNC (gimp_container_list_view_item_selected), - list_view, - GTK_OBJECT (list_view)); - - gtk_widget_show (list_view->gtk_list); - gtk_widget_show (list_view->scrolled_win); -} - -static void -gimp_container_list_view_destroy (GtkObject *object) -{ - GimpContainerListView *list_view; - - list_view = GIMP_CONTAINER_LIST_VIEW (object); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gimp_container_list_view_new (GimpContainer *container, - GimpContext *context, - gint preview_size, - gint min_items_x, - gint min_items_y) -{ - GimpContainerListView *list_view; - GimpContainerView *view; - gint window_border; - - g_return_val_if_fail (! container || GIMP_IS_CONTAINER (container), NULL); - g_return_val_if_fail (! context || GIMP_IS_CONTEXT (context), NULL); - g_return_val_if_fail (preview_size > 0 && preview_size <= 64, NULL); - g_return_val_if_fail (min_items_x > 0 && min_items_x <= 64, NULL); - g_return_val_if_fail (min_items_y > 0 && min_items_y <= 64, NULL); - - list_view = gtk_type_new (GIMP_TYPE_CONTAINER_LIST_VIEW); - - view = GIMP_CONTAINER_VIEW (list_view); - - view->preview_size = preview_size; - - window_border = - GTK_SCROLLED_WINDOW (list_view->scrolled_win)->vscrollbar->requisition.width + - GTK_SCROLLED_WINDOW_CLASS (GTK_OBJECT (list_view->scrolled_win)->klass)->scrollbar_spacing + - list_view->scrolled_win->style->klass->xthickness * 4; - - gtk_widget_set_usize (list_view->gtk_list->parent, - (preview_size + 2) * min_items_x + window_border, - (preview_size + 6) * min_items_y + window_border); - - if (container) - gimp_container_view_set_container (view, container); - - gimp_container_view_set_context (view, context); - - return GTK_WIDGET (list_view); -} - - -/* GimpContainerView methods */ - -static gpointer -gimp_container_list_view_insert_item (GimpContainerView *view, - GimpViewable *viewable, - gint index) -{ - GimpContainerListView *list_view; - GtkWidget *list_item; - GList *list; - - list_view = GIMP_CONTAINER_LIST_VIEW (view); - - list_item = gimp_list_item_new (viewable, view->preview_size); - - gtk_signal_connect (GTK_OBJECT (list_item), "button_press_event", - GTK_SIGNAL_FUNC (gimp_container_list_view_item_activated), - list_view); - - gtk_widget_show (list_item); - - list = g_list_prepend (NULL, list_item); - - if (index == -1) - gtk_list_append_items (GTK_LIST (list_view->gtk_list), list); - else - gtk_list_insert_items (GTK_LIST (list_view->gtk_list), list, index); - - return (gpointer) list_item; -} - -static void -gimp_container_list_view_remove_item (GimpContainerView *view, - GimpViewable *viewable, - gpointer insert_data) -{ - GimpContainerListView *list_view; - GtkWidget *list_item; - - list_view = GIMP_CONTAINER_LIST_VIEW (view); - - if (insert_data) - list_item = GTK_WIDGET (insert_data); - else - list_item = NULL; - - if (list_item) - { - GList *list; - - list = g_list_prepend (NULL, list_item); - - gtk_list_remove_items (GTK_LIST (list_view->gtk_list), list); - } -} - -static void -gimp_container_list_view_reorder_item (GimpContainerView *view, - GimpViewable *viewable, - gint new_index, - gpointer insert_data) -{ - GimpContainerListView *list_view; - GtkWidget *list_item; - gboolean selected; - - list_view = GIMP_CONTAINER_LIST_VIEW (view); - - if (insert_data) - list_item = GTK_WIDGET (insert_data); - else - list_item = NULL; - - if (list_item) - { - GList *list; - - list = g_list_prepend (NULL, list_item); - - selected = GTK_WIDGET_STATE (list_item) == GTK_STATE_SELECTED; - - gtk_object_ref (GTK_OBJECT (list_item)); - - gtk_list_remove_items (GTK_LIST (list_view->gtk_list), list); - - if (new_index == -1 || new_index == view->container->num_children - 1) - gtk_list_append_items (GTK_LIST (list_view->gtk_list), list); - else - gtk_list_insert_items (GTK_LIST (list_view->gtk_list), list, new_index); - - if (selected) - gimp_container_view_select_item (view, viewable); - - gtk_object_unref (GTK_OBJECT (list_item)); - } -} - -static void -gimp_container_list_view_select_item (GimpContainerView *view, - GimpViewable *viewable, - gpointer insert_data) -{ - GimpContainerListView *list_view; - GtkWidget *list_item; - - list_view = GIMP_CONTAINER_LIST_VIEW (view); - - if (insert_data) - list_item = GTK_WIDGET (insert_data); - else - list_item = NULL; - - if (list_item) - { - GtkAdjustment *adj; - gint item_height; - gint index; - - adj = gtk_scrolled_window_get_vadjustment - (GTK_SCROLLED_WINDOW (list_view->scrolled_win)); - - item_height = list_item->requisition.height; - - index = gimp_container_get_child_index (view->container, - GIMP_OBJECT (viewable)); - - gtk_signal_handler_block_by_func (GTK_OBJECT (list_view->gtk_list), - gimp_container_list_view_item_selected, - list_view); - - gtk_list_select_child (GTK_LIST (list_view->gtk_list), list_item); - - gtk_signal_handler_unblock_by_func (GTK_OBJECT (list_view->gtk_list), - gimp_container_list_view_item_selected, - list_view); - - if (index * item_height < adj->value) - { - gtk_adjustment_set_value (adj, index * item_height); - } - else if ((index + 1) * item_height > adj->value + adj->page_size) - { - gtk_adjustment_set_value (adj, - (index + 1) * item_height - adj->page_size); - } - } - else - { - gtk_list_unselect_all (GTK_LIST (list_view->gtk_list)); - } -} - -static void -gimp_container_list_view_clear_items (GimpContainerView *view) -{ - GimpContainerListView *list_view; - - list_view = GIMP_CONTAINER_LIST_VIEW (view); - - gtk_list_clear_items (GTK_LIST (list_view->gtk_list), 0, -1); - - if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->clear_items) - GIMP_CONTAINER_VIEW_CLASS (parent_class)->clear_items (view); -} - -static void -gimp_container_list_view_set_preview_size (GimpContainerView *view) -{ - GimpContainerListView *list_view; - GList *list; - - list_view = GIMP_CONTAINER_LIST_VIEW (view); - - for (list = GTK_LIST (list_view->gtk_list)->children; - list; - list = g_list_next (list)) - { - GimpPreview *preview; - - preview = GIMP_PREVIEW (GIMP_LIST_ITEM (list->data)->preview); - - gimp_preview_set_size (preview, view->preview_size, preview->border_width); - } - - gtk_widget_queue_resize (list_view->gtk_list); -} - - -/* GtkClist callbacks */ - -static void -gimp_container_list_view_item_selected (GtkWidget *widget, - GtkWidget *child, - gpointer data) -{ - GimpViewable *viewable; - - viewable = GIMP_PREVIEW (GIMP_LIST_ITEM (child)->preview)->viewable; - - gimp_container_view_item_selected (GIMP_CONTAINER_VIEW (data), viewable); -} - - -/* GtkListItem callbacks */ - -static gint -gimp_container_list_view_item_activated (GtkWidget *widget, - GdkEventButton *bevent, - gpointer data) -{ - if (bevent->type == GDK_2BUTTON_PRESS) - { - GimpViewable *viewable; - - viewable = GIMP_PREVIEW (GIMP_LIST_ITEM (widget)->preview)->viewable; - - gimp_container_view_item_activated (GIMP_CONTAINER_VIEW (data), viewable); - } - - return FALSE; -} diff --git a/app/gimpcontainerlistview.h b/app/gimpcontainerlistview.h deleted file mode 100644 index 4c2f41e989..0000000000 --- a/app/gimpcontainerlistview.h +++ /dev/null @@ -1,57 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * 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_CONTAINER_LIST_VIEW_H__ -#define __GIMP_CONTAINER_LIST_VIEW_H__ - - -#include "gimpcontainerview.h" - - -#define GIMP_TYPE_CONTAINER_LIST_VIEW (gimp_container_list_view_get_type ()) -#define GIMP_CONTAINER_LIST_VIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_CONTAINER_LIST_VIEW, GimpContainerListView)) -#define GIMP_CONTAINER_LIST_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CONTAINER_LIST_VIEW, GimpContainerListViewClass)) -#define GIMP_IS_CONTAINER_LIST_VIEW(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_CONTAINER_LIST_VIEW)) -#define GIMP_IS_CONTAINER_LIST_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONTAINER_LIST_VIEW)) - - -typedef struct _GimpContainerListViewClass GimpContainerListViewClass; - -struct _GimpContainerListView -{ - GimpContainerView parent_instance; - - GtkWidget *scrolled_win; - GtkWidget *gtk_list; -}; - -struct _GimpContainerListViewClass -{ - GimpContainerViewClass parent_class; -}; - - -GtkType gimp_container_list_view_get_type (void); -GtkWidget * gimp_container_list_view_new (GimpContainer *container, - GimpContext *context, - gint preview_size, - gint min_items_x, - gint min_items_y); - - -#endif /* __GIMP_CONTAINER_LIST_VIEW_H__ */ diff --git a/app/gimpcontainerview.c b/app/gimpcontainerview.c deleted file mode 100644 index ca10051e9c..0000000000 --- a/app/gimpcontainerview.c +++ /dev/null @@ -1,580 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * 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 - -#include "apptypes.h" - -#include "gimpcontainer.h" -#include "gimpcontainerview.h" -#include "gimpcontext.h" -#include "gimpdnd.h" -#include "gimpmarshal.h" -#include "gimpviewable.h" - - -enum -{ - SET_CONTAINER, - INSERT_ITEM, - REMOVE_ITEM, - REORDER_ITEM, - SELECT_ITEM, - ACTIVATE_ITEM, - CLEAR_ITEMS, - SET_PREVIEW_SIZE, - LAST_SIGNAL -}; - - -static void gimp_container_view_class_init (GimpContainerViewClass *klass); -static void gimp_container_view_init (GimpContainerView *panel); -static void gimp_container_view_destroy (GtkObject *object); - -static void gimp_container_view_real_set_container (GimpContainerView *view, - GimpContainer *container); - -static void gimp_container_view_clear_items (GimpContainerView *view); -static void gimp_container_view_real_clear_items (GimpContainerView *view); - -static void gimp_container_view_add_foreach (GimpViewable *viewable, - GimpContainerView *view); -static void gimp_container_view_add (GimpContainerView *view, - GimpViewable *viewable, - GimpContainer *container); -static void gimp_container_view_remove (GimpContainerView *view, - GimpViewable *viewable, - GimpContainer *container); -static void gimp_container_view_reorder (GimpContainerView *view, - GimpViewable *viewable, - gint new_index, - GimpContainer *container); - -static void gimp_container_view_context_changed (GimpContext *context, - GimpViewable *viewable, - GimpContainerView *view); -static void gimp_container_view_drop_viewable_callback (GtkWidget *widget, - GimpViewable *viewable, - gpointer data); - - -static guint view_signals[LAST_SIGNAL] = { 0 }; - -static GtkVBoxClass *parent_class = NULL; - - -GtkType -gimp_container_view_get_type (void) -{ - static guint view_type = 0; - - if (! view_type) - { - GtkTypeInfo view_info = - { - "GimpContainerView", - sizeof (GimpContainerView), - sizeof (GimpContainerViewClass), - (GtkClassInitFunc) gimp_container_view_class_init, - (GtkObjectInitFunc) gimp_container_view_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL - }; - - view_type = gtk_type_unique (GTK_TYPE_VBOX, &view_info); - } - - return view_type; -} - -static void -gimp_container_view_class_init (GimpContainerViewClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) klass; - - parent_class = gtk_type_class (GTK_TYPE_VBOX); - - view_signals[SET_CONTAINER] = - gtk_signal_new ("set_container", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (GimpContainerViewClass, - set_container), - gtk_marshal_NONE__OBJECT, - GTK_TYPE_NONE, 1, - GIMP_TYPE_OBJECT); - - view_signals[INSERT_ITEM] = - gtk_signal_new ("insert_item", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (GimpContainerViewClass, - insert_item), - gimp_marshal_POINTER__POINTER_INT, - GTK_TYPE_POINTER, 2, - GIMP_TYPE_OBJECT, - GTK_TYPE_INT); - - view_signals[REMOVE_ITEM] = - gtk_signal_new ("remove_item", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (GimpContainerViewClass, - remove_item), - gtk_marshal_NONE__POINTER_POINTER, - GTK_TYPE_NONE, 2, - GIMP_TYPE_OBJECT, - GTK_TYPE_POINTER); - - view_signals[REORDER_ITEM] = - gtk_signal_new ("reorder_item", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (GimpContainerViewClass, - reorder_item), - gtk_marshal_NONE__POINTER_INT_POINTER, - GTK_TYPE_NONE, 3, - GIMP_TYPE_OBJECT, - GTK_TYPE_INT, - GTK_TYPE_POINTER); - - view_signals[SELECT_ITEM] = - gtk_signal_new ("select_item", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (GimpContainerViewClass, - select_item), - gtk_marshal_NONE__POINTER_POINTER, - GTK_TYPE_NONE, 2, - GIMP_TYPE_OBJECT, - GTK_TYPE_POINTER); - - view_signals[ACTIVATE_ITEM] = - gtk_signal_new ("activate_item", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (GimpContainerViewClass, - activate_item), - gtk_marshal_NONE__POINTER_POINTER, - GTK_TYPE_NONE, 2, - GIMP_TYPE_OBJECT, - GTK_TYPE_POINTER); - - view_signals[CLEAR_ITEMS] = - gtk_signal_new ("clear_items", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (GimpContainerViewClass, - clear_items), - gtk_signal_default_marshaller, - GTK_TYPE_NONE, 0); - - view_signals[SET_PREVIEW_SIZE] = - gtk_signal_new ("set_preview_size", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (GimpContainerViewClass, - set_preview_size), - gtk_signal_default_marshaller, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, view_signals, LAST_SIGNAL); - - object_class->destroy = gimp_container_view_destroy; - - klass->set_container = gimp_container_view_real_set_container; - klass->insert_item = NULL; - klass->remove_item = NULL; - klass->reorder_item = NULL; - klass->select_item = NULL; - klass->activate_item = NULL; - klass->clear_items = gimp_container_view_real_clear_items; - klass->set_preview_size = NULL; -} - -static void -gimp_container_view_init (GimpContainerView *view) -{ - view->container = NULL; - view->context = NULL; - - view->hash_table = g_hash_table_new (g_direct_hash, g_direct_equal); - - view->preview_size = 0; -} - -static void -gimp_container_view_destroy (GtkObject *object) -{ - GimpContainerView *view; - - view = GIMP_CONTAINER_VIEW (object); - - gimp_container_view_set_container (view, NULL); - - gimp_container_view_set_context (view, NULL); - - g_hash_table_destroy (view->hash_table); - - view->hash_table = NULL; - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -void -gimp_container_view_set_container (GimpContainerView *view, - GimpContainer *container) -{ - g_return_if_fail (view != NULL); - g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view)); - g_return_if_fail (!container || GIMP_IS_CONTAINER (container)); - - if (container == view->container) - return; - - gtk_signal_emit (GTK_OBJECT (view), view_signals[SET_CONTAINER], - container); -} - -static void -gimp_container_view_real_set_container (GimpContainerView *view, - GimpContainer *container) -{ - if (view->container) - { - gimp_container_view_select_item (view, NULL); - - gimp_container_view_clear_items (view); - - gtk_signal_disconnect_by_func (GTK_OBJECT (view->container), - gimp_container_view_add, - view); - gtk_signal_disconnect_by_func (GTK_OBJECT (view->container), - gimp_container_view_remove, - view); - gtk_signal_disconnect_by_func (GTK_OBJECT (view->container), - gimp_container_view_reorder, - view); - - g_hash_table_destroy (view->hash_table); - - view->hash_table = g_hash_table_new (g_direct_hash, g_direct_equal); - - if (view->context) - { - gtk_signal_disconnect_by_func (GTK_OBJECT (view->context), - gimp_container_view_context_changed, - view); - - gtk_drag_dest_unset (GTK_WIDGET (view)); - gimp_dnd_viewable_dest_unset (GTK_WIDGET (view), - view->container->children_type); - } - } - - view->container = container; - - if (view->container) - { - gimp_container_foreach (view->container, - (GFunc) gimp_container_view_add_foreach, - view); - - gtk_signal_connect_object (GTK_OBJECT (view->container), "add", - GTK_SIGNAL_FUNC (gimp_container_view_add), - GTK_OBJECT (view)); - - gtk_signal_connect_object (GTK_OBJECT (view->container), "remove", - GTK_SIGNAL_FUNC (gimp_container_view_remove), - GTK_OBJECT (view)); - - gtk_signal_connect_object (GTK_OBJECT (view->container), "reorder", - GTK_SIGNAL_FUNC (gimp_container_view_reorder), - GTK_OBJECT (view)); - - if (view->context) - { - GimpObject *object; - const gchar *signal_name; - - signal_name = - gimp_context_type_to_signal_name (view->container->children_type); - - gtk_signal_connect - (GTK_OBJECT (view->context), signal_name, - GTK_SIGNAL_FUNC (gimp_container_view_context_changed), - view); - - object = gimp_context_get_by_type (view->context, - view->container->children_type); - - gimp_container_view_select_item (view, - object ? GIMP_VIEWABLE (object): NULL); - - gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view), - GTK_DEST_DEFAULT_ALL, - view->container->children_type, - GDK_ACTION_COPY); - gimp_dnd_viewable_dest_set (GTK_WIDGET (view), - view->container->children_type, - gimp_container_view_drop_viewable_callback, - NULL); - } - } -} - -void -gimp_container_view_set_context (GimpContainerView *view, - GimpContext *context) -{ - g_return_if_fail (view != NULL); - g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view)); - g_return_if_fail (! context || GIMP_IS_CONTEXT (context)); - - if (context == view->context) - return; - - if (view->context && view->container) - { - gtk_signal_disconnect_by_func (GTK_OBJECT (view->context), - gimp_container_view_context_changed, - view); - - gtk_drag_dest_unset (GTK_WIDGET (view)); - gimp_dnd_viewable_dest_unset (GTK_WIDGET (view), - view->container->children_type); - } - - view->context = context; - - if (view->context && view->container) - { - GimpObject *object; - const gchar *signal_name; - - signal_name = - gimp_context_type_to_signal_name (view->container->children_type); - - gtk_signal_connect (GTK_OBJECT (view->context), signal_name, - GTK_SIGNAL_FUNC (gimp_container_view_context_changed), - view); - - object = gimp_context_get_by_type (view->context, - view->container->children_type); - - gimp_container_view_select_item (view, - object ? GIMP_VIEWABLE (object) : NULL); - - gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view), - GTK_DEST_DEFAULT_ALL, - view->container->children_type, - GDK_ACTION_COPY); - gimp_dnd_viewable_dest_set (GTK_WIDGET (view), - view->container->children_type, - gimp_container_view_drop_viewable_callback, - NULL); - } -} - -void -gimp_container_view_set_preview_size (GimpContainerView *view, - gint preview_size) -{ - g_return_if_fail (view != NULL); - g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view)); - g_return_if_fail (preview_size > 0 && preview_size <= 256 /* FIXME: 64 */); - - view->preview_size = preview_size; - - gtk_signal_emit (GTK_OBJECT (view), view_signals[SET_PREVIEW_SIZE]); -} - -void -gimp_container_view_select_item (GimpContainerView *view, - GimpViewable *viewable) -{ - gpointer insert_data; - - g_return_if_fail (view != NULL); - g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view)); - g_return_if_fail (! viewable || GIMP_IS_VIEWABLE (viewable)); - - insert_data = g_hash_table_lookup (view->hash_table, viewable); - - gtk_signal_emit (GTK_OBJECT (view), view_signals[SELECT_ITEM], - viewable, insert_data); -} - -void -gimp_container_view_activate_item (GimpContainerView *view, - GimpViewable *viewable) -{ - gpointer insert_data; - - g_return_if_fail (view != NULL); - g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view)); - g_return_if_fail (viewable != NULL); - g_return_if_fail (GIMP_IS_VIEWABLE (viewable)); - - insert_data = g_hash_table_lookup (view->hash_table, viewable); - - gtk_signal_emit (GTK_OBJECT (view), view_signals[ACTIVATE_ITEM], - viewable, insert_data); -} - -void -gimp_container_view_item_selected (GimpContainerView *view, - GimpViewable *viewable) -{ - g_return_if_fail (view != NULL); - g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view)); - g_return_if_fail (viewable != NULL); - g_return_if_fail (GIMP_IS_VIEWABLE (viewable)); - - if (view->container && view->context) - { - gimp_context_set_by_type (view->context, - view->container->children_type, - GIMP_OBJECT (viewable)); - } - - gimp_container_view_select_item (view, viewable); -} - -void -gimp_container_view_item_activated (GimpContainerView *view, - GimpViewable *viewable) -{ - g_return_if_fail (view != NULL); - g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view)); - g_return_if_fail (viewable != NULL); - g_return_if_fail (GIMP_IS_VIEWABLE (viewable)); - - gimp_container_view_activate_item (view, viewable); -} - -static void -gimp_container_view_clear_items (GimpContainerView *view) -{ - gtk_signal_emit (GTK_OBJECT (view), view_signals[CLEAR_ITEMS]); -} - -static void -gimp_container_view_real_clear_items (GimpContainerView *view) -{ - g_hash_table_destroy (view->hash_table); - - view->hash_table = g_hash_table_new (g_direct_hash, g_direct_equal); -} - -static void -gimp_container_view_add_foreach (GimpViewable *viewable, - GimpContainerView *view) -{ - gpointer insert_data = NULL; - - gtk_signal_emit (GTK_OBJECT (view), view_signals[INSERT_ITEM], - viewable, -1, &insert_data); - - g_hash_table_insert (view->hash_table, viewable, insert_data); -} - -static void -gimp_container_view_add (GimpContainerView *view, - GimpViewable *viewable, - GimpContainer *container) -{ - gpointer insert_data = NULL; - gint index; - - index = gimp_container_get_child_index (container, - GIMP_OBJECT (viewable)); - - gtk_signal_emit (GTK_OBJECT (view), view_signals[INSERT_ITEM], - viewable, index, &insert_data); - - g_hash_table_insert (view->hash_table, viewable, insert_data); -} - -static void -gimp_container_view_remove (GimpContainerView *view, - GimpViewable *viewable, - GimpContainer *container) -{ - gpointer insert_data; - - insert_data = g_hash_table_lookup (view->hash_table, viewable); - - if (insert_data) - { - g_hash_table_remove (view->hash_table, viewable); - - gtk_signal_emit (GTK_OBJECT (view), view_signals[REMOVE_ITEM], - viewable, insert_data); - } -} - -static void -gimp_container_view_reorder (GimpContainerView *view, - GimpViewable *viewable, - gint new_index, - GimpContainer *container) -{ - gpointer insert_data; - - insert_data = g_hash_table_lookup (view->hash_table, viewable); - - if (insert_data) - { - gtk_signal_emit (GTK_OBJECT (view), view_signals[REORDER_ITEM], - viewable, new_index, insert_data); - } -} - -static void -gimp_container_view_context_changed (GimpContext *context, - GimpViewable *viewable, - GimpContainerView *view) -{ - gpointer insert_data; - - insert_data = g_hash_table_lookup (view->hash_table, viewable); - - gtk_signal_emit (GTK_OBJECT (view), view_signals[SELECT_ITEM], - viewable, insert_data); -} - -static void -gimp_container_view_drop_viewable_callback (GtkWidget *widget, - GimpViewable *viewable, - gpointer data) -{ - GimpContainerView *view; - - view = GIMP_CONTAINER_VIEW (widget); - - gimp_context_set_by_type (view->context, - view->container->children_type, - GIMP_OBJECT (viewable)); -} diff --git a/app/gimpcontainerview.h b/app/gimpcontainerview.h deleted file mode 100644 index b28dea62fc..0000000000 --- a/app/gimpcontainerview.h +++ /dev/null @@ -1,96 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * 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_CONTAINER_VIEW_H__ -#define __GIMP_CONTAINER_VIEW_H__ - - -#include - - -#define GIMP_TYPE_CONTAINER_VIEW (gimp_container_view_get_type ()) -#define GIMP_CONTAINER_VIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_CONTAINER_VIEW, GimpContainerView)) -#define GIMP_CONTAINER_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CONTAINER_VIEW, GimpContainerViewClass)) -#define GIMP_IS_CONTAINER_VIEW(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_CONTAINER_VIEW)) -#define GIMP_IS_CONTAINER_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CONTAINER_VIEW)) - - -typedef struct _GimpContainerViewClass GimpContainerViewClass; - -struct _GimpContainerView -{ - GtkVBox parent_instance; - - GimpContainer *container; - GimpContext *context; - - GHashTable *hash_table; - - gint preview_size; -}; - -struct _GimpContainerViewClass -{ - GtkVBoxClass parent_class; - - void (* set_container) (GimpContainerView *view, - GimpContainer *container); - gpointer (* insert_item) (GimpContainerView *view, - GimpViewable *object, - gint index); - void (* remove_item) (GimpContainerView *view, - GimpViewable *object, - gpointer insert_data); - void (* reorder_item) (GimpContainerView *view, - GimpViewable *object, - gint new_index, - gpointer insert_data); - void (* select_item) (GimpContainerView *view, - GimpViewable *object, - gpointer insert_data); - void (* activate_item) (GimpContainerView *view, - GimpViewable *object, - gpointer insert_data); - void (* clear_items) (GimpContainerView *view); - void (* set_preview_size) (GimpContainerView *view); -}; - - -GtkType gimp_container_view_get_type (void); - -void gimp_container_view_set_container (GimpContainerView *view, - GimpContainer *container); -void gimp_container_view_set_context (GimpContainerView *view, - GimpContext *context); -void gimp_container_view_set_preview_size (GimpContainerView *view, - gint preview_size); -void gimp_container_view_select_item (GimpContainerView *view, - GimpViewable *viewable); -void gimp_container_view_activate_item (GimpContainerView *view, - GimpViewable *viewable); - - -/* private */ - -void gimp_container_view_item_selected (GimpContainerView *view, - GimpViewable *item); -void gimp_container_view_item_activated (GimpContainerView *view, - GimpViewable *item); - - -#endif /* __GIMP_CONTAINER_VIEW_H__ */ diff --git a/app/gimpdatafactoryview.c b/app/gimpdatafactoryview.c deleted file mode 100644 index 498223333e..0000000000 --- a/app/gimpdatafactoryview.c +++ /dev/null @@ -1,623 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * 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 -#include - -#include - -#include "libgimpmath/gimpmath.h" -#include "libgimpwidgets/gimpwidgets.h" - -#include "apptypes.h" - -#include "gimpcontainer.h" -#include "gimpcontainerview.h" -#include "gimpdata.h" -#include "gimpdatafactory.h" -#include "gimpdatafactoryview.h" -#include "gimpcontainergridview.h" -#include "gimpcontainerlistview.h" -#include "gimpcontext.h" -#include "gimpdnd.h" -#include "gimpmarshal.h" -#include "gimpviewable.h" - -#include "libgimp/gimpintl.h" - -#include "pixmaps/delete.xpm" -#include "pixmaps/duplicate.xpm" -#include "pixmaps/new.xpm" -#include "pixmaps/edit.xpm" -#include "pixmaps/refresh.xpm" - - -static void gimp_data_factory_view_class_init (GimpDataFactoryViewClass *klass); -static void gimp_data_factory_view_init (GimpDataFactoryView *view); -static void gimp_data_factory_view_destroy (GtkObject *object); - -static void gimp_data_factory_view_new_clicked (GtkWidget *widget, - GimpDataFactoryView *view); -static void gimp_data_factory_view_duplicate_clicked (GtkWidget *widget, - GimpDataFactoryView *view); -static void gimp_data_factory_view_duplicate_dropped (GtkWidget *widget, - GimpViewable *viewable, - gpointer data); -static void gimp_data_factory_view_edit_clicked (GtkWidget *widget, - GimpDataFactoryView *view); -static void gimp_data_factory_view_edit_dropped (GtkWidget *widget, - GimpViewable *viewable, - gpointer data); -static void gimp_data_factory_view_delete_clicked (GtkWidget *widget, - GimpDataFactoryView *view); -static void gimp_data_factory_view_delete_dropped (GtkWidget *widget, - GimpViewable *viewable, - gpointer data); -static void gimp_data_factory_view_refresh_clicked (GtkWidget *widget, - GimpDataFactoryView *view); - -static void gimp_data_factory_view_data_changed (GimpContext *context, - GimpData *data, - GimpDataFactoryView *view); -static void gimp_data_factory_view_data_activate (GtkWidget *context, - GimpData *data, - gpointer insert_data, - GimpDataFactoryView *view); - - -static GtkVBoxClass *parent_class = NULL; - - -GtkType -gimp_data_factory_view_get_type (void) -{ - static guint view_type = 0; - - if (! view_type) - { - GtkTypeInfo view_info = - { - "GimpDataFactoryView", - sizeof (GimpDataFactoryView), - sizeof (GimpDataFactoryViewClass), - (GtkClassInitFunc) gimp_data_factory_view_class_init, - (GtkObjectInitFunc) gimp_data_factory_view_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL - }; - - view_type = gtk_type_unique (GTK_TYPE_VBOX, &view_info); - } - - return view_type; -} - -static void -gimp_data_factory_view_class_init (GimpDataFactoryViewClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) klass; - - parent_class = gtk_type_class (GTK_TYPE_VBOX); - - object_class->destroy = gimp_data_factory_view_destroy; -} - -static void -gimp_data_factory_view_init (GimpDataFactoryView *view) -{ - GtkWidget *pixmap; - - view->view = NULL; - - gtk_box_set_spacing (GTK_BOX (view), 2); - - view->button_box = gtk_hbox_new (TRUE, 2); - gtk_box_pack_end (GTK_BOX (view), view->button_box, FALSE, FALSE, 0); - gtk_widget_show (view->button_box); - - /* new */ - - view->new_button = gtk_button_new (); - gtk_box_pack_start (GTK_BOX (view->button_box), view->new_button, - TRUE, TRUE, 0); - gtk_widget_show (view->new_button); - - gimp_help_set_help_data (view->new_button, _("New"), NULL); - - gtk_signal_connect (GTK_OBJECT (view->new_button), "clicked", - GTK_SIGNAL_FUNC (gimp_data_factory_view_new_clicked), - view); - - pixmap = gimp_pixmap_new (new_xpm); - gtk_container_add (GTK_CONTAINER (view->new_button), pixmap); - gtk_widget_show (pixmap); - - /* duplicate */ - - view->duplicate_button = gtk_button_new (); - gtk_box_pack_start (GTK_BOX (view->button_box), view->duplicate_button, - TRUE, TRUE, 0); - gtk_widget_show (view->duplicate_button); - - gimp_help_set_help_data (view->duplicate_button, _("Duplicate"), NULL); - - gtk_signal_connect (GTK_OBJECT (view->duplicate_button), "clicked", - GTK_SIGNAL_FUNC (gimp_data_factory_view_duplicate_clicked), - view); - - pixmap = gimp_pixmap_new (duplicate_xpm); - gtk_container_add (GTK_CONTAINER (view->duplicate_button), pixmap); - gtk_widget_show (pixmap); - - /* edit */ - - view->edit_button = gtk_button_new (); - gtk_box_pack_start (GTK_BOX (view->button_box), view->edit_button, - TRUE, TRUE, 0); - gtk_widget_show (view->edit_button); - - gimp_help_set_help_data (view->edit_button, _("Edit"), NULL); - - gtk_signal_connect (GTK_OBJECT (view->edit_button), "clicked", - GTK_SIGNAL_FUNC (gimp_data_factory_view_edit_clicked), - view); - - pixmap = gimp_pixmap_new (edit_xpm); - gtk_container_add (GTK_CONTAINER (view->edit_button), pixmap); - gtk_widget_show (pixmap); - - /* delete */ - - view->delete_button = gtk_button_new (); - gtk_box_pack_start (GTK_BOX (view->button_box), view->delete_button, - TRUE, TRUE, 0); - gtk_widget_show (view->delete_button); - - gimp_help_set_help_data (view->delete_button, _("Delete"), NULL); - - gtk_signal_connect (GTK_OBJECT (view->delete_button), "clicked", - GTK_SIGNAL_FUNC (gimp_data_factory_view_delete_clicked), - view); - - pixmap = gimp_pixmap_new (delete_xpm); - gtk_container_add (GTK_CONTAINER (view->delete_button), pixmap); - gtk_widget_show (pixmap); - - /* refresh */ - - view->refresh_button = gtk_button_new (); - gtk_box_pack_start (GTK_BOX (view->button_box), view->refresh_button, - TRUE, TRUE, 0); - gtk_widget_show (view->refresh_button); - - gimp_help_set_help_data (view->refresh_button, _("Refresh"), NULL); - - gtk_signal_connect (GTK_OBJECT (view->refresh_button), "clicked", - GTK_SIGNAL_FUNC (gimp_data_factory_view_refresh_clicked), - view); - - pixmap = gimp_pixmap_new (refresh_xpm); - gtk_container_add (GTK_CONTAINER (view->refresh_button), pixmap); - gtk_widget_show (pixmap); - - gtk_widget_set_sensitive (view->duplicate_button, FALSE); - gtk_widget_set_sensitive (view->edit_button, FALSE); - gtk_widget_set_sensitive (view->delete_button, FALSE); -} - -static void -gimp_data_factory_view_destroy (GtkObject *object) -{ - GimpDataFactoryView *view; - - view = GIMP_DATA_FACTORY_VIEW (object); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gimp_data_factory_view_new (GimpViewType view_type, - GimpDataFactory *factory, - GimpDataEditFunc edit_func, - GimpContext *context, - gint preview_size, - gint min_items_x, - gint min_items_y) -{ - GimpDataFactoryView *factory_view; - - g_return_val_if_fail (factory != NULL, NULL); - g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL); - g_return_val_if_fail (preview_size > 0 && preview_size <= 64, NULL); - g_return_val_if_fail (min_items_x > 0 && min_items_x <= 64, NULL); - g_return_val_if_fail (min_items_y > 0 && min_items_y <= 64, NULL); - - factory_view = gtk_type_new (GIMP_TYPE_DATA_FACTORY_VIEW); - - factory_view->factory = factory; - factory_view->data_edit_func = edit_func; - - switch (view_type) - { - case GIMP_VIEW_TYPE_GRID: - factory_view->view = - GIMP_CONTAINER_VIEW (gimp_container_grid_view_new (factory->container, - context, - preview_size, - min_items_x, - min_items_y)); - break; - - case GIMP_VIEW_TYPE_LIST: - factory_view->view = - GIMP_CONTAINER_VIEW (gimp_container_list_view_new (factory->container, - context, - preview_size, - min_items_x, - min_items_y)); - break; - - default: - g_warning ("%s(): unknown GimpViewType passed", G_GNUC_FUNCTION); - gtk_object_unref (GTK_OBJECT (factory_view)); - return NULL; - } - - gtk_container_add (GTK_CONTAINER (factory_view), - GTK_WIDGET (factory_view->view)); - gtk_widget_show (GTK_WIDGET (factory_view->view)); - - gtk_signal_connect_while_alive - (GTK_OBJECT (context), - gimp_context_type_to_signal_name (factory->container->children_type), - GTK_SIGNAL_FUNC (gimp_data_factory_view_data_changed), - factory_view, - GTK_OBJECT (factory_view)); - - gtk_signal_connect_while_alive - (GTK_OBJECT (factory_view->view), "activate_item", - GTK_SIGNAL_FUNC (gimp_data_factory_view_data_activate), - factory_view, - GTK_OBJECT (factory_view)); - - /* drop to "duplicate" */ - gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (factory_view->duplicate_button), - GTK_DEST_DEFAULT_ALL, - factory_view->factory->container->children_type, - GDK_ACTION_COPY); - gimp_dnd_viewable_dest_set (GTK_WIDGET (factory_view->duplicate_button), - factory_view->factory->container->children_type, - gimp_data_factory_view_duplicate_dropped, - factory_view); - - /* drop to "edit" */ - gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (factory_view->edit_button), - GTK_DEST_DEFAULT_ALL, - factory_view->factory->container->children_type, - GDK_ACTION_COPY); - gimp_dnd_viewable_dest_set (GTK_WIDGET (factory_view->edit_button), - factory_view->factory->container->children_type, - gimp_data_factory_view_edit_dropped, - factory_view); - - /* drop to "delete" */ - gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (factory_view->delete_button), - GTK_DEST_DEFAULT_ALL, - factory_view->factory->container->children_type, - GDK_ACTION_COPY); - gimp_dnd_viewable_dest_set (GTK_WIDGET (factory_view->delete_button), - factory_view->factory->container->children_type, - gimp_data_factory_view_delete_dropped, - factory_view); - - /* set button sensitivity */ - gimp_data_factory_view_data_changed - (context, - (GimpData *) - gimp_context_get_by_type (context, factory->container->children_type), - factory_view); - - return GTK_WIDGET (factory_view); -} - -static void -gimp_data_factory_view_new_clicked (GtkWidget *widget, - GimpDataFactoryView *view) -{ - if (view->factory->data_new_func) - { - GimpData *data; - - data = gimp_data_factory_data_new (view->factory, _("Untitled")); - - if (data) - { - gimp_context_set_by_type (view->view->context, - view->factory->container->children_type, - GIMP_OBJECT (data)); - - gimp_data_factory_view_edit_clicked (NULL, view); - } - } -} - -static void -gimp_data_factory_view_duplicate_clicked (GtkWidget *widget, - GimpDataFactoryView *view) -{ - GimpData *data; - - data = (GimpData *) - gimp_context_get_by_type (view->view->context, - view->factory->container->children_type); - - if (data && gimp_container_have (view->factory->container, - GIMP_OBJECT (data))) - { - GimpData *new_data; - - new_data = gimp_data_duplicate (data); - - if (new_data) - { - const gchar *name; - gchar *ext; - gint copy_len; - gint number; - gchar *new_name; - - name = gimp_object_get_name (GIMP_OBJECT (data)); - - ext = strrchr (name, '#'); - copy_len = strlen (_("copy")); - - if ((strlen (name) >= copy_len && - strcmp (&name[strlen (name) - copy_len], _("copy")) == 0) || - (ext && (number = atoi (ext + 1)) > 0 && - ((gint) (log10 (number) + 1)) == strlen (ext + 1))) - { - /* don't have redundant "copy"s */ - new_name = g_strdup (name); - } - else - { - new_name = g_strdup_printf (_("%s copy"), name); - } - - gimp_object_set_name (GIMP_OBJECT (new_data), new_name); - - g_free (new_name); - - gimp_container_add (view->factory->container, GIMP_OBJECT (new_data)); - - gimp_context_set_by_type (view->view->context, - view->factory->container->children_type, - GIMP_OBJECT (new_data)); - - gimp_data_factory_view_edit_clicked (NULL, view); - } - } -} - -static void -gimp_data_factory_view_duplicate_dropped (GtkWidget *widget, - GimpViewable *viewable, - gpointer data) -{ - GimpDataFactoryView *view; - - view = (GimpDataFactoryView *) data; - - if (viewable && gimp_container_have (view->factory->container, - GIMP_OBJECT (viewable))) - { - gimp_context_set_by_type (view->view->context, - view->factory->container->children_type, - GIMP_OBJECT (viewable)); - - gimp_data_factory_view_duplicate_clicked (NULL, data); - } -} - -static void -gimp_data_factory_view_edit_clicked (GtkWidget *widget, - GimpDataFactoryView *view) -{ - GimpData *data; - - data = (GimpData *) - gimp_context_get_by_type (view->view->context, - view->factory->container->children_type); - - if (view->data_edit_func && - data && - gimp_container_have (view->factory->container, - GIMP_OBJECT (data))) - { - view->data_edit_func (data); - } -} - -static void -gimp_data_factory_view_edit_dropped (GtkWidget *widget, - GimpViewable *viewable, - gpointer data) -{ - GimpDataFactoryView *view; - - view = (GimpDataFactoryView *) data; - - if (viewable && gimp_container_have (view->factory->container, - GIMP_OBJECT (viewable))) - { - gimp_context_set_by_type (view->view->context, - view->factory->container->children_type, - GIMP_OBJECT (viewable)); - - gimp_data_factory_view_edit_clicked (NULL, data); - } -} - - -typedef struct _GimpDataDeleteData GimpDataDeleteData; - -struct _GimpDataDeleteData -{ - GimpDataFactory *factory; - GimpData *data; -}; - -static void -gimp_data_factory_view_delete_callback (GtkWidget *widget, - gboolean delete, - gpointer data) -{ - GimpDataDeleteData *delete_data; - - delete_data = (GimpDataDeleteData *) data; - - if (! delete) - return; - - if (gimp_container_have (delete_data->factory->container, - GIMP_OBJECT (delete_data->data))) - { - if (delete_data->data->filename) - gimp_data_delete_from_disk (delete_data->data); - - gimp_container_remove (delete_data->factory->container, - GIMP_OBJECT (delete_data->data)); - } -} - -static void -gimp_data_factory_view_delete_clicked (GtkWidget *widget, - GimpDataFactoryView *view) -{ - GimpData *data; - - data = (GimpData *) - gimp_context_get_by_type (view->view->context, - view->factory->container->children_type); - - if (data && gimp_container_have (view->factory->container, - GIMP_OBJECT (data))) - { - GimpDataDeleteData *delete_data; - GtkWidget *dialog; - gchar *str; - - delete_data = g_new0 (GimpDataDeleteData, 1); - - delete_data->factory = view->factory; - delete_data->data = data; - - str = g_strdup_printf (_("Are you sure you want to delete\n" - "\"%s\" from the list and from disk?"), - GIMP_OBJECT (data)->name); - - dialog = - gimp_query_boolean_box (_("Delete Data Object"), - gimp_standard_help_func, NULL, - FALSE, - str, - _("Delete"), _("Cancel"), - GTK_OBJECT (data), - "destroy", - gimp_data_factory_view_delete_callback, - delete_data); - - gtk_signal_connect_object (GTK_OBJECT (dialog), "destroy", - GTK_SIGNAL_FUNC (g_free), - (GtkObject *) delete_data); - - g_free (str); - - gtk_widget_show (dialog); - } -} - -static void -gimp_data_factory_view_delete_dropped (GtkWidget *widget, - GimpViewable *viewable, - gpointer data) -{ - GimpDataFactoryView *view; - - view = (GimpDataFactoryView *) data; - - if (viewable && gimp_container_have (view->factory->container, - GIMP_OBJECT (viewable))) - { - gimp_context_set_by_type (view->view->context, - view->factory->container->children_type, - GIMP_OBJECT (viewable)); - - gimp_data_factory_view_delete_clicked (NULL, data); - } -} - -static void -gimp_data_factory_view_refresh_clicked (GtkWidget *widget, - GimpDataFactoryView *view) -{ - gimp_data_factory_data_init (view->factory, FALSE); -} - -static void -gimp_data_factory_view_data_changed (GimpContext *context, - GimpData *data, - GimpDataFactoryView *view) -{ - gboolean duplicate_sensitive = FALSE; - gboolean edit_sensitive = FALSE; - gboolean delete_sensitive = FALSE; - - if (data && gimp_container_have (view->factory->container, - GIMP_OBJECT (data))) - { - duplicate_sensitive = - (GIMP_DATA_CLASS (GTK_OBJECT (data)->klass)->duplicate != NULL); - - edit_sensitive = (view->data_edit_func != NULL); - delete_sensitive = TRUE; /* TODO: check permissions */ - } - - gtk_widget_set_sensitive (view->duplicate_button, duplicate_sensitive); - gtk_widget_set_sensitive (view->edit_button, edit_sensitive); - gtk_widget_set_sensitive (view->delete_button, delete_sensitive); -} - -static void -gimp_data_factory_view_data_activate (GtkWidget *widget, - GimpData *data, - gpointer insert_data, - GimpDataFactoryView *view) -{ - if (data && gimp_container_have (view->factory->container, - GIMP_OBJECT (data))) - { - gimp_data_factory_view_edit_clicked (NULL, view); - } -} diff --git a/app/gimpdatafactoryview.h b/app/gimpdatafactoryview.h deleted file mode 100644 index 9c4524f15a..0000000000 --- a/app/gimpdatafactoryview.h +++ /dev/null @@ -1,80 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * 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_DATA_FACTORY_VIEW_H__ -#define __GIMP_DATA_FACTORY_VIEW_H__ - - -#include - - -typedef void (* GimpDataEditFunc) (GimpData *data); - - -typedef enum -{ - GIMP_VIEW_TYPE_GRID, - GIMP_VIEW_TYPE_LIST -} GimpViewType; - - -#define GIMP_TYPE_DATA_FACTORY_VIEW (gimp_data_factory_view_get_type ()) -#define GIMP_DATA_FACTORY_VIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DATA_FACTORY_VIEW, GimpDataFactoryView)) -#define GIMP_DATA_FACTORY_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DATA_FACTORY_VIEW, GimpDataFactoryViewClass)) -#define GIMP_IS_DATA_FACTORY_VIEW(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DATA_FACTORY_VIEW)) -#define GIMP_IS_DATA_FACTORY_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DATA_FACTORY_VIEW)) - - -typedef struct _GimpDataFactoryViewClass GimpDataFactoryViewClass; - -struct _GimpDataFactoryView -{ - GtkVBox parent_instance; - - GimpDataFactory *factory; - GimpDataEditFunc data_edit_func; - - GimpContainerView *view; - - GtkWidget *button_box; - - GtkWidget *new_button; - GtkWidget *duplicate_button; - GtkWidget *edit_button; - GtkWidget *delete_button; - - GtkWidget *refresh_button; -}; - -struct _GimpDataFactoryViewClass -{ - GtkVBoxClass parent_class; -}; - - -GtkType gimp_data_factory_view_get_type (void); -GtkWidget * gimp_data_factory_view_new (GimpViewType view_type, - GimpDataFactory *factory, - GimpDataEditFunc edit_func, - GimpContext *context, - gint preview_size, - gint min_items_x, - gint min_items_y); - - -#endif /* __GIMP_DATA_FACTORY_VIEW_H__ */ diff --git a/app/gimpdnd.c b/app/gimpdnd.c index bf188aa1bd..b76dd09dab 100644 --- a/app/gimpdnd.c +++ b/app/gimpdnd.c @@ -32,6 +32,8 @@ #include "tools/gimptoolinfo.h" #include "tools/tool_manager.h" +#include "widgets/gimppreview.h" + #include "context_manager.h" #include "file-open.h" #include "gimpimage.h" @@ -46,7 +48,6 @@ #include "gimplayermask.h" #include "gimppalette.h" #include "gimppattern.h" -#include "gimppreview.h" #include "gimprc.h" #include "temp_buf.h" diff --git a/app/gimpdock.c b/app/gimpdock.c deleted file mode 100644 index 60aca611ee..0000000000 --- a/app/gimpdock.c +++ /dev/null @@ -1,456 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * gimpdock.c - * Copyright (C) 2001 Michael Natterer - * - * 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 - -#include "libgimpwidgets/gimpwidgets.h" - -#include "apptypes.h" - -#include "gimpdnd.h" -#include "gimpdock.h" -#include "gimpdockable.h" -#include "gimpdockbook.h" - - -static void gimp_dock_class_init (GimpDockClass *klass); -static void gimp_dock_init (GimpDock *dock); - -static GtkWidget * gimp_dock_separator_new (GimpDock *dock); - -static void gimp_dock_destroy (GtkObject *object); - -static gboolean gimp_dock_separator_button_press (GtkWidget *widget, - GdkEventButton *bevent, - gpointer data); -static gboolean gimp_dock_separator_button_release (GtkWidget *widget, - GdkEventButton *bevent, - gpointer data); - -/* -static void gimp_dock_separator_drag_begin (GtkWidget *widget, - GdkDragContext *context, - gpointer data); -static void gimp_dock_separator_drag_end (GtkWidget *widget, - GdkDragContext *context, - gpointer data); -*/ - -static gboolean gimp_dock_separator_drag_drop (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time, - gpointer data); - - -static GtkWindowClass *parent_class = NULL; - -static GtkTargetEntry dialog_target_table[] = -{ - GIMP_TARGET_DIALOG -}; -static guint n_dialog_targets = (sizeof (dialog_target_table) / - sizeof (dialog_target_table[0])); - - -GtkType -gimp_dock_get_type (void) -{ - static GtkType dock_type = 0; - - if (! dock_type) - { - static const GtkTypeInfo dock_info = - { - "GimpDock", - sizeof (GimpDock), - sizeof (GimpDockClass), - (GtkClassInitFunc) gimp_dock_class_init, - (GtkObjectInitFunc) gimp_dock_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - dock_type = gtk_type_unique (GTK_TYPE_WINDOW, &dock_info); - } - - return dock_type; -} - -static void -gimp_dock_class_init (GimpDockClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) klass; - - parent_class = gtk_type_class (GTK_TYPE_WINDOW); - - object_class->destroy = gimp_dock_destroy; -} - -static void -gimp_dock_init (GimpDock *dock) -{ - GtkWidget *separator; - - gtk_window_set_policy (GTK_WINDOW (dock), FALSE, TRUE, TRUE); - - dock->vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (dock), dock->vbox); - gtk_widget_show (dock->vbox); - - separator = gimp_dock_separator_new (dock); - gtk_box_pack_start (GTK_BOX (dock->vbox), separator, FALSE, FALSE, 0); - gtk_widget_show (separator); -} - -static void -gimp_dock_destroy (GtkObject *object) -{ - GimpDock *dock; - - dock = GIMP_DOCK (object); - - g_list_free (dock->dockbooks); - - if (GTK_OBJECT_CLASS (parent_class)) - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gimp_dock_new (void) -{ - return GTK_WIDGET (gtk_type_new (GIMP_TYPE_DOCK)); -} - -static GtkWidget * -gimp_dock_separator_new (GimpDock *dock) -{ - GtkWidget *event_box; - GtkWidget *frame; - - event_box = gtk_event_box_new (); - gtk_widget_set_usize (event_box, -1, 8); - - frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT); - gtk_container_add (GTK_CONTAINER (event_box), frame); - gtk_widget_show (frame); - - gtk_drag_dest_set (GTK_WIDGET (event_box), - GTK_DEST_DEFAULT_ALL, - dialog_target_table, n_dialog_targets, - GDK_ACTION_MOVE); - gtk_signal_connect (GTK_OBJECT (event_box), "drag_drop", - GTK_SIGNAL_FUNC (gimp_dock_separator_drag_drop), - dock); - - gtk_signal_connect (GTK_OBJECT (event_box), "button_press_event", - GTK_SIGNAL_FUNC (gimp_dock_separator_button_press), - dock); - gtk_signal_connect (GTK_OBJECT (event_box), "button_release_event", - GTK_SIGNAL_FUNC (gimp_dock_separator_button_release), - dock); - - return event_box; -} - -void -gimp_dock_add (GimpDock *dock, - GimpDockable *dockable, - gint section, - gint position) -{ - GimpDockbook *dockbook; - - g_return_if_fail (dock != NULL); - g_return_if_fail (GIMP_IS_DOCK (dock)); - - g_return_if_fail (dockable != NULL); - g_return_if_fail (GIMP_IS_DOCKABLE (dockable)); - - g_return_if_fail (dockable->dockbook == NULL); - - dockbook = GIMP_DOCKBOOK (dock->dockbooks->data); - - gimp_dockbook_add (dockbook, dockable, position); -} - -void -gimp_dock_remove (GimpDock *dock, - GimpDockable *dockable) -{ - g_return_if_fail (dock != NULL); - g_return_if_fail (GIMP_IS_DOCK (dock)); - - g_return_if_fail (dockable != NULL); - g_return_if_fail (GIMP_IS_DOCKABLE (dockable)); - - g_return_if_fail (dockable->dockbook != NULL); - g_return_if_fail (dockable->dockbook->dock != NULL); - g_return_if_fail (dockable->dockbook->dock == dock); - - gimp_dockbook_remove (dockable->dockbook, dockable); -} - -void -gimp_dock_add_book (GimpDock *dock, - GimpDockbook *dockbook, - gint index) -{ - GtkWidget *separator; - gint length; - - g_return_if_fail (dock != NULL); - g_return_if_fail (GIMP_IS_DOCK (dock)); - - g_return_if_fail (dockbook != NULL); - g_return_if_fail (GIMP_IS_DOCKBOOK (dockbook)); - - g_return_if_fail (dockbook->dock == NULL); - - length = g_list_length (dock->dockbooks); - - if (index >= length || index < 0) - index = length; - - dockbook->dock = dock; - dock->dockbooks = g_list_insert (dock->dockbooks, dockbook, index); - - index *= 2; - - gtk_box_pack_start (GTK_BOX (dock->vbox), GTK_WIDGET (dockbook), - TRUE, TRUE, 0); - gtk_box_reorder_child (GTK_BOX (dock->vbox), GTK_WIDGET (dockbook), index); - gtk_widget_show (GTK_WIDGET (dockbook)); - - separator = gimp_dock_separator_new (dock); - gtk_box_pack_start (GTK_BOX (dock->vbox), separator, FALSE, FALSE, 0); - gtk_box_reorder_child (GTK_BOX (dock->vbox), separator, index); - gtk_widget_show (separator); -} - -void -gimp_dock_remove_book (GimpDock *dock, - GimpDockbook *dockbook) -{ - GList *children; - gint length; - gint index; - gint book_index; - - g_return_if_fail (dock != NULL); - g_return_if_fail (GIMP_IS_DOCK (dock)); - - g_return_if_fail (dockbook != NULL); - g_return_if_fail (GIMP_IS_DOCKBOOK (dockbook)); - - g_return_if_fail (dockbook->dock == dock); - - length = g_list_length (dock->dockbooks); - index = g_list_index (dock->dockbooks, dockbook); - - dockbook->dock = NULL; - dock->dockbooks = g_list_remove (dock->dockbooks, dockbook); - - children = gtk_container_children (GTK_CONTAINER (dock->vbox)); - book_index = g_list_index (children, dockbook); - - if (length != 1) - { - GtkWidget *separator; - - if (index == length -1) - { - separator = g_list_nth_data (children, book_index - 1); - } - else - { - separator = g_list_nth_data (children, book_index + 1); - } - - gtk_container_remove (GTK_CONTAINER (dock->vbox), separator); - } - - gtk_container_remove (GTK_CONTAINER (dock->vbox), GTK_WIDGET (dockbook)); - - if (length == 1) - { - gtk_widget_destroy (GTK_WIDGET (dock)); - return; - } -} - -static gboolean -gimp_dock_separator_button_press (GtkWidget *widget, - GdkEventButton *bevent, - gpointer data) -{ - if (bevent->type == GDK_BUTTON_PRESS) - { - if (bevent->button == 1) - { - gtk_grab_add (widget); - } - } - - return TRUE; -} - -static gboolean -gimp_dock_separator_button_release (GtkWidget *widget, - GdkEventButton *bevent, - gpointer data) -{ - if (bevent->button == 1) - { - gtk_grab_remove (widget); - } - - return TRUE; -} - -/* -static void -gimp_dock_tab_drag_begin (GtkWidget *widget, - GdkDragContext *context, - gpointer data) -{ - GimpDockable *dockable; - GtkWidget *window; - GtkWidget *frame; - GtkWidget *label; - - dockable = GIMP_DOCKABLE (data); - - window = gtk_window_new (GTK_WINDOW_POPUP); - - frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT); - gtk_container_add (GTK_CONTAINER (window), frame); - gtk_widget_show (frame); - - label = gtk_label_new (dockable->name); - gtk_misc_set_padding (GTK_MISC (label), 10, 5); - gtk_container_add (GTK_CONTAINER (frame), label); - gtk_widget_show (label); - - gtk_widget_show (window); - - gtk_object_set_data_full (GTK_OBJECT (dockable), "gimp_dock_drag_widget", - window, - (GtkDestroyNotify) gtk_widget_destroy); - - gtk_drag_set_icon_widget (context, window, - -8, -8); -} - -static void -gimp_dock_tab_drag_end (GtkWidget *widget, - GdkDragContext *context, - gpointer data) -{ - GimpDockable *dockable; - GtkWidget *drag_widget; - - dockable = GIMP_DOCKABLE (data); - - drag_widget = gtk_object_get_data (GTK_OBJECT (dockable), - "gimp_dock_drag_widget"); - - if (drag_widget) - { - GtkWidget *dock; - - gtk_object_set_data (GTK_OBJECT (dockable), "gimp_dock_drag_widget", NULL); - - dock = gimp_dock_new (); - - gtk_window_set_position (GTK_WINDOW (dock), GTK_WIN_POS_MOUSE); - - gtk_object_ref (GTK_OBJECT (dockable)); - - gimp_dock_remove (dockable->dock, dockable); - gimp_dock_add (GIMP_DOCK (dock), dockable, -1, -1); - - gtk_object_unref (GTK_OBJECT (dockable)); - - gtk_widget_show (dock); - } -} -*/ - -static gboolean -gimp_dock_separator_drag_drop (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time, - gpointer data) -{ - GimpDock *dock; - GtkWidget *source; - - dock = GIMP_DOCK (data); - - source = gtk_drag_get_source_widget (context); - - if (source) - { - GimpDockable *src_dockable; - - src_dockable = (GimpDockable *) gtk_object_get_data (GTK_OBJECT (source), - "gimp_dockable"); - - if (src_dockable) - { - GtkWidget *dockbook; - GList *children; - gint index; - - gtk_object_set_data (GTK_OBJECT (src_dockable), - "gimp_dock_drag_widget", NULL); - - children = gtk_container_children (GTK_CONTAINER (widget->parent)); - index = g_list_index (children, widget) / 2; - - dockbook = gimp_dockbook_new (); - - gimp_dock_add_book (dock, GIMP_DOCKBOOK (dockbook), index); - - gtk_object_ref (GTK_OBJECT (src_dockable)); - - gimp_dockbook_remove (src_dockable->dockbook, src_dockable); - gimp_dockbook_add (GIMP_DOCKBOOK (dockbook), src_dockable, -1); - - gtk_object_unref (GTK_OBJECT (src_dockable)); - - return TRUE; - } - } - - return FALSE; -} diff --git a/app/gimpdock.h b/app/gimpdock.h deleted file mode 100644 index 85546b21e9..0000000000 --- a/app/gimpdock.h +++ /dev/null @@ -1,71 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * gimpdock.h - * Copyright (C) 2001 Michael Natterer - * - * 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_DOCK_H__ -#define __GIMP_DOCK_H__ - - -#include - - -#define GIMP_TYPE_DOCK (gimp_dock_get_type ()) -#define GIMP_DOCK(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DOCK, GimpDock)) -#define GIMP_DOCK_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DOCK, GimpDockClass)) -#define GIMP_IS_DOCK(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DOCK)) -#define GIMP_IS_DOCK_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DOCK)) - - -typedef struct _GimpDockClass GimpDockClass; - - -struct _GimpDock -{ - GtkWindow parent_instance; - - GtkWidget *vbox; - - GList *dockbooks; -}; - -struct _GimpDockClass -{ - GtkWindowClass parent_class; -}; - - -GtkType gimp_dock_get_type (void); -GtkWidget * gimp_dock_new (void); - -void gimp_dock_add (GimpDock *dock, - GimpDockable *dockable, - gint book, - gint index); -void gimp_dock_remove (GimpDock *dock, - GimpDockable *dockable); - -void gimp_dock_add_book (GimpDock *dock, - GimpDockbook *dockbook, - gint index); -void gimp_dock_remove_book (GimpDock *dock, - GimpDockbook *dockbook); - - -#endif /* __GIMP_DOCK_H__ */ diff --git a/app/gimpdockable.c b/app/gimpdockable.c deleted file mode 100644 index fc8e30a7c4..0000000000 --- a/app/gimpdockable.c +++ /dev/null @@ -1,135 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * gimpdockable.c - * Copyright (C) 2001 Michael Natterer - * - * 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 - -#include "apptypes.h" - -#include "gimpdockable.h" - - -static void gimp_dockable_class_init (GimpDockableClass *klass); -static void gimp_dockable_init (GimpDockable *dockable); - -static void gimp_dockable_destroy (GtkObject *object); - - -static GtkVBoxClass *parent_class = NULL; - - -GtkType -gimp_dockable_get_type (void) -{ - static GtkType dockable_type = 0; - - if (! dockable_type) - { - static const GtkTypeInfo dockable_info = - { - "GimpDockable", - sizeof (GimpDockable), - sizeof (GimpDockableClass), - (GtkClassInitFunc) gimp_dockable_class_init, - (GtkObjectInitFunc) gimp_dockable_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - dockable_type = gtk_type_unique (GTK_TYPE_VBOX, &dockable_info); - } - - return dockable_type; -} - -static void -gimp_dockable_class_init (GimpDockableClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) klass; - - parent_class = gtk_type_class (GTK_TYPE_VBOX); - - object_class->destroy = gimp_dockable_destroy; -} - -static void -gimp_dockable_init (GimpDockable *dockable) -{ - dockable->name = NULL; - dockable->short_name = NULL; - dockable->dockbook = NULL; - dockable->get_tab_func = NULL; -} - -static void -gimp_dockable_destroy (GtkObject *object) -{ - GimpDockable *dockable; - - dockable = GIMP_DOCKABLE (object); - - g_free (dockable->name); - g_free (dockable->short_name); - - if (GTK_OBJECT_CLASS (parent_class)) - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gimp_dockable_new (const gchar *name, - const gchar *short_name, - GimpDockableGetTabFunc get_tab_func) -{ - GimpDockable *dockable; - - g_return_val_if_fail (name != NULL, NULL); - g_return_val_if_fail (short_name != NULL, NULL); - - dockable = gtk_type_new (GIMP_TYPE_DOCKABLE); - - dockable->name = g_strdup (name); - dockable->short_name = g_strdup (short_name); - - dockable->get_tab_func = get_tab_func; - - return GTK_WIDGET (dockable); -} - -GtkWidget * -gimp_dockable_get_tab_widget (GimpDockable *dockable, - gint size) -{ - g_return_val_if_fail (dockable != NULL, NULL); - g_return_val_if_fail (GIMP_IS_DOCKABLE (dockable), NULL); - - g_return_val_if_fail (size >= -1 && size < 64, NULL); - - if (dockable->get_tab_func) - { - return dockable->get_tab_func (dockable, size); - } - - return gtk_label_new (dockable->short_name); -} diff --git a/app/gimpdockable.h b/app/gimpdockable.h deleted file mode 100644 index 037a9934e0..0000000000 --- a/app/gimpdockable.h +++ /dev/null @@ -1,70 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * gimpdockable.h - * Copyright (C) 2001 Michael Natterer - * - * 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_DOCKABLE_H__ -#define __GIMP_DOCKABLE_H__ - - -#include - - -typedef GtkWidget * (* GimpDockableGetTabFunc) (GimpDockable *dockable, - gint size); - - -#define GIMP_TYPE_DOCKABLE (gimp_dockable_get_type ()) -#define GIMP_DOCKABLE(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DOCKABLE, GimpDockable)) -#define GIMP_DOCKABLE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DOCKABLE, GimpDockableClass)) -#define GIMP_IS_DOCKABLE(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DOCKABLE)) -#define GIMP_IS_DOCKABLE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DOCKABLE)) - - -typedef struct _GimpDockableClass GimpDockableClass; - - -struct _GimpDockable -{ - GtkVBox parent_instance; - - gchar *name; - gchar *short_name; - - GimpDockbook *dockbook; - - GimpDockableGetTabFunc get_tab_func; -}; - -struct _GimpDockableClass -{ - GtkVBoxClass parent_class; -}; - - -GtkType gimp_dockable_get_type (void); -GtkWidget * gimp_dockable_new (const gchar *name, - const gchar *short_name, - GimpDockableGetTabFunc get_tab_func); - -GtkWidget * gimp_dockable_get_tab_widget (GimpDockable *dockable, - gint size); - - -#endif /* __GIMP_DOCKABLE_H__ */ diff --git a/app/gimpdockbook.c b/app/gimpdockbook.c deleted file mode 100644 index c146a7136f..0000000000 --- a/app/gimpdockbook.c +++ /dev/null @@ -1,515 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * gimpdockbook.c - * Copyright (C) 2001 Michael Natterer - * - * 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 - -#include "libgimpwidgets/gimpwidgets.h" - -#include "apptypes.h" - -#include "gimpdnd.h" -#include "gimpdock.h" -#include "gimpdockable.h" -#include "gimpdockbook.h" - - -static void gimp_dockbook_class_init (GimpDockbookClass *klass); -static void gimp_dockbook_init (GimpDockbook *dockbook); - -static void gimp_dockbook_destroy (GtkObject *object); -static gboolean gimp_dockbook_drag_drop (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time); - -static gboolean gimp_dockbook_tab_button_press (GtkWidget *widget, - GdkEventButton *bevent, - gpointer data); -static void gimp_dockbook_tab_drag_begin (GtkWidget *widget, - GdkDragContext *context, - gpointer data); -static void gimp_dockbook_tab_drag_end (GtkWidget *widget, - GdkDragContext *context, - gpointer data); -static gboolean gimp_dockbook_tab_drag_drop (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time, - gpointer data); - - -static GtkNotebookClass *parent_class = NULL; - -static GtkTargetEntry dialog_target_table[] = -{ - GIMP_TARGET_DIALOG -}; -static guint n_dialog_targets = (sizeof (dialog_target_table) / - sizeof (dialog_target_table[0])); - - -GtkType -gimp_dockbook_get_type (void) -{ - static GtkType dockbook_type = 0; - - if (! dockbook_type) - { - static const GtkTypeInfo dockbook_info = - { - "GimpDockbook", - sizeof (GimpDockbook), - sizeof (GimpDockbookClass), - (GtkClassInitFunc) gimp_dockbook_class_init, - (GtkObjectInitFunc) gimp_dockbook_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - dockbook_type = gtk_type_unique (GTK_TYPE_NOTEBOOK, &dockbook_info); - } - - return dockbook_type; -} - -static void -gimp_dockbook_class_init (GimpDockbookClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) klass; - widget_class = (GtkWidgetClass *) klass; - - parent_class = gtk_type_class (GTK_TYPE_NOTEBOOK); - - object_class->destroy = gimp_dockbook_destroy; - - widget_class->drag_drop = gimp_dockbook_drag_drop; -} - -static void -gimp_dockbook_init (GimpDockbook *dockbook) -{ - dockbook->dock = NULL; - - gtk_notebook_set_tab_border (GTK_NOTEBOOK (dockbook), 0); - gtk_notebook_popup_enable (GTK_NOTEBOOK (dockbook)); - gtk_notebook_set_scrollable (GTK_NOTEBOOK (dockbook), TRUE); - - gtk_drag_dest_set (GTK_WIDGET (dockbook), - GTK_DEST_DEFAULT_ALL, - dialog_target_table, n_dialog_targets, - GDK_ACTION_MOVE); -} - -static void -gimp_dockbook_destroy (GtkObject *object) -{ - if (GTK_OBJECT_CLASS (parent_class)) - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gimp_dockbook_new (void) -{ - return GTK_WIDGET (gtk_type_new (GIMP_TYPE_DOCKBOOK)); -} - -static gboolean -gimp_dockbook_drag_drop (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time) -{ - GtkWidget *source; - - source = gtk_drag_get_source_widget (context); - - if (source) - { - GimpDockable *dockable; - - dockable = (GimpDockable *) gtk_object_get_data (GTK_OBJECT (source), - "gimp_dockable"); - - if (dockable) - { - gtk_object_set_data (GTK_OBJECT (dockable), - "gimp_dock_drag_widget", NULL); - - if (dockable->dockbook != GIMP_DOCKBOOK (widget)) - { - gtk_object_ref (GTK_OBJECT (dockable)); - - gimp_dockbook_remove (dockable->dockbook, dockable); - gimp_dockbook_add (GIMP_DOCKBOOK (widget), dockable, -1); - - gtk_object_unref (GTK_OBJECT (dockable)); - - return TRUE; - } - } - } - - return FALSE; -} - -void -gimp_dockbook_add (GimpDockbook *dockbook, - GimpDockable *dockable, - gint position) -{ - GtkWidget *tab_widget; - GtkWidget *menu_widget; - - g_return_if_fail (dockbook != NULL); - g_return_if_fail (GIMP_IS_DOCKBOOK (dockbook)); - - g_return_if_fail (dockable != NULL); - g_return_if_fail (GIMP_IS_DOCKABLE (dockable)); - - g_return_if_fail (dockable->dockbook == NULL); - - tab_widget = gimp_dockable_get_tab_widget (dockable, 24); - - if (GTK_IS_LABEL (tab_widget)) - { - GtkWidget *event_box; - - event_box = gtk_event_box_new (); - gtk_container_add (GTK_CONTAINER (event_box), tab_widget); - gtk_widget_show (tab_widget); - - tab_widget = event_box; - } - else - { - gimp_help_set_help_data (tab_widget, dockable->name, NULL); - } - - gtk_object_set_data (GTK_OBJECT (tab_widget), "gimp_dockable", dockable); - - gtk_signal_connect (GTK_OBJECT (tab_widget), "button_press_event", - GTK_SIGNAL_FUNC (gimp_dockbook_tab_button_press), - dockable); - - menu_widget = gimp_dockable_get_tab_widget (dockable, 16); - - if (! GTK_IS_LABEL (menu_widget)) - { - GtkWidget *hbox; - GtkWidget *label; - - hbox = gtk_hbox_new (FALSE, 4); - - gtk_box_pack_start (GTK_BOX (hbox), menu_widget, FALSE, FALSE, 0); - gtk_widget_show (menu_widget); - - label = gtk_label_new (dockable->name); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - menu_widget = hbox; - } - else - { - gtk_widget_destroy (menu_widget); - - menu_widget = gtk_label_new (dockable->name); - gtk_misc_set_alignment (GTK_MISC (menu_widget), 0.0, 0.5); - } - - if (position == -1) - { - gtk_notebook_append_page_menu (GTK_NOTEBOOK (dockbook), - GTK_WIDGET (dockable), - tab_widget, - menu_widget); - } - else - { - gtk_notebook_insert_page_menu (GTK_NOTEBOOK (dockbook), - GTK_WIDGET (dockable), - tab_widget, - menu_widget, - position); - } - - gtk_widget_show (GTK_WIDGET (dockable)); - - gtk_drag_source_set (GTK_WIDGET (tab_widget), - GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, - dialog_target_table, n_dialog_targets, - GDK_ACTION_MOVE); - gtk_signal_connect (GTK_OBJECT (tab_widget), "drag_begin", - GTK_SIGNAL_FUNC (gimp_dockbook_tab_drag_begin), - dockable); - gtk_signal_connect (GTK_OBJECT (tab_widget), "drag_end", - GTK_SIGNAL_FUNC (gimp_dockbook_tab_drag_end), - dockable); - - gtk_drag_dest_set (GTK_WIDGET (tab_widget), - GTK_DEST_DEFAULT_ALL, - dialog_target_table, n_dialog_targets, - GDK_ACTION_MOVE); - gtk_signal_connect (GTK_OBJECT (tab_widget), "drag_drop", - GTK_SIGNAL_FUNC (gimp_dockbook_tab_drag_drop), - dockbook); - - dockable->dockbook = dockbook; - - if (g_list_length (gtk_container_children (GTK_CONTAINER (dockbook))) == 1) - { - GtkWidget *item; - - item = gtk_menu_item_new (); - gtk_menu_append (GTK_MENU (GTK_NOTEBOOK (dockbook)->menu), item); - gtk_widget_set_sensitive (item, FALSE); - gtk_widget_show (item); - - item = gtk_menu_item_new_with_label ("Test"); - gtk_menu_append (GTK_MENU (GTK_NOTEBOOK (dockbook)->menu), item); - gtk_widget_show (item); - } -} - -void -gimp_dockbook_remove (GimpDockbook *dockbook, - GimpDockable *dockable) -{ - g_return_if_fail (dockbook != NULL); - g_return_if_fail (GIMP_IS_DOCKBOOK (dockbook)); - - g_return_if_fail (dockable != NULL); - g_return_if_fail (GIMP_IS_DOCKABLE (dockable)); - - g_return_if_fail (dockable->dockbook != NULL); - g_return_if_fail (dockable->dockbook == dockbook); - - if (g_list_length (gtk_container_children (GTK_CONTAINER (dockbook))) == 1) - { - while (GTK_MENU_SHELL (GTK_NOTEBOOK (dockbook)->menu)->children->next) - gtk_widget_destroy (GTK_WIDGET (GTK_MENU_SHELL (GTK_NOTEBOOK (dockbook)->menu)->children->next->data)); - } - - dockable->dockbook = NULL; - - gtk_container_remove (GTK_CONTAINER (dockbook), GTK_WIDGET (dockable)); - - if (! g_list_length (gtk_container_children (GTK_CONTAINER (dockbook)))) - { - gimp_dock_remove_book (dockbook->dock, dockbook); - } -} - -static gboolean -gimp_dockbook_tab_button_press (GtkWidget *widget, - GdkEventButton *bevent, - gpointer data) -{ - GimpDockable *dockable; - gint page_num; - - dockable = GIMP_DOCKABLE (data); - - switch (bevent->button) - { - case 3: - gtk_menu_popup (GTK_MENU (GTK_NOTEBOOK (dockable->dockbook)->menu), - NULL, NULL, - NULL, NULL, 3, bevent->time); - break; - - default: - page_num = gtk_notebook_page_num (GTK_NOTEBOOK (dockable->dockbook), - GTK_WIDGET (dockable)); - - gtk_notebook_set_page (GTK_NOTEBOOK (dockable->dockbook), page_num); - break; - } - - return FALSE; -} - -static void -gimp_dockbook_tab_drag_begin (GtkWidget *widget, - GdkDragContext *context, - gpointer data) -{ - GimpDockable *dockable; - GtkWidget *window; - GtkWidget *frame; - GtkWidget *preview; - - dockable = GIMP_DOCKABLE (data); - - window = gtk_window_new (GTK_WINDOW_POPUP); - - frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT); - gtk_container_add (GTK_CONTAINER (window), frame); - gtk_widget_show (frame); - - preview = gimp_dockable_get_tab_widget (dockable, 24); - - if (! GTK_IS_LABEL (preview)) - { - GtkWidget *hbox; - GtkWidget *label; - - hbox = gtk_hbox_new (FALSE, 2); - gtk_container_set_border_width (GTK_CONTAINER (hbox), 2); - - gtk_box_pack_start (GTK_BOX (hbox), preview, FALSE, FALSE, 0); - gtk_widget_show (preview); - - label = gtk_label_new (dockable->name); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 2); - gtk_widget_show (label); - - preview = hbox; - } - else - { - gtk_widget_destroy (preview); - - preview = gtk_label_new (dockable->name); - gtk_misc_set_padding (GTK_MISC (preview), 10, 5); - } - - gtk_container_add (GTK_CONTAINER (frame), preview); - gtk_widget_show (preview); - - gtk_widget_show (window); - - gtk_object_set_data_full (GTK_OBJECT (dockable), "gimp_dock_drag_widget", - window, - (GtkDestroyNotify) gtk_widget_destroy); - - gtk_drag_set_icon_widget (context, window, - -8, -8); -} - -static void -gimp_dockbook_tab_drag_end (GtkWidget *widget, - GdkDragContext *context, - gpointer data) -{ - GimpDockable *dockable; - GtkWidget *drag_widget; - - dockable = GIMP_DOCKABLE (data); - - drag_widget = gtk_object_get_data (GTK_OBJECT (dockable), - "gimp_dock_drag_widget"); - - if (drag_widget) - { - GtkWidget *dock; - GtkWidget *dockbook; - - gtk_object_set_data (GTK_OBJECT (dockable), "gimp_dock_drag_widget", NULL); - - dock = gimp_dock_new (); - - gtk_window_set_position (GTK_WINDOW (dock), GTK_WIN_POS_MOUSE); - - dockbook = gimp_dockbook_new (); - - gimp_dock_add_book (GIMP_DOCK (dock), GIMP_DOCKBOOK (dockbook), 0); - - gtk_object_ref (GTK_OBJECT (dockable)); - - gimp_dockbook_remove (dockable->dockbook, dockable); - gimp_dockbook_add (GIMP_DOCKBOOK (dockbook), dockable, 0); - - gtk_object_unref (GTK_OBJECT (dockable)); - - gtk_widget_show (dock); - } -} - -static gboolean -gimp_dockbook_tab_drag_drop (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time, - gpointer data) -{ - GimpDockable *dest_dockable; - GtkWidget *source; - - dest_dockable = (GimpDockable *) gtk_object_get_data (GTK_OBJECT (widget), - "gimp_dockable"); - - source = gtk_drag_get_source_widget (context); - - if (source) - { - GimpDockable *src_dockable; - - src_dockable = (GimpDockable *) gtk_object_get_data (GTK_OBJECT (source), - "gimp_dockable"); - - if (src_dockable) - { - gint page_index; - - page_index = - gtk_notebook_page_num (GTK_NOTEBOOK (dest_dockable->dockbook), - GTK_WIDGET (dest_dockable)); - - gtk_object_set_data (GTK_OBJECT (src_dockable), - "gimp_dock_drag_widget", NULL); - - if (src_dockable->dockbook != dest_dockable->dockbook) - { - gtk_object_ref (GTK_OBJECT (src_dockable)); - - gimp_dockbook_remove (src_dockable->dockbook, src_dockable); - gimp_dockbook_add (dest_dockable->dockbook, src_dockable, - page_index); - - gtk_object_unref (GTK_OBJECT (src_dockable)); - - return TRUE; - } - else if (src_dockable != dest_dockable) - { - gtk_notebook_reorder_child (GTK_NOTEBOOK (src_dockable->dockbook), - GTK_WIDGET (src_dockable), - page_index); - - return TRUE; - } - } - } - - return FALSE; -} diff --git a/app/gimpdockbook.h b/app/gimpdockbook.h deleted file mode 100644 index ef4f5838ac..0000000000 --- a/app/gimpdockbook.h +++ /dev/null @@ -1,61 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * gimpdockbook.h - * Copyright (C) 2001 Michael Natterer - * - * 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_DOCKBOOK_H__ -#define __GIMP_DOCKBOOK_H__ - - -#include - - -#define GIMP_TYPE_DOCKBOOK (gimp_dockbook_get_type ()) -#define GIMP_DOCKBOOK(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DOCKBOOK, GimpDockbook)) -#define GIMP_DOCKBOOK_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DOCKBOOK, GimpDockbookClass)) -#define GIMP_IS_DOCKBOOK(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DOCKBOOK)) -#define GIMP_IS_DOCKBOOK_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DOCKBOOK)) - - -typedef struct _GimpDockbookClass GimpDockbookClass; - -struct _GimpDockbook -{ - GtkNotebook parent_instance; - - GimpDock *dock; -}; - -struct _GimpDockbookClass -{ - GtkNotebookClass parent_class; -}; - - -GtkType gimp_dockbook_get_type (void); -GtkWidget * gimp_dockbook_new (void); - -void gimp_dockbook_add (GimpDockbook *dockbook, - GimpDockable *dockable, - gint position); -void gimp_dockbook_remove (GimpDockbook *dockbook, - GimpDockable *dockable); - - -#endif /* __GIMP_DOCKBOOK_H__ */ diff --git a/app/gimpdrawable-preview.c b/app/gimpdrawable-preview.c index da78afeb51..0d7a2bdb00 100644 --- a/app/gimpdrawable-preview.c +++ b/app/gimpdrawable-preview.c @@ -28,10 +28,11 @@ #include "paint-funcs/paint-funcs.h" +#include "widgets/gimpdrawablepreview.h" + #include "gimpchannel.h" #include "gimpimage.h" #include "gimpdrawable.h" -#include "gimpdrawablepreview.h" #include "gimplayer.h" #include "gimppreviewcache.h" #include "pixel_region.h" diff --git a/app/gimpdrawablelistitem.c b/app/gimpdrawablelistitem.c deleted file mode 100644 index d10da6be36..0000000000 --- a/app/gimpdrawablelistitem.c +++ /dev/null @@ -1,385 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * gimpdrawablelistitem.c - * Copyright (C) 2001 Michael Natterer - * - * 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 - -#include "libgimpwidgets/gimpwidgets.h" - -#include "apptypes.h" - -#include "drawable.h" -#include "gdisplay.h" -#include "gimpcontainer.h" -#include "gimpdnd.h" -#include "gimpdrawablelistitem.h" -#include "gimpdrawablelistview.h" -#include "gimpimage.h" -#include "gimppreview.h" -#include "gimpviewable.h" - -#include "pixmaps/eye.xpm" - - -static void gimp_drawable_list_item_class_init (GimpDrawableListItemClass *klass); -static void gimp_drawable_list_item_init (GimpDrawableListItem *list_item); - -static void gimp_drawable_list_item_set_viewable (GimpListItem *list_item, - GimpViewable *viewable); - -static gboolean gimp_drawable_list_item_drag_motion (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time); -static gboolean gimp_drawable_list_item_drag_drop (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time); - -static void gimp_drawable_list_item_eye_toggled (GtkWidget *widget, - gpointer data); - -static void gimp_drawable_list_item_visibility_changed (GimpDrawable *drawable, - gpointer data); -static void gimp_drawable_list_item_button_realize (GtkWidget *widget, - gpointer data); -static void gimp_drawable_list_item_button_state_changed (GtkWidget *widget, - GtkStateType previous_state, - gpointer data); - - -static GimpListItemClass *parent_class = NULL; - - -GtkType -gimp_drawable_list_item_get_type (void) -{ - static GtkType list_item_type = 0; - - if (! list_item_type) - { - static const GtkTypeInfo list_item_info = - { - "GimpDrawableListItem", - sizeof (GimpDrawableListItem), - sizeof (GimpDrawableListItemClass), - (GtkClassInitFunc) gimp_drawable_list_item_class_init, - (GtkObjectInitFunc) gimp_drawable_list_item_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - list_item_type = gtk_type_unique (GIMP_TYPE_LIST_ITEM, &list_item_info); - } - - return list_item_type; -} - -static void -gimp_drawable_list_item_class_init (GimpDrawableListItemClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GimpListItemClass *list_item_class; - - object_class = (GtkObjectClass *) klass; - widget_class = (GtkWidgetClass *) klass; - list_item_class = (GimpListItemClass *) klass; - - parent_class = gtk_type_class (GIMP_TYPE_LIST_ITEM); - - widget_class->drag_motion = gimp_drawable_list_item_drag_motion; - widget_class->drag_drop = gimp_drawable_list_item_drag_drop; - - list_item_class->set_viewable = gimp_drawable_list_item_set_viewable; -} - -static void -gimp_drawable_list_item_init (GimpDrawableListItem *list_item) -{ - GtkWidget *abox; - GtkWidget *pixmap; - - abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0); - gtk_box_pack_start (GTK_BOX (GIMP_LIST_ITEM (list_item)->hbox), abox, - FALSE, FALSE, 0); - gtk_widget_show (abox); - - list_item->eye_button = gtk_toggle_button_new (); - gtk_button_set_relief (GTK_BUTTON (list_item->eye_button), GTK_RELIEF_NONE); - gtk_container_add (GTK_CONTAINER (abox), list_item->eye_button); - gtk_widget_show (list_item->eye_button); - - gtk_signal_connect (GTK_OBJECT (list_item->eye_button), "realize", - GTK_SIGNAL_FUNC (gimp_drawable_list_item_button_realize), - list_item); - - gtk_signal_connect (GTK_OBJECT (list_item->eye_button), "state_changed", - GTK_SIGNAL_FUNC (gimp_drawable_list_item_button_state_changed), - list_item); - - pixmap = gimp_pixmap_new (eye_xpm); - gtk_container_add (GTK_CONTAINER (list_item->eye_button), pixmap); - gtk_widget_show (pixmap); -} - -static void -gimp_drawable_list_item_set_viewable (GimpListItem *list_item, - GimpViewable *viewable) -{ - GimpDrawableListItem *drawable_item; - GimpDrawable *drawable; - gboolean visible; - - if (GIMP_LIST_ITEM_CLASS (parent_class)->set_viewable) - GIMP_LIST_ITEM_CLASS (parent_class)->set_viewable (list_item, viewable); - - GIMP_PREVIEW (list_item->preview)->clickable = TRUE; - - drawable_item = GIMP_DRAWABLE_LIST_ITEM (list_item); - drawable = GIMP_DRAWABLE (GIMP_PREVIEW (list_item->preview)->viewable); - visible = gimp_drawable_get_visible (drawable); - - if (! visible) - { - GtkRequisition requisition; - - gtk_widget_size_request (drawable_item->eye_button, &requisition); - - gtk_widget_set_usize (drawable_item->eye_button, - requisition.width, - requisition.height); - gtk_widget_hide (GTK_BIN (drawable_item->eye_button)->child); - } - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (drawable_item->eye_button), - visible); - - gtk_signal_connect (GTK_OBJECT (drawable_item->eye_button), "toggled", - GTK_SIGNAL_FUNC (gimp_drawable_list_item_eye_toggled), - list_item); - - gtk_signal_connect_while_alive - (GTK_OBJECT (viewable), "visibility_changed", - GTK_SIGNAL_FUNC (gimp_drawable_list_item_visibility_changed), - list_item, - GTK_OBJECT (list_item)); -} - -static gboolean -gimp_drawable_list_item_drag_motion (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time) -{ - GimpListItem *list_item; - GimpViewable *src_viewable; - gint dest_index; - GdkDragAction drag_action; - GimpDropType drop_type; - gboolean return_val; - - list_item = GIMP_LIST_ITEM (widget); - - return_val = gimp_list_item_check_drag (list_item, context, x, y, - &src_viewable, - &dest_index, - &drag_action, - &drop_type); - - gdk_drag_status (context, drag_action, time); - - list_item->drop_type = drop_type; - - return return_val; -} - -static gboolean -gimp_drawable_list_item_drag_drop (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time) -{ - GimpListItem *list_item; - GimpViewable *src_viewable; - gint dest_index; - GdkDragAction drag_action; - GimpDropType drop_type; - gboolean return_val; - - list_item = GIMP_LIST_ITEM (widget); - - return_val = gimp_list_item_check_drag (list_item, context, x, y, - &src_viewable, - &dest_index, - &drag_action, - &drop_type); - - gtk_drag_finish (context, return_val, FALSE, time); - - list_item->drop_type = GIMP_DROP_NONE; - - if (return_val) - { - if (widget->parent && GIMP_IS_DRAWABLE_LIST_VIEW (widget->parent)) - { - GimpDrawableListView *list_view; - - list_view = GIMP_DRAWABLE_LIST_VIEW (widget->parent); - - list_view->reorder_drawable_func (list_view->gimage, - GIMP_DRAWABLE (src_viewable), - dest_index, - TRUE); - - gdisplays_flush (); - } - else - { - g_warning ("%s(): GimpDrawableListItem is not " - "part of a GimpDrawableListView", G_GNUC_FUNCTION); - } - } - - return return_val; -} - -static void -gimp_drawable_list_item_eye_toggled (GtkWidget *widget, - gpointer data) -{ - GimpListItem *list_item; - GimpDrawable *drawable; - gboolean visible; - - list_item = GIMP_LIST_ITEM (data); - drawable = GIMP_DRAWABLE (GIMP_PREVIEW (list_item->preview)->viewable); - visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); - - if (visible != gimp_drawable_get_visible (drawable)) - { - if (! visible) - { - gtk_widget_set_usize (GTK_WIDGET (widget), - GTK_WIDGET (widget)->allocation.width, - GTK_WIDGET (widget)->allocation.height); - gtk_widget_hide (GTK_BIN (widget)->child); - } - else - { - gtk_widget_show (GTK_BIN (widget)->child); - gtk_widget_set_usize (GTK_WIDGET (widget), -1, -1); - } - - gtk_signal_handler_block_by_func (GTK_OBJECT (drawable), - gimp_drawable_list_item_visibility_changed, - list_item); - - gimp_drawable_set_visible (drawable, visible); - - gtk_signal_handler_unblock_by_func (GTK_OBJECT (drawable), - gimp_drawable_list_item_visibility_changed, - list_item); - - drawable_update (drawable, 0, 0, - drawable->width, - drawable->height); - - gdisplays_flush (); - } -} - -static void -gimp_drawable_list_item_visibility_changed (GimpDrawable *drawable, - gpointer data) -{ - GimpListItem *list_item; - GtkToggleButton *toggle; - gboolean visible; - - list_item = GIMP_LIST_ITEM (data); - toggle = GTK_TOGGLE_BUTTON (GIMP_DRAWABLE_LIST_ITEM (data)->eye_button); - visible = gimp_drawable_get_visible (drawable); - - if (visible != toggle->active) - { - if (! visible) - { - gtk_widget_set_usize (GTK_WIDGET (toggle), - GTK_WIDGET (toggle)->allocation.width, - GTK_WIDGET (toggle)->allocation.height); - gtk_widget_hide (GTK_BIN (toggle)->child); - } - else - { - gtk_widget_show (GTK_BIN (toggle)->child); - gtk_widget_set_usize (GTK_WIDGET (toggle), -1, -1); - } - - gtk_signal_handler_block_by_func (GTK_OBJECT (toggle), - gimp_drawable_list_item_eye_toggled, - list_item); - - gtk_toggle_button_set_active (toggle, visible); - - gtk_signal_handler_unblock_by_func (GTK_OBJECT (toggle), - gimp_drawable_list_item_eye_toggled, - list_item); - } -} - -static void -gimp_drawable_list_item_button_realize (GtkWidget *widget, - gpointer data) -{ - gdk_window_set_back_pixmap (widget->window, NULL, TRUE); -} - -static void -gimp_drawable_list_item_button_state_changed (GtkWidget *widget, - GtkStateType previous_state, - gpointer data) -{ - GtkWidget *list_item; - - list_item = GTK_WIDGET (data); - - if (widget->state != list_item->state) - { - switch (widget->state) - { - case GTK_STATE_NORMAL: - case GTK_STATE_ACTIVE: - /* beware: recursion */ - gtk_widget_set_state (widget, list_item->state); - break; - - default: - break; - } - } -} diff --git a/app/gimpdrawablelistitem.h b/app/gimpdrawablelistitem.h deleted file mode 100644 index 428c44bbc3..0000000000 --- a/app/gimpdrawablelistitem.h +++ /dev/null @@ -1,64 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * gimpdrawablelistitem.h - * Copyright (C) 2001 Michael Natterer - * - * 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_DRAWABLE_LIST_ITEM_H__ -#define __GIMP_DRAWABLE_LIST_ITEM_H__ - - -#include "gimplistitem.h" - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -#define GIMP_TYPE_DRAWABLE_LIST_ITEM (gimp_drawable_list_item_get_type ()) -#define GIMP_DRAWABLE_LIST_ITEM(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DRAWABLE_LIST_ITEM, GimpDrawableListItem)) -#define GIMP_DRAWABLE_LIST_ITEM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DRAWABLE_LIST_ITEM, GimpDrawableListItemClass)) -#define GIMP_IS_DRAWABLE_LIST_ITEM(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DRAWABLE_LIST_ITEM)) -#define GIMP_IS_DRAWABLE_LIST_ITEM_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DRAWABLE_LIST_ITEM)) - - -typedef struct _GimpDrawableListItemClass GimpDrawableListItemClass; - -struct _GimpDrawableListItem -{ - GimpListItem parent_instance; - - GtkWidget *eye_button; -}; - -struct _GimpDrawableListItemClass -{ - GimpListItemClass parent_class; -}; - - -GtkType gimp_drawable_list_item_get_type (void); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __GIMP_DRAWABLE_LIST_ITEM_H__ */ diff --git a/app/gimpdrawablelistview.c b/app/gimpdrawablelistview.c deleted file mode 100644 index dacafa9d53..0000000000 --- a/app/gimpdrawablelistview.c +++ /dev/null @@ -1,731 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * 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 - -#include "libgimpmath/gimpmath.h" -#include "libgimpwidgets/gimpwidgets.h" - -#include "apptypes.h" - -#include "gdisplay.h" -#include "gimpcontainer.h" -#include "gimpdrawable.h" -#include "gimpdrawablelistview.h" -#include "gimpdnd.h" -#include "gimpimage.h" -#include "gimplayer.h" -#include "gimplayerlistview.h" -#include "gimplistitem.h" -#include "gimpmarshal.h" -#include "gimprc.h" -#include "gimpviewable.h" - -#include "libgimp/gimpintl.h" - -#include "pixmaps/delete.xpm" -#include "pixmaps/raise.xpm" -#include "pixmaps/lower.xpm" -#include "pixmaps/duplicate.xpm" -#include "pixmaps/new.xpm" -#include "pixmaps/edit.xpm" - - -static void gimp_drawable_list_view_class_init (GimpDrawableListViewClass *klass); -static void gimp_drawable_list_view_init (GimpDrawableListView *view); -static void gimp_drawable_list_view_destroy (GtkObject *object); - -static gpointer gimp_drawable_list_view_insert_item (GimpContainerView *view, - GimpViewable *viewable, - gint index); -static void gimp_drawable_list_view_select_item (GimpContainerView *view, - GimpViewable *item, - gpointer insert_data); -static void gimp_drawable_list_view_activate_item (GimpContainerView *view, - GimpViewable *item, - gpointer insert_data); - -static void gimp_drawable_list_view_new_drawable (GimpDrawableListView *view, - GimpDrawable *drawable); -static void gimp_drawable_list_view_new_clicked (GtkWidget *widget, - GimpDrawableListView *view); -static void gimp_drawable_list_view_new_dropped (GtkWidget *widget, - GimpViewable *viewable, - gpointer data); - -static void gimp_drawable_list_view_raise_clicked (GtkWidget *widget, - GimpDrawableListView *view); -static void gimp_drawable_list_view_lower_clicked (GtkWidget *widget, - GimpDrawableListView *view); - -static void gimp_drawable_list_view_duplicate_drawable (GimpDrawableListView *view, - GimpDrawable *drawable); -static void gimp_drawable_list_view_duplicate_clicked (GtkWidget *widget, - GimpDrawableListView *view); -static void gimp_drawable_list_view_duplicate_dropped (GtkWidget *widget, - GimpViewable *viewable, - gpointer drawable); - -static void gimp_drawable_list_view_edit_drawable (GimpDrawableListView *view, - GimpDrawable *drawable); -static void gimp_drawable_list_view_edit_clicked (GtkWidget *widget, - GimpDrawableListView *view); -static void gimp_drawable_list_view_edit_dropped (GtkWidget *widget, - GimpViewable *viewable, - gpointer drawable); - -static void gimp_drawable_list_view_delete_drawable (GimpDrawableListView *view, - GimpDrawable *drawable); -static void gimp_drawable_list_view_delete_clicked (GtkWidget *widget, - GimpDrawableListView *view); -static void gimp_drawable_list_view_delete_dropped (GtkWidget *widget, - GimpViewable *viewable, - gpointer drawable); - -static void gimp_drawable_list_view_drawable_changed (GimpImage *gimage, - GimpDrawableListView *view); - - -static GimpContainerListViewClass *parent_class = NULL; - - -GtkType -gimp_drawable_list_view_get_type (void) -{ - static guint view_type = 0; - - if (! view_type) - { - GtkTypeInfo view_info = - { - "GimpDrawableListView", - sizeof (GimpDrawableListView), - sizeof (GimpDrawableListViewClass), - (GtkClassInitFunc) gimp_drawable_list_view_class_init, - (GtkObjectInitFunc) gimp_drawable_list_view_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL - }; - - view_type = gtk_type_unique (GIMP_TYPE_CONTAINER_LIST_VIEW, &view_info); - } - - return view_type; -} - -static void -gimp_drawable_list_view_class_init (GimpDrawableListViewClass *klass) -{ - GtkObjectClass *object_class; - GimpContainerViewClass *container_view_class; - - object_class = (GtkObjectClass *) klass; - container_view_class = (GimpContainerViewClass *) klass; - - parent_class = gtk_type_class (GIMP_TYPE_CONTAINER_LIST_VIEW); - - object_class->destroy = gimp_drawable_list_view_destroy; - - container_view_class->insert_item = gimp_drawable_list_view_insert_item; - container_view_class->select_item = gimp_drawable_list_view_select_item; - container_view_class->activate_item = gimp_drawable_list_view_activate_item; -} - -static void -gimp_drawable_list_view_init (GimpDrawableListView *view) -{ - GtkWidget *pixmap; - - view->gimage = NULL; - view->drawable_type = GTK_TYPE_NONE; - view->signal_name = NULL; - - gtk_box_set_spacing (GTK_BOX (view), 2); - - view->button_box = gtk_hbox_new (TRUE, 2); - gtk_box_pack_end (GTK_BOX (view), view->button_box, FALSE, FALSE, 0); - gtk_widget_show (view->button_box); - - /* new */ - - view->new_button = gtk_button_new (); - gtk_box_pack_start (GTK_BOX (view->button_box), view->new_button, - TRUE, TRUE, 0); - gtk_widget_show (view->new_button); - - gimp_help_set_help_data (view->new_button, _("New"), NULL); - - gtk_signal_connect (GTK_OBJECT (view->new_button), "clicked", - GTK_SIGNAL_FUNC (gimp_drawable_list_view_new_clicked), - view); - - pixmap = gimp_pixmap_new (new_xpm); - gtk_container_add (GTK_CONTAINER (view->new_button), pixmap); - gtk_widget_show (pixmap); - - /* raise */ - - view->raise_button = gtk_button_new (); - gtk_box_pack_start (GTK_BOX (view->button_box), view->raise_button, - TRUE, TRUE, 0); - gtk_widget_show (view->raise_button); - - gimp_help_set_help_data (view->raise_button, _("Raise"), NULL); - - gtk_signal_connect (GTK_OBJECT (view->raise_button), "clicked", - GTK_SIGNAL_FUNC (gimp_drawable_list_view_raise_clicked), - view); - - pixmap = gimp_pixmap_new (raise_xpm); - gtk_container_add (GTK_CONTAINER (view->raise_button), pixmap); - gtk_widget_show (pixmap); - - /* lower */ - - view->lower_button = gtk_button_new (); - gtk_box_pack_start (GTK_BOX (view->button_box), view->lower_button, - TRUE, TRUE, 0); - gtk_widget_show (view->lower_button); - - gimp_help_set_help_data (view->lower_button, _("Lower"), NULL); - - gtk_signal_connect (GTK_OBJECT (view->lower_button), "clicked", - GTK_SIGNAL_FUNC (gimp_drawable_list_view_lower_clicked), - view); - - pixmap = gimp_pixmap_new (lower_xpm); - gtk_container_add (GTK_CONTAINER (view->lower_button), pixmap); - gtk_widget_show (pixmap); - - /* duplicate */ - - view->duplicate_button = gtk_button_new (); - gtk_box_pack_start (GTK_BOX (view->button_box), view->duplicate_button, - TRUE, TRUE, 0); - gtk_widget_show (view->duplicate_button); - - gimp_help_set_help_data (view->duplicate_button, _("Duplicate"), NULL); - - gtk_signal_connect (GTK_OBJECT (view->duplicate_button), "clicked", - GTK_SIGNAL_FUNC (gimp_drawable_list_view_duplicate_clicked), - view); - - pixmap = gimp_pixmap_new (duplicate_xpm); - gtk_container_add (GTK_CONTAINER (view->duplicate_button), pixmap); - gtk_widget_show (pixmap); - - /* edit */ - - view->edit_button = gtk_button_new (); - gtk_box_pack_start (GTK_BOX (view->button_box), view->edit_button, - TRUE, TRUE, 0); - gtk_widget_show (view->edit_button); - - gimp_help_set_help_data (view->edit_button, _("Edit"), NULL); - - gtk_signal_connect (GTK_OBJECT (view->edit_button), "clicked", - GTK_SIGNAL_FUNC (gimp_drawable_list_view_edit_clicked), - view); - - pixmap = gimp_pixmap_new (edit_xpm); - gtk_container_add (GTK_CONTAINER (view->edit_button), pixmap); - gtk_widget_show (pixmap); - - /* delete */ - - view->delete_button = gtk_button_new (); - gtk_box_pack_start (GTK_BOX (view->button_box), view->delete_button, - TRUE, TRUE, 0); - gtk_widget_show (view->delete_button); - - gimp_help_set_help_data (view->delete_button, _("Delete"), NULL); - - gtk_signal_connect (GTK_OBJECT (view->delete_button), "clicked", - GTK_SIGNAL_FUNC (gimp_drawable_list_view_delete_clicked), - view); - - pixmap = gimp_pixmap_new (delete_xpm); - gtk_container_add (GTK_CONTAINER (view->delete_button), pixmap); - gtk_widget_show (pixmap); - - gtk_widget_set_sensitive (view->new_button, FALSE); - gtk_widget_set_sensitive (view->raise_button, FALSE); - gtk_widget_set_sensitive (view->lower_button, FALSE); - gtk_widget_set_sensitive (view->duplicate_button, FALSE); - gtk_widget_set_sensitive (view->edit_button, FALSE); - gtk_widget_set_sensitive (view->delete_button, FALSE); -} - -static void -gimp_drawable_list_view_destroy (GtkObject *object) -{ - GimpDrawableListView *view; - - view = GIMP_DRAWABLE_LIST_VIEW (object); - - g_free (view->signal_name); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gimp_drawable_list_view_new (GimpImage *gimage, - GtkType drawable_type, - const gchar *signal_name, - GimpGetContainerFunc get_container_func, - GimpGetDrawableFunc get_drawable_func, - GimpSetDrawableFunc set_drawable_func, - GimpReorderDrawableFunc reorder_drawable_func, - GimpAddDrawableFunc add_drawable_func, - GimpRemoveDrawableFunc remove_drawable_func, - GimpCopyDrawableFunc copy_drawable_func) -{ - GimpDrawableListView *list_view; - GimpContainerView *view; - - g_return_val_if_fail (! gimage || GIMP_IS_IMAGE (gimage), NULL); - g_return_val_if_fail (signal_name != NULL, NULL); - g_return_val_if_fail (get_container_func != NULL, NULL); - g_return_val_if_fail (get_drawable_func != NULL, NULL); - g_return_val_if_fail (get_drawable_func != NULL, NULL); - g_return_val_if_fail (reorder_drawable_func != NULL, NULL); - g_return_val_if_fail (add_drawable_func != NULL, NULL); - g_return_val_if_fail (remove_drawable_func != NULL, NULL); - g_return_val_if_fail (copy_drawable_func != NULL, NULL); - - if (drawable_type == GIMP_TYPE_LAYER) - { - list_view = gtk_type_new (GIMP_TYPE_LAYER_LIST_VIEW); - } - else - { - list_view = gtk_type_new (GIMP_TYPE_DRAWABLE_LIST_VIEW); - } - - view = GIMP_CONTAINER_VIEW (list_view); - - view->preview_size = preview_size; - - list_view->drawable_type = drawable_type; - list_view->signal_name = g_strdup (signal_name); - list_view->get_container_func = get_container_func; - list_view->get_drawable_func = get_drawable_func; - list_view->set_drawable_func = set_drawable_func; - list_view->reorder_drawable_func = reorder_drawable_func; - list_view->add_drawable_func = add_drawable_func; - list_view->remove_drawable_func = remove_drawable_func; - list_view->copy_drawable_func = copy_drawable_func; - - /* drop to "new" */ - gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->new_button), - GTK_DEST_DEFAULT_ALL, - drawable_type, - GDK_ACTION_COPY); - gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->new_button), - drawable_type, - gimp_drawable_list_view_new_dropped, - list_view); - - /* drop to "duplicate" */ - gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->duplicate_button), - GTK_DEST_DEFAULT_ALL, - drawable_type, - GDK_ACTION_COPY); - gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->duplicate_button), - drawable_type, - gimp_drawable_list_view_duplicate_dropped, - list_view); - - /* drop to "edit" */ - gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->edit_button), - GTK_DEST_DEFAULT_ALL, - drawable_type, - GDK_ACTION_COPY); - gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->edit_button), - drawable_type, - gimp_drawable_list_view_edit_dropped, - list_view); - - /* drop to "delete" */ - gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_view->delete_button), - GTK_DEST_DEFAULT_ALL, - drawable_type, - GDK_ACTION_COPY); - gimp_dnd_viewable_dest_set (GTK_WIDGET (list_view->delete_button), - drawable_type, - gimp_drawable_list_view_delete_dropped, - list_view); - - if (gimage) - gimp_drawable_list_view_set_image (list_view, gimage); - - return GTK_WIDGET (list_view); -} - -void -gimp_drawable_list_view_set_image (GimpDrawableListView *view, - GimpImage *gimage) -{ - g_return_if_fail (view != NULL); - g_return_if_fail (GIMP_IS_DRAWABLE_LIST_VIEW (view)); - g_return_if_fail (! gimage || GIMP_IS_IMAGE (gimage)); - - if (view->gimage == gimage) - return; - - if (view->gimage) - { - gtk_signal_disconnect_by_func (GTK_OBJECT (view->gimage), - gimp_drawable_list_view_drawable_changed, - view); - - gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view), NULL); - } - - view->gimage = gimage; - - if (view->gimage) - { - GimpContainer *container; - - container = view->get_container_func (view->gimage); - - gimp_container_view_set_container (GIMP_CONTAINER_VIEW (view), container); - - gtk_signal_connect (GTK_OBJECT (view->gimage), view->signal_name, - GTK_SIGNAL_FUNC (gimp_drawable_list_view_drawable_changed), - view); - - gimp_drawable_list_view_drawable_changed (view->gimage, view); - } - - gtk_widget_set_sensitive (view->new_button, (view->gimage != NULL)); -} - - -/* GimpContainerView methods */ - -static gpointer -gimp_drawable_list_view_insert_item (GimpContainerView *view, - GimpViewable *viewable, - gint index) -{ - gpointer list_item = NULL; - - if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->insert_item) - list_item = GIMP_CONTAINER_VIEW_CLASS (parent_class)->insert_item (view, - viewable, - index); - - if (list_item) - gimp_list_item_set_reorderable (GIMP_LIST_ITEM (list_item), - TRUE, view->container); - - return list_item; -} - -static void -gimp_drawable_list_view_select_item (GimpContainerView *view, - GimpViewable *item, - gpointer insert_data) -{ - GimpDrawableListView *list_view; - gboolean raise_sensitive = FALSE; - gboolean lower_sensitive = FALSE; - gboolean duplicate_sensitive = FALSE; - gboolean edit_sensitive = FALSE; - gboolean delete_sensitive = FALSE; - - list_view = GIMP_DRAWABLE_LIST_VIEW (view); - - if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->select_item) - GIMP_CONTAINER_VIEW_CLASS (parent_class)->select_item (view, - item, - insert_data); - - if (item) - { - GimpDrawable *drawable; - gint index; - - drawable = list_view->get_drawable_func (list_view->gimage); - - if (drawable != GIMP_DRAWABLE (item)) - { - list_view->set_drawable_func (list_view->gimage, - GIMP_DRAWABLE (item)); - - gdisplays_flush (); - } - - index = gimp_container_get_child_index (view->container, - GIMP_OBJECT (item)); - - if (view->container->num_children > 1) - { - if (index > 0) - raise_sensitive = TRUE; - - if (index < (view->container->num_children - 1)) - lower_sensitive = TRUE; - } - - duplicate_sensitive = TRUE; - edit_sensitive = TRUE; - delete_sensitive = TRUE; - } - - gtk_widget_set_sensitive (list_view->raise_button, raise_sensitive); - gtk_widget_set_sensitive (list_view->lower_button, lower_sensitive); - gtk_widget_set_sensitive (list_view->duplicate_button, duplicate_sensitive); - gtk_widget_set_sensitive (list_view->edit_button, edit_sensitive); - gtk_widget_set_sensitive (list_view->delete_button, delete_sensitive); -} - -static void -gimp_drawable_list_view_activate_item (GimpContainerView *view, - GimpViewable *item, - gpointer insert_data) -{ - if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->activate_item) - GIMP_CONTAINER_VIEW_CLASS (parent_class)->activate_item (view, - item, - insert_data); - - gimp_drawable_list_view_edit_drawable (GIMP_DRAWABLE_LIST_VIEW (view), - GIMP_DRAWABLE (item)); -} - - -/* "New" functions */ - -static void -gimp_drawable_list_view_new_drawable (GimpDrawableListView *view, - GimpDrawable *drawable) -{ - if (drawable) - g_print ("new with \"%s\"'s properties\n", GIMP_OBJECT (drawable)->name); - else - g_print ("new default\n"); -} - -static void -gimp_drawable_list_view_new_clicked (GtkWidget *widget, - GimpDrawableListView *view) -{ - gimp_drawable_list_view_new_drawable (view, NULL); -} - -static void -gimp_drawable_list_view_new_dropped (GtkWidget *widget, - GimpViewable *viewable, - gpointer data) -{ - GimpDrawableListView *view; - - view = (GimpDrawableListView *) data; - - if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container, - GIMP_OBJECT (viewable))) - { - gimp_drawable_list_view_new_drawable (view, GIMP_DRAWABLE (viewable)); - } -} - - -/* "Duplicate" functions */ - -static void -gimp_drawable_list_view_duplicate_drawable (GimpDrawableListView *view, - GimpDrawable *drawable) -{ - GimpDrawable *new_drawable; - - new_drawable = view->copy_drawable_func (drawable, TRUE); - view->add_drawable_func (view->gimage, new_drawable, -1); - - gdisplays_flush (); -} - -static void -gimp_drawable_list_view_duplicate_clicked (GtkWidget *widget, - GimpDrawableListView *view) -{ - GimpDrawable *drawable; - - drawable = view->get_drawable_func (view->gimage); - - gimp_drawable_list_view_duplicate_drawable (view, drawable); -} - -static void -gimp_drawable_list_view_duplicate_dropped (GtkWidget *widget, - GimpViewable *viewable, - gpointer data) -{ - GimpDrawableListView *view; - - view = (GimpDrawableListView *) data; - - if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container, - GIMP_OBJECT (viewable))) - { - gimp_drawable_list_view_duplicate_drawable (view, - GIMP_DRAWABLE (viewable)); - } -} - - -/* "Raise/Lower" functions */ - -static void -gimp_drawable_list_view_raise_clicked (GtkWidget *widget, - GimpDrawableListView *view) -{ - GimpContainer *container; - GimpDrawable *drawable; - gint index; - - container = GIMP_CONTAINER_VIEW (view)->container; - drawable = view->get_drawable_func (view->gimage); - - index = gimp_container_get_child_index (container, GIMP_OBJECT (drawable)); - - if (index > 0) - { - view->reorder_drawable_func (view->gimage, drawable, index - 1, TRUE); - - gdisplays_flush (); - } -} - -static void -gimp_drawable_list_view_lower_clicked (GtkWidget *widget, - GimpDrawableListView *view) -{ - GimpContainer *container; - GimpDrawable *drawable; - gint index; - - container = GIMP_CONTAINER_VIEW (view)->container; - drawable = view->get_drawable_func (view->gimage); - - index = gimp_container_get_child_index (container, GIMP_OBJECT (drawable)); - - if (index < container->num_children - 1) - { - view->reorder_drawable_func (view->gimage, drawable, index + 1, TRUE); - - gdisplays_flush (); - } -} - - -/* "Edit" functions */ - -static void -gimp_drawable_list_view_edit_drawable (GimpDrawableListView *view, - GimpDrawable *drawable) -{ - g_print ("edit \"%s\"\n", GIMP_OBJECT (drawable)->name); -} - -static void -gimp_drawable_list_view_edit_clicked (GtkWidget *widget, - GimpDrawableListView *view) -{ - GimpDrawable *drawable; - - drawable = view->get_drawable_func (view->gimage); - - gimp_drawable_list_view_edit_drawable (view, drawable); -} - -static void -gimp_drawable_list_view_edit_dropped (GtkWidget *widget, - GimpViewable *viewable, - gpointer data) -{ - GimpDrawableListView *view; - - view = (GimpDrawableListView *) data; - - if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container, - GIMP_OBJECT (viewable))) - { - gimp_drawable_list_view_edit_drawable (view, GIMP_DRAWABLE (viewable)); - } -} - - -/* "Delete" functions */ - -static void -gimp_drawable_list_view_delete_drawable (GimpDrawableListView *view, - GimpDrawable *drawable) -{ - view->remove_drawable_func (view->gimage, drawable); - - gdisplays_flush (); -} - -static void -gimp_drawable_list_view_delete_clicked (GtkWidget *widget, - GimpDrawableListView *view) -{ - GimpDrawable *drawable; - - drawable = view->get_drawable_func (view->gimage); - - gimp_drawable_list_view_delete_drawable (view, drawable); -} - -static void -gimp_drawable_list_view_delete_dropped (GtkWidget *widget, - GimpViewable *viewable, - gpointer data) -{ - GimpDrawableListView *view; - - view = (GimpDrawableListView *) data; - - if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container, - GIMP_OBJECT (viewable))) - { - gimp_drawable_list_view_delete_drawable (view, GIMP_DRAWABLE (viewable)); - } -} - - -/* GimpImage callbacks */ - -static void -gimp_drawable_list_view_drawable_changed (GimpImage *gimage, - GimpDrawableListView *view) -{ - GimpDrawable *drawable; - - drawable = view->get_drawable_func (gimage); - - gimp_container_view_select_item (GIMP_CONTAINER_VIEW (view), - (GimpViewable *) drawable); -} diff --git a/app/gimpdrawablelistview.h b/app/gimpdrawablelistview.h deleted file mode 100644 index 2d897eecfa..0000000000 --- a/app/gimpdrawablelistview.h +++ /dev/null @@ -1,102 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * 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_DRAWABLE_LIST_VIEW_H__ -#define __GIMP_DRAWABLE_LIST_VIEW_H__ - - -#include "gimpcontainerlistview.h" - - -typedef GimpContainer * (* GimpGetContainerFunc) (const GimpImage *gimage); -typedef GimpDrawable * (* GimpGetDrawableFunc) (const GimpImage *gimage); -typedef void (* GimpSetDrawableFunc) (GimpImage *gimage, - GimpDrawable *drawable); -typedef void (* GimpReorderDrawableFunc) (GimpImage *gimage, - GimpDrawable *drawable, - gint new_index, - gboolean push_undo); -typedef void (* GimpAddDrawableFunc) (GimpImage *gimage, - GimpDrawable *drawable, - gint index); -typedef void (* GimpRemoveDrawableFunc) (GimpImage *gimage, - GimpDrawable *drawable); -typedef GimpDrawable * (* GimpCopyDrawableFunc) (GimpDrawable *drawable, - gboolean add_alpha); - - -#define GIMP_TYPE_DRAWABLE_LIST_VIEW (gimp_drawable_list_view_get_type ()) -#define GIMP_DRAWABLE_LIST_VIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DRAWABLE_LIST_VIEW, GimpDrawableListView)) -#define GIMP_DRAWABLE_LIST_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DRAWABLE_LIST_VIEW, GimpDrawableListViewClass)) -#define GIMP_IS_DRAWABLE_LIST_VIEW(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DRAWABLE_LIST_VIEW)) -#define GIMP_IS_DRAWABLE_LIST_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DRAWABLE_LIST_VIEW)) - - -typedef struct _GimpDrawableListViewClass GimpDrawableListViewClass; - -struct _GimpDrawableListView -{ - GimpContainerListView parent_instance; - - GimpImage *gimage; - - GtkType drawable_type; - gchar *signal_name; - - GimpGetContainerFunc get_container_func; - GimpGetDrawableFunc get_drawable_func; - GimpSetDrawableFunc set_drawable_func; - GimpReorderDrawableFunc reorder_drawable_func; - GimpAddDrawableFunc add_drawable_func; - GimpRemoveDrawableFunc remove_drawable_func; - GimpCopyDrawableFunc copy_drawable_func; - - GtkWidget *button_box; - - GtkWidget *new_button; - GtkWidget *raise_button; - GtkWidget *lower_button; - GtkWidget *duplicate_button; - GtkWidget *edit_button; - GtkWidget *delete_button; -}; - -struct _GimpDrawableListViewClass -{ - GimpContainerListViewClass parent_class; -}; - - -GtkType gimp_drawable_list_view_get_type (void); - -GtkWidget * gimp_drawable_list_view_new (GimpImage *gimage, - GtkType drawable_type, - const gchar *signal_name, - GimpGetContainerFunc get_container_func, - GimpGetDrawableFunc get_drawable_func, - GimpSetDrawableFunc set_drawable_func, - GimpReorderDrawableFunc reorder_drawable_func, - GimpAddDrawableFunc add_drawable_func, - GimpRemoveDrawableFunc remove_drawable_func, - GimpCopyDrawableFunc copy_drawable_func); - -void gimp_drawable_list_view_set_image (GimpDrawableListView *view, - GimpImage *gimage); - - -#endif /* __GIMP_DRAWABLE_LIST_VIEW_H__ */ diff --git a/app/gimpdrawablepreview.c b/app/gimpdrawablepreview.c deleted file mode 100644 index 978dc8ffbb..0000000000 --- a/app/gimpdrawablepreview.c +++ /dev/null @@ -1,321 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * GimpDrawablePreview Widget - * Copyright (C) 2001 Michael Natterer - * - * 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 - -#include "libgimpmath/gimpmath.h" - -#include "apptypes.h" - -#include "gimpdrawable.h" -#include "gimpdrawablepreview.h" -#include "gimpimage.h" -#include "temp_buf.h" - - -static void gimp_drawable_preview_class_init (GimpDrawablePreviewClass *klass); -static void gimp_drawable_preview_init (GimpDrawablePreview *preview); - -static void gimp_drawable_preview_render (GimpPreview *preview); -static void gimp_drawable_preview_get_size (GimpPreview *preview, - gint size, - gint *width, - gint *height); -static GtkWidget * gimp_drawable_preview_create_popup (GimpPreview *preview); -static void gimp_drawable_preview_calc_size (gint drawable_width, - gint drawable_height, - gint width, - gint height, - gint *return_width, - gint *return_height, - gboolean *scaling_up); - - -static GimpPreviewClass *parent_class = NULL; - - -GtkType -gimp_drawable_preview_get_type (void) -{ - static GtkType preview_type = 0; - - if (! preview_type) - { - GtkTypeInfo preview_info = - { - "GimpDrawablePreview", - sizeof (GimpDrawablePreview), - sizeof (GimpDrawablePreviewClass), - (GtkClassInitFunc) gimp_drawable_preview_class_init, - (GtkObjectInitFunc) gimp_drawable_preview_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL - }; - - preview_type = gtk_type_unique (GIMP_TYPE_PREVIEW, &preview_info); - } - - return preview_type; -} - -static void -gimp_drawable_preview_class_init (GimpDrawablePreviewClass *klass) -{ - GtkObjectClass *object_class; - GimpPreviewClass *preview_class; - - object_class = (GtkObjectClass *) klass; - preview_class = (GimpPreviewClass *) klass; - - parent_class = gtk_type_class (GIMP_TYPE_PREVIEW); - - preview_class->render = gimp_drawable_preview_render; - preview_class->get_size = gimp_drawable_preview_get_size; - preview_class->create_popup = gimp_drawable_preview_create_popup; -} - -static void -gimp_drawable_preview_init (GimpDrawablePreview *preview) -{ -} - -static void -gimp_drawable_preview_get_size (GimpPreview *preview, - gint size, - gint *width, - gint *height) -{ - GimpDrawable *drawable; - GimpImage *gimage; - gboolean scaling_up; - - drawable = GIMP_DRAWABLE (preview->viewable); - gimage = drawable->gimage; - - if (gimage) - { - gimp_drawable_preview_calc_size (gimage->width, - gimage->height, - size, - size, - width, - height, - &scaling_up); - } - else - { - gimp_drawable_preview_calc_size (drawable->width, - drawable->height, - size, - size, - width, - height, - &scaling_up); - } -} - -static void -gimp_drawable_preview_render (GimpPreview *preview) -{ - GimpDrawable *drawable; - GimpImage *gimage; - gint width; - gint height; - gint preview_width; - gint preview_height; - gboolean scaling_up; - TempBuf *render_buf; - - drawable = GIMP_DRAWABLE (preview->viewable); - gimage = drawable->gimage; - - width = preview->width; - height = preview->height; - - if (gimage && ! preview->is_popup) - { - width = MAX (1, ROUND ((((gdouble) width / (gdouble) gimage->width) * - (gdouble) drawable->width))); - height = MAX (1, ROUND ((((gdouble) height / (gdouble) gimage->height) * - (gdouble) drawable->height))); - - gimp_drawable_preview_calc_size (drawable->width, - drawable->height, - width, - height, - &preview_width, - &preview_height, - &scaling_up); - } - else - { - gimp_drawable_preview_calc_size (drawable->width, - drawable->height, - width, - height, - &preview_width, - &preview_height, - &scaling_up); - } - - if (scaling_up) - { - TempBuf *temp_buf; - - temp_buf = gimp_viewable_get_new_preview (preview->viewable, - drawable->width, - drawable->height); - render_buf = temp_buf_scale (temp_buf, preview_width, preview_height); - - temp_buf_free (temp_buf); - } - else - { - render_buf = gimp_viewable_get_new_preview (preview->viewable, - preview_width, - preview_height); - } - - if (gimage && ! preview->is_popup) - { - if (preview_width < preview->width) - render_buf->x = - ROUND ((((gdouble) preview->width / (gdouble) gimage->width) * - (gdouble) drawable->offset_x)); - - if (preview_height < preview->height) - render_buf->y = - ROUND ((((gdouble) preview->height / (gdouble) gimage->height) * - (gdouble) drawable->offset_y)); - } - else - { - if (preview_width < width) - render_buf->x = (width - preview_width) / 2; - - if (preview_height < height) - render_buf->y = (height - preview_height) / 2; - } - - if (! gimage && (render_buf->x || render_buf->y)) - { - TempBuf *temp_buf; - guchar white[4] = { 0, 0, 0, 0 }; - - temp_buf = temp_buf_new (width, height, - render_buf->bytes, - 0, 0, - white); - - temp_buf_copy_area (render_buf, temp_buf, - 0, 0, - render_buf->width, - render_buf->height, - render_buf->x, - render_buf->y); - - temp_buf_free (render_buf); - - gimp_preview_render_and_flush (preview, - temp_buf, - -1); - - temp_buf_free (temp_buf); - - return; - } - - gimp_preview_render_and_flush (preview, - render_buf, - -1); - - temp_buf_free (render_buf); -} - -static GtkWidget * -gimp_drawable_preview_create_popup (GimpPreview *preview) -{ - GimpDrawable *drawable; - gint popup_width; - gint popup_height; - gboolean scaling_up; - - drawable = GIMP_DRAWABLE (preview->viewable); - - gimp_drawable_preview_calc_size (drawable->width, - drawable->height, - MIN (preview->width * 2, 256), - MIN (preview->height * 2, 256), - &popup_width, - &popup_height, - &scaling_up); - - if (scaling_up) - { - return gimp_preview_new_full (preview->viewable, - drawable->width, - drawable->height, - 0, - TRUE, FALSE, FALSE); - } - else - { - return gimp_preview_new_full (preview->viewable, - popup_width, - popup_height, - 0, - TRUE, FALSE, FALSE); - } -} - -static void -gimp_drawable_preview_calc_size (gint drawable_width, - gint drawable_height, - gint width, - gint height, - gint *return_width, - gint *return_height, - gboolean *scaling_up) -{ - gdouble ratio; - - if (drawable_width > drawable_height) - { - ratio = (gdouble) width / (gdouble) drawable_width; - } - else - { - ratio = (gdouble) height / (gdouble) drawable_height; - } - - width = RINT (ratio * (gdouble) drawable_width); - height = RINT (ratio * (gdouble) drawable_height); - - if (width < 1) width = 1; - if (height < 1) height = 1; - - *return_width = width; - *return_height = height; - *scaling_up = (ratio > 1.0); -} diff --git a/app/gimpdrawablepreview.h b/app/gimpdrawablepreview.h deleted file mode 100644 index 63f46c4c7e..0000000000 --- a/app/gimpdrawablepreview.h +++ /dev/null @@ -1,61 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * GimpDrawablePreview Widget - * Copyright (C) 2001 Michael Natterer - * - * 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_DRAWABLE_PREVIEW_H__ -#define __GIMP_DRAWABLE_PREVIEW_H__ - - -#include "gimppreview.h" - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -#define GIMP_TYPE_DRAWABLE_PREVIEW (gimp_drawable_preview_get_type ()) -#define GIMP_DRAWABLE_PREVIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DRAWABLE_PREVIEW, GimpDrawablePreview)) -#define GIMP_DRAWABLE_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DRAWABLE_PREVIEW, GimpDrawablePreviewClass)) -#define GIMP_IS_DRAWABLE_PREVIEW(obj) (GTK_CHECK_TYPE (obj, GIMP_TYPE_DRAWABLE_PREVIEW)) -#define GIMP_IS_DRAWABLE_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DRAWABLE_PREVIEW)) - - -typedef struct _GimpDrawablePreviewClass GimpDrawablePreviewClass; - -struct _GimpDrawablePreview -{ - GimpPreview parent_instance; -}; - -struct _GimpDrawablePreviewClass -{ - GimpPreviewClass parent_class; -}; - - -GtkType gimp_drawable_preview_get_type (void); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __GIMP_DRAWABLE_PREVIEW_H__ */ diff --git a/app/gimpgradientpreview.c b/app/gimpgradientpreview.c deleted file mode 100644 index 1525c01d5e..0000000000 --- a/app/gimpgradientpreview.c +++ /dev/null @@ -1,164 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * GimpGradientPreview Widget - * Copyright (C) 2001 Michael Natterer - * - * 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 - -#include "apptypes.h" - -#include "gimpgradient.h" -#include "gimpgradientpreview.h" -#include "temp_buf.h" - - -static void gimp_gradient_preview_class_init (GimpGradientPreviewClass *klass); -static void gimp_gradient_preview_init (GimpGradientPreview *preview); - -static void gimp_gradient_preview_render (GimpPreview *preview); -static void gimp_gradient_preview_get_size (GimpPreview *preview, - gint size, - gint *width, - gint *height); -static gboolean gimp_gradient_preview_needs_popup (GimpPreview *preview); -static GtkWidget * gimp_gradient_preview_create_popup (GimpPreview *preview); - - -static GimpPreviewClass *parent_class = NULL; - - -GtkType -gimp_gradient_preview_get_type (void) -{ - static GtkType preview_type = 0; - - if (! preview_type) - { - GtkTypeInfo preview_info = - { - "GimpGradientPreview", - sizeof (GimpGradientPreview), - sizeof (GimpGradientPreviewClass), - (GtkClassInitFunc) gimp_gradient_preview_class_init, - (GtkObjectInitFunc) gimp_gradient_preview_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL - }; - - preview_type = gtk_type_unique (GIMP_TYPE_PREVIEW, &preview_info); - } - - return preview_type; -} - -static void -gimp_gradient_preview_class_init (GimpGradientPreviewClass *klass) -{ - GtkObjectClass *object_class; - GimpPreviewClass *preview_class; - - object_class = (GtkObjectClass *) klass; - preview_class = (GimpPreviewClass *) klass; - - parent_class = gtk_type_class (GIMP_TYPE_PREVIEW); - - preview_class->get_size = gimp_gradient_preview_get_size; - preview_class->render = gimp_gradient_preview_render; - preview_class->needs_popup = gimp_gradient_preview_needs_popup; - preview_class->create_popup = gimp_gradient_preview_create_popup; -} - -static void -gimp_gradient_preview_init (GimpGradientPreview *gradient_preview) -{ -} - -static void -gimp_gradient_preview_get_size (GimpPreview *preview, - gint size, - gint *width, - gint *height) -{ - *width = size * 3; - *height = size; -} - -static void -gimp_gradient_preview_render (GimpPreview *preview) -{ - GimpGradient *gradient; - TempBuf *temp_buf; - gint width; - gint height; - - gradient = GIMP_GRADIENT (preview->viewable); - - width = preview->width; - height = preview->height; - - temp_buf = gimp_viewable_get_new_preview (preview->viewable, - width, height); - - gimp_preview_render_and_flush (preview, - temp_buf, - -1); - - temp_buf_free (temp_buf); -} - -static gboolean -gimp_gradient_preview_needs_popup (GimpPreview *preview) -{ - GimpGradient *gradient; - gint popup_width; - gint popup_height; - - gradient = GIMP_GRADIENT (preview->viewable); - - popup_width = 48; - popup_height = 24; - - if (popup_width > preview->width || - popup_height > preview->height) - return TRUE; - - return FALSE; -} - -static GtkWidget * -gimp_gradient_preview_create_popup (GimpPreview *preview) -{ - GimpGradient *gradient; - gint popup_width; - gint popup_height; - - gradient = GIMP_GRADIENT (preview->viewable); - - popup_width = 128; - popup_height = 32; - - return gimp_preview_new_full (preview->viewable, - popup_width, - popup_height, - 0, - TRUE, FALSE, FALSE); -} diff --git a/app/gimpgradientpreview.h b/app/gimpgradientpreview.h deleted file mode 100644 index 7aeeaf49f7..0000000000 --- a/app/gimpgradientpreview.h +++ /dev/null @@ -1,61 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * GimpGradientPreview Widget - * Copyright (C) 2001 Michael Natterer - * - * 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_GRADIENT_PREVIEW_H__ -#define __GIMP_GRADIENT_PREVIEW_H__ - - -#include "gimppreview.h" - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -#define GIMP_TYPE_GRADIENT_PREVIEW (gimp_gradient_preview_get_type ()) -#define GIMP_GRADIENT_PREVIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_GRADIENT_PREVIEW, GimpGradientPreview)) -#define GIMP_GRADIENT_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_GRADIENT_PREVIEW, GimpGradientPreviewClass)) -#define GIMP_IS_GRADIENT_PREVIEW(obj) (GTK_CHECK_TYPE (obj, GIMP_TYPE_GRADIENT_PREVIEW)) -#define GIMP_IS_GRADIENT_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_GRADIENT_PREVIEW)) - - -typedef struct _GimpGradientPreviewClass GimpGradientPreviewClass; - -struct _GimpGradientPreview -{ - GimpPreview parent_instance; -}; - -struct _GimpGradientPreviewClass -{ - GimpPreviewClass parent_class; -}; - - -GtkType gimp_gradient_preview_get_type (void); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __GIMP_GRADIENT_PREVIEW_H__ */ diff --git a/app/gimphistogram.h b/app/gimphistogram.h index 073e5f4ec6..670b578f40 100644 --- a/app/gimphistogram.h +++ b/app/gimphistogram.h @@ -22,16 +22,6 @@ #define __GIMP_HISTOGRAM_H__ -typedef enum -{ - GIMP_HISTOGRAM_VALUE = 0, - GIMP_HISTOGRAM_RED = 1, - GIMP_HISTOGRAM_GREEN = 2, - GIMP_HISTOGRAM_BLUE = 3, - GIMP_HISTOGRAM_ALPHA = 4 -} GimpHistogramChannel; - - GimpHistogram * gimp_histogram_new (void); void gimp_histogram_free (GimpHistogram *histogram); void gimp_histogram_calculate (GimpHistogram *historgam, diff --git a/app/gimpimagepreview.c b/app/gimpimagepreview.c deleted file mode 100644 index 01d32decd9..0000000000 --- a/app/gimpimagepreview.c +++ /dev/null @@ -1,239 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * GimpImagePreview Widget - * Copyright (C) 2001 Michael Natterer - * - * 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 - -#include "libgimpmath/gimpmath.h" - -#include "apptypes.h" - -#include "gimpimage.h" -#include "gimpimagepreview.h" -#include "gimpviewable.h" -#include "temp_buf.h" - - -static void gimp_image_preview_class_init (GimpImagePreviewClass *klass); -static void gimp_image_preview_init (GimpImagePreview *preview); - -static void gimp_image_preview_render (GimpPreview *preview); -static GtkWidget * gimp_image_preview_create_popup (GimpPreview *preview); -static void gimp_image_preview_calc_size (GimpImage *gimage, - gint width, - gint height, - gint *return_width, - gint *return_height, - gboolean *scaling_up); - - -static GimpPreviewClass *parent_class = NULL; - - -GtkType -gimp_image_preview_get_type (void) -{ - static GtkType preview_type = 0; - - if (! preview_type) - { - GtkTypeInfo preview_info = - { - "GimpImagePreview", - sizeof (GimpImagePreview), - sizeof (GimpImagePreviewClass), - (GtkClassInitFunc) gimp_image_preview_class_init, - (GtkObjectInitFunc) gimp_image_preview_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL - }; - - preview_type = gtk_type_unique (GIMP_TYPE_PREVIEW, &preview_info); - } - - return preview_type; -} - -static void -gimp_image_preview_class_init (GimpImagePreviewClass *klass) -{ - GtkObjectClass *object_class; - GimpPreviewClass *preview_class; - - object_class = (GtkObjectClass *) klass; - preview_class = (GimpPreviewClass *) klass; - - parent_class = gtk_type_class (GIMP_TYPE_PREVIEW); - - preview_class->render = gimp_image_preview_render; - preview_class->create_popup = gimp_image_preview_create_popup; -} - -static void -gimp_image_preview_init (GimpImagePreview *preview) -{ -} - -static void -gimp_image_preview_render (GimpPreview *preview) -{ - GimpImage *gimage; - gint width; - gint height; - gint preview_width; - gint preview_height; - gboolean scaling_up; - TempBuf *render_buf; - - gimage = GIMP_IMAGE (preview->viewable); - - width = preview->width; - height = preview->height; - - gimp_image_preview_calc_size (gimage, - width, - height, - &preview_width, - &preview_height, - &scaling_up); - - if (scaling_up) - { - TempBuf *temp_buf; - - temp_buf = gimp_viewable_get_new_preview (preview->viewable, - gimage->width, - gimage->height); - render_buf = temp_buf_scale (temp_buf, preview_width, preview_height); - - temp_buf_free (temp_buf); - } - else - { - render_buf = gimp_viewable_get_new_preview (preview->viewable, - preview_width, - preview_height); - } - - if (preview_width < width) render_buf->x = (width - preview_width) / 2; - if (preview_height < height) render_buf->y = (height - preview_height) / 2; - - if (render_buf->x || render_buf->y) - { - TempBuf *temp_buf; - guchar white[4] = { 255, 255, 255, 255 }; - - temp_buf = temp_buf_new (width, height, - render_buf->bytes, - 0, 0, - white); - - temp_buf_copy_area (render_buf, temp_buf, - 0, 0, - render_buf->width, - render_buf->height, - render_buf->x, - render_buf->y); - - temp_buf_free (render_buf); - - gimp_preview_render_and_flush (preview, - temp_buf, - -1); - - temp_buf_free (temp_buf); - - return; - } - - gimp_preview_render_and_flush (preview, - render_buf, - -1); - - temp_buf_free (render_buf); -} - -static GtkWidget * -gimp_image_preview_create_popup (GimpPreview *preview) -{ - GimpImage *gimage; - gint popup_width; - gint popup_height; - gboolean scaling_up; - - gimage = GIMP_IMAGE (preview->viewable); - - gimp_image_preview_calc_size (gimage, - MIN (preview->width * 2, 256), - MIN (preview->height * 2, 256), - &popup_width, - &popup_height, - &scaling_up); - - if (scaling_up) - { - return gimp_preview_new_full (preview->viewable, - gimage->width, - gimage->height, - 0, - TRUE, FALSE, FALSE); - } - else - { - return gimp_preview_new_full (preview->viewable, - popup_width, - popup_height, - 0, - TRUE, FALSE, FALSE); - } -} - -static void -gimp_image_preview_calc_size (GimpImage *gimage, - gint width, - gint height, - gint *return_width, - gint *return_height, - gboolean *scaling_up) -{ - gdouble ratio; - - if (gimage->width > gimage->height) - { - ratio = (gdouble) width / (gdouble) gimage->width; - } - else - { - ratio = (gdouble) height / (gdouble) gimage->height; - } - - width = RINT (ratio * (gdouble) gimage->width); - height = RINT (ratio * (gdouble) gimage->height); - - if (width < 1) width = 1; - if (height < 1) height = 1; - - *return_width = width; - *return_height = height; - *scaling_up = (ratio > 1.0); -} diff --git a/app/gimpimagepreview.h b/app/gimpimagepreview.h deleted file mode 100644 index 4dfa40e6c7..0000000000 --- a/app/gimpimagepreview.h +++ /dev/null @@ -1,61 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * GimpImagePreview Widget - * Copyright (C) 2001 Michael Natterer - * - * 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_IMAGE_PREVIEW_H__ -#define __GIMP_IMAGE_PREVIEW_H__ - - -#include "gimppreview.h" - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -#define GIMP_TYPE_IMAGE_PREVIEW (gimp_image_preview_get_type ()) -#define GIMP_IMAGE_PREVIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_IMAGE_PREVIEW, GimpImagePreview)) -#define GIMP_IMAGE_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_IMAGE_PREVIEW, GimpImagePreviewClass)) -#define GIMP_IS_IMAGE_PREVIEW(obj) (GTK_CHECK_TYPE (obj, GIMP_TYPE_IMAGE_PREVIEW)) -#define GIMP_IS_IMAGE_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_IMAGE_PREVIEW)) - - -typedef struct _GimpImagePreviewClass GimpImagePreviewClass; - -struct _GimpImagePreview -{ - GimpPreview parent_instance; -}; - -struct _GimpImagePreviewClass -{ - GimpPreviewClass parent_class; -}; - - -GtkType gimp_image_preview_get_type (void); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __GIMP_IMAGE_PREVIEW_H__ */ diff --git a/app/gimplayerlistitem.c b/app/gimplayerlistitem.c deleted file mode 100644 index 6ba688a9f9..0000000000 --- a/app/gimplayerlistitem.c +++ /dev/null @@ -1,392 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * gimplayerlistitem.c - * Copyright (C) 2001 Michael Natterer - * - * 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 - -#include "libgimpcolor/gimpcolor.h" -#include "libgimpwidgets/gimpwidgets.h" - -#include "apptypes.h" - -#include "drawable.h" -#include "gdisplay.h" -#include "gimpchannel.h" -#include "gimpcontainer.h" -#include "gimpdnd.h" -#include "gimplayerlistitem.h" -#include "gimpimage.h" -#include "gimplayer.h" -#include "gimplayermask.h" -#include "gimppreview.h" -#include "gimpviewable.h" - - -static void gimp_layer_list_item_class_init (GimpLayerListItemClass *klass); -static void gimp_layer_list_item_init (GimpLayerListItem *list_item); - -static void gimp_layer_list_item_set_viewable (GimpListItem *list_item, - GimpViewable *viewable); - -static gboolean gimp_layer_list_item_drag_motion (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time); -static gboolean gimp_layer_list_item_drag_drop (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time); -static void gimp_layer_list_item_state_changed (GtkWidget *widget, - GtkStateType old_state); - -static void gimp_layer_list_item_mask_changed (GimpLayer *layer, - GimpLayerListItem *layer_item); -static void gimp_layer_list_item_update_state (GtkWidget *widget); - -static void gimp_layer_list_item_layer_clicked (GtkWidget *widget, - GimpLayer *layer); -static void gimp_layer_list_item_mask_clicked (GtkWidget *widget, - GimpLayerMask *mask); - - -static GimpDrawableListItemClass *parent_class = NULL; - -static GimpRGB black_color; -static GimpRGB white_color; -static GimpRGB green_color; -static GimpRGB red_color; - - -GtkType -gimp_layer_list_item_get_type (void) -{ - static GtkType list_item_type = 0; - - if (! list_item_type) - { - static const GtkTypeInfo list_item_info = - { - "GimpLayerListItem", - sizeof (GimpLayerListItem), - sizeof (GimpLayerListItemClass), - (GtkClassInitFunc) gimp_layer_list_item_class_init, - (GtkObjectInitFunc) gimp_layer_list_item_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - list_item_type = gtk_type_unique (GIMP_TYPE_DRAWABLE_LIST_ITEM, - &list_item_info); - } - - return list_item_type; -} - -static void -gimp_layer_list_item_class_init (GimpLayerListItemClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GimpListItemClass *list_item_class; - - object_class = (GtkObjectClass *) klass; - widget_class = (GtkWidgetClass *) klass; - list_item_class = (GimpListItemClass *) klass; - - parent_class = gtk_type_class (GIMP_TYPE_DRAWABLE_LIST_ITEM); - - widget_class->drag_motion = gimp_layer_list_item_drag_motion; - widget_class->drag_drop = gimp_layer_list_item_drag_drop; - widget_class->state_changed = gimp_layer_list_item_state_changed; - - list_item_class->set_viewable = gimp_layer_list_item_set_viewable; - - gimp_rgba_set (&black_color, 0.0, 0.0, 0.0, 1.0); - gimp_rgba_set (&white_color, 1.0, 1.0, 1.0, 1.0); - gimp_rgba_set (&green_color, 0.0, 1.0, 0.0, 1.0); - gimp_rgba_set (&red_color, 1.0, 0.0, 0.0, 1.0); -} - -static void -gimp_layer_list_item_init (GimpLayerListItem *list_item) -{ - list_item->mask_preview = NULL; -} - -static void -gimp_layer_list_item_set_viewable (GimpListItem *list_item, - GimpViewable *viewable) -{ - GimpLayerListItem *layer_item; - GimpLayer *layer; - - if (GIMP_LIST_ITEM_CLASS (parent_class)->set_viewable) - GIMP_LIST_ITEM_CLASS (parent_class)->set_viewable (list_item, viewable); - - gimp_preview_set_size (GIMP_PREVIEW (list_item->preview), - list_item->preview_size, 2); - - layer_item = GIMP_LAYER_LIST_ITEM (list_item); - layer = GIMP_LAYER (GIMP_PREVIEW (list_item->preview)->viewable); - - gtk_signal_connect (GTK_OBJECT (list_item->preview), "clicked", - GTK_SIGNAL_FUNC (gimp_layer_list_item_layer_clicked), - layer); - - if (gimp_layer_get_mask (layer)) - { - gimp_layer_list_item_mask_changed (layer, layer_item); - } - - gtk_signal_connect (GTK_OBJECT (layer), "mask_changed", - GTK_SIGNAL_FUNC (gimp_layer_list_item_mask_changed), - list_item); -} - -static gboolean -gimp_layer_list_item_drag_motion (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time) -{ - GimpListItem *list_item; - GimpLayer *layer; - GimpViewable *src_viewable; - gint dest_index; - GdkDragAction drag_action; - GimpDropType drop_type; - gboolean return_val; - - list_item = GIMP_LIST_ITEM (widget); - layer = GIMP_LAYER (GIMP_PREVIEW (list_item->preview)->viewable); - - return_val = gimp_list_item_check_drag (list_item, context, x, y, - &src_viewable, - &dest_index, - &drag_action, - &drop_type); - - if (! src_viewable || - ! gimp_drawable_has_alpha (GIMP_DRAWABLE (src_viewable)) || - ! layer || - ! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer))) - { - drag_action = GDK_ACTION_DEFAULT; - drop_type = GIMP_DROP_NONE; - return_val = FALSE; - } - - gdk_drag_status (context, drag_action, time); - - list_item->drop_type = drop_type; - - return return_val; -} - -static gboolean -gimp_layer_list_item_drag_drop (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time) -{ - GimpListItem *list_item; - GimpLayer *layer; - GimpViewable *src_viewable; - gint dest_index; - GdkDragAction drag_action; - GimpDropType drop_type; - gboolean return_val; - - list_item = GIMP_LIST_ITEM (widget); - layer = GIMP_LAYER (GIMP_PREVIEW (list_item->preview)->viewable); - - return_val = gimp_list_item_check_drag (list_item, context, x, y, - &src_viewable, - &dest_index, - &drag_action, - &drop_type); - - if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (src_viewable)) || - ! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer))) - { - drag_action = GDK_ACTION_DEFAULT; - drop_type = GIMP_DROP_NONE; - return_val = FALSE; - } - - gtk_drag_finish (context, return_val, FALSE, time); - - list_item->drop_type = GIMP_DROP_NONE; - - if (return_val) - { - gimp_image_position_layer (gimp_drawable_gimage (GIMP_DRAWABLE (src_viewable)), - GIMP_LAYER (src_viewable), - dest_index, - TRUE); - gdisplays_flush (); - } - - return return_val; -} - -static void -gimp_layer_list_item_state_changed (GtkWidget *widget, - GtkStateType old_state) -{ - if (GTK_WIDGET_CLASS (parent_class)->state_changed) - GTK_WIDGET_CLASS (parent_class)->state_changed (widget, old_state); - - gimp_layer_list_item_update_state (widget); -} - -static void -gimp_layer_list_item_mask_changed (GimpLayer *layer, - GimpLayerListItem *layer_item) -{ - GimpListItem *list_item; - GimpLayerMask *mask; - - list_item = GIMP_LIST_ITEM (layer_item); - mask = gimp_layer_get_mask (layer); - - if (mask && ! layer_item->mask_preview) - { - layer_item->mask_preview = gimp_preview_new (GIMP_VIEWABLE (mask), - list_item->preview_size, - 2, FALSE); - - GIMP_PREVIEW (layer_item->mask_preview)->clickable = TRUE; - - gtk_box_pack_start (GTK_BOX (list_item->hbox), layer_item->mask_preview, - FALSE, FALSE, 0); - gtk_box_reorder_child (GTK_BOX (list_item->hbox), - layer_item->mask_preview, 2); - gtk_widget_show (layer_item->mask_preview); - - gtk_signal_connect (GTK_OBJECT (layer_item->mask_preview), "clicked", - GTK_SIGNAL_FUNC (gimp_layer_list_item_mask_clicked), - mask); - - gtk_signal_connect_object - (GTK_OBJECT (mask), "apply_changed", - GTK_SIGNAL_FUNC (gimp_layer_list_item_update_state), - GTK_OBJECT (layer_item)); - - gtk_signal_connect_object_while_alive - (GTK_OBJECT (mask), "edit_changed", - GTK_SIGNAL_FUNC (gimp_layer_list_item_update_state), - GTK_OBJECT (layer_item)); - - gtk_signal_connect_object_while_alive - (GTK_OBJECT (mask), "show_changed", - GTK_SIGNAL_FUNC (gimp_layer_list_item_update_state), - GTK_OBJECT (layer_item)); - } - else if (! mask && layer_item->mask_preview) - { - gtk_widget_destroy (layer_item->mask_preview); - layer_item->mask_preview = NULL; - } - - gimp_layer_list_item_update_state (GTK_WIDGET (layer_item)); -} - -static void -gimp_layer_list_item_update_state (GtkWidget *widget) -{ - GimpLayerListItem *layer_item; - GimpListItem *list_item; - GimpLayer *layer; - GimpLayerMask *mask; - GimpPreview *preview; - GimpRGB *layer_color = &black_color; - GimpRGB *mask_color = &black_color; - - layer_item = GIMP_LAYER_LIST_ITEM (widget); - list_item = GIMP_LIST_ITEM (widget); - layer = GIMP_LAYER (GIMP_PREVIEW (list_item->preview)->viewable); - mask = gimp_layer_get_mask (layer); - - switch (widget->state) - { - case GTK_STATE_NORMAL: - break; - - case GTK_STATE_SELECTED: - if (! mask || (mask && ! gimp_layer_mask_get_edit (mask))) - { - layer_color = &white_color; - } - else - { - mask_color = &white_color; - } - break; - - default: - g_print ("%s(): unhandled state\n", G_GNUC_FUNCTION); - } - - preview = GIMP_PREVIEW (list_item->preview); - - gimp_preview_set_border_color (preview, layer_color); - - if (mask) - { - preview = GIMP_PREVIEW (layer_item->mask_preview); - - gimp_preview_set_border_color (preview, mask_color); - } -} - -static void -gimp_layer_list_item_layer_clicked (GtkWidget *widget, - GimpLayer *layer) -{ - GimpLayerMask *mask; - - g_print ("layer clicked\n"); - - mask = gimp_layer_get_mask (layer); - - if (mask) - { - if (gimp_layer_mask_get_edit (mask)) - gimp_layer_mask_set_edit (mask, FALSE); - } -} - -static void -gimp_layer_list_item_mask_clicked (GtkWidget *widget, - GimpLayerMask *mask) -{ - g_print ("mask clicked\n"); - - if (! gimp_layer_mask_get_edit (mask)) - gimp_layer_mask_set_edit (mask, TRUE); -} diff --git a/app/gimplayerlistitem.h b/app/gimplayerlistitem.h deleted file mode 100644 index cbb06265c9..0000000000 --- a/app/gimplayerlistitem.h +++ /dev/null @@ -1,64 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * gimplayerlistitem.h - * Copyright (C) 2001 Michael Natterer - * - * 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_LAYER_LIST_ITEM_H__ -#define __GIMP_LAYER_LIST_ITEM_H__ - - -#include "gimpdrawablelistitem.h" - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -#define GIMP_TYPE_LAYER_LIST_ITEM (gimp_layer_list_item_get_type ()) -#define GIMP_LAYER_LIST_ITEM(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_LAYER_LIST_ITEM, GimpLayerListItem)) -#define GIMP_LAYER_LIST_ITEM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_LAYER_LIST_ITEM, GimpLayerListItemClass)) -#define GIMP_IS_LAYER_LIST_ITEM(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_LAYER_LIST_ITEM)) -#define GIMP_IS_LAYER_LIST_ITEM_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_LAYER_LIST_ITEM)) - - -typedef struct _GimpLayerListItemClass GimpLayerListItemClass; - -struct _GimpLayerListItem -{ - GimpDrawableListItem parent_instance; - - GtkWidget *mask_preview; -}; - -struct _GimpLayerListItemClass -{ - GimpDrawableListItemClass parent_class; -}; - - -GtkType gimp_layer_list_item_get_type (void); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __GIMP_LAYER_LIST_ITEM_H__ */ diff --git a/app/gimplayerlistview.c b/app/gimplayerlistview.c deleted file mode 100644 index e3fcb9953e..0000000000 --- a/app/gimplayerlistview.c +++ /dev/null @@ -1,528 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * 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 - -#include "libgimpmath/gimpmath.h" -#include "libgimpwidgets/gimpwidgets.h" - -#include "apptypes.h" - -#include "drawable.h" -#include "gdisplay.h" -#include "gimpcontainer.h" -#include "gimplayer.h" -#include "gimplayerlistview.h" -#include "gimpdnd.h" -#include "gimpimage.h" -#include "gimplistitem.h" -#include "gimpmarshal.h" -#include "gimprc.h" -#include "gimpviewable.h" - -#include "tools/paint_options.h" - -#include "libgimp/gimpintl.h" - -#include "pixmaps/anchor.xpm" - - -static void gimp_layer_list_view_class_init (GimpLayerListViewClass *klass); -static void gimp_layer_list_view_init (GimpLayerListView *view); - -static void gimp_layer_list_view_destroy (GtkObject *object); - -static void gimp_layer_list_view_set_container (GimpContainerView *view, - GimpContainer *container); -static void gimp_layer_list_view_select_item (GimpContainerView *view, - GimpViewable *item, - gpointer insert_data); - -static void gimp_layer_list_view_anchor_layer (GimpLayerListView *view, - GimpLayer *layer); -static void gimp_layer_list_view_anchor_clicked (GtkWidget *widget, - GimpLayerListView *view); -static void gimp_layer_list_view_anchor_dropped (GtkWidget *widget, - GimpViewable *viewable, - gpointer data); - -static void gimp_layer_list_view_paint_mode_menu_callback - (GtkWidget *widget, - GimpLayerListView *view); -static void gimp_layer_list_view_preserve_button_toggled - (GtkWidget *widget, - GimpLayerListView *view); -static void gimp_layer_list_view_opacity_scale_changed - (GtkAdjustment *adjustment, - GimpLayerListView *view); - -static void gimp_layer_list_view_layer_signal_handler - (GimpLayer *layer, - GimpLayerListView *view); -static void gimp_layer_list_view_update_options (GimpLayerListView *view, - GimpLayer *layer); - - -static GimpDrawableListViewClass *parent_class = NULL; - - -GtkType -gimp_layer_list_view_get_type (void) -{ - static guint view_type = 0; - - if (! view_type) - { - GtkTypeInfo view_info = - { - "GimpLayerListView", - sizeof (GimpLayerListView), - sizeof (GimpLayerListViewClass), - (GtkClassInitFunc) gimp_layer_list_view_class_init, - (GtkObjectInitFunc) gimp_layer_list_view_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL - }; - - view_type = gtk_type_unique (GIMP_TYPE_DRAWABLE_LIST_VIEW, &view_info); - } - - return view_type; -} - -static void -gimp_layer_list_view_class_init (GimpLayerListViewClass *klass) -{ - GtkObjectClass *object_class; - GimpContainerViewClass *container_view_class; - - object_class = (GtkObjectClass *) klass; - container_view_class = (GimpContainerViewClass *) klass; - - parent_class = gtk_type_class (GIMP_TYPE_DRAWABLE_LIST_VIEW); - - object_class->destroy = gimp_layer_list_view_destroy; - - container_view_class->set_container = gimp_layer_list_view_set_container; - container_view_class->select_item = gimp_layer_list_view_select_item; -} - -static void -gimp_layer_list_view_init (GimpLayerListView *view) -{ - GimpDrawableListView *drawable_view; - GtkWidget *hbox; - GtkWidget *label; - GtkWidget *slider; - GtkWidget *pixmap; - - drawable_view = GIMP_DRAWABLE_LIST_VIEW (view); - - view->options_box = gtk_vbox_new (FALSE, 2); - gtk_box_pack_start (GTK_BOX (view), view->options_box, FALSE, FALSE, 0); - gtk_box_reorder_child (GTK_BOX (view), view->options_box, 0); - gtk_widget_show (view->options_box); - - hbox = gtk_hbox_new (FALSE, 2); - gtk_box_pack_start (GTK_BOX (view->options_box), hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - /* Paint mode menu */ - - label = gtk_label_new (_("Mode:")); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - view->paint_mode_menu = - paint_mode_menu_new (gimp_layer_list_view_paint_mode_menu_callback, view, - FALSE, NORMAL_MODE); - gtk_box_pack_start (GTK_BOX (hbox), view->paint_mode_menu, FALSE, FALSE, 2); - gtk_widget_show (view->paint_mode_menu); - - gimp_help_set_help_data (view->paint_mode_menu, - NULL, "#paint_mode_menu"); - - /* Preserve transparency toggle */ - - view->preserve_trans_toggle = - gtk_check_button_new_with_label (_("Keep Trans.")); - gtk_box_pack_start (GTK_BOX (hbox), view->preserve_trans_toggle, - FALSE, FALSE, 2); - gtk_widget_show (view->preserve_trans_toggle); - - gtk_signal_connect (GTK_OBJECT (view->preserve_trans_toggle), "toggled", - GTK_SIGNAL_FUNC (gimp_layer_list_view_preserve_button_toggled), - view); - - gimp_help_set_help_data (view->preserve_trans_toggle, - _("Keep Transparency"), "#keep_trans_button"); - - hbox = gtk_hbox_new (FALSE, 2); - gtk_box_pack_start (GTK_BOX (view->options_box), hbox, FALSE, FALSE, 0); - gtk_widget_show (hbox); - - /* Opacity scale */ - - label = gtk_label_new (_("Opacity:")); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_widget_show (label); - - view->opacity_adjustment = - GTK_ADJUSTMENT (gtk_adjustment_new (100.0, 0.0, 100.0, 1.0, 1.0, 0.0)); - - gtk_signal_connect (GTK_OBJECT (view->opacity_adjustment), "value_changed", - GTK_SIGNAL_FUNC (gimp_layer_list_view_opacity_scale_changed), - view); - - slider = gtk_hscale_new (view->opacity_adjustment); - gtk_scale_set_value_pos (GTK_SCALE (slider), GTK_POS_RIGHT); - gtk_box_pack_start (GTK_BOX (hbox), slider, TRUE, TRUE, 0); - gtk_widget_show (slider); - - gimp_help_set_help_data (slider, NULL, "#opacity_scale"); - - /* Anchor button */ - - view->anchor_button = gtk_button_new (); - gtk_box_pack_start (GTK_BOX (drawable_view->button_box), view->anchor_button, - TRUE, TRUE, 0); - gtk_box_reorder_child (GTK_BOX (drawable_view->button_box), - view->anchor_button, 5); - gtk_widget_show (view->anchor_button); - - gimp_help_set_help_data (view->anchor_button, _("Anchor"), NULL); - - gtk_signal_connect (GTK_OBJECT (view->anchor_button), "clicked", - GTK_SIGNAL_FUNC (gimp_layer_list_view_anchor_clicked), - view); - - pixmap = gimp_pixmap_new (anchor_xpm); - gtk_container_add (GTK_CONTAINER (view->anchor_button), pixmap); - gtk_widget_show (pixmap); - - gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (view->anchor_button), - GTK_DEST_DEFAULT_ALL, - GIMP_TYPE_LAYER, - GDK_ACTION_COPY); - gimp_dnd_viewable_dest_set (GTK_WIDGET (view->anchor_button), - GIMP_TYPE_LAYER, - gimp_layer_list_view_anchor_dropped, - view); - - gtk_widget_set_sensitive (view->options_box, FALSE); - gtk_widget_set_sensitive (view->anchor_button, FALSE); - - view->mode_changed_handler_id = 0; - view->opacity_changed_handler_id = 0; - view->preserve_trans_changed_handler_id = 0; -} - -static void -gimp_layer_list_view_destroy (GtkObject *object) -{ - GimpLayerListView *view; - - view = GIMP_LAYER_LIST_VIEW (object); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - - -/* GimpContainerView methods */ - -static void -gimp_layer_list_view_set_container (GimpContainerView *view, - GimpContainer *container) -{ - GimpLayerListView *layer_view; - - layer_view = GIMP_LAYER_LIST_VIEW (view); - - if (view->container) - { - gimp_container_remove_handler (view->container, - layer_view->mode_changed_handler_id); - gimp_container_remove_handler (view->container, - layer_view->opacity_changed_handler_id); - gimp_container_remove_handler (view->container, - layer_view->preserve_trans_changed_handler_id); - } - - if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->set_container) - GIMP_CONTAINER_VIEW_CLASS (parent_class)->set_container (view, container); - - if (view->container) - { - layer_view->mode_changed_handler_id = - gimp_container_add_handler (view->container, "mode_changed", - gimp_layer_list_view_layer_signal_handler, - view); - layer_view->opacity_changed_handler_id = - gimp_container_add_handler (view->container, "opacity_changed", - gimp_layer_list_view_layer_signal_handler, - view); - layer_view->preserve_trans_changed_handler_id = - gimp_container_add_handler (view->container, "preserve_trans_changed", - gimp_layer_list_view_layer_signal_handler, - view); - } -} - -static void -gimp_layer_list_view_select_item (GimpContainerView *view, - GimpViewable *item, - gpointer insert_data) -{ - GimpLayerListView *list_view; - gboolean options_sensitive = FALSE; - gboolean anchor_sensitive = FALSE; - - list_view = GIMP_LAYER_LIST_VIEW (view); - - if (GIMP_CONTAINER_VIEW_CLASS (parent_class)->select_item) - GIMP_CONTAINER_VIEW_CLASS (parent_class)->select_item (view, - item, - insert_data); - - if (item) - { - gimp_layer_list_view_update_options (list_view, GIMP_LAYER (item)); - - options_sensitive = TRUE; - - if (gimp_layer_is_floating_sel (GIMP_LAYER (item))) - { - anchor_sensitive = TRUE; - } - } - - gtk_widget_set_sensitive (list_view->options_box, options_sensitive); - gtk_widget_set_sensitive (list_view->anchor_button, anchor_sensitive); -} - - -/* "Anchor" functions */ - -static void -gimp_layer_list_view_anchor_layer (GimpLayerListView *view, - GimpLayer *layer) -{ - if (layer) - g_print ("anchor \"%s\"\n", GIMP_OBJECT (layer)->name); -} - -static void -gimp_layer_list_view_anchor_clicked (GtkWidget *widget, - GimpLayerListView *view) -{ - GimpDrawableListView *drawable_view; - GimpDrawable *drawable; - - drawable_view = GIMP_DRAWABLE_LIST_VIEW (view); - - drawable = drawable_view->get_drawable_func (drawable_view->gimage); - - if (drawable) - gimp_layer_list_view_anchor_layer (view, GIMP_LAYER (drawable)); -} - -static void -gimp_layer_list_view_anchor_dropped (GtkWidget *widget, - GimpViewable *viewable, - gpointer data) -{ - GimpLayerListView *view; - - view = (GimpLayerListView *) data; - - if (viewable && gimp_container_have (GIMP_CONTAINER_VIEW (view)->container, - GIMP_OBJECT (viewable))) - { - gimp_layer_list_view_anchor_layer (view, GIMP_LAYER (viewable)); - } -} - - -/* Paint Mode, Opacity and Preservce trans. callbacks */ - -#define BLOCK() \ - gtk_signal_handler_block_by_func (GTK_OBJECT (layer), \ - gimp_layer_list_view_layer_signal_handler, view) - -#define UNBLOCK() \ - gtk_signal_handler_unblock_by_func (GTK_OBJECT (layer), \ - gimp_layer_list_view_layer_signal_handler, view) - - -static void -gimp_layer_list_view_paint_mode_menu_callback (GtkWidget *widget, - GimpLayerListView *view) -{ - GimpDrawableListView *drawable_view; - GimpLayer *layer; - - drawable_view = GIMP_DRAWABLE_LIST_VIEW (view); - - layer = (GimpLayer *) drawable_view->get_drawable_func (drawable_view->gimage); - - if (layer) - { - LayerModeEffects mode; - - mode = (LayerModeEffects) - GPOINTER_TO_INT (gtk_object_get_user_data (GTK_OBJECT (widget))); - - if (gimp_layer_get_mode (layer) != mode) - { - BLOCK(); - gimp_layer_set_mode (layer, mode); - UNBLOCK(); - - drawable_update (GIMP_DRAWABLE (layer), 0, 0, - GIMP_DRAWABLE (layer)->width, - GIMP_DRAWABLE (layer)->height); - - gdisplays_flush (); - } - } -} - -static void -gimp_layer_list_view_preserve_button_toggled (GtkWidget *widget, - GimpLayerListView *view) -{ - GimpDrawableListView *drawable_view; - GimpLayer *layer; - - drawable_view = GIMP_DRAWABLE_LIST_VIEW (view); - - layer = (GimpLayer *) drawable_view->get_drawable_func (drawable_view->gimage); - - if (layer) - { - gboolean preserve_trans; - - preserve_trans = GTK_TOGGLE_BUTTON (widget)->active; - - if (gimp_layer_get_preserve_trans (layer) != preserve_trans) - { - BLOCK(); - gimp_layer_set_preserve_trans (layer, preserve_trans); - UNBLOCK(); - } - } -} - -static void -gimp_layer_list_view_opacity_scale_changed (GtkAdjustment *adjustment, - GimpLayerListView *view) -{ - GimpDrawableListView *drawable_view; - GimpLayer *layer; - - drawable_view = GIMP_DRAWABLE_LIST_VIEW (view); - - layer = (GimpLayer *) drawable_view->get_drawable_func (drawable_view->gimage); - - if (layer) - { - gdouble opacity; - - opacity = adjustment->value / 100.0; - - if (gimp_layer_get_opacity (layer) != opacity) - { - BLOCK(); - gimp_layer_set_opacity (layer, opacity); - UNBLOCK(); - - drawable_update (GIMP_DRAWABLE (layer), 0, 0, - GIMP_DRAWABLE (layer)->width, - GIMP_DRAWABLE (layer)->height); - - gdisplays_flush (); - } - } -} - -#undef BLOCK -#undef UNBLOCK - - -static void -gimp_layer_list_view_layer_signal_handler (GimpLayer *layer, - GimpLayerListView *view) -{ - GimpDrawableListView *drawable_view; - - drawable_view = GIMP_DRAWABLE_LIST_VIEW (view); - - if (drawable_view->get_drawable_func (drawable_view->gimage) == - (GimpDrawable *) layer) - { - gimp_layer_list_view_update_options (view, layer); - } -} - - -#define BLOCK(object,function) \ - gtk_signal_handler_block_by_func (GTK_OBJECT (object), \ - (function), view) - -#define UNBLOCK(object,function) \ - gtk_signal_handler_unblock_by_func (GTK_OBJECT (object), \ - (function), view) - -static void -gimp_layer_list_view_update_options (GimpLayerListView *view, - GimpLayer *layer) -{ - gimp_option_menu_set_history (GTK_OPTION_MENU (view->paint_mode_menu), - GINT_TO_POINTER (layer->mode)); - - if (layer->preserve_trans != - GTK_TOGGLE_BUTTON (view->preserve_trans_toggle)->active) - { - BLOCK (view->preserve_trans_toggle, - gimp_layer_list_view_preserve_button_toggled); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (view->preserve_trans_toggle), - layer->preserve_trans); - - UNBLOCK (view->preserve_trans_toggle, - gimp_layer_list_view_preserve_button_toggled); - } - - if ((gdouble) layer->opacity / 2.55 != view->opacity_adjustment->value) - { - BLOCK (view->opacity_adjustment, - gimp_layer_list_view_opacity_scale_changed); - - gtk_adjustment_set_value (view->opacity_adjustment, layer->opacity / 2.55); - - UNBLOCK (view->opacity_adjustment, - gimp_layer_list_view_opacity_scale_changed); - } -} - -#undef BLOCK -#undef UNBLOCK diff --git a/app/gimplayerlistview.h b/app/gimplayerlistview.h deleted file mode 100644 index e52fbbf313..0000000000 --- a/app/gimplayerlistview.h +++ /dev/null @@ -1,62 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * 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_LAYER_LIST_VIEW_H__ -#define __GIMP_LAYER_LIST_VIEW_H__ - - -#include "gimpdrawablelistview.h" - - -#define GIMP_TYPE_LAYER_LIST_VIEW (gimp_layer_list_view_get_type ()) -#define GIMP_LAYER_LIST_VIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_LAYER_LIST_VIEW, GimpLayerListView)) -#define GIMP_LAYER_LIST_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_LAYER_LIST_VIEW, GimpLayerListViewClass)) -#define GIMP_IS_LAYER_LIST_VIEW(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_LAYER_LIST_VIEW)) -#define GIMP_IS_LAYER_LIST_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_LAYER_LIST_VIEW)) - - -typedef struct _GimpLayerListViewClass GimpLayerListViewClass; - -struct _GimpLayerListView -{ - GimpDrawableListView parent_instance; - - GtkWidget *options_box; - - GtkWidget *paint_mode_menu; - GtkWidget *preserve_trans_toggle; - GtkAdjustment *opacity_adjustment; - - GtkWidget *anchor_button; - - /*< private >*/ - GQuark mode_changed_handler_id; - GQuark opacity_changed_handler_id; - GQuark preserve_trans_changed_handler_id; -}; - -struct _GimpLayerListViewClass -{ - GimpDrawableListViewClass parent_class; -}; - - -GtkType gimp_layer_list_view_get_type (void); - - -#endif /* __GIMP_LAYER_LIST_VIEW_H__ */ diff --git a/app/gimplistitem.c b/app/gimplistitem.c deleted file mode 100644 index 7eccbe2e64..0000000000 --- a/app/gimplistitem.c +++ /dev/null @@ -1,452 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * gimplistitem.c - * Copyright (C) 2001 Michael Natterer - * - * 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 - -#include "apptypes.h" - -#include "gimpcontainer.h" -#include "gimpdnd.h" -#include "gimpdrawable.h" -#include "gimpdrawablelistitem.h" -#include "gimplayer.h" -#include "gimplayerlistitem.h" -#include "gimplistitem.h" -#include "gimpmarshal.h" -#include "gimppreview.h" -#include "gimpviewable.h" - - -enum -{ - SET_VIEWABLE, - LAST_SIGNAL -}; - - -static void gimp_list_item_class_init (GimpListItemClass *klass); -static void gimp_list_item_init (GimpListItem *list_item); - -static void gimp_list_item_set_viewable (GimpListItem *list_item, - GimpViewable *viewable); - -static void gimp_list_item_real_set_viewable (GimpListItem *list_item, - GimpViewable *viewable); - -static void gimp_list_item_draw (GtkWidget *widget, - GdkRectangle *area); -static void gimp_list_item_drag_leave (GtkWidget *widget, - GdkDragContext *context, - guint time); -static gboolean gimp_list_item_drag_motion (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time); -static gboolean gimp_list_item_drag_drop (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time); - -static void gimp_list_item_name_changed (GimpViewable *viewable, - GtkLabel *label); -static GimpViewable * gimp_list_item_drag_viewable (GtkWidget *widget, - gpointer data); - - -static guint list_item_signals[LAST_SIGNAL] = { 0 }; - -static GtkListItemClass *parent_class = NULL; - - -GtkType -gimp_list_item_get_type (void) -{ - static GtkType list_item_type = 0; - - if (!list_item_type) - { - static const GtkTypeInfo list_item_info = - { - "GimpListItem", - sizeof (GimpListItem), - sizeof (GimpListItemClass), - (GtkClassInitFunc) gimp_list_item_class_init, - (GtkObjectInitFunc) gimp_list_item_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - list_item_type = gtk_type_unique (GTK_TYPE_LIST_ITEM, &list_item_info); - } - - return list_item_type; -} - -static void -gimp_list_item_class_init (GimpListItemClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) klass; - widget_class = (GtkWidgetClass *) klass; - - parent_class = gtk_type_class (GTK_TYPE_LIST_ITEM); - - list_item_signals[SET_VIEWABLE] = - gtk_signal_new ("set_viewable", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (GimpListItemClass, - set_viewable), - gtk_marshal_NONE__OBJECT, - GTK_TYPE_NONE, 1, - GIMP_TYPE_VIEWABLE); - - widget_class->draw = gimp_list_item_draw; - widget_class->drag_leave = gimp_list_item_drag_leave; - widget_class->drag_motion = gimp_list_item_drag_motion; - widget_class->drag_drop = gimp_list_item_drag_drop; - - klass->set_viewable = gimp_list_item_real_set_viewable; -} - -static void -gimp_list_item_init (GimpListItem *list_item) -{ - list_item->hbox = gtk_hbox_new (FALSE, 6); - gtk_container_set_border_width (GTK_CONTAINER (list_item->hbox), 2); - gtk_container_add (GTK_CONTAINER (list_item), list_item->hbox); - gtk_widget_show (list_item->hbox); - - list_item->preview = NULL; - list_item->name_label = NULL; - - list_item->preview_size = 0; - - list_item->reorderable = FALSE; - list_item->drop_type = GIMP_DROP_NONE; - list_item->container = NULL; -} - -static void -gimp_list_item_draw (GtkWidget *widget, - GdkRectangle *area) -{ - GimpListItem *list_item; - - list_item = GIMP_LIST_ITEM (widget); - - if (GTK_WIDGET_CLASS (parent_class)->draw) - GTK_WIDGET_CLASS (parent_class)->draw (widget, area); - - if (list_item->drop_type != GIMP_DROP_NONE) - { - gint x, y; - - x = list_item->name_label->allocation.x; - - y = ((list_item->drop_type == GIMP_DROP_ABOVE) ? - 3 : widget->allocation.height - 4); - - gdk_gc_set_line_attributes (widget->style->black_gc, 5, GDK_LINE_SOLID, - GDK_CAP_BUTT, GDK_JOIN_MITER); - - gdk_draw_line (widget->window, widget->style->black_gc, - x, y, - widget->allocation.width - 3, y); - - gdk_gc_set_line_attributes (widget->style->black_gc, 0, GDK_LINE_SOLID, - GDK_CAP_BUTT, GDK_JOIN_MITER); - } -} - -static void -gimp_list_item_drag_leave (GtkWidget *widget, - GdkDragContext *context, - guint time) -{ - GimpListItem *list_item; - - list_item = GIMP_LIST_ITEM (widget); - - list_item->drop_type = GIMP_DROP_NONE; -} - -static gboolean -gimp_list_item_drag_motion (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time) -{ - GimpListItem *list_item; - GimpViewable *src_viewable; - gint dest_index; - GdkDragAction drag_action; - GimpDropType drop_type; - gboolean return_val; - - list_item = GIMP_LIST_ITEM (widget); - - return_val = gimp_list_item_check_drag (list_item, context, x, y, - &src_viewable, - &dest_index, - &drag_action, - &drop_type); - - gdk_drag_status (context, drag_action, time); - - list_item->drop_type = drop_type; - - return return_val; -} - -static gboolean -gimp_list_item_drag_drop (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time) -{ - GimpListItem *list_item; - GimpViewable *src_viewable; - gint dest_index; - GdkDragAction drag_action; - GimpDropType drop_type; - gboolean return_val; - - list_item = GIMP_LIST_ITEM (widget); - - return_val = gimp_list_item_check_drag (list_item, context, x, y, - &src_viewable, - &dest_index, - &drag_action, - &drop_type); - - gtk_drag_finish (context, return_val, FALSE, time); - - list_item->drop_type = GIMP_DROP_NONE; - - if (return_val) - { - gimp_container_reorder (list_item->container, GIMP_OBJECT (src_viewable), - dest_index); - } - - return return_val; -} - -GtkWidget * -gimp_list_item_new (GimpViewable *viewable, - gint preview_size) -{ - GimpListItem *list_item; - - g_return_val_if_fail (viewable != NULL, NULL); - g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL); - g_return_val_if_fail (preview_size > 0 && preview_size <= 256, NULL); - - if (GIMP_IS_LAYER (viewable)) - { - list_item = gtk_type_new (GIMP_TYPE_LAYER_LIST_ITEM); - } - else if (GIMP_IS_DRAWABLE (viewable)) - { - list_item = gtk_type_new (GIMP_TYPE_DRAWABLE_LIST_ITEM); - } - else - { - list_item = gtk_type_new (GIMP_TYPE_LIST_ITEM); - } - - list_item->preview_size = preview_size; - - gimp_list_item_set_viewable (list_item, viewable); - - return GTK_WIDGET (list_item); -} - -static void -gimp_list_item_set_viewable (GimpListItem *list_item, - GimpViewable *viewable) -{ - gtk_signal_emit (GTK_OBJECT (list_item), list_item_signals[SET_VIEWABLE], - viewable); -} - -static void -gimp_list_item_real_set_viewable (GimpListItem *list_item, - GimpViewable *viewable) -{ - list_item->preview = gimp_preview_new (viewable, list_item->preview_size, - 1, FALSE); - gtk_box_pack_start (GTK_BOX (list_item->hbox), list_item->preview, - FALSE, FALSE, 0); - gtk_widget_show (list_item->preview); - - list_item->name_label = - gtk_label_new (gimp_object_get_name (GIMP_OBJECT (viewable))); - gtk_box_pack_start (GTK_BOX (list_item->hbox), list_item->name_label, - FALSE, FALSE, 0); - gtk_widget_show (list_item->name_label); - - gtk_signal_connect_while_alive (GTK_OBJECT (viewable), "name_changed", - GTK_SIGNAL_FUNC (gimp_list_item_name_changed), - list_item->name_label, - GTK_OBJECT (list_item->name_label)); - - gimp_gtk_drag_source_set_by_type (GTK_WIDGET (list_item), - GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, - GTK_OBJECT (viewable)->klass->type, - GDK_ACTION_MOVE | GDK_ACTION_COPY); - gimp_dnd_viewable_source_set (GTK_WIDGET (list_item), - GTK_OBJECT (viewable)->klass->type, - gimp_list_item_drag_viewable, - NULL); -} - -void -gimp_list_item_set_reorderable (GimpListItem *list_item, - gboolean reorderable, - GimpContainer *container) -{ - g_return_if_fail (list_item != NULL); - g_return_if_fail (GIMP_IS_LIST_ITEM (list_item)); - - g_return_if_fail (! reorderable || container != NULL); - g_return_if_fail (! container || GIMP_IS_CONTAINER (container)); - - list_item->reorderable = reorderable; - - if (reorderable) - { - list_item->container = container; - - gimp_gtk_drag_dest_set_by_type (GTK_WIDGET (list_item), - GTK_DEST_DEFAULT_ALL, - container->children_type, - GDK_ACTION_MOVE | GDK_ACTION_COPY); - } - else - { - list_item->container = NULL; - - gtk_drag_dest_unset (GTK_WIDGET (list_item)); - } -} - -gboolean -gimp_list_item_check_drag (GimpListItem *list_item, - GdkDragContext *context, - gint x, - gint y, - GimpViewable **src_viewable, - gint *dest_index, - GdkDragAction *drag_action, - GimpDropType *drop_type) -{ - GtkWidget *src_widget; - GimpViewable *my_src_viewable = NULL; - GimpViewable *my_dest_viewable = NULL; - gint my_src_index = -1; - gint my_dest_index = -1; - GdkDragAction my_drag_action = GDK_ACTION_DEFAULT; - GimpDropType my_drop_type = GIMP_DROP_NONE; - gboolean return_val = FALSE; - - if (list_item->reorderable && - list_item->container && - (src_widget = gtk_drag_get_source_widget (context)) && - src_widget != GTK_WIDGET (list_item)) - { - my_src_viewable = gimp_dnd_get_drag_data (src_widget); - my_dest_viewable = GIMP_PREVIEW (list_item->preview)->viewable; - - if (my_src_viewable && my_dest_viewable) - { - my_src_index = - gimp_container_get_child_index (list_item->container, - GIMP_OBJECT (my_src_viewable)); - my_dest_index = - gimp_container_get_child_index (list_item->container, - GIMP_OBJECT (my_dest_viewable)); - - if (my_src_viewable && my_src_index != -1 && - my_dest_viewable && my_dest_index != -1) - { - gint difference; - - difference = my_dest_index - my_src_index; - - if (y < GTK_WIDGET (list_item)->allocation.height / 2) - my_drop_type = GIMP_DROP_ABOVE; - else - my_drop_type = GIMP_DROP_BELOW; - - if (difference < 0 && my_drop_type == GIMP_DROP_BELOW) - { - my_dest_index++; - } - else if (difference > 0 && my_drop_type == GIMP_DROP_ABOVE) - { - my_dest_index--; - } - - if (my_src_index != my_dest_index) - { - my_drag_action = GDK_ACTION_MOVE; - return_val = TRUE; - } - else - { - my_drop_type = GIMP_DROP_NONE; - } - } - } - } - - *src_viewable = my_src_viewable; - *dest_index = my_dest_index; - *drag_action = my_drag_action; - *drop_type = my_drop_type; - - return return_val; -} - -static void -gimp_list_item_name_changed (GimpViewable *viewable, - GtkLabel *label) -{ - gtk_label_set_text (label, gimp_object_get_name (GIMP_OBJECT (viewable))); -} - -static GimpViewable * -gimp_list_item_drag_viewable (GtkWidget *widget, - gpointer data) -{ - return GIMP_PREVIEW (GIMP_LIST_ITEM (widget)->preview)->viewable; -} diff --git a/app/gimplistitem.h b/app/gimplistitem.h deleted file mode 100644 index 069ca3ddbc..0000000000 --- a/app/gimplistitem.h +++ /dev/null @@ -1,96 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * gimplistitem.h - * Copyright (C) 2001 Michael Natterer - * - * 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_LIST_ITEM_H__ -#define __GIMP_LIST_ITEM_H__ - - -#include - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -#define GIMP_TYPE_LIST_ITEM (gimp_list_item_get_type ()) -#define GIMP_LIST_ITEM(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_LIST_ITEM, GimpListItem)) -#define GIMP_LIST_ITEM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_LIST_ITEM, GimpListItemClass)) -#define GIMP_IS_LIST_ITEM(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_LIST_ITEM)) -#define GIMP_IS_LIST_ITEM_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_LIST_ITEM)) - - -typedef struct _GimpListItemClass GimpListItemClass; - -struct _GimpListItem -{ - GtkListItem parent_instance; - - GtkWidget *hbox; - - GtkWidget *preview; - GtkWidget *name_label; - - /*< protected >*/ - gint preview_size; - - /*< private >*/ - gboolean reorderable; - GimpContainer *container; - GimpDropType drop_type; -}; - -struct _GimpListItemClass -{ - GtkListItemClass parent_class; - - void (* set_viewable) (GimpListItem *list_item, - GimpViewable *viewable); -}; - - -GtkType gimp_list_item_get_type (void); -GtkWidget * gimp_list_item_new (GimpViewable *viewable, - gint preview_size); - -void gimp_list_item_set_reorderable (GimpListItem *list_item, - gboolean reorderable, - GimpContainer *container); - - -/* protected */ - -gboolean gimp_list_item_check_drag (GimpListItem *list_item, - GdkDragContext *context, - gint x, - gint y, - GimpViewable **src_viewable, - gint *dest_index, - GdkDragAction *drag_action, - GimpDropType *drop_type); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __GIMP_LIST_ITEM_H__ */ diff --git a/app/gimppalettepreview.c b/app/gimppalettepreview.c deleted file mode 100644 index fd35cab0b3..0000000000 --- a/app/gimppalettepreview.c +++ /dev/null @@ -1,175 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * GimpPalettePreview Widget - * Copyright (C) 2001 Michael Natterer - * - * 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 - -#include "apptypes.h" - -#include "gimppalette.h" -#include "gimppalettepreview.h" -#include "temp_buf.h" - - -static void gimp_palette_preview_class_init (GimpPalettePreviewClass *klass); -static void gimp_palette_preview_init (GimpPalettePreview *preview); - -static void gimp_palette_preview_get_size (GimpPreview *preview, - gint size, - gint *width, - gint *height); -static void gimp_palette_preview_render (GimpPreview *preview); -static GtkWidget * gimp_palette_preview_create_popup (GimpPreview *preview); -static gboolean gimp_palette_preview_needs_popup (GimpPreview *preview); - - -static GimpPreviewClass *parent_class = NULL; - - -GtkType -gimp_palette_preview_get_type (void) -{ - static GtkType preview_type = 0; - - if (! preview_type) - { - GtkTypeInfo preview_info = - { - "GimpPalettePreview", - sizeof (GimpPalettePreview), - sizeof (GimpPalettePreviewClass), - (GtkClassInitFunc) gimp_palette_preview_class_init, - (GtkObjectInitFunc) gimp_palette_preview_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL - }; - - preview_type = gtk_type_unique (GIMP_TYPE_PREVIEW, &preview_info); - } - - return preview_type; -} - -static void -gimp_palette_preview_class_init (GimpPalettePreviewClass *klass) -{ - GtkObjectClass *object_class; - GimpPreviewClass *preview_class; - - object_class = (GtkObjectClass *) klass; - preview_class = (GimpPreviewClass *) klass; - - parent_class = gtk_type_class (GIMP_TYPE_PREVIEW); - - preview_class->get_size = gimp_palette_preview_get_size; - preview_class->render = gimp_palette_preview_render; - preview_class->create_popup = gimp_palette_preview_create_popup; - preview_class->needs_popup = gimp_palette_preview_needs_popup; -} - -static void -gimp_palette_preview_init (GimpPalettePreview *palette_preview) -{ -} - -static void -gimp_palette_preview_get_size (GimpPreview *preview, - gint size, - gint *width, - gint *height) -{ - *width = size * 3; - *height = size; -} - -static void -gimp_palette_preview_render (GimpPreview *preview) -{ - GimpPalette *palette; - TempBuf *temp_buf; - gint width; - gint height; - - palette = GIMP_PALETTE (preview->viewable); - - width = preview->width; - height = preview->height; - - temp_buf = gimp_viewable_get_new_preview (preview->viewable, - width, height); - - gimp_preview_render_and_flush (preview, - temp_buf, - -1); - - temp_buf_free (temp_buf); -} - -static GtkWidget * -gimp_palette_preview_create_popup (GimpPreview *preview) -{ - GimpPalette *palette; - gint popup_width; - gint popup_height; - - palette = GIMP_PALETTE (preview->viewable); - - if (palette->n_columns) - popup_width = palette->n_columns; - else - popup_width = MIN (palette->n_colors, 16); - - popup_height = MAX (1, palette->n_colors / popup_width); - - return gimp_preview_new_full (preview->viewable, - popup_width * 4, - popup_height * 4, - 0, - TRUE, FALSE, FALSE); -} - -static gboolean -gimp_palette_preview_needs_popup (GimpPreview *preview) -{ - GimpPalette *palette; - gint popup_width; - gint popup_height; - - palette = GIMP_PALETTE (preview->viewable); - - if (! palette->n_colors) - return FALSE; - - if (palette->n_columns) - popup_width = palette->n_columns; - else - popup_width = MIN (palette->n_colors, 16); - - popup_height = MAX (1, palette->n_colors / popup_width); - - if (popup_width * 4 > preview->width || - popup_height * 4 > preview->height) - return TRUE; - - return FALSE; -} diff --git a/app/gimppalettepreview.h b/app/gimppalettepreview.h deleted file mode 100644 index 5e59d264c8..0000000000 --- a/app/gimppalettepreview.h +++ /dev/null @@ -1,61 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * GimpPalettePreview Widget - * Copyright (C) 2001 Michael Natterer - * - * 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_PALETTE_PREVIEW_H__ -#define __GIMP_PALETTE_PREVIEW_H__ - - -#include "gimppreview.h" - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -#define GIMP_TYPE_PALETTE_PREVIEW (gimp_palette_preview_get_type ()) -#define GIMP_PALETTE_PREVIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_PALETTE_PREVIEW, GimpPalettePreview)) -#define GIMP_PALETTE_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PALETTE_PREVIEW, GimpPalettePreviewClass)) -#define GIMP_IS_PALETTE_PREVIEW(obj) (GTK_CHECK_TYPE (obj, GIMP_TYPE_PALETTE_PREVIEW)) -#define GIMP_IS_PALETTE_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PALETTE_PREVIEW)) - - -typedef struct _GimpPalettePreviewClass GimpPalettePreviewClass; - -struct _GimpPalettePreview -{ - GimpPreview parent_instance; -}; - -struct _GimpPalettePreviewClass -{ - GimpPreviewClass parent_class; -}; - - -GtkType gimp_palette_preview_get_type (void); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __GIMP_PALETTE_PREVIEW_H__ */ diff --git a/app/gimppatternpreview.c b/app/gimppatternpreview.c deleted file mode 100644 index c9280ae79a..0000000000 --- a/app/gimppatternpreview.c +++ /dev/null @@ -1,167 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * GimpPatternPreview Widget - * Copyright (C) 2001 Michael Natterer - * - * 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 - -#include "apptypes.h" - -#include "gimppattern.h" -#include "gimppatternpreview.h" -#include "temp_buf.h" - - -static void gimp_pattern_preview_class_init (GimpPatternPreviewClass *klass); -static void gimp_pattern_preview_init (GimpPatternPreview *preview); - -static void gimp_pattern_preview_render (GimpPreview *preview); -static GtkWidget * gimp_pattern_preview_create_popup (GimpPreview *preview); -static gboolean gimp_pattern_preview_needs_popup (GimpPreview *preview); - - -static GimpPreviewClass *parent_class = NULL; - - -GtkType -gimp_pattern_preview_get_type (void) -{ - static GtkType preview_type = 0; - - if (! preview_type) - { - GtkTypeInfo preview_info = - { - "GimpPatternPreview", - sizeof (GimpPatternPreview), - sizeof (GimpPatternPreviewClass), - (GtkClassInitFunc) gimp_pattern_preview_class_init, - (GtkObjectInitFunc) gimp_pattern_preview_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL - }; - - preview_type = gtk_type_unique (GIMP_TYPE_PREVIEW, &preview_info); - } - - return preview_type; -} - -static void -gimp_pattern_preview_class_init (GimpPatternPreviewClass *klass) -{ - GtkObjectClass *object_class; - GimpPreviewClass *preview_class; - - object_class = (GtkObjectClass *) klass; - preview_class = (GimpPreviewClass *) klass; - - parent_class = gtk_type_class (GIMP_TYPE_PREVIEW); - - preview_class->render = gimp_pattern_preview_render; - preview_class->create_popup = gimp_pattern_preview_create_popup; - preview_class->needs_popup = gimp_pattern_preview_needs_popup; -} - -static void -gimp_pattern_preview_init (GimpPatternPreview *pattern_preview) -{ -} - -static void -gimp_pattern_preview_render (GimpPreview *preview) -{ - GimpPattern *pattern; - TempBuf *temp_buf; - gint width; - gint height; - gint pattern_width; - gint pattern_height; - - pattern = GIMP_PATTERN (preview->viewable); - pattern_width = pattern->mask->width; - pattern_height = pattern->mask->height; - - width = preview->width; - height = preview->height; - - if (width == pattern_width && - height == pattern_height) - { - gimp_preview_render_and_flush (preview, - pattern->mask, - -1); - - return; - } - else if (width <= pattern_width && - height <= pattern_height) - { - gimp_preview_render_and_flush (preview, - pattern->mask, - -1); - - return; - } - - temp_buf = gimp_viewable_get_new_preview (preview->viewable, - width, height); - - gimp_preview_render_and_flush (preview, - temp_buf, - -1); - - temp_buf_free (temp_buf); -} - -static GtkWidget * -gimp_pattern_preview_create_popup (GimpPreview *preview) -{ - gint popup_width; - gint popup_height; - - popup_width = GIMP_PATTERN (preview->viewable)->mask->width; - popup_height = GIMP_PATTERN (preview->viewable)->mask->height; - - return gimp_preview_new_full (preview->viewable, - popup_width, - popup_height, - 0, - TRUE, FALSE, FALSE); -} - -static gboolean -gimp_pattern_preview_needs_popup (GimpPreview *preview) -{ - GimpPattern *pattern; - gint pattern_width; - gint pattern_height; - - pattern = GIMP_PATTERN (preview->viewable); - pattern_width = pattern->mask->width; - pattern_height = pattern->mask->height; - - if (pattern_width > preview->width || pattern_height > preview->height) - return TRUE; - - return FALSE; -} diff --git a/app/gimppatternpreview.h b/app/gimppatternpreview.h deleted file mode 100644 index 44cb5d8ace..0000000000 --- a/app/gimppatternpreview.h +++ /dev/null @@ -1,61 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * GimpPatternPreview Widget - * Copyright (C) 2001 Michael Natterer - * - * 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_PATTERN_PREVIEW_H__ -#define __GIMP_PATTERN_PREVIEW_H__ - - -#include "gimppreview.h" - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -#define GIMP_TYPE_PATTERN_PREVIEW (gimp_pattern_preview_get_type ()) -#define GIMP_PATTERN_PREVIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_PATTERN_PREVIEW, GimpPatternPreview)) -#define GIMP_PATTERN_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PATTERN_PREVIEW, GimpPatternPreviewClass)) -#define GIMP_IS_PATTERN_PREVIEW(obj) (GTK_CHECK_TYPE (obj, GIMP_TYPE_PATTERN_PREVIEW)) -#define GIMP_IS_PATTERN_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PATTERN_PREVIEW)) - - -typedef struct _GimpPatternPreviewClass GimpPatternPreviewClass; - -struct _GimpPatternPreview -{ - GimpPreview parent_instance; -}; - -struct _GimpPatternPreviewClass -{ - GimpPreviewClass parent_class; -}; - - -GtkType gimp_pattern_preview_get_type (void); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __GIMP_PATTERN_PREVIEW_H__ */ diff --git a/app/gimppreview.c b/app/gimppreview.c deleted file mode 100644 index 011ba7071e..0000000000 --- a/app/gimppreview.c +++ /dev/null @@ -1,1111 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * GimpPreview Widget - * Copyright (C) 2001 Michael Natterer - * - * 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 - -#include - -#include "libgimpcolor/gimpcolor.h" -#include "libgimpwidgets/gimpwidgets.h" - -#include "apptypes.h" - -#include "tools/gimptoolinfo.h" - -#include "gimpbrush.h" -#include "gimpbrushpreview.h" -#include "gimpdnd.h" -#include "gimpdrawable.h" -#include "gimpdrawablepreview.h" -#include "gimpgradient.h" -#include "gimpgradientpreview.h" -#include "gimpimage.h" -#include "gimpimagepreview.h" -#include "gimpmarshal.h" -#include "gimppalette.h" -#include "gimppalettepreview.h" -#include "gimppattern.h" -#include "gimppatternpreview.h" -#include "gimppreview.h" -#include "gimptoolinfopreview.h" -#include "gimpviewable.h" -#include "image_render.h" -#include "temp_buf.h" - -#include "libgimp/gimplimits.h" - - -#define PREVIEW_POPUP_DELAY 150 - -#define PREVIEW_EVENT_MASK (GDK_BUTTON_PRESS_MASK | \ - GDK_BUTTON_RELEASE_MASK | \ - GDK_ENTER_NOTIFY_MASK | \ - GDK_LEAVE_NOTIFY_MASK) - -enum -{ - CLICKED, - DOUBLE_CLICKED, - RENDER, - GET_SIZE, - NEEDS_POPUP, - CREATE_POPUP, - LAST_SIGNAL -}; - - -static void gimp_preview_class_init (GimpPreviewClass *klass); -static void gimp_preview_init (GimpPreview *preview); -static void gimp_preview_destroy (GtkObject *object); -static void gimp_preview_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static gint gimp_preview_button_press_event (GtkWidget *widget, - GdkEventButton *bevent); -static gint gimp_preview_button_release_event (GtkWidget *widget, - GdkEventButton *bevent); -static gint gimp_preview_enter_notify_event (GtkWidget *widget, - GdkEventCrossing *event); -static gint gimp_preview_leave_notify_event (GtkWidget *widget, - GdkEventCrossing *event); - -static void gimp_preview_real_render (GimpPreview *preview); -static void gimp_preview_get_size (GimpPreview *preview, - gint size, - gint *width, - gint *height); -static void gimp_preview_real_get_size (GimpPreview *preview, - gint size, - gint *width, - gint *height); -static gboolean gimp_preview_needs_popup (GimpPreview *preview); -static gboolean gimp_preview_real_needs_popup (GimpPreview *preview); -static GtkWidget * gimp_preview_create_popup (GimpPreview *preview); -static GtkWidget * gimp_preview_real_create_popup (GimpPreview *preview); - -static void gimp_preview_popup_show (GimpPreview *preview, - gint x, - gint y); -static void gimp_preview_popup_hide (GimpPreview *preview); -static void gimp_preview_paint (GimpPreview *preview); -static gboolean gimp_preview_idle_paint (GimpPreview *preview); -static GimpViewable * gimp_preview_drag_viewable (GtkWidget *widget, - gpointer data); - - -static guint preview_signals[LAST_SIGNAL] = { 0 }; - -static GtkPreviewClass *parent_class = NULL; - - -GtkType -gimp_preview_get_type (void) -{ - static GtkType preview_type = 0; - - if (! preview_type) - { - GtkTypeInfo preview_info = - { - "GimpPreview", - sizeof (GimpPreview), - sizeof (GimpPreviewClass), - (GtkClassInitFunc) gimp_preview_class_init, - (GtkObjectInitFunc) gimp_preview_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL - }; - - preview_type = gtk_type_unique (GTK_TYPE_PREVIEW, &preview_info); - } - - return preview_type; -} - -static void -gimp_preview_class_init (GimpPreviewClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) klass; - widget_class = (GtkWidgetClass *) klass; - - parent_class = gtk_type_class (GTK_TYPE_PREVIEW); - - preview_signals[CLICKED] = - gtk_signal_new ("clicked", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (GimpPreviewClass, - clicked), - gtk_signal_default_marshaller, - GTK_TYPE_NONE, 0); - - preview_signals[DOUBLE_CLICKED] = - gtk_signal_new ("double_clicked", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (GimpPreviewClass, - double_clicked), - gtk_signal_default_marshaller, - GTK_TYPE_NONE, 0); - - preview_signals[RENDER] = - gtk_signal_new ("render", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (GimpPreviewClass, - render), - gtk_signal_default_marshaller, - GTK_TYPE_NONE, 0); - - preview_signals[GET_SIZE] = - gtk_signal_new ("get_size", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (GimpPreviewClass, - get_size), - gimp_marshal_NONE__INT_POINTER_POINTER, - GTK_TYPE_NONE, 3, - GTK_TYPE_INT, - GTK_TYPE_POINTER, - GTK_TYPE_POINTER); - - preview_signals[NEEDS_POPUP] = - gtk_signal_new ("needs_popup", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (GimpPreviewClass, - needs_popup), - gtk_marshal_BOOL__NONE, - GTK_TYPE_BOOL, 0); - - preview_signals[CREATE_POPUP] = - gtk_signal_new ("create_popup", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (GimpPreviewClass, - create_popup), - gimp_marshal_POINTER__NONE, - GTK_TYPE_POINTER, 0); - - gtk_object_class_add_signals (object_class, preview_signals, LAST_SIGNAL); - - object_class->destroy = gimp_preview_destroy; - - widget_class->size_allocate = gimp_preview_size_allocate; - widget_class->button_press_event = gimp_preview_button_press_event; - widget_class->button_release_event = gimp_preview_button_release_event; - widget_class->enter_notify_event = gimp_preview_enter_notify_event; - widget_class->leave_notify_event = gimp_preview_leave_notify_event; - - klass->clicked = NULL; - klass->double_clicked = NULL; - klass->render = gimp_preview_real_render; - klass->get_size = gimp_preview_real_get_size; - klass->needs_popup = gimp_preview_real_needs_popup; - klass->create_popup = gimp_preview_real_create_popup; -} - -static void -gimp_preview_init (GimpPreview *preview) -{ - preview->viewable = NULL; - - preview->width = 8; - preview->height = 8; - preview->border_width = 0; - - gimp_rgba_set (&preview->border_color, 0.0, 0.0, 0.0, 1.0); - - preview->is_popup = FALSE; - preview->clickable = FALSE; - preview->show_popup = FALSE; - - preview->in_button = FALSE; - preview->idle_id = 0; - preview->popup_id = 0; - preview->popup_x = 0; - preview->popup_y = 0; - - GTK_PREVIEW (preview)->type = GTK_PREVIEW_COLOR; - GTK_PREVIEW (preview)->bpp = 3; - GTK_PREVIEW (preview)->dither = GDK_RGB_DITHER_NORMAL; - - gtk_widget_set_events (GTK_WIDGET (preview), PREVIEW_EVENT_MASK); -} - -static void -gimp_preview_destroy (GtkObject *object) -{ - GimpPreview *preview; - - preview = GIMP_PREVIEW (object); - - if (preview->idle_id) - { - g_source_remove (preview->idle_id); - } - - gimp_preview_popup_hide (preview); - - gimp_preview_set_viewable (preview, NULL); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gimp_preview_new (GimpViewable *viewable, - gint size, - gint border_width, - gboolean is_popup) -{ - GimpPreview *preview; - gint width, height; - - g_return_val_if_fail (viewable != NULL, NULL); - g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL); - g_return_val_if_fail (size > 0 && size <= 256, NULL); - g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL); - - if (GIMP_IS_BRUSH (viewable)) - { - preview = gtk_type_new (GIMP_TYPE_BRUSH_PREVIEW); - } - else if (GIMP_IS_DRAWABLE (viewable)) - { - preview = gtk_type_new (GIMP_TYPE_DRAWABLE_PREVIEW); - } - else if (GIMP_IS_IMAGE (viewable)) - { - preview = gtk_type_new (GIMP_TYPE_IMAGE_PREVIEW); - } - else if (GIMP_IS_PATTERN (viewable)) - { - preview = gtk_type_new (GIMP_TYPE_PATTERN_PREVIEW); - } - else if (GIMP_IS_GRADIENT (viewable)) - { - preview = gtk_type_new (GIMP_TYPE_GRADIENT_PREVIEW); - } - else if (GIMP_IS_PALETTE (viewable)) - { - preview = gtk_type_new (GIMP_TYPE_PALETTE_PREVIEW); - } - else if (GIMP_IS_TOOL_INFO (viewable)) - { - preview = gtk_type_new (GIMP_TYPE_TOOL_INFO_PREVIEW); - } - else - { - preview = gtk_type_new (GIMP_TYPE_PREVIEW); - } - - preview->is_popup = is_popup; - preview->border_width = border_width; - - gimp_preview_set_viewable (preview, viewable); - - gimp_preview_get_size (preview, size, &width, &height); - - preview->width = width; - preview->height = height; - - gtk_preview_size (GTK_PREVIEW (preview), - width + 2 * border_width, - height + 2 * border_width); - - return GTK_WIDGET (preview); -} - -GtkWidget * -gimp_preview_new_full (GimpViewable *viewable, - gint width, - gint height, - gint border_width, - gboolean is_popup, - gboolean clickable, - gboolean show_popup) -{ - GimpPreview *preview; - - g_return_val_if_fail (viewable != NULL, NULL); - g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL); - g_return_val_if_fail (width > 0 && width <= 256, NULL); - g_return_val_if_fail (height > 0 && height <= 256, NULL); - g_return_val_if_fail (border_width >= 0 && border_width <= 16, NULL); - - if (GIMP_IS_BRUSH (viewable)) - { - preview = gtk_type_new (GIMP_TYPE_BRUSH_PREVIEW); - } - else if (GIMP_IS_DRAWABLE (viewable)) - { - preview = gtk_type_new (GIMP_TYPE_DRAWABLE_PREVIEW); - } - else if (GIMP_IS_IMAGE (viewable)) - { - preview = gtk_type_new (GIMP_TYPE_IMAGE_PREVIEW); - } - else if (GIMP_IS_PATTERN (viewable)) - { - preview = gtk_type_new (GIMP_TYPE_PATTERN_PREVIEW); - } - else if (GIMP_IS_GRADIENT (viewable)) - { - preview = gtk_type_new (GIMP_TYPE_GRADIENT_PREVIEW); - } - else if (GIMP_IS_PALETTE (viewable)) - { - preview = gtk_type_new (GIMP_TYPE_PALETTE_PREVIEW); - } - else if (GIMP_IS_TOOL_INFO (viewable)) - { - preview = gtk_type_new (GIMP_TYPE_TOOL_INFO_PREVIEW); - } - else - { - preview = gtk_type_new (GIMP_TYPE_PREVIEW); - } - - preview->is_popup = is_popup; - - preview->width = width; - preview->height = height; - preview->border_width = border_width; - - preview->clickable = clickable; - preview->show_popup = show_popup; - - gimp_preview_set_viewable (preview, viewable); - - gtk_preview_size (GTK_PREVIEW (preview), - width + 2 * border_width, - height + 2 * border_width); - - return GTK_WIDGET (preview); -} - -void -gimp_preview_set_viewable (GimpPreview *preview, - GimpViewable *viewable) -{ - g_return_if_fail (preview != NULL); - g_return_if_fail (GIMP_IS_PREVIEW (preview)); - g_return_if_fail (! viewable || GIMP_IS_VIEWABLE (viewable)); - - if (preview->viewable) - { - if (! preview->is_popup) - { - GtkType type; - - type = GTK_OBJECT (preview->viewable)->klass->type; - - gtk_drag_source_unset (GTK_WIDGET (preview)); - gimp_dnd_viewable_source_unset (GTK_WIDGET (preview), type); - } - - gtk_signal_disconnect_by_func (GTK_OBJECT (preview->viewable), - gimp_preview_paint, - preview); - - gtk_signal_disconnect_by_func (GTK_OBJECT (preview->viewable), - gtk_widget_destroyed, - &preview->viewable); - } - - preview->viewable = viewable; - - if (preview->viewable) - { - if (! preview->is_popup) - { - GtkType type; - - type = GTK_OBJECT (preview->viewable)->klass->type; - - gimp_gtk_drag_source_set_by_type (GTK_WIDGET (preview), - GDK_BUTTON1_MASK | GDK_BUTTON2_MASK, - type, - GDK_ACTION_COPY); - gimp_dnd_viewable_source_set (GTK_WIDGET (preview), - type, - gimp_preview_drag_viewable, - NULL); - } - - gtk_signal_connect_object (GTK_OBJECT (preview->viewable), - "invalidate_preview", - GTK_SIGNAL_FUNC (gimp_preview_paint), - GTK_OBJECT (preview)); - - gtk_signal_connect (GTK_OBJECT (preview->viewable), "destroy", - GTK_SIGNAL_FUNC (gtk_widget_destroyed), - &preview->viewable); - - gimp_preview_render (preview); - } -} - -void -gimp_preview_set_size (GimpPreview *preview, - gint preview_size, - gint border_width) -{ - gint width, height; - - g_return_if_fail (preview != NULL); - g_return_if_fail (GIMP_IS_PREVIEW (preview)); - g_return_if_fail (preview_size > 0 && preview_size <= 256); - g_return_if_fail (border_width >= 0 && border_width <= 16); - - gimp_preview_get_size (preview, preview_size, &width, &height); - - gimp_preview_set_size_full (preview, - width, - height, - border_width); -} - -void -gimp_preview_set_size_full (GimpPreview *preview, - gint width, - gint height, - gint border_width) -{ - g_return_if_fail (preview != NULL); - g_return_if_fail (GIMP_IS_PREVIEW (preview)); - g_return_if_fail (width > 0 && width <= 256); - g_return_if_fail (height > 0 && height <= 256); - g_return_if_fail (border_width >= 0 && border_width <= 16); - - preview->width = width; - preview->height = height; - preview->border_width = border_width; - - gtk_preview_size (GTK_PREVIEW (preview), - width + 2 * preview->border_width, - height + 2 * preview->border_width); -} - -void -gimp_preview_set_border_color (GimpPreview *preview, - const GimpRGB *color) -{ - g_return_if_fail (preview != NULL); - g_return_if_fail (GIMP_IS_PREVIEW (preview)); - g_return_if_fail (color != NULL); - - if (gimp_rgb_distance (&preview->border_color, color)) - { - preview->border_color = *color; - - gimp_preview_render (preview); - } -} - -void -gimp_preview_render (GimpPreview *preview) -{ - gtk_signal_emit (GTK_OBJECT (preview), preview_signals[RENDER]); -} - -static gint -gimp_preview_button_press_event (GtkWidget *widget, - GdkEventButton *bevent) -{ - GimpPreview *preview; - - preview = GIMP_PREVIEW (widget); - - if (! preview->clickable && - ! preview->show_popup) - return FALSE; - - if (bevent->type == GDK_BUTTON_PRESS) - { - if (bevent->button == 1) - { - gtk_grab_add (widget); - - if (preview->show_popup && gimp_preview_needs_popup (preview)) - { - gimp_preview_popup_show (preview, - bevent->x, - bevent->y); - } - } - else - { - return FALSE; - } - } - else if (bevent->type == GDK_2BUTTON_PRESS) - { - if (bevent->button == 1) - { - gtk_signal_emit (GTK_OBJECT (widget), preview_signals[DOUBLE_CLICKED]); - } - } - - return TRUE; -} - -static gint -gimp_preview_button_release_event (GtkWidget *widget, - GdkEventButton *bevent) -{ - GimpPreview *preview; - gboolean click = TRUE; - - preview = GIMP_PREVIEW (widget); - - if (! preview->clickable && - ! preview->show_popup) - return FALSE; - - if (bevent->button == 1) - { - if (preview->show_popup && gimp_preview_needs_popup (preview)) - { - click = (preview->popup_id != 0); - } - - gimp_preview_popup_hide (preview); - - /* remove the grab _after_ hiding the popup */ - gtk_grab_remove (widget); - - if (preview->clickable && click && preview->in_button) - { - gtk_signal_emit (GTK_OBJECT (widget), preview_signals[CLICKED]); - } - } - else - { - return FALSE; - } - - return TRUE; -} - -static gint -gimp_preview_enter_notify_event (GtkWidget *widget, - GdkEventCrossing *event) -{ - GimpPreview *preview; - GtkWidget *event_widget; - - preview = GIMP_PREVIEW (widget); - event_widget = gtk_get_event_widget ((GdkEvent *) event); - - if ((event_widget == widget) && - (event->detail != GDK_NOTIFY_INFERIOR)) - { - preview->in_button = TRUE; - } - - return FALSE; -} - -static gint -gimp_preview_leave_notify_event (GtkWidget *widget, - GdkEventCrossing *event) -{ - GimpPreview *preview; - GtkWidget *event_widget; - - preview = GIMP_PREVIEW (widget); - event_widget = gtk_get_event_widget ((GdkEvent *) event); - - if ((event_widget == widget) && - (event->detail != GDK_NOTIFY_INFERIOR)) - { - preview->in_button = FALSE; - } - - return FALSE; -} - -static void -gimp_preview_real_render (GimpPreview *preview) -{ - TempBuf *temp_buf; - - temp_buf = gimp_viewable_get_new_preview (preview->viewable, - preview->width, - preview->height); - - if (temp_buf) - gimp_preview_render_and_flush (preview, - temp_buf, - -1); -} - -static void -gimp_preview_get_size (GimpPreview *preview, - gint size, - gint *width, - gint *height) -{ - g_return_if_fail (preview != NULL); - g_return_if_fail (GIMP_IS_PREVIEW (preview)); - g_return_if_fail (width != NULL); - g_return_if_fail (height != NULL); - - gtk_signal_emit (GTK_OBJECT (preview), preview_signals[GET_SIZE], - size, width, height); -} - -static void -gimp_preview_real_get_size (GimpPreview *preview, - gint size, - gint *width, - gint *height) -{ - *width = size; - *height = size; -} - -static gboolean -gimp_preview_needs_popup (GimpPreview *preview) -{ - gboolean needs_popup = FALSE; - - gtk_signal_emit (GTK_OBJECT (preview), preview_signals[NEEDS_POPUP], - &needs_popup); - - return needs_popup; -} - -static gboolean -gimp_preview_real_needs_popup (GimpPreview *preview) -{ - return TRUE; -} - -static GtkWidget * -gimp_preview_create_popup (GimpPreview *preview) -{ - GtkWidget *popup_preview = NULL; - - gtk_signal_emit (GTK_OBJECT (preview), preview_signals[CREATE_POPUP], - &popup_preview); - - return popup_preview; -} - -static GtkWidget * -gimp_preview_real_create_popup (GimpPreview *preview) -{ - gint popup_width; - gint popup_height; - - popup_width = MIN (preview->width * 2, 256); - popup_height = MIN (preview->height * 2, 256); - - return gimp_preview_new_full (preview->viewable, - popup_width, - popup_height, - 0, - TRUE, FALSE, FALSE); -} - -static gboolean -gimp_preview_popup_timeout (GimpPreview *preview) -{ - GtkWidget *widget; - GtkWidget *window; - GtkWidget *frame; - GtkWidget *popup_preview; - gint orig_x; - gint orig_y; - gint scr_width; - gint scr_height; - gint x; - gint y; - gint popup_width; - gint popup_height; - - widget = GTK_WIDGET (preview); - - x = preview->popup_x; - y = preview->popup_y; - - preview->popup_id = 0; - preview->popup_x = 0; - preview->popup_y = 0; - - window = gtk_window_new (GTK_WINDOW_POPUP); - gtk_window_set_policy (GTK_WINDOW (window), FALSE, FALSE, TRUE); - - frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT); - gtk_container_add (GTK_CONTAINER (window), frame); - gtk_widget_show (frame); - - popup_preview = gimp_preview_create_popup (preview); - - popup_width = popup_preview->requisition.width; - popup_height = popup_preview->requisition.height; - - gtk_container_add (GTK_CONTAINER (frame), popup_preview); - gtk_widget_show (popup_preview); - - gdk_window_get_origin (widget->window, &orig_x, &orig_y); - scr_width = gdk_screen_width (); - scr_height = gdk_screen_height (); - x = orig_x + x - (popup_width >> 1); - y = orig_y + y - (popup_height >> 1); - x = (x < 0) ? 0 : x; - y = (y < 0) ? 0 : y; - x = (x + popup_width > scr_width) ? scr_width - popup_width : x; - y = (y + popup_height > scr_height) ? scr_height - popup_height : y; - - gtk_widget_popup (window, x, y); - - gtk_object_set_data_full (GTK_OBJECT (preview), "preview_popup_window", window, - (GtkDestroyNotify) gtk_widget_destroy); - - return FALSE; -} - -static void -gimp_preview_popup_show (GimpPreview *preview, - gint x, - gint y) -{ - preview->popup_x = x; - preview->popup_y = y; - - preview->popup_id = g_timeout_add (PREVIEW_POPUP_DELAY, - (GSourceFunc) gimp_preview_popup_timeout, - preview); -} - -static void -gimp_preview_popup_hide (GimpPreview *preview) -{ - if (preview->popup_id) - { - g_source_remove (preview->popup_id); - - preview->popup_id = 0; - preview->popup_x = 0; - preview->popup_y = 0; - } - - gtk_object_set_data (GTK_OBJECT (preview), "preview_popup_window", NULL); -} - -static void -gimp_preview_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - if (GTK_WIDGET_CLASS (parent_class)->size_allocate) - GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation); - - gimp_preview_paint (GIMP_PREVIEW (widget)); -} - -static void -gimp_preview_paint (GimpPreview *preview) -{ - if (preview->idle_id) - { - g_source_remove (preview->idle_id); - } - - preview->idle_id = - g_idle_add_full (G_PRIORITY_LOW, - (GSourceFunc) gimp_preview_idle_paint, preview, - NULL); -} - -static gboolean -gimp_preview_idle_paint (GimpPreview *preview) -{ - preview->idle_id = 0; - - if (! preview->viewable) - return FALSE; - - gimp_preview_render (preview); - - return FALSE; -} - -void -gimp_preview_render_and_flush (GimpPreview *preview, - TempBuf *temp_buf, - gint channel) -{ - gint width; - gint height; - guchar *src, *s; - guchar *cb; - guchar *buf; - gint a; - gint i, j, b; - gint x1, y1, x2, y2; - gint rowstride; - gboolean color_buf; - gboolean color; - gint alpha; - gboolean has_alpha; - gint image_bytes; - gint offset; - gint border; - guchar border_color[3]; - - width = preview->width; - height = preview->height; - border = preview->border_width; - - gimp_rgb_get_uchar (&preview->border_color, - &border_color[0], - &border_color[1], - &border_color[2]); - - alpha = ALPHA_PIX; - - /* Here are the different cases this functions handles correctly: - * 1) Offset temp_buf which does not necessarily cover full image area - * 2) Color conversion of temp_buf if it is gray and image is color - * 3) Background check buffer for transparent temp_bufs - * 4) Using the optional "channel" argument, one channel can be extracted - * from a multi-channel temp_buf and composited as a grayscale - * Prereqs: - * 1) Grayscale temp_bufs have bytes == {1, 2} - * 2) Color temp_bufs have bytes == {3, 4} - * 3) If image is gray, then temp_buf should have bytes == {1, 2} - */ - color_buf = (GTK_PREVIEW (preview)->type == GTK_PREVIEW_COLOR); - image_bytes = (color_buf) ? 3 : 1; - has_alpha = (temp_buf->bytes == 2 || temp_buf->bytes == 4); - rowstride = temp_buf->width * temp_buf->bytes; - - /* Determine if the preview buf supplied is color - * Generally, if the bytes == {3, 4}, this is true. - * However, if the channel argument supplied is not -1, then - * the preview buf is assumed to be gray despite the number of - * channels it contains - */ - color = ((channel == -1) && - (temp_buf->bytes == 3 || temp_buf->bytes == 4)); - - if (has_alpha) - { - buf = render_check_buf; - alpha = ((color) ? ALPHA_PIX : - ((channel != -1) ? (temp_buf->bytes - 1) : - ALPHA_G_PIX)); - } - else - { - buf = render_empty_buf; - } - - x1 = CLAMP (temp_buf->x, 0, width); - y1 = CLAMP (temp_buf->y, 0, height); - x2 = CLAMP (temp_buf->x + temp_buf->width, 0, width); - y2 = CLAMP (temp_buf->y + temp_buf->height, 0, height); - - src = temp_buf_data (temp_buf) + ((y1 - temp_buf->y) * rowstride + - (x1 - temp_buf->x) * temp_buf->bytes); - - /* One last thing for efficiency's sake: */ - if (channel == -1) - channel = 0; - - /* Set the border color once before rendering */ - for (j = 0; j < width + border * 2; j++) - { - render_temp_buf[j * 3 + 0] = border_color[0]; - render_temp_buf[j * 3 + 1] = border_color[1]; - render_temp_buf[j * 3 + 2] = border_color[2]; - } - - for (i = 0; i < border; i++) - gtk_preview_draw_row (GTK_PREVIEW (preview), - render_temp_buf, - 0, i, - width + 2 * border); - - for (i = border + height; i < 2 * border + height; i++) - gtk_preview_draw_row (GTK_PREVIEW (preview), - render_temp_buf, - 0, i, - width + 2 * border); - - for (i = 0; i < height; i++) - { - if (i & 0x4) - { - offset = 4; - cb = buf + offset * 3; - } - else - { - offset = 0; - cb = buf; - } - - /* The interesting stuff between leading & trailing - * vertical transparency - */ - if (i >= y1 && i < y2) - { - /* Handle the leading transparency */ - for (j = 0; j < x1; j++) - for (b = 0; b < image_bytes; b++) - render_temp_buf[(border + j) * image_bytes + b] = cb[j * 3 + b]; - - /* The stuff in the middle */ - s = src; - for (j = x1; j < x2; j++) - { - if (color) - { - if (has_alpha) - { - a = s[alpha] << 8; - - if ((j + offset) & 0x4) - { - render_temp_buf[(border + j) * 3 + 0] = - render_blend_dark_check [(a | s[RED_PIX])]; - render_temp_buf[(border + j) * 3 + 1] = - render_blend_dark_check [(a | s[GREEN_PIX])]; - render_temp_buf[(border + j) * 3 + 2] = - render_blend_dark_check [(a | s[BLUE_PIX])]; - } - else - { - render_temp_buf[(border + j) * 3 + 0] = - render_blend_light_check [(a | s[RED_PIX])]; - render_temp_buf[(border + j) * 3 + 1] = - render_blend_light_check [(a | s[GREEN_PIX])]; - render_temp_buf[(border + j) * 3 + 2] = - render_blend_light_check [(a | s[BLUE_PIX])]; - } - } - else - { - render_temp_buf[(border + j) * 3 + 0] = s[RED_PIX]; - render_temp_buf[(border + j) * 3 + 1] = s[GREEN_PIX]; - render_temp_buf[(border + j) * 3 + 2] = s[BLUE_PIX]; - } - } - else - { - if (has_alpha) - { - a = s[alpha] << 8; - - if ((j + offset) & 0x4) - { - if (color_buf) - { - render_temp_buf[(border + j) * 3 + 0] = - render_blend_dark_check [(a | s[GRAY_PIX])]; - render_temp_buf[(border + j) * 3 + 1] = - render_blend_dark_check [(a | s[GRAY_PIX])]; - render_temp_buf[(border + j) * 3 + 2] = - render_blend_dark_check [(a | s[GRAY_PIX])]; - } - else - { - render_temp_buf[(border + j)] = - render_blend_dark_check [(a | s[GRAY_PIX + channel])]; - } - } - else - { - if (color_buf) - { - render_temp_buf[(border + j) * 3 + 0] = - render_blend_light_check [(a | s[GRAY_PIX])]; - render_temp_buf[(border + j) * 3 + 1] = - render_blend_light_check [(a | s[GRAY_PIX])]; - render_temp_buf[(border + j) * 3 + 2] = - render_blend_light_check [(a | s[GRAY_PIX])]; - } - else - { - render_temp_buf[(border + j)] = - render_blend_light_check [(a | s[GRAY_PIX + channel])]; - } - } - } - else - { - if (color_buf) - { - render_temp_buf[(border + j) * 3 + 0] = s[GRAY_PIX]; - render_temp_buf[(border + j) * 3 + 1] = s[GRAY_PIX]; - render_temp_buf[(border + j) * 3 + 2] = s[GRAY_PIX]; - } - else - { - render_temp_buf[(border + j)] = s[GRAY_PIX + channel]; - } - } - } - - s += temp_buf->bytes; - } - - /* Handle the trailing transparency */ - for (j = x2; j < width; j++) - for (b = 0; b < image_bytes; b++) - render_temp_buf[(border + j) * image_bytes + b] = cb[j * 3 + b]; - - src += rowstride; - } - else - { - for (j = 0; j < width; j++) - for (b = 0; b < image_bytes; b++) - render_temp_buf[(border + j) * image_bytes + b] = cb[j * 3 + b]; - } - - gtk_preview_draw_row (GTK_PREVIEW (preview), - render_temp_buf, - 0, - i + border, - width + 2 * border); - } - - gtk_widget_queue_draw (GTK_WIDGET (preview)); -} - -static GimpViewable * -gimp_preview_drag_viewable (GtkWidget *widget, - gpointer data) -{ - return GIMP_PREVIEW (widget)->viewable; -} diff --git a/app/gimppreview.h b/app/gimppreview.h deleted file mode 100644 index 6e5a8b00a2..0000000000 --- a/app/gimppreview.h +++ /dev/null @@ -1,125 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * GimpPreview Widget - * Copyright (C) 2001 Michael Natterer - * - * 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_H__ -#define __GIMP_PREVIEW_H__ - - -#include - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -#define GIMP_TYPE_PREVIEW (gimp_preview_get_type ()) -#define GIMP_PREVIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_PREVIEW, GimpPreview)) -#define GIMP_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PREVIEW, GimpPreviewClass)) -#define GIMP_IS_PREVIEW(obj) (GTK_CHECK_TYPE (obj, GIMP_TYPE_PREVIEW)) -#define GIMP_IS_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PREVIEW)) - - -typedef struct _GimpPreviewClass GimpPreviewClass; - -struct _GimpPreview -{ - GtkPreview parent_instance; - - GimpViewable *viewable; - - gint width; - gint height; - gint border_width; - - GimpRGB border_color; - - gboolean is_popup; - gboolean clickable; - gboolean show_popup; - - /*< private >*/ - gboolean in_button; - guint idle_id; - guint popup_id; - gint popup_x; - gint popup_y; -}; - -struct _GimpPreviewClass -{ - GtkPreviewClass parent_class; - - void (* clicked) (GimpPreview *preview); - void (* double_clicked) (GimpPreview *preview); - void (* render) (GimpPreview *preview); - void (* get_size) (GimpPreview *preview, - gint size, - gint *width, - gint *height); - gboolean (* needs_popup) (GimpPreview *preview); - GtkWidget * (* create_popup) (GimpPreview *preview); -}; - - -GtkType gimp_preview_get_type (void); - -GtkWidget * gimp_preview_new (GimpViewable *viewable, - gint size, - gint border_width, - gboolean is_popup); -GtkWidget * gimp_preview_new_full (GimpViewable *viewable, - gint width, - gint height, - gint border_width, - gboolean is_popup, - gboolean clickable, - gboolean show_popup); - -void gimp_preview_set_viewable (GimpPreview *preview, - GimpViewable *viewable); - -void gimp_preview_set_size (GimpPreview *preview, - gint size, - gint border_width); -void gimp_preview_set_size_full (GimpPreview *preview, - gint width, - gint height, - gint border_width); - -void gimp_preview_set_border_color (GimpPreview *preview, - const GimpRGB *border_color); - -void gimp_preview_render (GimpPreview *preview); - - -/* protected */ - -void gimp_preview_render_and_flush (GimpPreview *preview, - TempBuf *temp_buf, - gint channel); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __GIMP_PREVIEW_H__ */ diff --git a/app/gimptoolinfopreview.c b/app/gimptoolinfopreview.c deleted file mode 100644 index b211f640f2..0000000000 --- a/app/gimptoolinfopreview.c +++ /dev/null @@ -1,218 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * GimpToolInfoPreview Widget - * Copyright (C) 2001 Michael Natterer - * - * 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 - -#include "apptypes.h" - -#include "tools/gimptoolinfo.h" - -#include "gimptoolinfopreview.h" -#include "temp_buf.h" - - -/* FIXME: make tool icons nicer */ -#define TOOL_INFO_WIDTH 22 -#define TOOL_INFO_HEIGHT 22 - - -static void gimp_tool_info_preview_class_init (GimpToolInfoPreviewClass *klass); -static void gimp_tool_info_preview_init (GimpToolInfoPreview *preview); - -static void gimp_tool_info_preview_state_changed (GtkWidget *widget, - GtkStateType previous_state); -static void gimp_tool_info_preview_render (GimpPreview *preview); -static GtkWidget * gimp_tool_info_preview_create_popup (GimpPreview *preview); -static gboolean gimp_tool_info_preview_needs_popup (GimpPreview *preview); - - -static GimpPreviewClass *parent_class = NULL; - - -GtkType -gimp_tool_info_preview_get_type (void) -{ - static GtkType preview_type = 0; - - if (! preview_type) - { - GtkTypeInfo preview_info = - { - "GimpToolInfoPreview", - sizeof (GimpToolInfoPreview), - sizeof (GimpToolInfoPreviewClass), - (GtkClassInitFunc) gimp_tool_info_preview_class_init, - (GtkObjectInitFunc) gimp_tool_info_preview_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL - }; - - preview_type = gtk_type_unique (GIMP_TYPE_PREVIEW, &preview_info); - } - - return preview_type; -} - -static void -gimp_tool_info_preview_class_init (GimpToolInfoPreviewClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GimpPreviewClass *preview_class; - - object_class = (GtkObjectClass *) klass; - widget_class = (GtkWidgetClass *) klass; - preview_class = (GimpPreviewClass *) klass; - - parent_class = gtk_type_class (GIMP_TYPE_PREVIEW); - - widget_class->state_changed = gimp_tool_info_preview_state_changed; - - preview_class->render = gimp_tool_info_preview_render; - preview_class->create_popup = gimp_tool_info_preview_create_popup; - preview_class->needs_popup = gimp_tool_info_preview_needs_popup; -} - -static void -gimp_tool_info_preview_init (GimpToolInfoPreview *tool_info_preview) -{ -} - -static void -gimp_tool_info_preview_state_changed (GtkWidget *widget, - GtkStateType previous_state) -{ - gimp_preview_render (GIMP_PREVIEW (widget)); -} - -static void -gimp_tool_info_preview_render (GimpPreview *preview) -{ - GtkWidget *widget; - GimpToolInfo *tool_info; - TempBuf *temp_buf; - TempBuf *render_buf; - guchar color[3]; - gint width; - gint height; - gint tool_info_width; - gint tool_info_height; - gint x, y; - guchar *src; - guchar *dest; - gboolean new_buf = FALSE; - - widget = GTK_WIDGET (preview); - - tool_info = GIMP_TOOL_INFO (preview->viewable); - tool_info_width = TOOL_INFO_WIDTH; - tool_info_height = TOOL_INFO_HEIGHT; - - width = preview->width; - height = preview->height; - - if (width == tool_info_width && - height == tool_info_height) - { - temp_buf = gimp_viewable_get_preview (preview->viewable, - width, height); - } - else - { - temp_buf = gimp_viewable_get_new_preview (preview->viewable, - width, height); - new_buf = TRUE; - } - - color[0] = widget->style->bg[widget->state].red >> 8; - color[1] = widget->style->bg[widget->state].green >> 8; - color[2] = widget->style->bg[widget->state].blue >> 8; - - render_buf = temp_buf_new (width, height, 3, 0, 0, color); - - src = temp_buf_data (temp_buf); - dest = temp_buf_data (render_buf); - - for (y = 0; y < height; y++) - { - for (x = 0; x < width; x++) - { - if (src[3] != 0) - { - *dest++ = *src++; - *dest++ = *src++; - *dest++ = *src++; - - src++; - } - else - { - src += 4; - dest += 3; - } - } - } - - if (new_buf) - temp_buf_free (temp_buf); - - gimp_preview_render_and_flush (preview, - render_buf, - -1); - - temp_buf_free (render_buf); -} - -static GtkWidget * -gimp_tool_info_preview_create_popup (GimpPreview *preview) -{ - gint popup_width; - gint popup_height; - - popup_width = TOOL_INFO_WIDTH; - popup_height = TOOL_INFO_HEIGHT; - - return gimp_preview_new_full (preview->viewable, - popup_width, - popup_height, - 0, - TRUE, FALSE, FALSE); -} - -static gboolean -gimp_tool_info_preview_needs_popup (GimpPreview *preview) -{ - GimpToolInfo *tool_info; - gint tool_info_width; - gint tool_info_height; - - tool_info = GIMP_TOOL_INFO (preview->viewable); - tool_info_width = TOOL_INFO_WIDTH; - tool_info_height = TOOL_INFO_HEIGHT; - - if (tool_info_width > preview->width || tool_info_height > preview->height) - return TRUE; - - return FALSE; -} diff --git a/app/gimptoolinfopreview.h b/app/gimptoolinfopreview.h deleted file mode 100644 index 1ce0831b8c..0000000000 --- a/app/gimptoolinfopreview.h +++ /dev/null @@ -1,61 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * GimpToolInfoPreview Widget - * Copyright (C) 2001 Michael Natterer - * - * 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_TOOL_INFO_PREVIEW_H__ -#define __GIMP_TOOL_INFO_PREVIEW_H__ - - -#include "gimppreview.h" - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -#define GIMP_TYPE_TOOL_INFO_PREVIEW (gimp_tool_info_preview_get_type ()) -#define GIMP_TOOL_INFO_PREVIEW(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_TOOL_INFO_PREVIEW, GimpToolInfoPreview)) -#define GIMP_TOOL_INFO_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TOOL_INFO_PREVIEW, GimpToolInfoPreviewClass)) -#define GIMP_IS_TOOL_INFO_PREVIEW(obj) (GTK_CHECK_TYPE (obj, GIMP_TYPE_TOOL_INFO_PREVIEW)) -#define GIMP_IS_TOOL_INFO_PREVIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TOOL_INFO_PREVIEW)) - - -typedef struct _GimpToolInfoPreviewClass GimpToolInfoPreviewClass; - -struct _GimpToolInfoPreview -{ - GimpPreview parent_instance; -}; - -struct _GimpToolInfoPreviewClass -{ - GimpPreviewClass parent_class; -}; - - -GtkType gimp_tool_info_preview_get_type (void); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __GIMP_TOOL_INFO_PREVIEW_H__ */ diff --git a/app/gradient_editor.c b/app/gradient_editor.c index 011cbad308..a1317aa52e 100644 --- a/app/gradient_editor.c +++ b/app/gradient_editor.c @@ -63,13 +63,14 @@ #include "apptypes.h" +#include "widgets/gimpcontainerlistview.h" + #include "color_notebook.h" #include "context_manager.h" #include "cursorutil.h" #include "datafiles.h" #include "errors.h" #include "gimpcontainer.h" -#include "gimpcontainerlistview.h" #include "gimpcontext.h" #include "gimpdatafactory.h" #include "gimpdnd.h" diff --git a/app/gradient_select.c b/app/gradient_select.c index ae0e1c3d9b..d27dfb809b 100644 --- a/app/gradient_select.c +++ b/app/gradient_select.c @@ -27,11 +27,12 @@ #include "apptypes.h" +#include "widgets/gimpdatafactoryview.h" + #include "appenv.h" #include "context_manager.h" #include "dialog_handler.h" #include "gimpcontainer.h" -#include "gimpdatafactoryview.h" #include "gimpcontext.h" #include "gimpdatafactory.h" #include "gimpgradient.h" diff --git a/app/gtkhwrapbox.c b/app/gtkhwrapbox.c deleted file mode 100644 index 8e15a32968..0000000000 --- a/app/gtkhwrapbox.c +++ /dev/null @@ -1,656 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * GtkHWrapBox: Horizontal wrapping box widget - * Copyright (C) 1999 Tim Janik - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#include "gtkhwrapbox.h" -#include - - -/* --- prototypes --- */ -static void gtk_hwrap_box_class_init (GtkHWrapBoxClass *klass); -static void gtk_hwrap_box_init (GtkHWrapBox *hwbox); -static void gtk_hwrap_box_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void gtk_hwrap_box_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static GSList* reverse_list_row_children (GtkWrapBox *wbox, - GtkWrapBoxChild **child_p, - GtkAllocation *area, - guint *max_height, - gboolean *can_vexpand); - - -/* --- variables --- */ -static gpointer parent_class = NULL; - - -/* --- functions --- */ -GtkType -gtk_hwrap_box_get_type (void) -{ - static GtkType hwrap_box_type = 0; - - if (!hwrap_box_type) - { - static const GtkTypeInfo hwrap_box_info = - { - "GtkHWrapBox", - sizeof (GtkHWrapBox), - sizeof (GtkHWrapBoxClass), - (GtkClassInitFunc) gtk_hwrap_box_class_init, - (GtkObjectInitFunc) gtk_hwrap_box_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - hwrap_box_type = gtk_type_unique (GTK_TYPE_WRAP_BOX, &hwrap_box_info); - } - - return hwrap_box_type; -} - -static void -gtk_hwrap_box_class_init (GtkHWrapBoxClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - GtkWrapBoxClass *wrap_box_class; - - object_class = GTK_OBJECT_CLASS (class); - widget_class = GTK_WIDGET_CLASS (class); - container_class = GTK_CONTAINER_CLASS (class); - wrap_box_class = GTK_WRAP_BOX_CLASS (class); - - parent_class = gtk_type_class (GTK_TYPE_WRAP_BOX); - - widget_class->size_request = gtk_hwrap_box_size_request; - widget_class->size_allocate = gtk_hwrap_box_size_allocate; - - wrap_box_class->rlist_line_children = reverse_list_row_children; -} - -static void -gtk_hwrap_box_init (GtkHWrapBox *hwbox) -{ - hwbox->max_child_width = 0; - hwbox->max_child_height = 0; -} - -GtkWidget* -gtk_hwrap_box_new (gboolean homogeneous) -{ - GtkHWrapBox *hwbox; - - hwbox = GTK_HWRAP_BOX (gtk_widget_new (GTK_TYPE_HWRAP_BOX, NULL)); - - GTK_WRAP_BOX (hwbox)->homogeneous = homogeneous ? TRUE : FALSE; - - return GTK_WIDGET (hwbox); -} - -static inline void -get_child_requisition (GtkWrapBox *wbox, - GtkWidget *child, - GtkRequisition *child_requisition) -{ - if (wbox->homogeneous) - { - GtkHWrapBox *hwbox = GTK_HWRAP_BOX (wbox); - - child_requisition->width = hwbox->max_child_width; - child_requisition->height = hwbox->max_child_height; - } - else - gtk_widget_get_child_requisition (child, child_requisition); -} - -#ifdef UNUSED_CODE -static void -_gtk_hwrap_box_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GtkHWrapBox *this = GTK_HWRAP_BOX (widget); - GtkWrapBox *wbox = GTK_WRAP_BOX (widget); - GtkWrapBoxChild *child; - guint area = 0; - - g_return_if_fail (requisition != NULL); - - /**/ - requisition->width = 0; - requisition->height = 0; - this->max_child_width = 0; - this->max_child_height = 0; - - for (child = wbox->children; child; child = child->next) - if (GTK_WIDGET_VISIBLE (child->widget)) - { - GtkRequisition child_requisition; - - gtk_widget_size_request (child->widget, &child_requisition); - - area += child_requisition.width * child_requisition.height; - this->max_child_width = MAX (this->max_child_width, child_requisition.width); - this->max_child_height = MAX (this->max_child_height, child_requisition.height); - } - if (wbox->homogeneous) - area = this->max_child_width * this->max_child_height * wbox->n_children; - - if (area) - { - requisition->width = sqrt (area * wbox->aspect_ratio); - requisition->height = area / requisition->width; - } - else - { - requisition->width = 0; - requisition->height = 0; - } - - requisition->width += GTK_CONTAINER (wbox)->border_width * 2; - requisition->height += GTK_CONTAINER (wbox)->border_width * 2; - /**/ -} -#endif - -static gfloat -get_layout_size (GtkHWrapBox *this, - guint max_width, - guint *width_inc) -{ - GtkWrapBox *wbox = GTK_WRAP_BOX (this); - GtkWrapBoxChild *child; - guint n_rows, left_over = 0, total_height = 0; - gboolean last_row_filled = TRUE; - - *width_inc = this->max_child_width + 1; - - n_rows = 0; - for (child = wbox->children; child; child = child->next) - { - GtkWrapBoxChild *row_child; - GtkRequisition child_requisition; - guint row_width, row_height, n = 1; - - if (!GTK_WIDGET_VISIBLE (child->widget)) - continue; - - get_child_requisition (wbox, child->widget, &child_requisition); - if (!last_row_filled) - *width_inc = MIN (*width_inc, child_requisition.width - left_over); - row_width = child_requisition.width; - row_height = child_requisition.height; - for (row_child = child->next; row_child && n < wbox->child_limit; row_child = row_child->next) - { - if (GTK_WIDGET_VISIBLE (row_child->widget)) - { - get_child_requisition (wbox, row_child->widget, &child_requisition); - if (row_width + wbox->hspacing + child_requisition.width > max_width) - break; - row_width += wbox->hspacing + child_requisition.width; - row_height = MAX (row_height, child_requisition.height); - n++; - } - child = row_child; - } - last_row_filled = n >= wbox->child_limit; - left_over = last_row_filled ? 0 : max_width - (row_width + wbox->hspacing); - total_height += (n_rows ? wbox->vspacing : 0) + row_height; - n_rows++; - } - - if (*width_inc > this->max_child_width) - *width_inc = 0; - - return MAX (total_height, 1); -} - -static void -gtk_hwrap_box_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GtkHWrapBox *this = GTK_HWRAP_BOX (widget); - GtkWrapBox *wbox = GTK_WRAP_BOX (widget); - GtkWrapBoxChild *child; - gfloat ratio_dist, layout_width = 0; - guint row_inc = 0; - - g_return_if_fail (requisition != NULL); - - requisition->width = 0; - requisition->height = 0; - this->max_child_width = 0; - this->max_child_height = 0; - - /* size_request all children */ - for (child = wbox->children; child; child = child->next) - if (GTK_WIDGET_VISIBLE (child->widget)) - { - GtkRequisition child_requisition; - - gtk_widget_size_request (child->widget, &child_requisition); - - this->max_child_width = MAX (this->max_child_width, child_requisition.width); - this->max_child_height = MAX (this->max_child_height, child_requisition.height); - } - - /* figure all possible layouts */ - ratio_dist = 32768; - layout_width = this->max_child_width; - do - { - gfloat layout_height; - gfloat ratio, dist; - - layout_width += row_inc; - layout_height = get_layout_size (this, layout_width, &row_inc); - ratio = layout_width / layout_height; /**/ - dist = MAX (ratio, wbox->aspect_ratio) - MIN (ratio, wbox->aspect_ratio); - if (dist < ratio_dist) - { - ratio_dist = dist; - requisition->width = layout_width; - requisition->height = layout_height; - } - - /* g_print ("ratio for width %d height %d = %f\n", - (gint) layout_width, - (gint) layout_height, - ratio); - */ - } - while (row_inc); - - requisition->width += GTK_CONTAINER (wbox)->border_width * 2; /**/ - requisition->height += GTK_CONTAINER (wbox)->border_width * 2; /**/ - /* g_print ("choosen: width %d, height %d\n", - requisition->width, - requisition->height); - */ -} - -static GSList* -reverse_list_row_children (GtkWrapBox *wbox, - GtkWrapBoxChild **child_p, - GtkAllocation *area, - guint *max_child_size, - gboolean *expand_line) -{ - GSList *slist = NULL; - guint width = 0, row_width = area->width; - GtkWrapBoxChild *child = *child_p; - - *max_child_size = 0; - *expand_line = FALSE; - - while (child && !GTK_WIDGET_VISIBLE (child->widget)) - { - *child_p = child->next; - child = *child_p; - } - - if (child) - { - GtkRequisition child_requisition; - guint n = 1; - - get_child_requisition (wbox, child->widget, &child_requisition); - width += child_requisition.width; - *max_child_size = MAX (*max_child_size, child_requisition.height); - *expand_line |= child->vexpand; - slist = g_slist_prepend (slist, child); - *child_p = child->next; - child = *child_p; - - while (child && n < wbox->child_limit) - { - if (GTK_WIDGET_VISIBLE (child->widget)) - { - get_child_requisition (wbox, child->widget, &child_requisition); - if (width + wbox->hspacing + child_requisition.width > row_width || - child->forced_break) - break; - width += wbox->hspacing + child_requisition.width; - *max_child_size = MAX (*max_child_size, child_requisition.height); - *expand_line |= child->vexpand; - slist = g_slist_prepend (slist, child); - n++; - } - *child_p = child->next; - child = *child_p; - } - } - - return slist; -} - -static void -layout_row (GtkWrapBox *wbox, - GtkAllocation *area, - GSList *children, - guint children_per_line, - gboolean vexpand) -{ - GSList *slist; - guint n_children = 0, n_expand_children = 0, have_expand_children = 0, total_width = 0; - gfloat x, width, extra; - GtkAllocation child_allocation; - - for (slist = children; slist; slist = slist->next) - { - GtkWrapBoxChild *child = slist->data; - GtkRequisition child_requisition; - - n_children++; - if (child->hexpand) - n_expand_children++; - - get_child_requisition (wbox, child->widget, &child_requisition); - total_width += child_requisition.width; - } - - width = MAX (1, area->width - (n_children - 1) * wbox->hspacing); - if (width > total_width) - extra = width - total_width; - else - extra = 0; - have_expand_children = n_expand_children && extra; - - x = area->x; - if (wbox->homogeneous) - { - width = MAX (1, area->width - (children_per_line - 1) * wbox->hspacing); - width /= ((gdouble) children_per_line); - extra = 0; - } - else if (have_expand_children && wbox->justify != GTK_JUSTIFY_FILL) - { - width = extra; - extra /= ((gdouble) n_expand_children); - } - else - { - if (wbox->justify == GTK_JUSTIFY_FILL) - { - width = extra; - have_expand_children = TRUE; - n_expand_children = n_children; - extra /= ((gdouble) n_expand_children); - } - else if (wbox->justify == GTK_JUSTIFY_CENTER) - { - x += extra / 2; - width = 0; - extra = 0; - } - else if (wbox->justify == GTK_JUSTIFY_LEFT) - { - width = 0; - extra = 0; - } - else if (wbox->justify == GTK_JUSTIFY_RIGHT) - { - x += extra; - width = 0; - extra = 0; - } - } - - n_children = 0; - for (slist = children; slist; slist = slist->next) - { - GtkWrapBoxChild *child = slist->data; - - child_allocation.x = x; - child_allocation.y = area->y; - if (wbox->homogeneous) - { - child_allocation.height = area->height; - child_allocation.width = width; - x += child_allocation.width + wbox->hspacing; - } - else - { - GtkRequisition child_requisition; - - get_child_requisition (wbox, child->widget, &child_requisition); - - if (child_requisition.height >= area->height) - child_allocation.height = area->height; - else - { - child_allocation.height = child_requisition.height; - if (wbox->line_justify == GTK_JUSTIFY_FILL || child->vfill) - child_allocation.height = area->height; - else if (child->vexpand || wbox->line_justify == GTK_JUSTIFY_CENTER) - child_allocation.y += (area->height - child_requisition.height) / 2; - else if (wbox->line_justify == GTK_JUSTIFY_BOTTOM) - child_allocation.y += area->height - child_requisition.height; - } - - if (have_expand_children) - { - child_allocation.width = child_requisition.width; - if (child->hexpand || wbox->justify == GTK_JUSTIFY_FILL) - { - guint space; - - n_expand_children--; - space = extra * n_expand_children; - space = width - space; - width -= space; - if (child->hfill) - child_allocation.width += space; - else - { - child_allocation.x += space / 2; - x += space; - } - } - } - else - { - /* g_print ("child_allocation.x %d += %d * %f ", - child_allocation.x, n_children, extra); */ - child_allocation.x += n_children * extra; - /* g_print ("= %d\n", - child_allocation.x); */ - child_allocation.width = MIN (child_requisition.width, - area->width - child_allocation.x + area->x); - } - } - - x += child_allocation.width + wbox->hspacing; - gtk_widget_size_allocate (child->widget, &child_allocation); - n_children++; - } -} - -typedef struct _Line Line; -struct _Line -{ - GSList *children; - guint16 min_size; - guint expand : 1; - Line *next; -}; - -static void -layout_rows (GtkWrapBox *wbox, - GtkAllocation *area) -{ - GtkWrapBoxChild *next_child; - guint min_height; - gboolean vexpand; - GSList *slist; - Line *line_list = NULL; - guint total_height = 0, n_expand_lines = 0, n_lines = 0; - gfloat shrink_height; - guint children_per_line; - - next_child = wbox->children; - slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox, - &next_child, - area, - &min_height, - &vexpand); - slist = g_slist_reverse (slist); - - children_per_line = g_slist_length (slist); - while (slist) - { - Line *line = g_new (Line, 1); - - line->children = slist; - line->min_size = min_height; - total_height += min_height; - line->expand = vexpand; - if (vexpand) - n_expand_lines++; - line->next = line_list; - line_list = line; - n_lines++; - - slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox, - &next_child, - area, - &min_height, - &vexpand); - slist = g_slist_reverse (slist); - } - - if (total_height > area->height) - shrink_height = total_height - area->height; - else - shrink_height = 0; - - if (1) /* reverse lines and shrink */ - { - Line *prev = NULL, *last = NULL; - gfloat n_shrink_lines = n_lines; - - while (line_list) - { - Line *tmp = line_list->next; - - if (shrink_height) - { - Line *line = line_list; - guint shrink_fract = shrink_height / n_shrink_lines + 0.5; - - if (line->min_size > shrink_fract) - { - shrink_height -= shrink_fract; - line->min_size -= shrink_fract; - } - else - { - shrink_height -= line->min_size - 1; - line->min_size = 1; - } - } - n_shrink_lines--; - - last = line_list; - line_list->next = prev; - prev = line_list; - line_list = tmp; - } - line_list = last; - } - - if (n_lines) - { - Line *line; - gfloat y, height, extra = 0; - - height = area->height; - height = MAX (n_lines, height - (n_lines - 1) * wbox->vspacing); - - if (wbox->homogeneous) - height /= ((gdouble) n_lines); - else if (n_expand_lines) - { - height = MAX (0, height - total_height); - extra = height / ((gdouble) n_expand_lines); - } - else - height = 0; - - y = area->y; - line = line_list; - while (line) - { - GtkAllocation row_allocation; - Line *next_line = line->next; - - row_allocation.x = area->x; - row_allocation.width = area->width; - if (wbox->homogeneous) - row_allocation.height = height; - else - { - row_allocation.height = line->min_size; - - if (line->expand) - row_allocation.height += extra; - } - - row_allocation.y = y; - - y += row_allocation.height + wbox->vspacing; - layout_row (wbox, - &row_allocation, - line->children, - children_per_line, - line->expand); - - g_slist_free (line->children); - g_free (line); - line = next_line; - } - } -} - -static void -gtk_hwrap_box_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkWrapBox *wbox = GTK_WRAP_BOX (widget); - GtkAllocation area; - guint border = GTK_CONTAINER (wbox)->border_width; /**/ - - widget->allocation = *allocation; - area.x = allocation->x + border; - area.y = allocation->y + border; - area.width = MAX (1, (gint) allocation->width - border * 2); - area.height = MAX (1, (gint) allocation->height - border * 2); - - /**/ - /* g_print ("got: width %d, height %d\n", - allocation->width, - allocation->height); - */ - /**/ - - layout_rows (wbox, &area); -} diff --git a/app/gtkhwrapbox.h b/app/gtkhwrapbox.h deleted file mode 100644 index b6d9fd99c0..0000000000 --- a/app/gtkhwrapbox.h +++ /dev/null @@ -1,75 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * GtkHWrapBox: Horizontal wrapping box widget - * Copyright (C) 1999 Tim Janik - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __GTK_HWRAP_BOX_H__ -#define __GTK_HWRAP_BOX_H__ - - -#include "gtkwrapbox.h" - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -/* --- type macros --- */ -#define GTK_TYPE_HWRAP_BOX (gtk_hwrap_box_get_type ()) -#define GTK_HWRAP_BOX(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_HWRAP_BOX, GtkHWrapBox)) -#define GTK_HWRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_HWRAP_BOX, GtkHWrapBoxClass)) -#define GTK_IS_HWRAP_BOX(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_HWRAP_BOX)) -#define GTK_IS_HWRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_HWRAP_BOX)) -#define GTK_HWRAP_BOX_GET_CLASS(obj) (GTK_HWRAP_BOX_CLASS (((GtkObject*) (obj))->klass)) - - -/* --- typedefs --- */ -typedef struct _GtkHWrapBox GtkHWrapBox; -typedef struct _GtkHWrapBoxClass GtkHWrapBoxClass; - - -/* --- GtkHWrapBox --- */ -struct _GtkHWrapBox -{ - GtkWrapBox parent_widget; - - /**/ - guint16 max_child_width; - guint16 max_child_height; - /**/ -}; - -struct _GtkHWrapBoxClass -{ - GtkWrapBoxClass parent_class; -}; - - -/* --- prototypes --- */ -GtkType gtk_hwrap_box_get_type (void); -GtkWidget* gtk_hwrap_box_new (gboolean homogeneous); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __GTK_HWRAP_BOX_H__ */ diff --git a/app/gtkvwrapbox.c b/app/gtkvwrapbox.c deleted file mode 100644 index 75a999ae9e..0000000000 --- a/app/gtkvwrapbox.c +++ /dev/null @@ -1,656 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * GtkVWrapBox: Vertical wrapping box widget - * Copyright (C) 1999 Tim Janik - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#include "gtkvwrapbox.h" -#include - - -/* --- prototypes --- */ -static void gtk_vwrap_box_class_init (GtkVWrapBoxClass *klass); -static void gtk_vwrap_box_init (GtkVWrapBox *vwbox); -static void gtk_vwrap_box_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void gtk_vwrap_box_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static GSList* reverse_list_col_children (GtkWrapBox *wbox, - GtkWrapBoxChild **child_p, - GtkAllocation *area, - guint *max_width, - gboolean *can_hexpand); - - -/* --- variables --- */ -static gpointer parent_class = NULL; - - -/* --- functions --- */ -GtkType -gtk_vwrap_box_get_type (void) -{ - static GtkType vwrap_box_type = 0; - - if (!vwrap_box_type) - { - static const GtkTypeInfo vwrap_box_info = - { - "GtkVWrapBox", - sizeof (GtkVWrapBox), - sizeof (GtkVWrapBoxClass), - (GtkClassInitFunc) gtk_vwrap_box_class_init, - (GtkObjectInitFunc) gtk_vwrap_box_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - vwrap_box_type = gtk_type_unique (GTK_TYPE_WRAP_BOX, &vwrap_box_info); - } - - return vwrap_box_type; -} - -static void -gtk_vwrap_box_class_init (GtkVWrapBoxClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - GtkWrapBoxClass *wrap_box_class; - - object_class = GTK_OBJECT_CLASS (class); - widget_class = GTK_WIDGET_CLASS (class); - container_class = GTK_CONTAINER_CLASS (class); - wrap_box_class = GTK_WRAP_BOX_CLASS (class); - - parent_class = gtk_type_class (GTK_TYPE_WRAP_BOX); - - widget_class->size_request = gtk_vwrap_box_size_request; - widget_class->size_allocate = gtk_vwrap_box_size_allocate; - - wrap_box_class->rlist_line_children = reverse_list_col_children; -} - -static void -gtk_vwrap_box_init (GtkVWrapBox *vwbox) -{ - vwbox->max_child_height = 0; - vwbox->max_child_width = 0; -} - -GtkWidget* -gtk_vwrap_box_new (gboolean homogeneous) -{ - GtkVWrapBox *vwbox; - - vwbox = GTK_VWRAP_BOX (gtk_widget_new (GTK_TYPE_VWRAP_BOX, NULL)); - - GTK_WRAP_BOX (vwbox)->homogeneous = homogeneous ? TRUE : FALSE; - - return GTK_WIDGET (vwbox); -} - -static inline void -get_child_requisition (GtkWrapBox *wbox, - GtkWidget *child, - GtkRequisition *child_requisition) -{ - if (wbox->homogeneous) - { - GtkVWrapBox *vwbox = GTK_VWRAP_BOX (wbox); - - child_requisition->height = vwbox->max_child_height; - child_requisition->width = vwbox->max_child_width; - } - else - gtk_widget_get_child_requisition (child, child_requisition); -} - -#ifdef UNUSED_CODE -static void -_gtk_vwrap_box_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GtkVWrapBox *this = GTK_VWRAP_BOX (widget); - GtkWrapBox *wbox = GTK_WRAP_BOX (widget); - GtkWrapBoxChild *child; - guint area = 0; - - g_return_if_fail (requisition != NULL); - - /**/ - requisition->width = 0; - requisition->height = 0; - this->max_child_width = 0; - this->max_child_height = 0; - - for (child = wbox->children; child; child = child->next) - if (GTK_WIDGET_VISIBLE (child->widget)) - { - GtkRequisition child_requisition; - - gtk_widget_size_request (child->widget, &child_requisition); - - area += child_requisition.width * child_requisition.height; - this->max_child_width = MAX (this->max_child_width, child_requisition.width); - this->max_child_height = MAX (this->max_child_height, child_requisition.height); - } - if (wbox->homogeneous) - area = this->max_child_width * this->max_child_height * wbox->n_children; - - if (area) - { - requisition->width = sqrt (area * wbox->aspect_ratio); - requisition->height = area / requisition->width; - } - else - { - requisition->width = 0; - requisition->height = 0; - } - - requisition->width += GTK_CONTAINER (wbox)->border_width * 2; - requisition->height += GTK_CONTAINER (wbox)->border_width * 2; - /**/ -} -#endif - -static gfloat -get_layout_size (GtkVWrapBox *this, - guint max_height, - guint *height_inc) -{ - GtkWrapBox *wbox = GTK_WRAP_BOX (this); - GtkWrapBoxChild *child; - guint n_cols, left_over = 0, total_width = 0; - gboolean last_col_filled = TRUE; - - *height_inc = this->max_child_height + 1; - - n_cols = 0; - for (child = wbox->children; child; child = child->next) - { - GtkWrapBoxChild *col_child; - GtkRequisition child_requisition; - guint col_height, col_width, n = 1; - - if (!GTK_WIDGET_VISIBLE (child->widget)) - continue; - - get_child_requisition (wbox, child->widget, &child_requisition); - if (!last_col_filled) - *height_inc = MIN (*height_inc, child_requisition.height - left_over); - col_height = child_requisition.height; - col_width = child_requisition.width; - for (col_child = child->next; col_child && n < wbox->child_limit; col_child = col_child->next) - { - if (GTK_WIDGET_VISIBLE (col_child->widget)) - { - get_child_requisition (wbox, col_child->widget, &child_requisition); - if (col_height + wbox->vspacing + child_requisition.height > max_height) - break; - col_height += wbox->vspacing + child_requisition.height; - col_width = MAX (col_width, child_requisition.width); - n++; - } - child = col_child; - } - last_col_filled = n >= wbox->child_limit; - left_over = last_col_filled ? 0 : max_height - (col_height + wbox->vspacing); - total_width += (n_cols ? wbox->hspacing : 0) + col_width; - n_cols++; - } - - if (*height_inc > this->max_child_height) - *height_inc = 0; - - return MAX (total_width, 1); -} - -static void -gtk_vwrap_box_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GtkVWrapBox *this = GTK_VWRAP_BOX (widget); - GtkWrapBox *wbox = GTK_WRAP_BOX (widget); - GtkWrapBoxChild *child; - gfloat ratio_dist, layout_height = 0; - guint col_inc = 0; - - g_return_if_fail (requisition != NULL); - - requisition->height = 0; - requisition->width = 0; - this->max_child_height = 0; - this->max_child_width = 0; - - /* size_request all children */ - for (child = wbox->children; child; child = child->next) - if (GTK_WIDGET_VISIBLE (child->widget)) - { - GtkRequisition child_requisition; - - gtk_widget_size_request (child->widget, &child_requisition); - - this->max_child_height = MAX (this->max_child_height, child_requisition.height); - this->max_child_width = MAX (this->max_child_width, child_requisition.width); - } - - /* figure all possible layouts */ - ratio_dist = 32768; - layout_height = this->max_child_height; - do - { - gfloat layout_width; - gfloat ratio, dist; - - layout_height += col_inc; - layout_width = get_layout_size (this, layout_height, &col_inc); - ratio = layout_width / layout_height; /**/ - dist = MAX (ratio, wbox->aspect_ratio) - MIN (ratio, wbox->aspect_ratio); - if (dist < ratio_dist) - { - ratio_dist = dist; - requisition->height = layout_height; - requisition->width = layout_width; - } - - /* g_print ("ratio for height %d width %d = %f\n", - (gint) layout_height, - (gint) layout_width, - ratio); - */ - } - while (col_inc); - - requisition->width += GTK_CONTAINER (wbox)->border_width * 2; /**/ - requisition->height += GTK_CONTAINER (wbox)->border_width * 2; /**/ - /* g_print ("choosen: height %d, width %d\n", - requisition->height, - requisition->width); - */ -} - -static GSList* -reverse_list_col_children (GtkWrapBox *wbox, - GtkWrapBoxChild **child_p, - GtkAllocation *area, - guint *max_child_size, - gboolean *expand_line) -{ - GSList *slist = NULL; - guint height = 0, col_height = area->height; - GtkWrapBoxChild *child = *child_p; - - *max_child_size = 0; - *expand_line = FALSE; - - while (child && !GTK_WIDGET_VISIBLE (child->widget)) - { - *child_p = child->next; - child = *child_p; - } - - if (child) - { - GtkRequisition child_requisition; - guint n = 1; - - get_child_requisition (wbox, child->widget, &child_requisition); - height += child_requisition.height; - *max_child_size = MAX (*max_child_size, child_requisition.width); - *expand_line |= child->hexpand; - slist = g_slist_prepend (slist, child); - *child_p = child->next; - child = *child_p; - - while (child && n < wbox->child_limit) - { - if (GTK_WIDGET_VISIBLE (child->widget)) - { - get_child_requisition (wbox, child->widget, &child_requisition); - if (height + wbox->vspacing + child_requisition.height > col_height || - child->forced_break) - break; - height += wbox->vspacing + child_requisition.height; - *max_child_size = MAX (*max_child_size, child_requisition.width); - *expand_line |= child->hexpand; - slist = g_slist_prepend (slist, child); - n++; - } - *child_p = child->next; - child = *child_p; - } - } - - return slist; -} - -static void -layout_col (GtkWrapBox *wbox, - GtkAllocation *area, - GSList *children, - guint children_per_line, - gboolean hexpand) -{ - GSList *slist; - guint n_children = 0, n_expand_children = 0, have_expand_children = 0, total_height = 0; - gfloat y, height, extra; - GtkAllocation child_allocation; - - for (slist = children; slist; slist = slist->next) - { - GtkWrapBoxChild *child = slist->data; - GtkRequisition child_requisition; - - n_children++; - if (child->vexpand) - n_expand_children++; - - get_child_requisition (wbox, child->widget, &child_requisition); - total_height += child_requisition.height; - } - - height = MAX (1, area->height - (n_children - 1) * wbox->vspacing); - if (height > total_height) - extra = height - total_height; - else - extra = 0; - have_expand_children = n_expand_children && extra; - - y = area->y; - if (wbox->homogeneous) - { - height = MAX (1, area->height - (children_per_line - 1) * wbox->vspacing); - height /= ((gdouble) children_per_line); - extra = 0; - } - else if (have_expand_children && wbox->justify != GTK_JUSTIFY_FILL) - { - height = extra; - extra /= ((gdouble) n_expand_children); - } - else - { - if (wbox->justify == GTK_JUSTIFY_FILL) - { - height = extra; - have_expand_children = TRUE; - n_expand_children = n_children; - extra /= ((gdouble) n_expand_children); - } - else if (wbox->justify == GTK_JUSTIFY_CENTER) - { - y += extra / 2; - height = 0; - extra = 0; - } - else if (wbox->justify == GTK_JUSTIFY_LEFT) - { - height = 0; - extra = 0; - } - else if (wbox->justify == GTK_JUSTIFY_RIGHT) - { - y += extra; - height = 0; - extra = 0; - } - } - - n_children = 0; - for (slist = children; slist; slist = slist->next) - { - GtkWrapBoxChild *child = slist->data; - - child_allocation.y = y; - child_allocation.x = area->x; - if (wbox->homogeneous) - { - child_allocation.width = area->width; - child_allocation.height = height; - y += child_allocation.height + wbox->vspacing; - } - else - { - GtkRequisition child_requisition; - - get_child_requisition (wbox, child->widget, &child_requisition); - - if (child_requisition.width >= area->width) - child_allocation.width = area->width; - else - { - child_allocation.width = child_requisition.width; - if (wbox->line_justify == GTK_JUSTIFY_FILL || child->hfill) - child_allocation.width = area->width; - else if (child->hexpand || wbox->line_justify == GTK_JUSTIFY_CENTER) - child_allocation.x += (area->width - child_requisition.width) / 2; - else if (wbox->line_justify == GTK_JUSTIFY_BOTTOM) - child_allocation.x += area->width - child_requisition.width; - } - - if (have_expand_children) - { - child_allocation.height = child_requisition.height; - if (child->vexpand || wbox->justify == GTK_JUSTIFY_FILL) - { - guint space; - - n_expand_children--; - space = extra * n_expand_children; - space = height - space; - height -= space; - if (child->vfill) - child_allocation.height += space; - else - { - child_allocation.y += space / 2; - y += space; - } - } - } - else - { - /* g_print ("child_allocation.y %d += %d * %f ", - child_allocation.y, n_children, extra); */ - child_allocation.y += n_children * extra; - /* g_print ("= %d\n", - child_allocation.y); */ - child_allocation.height = MIN (child_requisition.height, - area->height - child_allocation.y + area->y); - } - } - - y += child_allocation.height + wbox->vspacing; - gtk_widget_size_allocate (child->widget, &child_allocation); - n_children++; - } -} - -typedef struct _Line Line; -struct _Line -{ - GSList *children; - guint16 min_size; - guint expand : 1; - Line *next; -}; - -static void -layout_cols (GtkWrapBox *wbox, - GtkAllocation *area) -{ - GtkWrapBoxChild *next_child; - guint min_width; - gboolean hexpand; - GSList *slist; - Line *line_list = NULL; - guint total_width = 0, n_expand_lines = 0, n_lines = 0; - gfloat shrink_width; - guint children_per_line; - - next_child = wbox->children; - slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox, - &next_child, - area, - &min_width, - &hexpand); - slist = g_slist_reverse (slist); - - children_per_line = g_slist_length (slist); - while (slist) - { - Line *line = g_new (Line, 1); - - line->children = slist; - line->min_size = min_width; - total_width += min_width; - line->expand = hexpand; - if (hexpand) - n_expand_lines++; - line->next = line_list; - line_list = line; - n_lines++; - - slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox, - &next_child, - area, - &min_width, - &hexpand); - slist = g_slist_reverse (slist); - } - - if (total_width > area->width) - shrink_width = total_width - area->width; - else - shrink_width = 0; - - if (1) /* reverse lines and shrink */ - { - Line *prev = NULL, *last = NULL; - gfloat n_shrink_lines = n_lines; - - while (line_list) - { - Line *tmp = line_list->next; - - if (shrink_width) - { - Line *line = line_list; - guint shrink_fract = shrink_width / n_shrink_lines + 0.5; - - if (line->min_size > shrink_fract) - { - shrink_width -= shrink_fract; - line->min_size -= shrink_fract; - } - else - { - shrink_width -= line->min_size - 1; - line->min_size = 1; - } - } - n_shrink_lines--; - - last = line_list; - line_list->next = prev; - prev = line_list; - line_list = tmp; - } - line_list = last; - } - - if (n_lines) - { - Line *line; - gfloat x, width, extra = 0; - - width = area->width; - width = MAX (n_lines, width - (n_lines - 1) * wbox->hspacing); - - if (wbox->homogeneous) - width /= ((gdouble) n_lines); - else if (n_expand_lines) - { - width = MAX (0, width - total_width); - extra = width / ((gdouble) n_expand_lines); - } - else - width = 0; - - x = area->x; - line = line_list; - while (line) - { - GtkAllocation col_allocation; - Line *next_line = line->next; - - col_allocation.y = area->y; - col_allocation.height = area->height; - if (wbox->homogeneous) - col_allocation.width = width; - else - { - col_allocation.width = line->min_size; - - if (line->expand) - col_allocation.width += extra; - } - - col_allocation.x = x; - - x += col_allocation.width + wbox->hspacing; - layout_col (wbox, - &col_allocation, - line->children, - children_per_line, - line->expand); - - g_slist_free (line->children); - g_free (line); - line = next_line; - } - } -} - -static void -gtk_vwrap_box_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkWrapBox *wbox = GTK_WRAP_BOX (widget); - GtkAllocation area; - guint border = GTK_CONTAINER (wbox)->border_width; /**/ - - widget->allocation = *allocation; - area.y = allocation->y + border; - area.x = allocation->x + border; - area.height = MAX (1, (gint) allocation->height - border * 2); - area.width = MAX (1, (gint) allocation->width - border * 2); - - /**/ - /* g_print ("got: width %d, height %d\n", - allocation->width, - allocation->height); - */ - /**/ - - layout_cols (wbox, &area); -} diff --git a/app/gtkvwrapbox.h b/app/gtkvwrapbox.h deleted file mode 100644 index 83b0a95f70..0000000000 --- a/app/gtkvwrapbox.h +++ /dev/null @@ -1,75 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * GtkVWrapBox: Vertical wrapping box widget - * Copyright (C) 1999 Tim Janik - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __GTK_VWRAP_BOX_H__ -#define __GTK_VWRAP_BOX_H__ - - -#include "gtkwrapbox.h" - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -/* --- type macros --- */ -#define GTK_TYPE_VWRAP_BOX (gtk_vwrap_box_get_type ()) -#define GTK_VWRAP_BOX(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_VWRAP_BOX, GtkVWrapBox)) -#define GTK_VWRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_VWRAP_BOX, GtkVWrapBoxClass)) -#define GTK_IS_VWRAP_BOX(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_VWRAP_BOX)) -#define GTK_IS_VWRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_VWRAP_BOX)) -#define GTK_VWRAP_BOX_GET_CLASS(obj) (GTK_VWRAP_BOX_CLASS (((GtkObject*) (obj))->klass)) - - -/* --- typedefs --- */ -typedef struct _GtkVWrapBox GtkVWrapBox; -typedef struct _GtkVWrapBoxClass GtkVWrapBoxClass; - - -/* --- GtkVWrapBox --- */ -struct _GtkVWrapBox -{ - GtkWrapBox parent_widget; - - /**/ - guint16 max_child_width; - guint16 max_child_height; - /**/ -}; - -struct _GtkVWrapBoxClass -{ - GtkWrapBoxClass parent_class; -}; - - -/* --- prototypes --- */ -GtkType gtk_vwrap_box_get_type (void); -GtkWidget* gtk_vwrap_box_new (gboolean homogeneous); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __GTK_VWRAP_BOX_H__ */ diff --git a/app/gtkwrapbox.c b/app/gtkwrapbox.c deleted file mode 100644 index 90da770add..0000000000 --- a/app/gtkwrapbox.c +++ /dev/null @@ -1,830 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * GtkWrapBox: Wrapping box widget - * Copyright (C) 1999 Tim Janik - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#include - -#include "gtkwrapbox.h" - - -/* --- arguments --- */ -enum { - ARG_0, - ARG_HOMOGENEOUS, - ARG_JUSTIFY, - ARG_HSPACING, - ARG_VSPACING, - ARG_LINE_JUSTIFY, - ARG_ASPECT_RATIO, - ARG_CURRENT_RATIO, - ARG_CHILD_LIMIT -}; -enum { - CHILD_ARG_0, - CHILD_ARG_POSITION, - CHILD_ARG_HEXPAND, - CHILD_ARG_HFILL, - CHILD_ARG_VEXPAND, - CHILD_ARG_VFILL, - CHILD_ARG_FORCED_BREAK -}; - - -/* --- prototypes --- */ -static void gtk_wrap_box_class_init (GtkWrapBoxClass *klass); -static void gtk_wrap_box_init (GtkWrapBox *wbox); -static void gtk_wrap_box_get_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); -static void gtk_wrap_box_set_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); -static void gtk_wrap_box_set_child_arg (GtkContainer *container, - GtkWidget *child, - GtkArg *arg, - guint arg_id); -static void gtk_wrap_box_get_child_arg (GtkContainer *container, - GtkWidget *child, - GtkArg *arg, - guint arg_id); -static void gtk_wrap_box_map (GtkWidget *widget); -static void gtk_wrap_box_unmap (GtkWidget *widget); -static void gtk_wrap_box_draw (GtkWidget *widget, - GdkRectangle *area); -static gint gtk_wrap_box_expose (GtkWidget *widget, - GdkEventExpose *event); -static void gtk_wrap_box_add (GtkContainer *container, - GtkWidget *widget); -static void gtk_wrap_box_remove (GtkContainer *container, - GtkWidget *widget); -static void gtk_wrap_box_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); -static GtkType gtk_wrap_box_child_type (GtkContainer *container); - - -/* --- variables --- */ -static gpointer parent_class = NULL; - - -/* --- functions --- */ -GtkType -gtk_wrap_box_get_type (void) -{ - static GtkType wrap_box_type = 0; - - if (!wrap_box_type) - { - static const GtkTypeInfo wrap_box_info = - { - "GtkWrapBox", - sizeof (GtkWrapBox), - sizeof (GtkWrapBoxClass), - (GtkClassInitFunc) gtk_wrap_box_class_init, - (GtkObjectInitFunc) gtk_wrap_box_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - wrap_box_type = gtk_type_unique (GTK_TYPE_CONTAINER, &wrap_box_info); - } - - return wrap_box_type; -} - -static void -gtk_wrap_box_class_init (GtkWrapBoxClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - - object_class = GTK_OBJECT_CLASS (class); - widget_class = GTK_WIDGET_CLASS (class); - container_class = GTK_CONTAINER_CLASS (class); - - parent_class = gtk_type_class (GTK_TYPE_CONTAINER); - - object_class->set_arg = gtk_wrap_box_set_arg; - object_class->get_arg = gtk_wrap_box_get_arg; - - widget_class->map = gtk_wrap_box_map; - widget_class->unmap = gtk_wrap_box_unmap; - widget_class->draw = gtk_wrap_box_draw; - widget_class->expose_event = gtk_wrap_box_expose; - - container_class->add = gtk_wrap_box_add; - container_class->remove = gtk_wrap_box_remove; - container_class->forall = gtk_wrap_box_forall; - container_class->child_type = gtk_wrap_box_child_type; - container_class->set_child_arg = gtk_wrap_box_set_child_arg; - container_class->get_child_arg = gtk_wrap_box_get_child_arg; - - class->rlist_line_children = NULL; - - gtk_object_add_arg_type ("GtkWrapBox::homogeneous", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_HOMOGENEOUS); - gtk_object_add_arg_type ("GtkWrapBox::justify", - GTK_TYPE_JUSTIFICATION, GTK_ARG_READWRITE, ARG_JUSTIFY); - gtk_object_add_arg_type ("GtkWrapBox::hspacing", - GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_HSPACING); - gtk_object_add_arg_type ("GtkWrapBox::vspacing", - GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_VSPACING); - gtk_object_add_arg_type ("GtkWrapBox::line_justify", - GTK_TYPE_JUSTIFICATION, GTK_ARG_READWRITE, ARG_LINE_JUSTIFY); - gtk_object_add_arg_type ("GtkWrapBox::aspect_ratio", - GTK_TYPE_FLOAT, GTK_ARG_READWRITE, ARG_ASPECT_RATIO); - gtk_object_add_arg_type ("GtkWrapBox::current_ratio", - GTK_TYPE_FLOAT, GTK_ARG_READABLE, ARG_CURRENT_RATIO); - gtk_object_add_arg_type ("GtkWrapBox::max_children_per_line", - GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_CHILD_LIMIT); - gtk_container_add_child_arg_type ("GtkWrapBox::position", - GTK_TYPE_INT, GTK_ARG_READWRITE, CHILD_ARG_POSITION); - gtk_container_add_child_arg_type ("GtkWrapBox::hexpand", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_HEXPAND); - gtk_container_add_child_arg_type ("GtkWrapBox::hfill", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_HFILL); - gtk_container_add_child_arg_type ("GtkWrapBox::vexpand", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_VEXPAND); - gtk_container_add_child_arg_type ("GtkWrapBox::vfill", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_VFILL); - gtk_container_add_child_arg_type ("GtkWrapBox::forcebreak", - GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_FORCED_BREAK); -} - -static void -gtk_wrap_box_init (GtkWrapBox *wbox) -{ - GTK_WIDGET_SET_FLAGS (wbox, GTK_NO_WINDOW); - - wbox->homogeneous = FALSE; - wbox->hspacing = 0; - wbox->vspacing = 0; - wbox->justify = GTK_JUSTIFY_LEFT; - wbox->line_justify = GTK_JUSTIFY_BOTTOM; - wbox->n_children = 0; - wbox->children = NULL; - wbox->aspect_ratio = 1; - wbox->child_limit = 32767; -} - -static void -gtk_wrap_box_set_arg (GtkObject *object, - GtkArg *arg, - guint arg_id) -{ - GtkWrapBox *wbox = GTK_WRAP_BOX (object); - - switch (arg_id) - { - case ARG_HOMOGENEOUS: - gtk_wrap_box_set_homogeneous (wbox, GTK_VALUE_BOOL (*arg)); - break; - case ARG_JUSTIFY: - gtk_wrap_box_set_justify (wbox, GTK_VALUE_ENUM (*arg)); - break; - case ARG_LINE_JUSTIFY: - gtk_wrap_box_set_line_justify (wbox, GTK_VALUE_ENUM (*arg)); - break; - case ARG_HSPACING: - gtk_wrap_box_set_hspacing (wbox, GTK_VALUE_UINT (*arg)); - break; - case ARG_VSPACING: - gtk_wrap_box_set_vspacing (wbox, GTK_VALUE_UINT (*arg)); - break; - case ARG_ASPECT_RATIO: - gtk_wrap_box_set_aspect_ratio (wbox, GTK_VALUE_FLOAT (*arg)); - break; - case ARG_CHILD_LIMIT: - if (wbox->child_limit != GTK_VALUE_UINT (*arg)) - { - wbox->child_limit = CLAMP (GTK_VALUE_UINT (*arg), 1, 32767); - gtk_widget_queue_resize (GTK_WIDGET (wbox)); - } - break; - } -} - -static void -gtk_wrap_box_get_arg (GtkObject *object, - GtkArg *arg, - guint arg_id) -{ - GtkWrapBox *wbox = GTK_WRAP_BOX (object); - GtkWidget *widget = GTK_WIDGET (object); - - switch (arg_id) - { - case ARG_HOMOGENEOUS: - GTK_VALUE_BOOL (*arg) = wbox->homogeneous; - break; - case ARG_JUSTIFY: - GTK_VALUE_ENUM (*arg) = wbox->justify; - break; - case ARG_LINE_JUSTIFY: - GTK_VALUE_ENUM (*arg) = wbox->line_justify; - break; - case ARG_HSPACING: - GTK_VALUE_UINT (*arg) = wbox->hspacing; - break; - case ARG_VSPACING: - GTK_VALUE_UINT (*arg) = wbox->vspacing; - break; - case ARG_ASPECT_RATIO: - GTK_VALUE_FLOAT (*arg) = wbox->aspect_ratio; - break; - case ARG_CURRENT_RATIO: - GTK_VALUE_FLOAT (*arg) = (((gfloat) widget->allocation.width) / - ((gfloat) widget->allocation.height)); - break; - case ARG_CHILD_LIMIT: - GTK_VALUE_UINT (*arg) = wbox->child_limit; - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -gtk_wrap_box_set_child_arg (GtkContainer *container, - GtkWidget *child, - GtkArg *arg, - guint arg_id) -{ - GtkWrapBox *wbox = GTK_WRAP_BOX (container); - gboolean hexpand = FALSE, hfill = FALSE, vexpand = FALSE, vfill = FALSE; - - if (arg_id != CHILD_ARG_POSITION) - gtk_wrap_box_query_child_packing (wbox, child, &hexpand, &hfill, &vexpand, &vfill); - - switch (arg_id) - { - case CHILD_ARG_POSITION: - gtk_wrap_box_reorder_child (wbox, child, GTK_VALUE_INT (*arg)); - break; - case CHILD_ARG_HEXPAND: - gtk_wrap_box_set_child_packing (wbox, child, - GTK_VALUE_BOOL (*arg), hfill, - vexpand, vfill); - break; - case CHILD_ARG_HFILL: - gtk_wrap_box_set_child_packing (wbox, child, - hexpand, GTK_VALUE_BOOL (*arg), - vexpand, vfill); - break; - case CHILD_ARG_VEXPAND: - gtk_wrap_box_set_child_packing (wbox, child, - hexpand, hfill, - GTK_VALUE_BOOL (*arg), vfill); - break; - case CHILD_ARG_VFILL: - gtk_wrap_box_set_child_packing (wbox, child, - hexpand, hfill, - vexpand, GTK_VALUE_BOOL (*arg)); - break; - case CHILD_ARG_FORCED_BREAK: - gtk_wrap_box_set_child_forced_break (wbox, child, - GTK_VALUE_BOOL (*arg)); - break; - default: - break; - } -} - -static void -gtk_wrap_box_get_child_arg (GtkContainer *container, - GtkWidget *child, - GtkArg *arg, - guint arg_id) -{ - GtkWrapBox *wbox = GTK_WRAP_BOX (container); - gboolean hexpand = FALSE, hfill = FALSE, vexpand = FALSE, vfill = FALSE; - - if (arg_id != CHILD_ARG_POSITION) - gtk_wrap_box_query_child_packing (wbox, child, &hexpand, &hfill, &vexpand, &vfill); - - switch (arg_id) - { - GtkWrapBoxChild *child_info; - case CHILD_ARG_POSITION: - GTK_VALUE_INT (*arg) = 0; - for (child_info = wbox->children; child_info; child_info = child_info->next) - { - if (child_info->widget == child) - break; - GTK_VALUE_INT (*arg)++; - } - if (!child_info) - GTK_VALUE_INT (*arg) = -1; - break; - case CHILD_ARG_HEXPAND: - GTK_VALUE_BOOL (*arg) = hexpand; - break; - case CHILD_ARG_HFILL: - GTK_VALUE_BOOL (*arg) = hfill; - break; - case CHILD_ARG_VEXPAND: - GTK_VALUE_BOOL (*arg) = vexpand; - break; - case CHILD_ARG_VFILL: - GTK_VALUE_BOOL (*arg) = vfill; - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static GtkType -gtk_wrap_box_child_type (GtkContainer *container) -{ - return GTK_TYPE_WIDGET; -} - -void -gtk_wrap_box_set_homogeneous (GtkWrapBox *wbox, - gboolean homogeneous) -{ - g_return_if_fail (GTK_IS_WRAP_BOX (wbox)); - - homogeneous = homogeneous != FALSE; - if (wbox->homogeneous != homogeneous) - { - wbox->homogeneous = homogeneous; - gtk_widget_queue_resize (GTK_WIDGET (wbox)); - } -} - -void -gtk_wrap_box_set_hspacing (GtkWrapBox *wbox, - guint hspacing) -{ - g_return_if_fail (GTK_IS_WRAP_BOX (wbox)); - - if (wbox->hspacing != hspacing) - { - wbox->hspacing = hspacing; - gtk_widget_queue_resize (GTK_WIDGET (wbox)); - } -} - -void -gtk_wrap_box_set_vspacing (GtkWrapBox *wbox, - guint vspacing) -{ - g_return_if_fail (GTK_IS_WRAP_BOX (wbox)); - - if (wbox->vspacing != vspacing) - { - wbox->vspacing = vspacing; - gtk_widget_queue_resize (GTK_WIDGET (wbox)); - } -} - -void -gtk_wrap_box_set_justify (GtkWrapBox *wbox, - GtkJustification justify) -{ - g_return_if_fail (GTK_IS_WRAP_BOX (wbox)); - g_return_if_fail (justify <= GTK_JUSTIFY_FILL); - - if (wbox->justify != justify) - { - wbox->justify = justify; - gtk_widget_queue_resize (GTK_WIDGET (wbox)); - } -} - -void -gtk_wrap_box_set_line_justify (GtkWrapBox *wbox, - GtkJustification line_justify) -{ - g_return_if_fail (GTK_IS_WRAP_BOX (wbox)); - g_return_if_fail (line_justify <= GTK_JUSTIFY_FILL); - - if (wbox->line_justify != line_justify) - { - wbox->line_justify = line_justify; - gtk_widget_queue_resize (GTK_WIDGET (wbox)); - } -} - -void -gtk_wrap_box_set_aspect_ratio (GtkWrapBox *wbox, - gfloat aspect_ratio) -{ - g_return_if_fail (GTK_IS_WRAP_BOX (wbox)); - - aspect_ratio = CLAMP (aspect_ratio, 1.0 / 256.0, 256.0); - - if (wbox->aspect_ratio != aspect_ratio) - { - wbox->aspect_ratio = aspect_ratio; - gtk_widget_queue_resize (GTK_WIDGET (wbox)); - } -} - -void -gtk_wrap_box_pack (GtkWrapBox *wbox, - GtkWidget *child, - gboolean hexpand, - gboolean hfill, - gboolean vexpand, - gboolean vfill) -{ - GtkWrapBoxChild *child_info; - - g_return_if_fail (GTK_IS_WRAP_BOX (wbox)); - g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (child->parent == NULL); - - child_info = g_new (GtkWrapBoxChild, 1); - child_info->widget = child; - child_info->hexpand = hexpand ? TRUE : FALSE; - child_info->hfill = hfill ? TRUE : FALSE; - child_info->vexpand = vexpand ? TRUE : FALSE; - child_info->vfill = vfill ? TRUE : FALSE; - child_info->forced_break = FALSE; - child_info->next = NULL; - if (wbox->children) - { - GtkWrapBoxChild *last = wbox->children; - - while (last->next) - last = last->next; - last->next = child_info; - } - else - wbox->children = child_info; - wbox->n_children++; - - gtk_widget_set_parent (child, GTK_WIDGET (wbox)); - - if (GTK_WIDGET_REALIZED (wbox)) - gtk_widget_realize (child); - - if (GTK_WIDGET_VISIBLE (wbox) && GTK_WIDGET_VISIBLE (child)) - { - if (GTK_WIDGET_MAPPED (wbox)) - gtk_widget_map (child); - - gtk_widget_queue_resize (child); - } -} - -void -gtk_wrap_box_reorder_child (GtkWrapBox *wbox, - GtkWidget *child, - gint position) -{ - GtkWrapBoxChild *child_info, *last = NULL; - - g_return_if_fail (GTK_IS_WRAP_BOX (wbox)); - g_return_if_fail (GTK_IS_WIDGET (child)); - - for (child_info = wbox->children; child_info; last = child_info, child_info = last->next) - if (child_info->widget == child) - break; - - if (child_info && wbox->children->next) - { - GtkWrapBoxChild *tmp; - - if (last) - last->next = child_info->next; - else - wbox->children = child_info->next; - - last = NULL; - tmp = wbox->children; - while (position && tmp->next) - { - position--; - last = tmp; - tmp = last->next; - } - - if (position) - { - tmp->next = child_info; - child_info->next = NULL; - } - else - { - child_info->next = tmp; - if (last) - last->next = child_info; - else - wbox->children = child_info; - } - - if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (wbox)) - gtk_widget_queue_resize (child); - } -} - -void -gtk_wrap_box_query_child_packing (GtkWrapBox *wbox, - GtkWidget *child, - gboolean *hexpand, - gboolean *hfill, - gboolean *vexpand, - gboolean *vfill) -{ - GtkWrapBoxChild *child_info; - - g_return_if_fail (GTK_IS_WRAP_BOX (wbox)); - g_return_if_fail (GTK_IS_WIDGET (child)); - - for (child_info = wbox->children; child_info; child_info = child_info->next) - if (child_info->widget == child) - break; - - if (child_info) - { - if (hexpand) - *hexpand = child_info->hexpand; - if (hfill) - *hfill = child_info->hfill; - if (vexpand) - *vexpand = child_info->vexpand; - if (vfill) - *vfill = child_info->vfill; - } -} - -void -gtk_wrap_box_query_child_forced_break (GtkWrapBox *wbox, - GtkWidget *child, - gboolean *forced_break) -{ - GtkWrapBoxChild *child_info; - - g_return_if_fail (GTK_IS_WRAP_BOX (wbox)); - g_return_if_fail (GTK_IS_WIDGET (child)); - - for (child_info = wbox->children; child_info; child_info = child_info->next) - if (child_info->widget == child) - break; - - if (child_info) - { - if (forced_break) - *forced_break = child_info->forced_break; - } -} - -void -gtk_wrap_box_set_child_packing (GtkWrapBox *wbox, - GtkWidget *child, - gboolean hexpand, - gboolean hfill, - gboolean vexpand, - gboolean vfill) -{ - GtkWrapBoxChild *child_info; - - g_return_if_fail (GTK_IS_WRAP_BOX (wbox)); - g_return_if_fail (GTK_IS_WIDGET (child)); - - hexpand = hexpand != FALSE; - hfill = hfill != FALSE; - vexpand = vexpand != FALSE; - vfill = vfill != FALSE; - - for (child_info = wbox->children; child_info; child_info = child_info->next) - if (child_info->widget == child) - break; - - if (child_info && - (child_info->hexpand != hexpand || child_info->vexpand != vexpand || - child_info->hfill != hfill || child_info->vfill != vfill)) - { - child_info->hexpand = hexpand; - child_info->hfill = hfill; - child_info->vexpand = vexpand; - child_info->vfill = vfill; - - if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (wbox)) - gtk_widget_queue_resize (child); - } -} - -void -gtk_wrap_box_set_child_forced_break (GtkWrapBox *wbox, - GtkWidget *child, - gboolean forced_break) -{ - GtkWrapBoxChild *child_info; - - g_return_if_fail (GTK_IS_WRAP_BOX (wbox)); - g_return_if_fail (GTK_IS_WIDGET (child)); - - forced_break = forced_break != FALSE; - - for (child_info = wbox->children; child_info; child_info = child_info->next) - if (child_info->widget == child) - break; - - if (child_info && - (child_info->forced_break != forced_break)) - { - child_info->forced_break = forced_break; - - if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (wbox)) - gtk_widget_queue_resize (child); - } -} - -guint* -gtk_wrap_box_query_line_lengths (GtkWrapBox *wbox, - guint *_n_lines) -{ - GtkWrapBoxChild *next_child = NULL; - GtkAllocation area, *allocation; - gboolean expand_line; - GSList *slist; - guint max_child_size, border, n_lines = 0, *lines = NULL; - - if (_n_lines) - *_n_lines = 0; - g_return_val_if_fail (GTK_IS_WRAP_BOX (wbox), NULL); - - allocation = >K_WIDGET (wbox)->allocation; - border = GTK_CONTAINER (wbox)->border_width; - area.x = allocation->x + border; - area.y = allocation->y + border; - area.width = MAX (1, (gint) allocation->width - border * 2); - area.height = MAX (1, (gint) allocation->height - border * 2); - - next_child = wbox->children; - slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox, - &next_child, - &area, - &max_child_size, - &expand_line); - while (slist) - { - guint l = n_lines++; - - lines = g_renew (guint, lines, n_lines); - lines[l] = g_slist_length (slist); - g_slist_free (slist); - - slist = GTK_WRAP_BOX_GET_CLASS (wbox)->rlist_line_children (wbox, - &next_child, - &area, - &max_child_size, - &expand_line); - } - - if (_n_lines) - *_n_lines = n_lines; - - return lines; -} - -static void -gtk_wrap_box_map (GtkWidget *widget) -{ - GtkWrapBox *wbox = GTK_WRAP_BOX (widget); - GtkWrapBoxChild *child; - - GTK_WIDGET_SET_FLAGS (wbox, GTK_MAPPED); - - for (child = wbox->children; child; child = child->next) - if (GTK_WIDGET_VISIBLE (child->widget) && - !GTK_WIDGET_MAPPED (child->widget)) - gtk_widget_map (child->widget); -} - -static void -gtk_wrap_box_unmap (GtkWidget *widget) -{ - GtkWrapBox *wbox = GTK_WRAP_BOX (widget); - GtkWrapBoxChild *child; - - GTK_WIDGET_UNSET_FLAGS (wbox, GTK_MAPPED); - - for (child = wbox->children; child; child = child->next) - if (GTK_WIDGET_VISIBLE (child->widget) && - GTK_WIDGET_MAPPED (child->widget)) - gtk_widget_unmap (child->widget); -} - -static void -gtk_wrap_box_draw (GtkWidget *widget, - GdkRectangle *area) -{ - GtkWrapBox *wbox = GTK_WRAP_BOX (widget); - GtkWrapBoxChild *child; - GdkRectangle child_area; - - if (GTK_WIDGET_DRAWABLE (widget)) - for (child = wbox->children; child; child = child->next) - if (GTK_WIDGET_DRAWABLE (child->widget) && - gtk_widget_intersect (child->widget, area, &child_area)) - gtk_widget_draw (child->widget, &child_area); -} - -static gint -gtk_wrap_box_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - GtkWrapBox *wbox = GTK_WRAP_BOX (widget); - GtkWrapBoxChild *child; - GdkEventExpose child_event = *event; - - g_return_val_if_fail (event != NULL, FALSE); - - if (GTK_WIDGET_DRAWABLE (widget)) - for (child = wbox->children; child; child = child->next) - if (GTK_WIDGET_DRAWABLE (child->widget) && - GTK_WIDGET_NO_WINDOW (child->widget) && - gtk_widget_intersect (child->widget, &event->area, &child_event.area)) - gtk_widget_event (child->widget, (GdkEvent*) &child_event); - - return TRUE; -} - -static void -gtk_wrap_box_add (GtkContainer *container, - GtkWidget *widget) -{ - gtk_wrap_box_pack (GTK_WRAP_BOX (container), widget, FALSE, TRUE, FALSE, TRUE); -} - -static void -gtk_wrap_box_remove (GtkContainer *container, - GtkWidget *widget) -{ - GtkWrapBox *wbox = GTK_WRAP_BOX (container); - GtkWrapBoxChild *child, *last = NULL; - - child = wbox->children; - while (child) - { - if (child->widget == widget) - { - gboolean was_visible; - - was_visible = GTK_WIDGET_VISIBLE (widget); - gtk_widget_unparent (widget); - - if (last) - last->next = child->next; - else - wbox->children = child->next; - g_free (child); - wbox->n_children--; - - if (was_visible) - gtk_widget_queue_resize (GTK_WIDGET (container)); - - break; - } - - last = child; - child = last->next; - } -} - -static void -gtk_wrap_box_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - GtkWrapBox *wbox = GTK_WRAP_BOX (container); - GtkWrapBoxChild *child; - - child = wbox->children; - while (child) - { - GtkWidget *widget = child->widget; - - child = child->next; - - callback (widget, callback_data); - } -} diff --git a/app/gtkwrapbox.h b/app/gtkwrapbox.h deleted file mode 100644 index 6b2266b83c..0000000000 --- a/app/gtkwrapbox.h +++ /dev/null @@ -1,140 +0,0 @@ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * GtkWrapBox: Wrapping box widget - * Copyright (C) 1999 Tim Janik - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __GTK_WRAP_BOX_H__ -#define __GTK_WRAP_BOX_H__ - - -#include -#include - - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - - -/* --- type macros --- */ -#define GTK_TYPE_WRAP_BOX (gtk_wrap_box_get_type ()) -#define GTK_WRAP_BOX(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_WRAP_BOX, GtkWrapBox)) -#define GTK_WRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_WRAP_BOX, GtkWrapBoxClass)) -#define GTK_IS_WRAP_BOX(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_WRAP_BOX)) -#define GTK_IS_WRAP_BOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_WRAP_BOX)) -#define GTK_WRAP_BOX_GET_CLASS(obj) (GTK_WRAP_BOX_CLASS (((GtkObject*) (obj))->klass)) - - -/* --- typedefs --- */ -typedef struct _GtkWrapBox GtkWrapBox; -typedef struct _GtkWrapBoxClass GtkWrapBoxClass; -typedef struct _GtkWrapBoxChild GtkWrapBoxChild; - -/* --- GtkWrapBox --- */ -struct _GtkWrapBox -{ - GtkContainer container; - - guint homogeneous : 1; - guint justify : 4; - guint line_justify : 4; - guint8 hspacing; - guint8 vspacing; - guint16 n_children; - GtkWrapBoxChild *children; - gfloat aspect_ratio; /* 1/256..256 */ - guint child_limit; -}; -struct _GtkWrapBoxClass -{ - GtkContainerClass parent_class; - - GSList* (*rlist_line_children) (GtkWrapBox *wbox, - GtkWrapBoxChild **child_p, - GtkAllocation *area, - guint *max_child_size, - gboolean *expand_line); -}; -struct _GtkWrapBoxChild -{ - GtkWidget *widget; - guint hexpand : 1; - guint hfill : 1; - guint vexpand : 1; - guint vfill : 1; - guint forced_break : 1; - - GtkWrapBoxChild *next; -}; -#define GTK_JUSTIFY_TOP GTK_JUSTIFY_LEFT -#define GTK_JUSTIFY_BOTTOM GTK_JUSTIFY_RIGHT - - -/* --- prototypes --- */ -GtkType gtk_wrap_box_get_type (void); -void gtk_wrap_box_set_homogeneous (GtkWrapBox *wbox, - gboolean homogeneous); -void gtk_wrap_box_set_hspacing (GtkWrapBox *wbox, - guint hspacing); -void gtk_wrap_box_set_vspacing (GtkWrapBox *wbox, - guint vspacing); -void gtk_wrap_box_set_justify (GtkWrapBox *wbox, - GtkJustification justify); -void gtk_wrap_box_set_line_justify (GtkWrapBox *wbox, - GtkJustification line_justify); -void gtk_wrap_box_set_aspect_ratio (GtkWrapBox *wbox, - gfloat aspect_ratio); -void gtk_wrap_box_pack (GtkWrapBox *wbox, - GtkWidget *child, - gboolean hexpand, - gboolean hfill, - gboolean vexpand, - gboolean vfill); -void gtk_wrap_box_reorder_child (GtkWrapBox *wbox, - GtkWidget *child, - gint position); -void gtk_wrap_box_query_child_packing (GtkWrapBox *wbox, - GtkWidget *child, - gboolean *hexpand, - gboolean *hfill, - gboolean *vexpand, - gboolean *vfill); -void gtk_wrap_box_query_child_forced_break (GtkWrapBox *wbox, - GtkWidget *child, - gboolean *forced_break); -void gtk_wrap_box_set_child_packing (GtkWrapBox *wbox, - GtkWidget *child, - gboolean hexpand, - gboolean hfill, - gboolean vexpand, - gboolean vfill); -void gtk_wrap_box_set_child_forced_break (GtkWrapBox *wbox, - GtkWidget *child, - gboolean forced_break); -guint* gtk_wrap_box_query_line_lengths (GtkWrapBox *wbox, - guint *n_lines); - - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __GTK_WRAP_BOX_H__ */ diff --git a/app/gui/brush-select.c b/app/gui/brush-select.c index c3ff253581..beca142f84 100644 --- a/app/gui/brush-select.c +++ b/app/gui/brush-select.c @@ -26,6 +26,8 @@ #include "apptypes.h" +#include "widgets/gimpdatafactoryview.h" + #include "appenv.h" #include "context_manager.h" #include "brush_edit.h" @@ -33,7 +35,6 @@ #include "dialog_handler.h" #include "gimpbrushgenerated.h" #include "gimpcontainer.h" -#include "gimpdatafactoryview.h" #include "gimpcontext.h" #include "gimpdata.h" #include "gimpdatafactory.h" diff --git a/app/gui/channels-dialog.c b/app/gui/channels-dialog.c index 235544d26e..152bf03147 100644 --- a/app/gui/channels-dialog.c +++ b/app/gui/channels-dialog.c @@ -29,9 +29,10 @@ #include "paint-funcs/paint-funcs.h" +#include "widgets/gimpcolorpanel.h" + #include "appenv.h" #include "channels_dialog.h" -#include "color_panel.h" #include "drawable.h" #include "gdisplay.h" #include "gimage.h" diff --git a/app/gui/device-status-dialog.c b/app/gui/device-status-dialog.c index a4abfbef48..4089368eb9 100644 --- a/app/gui/device-status-dialog.c +++ b/app/gui/device-status-dialog.c @@ -31,6 +31,8 @@ #include "tools/gimptoolinfo.h" #include "tools/tool_manager.h" +#include "widgets/gimppreview.h" + #include "appenv.h" #include "context_manager.h" #include "devices.h" @@ -41,7 +43,6 @@ #include "gimpdnd.h" #include "gimpgradient.h" #include "gimppattern.h" -#include "gimppreview.h" #include "gimplist.h" #include "gimprc.h" #include "session.h" diff --git a/app/gui/gradient-editor.c b/app/gui/gradient-editor.c index 011cbad308..a1317aa52e 100644 --- a/app/gui/gradient-editor.c +++ b/app/gui/gradient-editor.c @@ -63,13 +63,14 @@ #include "apptypes.h" +#include "widgets/gimpcontainerlistview.h" + #include "color_notebook.h" #include "context_manager.h" #include "cursorutil.h" #include "datafiles.h" #include "errors.h" #include "gimpcontainer.h" -#include "gimpcontainerlistview.h" #include "gimpcontext.h" #include "gimpdatafactory.h" #include "gimpdnd.h" diff --git a/app/gui/gradient-select.c b/app/gui/gradient-select.c index ae0e1c3d9b..d27dfb809b 100644 --- a/app/gui/gradient-select.c +++ b/app/gui/gradient-select.c @@ -27,11 +27,12 @@ #include "apptypes.h" +#include "widgets/gimpdatafactoryview.h" + #include "appenv.h" #include "context_manager.h" #include "dialog_handler.h" #include "gimpcontainer.h" -#include "gimpdatafactoryview.h" #include "gimpcontext.h" #include "gimpdatafactory.h" #include "gimpgradient.h" diff --git a/app/gui/indicator-area.c b/app/gui/indicator-area.c index eb1615213a..d587f18238 100644 --- a/app/gui/indicator-area.c +++ b/app/gui/indicator-area.c @@ -27,12 +27,13 @@ #include "apptypes.h" +#include "widgets/gimppreview.h" + #include "brush_select.h" #include "gimpbrush.h" #include "gimpcontext.h" #include "gimpgradient.h" #include "gimppattern.h" -#include "gimppreview.h" #include "gimpdnd.h" #include "gradient_select.h" #include "indicator_area.h" diff --git a/app/gui/info-window.c b/app/gui/info-window.c index d4c679805c..0590fb3ea2 100644 --- a/app/gui/info-window.c +++ b/app/gui/info-window.c @@ -28,13 +28,14 @@ #include "tools/gimpcolorpickertool.h" #include "tools/tool_manager.h" +#include "widgets/gimppreview.h" + #include "context_manager.h" #include "colormaps.h" #include "gdisplay.h" #include "gimpcontainer.h" #include "gimpcontext.h" #include "gimpimage.h" -#include "gimppreview.h" #include "info_dialog.h" #include "info_window.h" diff --git a/app/gui/input-dialog.c b/app/gui/input-dialog.c index a4abfbef48..4089368eb9 100644 --- a/app/gui/input-dialog.c +++ b/app/gui/input-dialog.c @@ -31,6 +31,8 @@ #include "tools/gimptoolinfo.h" #include "tools/tool_manager.h" +#include "widgets/gimppreview.h" + #include "appenv.h" #include "context_manager.h" #include "devices.h" @@ -41,7 +43,6 @@ #include "gimpdnd.h" #include "gimpgradient.h" #include "gimppattern.h" -#include "gimppreview.h" #include "gimplist.h" #include "gimprc.h" #include "session.h" diff --git a/app/gui/palette-editor.c b/app/gui/palette-editor.c index aebdcb202a..14196f1c45 100644 --- a/app/gui/palette-editor.c +++ b/app/gui/palette-editor.c @@ -25,19 +25,20 @@ #include "apptypes.h" +#include "widgets/gimpcontainerlistview.h" +#include "widgets/gimpdatafactoryview.h" +#include "widgets/gimppreview.h" + #include "color_area.h" #include "color_notebook.h" #include "context_manager.h" #include "dialog_handler.h" #include "gimage.h" -#include "gimpcontainerlistview.h" #include "gimpcontext.h" #include "gimpdatafactory.h" -#include "gimpdatafactoryview.h" #include "gimpdatalist.h" #include "gimpdnd.h" #include "gimppalette.h" -#include "gimppreview.h" #include "gimprc.h" #include "palette.h" #include "palette_import.h" diff --git a/app/gui/palette-select.c b/app/gui/palette-select.c index 020d1dfa16..7640af039a 100644 --- a/app/gui/palette-select.c +++ b/app/gui/palette-select.c @@ -27,12 +27,13 @@ #include "apptypes.h" +#include "widgets/gimpdatafactoryview.h" + #include "appenv.h" #include "context_manager.h" #include "dialog_handler.h" #include "gimpcontainer.h" #include "gimpcontext.h" -#include "gimpdatafactoryview.h" #include "gimpdatafactory.h" #include "gimpdnd.h" #include "gimppalette.h" diff --git a/app/gui/pattern-select.c b/app/gui/pattern-select.c index 68b5ce387b..aa1ec0e95c 100644 --- a/app/gui/pattern-select.c +++ b/app/gui/pattern-select.c @@ -26,12 +26,13 @@ #include "apptypes.h" +#include "widgets/gimpdatafactoryview.h" + #include "appenv.h" #include "context_manager.h" #include "dialog_handler.h" #include "gimpcontainer.h" #include "gimpcontext.h" -#include "gimpdatafactoryview.h" #include "gimpdatafactory.h" #include "gimppattern.h" #include "pattern_select.h" diff --git a/app/gui/qmask-commands.c b/app/gui/qmask-commands.c index 95cfd79672..95822059ff 100644 --- a/app/gui/qmask-commands.c +++ b/app/gui/qmask-commands.c @@ -29,7 +29,8 @@ #include "apptypes.h" -#include "color_panel.h" +#include "widgets/gimpcolorpanel.h" + #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" diff --git a/app/gui/test-commands.c b/app/gui/test-commands.c index e15707d1d5..4b7bed19fe 100644 --- a/app/gui/test-commands.c +++ b/app/gui/test-commands.c @@ -27,22 +27,23 @@ #include "tools/tool_manager.h" +#include "widgets/gimpcontainerlistview.h" +#include "widgets/gimpcontainergridview.h" +#include "widgets/gimpdatafactoryview.h" +#include "widgets/gimpdock.h" +#include "widgets/gimpdockable.h" +#include "widgets/gimpdockbook.h" +#include "widgets/gimpdrawablelistview.h" +#include "widgets/gimppreview.h" + #include "context_manager.h" #include "gradient_editor.h" #include "gimpchannel.h" #include "gimpcontainer.h" -#include "gimpcontainerlistview.h" -#include "gimpcontainergridview.h" #include "gimpcontext.h" #include "gimpdatafactory.h" -#include "gimpdatafactoryview.h" -#include "gimpdock.h" -#include "gimpdockable.h" -#include "gimpdockbook.h" -#include "gimpdrawablelistview.h" #include "gimpimage.h" #include "gimplayer.h" -#include "gimppreview.h" #include "gimprc.h" #include "libgimp/gimpintl.h" diff --git a/app/gui/tool-options-dialog.c b/app/gui/tool-options-dialog.c index ca5018d35c..c85131af5c 100644 --- a/app/gui/tool-options-dialog.c +++ b/app/gui/tool-options-dialog.c @@ -24,11 +24,12 @@ #include "apptypes.h" +#include "widgets/gimppreview.h" + #include "dialog_handler.h" #include "gimpcontext.h" #include "gimpdnd.h" #include "gimplist.h" -#include "gimppreview.h" #include "gimpui.h" #include "session.h" diff --git a/app/gui/toolbox.c b/app/gui/toolbox.c index b0eebd74c2..525d4273f0 100644 --- a/app/gui/toolbox.c +++ b/app/gui/toolbox.c @@ -32,6 +32,9 @@ #include "tools/tool_options_dialog.h" #include "tools/tool_manager.h" +#include "widgets/gimppreview.h" +#include "widgets/gtkhwrapbox.h" + #include "app_procs.h" #include "color_area.h" #include "devices.h" @@ -42,9 +45,7 @@ #include "gimpdnd.h" #include "gimplayer.h" #include "gimplist.h" -#include "gimppreview.h" #include "gimprc.h" -#include "gtkhwrapbox.h" #include "indicator_area.h" #include "menus.h" #include "session.h" diff --git a/app/histogramwidget.c b/app/histogramwidget.c deleted file mode 100644 index 6c81f41767..0000000000 --- a/app/histogramwidget.c +++ /dev/null @@ -1,315 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * 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 - -#include "libgimpmath/gimpmath.h" - -#include "apptypes.h" - -#include "gimage.h" -#include "gimage_mask.h" -#include "gimphistogram.h" -#include "histogramwidget.h" -#include "tile_manager.h" - - -#define WAITING 0 -#define WORKING 1 - -#define WORK_DELAY 1 - -#define HISTOGRAM_MASK GDK_EXPOSURE_MASK | \ - GDK_BUTTON_PRESS_MASK | \ - GDK_BUTTON_RELEASE_MASK | \ - GDK_BUTTON1_MOTION_MASK - -#define HISTOGRAM 0x1 -#define RANGE 0x2 -#define ALL 0xF - - -enum -{ - RANGE_CHANGED, - LAST_SIGNAL -}; - -static guint histogram_widget_signals[LAST_SIGNAL]; - -static void histogram_widget_class_init (HistogramWidgetClass *klass); -static void histogram_widget_init (HistogramWidget *histogram); - - -/**************************/ -/* Function definitions */ - -GtkType -histogram_widget_get_type (void) -{ - static GtkType histogram_widet_type = 0; - - if (! histogram_widet_type) - { - static const GtkTypeInfo info = - { - "HistogramWidget", - sizeof (HistogramWidget), - sizeof (HistogramWidgetClass), - (GtkClassInitFunc) histogram_widget_class_init, - (GtkObjectInitFunc) histogram_widget_init, - NULL, NULL - }; - - histogram_widet_type = - gtk_type_unique (gtk_drawing_area_get_type (), &info); - } - - return histogram_widet_type; -} - -static void -histogram_widget_class_init (HistogramWidgetClass *klass) -{ - GtkObjectClass *object_class; - - object_class = GTK_OBJECT_CLASS (klass); - - histogram_widget_signals[RANGE_CHANGED] = - gtk_signal_new ("range_changed", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (HistogramWidgetClass, range_changed), - gtk_marshal_NONE__INT_INT, - GTK_TYPE_NONE, 2, - GTK_TYPE_INT, - GTK_TYPE_INT); - - gtk_object_class_add_signals (GTK_OBJECT_CLASS (klass), - histogram_widget_signals, LAST_SIGNAL); - - klass->range_changed = NULL; -} - -static void -histogram_widget_init (HistogramWidget *histogram) -{ - histogram->histogram = NULL; - histogram->channel = GIMP_HISTOGRAM_VALUE; - histogram->start = 0; - histogram->end = 255; -} - -static void -histogram_widget_draw (HistogramWidget *histogram, - gint update) -{ - gdouble max; - gdouble v; - gint i, x, y; - gint x1, x2; - gint width, height; - - width = GTK_WIDGET (histogram)->allocation.width - 2; - height = GTK_WIDGET (histogram)->allocation.height - 2; - - if (update & HISTOGRAM) - { - /* find the maximum value */ - max = gimp_histogram_get_maximum (histogram->histogram, - histogram->channel); - - if (max > 0.0) - max = log (max); - else - max = 1.0; - - /* clear the histogram */ - gdk_window_clear (GTK_WIDGET (histogram)->window); - - /* Draw the axis */ - gdk_draw_line (GTK_WIDGET (histogram)->window, - GTK_WIDGET (histogram)->style->black_gc, - 1, height + 1, width, height + 1); - - /* Draw the spikes */ - for (i = 0; i < 256; i++) - { - x = (width * i) / 256 + 1; - v = gimp_histogram_get_value (histogram->histogram, - histogram->channel, i); - if (v > 0.0) - y = (int) ((height * log (v)) / max); - else - y = 0; - gdk_draw_line (GTK_WIDGET (histogram)->window, - GTK_WIDGET (histogram)->style->black_gc, - x, height + 1, - x, height + 1 - y); - } - } - - if ((update & RANGE) && histogram->start >= 0) - { - x1 = (width * MIN (histogram->start, histogram->end)) / 256 + 1; - x2 = (width * MAX (histogram->start, histogram->end)) / 256 + 1; - gdk_gc_set_function (GTK_WIDGET (histogram)->style->black_gc, GDK_INVERT); - gdk_draw_rectangle (GTK_WIDGET (histogram)->window, - GTK_WIDGET (histogram)->style->black_gc, TRUE, - x1, 1, (x2 - x1) + 1, height); - gdk_gc_set_function (GTK_WIDGET (histogram)->style->black_gc, GDK_COPY); - } -} - -static gint -histogram_widget_events (HistogramWidget *histogram, - GdkEvent *event) -{ - GdkEventButton *bevent; - GdkEventMotion *mevent; - gint width; - - switch (event->type) - { - case GDK_EXPOSE: - histogram_widget_draw (histogram, ALL); - break; - - case GDK_BUTTON_PRESS: - bevent = (GdkEventButton *) event; - - if (bevent->button != 1) - break; - - gdk_pointer_grab (GTK_WIDGET (histogram)->window, FALSE, - GDK_BUTTON_RELEASE_MASK | GDK_BUTTON1_MOTION_MASK, - NULL, NULL, bevent->time); - - width = GTK_WIDGET (histogram)->allocation.width - 2; - - histogram_widget_draw (histogram, RANGE); - - histogram->start = CLAMP ((((bevent->x - 1) * 256) / width), 0, 255); - histogram->end = histogram->start; - - histogram_widget_draw (histogram, RANGE); - break; - - case GDK_BUTTON_RELEASE: - bevent = (GdkEventButton *) event; - - gdk_pointer_ungrab (bevent->time); - - gtk_signal_emit (GTK_OBJECT(histogram), - histogram_widget_signals[RANGE_CHANGED], - MIN (histogram->start, histogram->end), - MAX (histogram->start, histogram->end)); - break; - - case GDK_MOTION_NOTIFY: - mevent = (GdkEventMotion *) event; - width = GTK_WIDGET (histogram)->allocation.width - 2; - - histogram_widget_draw (histogram, RANGE); - - histogram->start = CLAMP ((((mevent->x - 1) * 256) / width), 0, 255); - - histogram_widget_draw (histogram, RANGE); - break; - - default: - break; - } - - return FALSE; -} - -HistogramWidget * -histogram_widget_new (gint width, - gint height) -{ - HistogramWidget *histogram; - - histogram = HISTOGRAM_WIDGET (gtk_type_new (HISTOGRAM_WIDGET_TYPE)); - - gtk_drawing_area_size (GTK_DRAWING_AREA (histogram), width + 2, height + 2); - gtk_widget_set_events (GTK_WIDGET (histogram), HISTOGRAM_MASK); - - gtk_signal_connect (GTK_OBJECT (histogram), "event", - GTK_SIGNAL_FUNC (histogram_widget_events), - histogram); - - return histogram; -} - -void -histogram_widget_update (HistogramWidget *histogram_widget, - GimpHistogram *hist) -{ - histogram_widget->histogram = hist; - - if (!hist) - return; - - if (histogram_widget->channel >= gimp_histogram_nchannels (hist)) - histogram_widget_channel (histogram_widget, 0); - - /* Make sure the histogram is updated */ - gtk_widget_draw (GTK_WIDGET (histogram_widget), NULL); - - /* Give a range callback */ - gtk_signal_emit (GTK_OBJECT (histogram_widget), - histogram_widget_signals[RANGE_CHANGED], - MIN (histogram_widget->start, histogram_widget->end), - MAX (histogram_widget->start, histogram_widget->end)); -} - -void -histogram_widget_range (HistogramWidget *histogram, - gint start, - gint end) -{ - histogram_widget_draw (histogram, RANGE); - - histogram->start = start; - histogram->end = end; - - histogram_widget_draw (histogram, RANGE); -} - -void -histogram_widget_channel (HistogramWidget *histogram, - int channel) -{ - histogram->channel = channel; - histogram_widget_draw (histogram, ALL); - - /* Give a range callback */ - gtk_signal_emit (GTK_OBJECT (histogram), - histogram_widget_signals[RANGE_CHANGED], - MIN (histogram->start, histogram->end), - MAX (histogram->start, histogram->end)); -} - -GimpHistogram * -histogram_widget_histogram (HistogramWidget *histogram) -{ - return histogram->histogram; -} diff --git a/app/histogramwidget.h b/app/histogramwidget.h deleted file mode 100644 index 3f5149835e..0000000000 --- a/app/histogramwidget.h +++ /dev/null @@ -1,70 +0,0 @@ -/* The GIMP -- an image manipulation program - * Copyright (C) 1995 Spencer Kimball and Peter Mattis - * - * 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 __HISTOGRAM_WIDGET_H__ -#define __HISTOGRAM_WIDGET_H__ - - -#include - - -#define HISTOGRAM_WIDGET_TYPE (histogram_widget_get_type ()) -#define HISTOGRAM_WIDGET(obj) GTK_CHECK_CAST (obj, histogram_widget_get_type (), HistogramWidget) -#define IS_HISTOGRAM_WIDGET(obj) GTK_CHECK_TYPE (obj, histogram_widget_get_type ()) -#define HISTOGRAM_WIDGET_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, histogram_widget_get_type (), HistogramWidget) - - -typedef struct _HistogramWidgetClass HistogramWidgetClass; - -struct _HistogramWidget -{ - GtkDrawingArea parent_instance; - - GimpHistogram *histogram; - GimpHistogramChannel channel; - gint start; - gint end; -}; - -struct _HistogramWidgetClass -{ - GtkDrawingAreaClass parent_class; - - void (* range_changed) (HistogramWidget *hw, - gint start, - gint end); -}; - - -/* Histogram functions */ - -GtkType histogram_widget_get_type (void); - -HistogramWidget * histogram_widget_new (gint width, - gint height); -void histogram_widget_update (HistogramWidget *hw, - GimpHistogram *histogram); -void histogram_widget_range (HistogramWidget *hw, - gint start, - gint end); -void histogram_widget_channel (HistogramWidget *hw, - gint channel); -GimpHistogram * histogram_widget_histogram (HistogramWidget *hw); - - -#endif /* __HISTOGRAM_WIDGET_H__ */ diff --git a/app/indicator_area.c b/app/indicator_area.c index eb1615213a..d587f18238 100644 --- a/app/indicator_area.c +++ b/app/indicator_area.c @@ -27,12 +27,13 @@ #include "apptypes.h" +#include "widgets/gimppreview.h" + #include "brush_select.h" #include "gimpbrush.h" #include "gimpcontext.h" #include "gimpgradient.h" #include "gimppattern.h" -#include "gimppreview.h" #include "gimpdnd.h" #include "gradient_select.h" #include "indicator_area.h" diff --git a/app/info_window.c b/app/info_window.c index d4c679805c..0590fb3ea2 100644 --- a/app/info_window.c +++ b/app/info_window.c @@ -28,13 +28,14 @@ #include "tools/gimpcolorpickertool.h" #include "tools/tool_manager.h" +#include "widgets/gimppreview.h" + #include "context_manager.h" #include "colormaps.h" #include "gdisplay.h" #include "gimpcontainer.h" #include "gimpcontext.h" #include "gimpimage.h" -#include "gimppreview.h" #include "info_dialog.h" #include "info_window.h" diff --git a/app/palette.c b/app/palette.c index aebdcb202a..14196f1c45 100644 --- a/app/palette.c +++ b/app/palette.c @@ -25,19 +25,20 @@ #include "apptypes.h" +#include "widgets/gimpcontainerlistview.h" +#include "widgets/gimpdatafactoryview.h" +#include "widgets/gimppreview.h" + #include "color_area.h" #include "color_notebook.h" #include "context_manager.h" #include "dialog_handler.h" #include "gimage.h" -#include "gimpcontainerlistview.h" #include "gimpcontext.h" #include "gimpdatafactory.h" -#include "gimpdatafactoryview.h" #include "gimpdatalist.h" #include "gimpdnd.h" #include "gimppalette.h" -#include "gimppreview.h" #include "gimprc.h" #include "palette.h" #include "palette_import.h" diff --git a/app/palette_select.c b/app/palette_select.c index 020d1dfa16..7640af039a 100644 --- a/app/palette_select.c +++ b/app/palette_select.c @@ -27,12 +27,13 @@ #include "apptypes.h" +#include "widgets/gimpdatafactoryview.h" + #include "appenv.h" #include "context_manager.h" #include "dialog_handler.h" #include "gimpcontainer.h" #include "gimpcontext.h" -#include "gimpdatafactoryview.h" #include "gimpdatafactory.h" #include "gimpdnd.h" #include "gimppalette.h" diff --git a/app/pattern_select.c b/app/pattern_select.c index 68b5ce387b..aa1ec0e95c 100644 --- a/app/pattern_select.c +++ b/app/pattern_select.c @@ -26,12 +26,13 @@ #include "apptypes.h" +#include "widgets/gimpdatafactoryview.h" + #include "appenv.h" #include "context_manager.h" #include "dialog_handler.h" #include "gimpcontainer.h" #include "gimpcontext.h" -#include "gimpdatafactoryview.h" #include "gimpdatafactory.h" #include "gimppattern.h" #include "pattern_select.h" diff --git a/app/pdb/color_cmds.c b/app/pdb/color_cmds.c index 99c9a12572..f432289b2f 100644 --- a/app/pdb/color_cmds.c +++ b/app/pdb/color_cmds.c @@ -33,7 +33,6 @@ #include "gimphistogram.h" #include "gimpimage.h" #include "gimplut.h" -#include "histogramwidget.h" #include "invert.h" #include "lut_funcs.h" #include "pixel_processor.h" @@ -43,6 +42,7 @@ #include "tools/histogram_tool.h" #include "tools/hue_saturation.h" #include "tools/threshold.h" +#include "widgets/gimphistogramview.h" static ProcRecord brightness_contrast_proc; static ProcRecord levels_proc; diff --git a/app/qmask.c b/app/qmask.c index 95cfd79672..95822059ff 100644 --- a/app/qmask.c +++ b/app/qmask.c @@ -29,7 +29,8 @@ #include "apptypes.h" -#include "color_panel.h" +#include "widgets/gimpcolorpanel.h" + #include "drawable.h" #include "floating_sel.h" #include "gdisplay.h" diff --git a/app/test_commands.c b/app/test_commands.c index e15707d1d5..4b7bed19fe 100644 --- a/app/test_commands.c +++ b/app/test_commands.c @@ -27,22 +27,23 @@ #include "tools/tool_manager.h" +#include "widgets/gimpcontainerlistview.h" +#include "widgets/gimpcontainergridview.h" +#include "widgets/gimpdatafactoryview.h" +#include "widgets/gimpdock.h" +#include "widgets/gimpdockable.h" +#include "widgets/gimpdockbook.h" +#include "widgets/gimpdrawablelistview.h" +#include "widgets/gimppreview.h" + #include "context_manager.h" #include "gradient_editor.h" #include "gimpchannel.h" #include "gimpcontainer.h" -#include "gimpcontainerlistview.h" -#include "gimpcontainergridview.h" #include "gimpcontext.h" #include "gimpdatafactory.h" -#include "gimpdatafactoryview.h" -#include "gimpdock.h" -#include "gimpdockable.h" -#include "gimpdockbook.h" -#include "gimpdrawablelistview.h" #include "gimpimage.h" #include "gimplayer.h" -#include "gimppreview.h" #include "gimprc.h" #include "libgimp/gimpintl.h" diff --git a/app/toolbox.c b/app/toolbox.c index b0eebd74c2..525d4273f0 100644 --- a/app/toolbox.c +++ b/app/toolbox.c @@ -32,6 +32,9 @@ #include "tools/tool_options_dialog.h" #include "tools/tool_manager.h" +#include "widgets/gimppreview.h" +#include "widgets/gtkhwrapbox.h" + #include "app_procs.h" #include "color_area.h" #include "devices.h" @@ -42,9 +45,7 @@ #include "gimpdnd.h" #include "gimplayer.h" #include "gimplist.h" -#include "gimppreview.h" #include "gimprc.h" -#include "gtkhwrapbox.h" #include "indicator_area.h" #include "menus.h" #include "session.h" diff --git a/app/tools/gimppaintoptions-gui.c b/app/tools/gimppaintoptions-gui.c index 5e1e9a2b69..79f7dadc33 100644 --- a/app/tools/gimppaintoptions-gui.c +++ b/app/tools/gimppaintoptions-gui.c @@ -24,9 +24,10 @@ #include "apptypes.h" +#include "widgets/gtkhwrapbox.h" + #include "gimpcontext.h" #include "gimprc.h" -#include "gtkhwrapbox.h" #include "gimptool.h" #include "gimptoolinfo.h" diff --git a/app/tools/paint_options.c b/app/tools/paint_options.c index 5e1e9a2b69..79f7dadc33 100644 --- a/app/tools/paint_options.c +++ b/app/tools/paint_options.c @@ -24,9 +24,10 @@ #include "apptypes.h" +#include "widgets/gtkhwrapbox.h" + #include "gimpcontext.h" #include "gimprc.h" -#include "gtkhwrapbox.h" #include "gimptool.h" #include "gimptoolinfo.h" diff --git a/app/tools/tool_options_dialog.c b/app/tools/tool_options_dialog.c index ca5018d35c..c85131af5c 100644 --- a/app/tools/tool_options_dialog.c +++ b/app/tools/tool_options_dialog.c @@ -24,11 +24,12 @@ #include "apptypes.h" +#include "widgets/gimppreview.h" + #include "dialog_handler.h" #include "gimpcontext.h" #include "gimpdnd.h" #include "gimplist.h" -#include "gimppreview.h" #include "gimpui.h" #include "session.h" diff --git a/app/widgets/Makefile.am b/app/widgets/Makefile.am index cdf1fb9644..854c55dbdd 100644 --- a/app/widgets/Makefile.am +++ b/app/widgets/Makefile.am @@ -5,6 +5,8 @@ noinst_LTLIBRARIES = libappwidgets.la libappwidgets_la_SOURCES = \ gimpbrushpreview.c \ gimpbrushpreview.h \ + gimpcolorpanel.c \ + gimpcolorpanel.h \ gimpcontainergridview.h \ gimpcontainergridview.c \ gimpcontainerlistview.h \ diff --git a/app/widgets/gimpcolorpanel.c b/app/widgets/gimpcolorpanel.c index c9bf08a6b2..e8561139f3 100644 --- a/app/widgets/gimpcolorpanel.c +++ b/app/widgets/gimpcolorpanel.c @@ -24,8 +24,9 @@ #include "apptypes.h" +#include "gimpcolorpanel.h" + #include "appenv.h" -#include "color_panel.h" #include "color_notebook.h" diff --git a/app/widgets/gimpcolorpanel.h b/app/widgets/gimpcolorpanel.h index 7d7fa5fb68..5ad2298372 100644 --- a/app/widgets/gimpcolorpanel.h +++ b/app/widgets/gimpcolorpanel.h @@ -16,8 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef __COLOR_PANEL_H__ -#define __COLOR_PANEL_H__ +#ifndef __GIMP_COLOR_PANEL_H__ +#define __GIMP_COLOR_PANEL_H__ #include "libgimpwidgets/gimpcolorbutton.h" @@ -29,6 +29,7 @@ #define GIMP_IS_COLOR_PANEL(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_COLOR_PANEL)) #define GIMP_IS_COLOR_PANEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_PANEL)) + typedef struct _GimpColorPanel GimpColorPanel; typedef struct _GimpColorPanelClass GimpColorPanelClass; @@ -45,4 +46,4 @@ GtkWidget * gimp_color_panel_new (const gchar *title, gint height); -#endif /* __COLOR_PANEL_H__ */ +#endif /* __GIMP_COLOR_PANEL_H__ */ diff --git a/app/widgets/gimpdeviceinfo.c b/app/widgets/gimpdeviceinfo.c index a4abfbef48..4089368eb9 100644 --- a/app/widgets/gimpdeviceinfo.c +++ b/app/widgets/gimpdeviceinfo.c @@ -31,6 +31,8 @@ #include "tools/gimptoolinfo.h" #include "tools/tool_manager.h" +#include "widgets/gimppreview.h" + #include "appenv.h" #include "context_manager.h" #include "devices.h" @@ -41,7 +43,6 @@ #include "gimpdnd.h" #include "gimpgradient.h" #include "gimppattern.h" -#include "gimppreview.h" #include "gimplist.h" #include "gimprc.h" #include "session.h" diff --git a/app/widgets/gimpdevices.c b/app/widgets/gimpdevices.c index a4abfbef48..4089368eb9 100644 --- a/app/widgets/gimpdevices.c +++ b/app/widgets/gimpdevices.c @@ -31,6 +31,8 @@ #include "tools/gimptoolinfo.h" #include "tools/tool_manager.h" +#include "widgets/gimppreview.h" + #include "appenv.h" #include "context_manager.h" #include "devices.h" @@ -41,7 +43,6 @@ #include "gimpdnd.h" #include "gimpgradient.h" #include "gimppattern.h" -#include "gimppreview.h" #include "gimplist.h" #include "gimprc.h" #include "session.h" diff --git a/app/widgets/gimpdnd.c b/app/widgets/gimpdnd.c index bf188aa1bd..b76dd09dab 100644 --- a/app/widgets/gimpdnd.c +++ b/app/widgets/gimpdnd.c @@ -32,6 +32,8 @@ #include "tools/gimptoolinfo.h" #include "tools/tool_manager.h" +#include "widgets/gimppreview.h" + #include "context_manager.h" #include "file-open.h" #include "gimpimage.h" @@ -46,7 +48,6 @@ #include "gimplayermask.h" #include "gimppalette.h" #include "gimppattern.h" -#include "gimppreview.h" #include "gimprc.h" #include "temp_buf.h" diff --git a/app/widgets/gimpgradienteditor.c b/app/widgets/gimpgradienteditor.c index 011cbad308..a1317aa52e 100644 --- a/app/widgets/gimpgradienteditor.c +++ b/app/widgets/gimpgradienteditor.c @@ -63,13 +63,14 @@ #include "apptypes.h" +#include "widgets/gimpcontainerlistview.h" + #include "color_notebook.h" #include "context_manager.h" #include "cursorutil.h" #include "datafiles.h" #include "errors.h" #include "gimpcontainer.h" -#include "gimpcontainerlistview.h" #include "gimpcontext.h" #include "gimpdatafactory.h" #include "gimpdnd.h" diff --git a/app/widgets/gimphistogramview.c b/app/widgets/gimphistogramview.c index 6c81f41767..16b8cb3a31 100644 --- a/app/widgets/gimphistogramview.c +++ b/app/widgets/gimphistogramview.c @@ -24,10 +24,11 @@ #include "apptypes.h" +#include "gimphistogramview.h" + #include "gimage.h" #include "gimage_mask.h" #include "gimphistogram.h" -#include "histogramwidget.h" #include "tile_manager.h" diff --git a/app/widgets/gimppaletteeditor.c b/app/widgets/gimppaletteeditor.c index aebdcb202a..14196f1c45 100644 --- a/app/widgets/gimppaletteeditor.c +++ b/app/widgets/gimppaletteeditor.c @@ -25,19 +25,20 @@ #include "apptypes.h" +#include "widgets/gimpcontainerlistview.h" +#include "widgets/gimpdatafactoryview.h" +#include "widgets/gimppreview.h" + #include "color_area.h" #include "color_notebook.h" #include "context_manager.h" #include "dialog_handler.h" #include "gimage.h" -#include "gimpcontainerlistview.h" #include "gimpcontext.h" #include "gimpdatafactory.h" -#include "gimpdatafactoryview.h" #include "gimpdatalist.h" #include "gimpdnd.h" #include "gimppalette.h" -#include "gimppreview.h" #include "gimprc.h" #include "palette.h" #include "palette_import.h" diff --git a/app/widgets/gimptoolbox-indicator-area.c b/app/widgets/gimptoolbox-indicator-area.c index eb1615213a..d587f18238 100644 --- a/app/widgets/gimptoolbox-indicator-area.c +++ b/app/widgets/gimptoolbox-indicator-area.c @@ -27,12 +27,13 @@ #include "apptypes.h" +#include "widgets/gimppreview.h" + #include "brush_select.h" #include "gimpbrush.h" #include "gimpcontext.h" #include "gimpgradient.h" #include "gimppattern.h" -#include "gimppreview.h" #include "gimpdnd.h" #include "gradient_select.h" #include "indicator_area.h" diff --git a/app/widgets/gimptoolbox.c b/app/widgets/gimptoolbox.c index b0eebd74c2..525d4273f0 100644 --- a/app/widgets/gimptoolbox.c +++ b/app/widgets/gimptoolbox.c @@ -32,6 +32,9 @@ #include "tools/tool_options_dialog.h" #include "tools/tool_manager.h" +#include "widgets/gimppreview.h" +#include "widgets/gtkhwrapbox.h" + #include "app_procs.h" #include "color_area.h" #include "devices.h" @@ -42,9 +45,7 @@ #include "gimpdnd.h" #include "gimplayer.h" #include "gimplist.h" -#include "gimppreview.h" #include "gimprc.h" -#include "gtkhwrapbox.h" #include "indicator_area.h" #include "menus.h" #include "session.h" diff --git a/app/widgets/gimptooloptionseditor.c b/app/widgets/gimptooloptionseditor.c index ca5018d35c..c85131af5c 100644 --- a/app/widgets/gimptooloptionseditor.c +++ b/app/widgets/gimptooloptionseditor.c @@ -24,11 +24,12 @@ #include "apptypes.h" +#include "widgets/gimppreview.h" + #include "dialog_handler.h" #include "gimpcontext.h" #include "gimpdnd.h" #include "gimplist.h" -#include "gimppreview.h" #include "gimpui.h" #include "session.h" diff --git a/configure.in b/configure.in index 85605544fe..4f136a0c7d 100644 --- a/configure.in +++ b/configure.in @@ -785,6 +785,7 @@ app/makefile.mingw app/paint-funcs/Makefile app/pdb/Makefile app/tools/Makefile +app/widgets/Makefile plug-ins/Makefile plug-ins/makefile.mingw plug-ins/perl/config.pl diff --git a/po-plug-ins/ChangeLog b/po-plug-ins/ChangeLog index 89386831ff..ba8d693a5b 100644 --- a/po-plug-ins/ChangeLog +++ b/po-plug-ins/ChangeLog @@ -1,3 +1,7 @@ +2001-04-11 Michael Natterer + + * ja.po: fixed invalid multibyte sequences. + 2001-04-09 Stanislav Brabec * cs.po: Updated translation. diff --git a/po-plug-ins/ja.po b/po-plug-ins/ja.po index a568399725..22d5e94978 100644 --- a/po-plug-ins/ja.po +++ b/po-plug-ins/ja.po @@ -5373,10 +5373,7 @@ msgstr " msgid "" "When toggled, the resulting image will be scaled to fit into the given size " "without changing the aspect ratio." -msgstr "" -"¥Á¥§¥Ã¥¯¤òÆþ¤ì¤ë¤È, " -"²èÁü¤Ï¥¢¥¹¥Ú¥¯¥È¥ëÈæ¤òÊѹ¹¤»¤º¤ËÍ¿¤¨¤é¤ì¤¿¥µ¥¤¥º¤Ë¹ç¤¦¤è¤¦¤ËÄ´À°¤µ¤ì¤Æ½ÐÎϤµ¤" -"ì¤Þ¤¹." +msgstr "¥Á¥§¥Ã¥¯¤òÆþ¤ì¤ë¤È, ²èÁü¤Ï¥¢¥¹¥Ú¥¯¥È¥ëÈæ¤òÊѹ¹¤»¤º¤ËÍ¿¤¨¤é¤ì¤¿¥µ¥¤¥º¤Ë¹ç¤¦¤è¤¦¤ËÄ´À°¤µ¤ì¤Æ½ÐÎϤµ¤ì¤Þ¤¹." #. Unit #: plug-ins/common/ps.c:2883 @@ -11605,13 +11602,7 @@ msgid "" "this topic has not been written yet or that something is wrong with your " "installation. Please check carefully before you report this as a " "bug." -msgstr "" -"¥Ç¥£¥ì¥¯¥È¥ê¤¬¸«ÉÕ¤«¤ê¤Þ¤»¤ó

%s

¥Ç¥£¥ì¥¯¥È¥ê

%s

¤ËÊѤ¨¤é" -"¤ì¤Þ¤»¤ó.

¤³¤ì¤Ï¥Õ¥¡¥¤¥ë

%s

¤Ë¥¢¥¯¥»¥¹¤·¤è¤¦¤È¤·¤ÆȯÀ" -"¸¤·¤Þ¤·¤¿

¤³¤ÎÏÃÂê¤Î¤¿¤á¤Î¥Ø¥ë¥×¤¬¤Þ¤À½ñ¤«¤ì¤Æ¤¤¤Ê¤¤¤«" -"¤¢¤Ê¤¿¤Î¥¤¥ó¥¹¥È¡¼¥ë¤Î¤É¤³¤«¤¬´Ö°ã¤Ã¤Æ¤¤¤Þ¤¹. " -"¤¢¤Ê¤¿¤¬¤³¤ì¤ò¥Ð¥°¤È¤·¤ÆÊó¹ð¤¹¤ëÁ°¤Ë¿µ½Å¤ËÄ´¤Ù¤Æ²¼¤µ¤¤" +msgstr "¥Ç¥£¥ì¥¯¥È¥ê¤¬¸«ÉÕ¤«¤ê¤Þ¤»¤ó

%s

¥Ç¥£¥ì¥¯¥È¥ê

%s

¤ËÊѤ¨¤é¤ì¤Þ¤»¤ó.

¤³¤ì¤Ï¥Õ¥¡¥¤¥ë

%s

¤Ë¥¢¥¯¥»¥¹¤·¤è¤¦¤È¤·¤ÆȯÀ¸¤·¤Þ¤·¤¿

¤³¤ÎÏÃÂê¤Î¤¿¤á¤Î¥Ø¥ë¥×¤¬¤Þ¤À½ñ¤«¤ì¤Æ¤¤¤Ê¤¤¤«¤¢¤Ê¤¿¤Î¥¤¥ó¥¹¥È¡¼¥ë¤Î¤É¤³¤«¤¬´Ö°ã¤Ã¤Æ¤¤¤Þ¤¹. ¤¢¤Ê¤¿¤¬¤³¤ì¤ò¥Ð¥°¤È¤·¤ÆÊó¹ð¤¹¤ëÁ°¤Ë¿µ½Å¤ËÄ´¤Ù¤Æ²¼¤µ¤¤" #: plug-ins/helpbrowser/helpbrowser.c:137 msgid "Contents" diff --git a/tools/pdbgen/pdb/color.pdb b/tools/pdbgen/pdb/color.pdb index b22fbf3544..fb7f81f880 100644 --- a/tools/pdbgen/pdb/color.pdb +++ b/tools/pdbgen/pdb/color.pdb @@ -761,7 +761,7 @@ CODE ); } -@headers = qw("histogramwidget.h" "gimpimage.h" "gimpdrawable.h" "gimphistogram.h" "gimplut.h" +@headers = qw("widgets/gimphistogramview.h" "gimpimage.h" "gimpdrawable.h" "gimphistogram.h" "gimplut.h" "lut_funcs.h" "pixel_region.h" "pixel_processor.h"); @procs = qw(brightness_contrast levels posterize desaturate equalize invert