gtk/gtk/gtktypeutils.c
Manish Singh bc035915e9 add -DGTK_DISABLE_DEPRECATED. #undef it at the top of gtktypebuiltins.c.
Tue Nov 19 17:05:51 2002 Manish Singh  <yosh@gimp.org>

	* gtk/Makefile.am: add -DGTK_DISABLE_DEPRECATED. #undef it at the
	top of gtktypebuiltins.c.

	* gtk/gtkclist.c
	* gtk/gtkcombo.c
	* gtk/gtkctree.c
	* gtk/gtklist.c
	* gtk/gtklistitem.c
	* gtk/gtkoldeditable.c
	* gtk/gtkpixmap.c
	* gtk/gtkpreview.c
	* gtk/gtksignal.c
	* gtk/gtktext.c
	* gtk/gtktipsquery.c
	* gtk/gtktree.c
	* gtk/gtktreeitem.c
	* gtk/gtktypeutils.c: #undef GTK_DISABLE_DEPRECATED, deprecated widgets
	and compat code.

	* gtk/gtkcolorsel.c: move gtk_color_selection_set_color implementation
	to set_color_internal, and use that. The deprecated function now
	merely wraps it.

	* gtk/gtkfontsel.c: same as above, except with
	gtk_font_selection_get_font.

	* gtk/gtknotebook.c: same as above, except with
	gtk_notebook_set_homogeneous, and gtk_notebook_set_tab_{border,
	hborder,vborder}.

	* gtk/gtkprogressbar.c: same as above, except with
	gtk_progress_bar_set_{bar_stype,discrete_blocks,activity_step,
	activity_blocks}.

	* gtk/gtkstyle.c: same as above, except with gtk_style_get_font.

	* gtk/gtkwidget.c: same as above, except with gtk_widget_set_usize.

	* gtk/gtkitemfactory.h: declare compatibility functions for deprecated
	GtkMenuFactory stuff if GTK_COMPILATION, since they are used
	internally by the compat code.

	* gtk/gtkitemfactory.c (gtk_item_factory_create_item): remove
	use of deprecated gtk_check_menu_item_set_show_toggle (it is a noop
	now).

	* gtk/gtkmain.c: replaced deprecated GTK_TYPE_* with G_TYPE_*.

	* gtk/gtkobject.c: replaced various deprecated functions. In set and
	get_property, use g_object_{set,get}_data with "user_data" instead
	of gtk_object_{set,get}_user_data.

	* gtk/gtkprogress.h: API declared if GTK_COMPILATION

	* gtk/gtkprogress.c: port get_type to GObject API.

	* gtk/gtktypeutils.h: declare GtkArg stuff and gtk_type_init,
	if GTK_COMPILATION.

	* gtk/gtkwidget.c: define gtk_widget_queue_clear in terms of
	gtk_widget_queue_draw instead of the other way around.

	* tests/Makefile.am: define -DGTK_DISABLE_DEPRECATED

	* tests/testgtk.c
	* tests/testselection.c
	* tests/testsocket.c: #undef GTK_DISABLE_DEPRECATED, makes use of
	deprecated stuff.
2002-11-20 01:07:33 +00:00

199 lines
5.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/.
*/
#undef GTK_DISABLE_DEPRECATED
#include <string.h> /* strcmp */
#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 (G_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_object_new (type, NULL);
return object;
}
void
gtk_type_init (GTypeDebugFlags debug_flags)
{
static gboolean initialized = FALSE;
if (!initialized)
{
initialized = TRUE;
/* initialize GLib type system
*/
g_type_init_with_debug_flags (debug_flags);
/* GTK_TYPE_OBJECT
*/
gtk_object_get_type ();
}
}
GType
gtk_identifier_get_type (void)
{
static GType our_type = 0;
if (our_type == 0)
{
GTypeInfo tinfo = { 0, };
our_type = g_type_register_static (G_TYPE_STRING, "GtkIdentifier", &tinfo, 0);
}
return our_type;
}
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;
}