gtk2/gtk/gtktypeutils.c
Tim Janik d69496c060 urg, removed implementation of gtk_marshal_VOID__INT_INT_INT_INT. if
Wed Oct 25 20:47:41 2000  Tim Janik  <timj@gtk.org>

        * gtk/gdk-pixbuf-loader.c (gdk_pixbuf_loader_class_init): urg, removed
        implementation of gtk_marshal_VOID__INT_INT_INT_INT. if people do that,
        couldn't they at least give it a non-standard name?

        * gtk/gtktextlayout.c: arg! yet another implementation of
        gtk_marshal_VOID__INT_INT_INT_INT(), is this a conspiracy?

        * gtk/gtktextbuffer.c: gotcha! captured a vagabonding
        gtk_marshal_VOID__INT_POINTER_INT() implementation, braught it back
        home. now i know this _is_ a conspiracy.

        * gtk/gtkwidget.c (gtk_widget_class_init): marshaller fixups for
        ::state-changed.

        * gtk/gtkaccelgroup.c (gtk_accel_group_create_remove):
        (gtk_accel_group_create_add): marshaller signature fixups.

        * gtk/gtklistitem.c (gtk_list_item_class_init): signal creation fixups,
        pass in GTK_TYPE_SCROLL_TYPE instead of GTK_TYPE_ENUM.

        * gtk/gtkobject.[hc]: removed GTK_CONNECTED flag, it's not valid
        anymore.

Tue Oct 24 23:59:21 2000  Tim Janik  <timj@gtk.org>

        * docs/reference/Makefile.am: disabled SUBDIRS for the moment, since
        due to the signal system changes, it wouldn't build currently. to
        be fixed soon.

        * docs/Changes-2.0.txt: GtkSignal/GSignal updates.

        * gtk/gtkwidget.c: ::direction_changed takes an enum as argument,
        so it needs gtk_marshal_VOID__ENUM() instead of
        gtk_marshal_NONE__UINT().

        * gdk/gdk*.c: adapted type registration functions.

        * gtk/gtkbindings.c:
        * gtk/gtkaccelgroup.c: operate on GSignalQuery, GtkSignalQuery is
        gone.

        * gtk/gtkenums.h: define GtkSignalRunType in terms of GSignalType.

        * gtk/gtkobject.c:
        (gtk_object_destroy):
        (gtk_object_shutdown): fixed recursion guards. basically we have to
        catch the case where any of GObject.shutdown() or gtk_object_destroy()
        is called during ::destroy, and avoid recursion there.

        * gtk/gtktypeutils.c:
        * gtk/maketypes.awk: awk-script hackup to provide gtk_type_init() with
        boxed_copy/boxed_free. this needs a more general solution based on a
        publically installed code-generator utility.

        * gtk/gtktypeutils.[hc]: compat aliased GTK_TYPE_BOXED to G_TYPE_BOXED,
        glib's gobject has support for that now.
        define GtkSignalMarshaller in terms of GSignalCMarshaller.


Mon Oct 23 09:36:42 2000  Tim Janik  <timj@gtk.org>

        * gtk/gtksignal.[hc]:
        * gtk/gtkmarshal.[hc]:
        * gtk/Makefile.am: generate marshallers with glib-genmarshal and don't
        compile gtkmarshal.c on its own anymore, just include it in gtksignal.c.
        removed #include <gtkmarshal.h>s all over the place, gtksignal.h takes
        care of that.

        * *.c: marshaller name fixups.

        * gtk/gtkmarshal.list: added a comment briefing the format.

Sun Oct 22 23:14:39 2000  Tim Janik  <timj@gtk.org>

        * gtk/gtksignal.[hc]: nuked old implementation. we mostly have
        compatibility macros here now. more specifically, most of
        the API is preserved (yes, _most_, nonwithstanding the
        following exceptions listed, the API is stil lHUGE ;)
        things that got removed completely:
        GtkSignalQuery, gtk_signal_query(), gtk_signal_n_emissions(),
        gtk_signal_n_emissions_by_name(), gtk_signal_handlers_destroy(),
        gtk_signal_set_funcs(), gtk_signal_handler_pending_by_id(),
        gtk_signal_add_emission_hook(), gtk_signal_add_emission_hook_full(),
        gtk_signal_remove_emission_hook().
        non-functional functions variants:
        gtk_signal_add_emission_hook(), gtk_signal_remove_emission_hook().
        the GtkCallbackMarshal argument to gtk_signal_connect_full() is
        not supported anymore.
        (gtk_signal_compat_matched): new internal function to aid
        implementation of the compatibility macros, it  provides
        functionality to block/unblock/disconnect handlers based
        on func/data.

        * gtk/gtkenums.h: define GtkSignalRunType in terms of GSignalType,

        * *.c: adaptions to new type registration API signatures.


Fri Oct 20 15:26:33 2000  Tim Janik  <timj@gtk.org>

        * gtk/gtktypeutils.[hc]: removed G_TYPE_GTK_POINTER cludge.
2000-10-25 22:34:14 +00:00

264 lines
7.1 KiB
C

/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "gtktypeutils.h"
#include "gtkobject.h"
/* --- functions --- */
GtkType
gtk_type_unique (GtkType parent_type,
const GtkTypeInfo *gtkinfo)
{
GTypeInfo tinfo = { 0, };
g_return_val_if_fail (GTK_TYPE_IS_OBJECT (parent_type), 0);
g_return_val_if_fail (gtkinfo != NULL, 0);
g_return_val_if_fail (gtkinfo->type_name != NULL, 0);
g_return_val_if_fail (g_type_from_name (gtkinfo->type_name) == 0, 0);
tinfo.class_size = gtkinfo->class_size;
tinfo.base_init = gtkinfo->base_class_init_func;
tinfo.base_finalize = NULL;
tinfo.class_init = (GClassInitFunc) gtkinfo->class_init_func;
tinfo.class_finalize = NULL;
tinfo.class_data = NULL;
tinfo.instance_size = gtkinfo->object_size;
tinfo.n_preallocs = 0;
tinfo.instance_init = gtkinfo->object_init_func;
return g_type_register_static (parent_type, gtkinfo->type_name, &tinfo, 0);
}
gpointer
gtk_type_class (GtkType type)
{
static GQuark quark_static_class = 0;
gpointer class;
if (!G_TYPE_IS_ENUM (type) && !G_TYPE_IS_FLAGS (type))
g_return_val_if_fail (GTK_TYPE_IS_OBJECT (type), NULL);
/* ok, this is a bit ugly, GLib reference counts classes,
* and gtk_type_class() used to always return static classes.
* while we coud be faster with just peeking the glib class
* for the normal code path, we can't be sure that that
* class stays around (someone else might be holding the
* reference count and is going to drop it later). so to
* ensure that Gtk actually holds a static reference count
* on the class, we use GType qdata to store referenced
* classes, and only return those.
*/
class = g_type_get_qdata (type, quark_static_class);
if (!class)
{
if (!quark_static_class)
quark_static_class = g_quark_from_static_string ("GtkStaticTypeClass");
class = g_type_class_ref (type);
g_assert (class != NULL);
g_type_set_qdata (type, quark_static_class, class);
}
return class;
}
gpointer
gtk_type_new (GtkType type)
{
gpointer object;
g_return_val_if_fail (GTK_TYPE_IS_OBJECT (type), NULL);
object = g_type_create_instance (type);
return object;
}
/* includes for various places
* with enum definitions
*/
#include "makeenums.h"
/* type variable declarations
*/
#include "gtktypebuiltins_vars.c"
GType GTK_TYPE_IDENTIFIER = 0;
#include "gtktypebuiltins_evals.c" /* enum value definition arrays */
/* Hack to communicate with GLib object debugging for now
*/
#ifdef G_OS_WIN32
#define IMPORT __declspec(dllimport)
#else
#define IMPORT
#endif
extern IMPORT gboolean glib_debug_objects;
#include <gtk.h> /* for gtktypebuiltins_ids.c */
#include <gdk.h> /* gtktypebuiltins_ids.c */
void
gtk_type_init (void)
{
static gboolean initialized = FALSE;
if (!initialized)
{
static const struct {
GtkType type_id;
gchar *name;
} fundamental_info[] = {
{ GTK_TYPE_SIGNAL, "GtkSignal" },
};
static struct {
gchar *type_name;
GtkType *type_id;
GtkType parent;
gconstpointer pointer1;
gpointer pointer2;
} builtin_info[GTK_TYPE_N_BUILTINS + 1] = {
#include "gtktypebuiltins_ids.c" /* type entries */
{ NULL }
};
GTypeFundamentalInfo finfo = { 0, };
GTypeInfo tinfo = { 0, };
GtkType type_id;
guint i;
initialized = TRUE;
glib_debug_objects = (gtk_debug_flags & GTK_DEBUG_OBJECTS) != 0;
/* initialize GLib type system
*/
g_type_init ();
/* GTK_TYPE_OBJECT
*/
gtk_object_get_type ();
/* compatibility fundamentals
*/
for (i = 0; i < sizeof (fundamental_info) / sizeof (fundamental_info[0]); i++)
{
type_id = g_type_register_fundamental (fundamental_info[i].type_id,
fundamental_info[i].name,
&tinfo, &finfo, 0);
g_assert (type_id == fundamental_info[i].type_id);
}
/* GTK_TYPE_IDENTIFIER
*/
GTK_TYPE_IDENTIFIER = g_type_register_static (G_TYPE_STRING, "GtkIdentifier", &tinfo, 0);
/* enums and flags
*/
for (i = 0; i < GTK_TYPE_N_BUILTINS; i++)
{
GtkType type_id = 0;
if (builtin_info[i].parent == G_TYPE_ENUM)
type_id = g_enum_register_static (builtin_info[i].type_name, builtin_info[i].pointer1);
else if (builtin_info[i].parent == G_TYPE_FLAGS)
type_id = g_flags_register_static (builtin_info[i].type_name, builtin_info[i].pointer1);
else if (builtin_info[i].parent == GTK_TYPE_BOXED)
{
if (builtin_info[i].pointer1 && builtin_info[i].pointer2)
type_id = g_boxed_type_register_static (builtin_info[i].type_name,
builtin_info[i].pointer1,
builtin_info[i].pointer2);
else
type_id = g_type_register_static (GTK_TYPE_BOXED, builtin_info[i].type_name, &tinfo, 0);
}
else
g_assert_not_reached ();
*builtin_info[i].type_id = type_id;
}
}
}
GtkEnumValue*
gtk_type_enum_get_values (GtkType enum_type)
{
GEnumClass *class;
g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
class = gtk_type_class (enum_type);
return class->values;
}
GtkFlagValue*
gtk_type_flags_get_values (GtkType flags_type)
{
GFlagsClass *class;
g_return_val_if_fail (G_TYPE_IS_FLAGS (flags_type), NULL);
class = gtk_type_class (flags_type);
return class->values;
}
GtkEnumValue*
gtk_type_enum_find_value (GtkType enum_type,
const gchar *value_name)
{
GtkEnumValue *value;
GEnumClass *class;
g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
g_return_val_if_fail (value_name != NULL, NULL);
class = gtk_type_class (enum_type);
value = g_enum_get_value_by_name (class, value_name);
if (!value)
value = g_enum_get_value_by_nick (class, value_name);
return value;
}
GtkFlagValue*
gtk_type_flags_find_value (GtkType flags_type,
const gchar *value_name)
{
GtkFlagValue *value;
GFlagsClass *class;
g_return_val_if_fail (G_TYPE_IS_FLAGS (flags_type), NULL);
g_return_val_if_fail (value_name != NULL, NULL);
class = gtk_type_class (flags_type);
value = g_flags_get_value_by_name (class, value_name);
if (!value)
value = g_flags_get_value_by_nick (class, value_name);
return value;
}