diff --git a/ChangeLog b/ChangeLog index 22379d6a29..7e81450479 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2003-04-13 Michael Natterer + + * app/widgets/gimpcontainergridview.c: connect to "realize" of the + scrolled window's viewport and scroll to the correct item + (because GtkViewport is too dumb to this by itself). + + * app/widgets/gimpcontainerpopup.[ch]: added a "view_type" + parameter. + + * app/widgets/gimpviewablebutton.[ch]: added new function + gimp_viewable_button_set_view_type() and pass the view_type + to the GimpContainerPopup. + + * app/widgets/gimptemplateeditor.c: default to GIMP_VIEW_TYPE_GRID + for the stock icon popup. + 2003-04-13 Michael Natterer * app/core/gimpdrawable-desaturate.c (gimp_drawable_desaturate): diff --git a/app/widgets/gimpcontainergridview.c b/app/widgets/gimpcontainergridview.c index 4e1eb6f51c..3bd1b81480 100644 --- a/app/widgets/gimpcontainergridview.c +++ b/app/widgets/gimpcontainergridview.c @@ -88,6 +88,8 @@ static void gimp_container_grid_view_highlight_item (GimpContainerView *v static void gimp_container_grid_view_vieport_resized (GtkWidget *widget, GtkAllocation *allocation, GimpContainerGridView *view); +static void gimp_container_grid_view_vieport_realize (GtkWidget *widget, + GimpContainerGridView *view); static GimpContainerViewClass *parent_class = NULL; @@ -212,6 +214,9 @@ gimp_container_grid_view_init (GimpContainerGridView *grid_view) g_signal_connect (grid_view->wrap_box->parent, "size_allocate", G_CALLBACK (gimp_container_grid_view_vieport_resized), grid_view); + g_signal_connect (grid_view->wrap_box->parent, "realize", + G_CALLBACK (gimp_container_grid_view_vieport_realize), + grid_view); gtk_container_set_focus_vadjustment (GTK_CONTAINER (grid_view->wrap_box->parent), @@ -538,7 +543,7 @@ gimp_container_grid_view_highlight_item (GimpContainerView *view, adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (view->scrolled_win)); - item_height = GTK_WIDGET (preview)->allocation.height; + item_height = GTK_WIDGET (preview)->requisition.height; index = gimp_container_get_child_index (view->container, GIMP_OBJECT (viewable)); @@ -621,3 +626,25 @@ gimp_container_grid_view_vieport_resized (GtkWidget *widget, } } } + +static void +gimp_container_grid_view_vieport_realize (GtkWidget *widget, + GimpContainerGridView *grid_view) +{ + GimpContainerView *view; + + view = GIMP_CONTAINER_VIEW (grid_view); + + if (view->container) + { + GimpPreview *preview; + + preview = g_object_get_data (G_OBJECT (view), + "last_selected_item"); + + if (preview) + gimp_container_grid_view_highlight_item (view, + preview->viewable, + preview); + } +} diff --git a/app/widgets/gimpcontainerpopup.c b/app/widgets/gimpcontainerpopup.c index b433e1a7a8..5e2351534b 100644 --- a/app/widgets/gimpcontainerpopup.c +++ b/app/widgets/gimpcontainerpopup.c @@ -360,6 +360,7 @@ gimp_container_popup_context_changed (GimpContext *context, GtkWidget * gimp_container_popup_new (GimpContainer *container, GimpContext *context, + GimpViewType view_type, gint preview_size, gint preview_border_width, GimpDialogFactory *dialog_factory, @@ -410,7 +411,7 @@ gimp_container_popup_new (GimpContainer *container, popup->dialog_tooltip = g_strdup (dialog_tooltip); } - gimp_container_popup_create_view (popup, GIMP_VIEW_TYPE_LIST); + gimp_container_popup_create_view (popup, view_type); return GTK_WIDGET (popup); } diff --git a/app/widgets/gimpcontainerpopup.h b/app/widgets/gimpcontainerpopup.h index 5838afa522..0601574834 100644 --- a/app/widgets/gimpcontainerpopup.h +++ b/app/widgets/gimpcontainerpopup.h @@ -69,6 +69,7 @@ GType gimp_container_popup_get_type (void) G_GNUC_CONST; GtkWidget * gimp_container_popup_new (GimpContainer *container, GimpContext *context, + GimpViewType view_type, gint preview_size, gint preview_border_width, GimpDialogFactory *dialog_factory, diff --git a/app/widgets/gimptemplateeditor.c b/app/widgets/gimptemplateeditor.c index c459ead44f..8138423928 100644 --- a/app/widgets/gimptemplateeditor.c +++ b/app/widgets/gimptemplateeditor.c @@ -429,6 +429,8 @@ gimp_template_editor_new (Gimp *gimp, editor->stock_id_context, GIMP_PREVIEW_SIZE_SMALL, 0, NULL, NULL, NULL, NULL); + gimp_viewable_button_set_view_type (GIMP_VIEWABLE_BUTTON (button), + GIMP_VIEW_TYPE_GRID); gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, _("_Icon:"), 1.0, 0.5, diff --git a/app/widgets/gimpviewablebutton.c b/app/widgets/gimpviewablebutton.c index 74b387bd79..02107b0631 100644 --- a/app/widgets/gimpviewablebutton.c +++ b/app/widgets/gimpviewablebutton.c @@ -100,6 +100,7 @@ gimp_viewable_button_class_init (GimpViewableButtonClass *klass) static void gimp_viewable_button_init (GimpViewableButton *button) { + button->view_type = GIMP_VIEW_TYPE_LIST; button->preview_size = GIMP_PREVIEW_SIZE_SMALL; button->preview_border_width = 1; } @@ -194,6 +195,7 @@ gimp_viewable_button_clicked (GtkButton *button) popup = gimp_container_popup_new (viewable_button->container, viewable_button->context, + viewable_button->view_type, viewable_button->preview_size, viewable_button->preview_border_width, viewable_button->dialog_factory, @@ -257,3 +259,12 @@ gimp_viewable_button_new (GimpContainer *container, return GTK_WIDGET (button); } + +void +gimp_viewable_button_set_view_type (GimpViewableButton *button, + GimpViewType view_type) +{ + g_return_if_fail (GIMP_IS_VIEWABLE_BUTTON (button)); + + button->view_type = view_type; +} diff --git a/app/widgets/gimpviewablebutton.h b/app/widgets/gimpviewablebutton.h index 64ea4ed3e5..9d7a00c5f7 100644 --- a/app/widgets/gimpviewablebutton.h +++ b/app/widgets/gimpviewablebutton.h @@ -43,6 +43,7 @@ struct _GimpViewableButton GimpContainer *container; GimpContext *context; + GimpViewType view_type; gint preview_size; gint preview_border_width; @@ -62,14 +63,17 @@ struct _GimpViewableButtonClass 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, - const gchar *dialog_tooltip); +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, + const gchar *dialog_tooltip); +void gimp_viewable_button_set_view_type (GimpViewableButton *button, + GimpViewType view_type); + G_END_DECLS