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

removed typedefs from the widgets/ subdir.

2001-05-03  Michael Natterer  <mitch@gimp.org>

	* app/apptypes.h: removed typedefs from the widgets/ subdir.

	* app/widgets/Makefile.am
	* app/widgets/widgets-types.h: new file.

	* app/widgets/gimpcontainermenu.[ch]
	* app/widgets/gimpcontainerview.[ch]: synced them again and added a
	"get_name_func"

	* app/widgets/gimplistitem.[ch]
	* app/widgets/gimpmenuitem.[ch]: add a "get_name_func" and use it
	to get the item's name.

	* app/widgets/gimpcontainerlistview.c
	* app/widgets/gimpcontainermenuimpl.c: pass the get_name_func to
	the created items.

	* app/widgets/gimpchannellistview.c: gtk_widget_queue_resize() the
	component frame after changing the image.

	* app/widgets/gimpcomponentlistitem.c: set a custom
	get_name_func() so the components are named Red, Green, ... again.

	* app/widgets/gimpimagedock.c: set a custom get_name_func() which
	returns names like in the old L&C dialog's image menu.

	* tools/pdbgen/Makefile.am: don't scan apptypes.h for enums.
parent 07b8ffd4
2001-05-03 Michael Natterer <mitch@gimp.org>
* app/apptypes.h: removed typedefs from the widgets/ subdir.
* app/widgets/Makefile.am
* app/widgets/widgets-types.h: new file.
* app/widgets/gimpcontainermenu.[ch]
* app/widgets/gimpcontainerview.[ch]: synced them again and added a
"get_name_func"
* app/widgets/gimplistitem.[ch]
* app/widgets/gimpmenuitem.[ch]: add a "get_name_func" and use it
to get the item's name.
* app/widgets/gimpcontainerlistview.c
* app/widgets/gimpcontainermenuimpl.c: pass the get_name_func to
the created items.
* app/widgets/gimpchannellistview.c: gtk_widget_queue_resize() the
component frame after changing the image.
* app/widgets/gimpcomponentlistitem.c: set a custom
get_name_func() so the components are named Red, Green, ... again.
* app/widgets/gimpimagedock.c: set a custom get_name_func() which
returns names like in the old L&C dialog's image menu.
* tools/pdbgen/Makefile.am: don't scan apptypes.h for enums.
2001-05-03 Michael Natterer <mitch@gimp.org>
* app/app_procs.c: don't #include "gui/color-select.h"
......
......@@ -29,6 +29,10 @@
#include "appenums.h"
#ifdef __GTK_H__
#include "widgets/widgets-types.h"
#endif
/* base objects */
......@@ -91,48 +95,6 @@ typedef struct _GimpUndo GimpUndo;
typedef struct _GimpUndoStack GimpUndoStack;
/* gui objects */
typedef struct _GimpDialogFactory GimpDialogFactory;
/* widgets */
typedef struct _GimpPreview GimpPreview;
typedef struct _GimpImagePreview GimpImagePreview;
typedef struct _GimpDrawablePreview GimpDrawablePreview;
typedef struct _GimpBrushPreview GimpBrushPreview;
typedef struct _GimpPatternPreview GimpPatternPreview;
typedef struct _GimpPalettePreview GimpPalettePreview;
typedef struct _GimpGradientPreview GimpGradientPreview;
typedef struct _GimpToolInfoPreview GimpToolInfoPreview;
typedef struct _GimpContainerMenu GimpContainerMenu;
typedef struct _GimpContainerMenuImpl GimpContainerMenuImpl;
typedef struct _GimpMenuItem GimpMenuItem;
typedef struct _GimpContainerView GimpContainerView;
typedef struct _GimpContainerListView GimpContainerListView;
typedef struct _GimpContainerGridView GimpContainerGridView;
typedef struct _GimpDataFactoryView GimpDataFactoryView;
typedef struct _GimpDrawableListView GimpDrawableListView;
typedef struct _GimpLayerListView GimpLayerListView;
typedef struct _GimpChannelListView GimpChannelListView;
typedef struct _GimpListItem GimpListItem;
typedef struct _GimpDrawableListItem GimpDrawableListItem;
typedef struct _GimpLayerListItem GimpLayerListItem;
typedef struct _GimpComponentListItem GimpComponentListItem;
typedef struct _GimpDock GimpDock;
typedef struct _GimpImageDock GimpImageDock;
typedef struct _GimpDockable GimpDockable;
typedef struct _GimpDockbook GimpDockbook;
typedef struct _HistogramWidget HistogramWidget;
/* other stuff */
typedef struct _Argument Argument;
......
......@@ -68,7 +68,8 @@ libappwidgets_la_SOURCES = \
gtkvwrapbox.c \
gtkvwrapbox.h \
gimpconstrainedhwrapbox.c \
gimpconstrainedhwrapbox.h
gimpconstrainedhwrapbox.h \
widgets-types.h
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"Gimp-Widgets\"
......
......@@ -333,4 +333,6 @@ gimp_channel_list_view_create_components (GimpChannelListView *view)
}
gtk_list_insert_items (GTK_LIST (view->component_list), list, 0);
gtk_widget_queue_resize (GTK_WIDGET (view->component_frame));
}
......@@ -333,4 +333,6 @@ gimp_channel_list_view_create_components (GimpChannelListView *view)
}
gtk_list_insert_items (GTK_LIST (view->component_list), list, 0);
gtk_widget_queue_resize (GTK_WIDGET (view->component_frame));
}
......@@ -37,27 +37,31 @@
#include "gimpimagepreview.h"
#include "gimppreview.h"
#include "libgimp/gimpintl.h"
#include "pixmaps/eye.xpm"
static void gimp_component_list_item_class_init (GimpComponentListItemClass *klass);
static void gimp_component_list_item_init (GimpComponentListItem *list_item);
static void gimp_component_list_item_class_init (GimpComponentListItemClass *klass);
static void gimp_component_list_item_init (GimpComponentListItem *list_item);
static void gimp_component_list_item_set_viewable (GimpListItem *list_item,
GimpViewable *viewable);
static void gimp_component_list_item_set_viewable (GimpListItem *list_item,
GimpViewable *viewable);
static void gimp_component_list_item_eye_toggled (GtkWidget *widget,
gpointer data);
static void gimp_component_list_item_eye_toggled (GtkWidget *widget,
gpointer data);
static void gimp_component_list_item_visibility_changed (GimpImage *gimage,
ChannelType channel,
gpointer data);
static void gimp_component_list_item_visibility_changed (GimpImage *gimage,
ChannelType channel,
gpointer data);
static void gimp_component_list_item_state_changed (GtkWidget *widget,
GtkStateType previous_state);
static void gimp_component_list_item_active_changed (GimpImage *gimage,
ChannelType channel,
gpointer data);
static void gimp_component_list_item_state_changed (GtkWidget *widget,
GtkStateType previous_state);
static void gimp_component_list_item_active_changed (GimpImage *gimage,
ChannelType channel,
gpointer data);
static gchar * gimp_component_list_item_get_name (GtkWidget *widget);
static GimpListItemClass *parent_class = NULL;
......@@ -152,7 +156,8 @@ gimp_component_list_item_new (GimpImage *gimage,
list_item = gtk_type_new (GIMP_TYPE_COMPONENT_LIST_ITEM);
list_item->preview_size = preview_size;
list_item->preview_size = preview_size;
list_item->get_name_func = gimp_component_list_item_get_name;
GIMP_COMPONENT_LIST_ITEM (list_item)->channel = channel;
......@@ -399,3 +404,22 @@ gimp_component_list_item_active_changed (GimpImage *gimage,
else
gtk_item_deselect (GTK_ITEM (data));
}
static gchar *
gimp_component_list_item_get_name (GtkWidget *widget)
{
GimpComponentListItem *component_item;
component_item = GIMP_COMPONENT_LIST_ITEM (widget);
switch (component_item->channel)
{
case RED_CHANNEL: return g_strdup (_("Red")); break;
case GREEN_CHANNEL: return g_strdup (_("Green")); break;
case BLUE_CHANNEL: return g_strdup (_("Blue")); break;
case GRAY_CHANNEL: return g_strdup (_("Gray")); break;
case INDEXED_CHANNEL: return g_strdup (_("Indexed")); break;
case ALPHA_CHANNEL: return g_strdup (_("Alpha")); break;
default: return g_strdup ("EEK"); break;
}
}
......@@ -219,6 +219,9 @@ gimp_container_list_view_insert_item (GimpContainerView *view,
list_item = gimp_list_item_new (viewable, view->preview_size);
gimp_list_item_set_name_func (GIMP_LIST_ITEM (list_item),
view->get_name_func);
gtk_signal_connect (GTK_OBJECT (list_item), "button_press_event",
GTK_SIGNAL_FUNC (gimp_container_list_view_item_activated),
list_view);
......
......@@ -40,6 +40,7 @@ enum
REORDER_ITEM,
SELECT_ITEM,
ACTIVATE_ITEM,
CONTEXT_ITEM,
CLEAR_ITEMS,
SET_PREVIEW_SIZE,
LAST_SIGNAL
......@@ -179,6 +180,17 @@ gimp_container_menu_class_init (GimpContainerMenuClass *klass)
GIMP_TYPE_OBJECT,
GTK_TYPE_POINTER);
menu_signals[CONTEXT_ITEM] =
gtk_signal_new ("context_item",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpContainerMenuClass,
context_item),
gtk_marshal_NONE__POINTER_POINTER,
GTK_TYPE_NONE, 2,
GIMP_TYPE_OBJECT,
GTK_TYPE_POINTER);
menu_signals[CLEAR_ITEMS] =
gtk_signal_new ("clear_items",
GTK_RUN_FIRST,
......@@ -207,6 +219,7 @@ gimp_container_menu_class_init (GimpContainerMenuClass *klass)
klass->reorder_item = NULL;
klass->select_item = NULL;
klass->activate_item = NULL;
klass->context_item = NULL;
klass->clear_items = gimp_container_menu_real_clear_items;
klass->set_preview_size = NULL;
}
......@@ -379,9 +392,25 @@ gimp_container_menu_set_preview_size (GimpContainerMenu *menu,
g_return_if_fail (GIMP_IS_CONTAINER_MENU (menu));
g_return_if_fail (preview_size > 0 && preview_size <= 256 /* FIXME: 64 */);
menu->preview_size = preview_size;
if (menu->preview_size != preview_size)
{
menu->preview_size = preview_size;
gtk_signal_emit (GTK_OBJECT (menu), menu_signals[SET_PREVIEW_SIZE]);
gtk_signal_emit (GTK_OBJECT (menu), menu_signals[SET_PREVIEW_SIZE]);
}
}
void
gimp_container_menu_set_name_func (GimpContainerMenu *menu,
GimpItemGetNameFunc get_name_func)
{
g_return_if_fail (menu != NULL);
g_return_if_fail (GIMP_IS_CONTAINER_MENU (menu));
if (menu->get_name_func != get_name_func)
{
menu->get_name_func = get_name_func;
}
}
void
......@@ -417,6 +446,23 @@ gimp_container_menu_activate_item (GimpContainerMenu *menu,
viewable, insert_data);
}
void
gimp_container_menu_context_item (GimpContainerMenu *menu,
GimpViewable *viewable)
{
gpointer insert_data;
g_return_if_fail (menu != NULL);
g_return_if_fail (GIMP_IS_CONTAINER_MENU (menu));
g_return_if_fail (viewable != NULL);
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
insert_data = g_hash_table_lookup (menu->hash_table, viewable);
gtk_signal_emit (GTK_OBJECT (menu), menu_signals[CONTEXT_ITEM],
viewable, insert_data);
}
void
gimp_container_menu_item_selected (GimpContainerMenu *menu,
GimpViewable *viewable)
......@@ -448,6 +494,18 @@ gimp_container_menu_item_activated (GimpContainerMenu *menu,
gimp_container_menu_activate_item (menu, viewable);
}
void
gimp_container_menu_item_context (GimpContainerMenu *menu,
GimpViewable *viewable)
{
g_return_if_fail (menu != NULL);
g_return_if_fail (GIMP_IS_CONTAINER_MENU (menu));
g_return_if_fail (viewable != NULL);
g_return_if_fail (GIMP_IS_VIEWABLE (viewable));
gimp_container_menu_context_item (menu, viewable);
}
static void
gimp_container_menu_clear_items (GimpContainerMenu *menu)
{
......
......@@ -40,14 +40,16 @@ typedef struct _GimpContainerMenuClass GimpContainerMenuClass;
struct _GimpContainerMenu
{
GtkMenu parent_instance;
GtkMenu parent_instance;
GimpContainer *container;
GimpContext *context;
GimpContainer *container;
GimpContext *context;
GHashTable *hash_table;
GHashTable *hash_table;
gint preview_size;
gint preview_size;
GimpItemGetNameFunc get_name_func;
};
struct _GimpContainerMenuClass
......@@ -72,6 +74,9 @@ struct _GimpContainerMenuClass
void (* activate_item) (GimpContainerMenu *menu,
GimpViewable *object,
gpointer insert_data);
void (* context_item) (GimpContainerMenu *menu,
GimpViewable *object,
gpointer insert_data);
void (* clear_items) (GimpContainerMenu *menu);
void (* set_preview_size) (GimpContainerMenu *menu);
};
......@@ -79,16 +84,21 @@ struct _GimpContainerMenuClass
GtkType gimp_container_menu_get_type (void);
void gimp_container_menu_set_container (GimpContainerMenu *menu,
GimpContainer *container);
void gimp_container_menu_set_context (GimpContainerMenu *menu,
GimpContext *context);
void gimp_container_menu_set_preview_size (GimpContainerMenu *menu,
gint preview_size);
void gimp_container_menu_select_item (GimpContainerMenu *menu,
GimpViewable *viewable);
void gimp_container_menu_activate_item (GimpContainerMenu *menu,
GimpViewable *viewable);
void gimp_container_menu_set_container (GimpContainerMenu *menu,
GimpContainer *container);
void gimp_container_menu_set_context (GimpContainerMenu *menu,
GimpContext *context);
void gimp_container_menu_set_preview_size (GimpContainerMenu *menu,
gint preview_size);
void gimp_container_menu_set_name_func (GimpContainerMenu *menu,
GimpItemGetNameFunc get_name_func);
void gimp_container_menu_select_item (GimpContainerMenu *menu,
GimpViewable *viewable);
void gimp_container_menu_activate_item (GimpContainerMenu *menu,
GimpViewable *viewable);
void gimp_container_menu_context_item (GimpContainerMenu *menu,
GimpViewable *viewable);
/* private */
......@@ -97,6 +107,8 @@ void gimp_container_menu_item_selected (GimpContainerMenu *menu,
GimpViewable *item);
void gimp_container_menu_item_activated (GimpContainerMenu *menu,
GimpViewable *item);
void gimp_container_menu_item_context (GimpContainerMenu *menu,
GimpViewable *item);
#endif /* __GIMP_CONTAINER_MENU_H__ */
......@@ -179,6 +179,9 @@ gimp_container_menu_impl_insert_item (GimpContainerMenu *menu,
menu_item = gimp_menu_item_new (viewable, menu->preview_size);
gimp_menu_item_set_name_func (GIMP_MENU_ITEM (menu_item),
menu->get_name_func);
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
GTK_SIGNAL_FUNC (gimp_container_menu_impl_item_selected),
menu);
......
......@@ -421,9 +421,25 @@ gimp_container_view_set_preview_size (GimpContainerView *view,
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;
if (view->preview_size != preview_size)
{
view->preview_size = preview_size;
gtk_signal_emit (GTK_OBJECT (view), view_signals[SET_PREVIEW_SIZE]);
}
}
gtk_signal_emit (GTK_OBJECT (view), view_signals[SET_PREVIEW_SIZE]);
void
gimp_container_view_set_name_func (GimpContainerView *view,
GimpItemGetNameFunc get_name_func)
{
g_return_if_fail (view != NULL);
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
if (view->get_name_func != get_name_func)
{
view->get_name_func = get_name_func;
}
}
void
......
......@@ -37,14 +37,16 @@ typedef struct _GimpContainerViewClass GimpContainerViewClass;
struct _GimpContainerView
{
GtkVBox parent_instance;
GtkVBox parent_instance;
GimpContainer *container;
GimpContext *context;
GimpContainer *container;
GimpContext *context;
GHashTable *hash_table;
GHashTable *hash_table;
gint preview_size;
gint preview_size;
GimpItemGetNameFunc get_name_func;
};
struct _GimpContainerViewClass
......@@ -85,6 +87,9 @@ 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_set_name_func (GimpContainerView *view,
GimpItemGetNameFunc get_name_func);
void gimp_container_view_select_item (GimpContainerView *view,
GimpViewable *viewable);
void gimp_container_view_activate_item (GimpContainerView *view,
......
......@@ -31,6 +31,8 @@
#include "gimpimagedock.h"
#include "gimpcontainermenuimpl.h"
#include "gimpdockbook.h"
#include "gimpmenuitem.h"
#include "gimppreview.h"
#include "gimpcontainer.h"
#include "gimpcontext.h"
......@@ -142,6 +144,24 @@ gimp_image_dock_destroy (GtkObject *object)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static gchar *
gimp_image_dock_image_name_func (GtkWidget *widget)
{
GimpMenuItem *menu_item;
GimpImage *gimage;
gchar *name;
menu_item = GIMP_MENU_ITEM (widget);
gimage = GIMP_IMAGE (GIMP_PREVIEW (menu_item->preview)->viewable);
name = g_strdup_printf ("%s-%d",
g_basename (gimp_image_filename (gimage)),
gimp_image_get_ID (gimage));
return name;
}
GtkWidget *
gimp_image_dock_new (GimpDialogFactory *factory,
GimpContainer *image_container)
......@@ -183,8 +203,12 @@ gimp_image_dock_new (GimpDialogFactory *factory,
dock,
GTK_OBJECT (dock));
image_dock->menu = gimp_container_menu_new (image_container,
image_dock->menu = gimp_container_menu_new (NULL,
dock->context, 24);
gimp_container_menu_set_name_func (GIMP_CONTAINER_MENU (image_dock->menu),
gimp_image_dock_image_name_func);
gimp_container_menu_set_container (GIMP_CONTAINER_MENU (image_dock->menu),
image_container);
gtk_option_menu_set_menu (GTK_OPTION_MENU (image_dock->option_menu),
image_dock->menu);
gtk_widget_show (image_dock->menu);
......
......@@ -67,7 +67,7 @@ static gboolean gimp_list_item_drag_drop (GtkWidget *widget,
guint time);
static void gimp_list_item_name_changed (GimpViewable *viewable,
GtkLabel *label);
GimpListItem *list_item);
static GimpViewable * gimp_list_item_drag_viewable (GtkWidget *widget,
gpointer data);
......@@ -139,14 +139,15 @@ gimp_list_item_init (GimpListItem *list_item)
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 = NULL;
list_item->name_label = NULL;
list_item->preview_size = 0;
list_item->preview_size = 0;
list_item->reorderable = FALSE;
list_item->drop_type = GIMP_DROP_NONE;
list_item->container = NULL;
list_item->reorderable = FALSE;
list_item->drop_type = GIMP_DROP_NONE;
list_item->container = NULL;
list_item->get_name_func = NULL;
}
static void
......@@ -305,16 +306,17 @@ gimp_list_item_real_set_viewable (GimpListItem *list_item,
FALSE, FALSE, 0);
gtk_widget_show (list_item->preview);
list_item->name_label =
gtk_label_new (gimp_object_get_name (GIMP_OBJECT (viewable)));
list_item->name_label = gtk_label_new (NULL);
gtk_box_pack_start (GTK_BOX (list_item->hbox), list_item->name_label,
FALSE, FALSE, 0);
gtk_widget_show (list_item->name_label);
gimp_list_item_name_changed (viewable, list_item);
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));
list_item,
GTK_OBJECT (list_item));
gimp_gtk_drag_source_set_by_type (GTK_WIDGET (list_item),
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
......@@ -356,6 +358,26 @@ gimp_list_item_set_reorderable (GimpListItem *list_item,
}
}
void
gimp_list_item_set_name_func (GimpListItem *list_item,
GimpItemGetNameFunc get_name_func)
{
g_return_if_fail (list_item != NULL);
g_return_if_fail (GIMP_IS_LIST_ITEM (list_item));
if (list_item->get_name_func != get_name_func)
{
GimpViewable *viewable;
list_item->get_name_func = get_name_func;
viewable = GIMP_PREVIEW (list_item->preview)->viewable;
if (viewable)
gimp_list_item_name_changed (viewable, list_item);
}
}
gboolean
gimp_list_item_check_drag (GimpListItem *list_item,
GdkDragContext *context,
......@@ -468,9 +490,23 @@ gimp_list_item_button_state_changed (GtkWidget *widget,
static void
gimp_list_item_name_changed (GimpViewable *viewable,
GtkLabel *label)
GimpListItem *list_item)
{
gtk_label_set_text (label, gimp_object_get_name (GIMP_OBJECT (viewable)));
if (list_item->get_name_func)
{
gchar *name;
name = list_item->get_name_func (GTK_WIDGET (list_item));
gtk_label_set_text (GTK_LABEL (list_item->name_label), name);
g_free (name);
}
else
{
gtk_label_set_text (GTK_LABEL (list_item->name_label),
gimp_object_get_name (GIMP_OBJECT (viewable)));
}
}
static GimpViewable *
......
......@@ -42,20 +42,21 @@ typedef struct _GimpListItemClass GimpListItemClass;
struct _GimpListItem
{
GtkListItem parent_instance;
GtkListItem parent_instance;
GtkWidget *hbox;