From a4be816fa6ca4df82ef7cfa35363c9366ddccdfc Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sat, 12 Apr 2003 20:02:16 +0000 Subject: [PATCH] app/widgets/gimpcontainerpopup.[ch] added "preview_size" and 2003-04-12 Michael Natterer * app/widgets/gimpcontainerpopup.[ch] * app/widgets/gimpviewablebutton.[ch]: added "preview_size" and "preview_border_width" parameters to the constructors and use them when creating the popup. * app/tools/gimptextoptions.c * app/tools/paint_options.c * app/widgets/gimptemplateeditor.c: changed accordingly. Create the icon popup without borders. --- ChangeLog | 12 ++++++++++++ app/tools/gimppaintoptions-gui.c | 9 ++++++--- app/tools/gimptextoptions.c | 3 ++- app/tools/paint_options.c | 9 ++++++--- app/widgets/gimpcontainerpopup.c | 31 +++++++++++++++++++++++++------ app/widgets/gimpcontainerpopup.h | 5 +++++ app/widgets/gimptemplateeditor.c | 2 +- app/widgets/gimpviewablebutton.c | 12 ++++++++++++ app/widgets/gimpviewablebutton.h | 4 ++++ 9 files changed, 73 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7edc6f0218..55c92738c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2003-04-12 Michael Natterer + + * app/widgets/gimpcontainerpopup.[ch] + * app/widgets/gimpviewablebutton.[ch]: added "preview_size" and + "preview_border_width" parameters to the constructors and use them + when creating the popup. + + * app/tools/gimptextoptions.c + * app/tools/paint_options.c + * app/widgets/gimptemplateeditor.c: changed accordingly. Create the + icon popup without borders. + 2003-04-12 Michael Natterer * app/config/gimpconfig-params.h: made object properties diff --git a/app/tools/gimppaintoptions-gui.c b/app/tools/gimppaintoptions-gui.c index 67dc5bbb85..a22af11ac5 100644 --- a/app/tools/gimppaintoptions-gui.c +++ b/app/tools/gimppaintoptions-gui.c @@ -127,7 +127,8 @@ gimp_paint_options_gui (GimpToolOptions *tool_options) tool_options->tool_info->tool_type != GIMP_TYPE_INK_TOOL) { button = gimp_viewable_button_new (context->gimp->brush_factory->container, - context, 24, + context, + GIMP_PREVIEW_SIZE_SMALL, 1, dialog_factory, "gimp-brush-grid", GIMP_STOCK_TOOL_PAINTBRUSH, @@ -143,7 +144,8 @@ gimp_paint_options_gui (GimpToolOptions *tool_options) tool_options->tool_info->tool_type == GIMP_TYPE_CLONE_TOOL) { button = gimp_viewable_button_new (context->gimp->pattern_factory->container, - context, 24, + context, + GIMP_PREVIEW_SIZE_SMALL, 1, dialog_factory, "gimp-pattern-grid", GIMP_STOCK_TOOL_BUCKET_FILL, @@ -158,7 +160,8 @@ gimp_paint_options_gui (GimpToolOptions *tool_options) if (tool_options->tool_info->tool_type == GIMP_TYPE_BLEND_TOOL) { button = gimp_viewable_button_new (context->gimp->gradient_factory->container, - context, 32, + context, + GIMP_PREVIEW_SIZE_SMALL * 2, 1, dialog_factory, "gimp-gradient-list", GIMP_STOCK_TOOL_BLEND, diff --git a/app/tools/gimptextoptions.c b/app/tools/gimptextoptions.c index 8fbce7b667..b7edd7ef77 100644 --- a/app/tools/gimptextoptions.c +++ b/app/tools/gimptextoptions.c @@ -259,7 +259,8 @@ gimp_text_options_gui (GimpToolOptions *tool_options) gtk_widget_show (table); button = gimp_viewable_button_new (GIMP_CONTEXT (options)->gimp->fonts, - GIMP_CONTEXT (options), 24, + GIMP_CONTEXT (options), + GIMP_PREVIEW_SIZE_SMALL, 1, dialog_factory, "gimp-font-list", GIMP_STOCK_TOOL_TEXT, diff --git a/app/tools/paint_options.c b/app/tools/paint_options.c index 67dc5bbb85..a22af11ac5 100644 --- a/app/tools/paint_options.c +++ b/app/tools/paint_options.c @@ -127,7 +127,8 @@ gimp_paint_options_gui (GimpToolOptions *tool_options) tool_options->tool_info->tool_type != GIMP_TYPE_INK_TOOL) { button = gimp_viewable_button_new (context->gimp->brush_factory->container, - context, 24, + context, + GIMP_PREVIEW_SIZE_SMALL, 1, dialog_factory, "gimp-brush-grid", GIMP_STOCK_TOOL_PAINTBRUSH, @@ -143,7 +144,8 @@ gimp_paint_options_gui (GimpToolOptions *tool_options) tool_options->tool_info->tool_type == GIMP_TYPE_CLONE_TOOL) { button = gimp_viewable_button_new (context->gimp->pattern_factory->container, - context, 24, + context, + GIMP_PREVIEW_SIZE_SMALL, 1, dialog_factory, "gimp-pattern-grid", GIMP_STOCK_TOOL_BUCKET_FILL, @@ -158,7 +160,8 @@ gimp_paint_options_gui (GimpToolOptions *tool_options) if (tool_options->tool_info->tool_type == GIMP_TYPE_BLEND_TOOL) { button = gimp_viewable_button_new (context->gimp->gradient_factory->container, - context, 32, + context, + GIMP_PREVIEW_SIZE_SMALL * 2, 1, dialog_factory, "gimp-gradient-list", GIMP_STOCK_TOOL_BLEND, diff --git a/app/widgets/gimpcontainerpopup.c b/app/widgets/gimpcontainerpopup.c index 84c93e87e5..b433e1a7a8 100644 --- a/app/widgets/gimpcontainerpopup.c +++ b/app/widgets/gimpcontainerpopup.c @@ -31,13 +31,14 @@ #include "core/gimpcontext.h" #include "core/gimpcontainer.h" #include "core/gimpmarshal.h" +#include "core/gimpviewable.h" #include "gimpcontainereditor.h" #include "gimpcontainerpopup.h" #include "gimpcontainergridview.h" #include "gimpcontainertreeview.h" #include "gimpdialogfactory.h" -#include "gimppreview.h" +#include "gimppreviewrenderer.h" #include "gimp-intl.h" @@ -162,6 +163,9 @@ gimp_container_popup_class_init (GimpContainerPopupClass *klass) static void gimp_container_popup_init (GimpContainerPopup *popup) { + popup->preview_size = GIMP_PREVIEW_SIZE_SMALL; + popup->preview_border_width = 1; + popup->frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (popup->frame), GTK_SHADOW_OUT); gtk_container_add (GTK_CONTAINER (popup), popup->frame); @@ -356,6 +360,8 @@ gimp_container_popup_context_changed (GimpContext *context, GtkWidget * gimp_container_popup_new (GimpContainer *container, GimpContext *context, + gint preview_size, + gint preview_border_width, GimpDialogFactory *dialog_factory, const gchar *dialog_identifier, const gchar *dialog_stock_id, @@ -365,6 +371,11 @@ gimp_container_popup_new (GimpContainer *container, g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL); g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); + g_return_val_if_fail (preview_size > 0 && + preview_size <= GIMP_VIEWABLE_MAX_POPUP_SIZE, NULL); + g_return_val_if_fail (preview_border_width >= 0 && + preview_border_width <= GIMP_PREVIEW_MAX_BORDER_WIDTH, + NULL); g_return_val_if_fail (dialog_factory == NULL || GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL); if (dialog_factory) @@ -383,6 +394,9 @@ gimp_container_popup_new (GimpContainer *container, popup->orig_context = context; popup->context = gimp_context_new (context->gimp, "popup", context); + popup->preview_size = preview_size; + popup->preview_border_width = preview_border_width; + g_signal_connect (popup->context, gimp_context_type_to_signal_name (container->children_type), G_CALLBACK (gimp_container_popup_context_changed), @@ -454,13 +468,16 @@ gimp_container_popup_create_view (GimpContainerPopup *popup, view_type, popup->container, popup->context, - GIMP_PREVIEW_SIZE_SMALL, 1, + popup->preview_size, + popup->preview_border_width, FALSE, /* reorderable */ NULL, NULL); gimp_container_view_set_size_request (GIMP_CONTAINER_VIEW (GIMP_CONTAINER_EDITOR (popup->editor)->view), - 6 * (GIMP_PREVIEW_SIZE_SMALL + 2), - 8 * (GIMP_PREVIEW_SIZE_SMALL + 2)); + 6 * (popup->preview_size + + 2 * popup->preview_border_width), + 10 * (popup->preview_size + + 2 * popup->preview_border_width)); if (GIMP_IS_CONTAINER_GRID_VIEW (popup->editor->view)) gtk_widget_hide (GIMP_CONTAINER_GRID_VIEW (popup->editor->view)->name_label); @@ -507,7 +524,8 @@ gimp_container_popup_smaller_clicked (GtkWidget *button, popup->editor->view->preview_size * 0.8); gimp_container_view_set_preview_size (popup->editor->view, - preview_size, 1); + preview_size, + popup->preview_border_width); } static void @@ -520,7 +538,8 @@ gimp_container_popup_larger_clicked (GtkWidget *button, popup->editor->view->preview_size * 1.2); gimp_container_view_set_preview_size (popup->editor->view, - preview_size, 1); + preview_size, + popup->preview_border_width); } static void diff --git a/app/widgets/gimpcontainerpopup.h b/app/widgets/gimpcontainerpopup.h index 35c700ab61..5838afa522 100644 --- a/app/widgets/gimpcontainerpopup.h +++ b/app/widgets/gimpcontainerpopup.h @@ -44,6 +44,9 @@ struct _GimpContainerPopup GimpContext *orig_context; GimpContext *context; + gint preview_size; + gint preview_border_width; + GtkWidget *frame; GimpContainerEditor *editor; @@ -66,6 +69,8 @@ GType gimp_container_popup_get_type (void) G_GNUC_CONST; GtkWidget * gimp_container_popup_new (GimpContainer *container, GimpContext *context, + gint preview_size, + gint preview_border_width, GimpDialogFactory *dialog_factory, const gchar *dialog_identifier, const gchar *dialog_stock_id, diff --git a/app/widgets/gimptemplateeditor.c b/app/widgets/gimptemplateeditor.c index 6b4c30204e..b0265b8158 100644 --- a/app/widgets/gimptemplateeditor.c +++ b/app/widgets/gimptemplateeditor.c @@ -419,7 +419,7 @@ gimp_template_editor_new (Gimp *gimp, button = gimp_viewable_button_new (editor->stock_id_container, editor->stock_id_context, - GIMP_PREVIEW_SIZE_SMALL, + GIMP_PREVIEW_SIZE_SMALL, 0, NULL, NULL, NULL, NULL); gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, diff --git a/app/widgets/gimpviewablebutton.c b/app/widgets/gimpviewablebutton.c index e2c35352af..74b387bd79 100644 --- a/app/widgets/gimpviewablebutton.c +++ b/app/widgets/gimpviewablebutton.c @@ -34,6 +34,7 @@ #include "gimpcontainerpopup.h" #include "gimpdialogfactory.h" #include "gimppropwidgets.h" +#include "gimppreviewrenderer.h" #include "gimpviewablebutton.h" #include "gimp-intl.h" @@ -99,6 +100,8 @@ gimp_viewable_button_class_init (GimpViewableButtonClass *klass) static void gimp_viewable_button_init (GimpViewableButton *button) { + button->preview_size = GIMP_PREVIEW_SIZE_SMALL; + button->preview_border_width = 1; } static void @@ -191,6 +194,8 @@ gimp_viewable_button_clicked (GtkButton *button) popup = gimp_container_popup_new (viewable_button->container, viewable_button->context, + viewable_button->preview_size, + viewable_button->preview_border_width, viewable_button->dialog_factory, viewable_button->dialog_identifier, viewable_button->dialog_stock_id, @@ -202,6 +207,7 @@ GtkWidget * gimp_viewable_button_new (GimpContainer *container, GimpContext *context, gint preview_size, + gint preview_border_width, GimpDialogFactory *dialog_factory, const gchar *dialog_identifier, const gchar *dialog_stock_id, @@ -214,6 +220,9 @@ gimp_viewable_button_new (GimpContainer *container, g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); g_return_val_if_fail (preview_size > 0 && preview_size <= GIMP_VIEWABLE_MAX_POPUP_SIZE, NULL); + g_return_val_if_fail (preview_border_width >= 0 && + preview_border_width <= GIMP_PREVIEW_MAX_BORDER_WIDTH, + NULL); g_return_val_if_fail (dialog_factory == NULL || GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL); if (dialog_factory) @@ -228,6 +237,9 @@ gimp_viewable_button_new (GimpContainer *container, button->container = container; button->context = context; + button->preview_size = preview_size; + button->preview_border_width = preview_border_width; + if (dialog_factory) { button->dialog_factory = dialog_factory; diff --git a/app/widgets/gimpviewablebutton.h b/app/widgets/gimpviewablebutton.h index 514bad57cb..64ea4ed3e5 100644 --- a/app/widgets/gimpviewablebutton.h +++ b/app/widgets/gimpviewablebutton.h @@ -43,6 +43,9 @@ struct _GimpViewableButton GimpContainer *container; GimpContext *context; + gint preview_size; + gint preview_border_width; + GimpDialogFactory *dialog_factory; gchar *dialog_identifier; gchar *dialog_stock_id; @@ -62,6 +65,7 @@ GType gimp_viewable_button_get_type (void) G_GNUC_CONST; GtkWidget * gimp_viewable_button_new (GimpContainer *container, GimpContext *context, gint preview_size, + gint preview_border_width, GimpDialogFactory *dialog_factory, const gchar *dialog_identifier, const gchar *dialog_stock_id,