added a GimpItemFactory to the GimpEditor struct. Added

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

	* app/widgets/gimpeditor.[ch]: added a GimpItemFactory to the
	GimpEditor struct. Added gimp_editor_create_menu().

	* app/widgets/gimpcolormapeditor.[ch]
	* app/widgets/gimpcomponenteditor.[ch]
	* app/widgets/gimpcontainereditor.[ch]
	* app/widgets/gimpdataeditor.[ch]
	* app/widgets/gimpitemtreeview.[ch]: removed item_factory pointers
	and lots of inalizers which just unref'ed the item_factory.  Use
	gimp_editor_create_menu() instead.

	* app/widgets/gimpchanneltreeview.c
	* app/widgets/gimpgradienteditor.c
	* app/widgets/gimppaletteeditor.c: changed accordingly.
This commit is contained in:
Michael Natterer 2003-03-21 11:47:37 +00:00 committed by Michael Natterer
parent 952e142965
commit 7f613b4783
16 changed files with 113 additions and 137 deletions

View File

@ -1,3 +1,20 @@
2003-03-21 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpeditor.[ch]: added a GimpItemFactory to the
GimpEditor struct. Added gimp_editor_create_menu().
* app/widgets/gimpcolormapeditor.[ch]
* app/widgets/gimpcomponenteditor.[ch]
* app/widgets/gimpcontainereditor.[ch]
* app/widgets/gimpdataeditor.[ch]
* app/widgets/gimpitemtreeview.[ch]: removed item_factory pointers
and lots of inalizers which just unref'ed the item_factory. Use
gimp_editor_create_menu() instead.
* app/widgets/gimpchanneltreeview.c
* app/widgets/gimpgradienteditor.c
* app/widgets/gimppaletteeditor.c: changed accordingly.
2003-03-20 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/gimpdialog.c: implement GtkDialog::close() and

View File

@ -176,7 +176,7 @@ gimp_channel_tree_view_set_image (GimpItemTreeView *item_view,
{
channel_view->component_editor =
gimp_component_editor_new (GIMP_CONTAINER_VIEW (item_view)->preview_size,
item_view->menu_factory);
GIMP_EDITOR (item_view)->menu_factory);
gtk_box_pack_start (GTK_BOX (item_view), channel_view->component_editor,
FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (item_view),

View File

@ -216,12 +216,6 @@ gimp_colormap_editor_destroy (GtkObject *object)
editor = GIMP_COLORMAP_EDITOR (object);
if (editor->item_factory)
{
g_object_unref (editor->item_factory);
editor->item_factory = NULL;
}
if (editor->color_notebook)
{
color_notebook_free (editor->color_notebook);
@ -318,11 +312,8 @@ gimp_colormap_editor_new (GimpImage *gimage,
editor = g_object_new (GIMP_TYPE_COLORMAP_EDITOR, NULL);
editor->item_factory = gimp_menu_factory_menu_new (menu_factory,
"<ColormapEditor>",
GTK_TYPE_MENU,
editor,
FALSE);
gimp_editor_create_menu (GIMP_EDITOR (editor),
menu_factory, "<ColormapEditor>", editor);
/* The palette frame */
frame = gtk_frame_new (NULL);
@ -757,7 +748,8 @@ gimp_colormap_preview_button_press (GtkWidget *widget,
case 3:
gimp_colormap_editor_set_index (editor, col);
gimp_item_factory_popup_with_data (editor->item_factory, editor, NULL);
gimp_item_factory_popup_with_data (GIMP_EDITOR (editor)->item_factory,
editor, NULL);
return TRUE;
default:

View File

@ -39,8 +39,6 @@ struct _GimpColormapEditor
{
GimpImageEditor parent_instance;
GimpItemFactory *item_factory;
gint col_index;
gint dnd_col_index;
GtkWidget *palette;

View File

@ -54,7 +54,6 @@ enum
static void gimp_component_editor_class_init (GimpComponentEditorClass *klass);
static void gimp_component_editor_init (GimpComponentEditor *editor);
static void gimp_component_editor_finalize (GObject *object);
static void gimp_component_editor_set_image (GimpImageEditor *editor,
GimpImage *gimage);
@ -120,16 +119,12 @@ gimp_component_editor_get_type (void)
static void
gimp_component_editor_class_init (GimpComponentEditorClass *klass)
{
GObjectClass *object_class;
GimpImageEditorClass *image_editor_class;
object_class = G_OBJECT_CLASS (klass);
image_editor_class = GIMP_IMAGE_EDITOR_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_component_editor_finalize;
image_editor_class->set_image = gimp_component_editor_set_image;
}
@ -197,22 +192,6 @@ gimp_component_editor_init (GimpComponentEditor *editor)
editor, NULL);
}
static void
gimp_component_editor_finalize (GObject *object)
{
GimpComponentEditor *editor;
editor = GIMP_COMPONENT_EDITOR (object);
if (editor->item_factory)
{
g_object_unref (editor->item_factory);
editor->item_factory = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_component_editor_set_image (GimpImageEditor *editor,
GimpImage *gimage)
@ -274,11 +253,8 @@ gimp_component_editor_new (gint preview_size,
gimp_component_editor_set_preview_size (editor, preview_size);
editor->item_factory = gimp_menu_factory_menu_new (menu_factory,
"<Channels>",
GTK_TYPE_MENU,
editor,
FALSE);
gimp_editor_create_menu (GIMP_EDITOR (editor),
menu_factory, "<Channels>", editor);
return GTK_WIDGET (editor);
}
@ -514,7 +490,7 @@ gimp_component_editor_button_press (GtkWidget *widget,
break;
case 3:
gimp_item_factory_popup_with_data (editor->item_factory,
gimp_item_factory_popup_with_data (GIMP_EDITOR (editor)->item_factory,
editor,
NULL);
break;

View File

@ -41,7 +41,6 @@ struct _GimpComponentEditor
GimpImageEditor parent_instance;
gint preview_size;
GimpItemFactory *item_factory;
GtkTreeModel *model;
GtkTreeView *view;

View File

@ -41,8 +41,6 @@
static void gimp_container_editor_class_init (GimpContainerEditorClass *klass);
static void gimp_container_editor_init (GimpContainerEditor *view);
static void gimp_container_editor_finalize (GObject *object);
static void gimp_container_editor_select_item (GtkWidget *widget,
GimpViewable *viewable,
gpointer insert_data,
@ -93,14 +91,8 @@ gimp_container_editor_get_type (void)
static void
gimp_container_editor_class_init (GimpContainerEditorClass *klass)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_container_editor_finalize;
klass->select_item = NULL;
klass->activate_item = NULL;
klass->context_item = gimp_container_editor_real_context_item;
@ -109,24 +101,7 @@ gimp_container_editor_class_init (GimpContainerEditorClass *klass)
static void
gimp_container_editor_init (GimpContainerEditor *view)
{
view->item_factory = NULL;
view->view = NULL;
}
static void
gimp_container_editor_finalize (GObject *object)
{
GimpContainerEditor *editor;
editor = GIMP_CONTAINER_EDITOR (object);
if (editor->item_factory)
{
g_object_unref (editor->item_factory);
editor->item_factory = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
view->view = NULL;
}
gboolean
@ -152,12 +127,6 @@ gimp_container_editor_construct (GimpContainerEditor *editor,
g_return_val_if_fail (min_items_x > 0 && min_items_x <= 64, FALSE);
g_return_val_if_fail (min_items_y > 0 && min_items_y <= 64, FALSE);
editor->item_factory = gimp_menu_factory_menu_new (menu_factory,
menu_identifier,
GTK_TYPE_MENU,
editor,
FALSE);
switch (view_type)
{
case GIMP_VIEW_TYPE_GRID:
@ -185,6 +154,9 @@ gimp_container_editor_construct (GimpContainerEditor *editor,
return FALSE;
}
gimp_editor_create_menu (GIMP_EDITOR (editor->view),
menu_factory, menu_identifier, editor);
gtk_container_add (GTK_CONTAINER (editor), GTK_WIDGET (editor->view));
gtk_widget_show (GTK_WIDGET (editor->view));
@ -258,11 +230,11 @@ gimp_container_editor_real_context_item (GimpContainerEditor *editor,
if (viewable && gimp_container_have (editor->view->container,
GIMP_OBJECT (viewable)))
{
if (editor->item_factory)
{
gimp_item_factory_popup_with_data (editor->item_factory,
editor,
NULL);
}
GimpItemFactory *item_factory;
item_factory = GIMP_EDITOR (editor->view)->item_factory;
if (item_factory)
gimp_item_factory_popup_with_data (item_factory, editor, NULL);
}
}

View File

@ -40,7 +40,6 @@ struct _GimpContainerEditor
{
GtkVBox parent_instance;
GimpItemFactory *item_factory;
GimpContainerView *view;
};

View File

@ -112,7 +112,6 @@ gimp_data_editor_init (GimpDataEditor *editor)
editor->data_type = G_TYPE_NONE;
editor->data = NULL;
editor->data_editable = FALSE;
editor->item_factory = NULL;
editor->name_entry = gtk_entry_new ();
gtk_box_pack_start (GTK_BOX (editor), editor->name_entry,
@ -153,12 +152,6 @@ gimp_data_editor_dispose (GObject *object)
if (editor->data)
gimp_data_editor_set_data (editor, NULL);
if (editor->item_factory)
{
g_object_unref (editor->item_factory);
editor->item_factory = NULL;
}
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@ -221,11 +214,8 @@ gimp_data_editor_construct (GimpDataEditor *editor,
editor->data_type = data_type;
if (menu_factory && menu_identifier)
editor->item_factory = gimp_menu_factory_menu_new (menu_factory,
menu_identifier,
GTK_TYPE_MENU,
editor,
FALSE);
gimp_editor_create_menu (GIMP_EDITOR (editor),
menu_factory, menu_identifier, editor);
data = (GimpData *)
gimp_context_get_by_type (gimp_get_user_context (gimp), data_type);
@ -240,14 +230,12 @@ gimp_data_editor_set_data (GimpDataEditor *editor,
GimpData *data)
{
g_return_if_fail (GIMP_IS_DATA_EDITOR (editor));
g_return_if_fail (! data || GIMP_IS_DATA (data));
g_return_if_fail (! data || g_type_is_a (G_TYPE_FROM_INSTANCE (data),
editor->data_type));
g_return_if_fail (data == NULL || GIMP_IS_DATA (data));
g_return_if_fail (data == NULL || g_type_is_a (G_TYPE_FROM_INSTANCE (data),
editor->data_type));
if (editor->data != data)
{
GIMP_DATA_EDITOR_GET_CLASS (editor)->set_data (editor, data);
}
GIMP_DATA_EDITOR_GET_CLASS (editor)->set_data (editor, data);
}
GimpData *

View File

@ -46,8 +46,6 @@ struct _GimpDataEditor
GimpData *data;
gboolean data_editable;
GimpItemFactory *item_factory;
GtkWidget *name_entry;
GtkWidget *save_button;

View File

@ -29,6 +29,7 @@
#include "gimpeditor.h"
#include "gimpdnd.h"
#include "gimpmenufactory.h"
#define DEFAULT_CONTENT_SPACING 2
@ -39,6 +40,7 @@
static void gimp_editor_class_init (GimpEditorClass *klass);
static void gimp_editor_init (GimpEditor *panel);
static void gimp_editor_destroy (GtkObject *object);
static void gimp_editor_style_set (GtkWidget *widget,
GtkStyle *prev_style);
@ -77,12 +79,16 @@ gimp_editor_get_type (void)
static void
gimp_editor_class_init (GimpEditorClass *klass)
{
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = GTK_OBJECT_CLASS (klass);
widget_class = GTK_WIDGET_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->destroy = gimp_editor_destroy;
widget_class->style_set = gimp_editor_style_set;
gtk_widget_class_install_style_property (widget_class,
@ -112,6 +118,25 @@ gimp_editor_class_init (GimpEditorClass *klass)
static void
gimp_editor_init (GimpEditor *editor)
{
editor->menu_factory = NULL;
editor->item_factory = NULL;
editor->button_box = NULL;
}
static void
gimp_editor_destroy (GtkObject *object)
{
GimpEditor *editor;
editor = GIMP_EDITOR (object);
if (editor->item_factory)
{
g_object_unref (editor->item_factory);
editor->item_factory = NULL;
}
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
@ -172,6 +197,27 @@ gimp_editor_new (void)
return GTK_WIDGET (editor);
}
void
gimp_editor_create_menu (GimpEditor *editor,
GimpMenuFactory *menu_factory,
const gchar *menu_identifier,
gpointer callback_data)
{
g_return_if_fail (GIMP_IS_EDITOR (editor));
g_return_if_fail (GIMP_IS_MENU_FACTORY (menu_factory));
g_return_if_fail (menu_identifier != NULL);
if (editor->item_factory)
g_object_unref (editor->item_factory);
editor->menu_factory = menu_factory;
editor->item_factory = gimp_menu_factory_menu_new (menu_factory,
menu_identifier,
GTK_TYPE_MENU,
callback_data,
FALSE);
}
GtkWidget *
gimp_editor_add_button (GimpEditor *editor,
const gchar *stock_id,

View File

@ -38,9 +38,12 @@ typedef struct _GimpEditorClass GimpEditorClass;
struct _GimpEditor
{
GtkVBox parent_instance;
GtkVBox parent_instance;
GtkWidget *button_box;
GimpMenuFactory *menu_factory;
GimpItemFactory *item_factory;
GtkWidget *button_box;
};
struct _GimpEditorClass
@ -51,15 +54,20 @@ struct _GimpEditorClass
GType gimp_editor_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_editor_new (void);
GtkWidget * gimp_editor_new (void);
GtkWidget * gimp_editor_add_button (GimpEditor *editor,
const gchar *stock_id,
const gchar *tooltip,
const gchar *help_data,
GCallback callback,
GCallback extended_callback,
gpointer callback_data);
void gimp_editor_create_menu (GimpEditor *editor,
GimpMenuFactory *menu_factory,
const gchar *menu_identifier,
gpointer callback_data);
GtkWidget * gimp_editor_add_button (GimpEditor *editor,
const gchar *stock_id,
const gchar *tooltip,
const gchar *help_data,
GCallback callback,
GCallback extended_callback,
gpointer callback_data);
#endif /* __GIMP_EDITOR_H__ */

View File

@ -710,7 +710,7 @@ preview_events (GtkWidget *widget,
case 3:
if (GIMP_DATA_EDITOR (editor)->data_editable)
gimp_item_factory_popup_with_data (GIMP_DATA_EDITOR (editor)->item_factory,
gimp_item_factory_popup_with_data (GIMP_EDITOR (editor)->item_factory,
editor, NULL);
break;
@ -1145,12 +1145,8 @@ control_button_press (GimpGradientEditor *editor,
if (button == 3)
{
GimpItemFactory *factory;
factory = GIMP_DATA_EDITOR (editor)->item_factory;
gimp_item_factory_popup_with_data (factory, editor, NULL);
gimp_item_factory_popup_with_data (GIMP_EDITOR (editor)->item_factory,
editor, NULL);
return;
}

View File

@ -332,12 +332,6 @@ gimp_item_tree_view_destroy (GtkObject *object)
view->signal_name = NULL;
}
if (view->item_factory)
{
g_object_unref (view->item_factory);
view->item_factory = NULL;
}
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
@ -403,12 +397,8 @@ gimp_item_tree_view_new (gint preview_size,
item_view->edit_item_func = edit_item_func;
item_view->activate_item_func = activate_item_func;
item_view->menu_factory = menu_factory;
item_view->item_factory = gimp_menu_factory_menu_new (menu_factory,
menu_identifier,
GTK_TYPE_MENU,
item_view,
FALSE);
gimp_editor_create_menu (GIMP_EDITOR (item_view),
menu_factory, menu_identifier, item_view);
/* connect "drop to new" manually as it makes a difference whether
* it was clicked or dropped
@ -582,8 +572,8 @@ gimp_item_tree_view_context_item (GimpContainerView *view,
item_view = GIMP_ITEM_TREE_VIEW (view);
if (item_view->item_factory)
gimp_item_factory_popup_with_data (item_view->item_factory,
if (GIMP_EDITOR (item_view)->item_factory)
gimp_item_factory_popup_with_data (GIMP_EDITOR (item_view)->item_factory,
item_view,
NULL);
}

View File

@ -73,9 +73,6 @@ struct _GimpItemTreeView
GimpEditItemFunc edit_item_func;
GimpActivateItemFunc activate_item_func;
GimpMenuFactory *menu_factory;
GimpItemFactory *item_factory;
GtkWidget *new_button;
GtkWidget *raise_button;
GtkWidget *lower_button;

View File

@ -458,7 +458,7 @@ palette_editor_eventbox_button_press (GtkWidget *widget,
{
if (bevent->button == 3 && GIMP_DATA_EDITOR (editor)->data_editable)
{
gimp_item_factory_popup_with_data (GIMP_DATA_EDITOR (editor)->item_factory,
gimp_item_factory_popup_with_data (GIMP_EDITOR (editor)->item_factory,
editor, NULL);
}