added the scrolled_win to the GimpContainerView struct. Create it in

2003-03-26  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpcontainerview.[ch]: added the scrolled_win
	to the GimpContainerView struct. Create it in init().
	Added gimp_container_view_set_size_request() which adds the
	scrolled_window's scrollbar and frames sizes correctly.

	* app/widgets/gimpcontainergridview.[ch]
	* app/widgets/gimpcontainertreeview.[ch]: removed scrolled windows
	here and use the one from the parent_instance. Use the new utility
	function.

	* app/widgets/gimpcontainertreeview.c: enable searching in the
	name column. Grab the focus in button_press.

	* app/widgets/gimpcontainerpopup.[ch]: added a button_box containing
	zoom in/out, view as list/grid and a button to show the permanently
	open dialog. Added more parameters to gimp_container_popup_new().

	* app/tools/gimpblendoptions.c
	* app/tools/gimpbucketfilloptions.c
	* app/tools/gimptextoptions.c
	* app/tools/paint_options.c: changed accordingly.
This commit is contained in:
Michael Natterer 2003-03-26 14:56:10 +00:00 committed by Michael Natterer
parent 1e92b66b5b
commit af37e71b80
14 changed files with 352 additions and 104 deletions

View File

@ -1,3 +1,27 @@
2003-03-26 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpcontainerview.[ch]: added the scrolled_win
to the GimpContainerView struct. Create it in init().
Added gimp_container_view_set_size_request() which adds the
scrolled_window's scrollbar and frames sizes correctly.
* app/widgets/gimpcontainergridview.[ch]
* app/widgets/gimpcontainertreeview.[ch]: removed scrolled windows
here and use the one from the parent_instance. Use the new utility
function.
* app/widgets/gimpcontainertreeview.c: enable searching in the
name column. Grab the focus in button_press.
* app/widgets/gimpcontainerpopup.[ch]: added a button_box containing
zoom in/out, view as list/grid and a button to show the permanently
open dialog. Added more parameters to gimp_container_popup_new().
* app/tools/gimpblendoptions.c
* app/tools/gimpbucketfilloptions.c
* app/tools/gimptextoptions.c
* app/tools/paint_options.c: changed accordingly.
2003-03-26 Sven Neumann <sven@gimp.org>
* app/gui/tool-options-dialog.c (tool_options_dialog_restore_callback):

View File

@ -31,6 +31,7 @@
#include "core/gimptoolinfo.h"
#include "widgets/gimpcontainerpopup.h"
#include "widgets/gimpdock.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimppropwidgets.h"
@ -322,10 +323,17 @@ static void
blend_options_gradient_clicked (GtkWidget *widget,
GimpContext *context)
{
GtkWidget *toplevel;
GtkWidget *popup;
toplevel = gtk_widget_get_toplevel (widget);
popup = gimp_container_popup_new (context->gimp->gradient_factory->container,
context);
context,
GIMP_DOCK (toplevel)->dialog_factory,
"gimp-gradient-list",
GIMP_STOCK_TOOL_BLEND,
_("Open the gradient selection dialog"));
gimp_container_popup_show (GIMP_CONTAINER_POPUP (popup), widget);
}

View File

@ -34,6 +34,7 @@
#include "display/gimpdisplay.h"
#include "widgets/gimpcontainerpopup.h"
#include "widgets/gimpdock.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gimpwidgets-utils.h"
@ -69,9 +70,6 @@ static void gimp_bucket_fill_options_reset (GimpToolOptions *tool_optio
static void bucket_options_pattern_clicked (GtkWidget *widget,
GimpContext *context);
static void bucket_options_fill_mode_notify (GimpBucketFillOptions *options,
GParamSpec *pspec,
GtkWidget *button);
static GimpPaintOptionsClass *parent_class = NULL;
@ -265,10 +263,6 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
g_signal_connect (config, "notify::fill-mode",
G_CALLBACK (bucket_options_fill_mode_notify),
button);
frame = gtk_frame_new (_("Finding Similar Colors"));
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
@ -311,18 +305,16 @@ static void
bucket_options_pattern_clicked (GtkWidget *widget,
GimpContext *context)
{
GtkWidget *toplevel;
GtkWidget *popup;
toplevel = gtk_widget_get_toplevel (widget);
popup = gimp_container_popup_new (context->gimp->pattern_factory->container,
context);
context,
GIMP_DOCK (toplevel)->dialog_factory,
"gimp-pattern-grid",
GIMP_STOCK_TOOL_BUCKET_FILL,
_("Open the pattern selection dialog"));
gimp_container_popup_show (GIMP_CONTAINER_POPUP (popup), widget);
}
static void
bucket_options_fill_mode_notify (GimpBucketFillOptions *options,
GParamSpec *pspec,
GtkWidget *button)
{
gtk_widget_set_sensitive (button,
options->fill_mode == GIMP_PATTERN_BUCKET_FILL);
}

View File

@ -35,6 +35,7 @@
#include "widgets/gimpcontainerpopup.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdock.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gtkhwrapbox.h"
@ -410,9 +411,16 @@ static void
paint_options_brush_clicked (GtkWidget *widget,
GimpContext *context)
{
GtkWidget *toplevel;
GtkWidget *popup;
toplevel = gtk_widget_get_toplevel (widget);
popup = gimp_container_popup_new (context->gimp->brush_factory->container,
context);
context,
GIMP_DOCK (toplevel)->dialog_factory,
"gimp-brush-grid",
GIMP_STOCK_TOOL_PAINTBRUSH,
_("Open the brush selection dialog"));
gimp_container_popup_show (GIMP_CONTAINER_POPUP (popup), widget);
}

View File

@ -37,6 +37,7 @@
#include "widgets/gimpcolorpanel.h"
#include "widgets/gimpcontainerpopup.h"
#include "widgets/gimpdock.h"
#include "widgets/gimpfontselection.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gimptexteditor.h"
@ -299,9 +300,15 @@ static void
gimp_text_options_font_clicked (GtkWidget *widget,
GimpContext *context)
{
GtkWidget *toplevel;
GtkWidget *popup;
popup = gimp_container_popup_new (context->gimp->fonts, context);
toplevel = gtk_widget_get_toplevel (widget);
popup = gimp_container_popup_new (context->gimp->fonts, context,
GIMP_DOCK (toplevel)->dialog_factory,
"gimp-font-list",
GTK_STOCK_SELECT_FONT,
_("Open the font selection dialog"));
gimp_container_popup_show (GIMP_CONTAINER_POPUP (popup), widget);
}

View File

@ -35,6 +35,7 @@
#include "widgets/gimpcontainerpopup.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimpdock.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gtkhwrapbox.h"
@ -410,9 +411,16 @@ static void
paint_options_brush_clicked (GtkWidget *widget,
GimpContext *context)
{
GtkWidget *toplevel;
GtkWidget *popup;
toplevel = gtk_widget_get_toplevel (widget);
popup = gimp_container_popup_new (context->gimp->brush_factory->container,
context);
context,
GIMP_DOCK (toplevel)->dialog_factory,
"gimp-brush-grid",
GIMP_STOCK_TOOL_PAINTBRUSH,
_("Open the brush selection dialog"));
gimp_container_popup_show (GIMP_CONTAINER_POPUP (popup), widget);
}

View File

@ -131,29 +131,27 @@ gimp_container_grid_view_class_init (GimpContainerGridViewClass *klass)
static void
gimp_container_grid_view_init (GimpContainerGridView *grid_view)
{
GimpContainerView *view;
view = GIMP_CONTAINER_VIEW (grid_view);
grid_view->rows = 1;
grid_view->columns = 1;
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (view->scrolled_win),
GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
grid_view->name_label = gtk_label_new (_("(None)"));
gtk_misc_set_alignment (GTK_MISC (grid_view->name_label), 0.0, 0.5);
gtk_misc_set_padding (GTK_MISC (grid_view->name_label),
grid_view->name_label->style->xthickness, 0);
gtk_box_pack_start (GTK_BOX (grid_view), grid_view->name_label,
FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (grid_view), grid_view->name_label, 0);
gtk_widget_show (grid_view->name_label);
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);
gtk_widget_show (grid_view->scrolled_win);
GIMP_CONTAINER_VIEW (grid_view)->dnd_widget = grid_view->scrolled_win;
grid_view->wrap_box = gtk_hwrap_box_new (FALSE);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (grid_view->scrolled_win),
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (view->scrolled_win),
grid_view->wrap_box);
gtk_widget_show (grid_view->wrap_box);
@ -164,11 +162,7 @@ gimp_container_grid_view_init (GimpContainerGridView *grid_view)
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);
(view->scrolled_win)));
GTK_WIDGET_SET_FLAGS (grid_view->wrap_box->parent, GTK_CAN_FOCUS);
}
@ -183,10 +177,10 @@ gimp_container_grid_view_new (GimpContainer *container,
{
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 (container == NULL || GIMP_IS_CONTAINER (container),
NULL);
g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (preview_size > 0 &&
preview_size <= GIMP_PREVIEW_MAX_SIZE, NULL);
g_return_val_if_fail (min_items_x > 0 && min_items_x <= 64, NULL);
@ -199,19 +193,15 @@ gimp_container_grid_view_new (GimpContainer *container,
view->preview_size = preview_size;
view->reorderable = reorderable ? TRUE : FALSE;
window_border =
GTK_SCROLLED_WINDOW (grid_view->scrolled_win)->vscrollbar->requisition.width +
GTK_SCROLLED_WINDOW_GET_CLASS (grid_view->scrolled_win)->scrollbar_spacing +
grid_view->scrolled_win->style->xthickness * 4;
gtk_widget_set_size_request (grid_view->scrolled_win,
(preview_size + 2) * min_items_x + window_border,
(preview_size + 2) * min_items_y + window_border);
gimp_container_view_set_size_request (view,
(preview_size + 2) * min_items_x,
(preview_size + 2) * min_items_y);
if (container)
gimp_container_view_set_container (view, container);
gimp_container_view_set_context (view, context);
if (context)
gimp_container_view_set_context (view, context);
return GTK_WIDGET (grid_view);
}
@ -245,11 +235,9 @@ gimp_container_grid_view_insert_item (GimpContainerView *view,
g_signal_connect (preview, "clicked",
G_CALLBACK (gimp_container_grid_view_item_selected),
view);
g_signal_connect (preview, "double_clicked",
G_CALLBACK (gimp_container_grid_view_item_activated),
view);
g_signal_connect (preview, "context",
G_CALLBACK (gimp_container_grid_view_item_context),
view);
@ -271,9 +259,7 @@ gimp_container_grid_view_remove_item (GimpContainerView *view,
if (preview)
{
if (g_object_get_data (G_OBJECT (view), "last_selected_item") == preview)
{
g_object_set_data (G_OBJECT (view), "last_selected_item", NULL);
}
g_object_set_data (G_OBJECT (view), "last_selected_item", NULL);
gtk_container_remove (GTK_CONTAINER (grid_view->wrap_box), preview);
}
@ -397,7 +383,7 @@ gimp_container_grid_view_highlight_item (GimpContainerView *view,
gint row;
adj = gtk_scrolled_window_get_vadjustment
(GTK_SCROLLED_WINDOW (grid_view->scrolled_win));
(GTK_SCROLLED_WINDOW (view->scrolled_win));
item_height = GTK_WIDGET (preview)->allocation.height;

View File

@ -41,8 +41,6 @@ struct _GimpContainerGridView
GimpContainerView parent_instance;
GtkWidget *name_label;
GtkWidget *scrolled_win;
GtkWidget *wrap_box;
gint rows;

View File

@ -34,8 +34,12 @@
#include "gimpcontainereditor.h"
#include "gimpcontainerpopup.h"
#include "gimpcontainergridview.h"
#include "gimpdialogfactory.h"
#include "gimppreview.h"
#include "gimp-intl.h"
enum
{
@ -57,6 +61,20 @@ static gboolean gimp_container_popup_key_press (GtkWidget *widget,
static void gimp_container_popup_real_cancel (GimpContainerPopup *popup);
static void gimp_container_popup_real_confirm (GimpContainerPopup *popup);
static void gimp_container_popup_create_view (GimpContainerPopup *popup,
GimpViewType view_type);
static void gimp_container_popup_smaller_clicked (GtkWidget *button,
GimpContainerPopup *popup);
static void gimp_container_popup_larger_clicked (GtkWidget *button,
GimpContainerPopup *popup);
static void gimp_container_popup_list_clicked (GtkWidget *button,
GimpContainerPopup *popup);
static void gimp_container_popup_grid_clicked (GtkWidget *button,
GimpContainerPopup *popup);
static void gimp_container_popup_dialog_clicked (GtkWidget *button,
GimpContainerPopup *popup);
static GtkWindowClass *parent_class = NULL;
@ -145,7 +163,10 @@ gimp_container_popup_class_init (GimpContainerPopupClass *klass)
static void
gimp_container_popup_init (GimpContainerPopup *popup)
{
popup->editor = NULL;
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);
gtk_widget_show (popup->frame);
}
static void
@ -161,6 +182,24 @@ gimp_container_popup_finalize (GObject *object)
popup->context = NULL;
}
if (popup->dialog_identifier)
{
g_free (popup->dialog_identifier);
popup->dialog_identifier = NULL;
}
if (popup->dialog_stock_id)
{
g_free (popup->dialog_stock_id);
popup->dialog_stock_id = NULL;
}
if (popup->dialog_tooltip)
{
g_free (popup->dialog_tooltip);
popup->dialog_tooltip = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@ -304,7 +343,8 @@ gimp_container_popup_context_changed (GimpContext *context,
if (current_event)
{
if (((GdkEventAny *) current_event)->type == GDK_BUTTON_PRESS)
if (((GdkEventAny *) current_event)->type == GDK_BUTTON_PRESS ||
((GdkEventAny *) current_event)->type == GDK_BUTTON_RELEASE)
confirm = TRUE;
gdk_event_free (current_event);
@ -315,15 +355,25 @@ gimp_container_popup_context_changed (GimpContext *context,
}
GtkWidget *
gimp_container_popup_new (GimpContainer *container,
GimpContext *context)
gimp_container_popup_new (GimpContainer *container,
GimpContext *context,
GimpDialogFactory *dialog_factory,
const gchar *dialog_identifier,
const gchar *dialog_stock_id,
const gchar *dialog_tooltip)
{
GimpContainerPopup *popup;
GtkWidget *frame;
GtkWidget *view;
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 (dialog_factory == NULL ||
GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL);
if (dialog_factory)
{
g_return_val_if_fail (dialog_identifier != NULL, NULL);
g_return_val_if_fail (dialog_stock_id != NULL, NULL);
g_return_val_if_fail (dialog_tooltip != NULL, NULL);
}
popup = g_object_new (GIMP_TYPE_CONTAINER_POPUP,
"type", GTK_WINDOW_POPUP,
@ -339,21 +389,15 @@ gimp_container_popup_new (GimpContainer *container,
G_CALLBACK (gimp_container_popup_context_changed),
popup);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_container_add (GTK_CONTAINER (popup), frame);
gtk_widget_show (frame);
if (dialog_factory)
{
popup->dialog_factory = dialog_factory;
popup->dialog_identifier = g_strdup (dialog_identifier);
popup->dialog_stock_id = g_strdup (dialog_stock_id);
popup->dialog_tooltip = g_strdup (dialog_tooltip);
}
view = g_object_new (GIMP_TYPE_CONTAINER_EDITOR, NULL);
gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (view),
GIMP_VIEW_TYPE_LIST,
container,
popup->context,
GIMP_PREVIEW_SIZE_SMALL,
FALSE, /* reorderable */
6, 8, NULL, NULL);
gtk_container_add (GTK_CONTAINER (frame), view);
gtk_widget_show (view);
gimp_container_popup_create_view (popup, GIMP_VIEW_TYPE_LIST);
return GTK_WIDGET (popup);
}
@ -398,3 +442,119 @@ gimp_container_popup_show (GimpContainerPopup *popup,
gtk_widget_show (GTK_WIDGET (popup));
}
static void
gimp_container_popup_create_view (GimpContainerPopup *popup,
GimpViewType view_type)
{
GimpEditor *editor;
GtkWidget *button;
popup->editor = g_object_new (GIMP_TYPE_CONTAINER_EDITOR, NULL);
gimp_container_editor_construct (popup->editor,
view_type,
popup->container,
popup->context,
GIMP_PREVIEW_SIZE_SMALL,
FALSE, /* reorderable */
6, 8, NULL, NULL);
if (GIMP_IS_CONTAINER_GRID_VIEW (popup->editor->view))
gtk_widget_hide (GIMP_CONTAINER_GRID_VIEW (popup->editor->view)->name_label);
gtk_container_add (GTK_CONTAINER (popup->frame), GTK_WIDGET (popup->editor));
gtk_widget_show (GTK_WIDGET (popup->editor));
editor = GIMP_EDITOR (popup->editor->view);
gimp_editor_add_button (editor, GTK_STOCK_ZOOM_OUT,
_("Smaller Previews"), NULL,
G_CALLBACK (gimp_container_popup_smaller_clicked),
NULL,
popup);
gimp_editor_add_button (editor, GTK_STOCK_ZOOM_IN,
_("Larger Previews"), NULL,
G_CALLBACK (gimp_container_popup_larger_clicked),
NULL,
popup);
button =
gimp_editor_add_button (editor, GTK_STOCK_INDEX,
_("View as List"), NULL,
G_CALLBACK (gimp_container_popup_list_clicked),
NULL,
popup);
if (view_type == GIMP_VIEW_TYPE_LIST)
gtk_widget_set_sensitive (button, FALSE);
button =
gimp_editor_add_button (editor, GTK_STOCK_SELECT_COLOR,
_("View as Grid"), NULL,
G_CALLBACK (gimp_container_popup_grid_clicked),
NULL,
popup);
if (view_type == GIMP_VIEW_TYPE_GRID)
gtk_widget_set_sensitive (button, FALSE);
if (popup->dialog_factory)
gimp_editor_add_button (editor, popup->dialog_stock_id,
popup->dialog_tooltip, NULL,
G_CALLBACK (gimp_container_popup_dialog_clicked),
NULL,
popup);
gtk_widget_grab_focus (GTK_WIDGET (popup->editor));
}
static void
gimp_container_popup_smaller_clicked (GtkWidget *button,
GimpContainerPopup *popup)
{
gint preview_size;
preview_size = MAX (GIMP_PREVIEW_SIZE_TINY,
popup->editor->view->preview_size * 0.8);
gimp_container_view_set_preview_size (popup->editor->view,
preview_size);
}
static void
gimp_container_popup_larger_clicked (GtkWidget *button,
GimpContainerPopup *popup)
{
gint preview_size;
preview_size = MIN (GIMP_PREVIEW_SIZE_HUGE,
popup->editor->view->preview_size * 1.2);
gimp_container_view_set_preview_size (popup->editor->view,
preview_size);
}
static void
gimp_container_popup_list_clicked (GtkWidget *button,
GimpContainerPopup *popup)
{
gtk_container_remove (GTK_CONTAINER (popup->frame),
GTK_WIDGET (popup->editor));
gimp_container_popup_create_view (popup, GIMP_VIEW_TYPE_LIST);
}
static void
gimp_container_popup_grid_clicked (GtkWidget *button,
GimpContainerPopup *popup)
{
gtk_container_remove (GTK_CONTAINER (popup->frame),
GTK_WIDGET (popup->editor));
gimp_container_popup_create_view (popup, GIMP_VIEW_TYPE_GRID);
}
static void
gimp_container_popup_dialog_clicked (GtkWidget *button,
GimpContainerPopup *popup)
{
gimp_dialog_factory_dialog_raise (popup->dialog_factory,
popup->dialog_identifier, -1);
g_signal_emit (popup, popup_signals[CONFIRM], 0);
}

View File

@ -44,7 +44,13 @@ struct _GimpContainerPopup
GimpContext *orig_context;
GimpContext *context;
GtkWidget *frame;
GimpContainerEditor *editor;
GimpDialogFactory *dialog_factory;
gchar *dialog_identifier;
gchar *dialog_stock_id;
gchar *dialog_tooltip;
};
struct _GimpContainerPopupClass
@ -59,7 +65,11 @@ struct _GimpContainerPopupClass
GType gimp_container_popup_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_container_popup_new (GimpContainer *container,
GimpContext *context);
GimpContext *context,
GimpDialogFactory *dialog_factory,
const gchar *dialog_identifier,
const gchar *dialog_stock_id,
const gchar *dialog_tooltip);
void gimp_container_popup_show (GimpContainerPopup *popup,
GtkWidget *widget);

View File

@ -21,6 +21,8 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "widgets-types.h"
@ -148,6 +150,10 @@ gimp_container_tree_view_class_init (GimpContainerTreeViewClass *klass)
static void
gimp_container_tree_view_init (GimpContainerTreeView *tree_view)
{
GimpContainerView *view;
view = GIMP_CONTAINER_VIEW (tree_view);
tree_view->n_model_columns = NUM_COLUMNS;
tree_view->model_columns[COLUMN_RENDERER] = GIMP_TYPE_PREVIEW_RENDERER;
@ -158,18 +164,10 @@ gimp_container_tree_view_init (GimpContainerTreeView *tree_view)
tree_view->preview_border_width = 1;
tree_view->scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (tree_view->scrolled_win),
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (view->scrolled_win),
GTK_SHADOW_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tree_view->scrolled_win),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (tree_view), tree_view->scrolled_win);
gtk_widget_show (tree_view->scrolled_win);
GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW
(tree_view->scrolled_win)->vscrollbar,
GTK_CAN_FOCUS);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (view->scrolled_win),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
}
static GObject *
@ -178,12 +176,14 @@ gimp_container_tree_view_constructor (GType type,
GObjectConstructParam *params)
{
GimpContainerTreeView *tree_view;
GimpContainerView *view;
GtkListStore *list;
GObject *object;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
tree_view = GIMP_CONTAINER_TREE_VIEW (object);
view = GIMP_CONTAINER_VIEW (object);
list = gtk_list_store_newv (tree_view->n_model_columns,
tree_view->model_columns);
@ -194,7 +194,7 @@ gimp_container_tree_view_constructor (GType type,
g_object_unref (list);
gtk_tree_view_set_headers_visible (tree_view->view, FALSE);
gtk_container_add (GTK_CONTAINER (tree_view->scrolled_win),
gtk_container_add (GTK_CONTAINER (view->scrolled_win),
GTK_WIDGET (tree_view->view));
gtk_widget_show (GTK_WIDGET (tree_view->view));
@ -243,6 +243,9 @@ gimp_container_tree_view_constructor (GType type,
G_CALLBACK (gimp_container_tree_view_drag_drop),
tree_view);
gtk_tree_view_set_search_column (tree_view->view, COLUMN_NAME);
gtk_tree_view_set_enable_search (tree_view->view, TRUE);
return object;
}
@ -256,10 +259,10 @@ gimp_container_tree_view_new (GimpContainer *container,
{
GimpContainerTreeView *tree_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 (container == NULL || GIMP_IS_CONTAINER (container),
NULL);
g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL);
g_return_val_if_fail (preview_size > 0 &&
preview_size <= GIMP_PREVIEW_MAX_SIZE, NULL);
g_return_val_if_fail (min_items_x > 0 && min_items_x <= 64, NULL);
@ -272,14 +275,9 @@ gimp_container_tree_view_new (GimpContainer *container,
view->preview_size = preview_size;
view->reorderable = reorderable ? TRUE : FALSE;
window_border =
GTK_SCROLLED_WINDOW (tree_view->scrolled_win)->vscrollbar->requisition.width +
GTK_SCROLLED_WINDOW_GET_CLASS (tree_view->scrolled_win)->scrollbar_spacing +
tree_view->scrolled_win->style->xthickness * 4;
gtk_widget_set_size_request (GTK_WIDGET (tree_view),
(preview_size + 2) * min_items_x + window_border,
(preview_size + 6) * min_items_y + window_border);
gimp_container_view_set_size_request (view,
(preview_size + 2) * min_items_x,
(preview_size + 2) * min_items_y);
if (container)
gimp_container_view_set_container (view, container);
@ -713,6 +711,9 @@ gimp_container_tree_view_button_press (GtkWidget *widget,
tree_view->dnd_viewable = NULL;
if (! GTK_WIDGET_HAS_FOCUS (widget))
gtk_widget_grab_focus (widget);
if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
bevent->x,
bevent->y,

View File

@ -40,8 +40,6 @@ struct _GimpContainerTreeView
{
GimpContainerView parent_instance;
GtkWidget *scrolled_win;
GtkTreeModel *model;
gint n_model_columns;
GType model_columns[16];

View File

@ -190,7 +190,14 @@ gimp_container_view_init (GimpContainerView *view,
view->get_name_func = NULL;
view->dnd_widget = NULL;
view->scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_box_pack_start (GTK_BOX (view), view->scrolled_win, TRUE, TRUE, 0);
gtk_widget_show (view->scrolled_win);
GTK_WIDGET_UNSET_FLAGS (GTK_SCROLLED_WINDOW (view->scrolled_win)->vscrollbar,
GTK_CAN_FOCUS);
view->dnd_widget = view->scrolled_win;
}
static void
@ -434,6 +441,42 @@ gimp_container_view_enable_dnd (GimpContainerView *view,
view);
}
void
gimp_container_view_set_size_request (GimpContainerView *view,
gint width,
gint height)
{
GtkScrolledWindowClass *sw_class;
GtkRequisition req;
gint scrollbar_width;
gint border_x;
gint border_y;
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
g_return_if_fail (width >= view->preview_size);
g_return_if_fail (height >= view->preview_size);
sw_class = GTK_SCROLLED_WINDOW_GET_CLASS (view->scrolled_win);
if (sw_class->scrollbar_spacing >= 0)
width = sw_class->scrollbar_spacing;
else
gtk_widget_style_get (GTK_WIDGET (view->scrolled_win),
"scrollbar_spacing", &scrollbar_width,
NULL);
gtk_widget_size_request (GTK_SCROLLED_WINDOW (view->scrolled_win)->vscrollbar,
&req);
scrollbar_width += req.width;
border_x = view->scrolled_win->style->xthickness * 2 + scrollbar_width;
border_y = view->scrolled_win->style->ythickness * 2;
gtk_widget_set_size_request (view->scrolled_win,
width + border_x,
height + border_y);
}
void
gimp_container_view_select_item (GimpContainerView *view,
GimpViewable *viewable)

View File

@ -50,6 +50,8 @@ struct _GimpContainerView
GimpItemGetNameFunc get_name_func;
GtkWidget *scrolled_win;
/* initialized by subclass */
GtkWidget *dnd_widget;
};
@ -104,6 +106,9 @@ void gimp_container_view_set_name_func (GimpContainerView *view,
void gimp_container_view_enable_dnd (GimpContainerView *editor,
GtkButton *button,
GType children_type);
void gimp_container_view_set_size_request (GimpContainerView *view,
gint width,
gint height);
void gimp_container_view_select_item (GimpContainerView *view,
GimpViewable *viewable);