mirror of https://github.com/GNOME/gimp.git
app/gimpcontainerlistview.[ch] app/gimpcontainerview.[ch] moved the signal
2001-02-05 Michael Natterer <mitch@gimp.org> * app/gimpcontainerlistview.[ch] * app/gimpcontainerview.[ch] * app/gimpmarshal.[ch]: moved the signal connecting stuff to the GimpContainerViewClass which has virtual functions for insert, remove and clear now which are implemented by the GimpContainerListViewClass.
This commit is contained in:
parent
2e464cf5e6
commit
359e141fc0
|
@ -1,3 +1,12 @@
|
|||
2001-02-05 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/gimpcontainerlistview.[ch]
|
||||
* app/gimpcontainerview.[ch]
|
||||
* app/gimpmarshal.[ch]: moved the signal connecting stuff to the
|
||||
GimpContainerViewClass which has virtual functions for insert,
|
||||
remove and clear now which are implemented by the
|
||||
GimpContainerListViewClass.
|
||||
|
||||
2001-02-05 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/gimpcontainer.[ch]
|
||||
|
|
|
@ -115,6 +115,25 @@ gimp_marshal_POINTER__INT (GtkObject *object,
|
|||
}
|
||||
|
||||
|
||||
typedef gpointer (* GimpSignal_POINTER__INT_INT) (GtkObject *object,
|
||||
gint arg1,
|
||||
gint arg2,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
gimp_marshal_POINTER__INT_INT (GtkObject *object,
|
||||
GtkSignalFunc func,
|
||||
gpointer func_data,
|
||||
GtkArg *args)
|
||||
{
|
||||
*GTK_RETLOC_POINTER (args[2]) =
|
||||
(* (GimpSignal_POINTER__INT_INT) func) (object,
|
||||
GTK_VALUE_INT (args[0]),
|
||||
GTK_VALUE_INT (args[1]),
|
||||
func_data);
|
||||
}
|
||||
|
||||
|
||||
typedef gpointer (* GimpSignal_POINTER__POINTER) (GtkObject *object,
|
||||
gpointer arg1,
|
||||
gpointer user_data);
|
||||
|
@ -132,22 +151,22 @@ gimp_marshal_POINTER__POINTER (GtkObject *object,
|
|||
}
|
||||
|
||||
|
||||
typedef gpointer (* GimpSignal_POINTER__INT_INT) (GtkObject *object,
|
||||
gint arg1,
|
||||
gint arg2,
|
||||
gpointer user_data);
|
||||
typedef gpointer (* GimpSignal_POINTER__POINTER_INT) (GtkObject *object,
|
||||
gpointer arg1,
|
||||
gint arg2,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
gimp_marshal_POINTER__INT_INT (GtkObject *object,
|
||||
GtkSignalFunc func,
|
||||
gpointer func_data,
|
||||
GtkArg *args)
|
||||
gimp_marshal_POINTER__POINTER_INT (GtkObject *object,
|
||||
GtkSignalFunc func,
|
||||
gpointer func_data,
|
||||
GtkArg *args)
|
||||
{
|
||||
*GTK_RETLOC_POINTER (args[2]) =
|
||||
(* (GimpSignal_POINTER__INT_INT) func) (object,
|
||||
GTK_VALUE_INT (args[0]),
|
||||
GTK_VALUE_INT (args[1]),
|
||||
func_data);
|
||||
(* (GimpSignal_POINTER__POINTER_INT) func) (object,
|
||||
GTK_VALUE_POINTER (args[0]),
|
||||
GTK_VALUE_INT (args[1]),
|
||||
func_data);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -45,12 +45,17 @@ void gimp_marshal_POINTER__INT (GtkObject *object,
|
|||
gpointer func_data,
|
||||
GtkArg *args);
|
||||
|
||||
void gimp_marshal_POINTER__INT_INT (GtkObject *object,
|
||||
GtkSignalFunc func,
|
||||
gpointer func_data,
|
||||
GtkArg *args);
|
||||
|
||||
void gimp_marshal_POINTER__POINTER (GtkObject *object,
|
||||
GtkSignalFunc func,
|
||||
gpointer func_data,
|
||||
GtkArg *args);
|
||||
|
||||
void gimp_marshal_POINTER__INT_INT (GtkObject *object,
|
||||
void gimp_marshal_POINTER__POINTER_INT (GtkObject *object,
|
||||
GtkSignalFunc func,
|
||||
gpointer func_data,
|
||||
GtkArg *args);
|
||||
|
|
|
@ -31,20 +31,20 @@
|
|||
#include "gimppreview.h"
|
||||
|
||||
|
||||
static void gimp_container_list_view_class_init (GimpContainerListViewClass *klass);
|
||||
static void gimp_container_list_view_init (GimpContainerListView *panel);
|
||||
static void gimp_container_list_view_destroy (GtkObject *object);
|
||||
static void gimp_container_list_view_class_init (GimpContainerListViewClass *klass);
|
||||
static void gimp_container_list_view_init (GimpContainerListView *panel);
|
||||
static void gimp_container_list_view_destroy (GtkObject *object);
|
||||
|
||||
static void gimp_container_list_view_add_foreach (GimpViewable *viewable,
|
||||
GimpContainerListView *list_view);
|
||||
static void gimp_container_list_view_add (GimpContainerListView *list_view,
|
||||
GimpViewable *viewable,
|
||||
GimpContainer *container);
|
||||
static void gimp_container_list_view_remove (GimpContainerListView *list_view,
|
||||
GimpViewable *viewable,
|
||||
GimpContainer *container);
|
||||
static void gimp_container_list_view_name_changed (GimpContainerListView *list_view,
|
||||
GimpViewable *viewable);
|
||||
static gpointer gimp_container_list_view_insert_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gint index);
|
||||
static void gimp_container_list_view_remove_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer insert_data);
|
||||
static void gimp_container_list_view_clear_items (GimpContainerView *view);
|
||||
|
||||
static void gimp_container_list_view_name_changed (GimpContainerListView *list_view,
|
||||
GimpViewable *viewable);
|
||||
|
||||
|
||||
static GimpContainerViewClass *parent_class = NULL;
|
||||
|
@ -88,6 +88,10 @@ gimp_container_list_view_class_init (GimpContainerListViewClass *klass)
|
|||
parent_class = gtk_type_class (GIMP_TYPE_CONTAINER_VIEW);
|
||||
|
||||
object_class->destroy = gimp_container_list_view_destroy;
|
||||
|
||||
container_view_class->insert_item = gimp_container_list_view_insert_item;
|
||||
container_view_class->remove_item = gimp_container_list_view_remove_item;
|
||||
container_view_class->clear_items = gimp_container_list_view_clear_items;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -114,8 +118,6 @@ gimp_container_list_view_init (GimpContainerListView *list_view)
|
|||
|
||||
gtk_widget_show (list_view->gtk_list);
|
||||
gtk_widget_show (scrolled_win);
|
||||
|
||||
list_view->hash_table = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -125,8 +127,6 @@ gimp_container_list_view_destroy (GtkObject *object)
|
|||
|
||||
list_view = GIMP_CONTAINER_LIST_VIEW (object);
|
||||
|
||||
g_hash_table_destroy (list_view->hash_table);
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
@ -144,38 +144,27 @@ gimp_container_list_view_new (GimpContainer *container)
|
|||
|
||||
view = GIMP_CONTAINER_VIEW (list_view);
|
||||
|
||||
view->container = container;
|
||||
|
||||
gimp_container_foreach (container,
|
||||
(GFunc) gimp_container_list_view_add_foreach,
|
||||
list_view);
|
||||
|
||||
gtk_signal_connect_object_while_alive (GTK_OBJECT (container), "add",
|
||||
GTK_SIGNAL_FUNC (gimp_container_list_view_add),
|
||||
GTK_OBJECT (list_view));
|
||||
|
||||
gtk_signal_connect_object_while_alive (GTK_OBJECT (container), "remove",
|
||||
GTK_SIGNAL_FUNC (gimp_container_list_view_remove),
|
||||
GTK_OBJECT (list_view));
|
||||
gimp_container_view_set_container (view, container);
|
||||
|
||||
return GTK_WIDGET (list_view);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_list_view_insert (GimpContainerListView *list_view,
|
||||
GimpViewable *viewable,
|
||||
gint index)
|
||||
static gpointer
|
||||
gimp_container_list_view_insert_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gint index)
|
||||
{
|
||||
GtkWidget *list_item;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *preview;
|
||||
GtkWidget *label;
|
||||
GList *list;
|
||||
GimpContainerListView *list_view;
|
||||
GtkWidget *list_item;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *preview;
|
||||
GtkWidget *label;
|
||||
GList *list;
|
||||
|
||||
list_view = GIMP_CONTAINER_LIST_VIEW (view);
|
||||
|
||||
list_item = gtk_list_item_new ();
|
||||
|
||||
g_hash_table_insert (list_view->hash_table, viewable, list_item);
|
||||
|
||||
gtk_signal_connect_object_while_alive (GTK_OBJECT (viewable), "name_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_container_list_view_name_changed),
|
||||
GTK_OBJECT (list_view));
|
||||
|
@ -206,36 +195,19 @@ gimp_container_list_view_insert (GimpContainerListView *list_view,
|
|||
else
|
||||
gtk_list_insert_items (GTK_LIST (list_view->gtk_list), list, index);
|
||||
|
||||
return (gpointer) list_item;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_list_view_add_foreach (GimpViewable *viewable,
|
||||
GimpContainerListView *list_view)
|
||||
gimp_container_list_view_remove_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer insert_data)
|
||||
{
|
||||
gimp_container_list_view_insert (list_view, viewable, -1);
|
||||
}
|
||||
GimpContainerListView *list_view;
|
||||
GtkWidget *list_item;
|
||||
|
||||
static void
|
||||
gimp_container_list_view_add (GimpContainerListView *list_view,
|
||||
GimpViewable *viewable,
|
||||
GimpContainer *container)
|
||||
{
|
||||
gint index;
|
||||
|
||||
index = gimp_container_get_child_index (container,
|
||||
GIMP_OBJECT (viewable));
|
||||
|
||||
gimp_container_list_view_insert (list_view, viewable, index);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_list_view_remove (GimpContainerListView *list_view,
|
||||
GimpViewable *viewable,
|
||||
GimpContainer *container)
|
||||
{
|
||||
GtkWidget *list_item;
|
||||
|
||||
list_item = g_hash_table_lookup (list_view->hash_table, viewable);
|
||||
list_view = GIMP_CONTAINER_LIST_VIEW (view);
|
||||
list_item = GTK_WIDGET (insert_data);
|
||||
|
||||
if (list_item)
|
||||
{
|
||||
|
@ -244,18 +216,27 @@ gimp_container_list_view_remove (GimpContainerListView *list_view,
|
|||
list = g_list_prepend (NULL, list_item);
|
||||
|
||||
gtk_list_remove_items (GTK_LIST (list_view->gtk_list), list);
|
||||
|
||||
g_hash_table_remove (list_view->hash_table, viewable);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_list_view_clear_items (GimpContainerView *view)
|
||||
{
|
||||
GimpContainerListView *list_view;
|
||||
|
||||
list_view = GIMP_CONTAINER_LIST_VIEW (view);
|
||||
|
||||
gtk_list_clear_items (GTK_LIST (list_view->gtk_list), 0, -1);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_list_view_name_changed (GimpContainerListView *list_view,
|
||||
GimpViewable *viewable)
|
||||
{
|
||||
GtkWidget *list_item;
|
||||
|
||||
list_item = g_hash_table_lookup (list_view->hash_table, viewable);
|
||||
list_item = g_hash_table_lookup (GIMP_CONTAINER_VIEW (list_view)->hash_table,
|
||||
viewable);
|
||||
|
||||
if (list_item)
|
||||
{
|
||||
|
|
|
@ -37,7 +37,6 @@ struct _GimpContainerListView
|
|||
GimpContainerView parent_instance;
|
||||
|
||||
GtkWidget *gtk_list;
|
||||
GHashTable *hash_table; /* container child --> list item mapping */
|
||||
};
|
||||
|
||||
struct _GimpContainerListViewClass
|
||||
|
|
|
@ -18,21 +18,42 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "appenv.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimpcontainerview.h"
|
||||
#include "gimpmarshal.h"
|
||||
|
||||
|
||||
static void gimp_container_view_class_init (GimpContainerViewClass *klass);
|
||||
static void gimp_container_view_init (GimpContainerView *panel);
|
||||
static void gimp_container_view_destroy (GtkObject *object);
|
||||
enum
|
||||
{
|
||||
INSERT_ITEM,
|
||||
REMOVE_ITEM,
|
||||
CLEAR_ITEMS,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
||||
static void gimp_container_view_class_init (GimpContainerViewClass *klass);
|
||||
static void gimp_container_view_init (GimpContainerView *panel);
|
||||
static void gimp_container_view_destroy (GtkObject *object);
|
||||
|
||||
static void gimp_container_view_clear (GimpContainerView *view);
|
||||
|
||||
static void gimp_container_view_add_foreach (GimpViewable *viewable,
|
||||
GimpContainerView *view);
|
||||
static void gimp_container_view_add (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
GimpContainer *container);
|
||||
static void gimp_container_view_remove (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
GimpContainer *container);
|
||||
|
||||
|
||||
static guint view_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static GtkVBoxClass *parent_class = NULL;
|
||||
|
||||
|
||||
|
@ -70,13 +91,47 @@ gimp_container_view_class_init (GimpContainerViewClass *klass)
|
|||
|
||||
parent_class = gtk_type_class (GTK_TYPE_VBOX);
|
||||
|
||||
view_signals[INSERT_ITEM] =
|
||||
gtk_signal_new ("insert_item",
|
||||
GTK_RUN_LAST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpContainerViewClass,
|
||||
insert_item),
|
||||
gimp_marshal_POINTER__POINTER_INT,
|
||||
GTK_TYPE_POINTER, 2,
|
||||
GIMP_TYPE_OBJECT,
|
||||
GTK_TYPE_INT);
|
||||
|
||||
view_signals[REMOVE_ITEM] =
|
||||
gtk_signal_new ("remove_item",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpContainerViewClass,
|
||||
remove_item),
|
||||
gtk_marshal_NONE__POINTER_POINTER,
|
||||
GTK_TYPE_NONE, 2,
|
||||
GIMP_TYPE_OBJECT,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
view_signals[CLEAR_ITEMS] =
|
||||
gtk_signal_new ("clear_items",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpContainerViewClass,
|
||||
clear_items),
|
||||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
gtk_object_class_add_signals (object_class, view_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gimp_container_view_destroy;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_view_init (GimpContainerView *view)
|
||||
{
|
||||
view->container = NULL;
|
||||
view->container = NULL;
|
||||
view->hash_table = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -85,7 +140,107 @@ gimp_container_view_destroy (GtkObject *object)
|
|||
GimpContainerView *view;
|
||||
|
||||
view = GIMP_CONTAINER_VIEW (object);
|
||||
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_container_view_set_container (GimpContainerView *view,
|
||||
GimpContainer *container)
|
||||
{
|
||||
g_return_if_fail (view != NULL);
|
||||
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
|
||||
g_return_if_fail (!container || GIMP_IS_CONTAINER (container));
|
||||
|
||||
if (container == view->container)
|
||||
return;
|
||||
|
||||
if (view->container)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (container),
|
||||
gimp_container_view_add,
|
||||
view);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (container),
|
||||
gimp_container_view_remove,
|
||||
view);
|
||||
|
||||
g_hash_table_destroy (view->hash_table);
|
||||
|
||||
gimp_container_view_clear (view);
|
||||
}
|
||||
|
||||
view->container = container;
|
||||
|
||||
if (view->container)
|
||||
{
|
||||
view->hash_table = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
|
||||
gimp_container_foreach (container,
|
||||
(GFunc) gimp_container_view_add_foreach,
|
||||
view);
|
||||
|
||||
gtk_signal_connect_object_while_alive
|
||||
(GTK_OBJECT (container), "add",
|
||||
GTK_SIGNAL_FUNC (gimp_container_view_add),
|
||||
GTK_OBJECT (view));
|
||||
|
||||
gtk_signal_connect_object_while_alive
|
||||
(GTK_OBJECT (container), "remove",
|
||||
GTK_SIGNAL_FUNC (gimp_container_view_remove),
|
||||
GTK_OBJECT (view));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_view_clear (GimpContainerView *view)
|
||||
{
|
||||
gtk_signal_emit (GTK_OBJECT (view), view_signals[CLEAR_ITEMS]);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_view_add_foreach (GimpViewable *viewable,
|
||||
GimpContainerView *view)
|
||||
{
|
||||
gpointer insert_data = NULL;
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (view), view_signals[INSERT_ITEM],
|
||||
viewable, -1, &insert_data);
|
||||
|
||||
g_hash_table_insert (view->hash_table, viewable, insert_data);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_view_add (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
GimpContainer *container)
|
||||
{
|
||||
gpointer insert_data = NULL;
|
||||
gint index;
|
||||
|
||||
index = gimp_container_get_child_index (container,
|
||||
GIMP_OBJECT (viewable));
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (view), view_signals[INSERT_ITEM],
|
||||
viewable, index, &insert_data);
|
||||
|
||||
g_hash_table_insert (view->hash_table, viewable, insert_data);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_view_remove (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
GimpContainer *container)
|
||||
{
|
||||
gpointer insert_data;
|
||||
|
||||
insert_data = g_hash_table_lookup (view->hash_table, viewable);
|
||||
|
||||
if (insert_data)
|
||||
{
|
||||
g_hash_table_remove (view->hash_table, viewable);
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (view), view_signals[REMOVE_ITEM],
|
||||
viewable, insert_data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,15 +38,28 @@ struct _GimpContainerView
|
|||
GtkVBox parent_instance;
|
||||
|
||||
GimpContainer *container;
|
||||
|
||||
GHashTable *hash_table;
|
||||
};
|
||||
|
||||
struct _GimpContainerViewClass
|
||||
{
|
||||
GtkVBoxClass parent_class;
|
||||
|
||||
gpointer (* insert_item) (GimpContainerView *view,
|
||||
GimpViewable *object,
|
||||
gint index);
|
||||
void (* remove_item) (GimpContainerView *view,
|
||||
GimpViewable *object,
|
||||
gpointer insert_data);
|
||||
void (* clear_items) (GimpContainerView *view);
|
||||
};
|
||||
|
||||
|
||||
GtkType gimp_container_view_get_type (void);
|
||||
GtkType gimp_container_view_get_type (void);
|
||||
|
||||
void gimp_container_view_set_container (GimpContainerView *view,
|
||||
GimpContainer *container);
|
||||
|
||||
|
||||
#endif /* __GIMP_CONTAINER_VIEW_H__ */
|
||||
|
|
|
@ -115,6 +115,25 @@ gimp_marshal_POINTER__INT (GtkObject *object,
|
|||
}
|
||||
|
||||
|
||||
typedef gpointer (* GimpSignal_POINTER__INT_INT) (GtkObject *object,
|
||||
gint arg1,
|
||||
gint arg2,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
gimp_marshal_POINTER__INT_INT (GtkObject *object,
|
||||
GtkSignalFunc func,
|
||||
gpointer func_data,
|
||||
GtkArg *args)
|
||||
{
|
||||
*GTK_RETLOC_POINTER (args[2]) =
|
||||
(* (GimpSignal_POINTER__INT_INT) func) (object,
|
||||
GTK_VALUE_INT (args[0]),
|
||||
GTK_VALUE_INT (args[1]),
|
||||
func_data);
|
||||
}
|
||||
|
||||
|
||||
typedef gpointer (* GimpSignal_POINTER__POINTER) (GtkObject *object,
|
||||
gpointer arg1,
|
||||
gpointer user_data);
|
||||
|
@ -132,22 +151,22 @@ gimp_marshal_POINTER__POINTER (GtkObject *object,
|
|||
}
|
||||
|
||||
|
||||
typedef gpointer (* GimpSignal_POINTER__INT_INT) (GtkObject *object,
|
||||
gint arg1,
|
||||
gint arg2,
|
||||
gpointer user_data);
|
||||
typedef gpointer (* GimpSignal_POINTER__POINTER_INT) (GtkObject *object,
|
||||
gpointer arg1,
|
||||
gint arg2,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
gimp_marshal_POINTER__INT_INT (GtkObject *object,
|
||||
GtkSignalFunc func,
|
||||
gpointer func_data,
|
||||
GtkArg *args)
|
||||
gimp_marshal_POINTER__POINTER_INT (GtkObject *object,
|
||||
GtkSignalFunc func,
|
||||
gpointer func_data,
|
||||
GtkArg *args)
|
||||
{
|
||||
*GTK_RETLOC_POINTER (args[2]) =
|
||||
(* (GimpSignal_POINTER__INT_INT) func) (object,
|
||||
GTK_VALUE_INT (args[0]),
|
||||
GTK_VALUE_INT (args[1]),
|
||||
func_data);
|
||||
(* (GimpSignal_POINTER__POINTER_INT) func) (object,
|
||||
GTK_VALUE_POINTER (args[0]),
|
||||
GTK_VALUE_INT (args[1]),
|
||||
func_data);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -45,12 +45,17 @@ void gimp_marshal_POINTER__INT (GtkObject *object,
|
|||
gpointer func_data,
|
||||
GtkArg *args);
|
||||
|
||||
void gimp_marshal_POINTER__INT_INT (GtkObject *object,
|
||||
GtkSignalFunc func,
|
||||
gpointer func_data,
|
||||
GtkArg *args);
|
||||
|
||||
void gimp_marshal_POINTER__POINTER (GtkObject *object,
|
||||
GtkSignalFunc func,
|
||||
gpointer func_data,
|
||||
GtkArg *args);
|
||||
|
||||
void gimp_marshal_POINTER__INT_INT (GtkObject *object,
|
||||
void gimp_marshal_POINTER__POINTER_INT (GtkObject *object,
|
||||
GtkSignalFunc func,
|
||||
gpointer func_data,
|
||||
GtkArg *args);
|
||||
|
|
|
@ -31,20 +31,20 @@
|
|||
#include "gimppreview.h"
|
||||
|
||||
|
||||
static void gimp_container_list_view_class_init (GimpContainerListViewClass *klass);
|
||||
static void gimp_container_list_view_init (GimpContainerListView *panel);
|
||||
static void gimp_container_list_view_destroy (GtkObject *object);
|
||||
static void gimp_container_list_view_class_init (GimpContainerListViewClass *klass);
|
||||
static void gimp_container_list_view_init (GimpContainerListView *panel);
|
||||
static void gimp_container_list_view_destroy (GtkObject *object);
|
||||
|
||||
static void gimp_container_list_view_add_foreach (GimpViewable *viewable,
|
||||
GimpContainerListView *list_view);
|
||||
static void gimp_container_list_view_add (GimpContainerListView *list_view,
|
||||
GimpViewable *viewable,
|
||||
GimpContainer *container);
|
||||
static void gimp_container_list_view_remove (GimpContainerListView *list_view,
|
||||
GimpViewable *viewable,
|
||||
GimpContainer *container);
|
||||
static void gimp_container_list_view_name_changed (GimpContainerListView *list_view,
|
||||
GimpViewable *viewable);
|
||||
static gpointer gimp_container_list_view_insert_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gint index);
|
||||
static void gimp_container_list_view_remove_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer insert_data);
|
||||
static void gimp_container_list_view_clear_items (GimpContainerView *view);
|
||||
|
||||
static void gimp_container_list_view_name_changed (GimpContainerListView *list_view,
|
||||
GimpViewable *viewable);
|
||||
|
||||
|
||||
static GimpContainerViewClass *parent_class = NULL;
|
||||
|
@ -88,6 +88,10 @@ gimp_container_list_view_class_init (GimpContainerListViewClass *klass)
|
|||
parent_class = gtk_type_class (GIMP_TYPE_CONTAINER_VIEW);
|
||||
|
||||
object_class->destroy = gimp_container_list_view_destroy;
|
||||
|
||||
container_view_class->insert_item = gimp_container_list_view_insert_item;
|
||||
container_view_class->remove_item = gimp_container_list_view_remove_item;
|
||||
container_view_class->clear_items = gimp_container_list_view_clear_items;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -114,8 +118,6 @@ gimp_container_list_view_init (GimpContainerListView *list_view)
|
|||
|
||||
gtk_widget_show (list_view->gtk_list);
|
||||
gtk_widget_show (scrolled_win);
|
||||
|
||||
list_view->hash_table = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -125,8 +127,6 @@ gimp_container_list_view_destroy (GtkObject *object)
|
|||
|
||||
list_view = GIMP_CONTAINER_LIST_VIEW (object);
|
||||
|
||||
g_hash_table_destroy (list_view->hash_table);
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
@ -144,38 +144,27 @@ gimp_container_list_view_new (GimpContainer *container)
|
|||
|
||||
view = GIMP_CONTAINER_VIEW (list_view);
|
||||
|
||||
view->container = container;
|
||||
|
||||
gimp_container_foreach (container,
|
||||
(GFunc) gimp_container_list_view_add_foreach,
|
||||
list_view);
|
||||
|
||||
gtk_signal_connect_object_while_alive (GTK_OBJECT (container), "add",
|
||||
GTK_SIGNAL_FUNC (gimp_container_list_view_add),
|
||||
GTK_OBJECT (list_view));
|
||||
|
||||
gtk_signal_connect_object_while_alive (GTK_OBJECT (container), "remove",
|
||||
GTK_SIGNAL_FUNC (gimp_container_list_view_remove),
|
||||
GTK_OBJECT (list_view));
|
||||
gimp_container_view_set_container (view, container);
|
||||
|
||||
return GTK_WIDGET (list_view);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_list_view_insert (GimpContainerListView *list_view,
|
||||
GimpViewable *viewable,
|
||||
gint index)
|
||||
static gpointer
|
||||
gimp_container_list_view_insert_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gint index)
|
||||
{
|
||||
GtkWidget *list_item;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *preview;
|
||||
GtkWidget *label;
|
||||
GList *list;
|
||||
GimpContainerListView *list_view;
|
||||
GtkWidget *list_item;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *preview;
|
||||
GtkWidget *label;
|
||||
GList *list;
|
||||
|
||||
list_view = GIMP_CONTAINER_LIST_VIEW (view);
|
||||
|
||||
list_item = gtk_list_item_new ();
|
||||
|
||||
g_hash_table_insert (list_view->hash_table, viewable, list_item);
|
||||
|
||||
gtk_signal_connect_object_while_alive (GTK_OBJECT (viewable), "name_changed",
|
||||
GTK_SIGNAL_FUNC (gimp_container_list_view_name_changed),
|
||||
GTK_OBJECT (list_view));
|
||||
|
@ -206,36 +195,19 @@ gimp_container_list_view_insert (GimpContainerListView *list_view,
|
|||
else
|
||||
gtk_list_insert_items (GTK_LIST (list_view->gtk_list), list, index);
|
||||
|
||||
return (gpointer) list_item;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_list_view_add_foreach (GimpViewable *viewable,
|
||||
GimpContainerListView *list_view)
|
||||
gimp_container_list_view_remove_item (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
gpointer insert_data)
|
||||
{
|
||||
gimp_container_list_view_insert (list_view, viewable, -1);
|
||||
}
|
||||
GimpContainerListView *list_view;
|
||||
GtkWidget *list_item;
|
||||
|
||||
static void
|
||||
gimp_container_list_view_add (GimpContainerListView *list_view,
|
||||
GimpViewable *viewable,
|
||||
GimpContainer *container)
|
||||
{
|
||||
gint index;
|
||||
|
||||
index = gimp_container_get_child_index (container,
|
||||
GIMP_OBJECT (viewable));
|
||||
|
||||
gimp_container_list_view_insert (list_view, viewable, index);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_list_view_remove (GimpContainerListView *list_view,
|
||||
GimpViewable *viewable,
|
||||
GimpContainer *container)
|
||||
{
|
||||
GtkWidget *list_item;
|
||||
|
||||
list_item = g_hash_table_lookup (list_view->hash_table, viewable);
|
||||
list_view = GIMP_CONTAINER_LIST_VIEW (view);
|
||||
list_item = GTK_WIDGET (insert_data);
|
||||
|
||||
if (list_item)
|
||||
{
|
||||
|
@ -244,18 +216,27 @@ gimp_container_list_view_remove (GimpContainerListView *list_view,
|
|||
list = g_list_prepend (NULL, list_item);
|
||||
|
||||
gtk_list_remove_items (GTK_LIST (list_view->gtk_list), list);
|
||||
|
||||
g_hash_table_remove (list_view->hash_table, viewable);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_list_view_clear_items (GimpContainerView *view)
|
||||
{
|
||||
GimpContainerListView *list_view;
|
||||
|
||||
list_view = GIMP_CONTAINER_LIST_VIEW (view);
|
||||
|
||||
gtk_list_clear_items (GTK_LIST (list_view->gtk_list), 0, -1);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_list_view_name_changed (GimpContainerListView *list_view,
|
||||
GimpViewable *viewable)
|
||||
{
|
||||
GtkWidget *list_item;
|
||||
|
||||
list_item = g_hash_table_lookup (list_view->hash_table, viewable);
|
||||
list_item = g_hash_table_lookup (GIMP_CONTAINER_VIEW (list_view)->hash_table,
|
||||
viewable);
|
||||
|
||||
if (list_item)
|
||||
{
|
||||
|
|
|
@ -37,7 +37,6 @@ struct _GimpContainerListView
|
|||
GimpContainerView parent_instance;
|
||||
|
||||
GtkWidget *gtk_list;
|
||||
GHashTable *hash_table; /* container child --> list item mapping */
|
||||
};
|
||||
|
||||
struct _GimpContainerListViewClass
|
||||
|
|
|
@ -18,21 +18,42 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "appenv.h"
|
||||
#include "gimpcontainer.h"
|
||||
#include "gimpcontainerview.h"
|
||||
#include "gimpmarshal.h"
|
||||
|
||||
|
||||
static void gimp_container_view_class_init (GimpContainerViewClass *klass);
|
||||
static void gimp_container_view_init (GimpContainerView *panel);
|
||||
static void gimp_container_view_destroy (GtkObject *object);
|
||||
enum
|
||||
{
|
||||
INSERT_ITEM,
|
||||
REMOVE_ITEM,
|
||||
CLEAR_ITEMS,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
||||
static void gimp_container_view_class_init (GimpContainerViewClass *klass);
|
||||
static void gimp_container_view_init (GimpContainerView *panel);
|
||||
static void gimp_container_view_destroy (GtkObject *object);
|
||||
|
||||
static void gimp_container_view_clear (GimpContainerView *view);
|
||||
|
||||
static void gimp_container_view_add_foreach (GimpViewable *viewable,
|
||||
GimpContainerView *view);
|
||||
static void gimp_container_view_add (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
GimpContainer *container);
|
||||
static void gimp_container_view_remove (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
GimpContainer *container);
|
||||
|
||||
|
||||
static guint view_signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static GtkVBoxClass *parent_class = NULL;
|
||||
|
||||
|
||||
|
@ -70,13 +91,47 @@ gimp_container_view_class_init (GimpContainerViewClass *klass)
|
|||
|
||||
parent_class = gtk_type_class (GTK_TYPE_VBOX);
|
||||
|
||||
view_signals[INSERT_ITEM] =
|
||||
gtk_signal_new ("insert_item",
|
||||
GTK_RUN_LAST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpContainerViewClass,
|
||||
insert_item),
|
||||
gimp_marshal_POINTER__POINTER_INT,
|
||||
GTK_TYPE_POINTER, 2,
|
||||
GIMP_TYPE_OBJECT,
|
||||
GTK_TYPE_INT);
|
||||
|
||||
view_signals[REMOVE_ITEM] =
|
||||
gtk_signal_new ("remove_item",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpContainerViewClass,
|
||||
remove_item),
|
||||
gtk_marshal_NONE__POINTER_POINTER,
|
||||
GTK_TYPE_NONE, 2,
|
||||
GIMP_TYPE_OBJECT,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
view_signals[CLEAR_ITEMS] =
|
||||
gtk_signal_new ("clear_items",
|
||||
GTK_RUN_FIRST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (GimpContainerViewClass,
|
||||
clear_items),
|
||||
gtk_signal_default_marshaller,
|
||||
GTK_TYPE_NONE, 0);
|
||||
|
||||
gtk_object_class_add_signals (object_class, view_signals, LAST_SIGNAL);
|
||||
|
||||
object_class->destroy = gimp_container_view_destroy;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_view_init (GimpContainerView *view)
|
||||
{
|
||||
view->container = NULL;
|
||||
view->container = NULL;
|
||||
view->hash_table = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -85,7 +140,107 @@ gimp_container_view_destroy (GtkObject *object)
|
|||
GimpContainerView *view;
|
||||
|
||||
view = GIMP_CONTAINER_VIEW (object);
|
||||
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_container_view_set_container (GimpContainerView *view,
|
||||
GimpContainer *container)
|
||||
{
|
||||
g_return_if_fail (view != NULL);
|
||||
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
|
||||
g_return_if_fail (!container || GIMP_IS_CONTAINER (container));
|
||||
|
||||
if (container == view->container)
|
||||
return;
|
||||
|
||||
if (view->container)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (container),
|
||||
gimp_container_view_add,
|
||||
view);
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (container),
|
||||
gimp_container_view_remove,
|
||||
view);
|
||||
|
||||
g_hash_table_destroy (view->hash_table);
|
||||
|
||||
gimp_container_view_clear (view);
|
||||
}
|
||||
|
||||
view->container = container;
|
||||
|
||||
if (view->container)
|
||||
{
|
||||
view->hash_table = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
|
||||
gimp_container_foreach (container,
|
||||
(GFunc) gimp_container_view_add_foreach,
|
||||
view);
|
||||
|
||||
gtk_signal_connect_object_while_alive
|
||||
(GTK_OBJECT (container), "add",
|
||||
GTK_SIGNAL_FUNC (gimp_container_view_add),
|
||||
GTK_OBJECT (view));
|
||||
|
||||
gtk_signal_connect_object_while_alive
|
||||
(GTK_OBJECT (container), "remove",
|
||||
GTK_SIGNAL_FUNC (gimp_container_view_remove),
|
||||
GTK_OBJECT (view));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_view_clear (GimpContainerView *view)
|
||||
{
|
||||
gtk_signal_emit (GTK_OBJECT (view), view_signals[CLEAR_ITEMS]);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_view_add_foreach (GimpViewable *viewable,
|
||||
GimpContainerView *view)
|
||||
{
|
||||
gpointer insert_data = NULL;
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (view), view_signals[INSERT_ITEM],
|
||||
viewable, -1, &insert_data);
|
||||
|
||||
g_hash_table_insert (view->hash_table, viewable, insert_data);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_view_add (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
GimpContainer *container)
|
||||
{
|
||||
gpointer insert_data = NULL;
|
||||
gint index;
|
||||
|
||||
index = gimp_container_get_child_index (container,
|
||||
GIMP_OBJECT (viewable));
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (view), view_signals[INSERT_ITEM],
|
||||
viewable, index, &insert_data);
|
||||
|
||||
g_hash_table_insert (view->hash_table, viewable, insert_data);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_view_remove (GimpContainerView *view,
|
||||
GimpViewable *viewable,
|
||||
GimpContainer *container)
|
||||
{
|
||||
gpointer insert_data;
|
||||
|
||||
insert_data = g_hash_table_lookup (view->hash_table, viewable);
|
||||
|
||||
if (insert_data)
|
||||
{
|
||||
g_hash_table_remove (view->hash_table, viewable);
|
||||
|
||||
gtk_signal_emit (GTK_OBJECT (view), view_signals[REMOVE_ITEM],
|
||||
viewable, insert_data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,15 +38,28 @@ struct _GimpContainerView
|
|||
GtkVBox parent_instance;
|
||||
|
||||
GimpContainer *container;
|
||||
|
||||
GHashTable *hash_table;
|
||||
};
|
||||
|
||||
struct _GimpContainerViewClass
|
||||
{
|
||||
GtkVBoxClass parent_class;
|
||||
|
||||
gpointer (* insert_item) (GimpContainerView *view,
|
||||
GimpViewable *object,
|
||||
gint index);
|
||||
void (* remove_item) (GimpContainerView *view,
|
||||
GimpViewable *object,
|
||||
gpointer insert_data);
|
||||
void (* clear_items) (GimpContainerView *view);
|
||||
};
|
||||
|
||||
|
||||
GtkType gimp_container_view_get_type (void);
|
||||
GtkType gimp_container_view_get_type (void);
|
||||
|
||||
void gimp_container_view_set_container (GimpContainerView *view,
|
||||
GimpContainer *container);
|
||||
|
||||
|
||||
#endif /* __GIMP_CONTAINER_VIEW_H__ */
|
||||
|
|
Loading…
Reference in New Issue