summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorTim Janik <timj@gtk.org>1998-06-07 07:52:26 +0000
committerTim Janik <timj@src.gnome.org>1998-06-07 07:52:26 +0000
commit210cb3f5a000fcb950f11bd1454c8e98de28d3d4 (patch)
treea644e66db4b7c19b50cbfc636ba1695873aede0d /gtk
parentcd8e439b9bb298900a7e60bb4527acf41ab11539 (diff)
downloadgtk+-210cb3f5a000fcb950f11bd1454c8e98de28d3d4.tar.gz
support different types of callbacks, to maintain existing code.
Sun Jun 7 09:36:04 1998 Tim Janik <timj@gtk.org> * gtk/gtkitemfactory.h: * gtk/gtkitemfactory.c: support different types of callbacks, to maintain existing code. ... changes to the item factory to ease support of the gimp's code...
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkitemfactory.c47
-rw-r--r--gtk/gtkitemfactory.h23
2 files changed, 55 insertions, 15 deletions
diff --git a/gtk/gtkitemfactory.c b/gtk/gtkitemfactory.c
index 6910703a97..a19e39e07a 100644
--- a/gtk/gtkitemfactory.c
+++ b/gtk/gtkitemfactory.c
@@ -46,9 +46,10 @@ typedef struct _GtkIFCBData GtkIFCBData;
typedef struct _GtkIFActionLink GtkIFActionLink;
struct _GtkIFCBData
{
- GtkItemFactoryCallback func;
- gpointer func_data;
- guint callback_action;
+ GtkItemFactoryCallback func;
+ guint callback_type;
+ gpointer func_data;
+ guint callback_action;
};
struct _GtkIFActionLink
{
@@ -240,7 +241,16 @@ gtk_item_factory_callback_marshal (GtkWidget *widget,
data = func_data;
- data->func (data->func_data, data->callback_action, widget);
+ if (data->callback_type == 1)
+ {
+ GtkItemFactoryCallback1 func1 = data->func;
+ func1 (data->func_data, data->callback_action, widget);
+ }
+ else if (data->callback_type == 2)
+ {
+ GtkItemFactoryCallback2 func2 = data->func;
+ func2 (widget, data->func_data, data->callback_action);
+ }
}
static void
@@ -386,6 +396,7 @@ gtk_item_factory_add_item (GtkItemFactory *ifactory,
GtkItemFactoryCallback callback,
guint callback_action,
gpointer callback_data,
+ guint callback_type,
gchar *item_type,
GtkWidget *widget)
{
@@ -505,6 +516,7 @@ gtk_item_factory_add_item (GtkItemFactory *ifactory,
data = g_chunk_new (GtkIFCBData, ifactory_cb_data_chunks);
data->func = callback;
+ data->callback_type = callback_type;
data->func_data = callback_data;
data->callback_action = callback_action;
@@ -562,7 +574,7 @@ gtk_item_factory_construct (GtkItemFactory *ifactory,
GTK_OBJECT (ifactory));
gtk_item_factory_add_item (ifactory,
"", NULL,
- NULL, 0, NULL,
+ NULL, 0, NULL, 0,
ITEM_FACTORY_STRING,
ifactory->widget);
}
@@ -707,15 +719,29 @@ gtk_item_factory_create_items (GtkItemFactory *ifactory,
GtkItemFactoryEntry *entries,
gpointer callback_data)
{
+ gtk_item_factory_create_items_ac (ifactory, n_entries, entries, callback_data, 1);
+}
+
+void
+gtk_item_factory_create_items_ac (GtkItemFactory *ifactory,
+ guint n_entries,
+ GtkItemFactoryEntry *entries,
+ gpointer callback_data,
+ guint callback_type)
+{
guint i;
g_return_if_fail (ifactory != NULL);
g_return_if_fail (GTK_IS_ITEM_FACTORY (ifactory));
- if (n_entries == 0) return;
+ g_return_if_fail (callback_type >= 1 && callback_type <= 2);
+
+ if (n_entries == 0)
+ return;
+
g_return_if_fail (entries != NULL);
for (i = 0; i < n_entries; i++)
- gtk_item_factory_create_item (ifactory, entries + i, callback_data);
+ gtk_item_factory_create_item (ifactory, entries + i, callback_data, callback_type);
}
GtkWidget*
@@ -775,7 +801,8 @@ gtk_item_factory_get_widget_by_action (GtkItemFactory *ifactory,
void
gtk_item_factory_create_item (GtkItemFactory *ifactory,
GtkItemFactoryEntry *entry,
- gpointer callback_data)
+ gpointer callback_data,
+ guint callback_type)
{
GtkWidget *parent;
GtkWidget *widget;
@@ -790,6 +817,7 @@ gtk_item_factory_create_item (GtkItemFactory *ifactory,
g_return_if_fail (entry != NULL);
g_return_if_fail (entry->path != NULL);
g_return_if_fail (entry->path[0] == PARENT_DELIMITER);
+ g_return_if_fail (callback_type >= 1 && callback_type <= 2);
if (!entry->item_type ||
entry->item_type == 0)
@@ -853,7 +881,7 @@ gtk_item_factory_create_item (GtkItemFactory *ifactory,
pentry.callback_action = 0;
pentry.item_type = "<Branch>";
- gtk_item_factory_create_item (ifactory, &pentry, NULL);
+ gtk_item_factory_create_item (ifactory, &pentry, NULL, 1);
parent = gtk_item_factory_get_widget (ifactory, parent_path);
}
@@ -905,6 +933,7 @@ gtk_item_factory_create_item (GtkItemFactory *ifactory,
gtk_item_factory_add_item (ifactory,
entry->path, entry->accelerator,
entry->callback, entry->callback_action, callback_data,
+ callback_type,
entry->item_type,
widget);
}
diff --git a/gtk/gtkitemfactory.h b/gtk/gtkitemfactory.h
index 92cd6691fc..a1b272ee2d 100644
--- a/gtk/gtkitemfactory.h
+++ b/gtk/gtkitemfactory.h
@@ -31,11 +31,15 @@ extern "C" {
#endif /* __cplusplus */
-typedef void (*GtkPrintFunc) (gpointer func_data,
- gchar *str);
-typedef void (*GtkItemFactoryCallback) (gpointer callback_data,
- guint callback_action,
- GtkWidget *widget);
+typedef void (*GtkPrintFunc) (gpointer func_data,
+ gchar *str);
+typedef void (*GtkItemFactoryCallback) ();
+typedef void (*GtkItemFactoryCallback1) (gpointer callback_data,
+ guint callback_action,
+ GtkWidget *widget);
+typedef void (*GtkItemFactoryCallback2) (GtkWidget *widget,
+ gpointer callback_data,
+ guint callback_action);
#define GTK_TYPE_ITEM_FACTORY (gtk_item_factory_get_type ())
#define GTK_ITEM_FACTORY(object) (GTK_CHECK_CAST (object, GTK_TYPE_ITEM_FACTORY, GtkItemFactory))
@@ -43,6 +47,7 @@ typedef void (*GtkItemFactoryCallback) (gpointer callback_data,
#define GTK_IS_ITEM_FACTORY(object) (GTK_CHECK_TYPE (object, GTK_TYPE_ITEM_FACTORY))
#define GTK_IS_ITEM_FACTORY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ITEM_FACTORY))
+
typedef struct _GtkItemFactory GtkItemFactory;
typedef struct _GtkItemFactoryClass GtkItemFactoryClass;
typedef struct _GtkItemFactoryEntry GtkItemFactoryEntry;
@@ -140,11 +145,17 @@ void gtk_item_factory_dump_rc (const gchar *ifactory_path,
gpointer func_data);
void gtk_item_factory_create_item (GtkItemFactory *ifactory,
GtkItemFactoryEntry *entry,
- gpointer callback_data);
+ gpointer callback_data,
+ guint callback_type);
void gtk_item_factory_create_items (GtkItemFactory *ifactory,
guint n_entries,
GtkItemFactoryEntry *entries,
gpointer callback_data);
+void gtk_item_factory_create_items_ac(GtkItemFactory *ifactory,
+ guint n_entries,
+ GtkItemFactoryEntry *entries,
+ gpointer callback_data,
+ guint callback_type);
void gtk_item_factory_path_delete (const gchar *ifactory_path,
const gchar *path);
void gtk_item_factory_delete_item (GtkItemFactory *ifactory,