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

removed tree_view->preview_border_width.

2003-04-04  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpcontainertreeview.[ch]: removed
	tree_view->preview_border_width.

	* app/widgets/gimpcontainermenu.[ch]
	* app/widgets/gimpcontainerview.[ch]: and added it here so it is
	configurable in all views. Synced the changes in both classes.

	* app/widgets/gimpcontainermenuimpl.[ch]
	* app/widgets/gimpmenuitem.[ch]: made preview_border_size
	configurable here, too.

	* app/widgets/gimplayertreeview.c
	* app/widgets/gimpimagedock.c
	* app/gui/palette-import-dialog.c: changed accordingly.

	* app/gui/file-new-dialog.c: Removed the border from the template
	menu previews.
parent c27429c8
2003-04-04 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpcontainertreeview.[ch]: removed
tree_view->preview_border_width.
* app/widgets/gimpcontainermenu.[ch]
* app/widgets/gimpcontainerview.[ch]: and added it here so it is
configurable in all views. Synced the changes in both classes.
* app/widgets/gimpcontainermenuimpl.[ch]
* app/widgets/gimpmenuitem.[ch]: made preview_border_size
configurable here, too.
* app/widgets/gimplayertreeview.c
* app/widgets/gimpimagedock.c
* app/gui/palette-import-dialog.c: changed accordingly.
* app/gui/file-new-dialog.c: Removed the border from the template
menu previews.
2003-04-04 Michael Natterer <mitch@gimp.org>
 
* app/core/gimpundo.h: #define GIMP_UNDO_PREVIEW_SIZE 64
......@@ -161,7 +161,7 @@ file_new_dialog_create (Gimp *gimp,
gtk_label_set_mnemonic_widget (GTK_LABEL (label), optionmenu);
info->template_menu = gimp_container_menu_new (gimp->templates, NULL, 16);
info->template_menu = gimp_container_menu_new (gimp->templates, NULL, 16, 0);
gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), info->template_menu);
gtk_widget_show (info->template_menu);
......
......@@ -241,7 +241,7 @@ palette_import_dialog_new (Gimp *gimp)
import_dialog->gradient_menu, 1, FALSE);
menu = gimp_container_menu_new (gimp->gradient_factory->container,
import_dialog->context, 24);
import_dialog->context, 24, 1);
gtk_option_menu_set_menu (GTK_OPTION_MENU (import_dialog->gradient_menu),
menu);
gtk_widget_show (menu);
......@@ -252,7 +252,7 @@ palette_import_dialog_new (Gimp *gimp)
NULL, 1.0, 0.5,
import_dialog->image_menu, 1, FALSE);
menu = gimp_container_menu_new (gimp->images, import_dialog->context, 24);
menu = gimp_container_menu_new (gimp->images, import_dialog->context, 24, 1);
gtk_option_menu_set_menu (GTK_OPTION_MENU (import_dialog->image_menu), menu);
gtk_widget_show (menu);
......
......@@ -161,7 +161,7 @@ file_new_dialog_create (Gimp *gimp,
gtk_label_set_mnemonic_widget (GTK_LABEL (label), optionmenu);
info->template_menu = gimp_container_menu_new (gimp->templates, NULL, 16);
info->template_menu = gimp_container_menu_new (gimp->templates, NULL, 16, 0);
gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), info->template_menu);
gtk_widget_show (info->template_menu);
......
......@@ -241,7 +241,7 @@ palette_import_dialog_new (Gimp *gimp)
import_dialog->gradient_menu, 1, FALSE);
menu = gimp_container_menu_new (gimp->gradient_factory->container,
import_dialog->context, 24);
import_dialog->context, 24, 1);
gtk_option_menu_set_menu (GTK_OPTION_MENU (import_dialog->gradient_menu),
menu);
gtk_widget_show (menu);
......@@ -252,7 +252,7 @@ palette_import_dialog_new (Gimp *gimp)
NULL, 1.0, 0.5,
import_dialog->image_menu, 1, FALSE);
menu = gimp_container_menu_new (gimp->images, import_dialog->context, 24);
menu = gimp_container_menu_new (gimp->images, import_dialog->context, 24, 1);
gtk_option_menu_set_menu (GTK_OPTION_MENU (import_dialog->image_menu), menu);
gtk_widget_show (menu);
......
......@@ -163,12 +163,11 @@ gimp_container_menu_class_init (GimpContainerMenuClass *klass)
static void
gimp_container_menu_init (GimpContainerMenu *menu)
{
menu->container = NULL;
menu->context = NULL;
menu->hash_table = g_hash_table_new (g_direct_hash, g_direct_equal);
menu->preview_size = 0;
menu->container = NULL;
menu->context = NULL;
menu->hash_table = g_hash_table_new (g_direct_hash, g_direct_equal);
menu->preview_size = 0;
menu->preview_border_width = 1;
}
static void
......@@ -199,12 +198,10 @@ gimp_container_menu_set_container (GimpContainerMenu *menu,
GimpContainer *container)
{
g_return_if_fail (GIMP_IS_CONTAINER_MENU (menu));
g_return_if_fail (! container || GIMP_IS_CONTAINER (container));
g_return_if_fail (container == NULL || GIMP_IS_CONTAINER (container));
if (container != menu->container)
{
GIMP_CONTAINER_MENU_GET_CLASS (menu)->set_container (menu, container);
}
GIMP_CONTAINER_MENU_GET_CLASS (menu)->set_container (menu, container);
}
static void
......@@ -367,52 +364,61 @@ gimp_container_menu_set_name_func (GimpContainerMenu *menu,
{
g_return_if_fail (GIMP_IS_CONTAINER_MENU (menu));
if (menu->get_name_func != get_name_func)
{
menu->get_name_func = get_name_func;
}
menu->get_name_func = get_name_func;
}
void
gimp_container_menu_select_item (GimpContainerMenu *menu,
GimpViewable *viewable)
{
gpointer insert_data;
g_return_if_fail (GIMP_IS_CONTAINER_MENU (menu));
g_return_if_fail (! viewable || GIMP_IS_VIEWABLE (viewable));
insert_data = g_hash_table_lookup (menu->hash_table, viewable);
if (menu->hash_table)
{
gpointer insert_data;
g_signal_emit (menu, menu_signals[SELECT_ITEM], 0, viewable, insert_data);
insert_data = g_hash_table_lookup (menu->hash_table, viewable);
g_signal_emit (menu, menu_signals[SELECT_ITEM], 0,
viewable, insert_data);
}
}
void
gimp_container_menu_activate_item (GimpContainerMenu *menu,
GimpViewable *viewable)
{
gpointer insert_data;
g_return_if_fail (GIMP_IS_CONTAINER_MENU (menu));
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
insert_data = g_hash_table_lookup (menu->hash_table, viewable);
if (menu->hash_table)
{
gpointer insert_data;
g_signal_emit (menu, menu_signals[ACTIVATE_ITEM], 0, viewable, insert_data);
insert_data = g_hash_table_lookup (menu->hash_table, viewable);
g_signal_emit (menu, menu_signals[ACTIVATE_ITEM], 0,
viewable, insert_data);
}
}
void
gimp_container_menu_context_item (GimpContainerMenu *menu,
GimpViewable *viewable)
{
gpointer insert_data;
g_return_if_fail (GIMP_IS_CONTAINER_MENU (menu));
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
insert_data = g_hash_table_lookup (menu->hash_table, viewable);
if (menu->hash_table)
{
gpointer insert_data;
g_signal_emit (menu, menu_signals[CONTEXT_ITEM], 0, viewable, insert_data);
insert_data = g_hash_table_lookup (menu->hash_table, viewable);
g_signal_emit (menu, menu_signals[CONTEXT_ITEM], 0,
viewable, insert_data);
}
}
void
......@@ -424,9 +430,26 @@ gimp_container_menu_item_selected (GimpContainerMenu *menu,
if (menu->container && menu->context)
{
gimp_context_set_by_type (menu->context,
GimpContext *context;
/* ref and remember the context because menu->context may
* become NULL by calling gimp_context_set_by_type()
*/
context = g_object_ref (menu->context);
g_signal_handlers_block_by_func (context,
gimp_container_menu_context_changed,
menu);
gimp_context_set_by_type (context,
menu->container->children_type,
GIMP_OBJECT (viewable));
g_signal_handlers_unblock_by_func (context,
gimp_container_menu_context_changed,
menu);
g_object_unref (context);
}
gimp_container_menu_select_item (menu, viewable);
......@@ -508,11 +531,11 @@ gimp_container_menu_remove (GimpContainerMenu *menu,
if (insert_data)
{
g_hash_table_remove (menu->hash_table, viewable);
GIMP_CONTAINER_MENU_GET_CLASS (menu)->remove_item (menu,
viewable,
insert_data);
g_hash_table_remove (menu->hash_table, viewable);
}
}
......
......@@ -50,6 +50,7 @@ struct _GimpContainerMenu
GHashTable *hash_table;
gint preview_size;
gint preview_border_width;
GimpItemGetNameFunc get_name_func;
};
......
......@@ -120,7 +120,8 @@ gimp_container_menu_impl_init (GimpContainerMenuImpl *menu_impl)
GtkWidget *
gimp_container_menu_new (GimpContainer *container,
GimpContext *context,
gint preview_size)
gint preview_size,
gint preview_border_width)
{
GimpContainerMenuImpl *menu_impl;
GimpContainerMenu *menu;
......@@ -130,17 +131,22 @@ gimp_container_menu_new (GimpContainer *container,
g_return_val_if_fail (context == NULL || 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);
menu_impl = g_object_new (GIMP_TYPE_CONTAINER_MENU_IMPL, NULL);
menu = GIMP_CONTAINER_MENU (menu_impl);
menu->preview_size = preview_size;
menu->preview_size = preview_size;
menu->preview_border_width = preview_border_width;
menu_impl->empty_item = gtk_menu_item_new_with_label ("(none)");
gtk_widget_set_size_request (menu_impl->empty_item,
-1,
preview_size +
2 * preview_border_width +
2 * menu_impl->empty_item->style->ythickness);
gtk_widget_set_sensitive (menu_impl->empty_item, FALSE);
gtk_widget_show (menu_impl->empty_item);
......@@ -166,7 +172,9 @@ gimp_container_menu_impl_insert_item (GimpContainerMenu *menu,
{
GtkWidget *menu_item;
menu_item = gimp_menu_item_new (viewable, menu->preview_size);
menu_item = gimp_menu_item_new (viewable,
menu->preview_size,
menu->preview_border_width);
gimp_menu_item_set_name_func (GIMP_MENU_ITEM (menu_item),
menu->get_name_func);
......@@ -303,7 +311,7 @@ gimp_container_menu_impl_set_preview_size (GimpContainerMenu *menu)
gimp_preview_set_size (GIMP_PREVIEW (menu_item->preview),
menu->preview_size,
GIMP_PREVIEW (menu_item->preview)->renderer->border_width);
menu->preview_border_width);
}
}
}
......
......@@ -53,7 +53,8 @@ GType gimp_container_menu_impl_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_container_menu_new (GimpContainer *container,
GimpContext *context,
gint preview_size);
gint preview_size,
gint preview_border_width);
#endif /* __GIMP_CONTAINER_MENU_IMPL_H__ */
......@@ -162,8 +162,6 @@ gimp_container_tree_view_init (GimpContainerTreeView *tree_view)
tree_view->model_column_renderer = COLUMN_RENDERER;
tree_view->model_column_name = COLUMN_NAME;
tree_view->preview_border_width = 1;
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (view->scrolled_win),
GTK_SHADOW_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (view->scrolled_win),
......@@ -295,7 +293,7 @@ gimp_container_tree_view_set (GimpContainerTreeView *tree_view,
renderer = gimp_preview_renderer_new (G_TYPE_FROM_INSTANCE (viewable),
view->preview_size,
tree_view->preview_border_width,
view->preview_border_width,
FALSE);
gimp_preview_renderer_set_viewable (renderer, viewable);
gimp_preview_renderer_remove_idle (renderer);
......@@ -621,8 +619,9 @@ gimp_container_tree_view_set_preview_size (GimpContainerView *view)
COLUMN_RENDERER, &renderer,
-1);
gimp_preview_renderer_set_size (renderer, view->preview_size,
tree_view->preview_border_width);
gimp_preview_renderer_set_size (renderer,
view->preview_size,
view->preview_border_width);
g_object_unref (renderer);
}
......
......@@ -58,8 +58,6 @@ struct _GimpContainerTreeView
GList *renderer_cells;
GList *editable_cells;
gint preview_border_width;
GQuark invalidate_preview_handler_id;
GQuark name_changed_handler_id;
......
......@@ -177,17 +177,16 @@ static void
gimp_container_view_init (GimpContainerView *view,
GimpContainerViewClass *klass)
{
view->container = NULL;
view->context = NULL;
view->hash_table = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL,
klass->insert_data_free);
view->preview_size = 0;
view->reorderable = FALSE;
view->get_name_func = NULL;
view->container = NULL;
view->context = NULL;
view->hash_table = g_hash_table_new_full (g_direct_hash,
g_direct_equal,
NULL,
klass->insert_data_free);
view->preview_size = 0;
view->preview_border_width = 1;
view->reorderable = FALSE;
view->get_name_func = NULL;
view->scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_box_pack_start (GTK_BOX (view), view->scrolled_win, TRUE, TRUE, 0);
......@@ -226,7 +225,7 @@ gimp_container_view_set_container (GimpContainerView *view,
GimpContainer *container)
{
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
g_return_if_fail (! container || GIMP_IS_CONTAINER (container));
g_return_if_fail (container == NULL || GIMP_IS_CONTAINER (container));
if (container != view->container)
GIMP_CONTAINER_VIEW_GET_CLASS (view)->set_container (view, container);
......@@ -715,8 +714,7 @@ gimp_container_view_context_changed (GimpContext *context,
insert_data = g_hash_table_lookup (view->hash_table, viewable);
g_signal_emit (view, view_signals[SELECT_ITEM], 0,
viewable, insert_data);
g_signal_emit (view, view_signals[SELECT_ITEM], 0, viewable, insert_data);
}
static void
......
......@@ -46,6 +46,7 @@ struct _GimpContainerView
GHashTable *hash_table;
gint preview_size;
gint preview_border_width;
gboolean reorderable;
GimpItemGetNameFunc get_name_func;
......
......@@ -298,7 +298,7 @@ gimp_image_dock_new (GimpDialogFactory *dialog_factory,
&menu_preview_width, &menu_preview_height);
image_dock->menu = gimp_container_menu_new (image_container, context,
menu_preview_height);
menu_preview_height, 1);
gtk_option_menu_set_menu (GTK_OPTION_MENU (image_dock->option_menu),
image_dock->menu);
gtk_widget_show (image_dock->menu);
......
......@@ -231,7 +231,7 @@ gimp_layer_tree_view_init (GimpLayerTreeView *view)
view->model_column_mask_visible = tree_view->n_model_columns;
tree_view->model_columns[tree_view->n_model_columns++] = G_TYPE_BOOLEAN;
tree_view->preview_border_width = 2;
GIMP_CONTAINER_VIEW (view)->preview_border_width = 2;
view->options_box = gtk_table_new (2, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (view->options_box), 2);
......@@ -547,8 +547,9 @@ gimp_layer_tree_view_set_preview_size (GimpContainerView *view)
if (renderer)
{
gimp_preview_renderer_set_size (renderer, view->preview_size,
tree_view->preview_border_width);
gimp_preview_renderer_set_size (renderer,
view->preview_size,
view->preview_border_width);
g_object_unref (renderer);
}
}
......@@ -890,7 +891,7 @@ gimp_layer_tree_view_mask_update (GimpLayerTreeView *layer_view,
renderer = gimp_preview_renderer_new (G_TYPE_FROM_INSTANCE (mask),
container_view->preview_size,
tree_view->preview_border_width,
container_view->preview_border_width,
FALSE);
gimp_preview_renderer_set_viewable (renderer, GIMP_VIEWABLE (mask));
......
......@@ -298,7 +298,7 @@ gimp_image_dock_new (GimpDialogFactory *dialog_factory,
&menu_preview_width, &menu_preview_height);
image_dock->menu = gimp_container_menu_new (image_container, context,
menu_preview_height);
menu_preview_height, 1);
gtk_option_menu_set_menu (GTK_OPTION_MENU (image_dock->option_menu),
image_dock->menu);
gtk_widget_show (image_dock->menu);
......
......@@ -33,6 +33,7 @@
#include "gimpdnd.h"
#include "gimpmenuitem.h"
#include "gimppreview.h"
#include "gimppreviewrenderer.h"
static void gimp_menu_item_class_init (GimpMenuItemClass *klass);
......@@ -96,26 +97,32 @@ gimp_menu_item_init (GimpMenuItem *menu_item)
gtk_container_add (GTK_CONTAINER (menu_item), menu_item->hbox);
gtk_widget_show (menu_item->hbox);
menu_item->preview = NULL;
menu_item->name_label = NULL;
menu_item->preview = NULL;
menu_item->name_label = NULL;
menu_item->preview_size = 0;
menu_item->get_name_func = NULL;
menu_item->preview_size = 0;
menu_item->preview_border_width = 1;
menu_item->get_name_func = NULL;
}
GtkWidget *
gimp_menu_item_new (GimpViewable *viewable,
gint preview_size)
gint preview_size,
gint preview_border_width)
{
GimpMenuItem *menu_item;
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), 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);
menu_item = g_object_new (GIMP_TYPE_MENU_ITEM, NULL);
menu_item->preview_size = preview_size;
menu_item->preview_size = preview_size;
menu_item->preview_border_width = preview_border_width;
gimp_menu_item_set_viewable (menu_item, viewable);
......@@ -133,9 +140,14 @@ static void
gimp_menu_item_real_set_viewable (GimpMenuItem *menu_item,
GimpViewable *viewable)
{
menu_item->preview = gimp_preview_new (viewable, menu_item->preview_size,
1, FALSE);
gtk_widget_set_size_request (menu_item->preview, menu_item->preview_size, -1);
menu_item->preview = gimp_preview_new (viewable,
menu_item->preview_size,
menu_item->preview_border_width,
FALSE);
gtk_widget_set_size_request (menu_item->preview,
menu_item->preview_size +
2 * menu_item->preview_border_width,
-1);
gtk_box_pack_start (GTK_BOX (menu_item->hbox), menu_item->preview,
FALSE, FALSE, 0);
gtk_widget_show (menu_item->preview);
......
......@@ -46,6 +46,7 @@ struct _GimpMenuItem
/*< protected >*/
gint preview_size;
gint preview_border_width;
/*< private >*/
GimpItemGetNameFunc get_name_func;
......@@ -64,7 +65,8 @@ struct _GimpMenuItemClass
GType gimp_menu_item_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_menu_item_new (GimpViewable *viewable,
gint preview_size);
gint preview_size,
gint preview_border_width);
void gimp_menu_item_set_name_func (GimpMenuItem *menu_item,
GimpItemGetNameFunc get_name_func);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment