fix PROP_EVENTS.

Mon Jun 18 02:00:49 2001  Tim Janik  <timj@gtk.org>

        * gtk/gtkwidget.c (gtk_widget_get_property): fix PROP_EVENTS.

        * gtk/Makefile.am:
        * gtk/gtk.h: disabled GtkPacker compilation.

        * gtk/gtkarg.[hc], gtk/gtkargcollector.c: got rid of these.

        * gtk/gtknotebook.c:
        * gtk/gtktable.c:
        * gtk/gtkbox.c: ported this over to child properties.

        * gtk/gtksettings.c: fetch class properties via
        g_object_class_list_properties().

        * gtk/gtkcontainer.[hc]: implemented child properties, got rid of the
        child arg interface. use gobjectnotifyqueue.c for child property
        notification.

        * gtk/gtkwidget.[hc]: provide necessary means for container child
        properties, i.e. ::child_notify signal,
        gtk_widget_freeze_child_notify(),
        gtk_widget_child_notify(),
        gtk_widget_thaw_child_notify().

        * tests/testgtk.c: removed inferior property handling code, for
        property editing, a generic module should be used, and GLE
        coincidentally fullfills that purpose.

        * docs/reference/Makefile.am: disabled gtk docs building, gtk-doc
        needs to be adapted to g_object_class_list_properties() before this
        builds again.
This commit is contained in:
Tim Janik 2001-06-19 12:54:10 +00:00 committed by Tim Janik
parent 07ddd35c57
commit 5ebd1d022a
25 changed files with 1242 additions and 2177 deletions

View File

@ -1,3 +1,37 @@
Mon Jun 18 02:00:49 2001 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_get_property): fix PROP_EVENTS.
* gtk/Makefile.am:
* gtk/gtk.h: disabled GtkPacker compilation.
* gtk/gtkarg.[hc], gtk/gtkargcollector.c: got rid of these.
* gtk/gtknotebook.c:
* gtk/gtktable.c:
* gtk/gtkbox.c: ported this over to child properties.
* gtk/gtksettings.c: fetch class properties via
g_object_class_list_properties().
* gtk/gtkcontainer.[hc]: implemented child properties, got rid of the
child arg interface. use gobjectnotifyqueue.c for child property
notification.
* gtk/gtkwidget.[hc]: provide necessary means for container child
properties, i.e. ::child_notify signal,
gtk_widget_freeze_child_notify(),
gtk_widget_child_notify(),
gtk_widget_thaw_child_notify().
* tests/testgtk.c: removed inferior property handling code, for
property editing, a generic module should be used, and GLE
coincidentally fullfills that purpose.
* docs/reference/Makefile.am: disabled gtk docs building, gtk-doc
needs to be adapted to g_object_class_list_properties() before this
builds again.
Mon Jun 18 20:06:10 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_row_expanded): New function to

View File

@ -1,3 +1,37 @@
Mon Jun 18 02:00:49 2001 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_get_property): fix PROP_EVENTS.
* gtk/Makefile.am:
* gtk/gtk.h: disabled GtkPacker compilation.
* gtk/gtkarg.[hc], gtk/gtkargcollector.c: got rid of these.
* gtk/gtknotebook.c:
* gtk/gtktable.c:
* gtk/gtkbox.c: ported this over to child properties.
* gtk/gtksettings.c: fetch class properties via
g_object_class_list_properties().
* gtk/gtkcontainer.[hc]: implemented child properties, got rid of the
child arg interface. use gobjectnotifyqueue.c for child property
notification.
* gtk/gtkwidget.[hc]: provide necessary means for container child
properties, i.e. ::child_notify signal,
gtk_widget_freeze_child_notify(),
gtk_widget_child_notify(),
gtk_widget_thaw_child_notify().
* tests/testgtk.c: removed inferior property handling code, for
property editing, a generic module should be used, and GLE
coincidentally fullfills that purpose.
* docs/reference/Makefile.am: disabled gtk docs building, gtk-doc
needs to be adapted to g_object_class_list_properties() before this
builds again.
Mon Jun 18 20:06:10 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_row_expanded): New function to

View File

@ -1,3 +1,37 @@
Mon Jun 18 02:00:49 2001 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_get_property): fix PROP_EVENTS.
* gtk/Makefile.am:
* gtk/gtk.h: disabled GtkPacker compilation.
* gtk/gtkarg.[hc], gtk/gtkargcollector.c: got rid of these.
* gtk/gtknotebook.c:
* gtk/gtktable.c:
* gtk/gtkbox.c: ported this over to child properties.
* gtk/gtksettings.c: fetch class properties via
g_object_class_list_properties().
* gtk/gtkcontainer.[hc]: implemented child properties, got rid of the
child arg interface. use gobjectnotifyqueue.c for child property
notification.
* gtk/gtkwidget.[hc]: provide necessary means for container child
properties, i.e. ::child_notify signal,
gtk_widget_freeze_child_notify(),
gtk_widget_child_notify(),
gtk_widget_thaw_child_notify().
* tests/testgtk.c: removed inferior property handling code, for
property editing, a generic module should be used, and GLE
coincidentally fullfills that purpose.
* docs/reference/Makefile.am: disabled gtk docs building, gtk-doc
needs to be adapted to g_object_class_list_properties() before this
builds again.
Mon Jun 18 20:06:10 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_row_expanded): New function to

View File

@ -1,3 +1,37 @@
Mon Jun 18 02:00:49 2001 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_get_property): fix PROP_EVENTS.
* gtk/Makefile.am:
* gtk/gtk.h: disabled GtkPacker compilation.
* gtk/gtkarg.[hc], gtk/gtkargcollector.c: got rid of these.
* gtk/gtknotebook.c:
* gtk/gtktable.c:
* gtk/gtkbox.c: ported this over to child properties.
* gtk/gtksettings.c: fetch class properties via
g_object_class_list_properties().
* gtk/gtkcontainer.[hc]: implemented child properties, got rid of the
child arg interface. use gobjectnotifyqueue.c for child property
notification.
* gtk/gtkwidget.[hc]: provide necessary means for container child
properties, i.e. ::child_notify signal,
gtk_widget_freeze_child_notify(),
gtk_widget_child_notify(),
gtk_widget_thaw_child_notify().
* tests/testgtk.c: removed inferior property handling code, for
property editing, a generic module should be used, and GLE
coincidentally fullfills that purpose.
* docs/reference/Makefile.am: disabled gtk docs building, gtk-doc
needs to be adapted to g_object_class_list_properties() before this
builds again.
Mon Jun 18 20:06:10 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_row_expanded): New function to

View File

@ -1,3 +1,37 @@
Mon Jun 18 02:00:49 2001 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_get_property): fix PROP_EVENTS.
* gtk/Makefile.am:
* gtk/gtk.h: disabled GtkPacker compilation.
* gtk/gtkarg.[hc], gtk/gtkargcollector.c: got rid of these.
* gtk/gtknotebook.c:
* gtk/gtktable.c:
* gtk/gtkbox.c: ported this over to child properties.
* gtk/gtksettings.c: fetch class properties via
g_object_class_list_properties().
* gtk/gtkcontainer.[hc]: implemented child properties, got rid of the
child arg interface. use gobjectnotifyqueue.c for child property
notification.
* gtk/gtkwidget.[hc]: provide necessary means for container child
properties, i.e. ::child_notify signal,
gtk_widget_freeze_child_notify(),
gtk_widget_child_notify(),
gtk_widget_thaw_child_notify().
* tests/testgtk.c: removed inferior property handling code, for
property editing, a generic module should be used, and GLE
coincidentally fullfills that purpose.
* docs/reference/Makefile.am: disabled gtk docs building, gtk-doc
needs to be adapted to g_object_class_list_properties() before this
builds again.
Mon Jun 18 20:06:10 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_row_expanded): New function to

View File

@ -1,3 +1,37 @@
Mon Jun 18 02:00:49 2001 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_get_property): fix PROP_EVENTS.
* gtk/Makefile.am:
* gtk/gtk.h: disabled GtkPacker compilation.
* gtk/gtkarg.[hc], gtk/gtkargcollector.c: got rid of these.
* gtk/gtknotebook.c:
* gtk/gtktable.c:
* gtk/gtkbox.c: ported this over to child properties.
* gtk/gtksettings.c: fetch class properties via
g_object_class_list_properties().
* gtk/gtkcontainer.[hc]: implemented child properties, got rid of the
child arg interface. use gobjectnotifyqueue.c for child property
notification.
* gtk/gtkwidget.[hc]: provide necessary means for container child
properties, i.e. ::child_notify signal,
gtk_widget_freeze_child_notify(),
gtk_widget_child_notify(),
gtk_widget_thaw_child_notify().
* tests/testgtk.c: removed inferior property handling code, for
property editing, a generic module should be used, and GLE
coincidentally fullfills that purpose.
* docs/reference/Makefile.am: disabled gtk docs building, gtk-doc
needs to be adapted to g_object_class_list_properties() before this
builds again.
Mon Jun 18 20:06:10 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_row_expanded): New function to

View File

@ -1,3 +1,37 @@
Mon Jun 18 02:00:49 2001 Tim Janik <timj@gtk.org>
* gtk/gtkwidget.c (gtk_widget_get_property): fix PROP_EVENTS.
* gtk/Makefile.am:
* gtk/gtk.h: disabled GtkPacker compilation.
* gtk/gtkarg.[hc], gtk/gtkargcollector.c: got rid of these.
* gtk/gtknotebook.c:
* gtk/gtktable.c:
* gtk/gtkbox.c: ported this over to child properties.
* gtk/gtksettings.c: fetch class properties via
g_object_class_list_properties().
* gtk/gtkcontainer.[hc]: implemented child properties, got rid of the
child arg interface. use gobjectnotifyqueue.c for child property
notification.
* gtk/gtkwidget.[hc]: provide necessary means for container child
properties, i.e. ::child_notify signal,
gtk_widget_freeze_child_notify(),
gtk_widget_child_notify(),
gtk_widget_thaw_child_notify().
* tests/testgtk.c: removed inferior property handling code, for
property editing, a generic module should be used, and GLE
coincidentally fullfills that purpose.
* docs/reference/Makefile.am: disabled gtk docs building, gtk-doc
needs to be adapted to g_object_class_list_properties() before this
builds again.
Mon Jun 18 20:06:10 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_row_expanded): New function to

View File

@ -1,4 +1,4 @@
## Process this file with automake to produce Makefile.in
SUBDIRS = gdk-pixbuf gdk gtk
SUBDIRS = gdk-pixbuf gdk # gtk

View File

@ -48,7 +48,6 @@ gtk_public_h_sources = @STRIP_BEGIN@ \
gtkaccessible.h \
gtkadjustment.h \
gtkalignment.h \
gtkarg.h \
gtkarrow.h \
gtkaspectframe.h \
gtkbin.h \
@ -122,7 +121,6 @@ gtk_public_h_sources = @STRIP_BEGIN@ \
gtkoldeditable.h \
gtkobject.h \
gtkoptionmenu.h \
gtkpacker.h \
gtkpaned.h \
gtkpixmap.h \
gtkplug.h \
@ -208,7 +206,6 @@ gtk_c_sources = @STRIP_BEGIN@ \
gtkaccessible.c \
gtkadjustment.c \
gtkalignment.c \
gtkarg.c \
gtkarrow.c \
gtkaspectframe.c \
gtkbin.c \
@ -283,7 +280,6 @@ gtk_c_sources = @STRIP_BEGIN@ \
gtkobject.c \
gtkoldeditable.c \
gtkoptionmenu.c \
gtkpacker.c \
gtkpaned.c \
gtkpixmap.c \
gtkpreview.c \
@ -394,7 +390,6 @@ gtk_extra_sources = @STRIP_BEGIN@ \
gtkcompat.h.in \
maketypes.awk \
makeenums.h \
gtkargcollector.c \
gtk-boxed.defs \
gtkmarshal.list \
@STRIP_END@

View File

@ -34,7 +34,6 @@
#include <gtk/gtkaccessible.h>
#include <gtk/gtkadjustment.h>
#include <gtk/gtkalignment.h>
#include <gtk/gtkarg.h>
#include <gtk/gtkaspectframe.h>
#include <gtk/gtkarrow.h>
#include <gtk/gtkbin.h>
@ -105,7 +104,7 @@
#include <gtk/gtkobject.h>
#include <gtk/gtkoldeditable.h>
#include <gtk/gtkoptionmenu.h>
#include <gtk/gtkpacker.h>
/* #include <gtk/gtkpacker.h> */
#include <gtk/gtkpaned.h>
#include <gtk/gtkpixmap.h>
#include <gtk/gtkplug.h>

View File

@ -1,639 +0,0 @@
/* 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 <stdarg.h>
#include <string.h>
#include "gtkobject.h"
#include "gtkargcollector.c"
#define MAX_ARG_LENGTH (256)
/* --- typedefs --- */
typedef struct _GtkArgQueryData GtkArgQueryData;
/* --- structures --- */
struct _GtkArgQueryData
{
GList *arg_list;
GtkType class_type;
};
/* --- functions --- */
GtkArgInfo*
gtk_arg_type_new_static (GtkType base_class_type,
const gchar *arg_name,
guint class_n_args_offset,
GHashTable *arg_info_hash_table,
GtkType arg_type,
guint arg_flags,
guint arg_id)
{
GtkArgInfo *info;
gchar class_part[MAX_ARG_LENGTH];
gchar *arg_part;
GtkType class_type;
guint class_offset;
guint *n_args_p;
gchar *p;
g_return_val_if_fail (arg_name != NULL, NULL);
g_return_val_if_fail (GTK_TYPE_IS_OBJECT (base_class_type), NULL);
g_return_val_if_fail (class_n_args_offset != 0, NULL);
g_return_val_if_fail (arg_info_hash_table != NULL, NULL);
g_return_val_if_fail (arg_type > GTK_TYPE_NONE, NULL);
g_return_val_if_fail (arg_id > 0, NULL);
g_return_val_if_fail ((arg_flags & GTK_ARG_READWRITE) != 0, NULL);
/* g_return_val_if_fail ((arg_flags & GTK_ARG_CHILD_ARG) == 0, NULL); */
arg_flags &= GTK_ARG_MASK;
arg_part = strchr (arg_name, ':');
if (!arg_part || (arg_part[0] != ':') || (arg_part[1] != ':'))
{
g_warning ("gtk_arg_type_new(): invalid arg name: \"%s\"\n", arg_name);
return NULL;
}
class_offset = (guint) (arg_part - arg_name);
strncpy (class_part, arg_name, class_offset);
class_part[class_offset] = 0;
class_type = gtk_type_from_name (class_part);
if (!gtk_type_is_a (class_type, base_class_type))
{
g_warning ("gtk_arg_type_new(): argument class in \"%s\" is not in the `%s' ancestry",
arg_name,
gtk_type_name (base_class_type));
return NULL;
}
p = gtk_type_class (class_type);
p += class_n_args_offset;
n_args_p = (guint*) p;
*n_args_p += 1;
info = g_new (GtkArgInfo, 1);
info->class_type = class_type;
info->full_name = (gchar*) arg_name; /* _static */
info->name = info->full_name + class_offset + 2;
info->type = arg_type;
info->arg_flags = arg_flags;
info->arg_id = arg_id;
info->seq_id = *n_args_p;
g_hash_table_insert (arg_info_hash_table, info, info);
return info;
}
gchar*
gtk_arg_name_strip_type (const gchar *arg_name)
{
gchar buffer[MAX_ARG_LENGTH];
gchar *p;
/* security audit
*/
if (!arg_name || strlen (arg_name) > MAX_ARG_LENGTH - 8)
return NULL;
p = strchr (arg_name, ':');
if (p)
{
guint len;
if ((p[0] != ':') || (p[1] != ':') || (p[2] == 0))
return NULL;
len = (guint) (p - arg_name);
strncpy (buffer, arg_name, len);
buffer[len] = 0;
if (gtk_type_from_name (buffer) != GTK_TYPE_INVALID)
return p + 2;
}
return (gchar*) arg_name;
}
gchar*
gtk_arg_get_info (GtkType object_type,
GHashTable *arg_info_hash_table,
const gchar *arg_name,
GtkArgInfo **info_p)
{
GtkType otype;
gchar buffer[MAX_ARG_LENGTH];
guint len;
gchar *p;
*info_p = NULL;
/* security audit
*/
if (!arg_name || strlen (arg_name) > MAX_ARG_LENGTH - 8)
return g_strdup ("argument name exceeds maximum size.");
/* split off the object-type part
*/
p = strchr (arg_name, ':');
if (p)
{
if ((p[0] != ':') || (p[1] != ':'))
return g_strconcat ("invalid argument syntax: \"",
arg_name,
"\"",
NULL);
len = (guint) (p - arg_name);
strncpy (buffer, arg_name, len);
buffer[len] = 0;
otype = gtk_type_from_name (buffer);
if (otype != GTK_TYPE_INVALID)
arg_name = p + 2;
}
else
otype = GTK_TYPE_INVALID;
/* split off the argument name
*/
p = strchr (arg_name, ':');
if (p)
{
if ((p[0] != ':') || (p[1] != ':'))
return g_strconcat ("invalid argument syntax: \"",
arg_name,
"\"",
NULL);
len = (guint) (p - arg_name);
strncpy (buffer, arg_name, len);
buffer[len] = 0;
arg_name = buffer;
}
/* lookup the argument
*/
if (otype != GTK_TYPE_INVALID)
{
GtkArgInfo info;
info.class_type = otype;
info.name = (gchar*) arg_name;
*info_p = g_hash_table_lookup (arg_info_hash_table, &info);
if (*info_p && !gtk_type_is_a (object_type, (*info_p)->class_type))
*info_p = NULL;
}
else
{
otype = object_type;
while (!*info_p && GTK_TYPE_IS_OBJECT (otype))
{
GtkArgInfo info;
info.class_type = otype;
info.name = (gchar*) arg_name;
*info_p = g_hash_table_lookup (arg_info_hash_table, &info);
otype = gtk_type_parent (otype);
}
}
if (!*info_p)
return g_strconcat ("could not find argument \"",
arg_name,
"\" in the `",
gtk_type_name (object_type),
"' class ancestry",
NULL);
return NULL;
}
gchar*
gtk_args_collect (GtkType object_type,
GHashTable *arg_info_hash_table,
GSList **arg_list_p,
GSList **info_list_p,
const gchar *first_arg_name,
va_list var_args)
{
GSList *arg_list;
GSList *info_list;
const gchar *arg_name;
g_return_val_if_fail (arg_list_p != NULL, NULL);
*arg_list_p = NULL;
g_return_val_if_fail (info_list_p != NULL, NULL);
*info_list_p = 0;
g_return_val_if_fail (arg_info_hash_table != NULL, NULL);
arg_list = NULL;
info_list = NULL;
arg_name = first_arg_name;
while (arg_name)
{
GtkArgInfo *info = NULL;
gchar *error;
error = gtk_arg_get_info (object_type, arg_info_hash_table, arg_name, &info);
if (!error)
{
GtkArg *arg;
info_list = g_slist_prepend (info_list, info);
arg = gtk_arg_new (info->type);
arg->name = (gchar*) arg_name;
GTK_ARG_COLLECT_VALUE (arg, var_args, error);
arg_list = g_slist_prepend (arg_list, arg);
}
if (error)
{
gtk_args_collect_cleanup (arg_list, info_list);
return error;
}
arg_name = va_arg (var_args, gchar*);
}
*arg_list_p = g_slist_reverse (arg_list);
*info_list_p = g_slist_reverse (info_list);
return NULL;
}
void
gtk_args_collect_cleanup (GSList *arg_list,
GSList *info_list)
{
GSList *slist;
g_slist_free (info_list);
for (slist = arg_list; slist; slist = slist->next)
gtk_arg_free (slist->data, FALSE);
g_slist_free (arg_list);
}
static void
gtk_args_query_foreach (gpointer key,
gpointer value,
gpointer user_data)
{
register GtkArgInfo *info;
register GtkArgQueryData *data;
g_assert (key == value); /* paranoid */
info = value;
data = user_data;
if (info->class_type == data->class_type)
data->arg_list = g_list_prepend (data->arg_list, info);
}
GtkArg*
gtk_args_query (GtkType class_type,
GHashTable *arg_info_hash_table,
guint32 **arg_flags,
guint *n_args_p)
{
GtkArg *args;
GtkArgQueryData query_data;
if (arg_flags)
*arg_flags = NULL;
g_return_val_if_fail (n_args_p != NULL, NULL);
*n_args_p = 0;
g_return_val_if_fail (arg_info_hash_table != NULL, NULL);
/* make sure the types class has been initialized, because
* the argument setup happens in the gtk_*_class_init() functions.
*/
gtk_type_class (class_type);
query_data.arg_list = NULL;
query_data.class_type = class_type;
g_hash_table_foreach (arg_info_hash_table, gtk_args_query_foreach, &query_data);
if (query_data.arg_list)
{
register GList *list;
register guint len;
list = query_data.arg_list;
len = 1;
while (list->next)
{
len++;
list = list->next;
}
args = g_new0 (GtkArg, len);
*n_args_p = len;
if (arg_flags)
*arg_flags = g_new (guint32, len);
do
{
GtkArgInfo *info;
info = list->data;
list = list->prev;
g_assert (info->seq_id > 0 && info->seq_id <= len); /* paranoid */
args[info->seq_id - 1].type = info->type;
args[info->seq_id - 1].name = info->full_name;
if (arg_flags)
(*arg_flags)[info->seq_id - 1] = info->arg_flags;
}
while (list);
g_list_free (query_data.arg_list);
}
else
args = NULL;
return args;
}
GtkArg*
gtk_arg_new (GtkType arg_type)
{
GtkArg *arg;
arg = g_new0 (GtkArg, 1);
arg->type = arg_type;
arg->name = NULL;
return arg;
}
GtkArg*
gtk_arg_copy (GtkArg *src_arg,
GtkArg *dest_arg)
{
g_return_val_if_fail (src_arg != NULL, NULL);
if (!dest_arg)
{
dest_arg = g_new0 (GtkArg, 1);
dest_arg->name = src_arg->name;
}
dest_arg->type = src_arg->type;
dest_arg->d = src_arg->d;
if (GTK_FUNDAMENTAL_TYPE (src_arg->type) == GTK_TYPE_STRING)
GTK_VALUE_STRING (*dest_arg) = g_strdup (GTK_VALUE_STRING (*src_arg));
return dest_arg;
}
void
gtk_arg_free (GtkArg *arg,
gboolean free_contents)
{
g_return_if_fail (arg != NULL);
if (free_contents)
gtk_arg_reset (arg);
g_free (arg);
}
void
gtk_arg_reset (GtkArg *arg)
{
GtkType fundamental_type;
g_return_if_fail (arg != NULL);
fundamental_type = GTK_FUNDAMENTAL_TYPE (arg->type);
if (fundamental_type == GTK_TYPE_STRING)
{
g_free (GTK_VALUE_STRING (*arg));
arg->type = GTK_TYPE_INVALID;
}
else if (arg->type != GTK_TYPE_INVALID)
arg->type = GTK_TYPE_INVALID;
}
gboolean
gtk_arg_info_equal (gconstpointer arg_info_1,
gconstpointer arg_info_2)
{
register const GtkArgInfo *info1 = arg_info_1;
register const GtkArgInfo *info2 = arg_info_2;
return ((info1->class_type == info2->class_type) &&
strcmp (info1->name, info2->name) == 0);
}
guint
gtk_arg_info_hash (gconstpointer arg_info)
{
register const GtkArgInfo *info = arg_info;
register const gchar *p;
register guint h = info->class_type >> 8;
for (p = info->name; *p; p++)
{
register guint g;
h = (h << 4) + *p;
g = h & 0xf0000000;
if (g)
{
h = h ^ (g >> 24);
h = h ^ g;
}
}
return h;
}
gboolean
gtk_arg_values_equal (const GtkArg *arg1,
const GtkArg *arg2)
{
GtkType fundamental_type;
gboolean equal;
g_return_val_if_fail (arg1 != NULL, FALSE);
g_return_val_if_fail (arg2 != NULL, FALSE);
g_return_val_if_fail (GTK_FUNDAMENTAL_TYPE (arg1->type) ==
GTK_FUNDAMENTAL_TYPE (arg2->type), FALSE);
fundamental_type = GTK_FUNDAMENTAL_TYPE (arg1->type);
switch (fundamental_type)
{
case GTK_TYPE_INVALID:
equal = TRUE;
break;
case GTK_TYPE_CHAR:
equal = GTK_VALUE_CHAR (*arg1) == GTK_VALUE_CHAR (*arg2);
break;
case GTK_TYPE_BOOL:
equal = (GTK_VALUE_BOOL (*arg1) != FALSE) == (GTK_VALUE_BOOL (*arg2) != FALSE);
break;
case GTK_TYPE_INT:
equal = GTK_VALUE_INT (*arg1) == GTK_VALUE_INT (*arg2);
break;
case GTK_TYPE_UINT:
equal = GTK_VALUE_UINT (*arg1) == GTK_VALUE_UINT (*arg2);
break;
case GTK_TYPE_LONG:
equal = GTK_VALUE_LONG (*arg1) == GTK_VALUE_LONG (*arg2);
break;
case GTK_TYPE_ULONG:
equal = GTK_VALUE_ULONG (*arg1) == GTK_VALUE_ULONG (*arg2);
break;
case GTK_TYPE_FLOAT:
equal = GTK_VALUE_FLOAT (*arg1) == GTK_VALUE_FLOAT (*arg2);
break;
case GTK_TYPE_DOUBLE:
equal = GTK_VALUE_DOUBLE (*arg1) == GTK_VALUE_DOUBLE (*arg2);
break;
case GTK_TYPE_STRING:
if (!GTK_VALUE_STRING (*arg1) ||
!GTK_VALUE_STRING (*arg2))
equal = GTK_VALUE_STRING (*arg1) == GTK_VALUE_STRING (*arg2);
else
equal = g_str_equal (GTK_VALUE_STRING (*arg1), GTK_VALUE_STRING (*arg2));
break;
case GTK_TYPE_ENUM:
equal = GTK_VALUE_ENUM (*arg1) == GTK_VALUE_ENUM (*arg2);
break;
case GTK_TYPE_FLAGS:
equal = GTK_VALUE_FLAGS (*arg1) == GTK_VALUE_FLAGS (*arg2);
break;
case GTK_TYPE_BOXED:
equal = GTK_VALUE_BOXED (*arg1) == GTK_VALUE_BOXED (*arg2);
break;
case G_TYPE_OBJECT:
equal = GTK_VALUE_OBJECT (*arg1) == GTK_VALUE_OBJECT (*arg2);
break;
case GTK_TYPE_POINTER:
equal = GTK_VALUE_POINTER (*arg1) == GTK_VALUE_POINTER (*arg2);
break;
default:
g_warning ("gtk_arg_values_equal() used with unknown type `%s'", gtk_type_name (arg1->type));
equal = FALSE;
break;
}
return equal;
}
void
gtk_arg_to_valueloc (GtkArg *arg,
gpointer value_pointer)
{
GtkType fundamental_type;
g_return_if_fail (arg != NULL);
g_return_if_fail (value_pointer != NULL);
fundamental_type = GTK_FUNDAMENTAL_TYPE (arg->type);
switch (fundamental_type)
{
gchar *p_char;
guchar *p_uchar;
gboolean *p_boolean;
gint *p_int;
guint *p_uint;
glong *p_long;
gulong *p_ulong;
gfloat *p_float;
gdouble *p_double;
gpointer *p_pointer;
case GTK_TYPE_CHAR:
p_char = value_pointer;
*p_char = GTK_VALUE_CHAR (*arg);
break;
case GTK_TYPE_UCHAR:
p_uchar = value_pointer;
*p_uchar = GTK_VALUE_UCHAR (*arg);
break;
case GTK_TYPE_BOOL:
p_boolean = value_pointer;
*p_boolean = GTK_VALUE_BOOL (*arg);
break;
case GTK_TYPE_INT:
case GTK_TYPE_ENUM:
p_int = value_pointer;
*p_int = GTK_VALUE_INT (*arg);
break;
case GTK_TYPE_UINT:
case GTK_TYPE_FLAGS:
p_uint = value_pointer;
*p_uint = GTK_VALUE_UINT (*arg);
break;
case GTK_TYPE_LONG:
p_long = value_pointer;
*p_long = GTK_VALUE_LONG (*arg);
break;
case GTK_TYPE_ULONG:
p_ulong = value_pointer;
*p_ulong = GTK_VALUE_ULONG (*arg);
break;
case GTK_TYPE_FLOAT:
p_float = value_pointer;
*p_float = GTK_VALUE_FLOAT (*arg);
break;
case GTK_TYPE_DOUBLE:
p_double = value_pointer;
*p_double = GTK_VALUE_DOUBLE (*arg);
break;
case GTK_TYPE_STRING:
case GTK_TYPE_POINTER:
case GTK_TYPE_BOXED:
case G_TYPE_OBJECT:
p_pointer = value_pointer;
*p_pointer = GTK_VALUE_POINTER (*arg);
break;
case GTK_TYPE_NONE:
case GTK_TYPE_INVALID:
/* it doesn't make much sense to retrive these values,
* they either are always read-only args, or require
* multiple pointers.
*/
g_warning ("gtk_arg_fill_retloc(): unsupported argument type `%s'",
gtk_type_name (arg->type));
break;
}
}

View File

@ -1,109 +0,0 @@
/* 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/.
*/
#ifndef __GTK_ARG_H__
#define __GTK_ARG_H__
#include <gtk/gtktypeutils.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct _GtkArgInfo GtkArgInfo;
struct _GtkArgInfo
{
/* hash key portion */
GtkType class_type;
gchar *name;
GtkType type;
guint arg_flags;
gchar *full_name;
/* private fields */
guint arg_id;
guint seq_id;
};
/* Non-public methods */
#define GTK_ARG_MASK 0x1f
GtkArg* gtk_arg_new (GtkType arg_type);
GtkArg* gtk_arg_copy (GtkArg *src_arg,
GtkArg *dest_arg);
void gtk_arg_free (GtkArg *arg,
gboolean free_contents);
void gtk_arg_reset (GtkArg *arg);
gboolean gtk_arg_values_equal (const GtkArg *arg1,
const GtkArg *arg2);
gchar* gtk_args_collect (GtkType object_type,
GHashTable *arg_info_hash_table,
GSList **arg_list_p,
GSList **info_list_p,
const gchar *first_arg_name,
va_list var_args);
void gtk_args_collect_cleanup (GSList *arg_list,
GSList *info_list);
gchar* gtk_arg_get_info (GtkType object_type,
GHashTable *arg_info_hash_table,
const gchar *arg_name,
GtkArgInfo **info_p);
GtkArgInfo* gtk_arg_type_new_static (GtkType base_class_type,
const gchar *arg_name,
guint class_n_args_offset,
GHashTable *arg_info_hash_table,
GtkType arg_type,
guint arg_flags,
guint arg_id);
GtkArg* gtk_args_query (GtkType class_type,
GHashTable *arg_info_hash_table,
guint32 **arg_flags,
guint *n_args_p);
gchar* gtk_arg_name_strip_type (const gchar *arg_name);
gboolean gtk_arg_info_equal (gconstpointer arg_info_1,
gconstpointer arg_info_2);
guint gtk_arg_info_hash (gconstpointer arg_info);
void gtk_arg_to_valueloc (GtkArg *arg,
gpointer value_pointer);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GTK_ARG_H__ */

View File

@ -1,149 +0,0 @@
/* 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/.
*/
/* collect a single argument value from a va_list.
* this is implemented as a huge macro <shrug>, because we can't
* pass va_list variables by reference on some systems.
* the corresponding prototype would be:
* static inline gchar*
* gtk_arg_collect_value (GtkArg *arg,
* va_list var_args);
*/
#define GTK_ARG_COLLECT_VALUE(arg, var_args, _error) \
G_STMT_START { \
gchar *error_msg; \
GtkType fundamental_type; \
\
fundamental_type = GTK_FUNDAMENTAL_TYPE (arg->type); \
\
error_msg = NULL; \
switch (fundamental_type) \
{ \
case GTK_TYPE_INVALID: \
error_msg = g_strdup ("invalid untyped argument"); \
break; \
\
case GTK_TYPE_NONE: \
/* we just ignore this type, since it arithmetically just requires \
* us to not move the var_args pointer any further. callers need to \
* check for the validity of GTK_TYPE_NONE themselves. \
* \
* error_msg = g_strdup ("invalid argument type `void'"); \
*/ \
break; \
\
/* everything smaller than an int is guarranteed to be \
* passed as an int \
*/ \
case GTK_TYPE_CHAR: \
GTK_VALUE_CHAR (*arg) = va_arg (var_args, gint); \
break; \
case GTK_TYPE_UCHAR: \
GTK_VALUE_UCHAR (*arg) = va_arg (var_args, guint); \
break; \
case GTK_TYPE_BOOL: \
GTK_VALUE_BOOL (*arg) = va_arg (var_args, gint); \
break; \
case GTK_TYPE_INT: \
GTK_VALUE_INT (*arg) = va_arg (var_args, gint); \
break; \
case GTK_TYPE_UINT: \
GTK_VALUE_UINT (*arg) = va_arg (var_args, guint); \
break; \
case GTK_TYPE_ENUM: \
GTK_VALUE_ENUM (*arg) = va_arg (var_args, gint); \
break; \
case GTK_TYPE_FLAGS: \
GTK_VALUE_FLAGS (*arg) = va_arg (var_args, guint); \
break; \
\
/* we collect longs as glongs since they differ in size with \
* integers on some platforms \
*/ \
case GTK_TYPE_LONG: \
GTK_VALUE_LONG (*arg) = va_arg (var_args, glong); \
break; \
case GTK_TYPE_ULONG: \
GTK_VALUE_ULONG (*arg) = va_arg (var_args, gulong); \
break; \
\
/* floats are always passed as doubles \
*/ \
case GTK_TYPE_FLOAT: \
/* GTK_VALUE_FLOAT (*arg) = va_arg (var_args, gfloat); */ \
GTK_VALUE_FLOAT (*arg) = va_arg (var_args, gdouble); \
break; \
case GTK_TYPE_DOUBLE: \
GTK_VALUE_DOUBLE (*arg) = va_arg (var_args, gdouble); \
break; \
\
/* collect pointer values \
*/ \
case GTK_TYPE_STRING: \
GTK_VALUE_STRING (*arg) = va_arg (var_args, gchar*); \
break; \
case GTK_TYPE_POINTER: \
GTK_VALUE_POINTER (*arg) = va_arg (var_args, gpointer); \
break; \
case GTK_TYPE_BOXED: \
GTK_VALUE_BOXED (*arg) = va_arg (var_args, gpointer); \
break; \
\
/* we do some extra sanity checking when collecting objects, \
* i.e. if the object pointer is not NULL, we check whether we \
* actually got an object pointer within the desired class branch. \
*/ \
case G_TYPE_OBJECT: \
GTK_VALUE_OBJECT (*arg) = va_arg (var_args, GtkObject*); \
if (GTK_VALUE_OBJECT (*arg) != NULL) \
{ \
register GtkObject *object = GTK_VALUE_OBJECT (*arg); \
\
if (((GTypeInstance*) object)->g_class == NULL) \
error_msg = g_strconcat ("invalid unclassed object pointer for argument type `", \
gtk_type_name (arg->type), \
"'", \
NULL); \
else if (!gtk_type_is_a (GTK_OBJECT_TYPE (object), arg->type)) \
error_msg = g_strconcat ("invalid object `", \
gtk_type_name (G_OBJECT_TYPE (object)), \
"' for argument type `", \
gtk_type_name (arg->type), \
"'", \
NULL); \
} \
break; \
\
default: \
error_msg = g_strconcat ("unsupported argument type `", \
gtk_type_name (arg->type), \
"'", \
NULL); \
break; \
} \
\
_error = error_msg; /* return error_msg; */ \
} G_STMT_END

View File

@ -34,12 +34,12 @@ enum {
};
enum {
CHILD_ARG_0,
CHILD_ARG_EXPAND,
CHILD_ARG_FILL,
CHILD_ARG_PADDING,
CHILD_ARG_PACK_TYPE,
CHILD_ARG_POSITION
CHILD_PROP_0,
CHILD_PROP_EXPAND,
CHILD_PROP_FILL,
CHILD_PROP_PADDING,
CHILD_PROP_PACK_TYPE,
CHILD_PROP_POSITION
};
static void gtk_box_class_init (GtkBoxClass *klass);
@ -62,14 +62,16 @@ static void gtk_box_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callback_data);
static void gtk_box_set_child_arg (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
guint arg_id);
static void gtk_box_get_child_arg (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
guint arg_id);
static void gtk_box_set_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_box_get_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
GValue *value,
GParamSpec *pspec);
static GtkType gtk_box_child_type (GtkContainer *container);
@ -104,21 +106,25 @@ gtk_box_get_type (void)
static void
gtk_box_class_init (GtkBoxClass *class)
{
GObjectClass *gobject_class;
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
gobject_class = (GObjectClass*) class;
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
container_class = (GtkContainerClass*) class;
parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
parent_class = g_type_class_peek_parent (class);
gobject_class->set_property = gtk_box_set_property;
gobject_class->get_property = gtk_box_get_property;
widget_class->map = gtk_box_map;
widget_class->unmap = gtk_box_unmap;
container_class->add = gtk_box_add;
container_class->remove = gtk_box_remove;
container_class->forall = gtk_box_forall;
container_class->child_type = gtk_box_child_type;
container_class->set_child_property = gtk_box_set_child_property;
container_class->get_child_property = gtk_box_get_child_property;
g_object_class_install_property (gobject_class,
PROP_SPACING,
g_param_spec_int ("spacing",
@ -137,21 +143,31 @@ gtk_box_class_init (GtkBoxClass *class)
FALSE,
G_PARAM_READABLE | G_PARAM_WRITABLE));
gtk_container_add_child_arg_type ("GtkBox::expand", GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_EXPAND);
gtk_container_add_child_arg_type ("GtkBox::fill", GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_FILL);
gtk_container_add_child_arg_type ("GtkBox::padding", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_PADDING);
gtk_container_add_child_arg_type ("GtkBox::pack_type", GTK_TYPE_PACK_TYPE, GTK_ARG_READWRITE, CHILD_ARG_PACK_TYPE);
gtk_container_add_child_arg_type ("GtkBox::position", GTK_TYPE_INT, GTK_ARG_READWRITE, CHILD_ARG_POSITION);
widget_class->map = gtk_box_map;
widget_class->unmap = gtk_box_unmap;
container_class->add = gtk_box_add;
container_class->remove = gtk_box_remove;
container_class->forall = gtk_box_forall;
container_class->child_type = gtk_box_child_type;
container_class->set_child_arg = gtk_box_set_child_arg;
container_class->get_child_arg = gtk_box_get_child_arg;
gtk_container_class_install_child_property (container_class,
CHILD_PROP_EXPAND,
g_param_spec_boolean ("expand", NULL, NULL,
TRUE,
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_FILL,
g_param_spec_boolean ("fill", NULL, NULL,
TRUE,
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_PADDING,
g_param_spec_uint ("padding", NULL, NULL,
0, G_MAXINT, 0,
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_PACK_TYPE,
g_param_spec_enum ("pack_type", NULL, NULL,
GTK_TYPE_PACK_TYPE, GTK_PACK_START,
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_POSITION,
g_param_spec_int ("position", NULL, NULL,
-1, G_MAXINT, 0,
G_PARAM_READWRITE));
}
static void
@ -218,73 +234,75 @@ gtk_box_child_type (GtkContainer *container)
}
static void
gtk_box_set_child_arg (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
guint arg_id)
gtk_box_set_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
gboolean expand = 0;
gboolean fill = 0;
guint padding = 0;
GtkPackType pack_type = 0;
if (arg_id != CHILD_ARG_POSITION)
if (property_id != CHILD_PROP_POSITION)
gtk_box_query_child_packing (GTK_BOX (container),
child,
&expand,
&fill,
&padding,
&pack_type);
switch (arg_id)
switch (property_id)
{
case CHILD_ARG_EXPAND:
case CHILD_PROP_EXPAND:
gtk_box_set_child_packing (GTK_BOX (container),
child,
GTK_VALUE_BOOL (*arg),
g_value_get_boolean (value),
fill,
padding,
pack_type);
break;
case CHILD_ARG_FILL:
case CHILD_PROP_FILL:
gtk_box_set_child_packing (GTK_BOX (container),
child,
expand,
GTK_VALUE_BOOL (*arg),
g_value_get_boolean (value),
padding,
pack_type);
break;
case CHILD_ARG_PADDING:
case CHILD_PROP_PADDING:
gtk_box_set_child_packing (GTK_BOX (container),
child,
expand,
fill,
GTK_VALUE_UINT (*arg),
g_value_get_uint (value),
pack_type);
break;
case CHILD_ARG_PACK_TYPE:
case CHILD_PROP_PACK_TYPE:
gtk_box_set_child_packing (GTK_BOX (container),
child,
expand,
fill,
padding,
GTK_VALUE_ENUM (*arg));
g_value_get_enum (value));
break;
case CHILD_ARG_POSITION:
case CHILD_PROP_POSITION:
gtk_box_reorder_child (GTK_BOX (container),
child,
GTK_VALUE_INT (*arg));
g_value_get_int (value));
break;
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
}
}
static void
gtk_box_get_child_arg (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
guint arg_id)
gtk_box_get_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
gboolean expand = 0;
gboolean fill = 0;
@ -292,30 +310,30 @@ gtk_box_get_child_arg (GtkContainer *container,
GtkPackType pack_type = 0;
GList *list;
if (arg_id != CHILD_ARG_POSITION)
if (property_id != CHILD_PROP_POSITION)
gtk_box_query_child_packing (GTK_BOX (container),
child,
&expand,
&fill,
&padding,
&pack_type);
switch (arg_id)
switch (property_id)
{
case CHILD_ARG_EXPAND:
GTK_VALUE_BOOL (*arg) = expand;
guint i;
case CHILD_PROP_EXPAND:
g_value_set_boolean (value, expand);
break;
case CHILD_ARG_FILL:
GTK_VALUE_BOOL (*arg) = fill;
case CHILD_PROP_FILL:
g_value_set_boolean (value, fill);
break;
case CHILD_ARG_PADDING:
GTK_VALUE_UINT (*arg) = padding;
case CHILD_PROP_PADDING:
g_value_set_uint (value, padding);
break;
case CHILD_ARG_PACK_TYPE:
GTK_VALUE_ENUM (*arg) = pack_type;
case CHILD_PROP_PACK_TYPE:
g_value_set_enum (value, pack_type);
break;
case CHILD_ARG_POSITION:
GTK_VALUE_INT (*arg) = 0;
case CHILD_PROP_POSITION:
i = 0;
for (list = GTK_BOX (container)->children; list; list = list->next)
{
GtkBoxChild *child_entry;
@ -323,13 +341,12 @@ gtk_box_get_child_arg (GtkContainer *container,
child_entry = list->data;
if (child_entry->widget == child)
break;
GTK_VALUE_INT (*arg)++;
i++;
}
if (!list)
GTK_VALUE_INT (*arg) = -1;
g_value_set_int (value, list ? i : -1);
break;
default:
arg->type = GTK_TYPE_INVALID;
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
}
}
@ -357,6 +374,8 @@ gtk_box_pack_start (GtkBox *box,
box->children = g_list_append (box->children, child_info);
gtk_widget_freeze_child_notify (child);
gtk_widget_set_parent (child, GTK_WIDGET (box));
if (GTK_WIDGET_REALIZED (box))
@ -369,6 +388,12 @@ gtk_box_pack_start (GtkBox *box,
gtk_widget_queue_resize (child);
}
gtk_widget_child_notify (child, "expand");
gtk_widget_child_notify (child, "fill");
gtk_widget_child_notify (child, "padding");
gtk_widget_child_notify (child, "pack_type");
gtk_widget_child_notify (child, "position");
gtk_widget_thaw_child_notify (child);
}
void
@ -394,6 +419,8 @@ gtk_box_pack_end (GtkBox *box,
box->children = g_list_append (box->children, child_info);
gtk_widget_freeze_child_notify (child);
gtk_widget_set_parent (child, GTK_WIDGET (box));
if (GTK_WIDGET_REALIZED (box))
@ -406,6 +433,12 @@ gtk_box_pack_end (GtkBox *box,
gtk_widget_queue_resize (child);
}
gtk_widget_child_notify (child, "expand");
gtk_widget_child_notify (child, "fill");
gtk_widget_child_notify (child, "padding");
gtk_widget_child_notify (child, "pack_type");
gtk_widget_child_notify (child, "position");
gtk_widget_thaw_child_notify (child);
}
void
@ -477,9 +510,9 @@ gtk_box_get_spacing (GtkBox *box)
}
void
gtk_box_reorder_child (GtkBox *box,
GtkWidget *child,
gint position)
gtk_box_reorder_child (GtkBox *box,
GtkWidget *child,
gint position)
{
GList *list;
@ -534,6 +567,7 @@ gtk_box_reorder_child (GtkBox *box,
list->next = tmp_list;
}
gtk_widget_child_notify (child, "position");
if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (box))
gtk_widget_queue_resize (child);
}
@ -602,19 +636,25 @@ gtk_box_set_child_packing (GtkBox *box,
list = list->next;
}
gtk_widget_freeze_child_notify (child);
if (list)
{
child_info->expand = expand != FALSE;
gtk_widget_child_notify (child, "expand");
child_info->fill = fill != FALSE;
gtk_widget_child_notify (child, "fill");
child_info->padding = padding;
gtk_widget_child_notify (child, "padding");
if (pack_type == GTK_PACK_END)
child_info->pack = GTK_PACK_END;
else
child_info->pack = GTK_PACK_START;
gtk_widget_child_notify (child, "pack_type");
if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (box))
gtk_widget_queue_resize (child);
}
gtk_widget_thaw_child_notify (child);
}
static void

View File

@ -34,6 +34,9 @@
#include "gtkmain.h"
#include "gtkwindow.h"
#include "gtkintl.h"
#include <gobject/gobjectnotifyqueue.c>
#include <gobject/gvaluecollector.h>
enum {
ADD,
@ -50,18 +53,13 @@ enum {
PROP_CHILD,
};
typedef struct _GtkChildArgInfo GtkChildArgInfo;
struct _GtkChildArgInfo
{
gchar *name;
GtkType type;
GtkType class_type;
guint arg_flags;
guint arg_id;
guint seq_id;
};
#define PARAM_SPEC_PARAM_ID(pspec) ((pspec)->param_id)
#define PARAM_SPEC_SET_PARAM_ID(pspec, id) ((pspec)->param_id = (id))
/* --- prototypes --- */
static void gtk_container_base_class_init (GtkContainerClass *klass);
static void gtk_container_base_class_finalize (GtkContainerClass *klass);
static void gtk_container_class_init (GtkContainerClass *klass);
static void gtk_container_init (GtkContainer *container);
static void gtk_container_destroy (GtkObject *object);
@ -100,24 +98,23 @@ static void gtk_container_show_all (GtkWidget *widget);
static void gtk_container_hide_all (GtkWidget *widget);
static gint gtk_container_expose (GtkWidget *widget,
GdkEventExpose *event);
static gchar* gtk_container_child_default_composite_name (GtkContainer *container,
GtkWidget *child);
/* --- variables --- */
static const gchar *vadjustment_key = "gtk-vadjustment";
static guint vadjustment_key_id = 0;
static const gchar *hadjustment_key = "gtk-hadjustment";
static guint hadjustment_key_id = 0;
static GSList *container_resize_queue = NULL;
static guint container_signals[LAST_SIGNAL] = { 0 };
static GtkWidgetClass *parent_class = NULL;
extern GParamSpecPool *_gtk_widget_child_property_pool;
extern GObjectNotifyContext *_gtk_widget_child_property_notify_context;
static guint container_signals[LAST_SIGNAL] = { 0 };
static GHashTable *container_child_arg_info_ht = NULL;
static GtkWidgetClass *parent_class = NULL;
static const gchar *vadjustment_key = "gtk-vadjustment";
static guint vadjustment_key_id = 0;
static const gchar *hadjustment_key = "gtk-hadjustment";
static guint hadjustment_key_id = 0;
static GSList *container_resize_queue = NULL;
/* --- functions --- */
GtkType
gtk_container_get_type (void)
{
@ -125,19 +122,20 @@ gtk_container_get_type (void)
if (!container_type)
{
static const GtkTypeInfo container_info =
{
"GtkContainer",
sizeof (GtkContainer),
static GTypeInfo container_info = {
sizeof (GtkContainerClass),
(GtkClassInitFunc) gtk_container_class_init,
(GtkObjectInitFunc) gtk_container_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) gtk_container_base_class_init,
(GBaseInitFunc) gtk_container_base_class_init,
(GBaseFinalizeFunc) gtk_container_base_class_finalize,
(GClassInitFunc) gtk_container_class_init,
NULL /* class_destroy */,
NULL /* class_data */,
sizeof (GtkContainer),
0 /* n_preallocs */,
(GInstanceInitFunc) gtk_container_init,
NULL, /* value_table */
};
container_type = gtk_type_unique (gtk_widget_get_type (), &container_info);
container_type = g_type_register_static (GTK_TYPE_WIDGET, "GtkContainer", &container_info, 0);
}
return container_type;
@ -147,26 +145,35 @@ static void
gtk_container_base_class_init (GtkContainerClass *class)
{
/* reset instance specifc class fields that don't get inherited */
class->n_child_args = 0;
class->set_child_arg = NULL;
class->get_child_arg = NULL;
class->set_child_property = NULL;
class->get_child_property = NULL;
}
static void
gtk_container_base_class_finalize (GtkContainerClass *class)
{
GList *list, *node;
list = g_param_spec_pool_belongings (_gtk_widget_child_property_pool, G_OBJECT_CLASS_TYPE (class));
for (node = list; node; node = node->next)
{
GParamSpec *pspec = node->data;
g_param_spec_pool_remove (_gtk_widget_child_property_pool, pspec);
PARAM_SPEC_SET_PARAM_ID (pspec, 0);
g_param_spec_unref (pspec);
}
g_list_free (list);
}
static void
gtk_container_class_init (GtkContainerClass *class)
{
GObjectClass *gobject_class;
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
gobject_class = G_OBJECT_CLASS (class);
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
parent_class = gtk_type_class (gtk_widget_get_type ());
container_child_arg_info_ht = g_hash_table_new (gtk_arg_info_hash,
gtk_arg_info_equal);
parent_class = g_type_class_peek_parent (class);
vadjustment_key_id = g_quark_from_static_string (vadjustment_key);
hadjustment_key_id = g_quark_from_static_string (hadjustment_key);
@ -174,6 +181,21 @@ gtk_container_class_init (GtkContainerClass *class)
gobject_class->set_property = gtk_container_set_property;
gobject_class->get_property = gtk_container_get_property;
object_class->destroy = gtk_container_destroy;
widget_class->show_all = gtk_container_show_all;
widget_class->hide_all = gtk_container_hide_all;
widget_class->expose_event = gtk_container_expose;
widget_class->focus = gtk_container_focus;
class->add = gtk_container_add_unimplemented;
class->remove = gtk_container_remove_unimplemented;
class->check_resize = gtk_container_real_check_resize;
class->forall = NULL;
class->set_focus_child = gtk_container_real_set_focus_child;
class->child_type = NULL;
class->composite_name = gtk_container_child_default_composite_name;
g_object_class_install_property (gobject_class,
PROP_RESIZE_MODE,
g_param_spec_enum ("resize_mode",
@ -198,22 +220,6 @@ gtk_container_class_init (GtkContainerClass *class)
_("Can be used to add a new child to the container."),
GTK_TYPE_WIDGET,
G_PARAM_WRITABLE));
object_class->destroy = gtk_container_destroy;
widget_class->show_all = gtk_container_show_all;
widget_class->hide_all = gtk_container_hide_all;
widget_class->expose_event = gtk_container_expose;
widget_class->focus = gtk_container_focus;
class->add = gtk_container_add_unimplemented;
class->remove = gtk_container_remove_unimplemented;
class->check_resize = gtk_container_real_check_resize;
class->forall = NULL;
class->set_focus_child = gtk_container_real_set_focus_child;
class->child_type = NULL;
class->composite_name = gtk_container_child_default_composite_name;
container_signals[ADD] =
gtk_signal_new ("add",
GTK_RUN_FIRST,
@ -248,7 +254,7 @@ gtk_container_class_init (GtkContainerClass *class)
}
GtkType
gtk_container_child_type (GtkContainer *container)
gtk_container_child_type (GtkContainer *container)
{
GtkType slot;
GtkContainerClass *class;
@ -265,16 +271,185 @@ gtk_container_child_type (GtkContainer *container)
return slot;
}
/****************************************************
* GtkContainer child argument mechanism
*
****************************************************/
/* --- GtkContainer child property mechanism --- */
static inline void
container_get_child_property (GtkContainer *container,
GtkWidget *child,
GParamSpec *pspec,
GValue *value)
{
GtkContainerClass *class = g_type_class_peek (pspec->owner_type);
class->get_child_property (container, child, PARAM_SPEC_PARAM_ID (pspec), value, pspec);
}
static inline void
container_set_child_property (GtkContainer *container,
GtkWidget *child,
GParamSpec *pspec,
const GValue *value,
GObjectNotifyQueue *nqueue)
{
GValue tmp_value = { 0, };
GtkContainerClass *class = g_type_class_peek (pspec->owner_type);
/* provide a copy to work from, convert (if necessary) and validate */
g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
if (!g_value_transform (value, &tmp_value))
g_warning ("unable to set child property `%s' of type `%s' from value of type `%s'",
pspec->name,
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
G_VALUE_TYPE_NAME (value));
else if (g_param_value_validate (pspec, &tmp_value) && !(pspec->flags & G_PARAM_LAX_VALIDATION))
{
gchar *contents = g_strdup_value_contents (value);
g_warning ("value \"%s\" of type `%s' is invalid for property `%s' of type `%s'",
contents,
G_VALUE_TYPE_NAME (value),
pspec->name,
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
g_free (contents);
}
else
{
class->set_child_property (container, child, PARAM_SPEC_PARAM_ID (pspec), &tmp_value, pspec);
g_object_notify_queue_add (G_OBJECT (child), nqueue, pspec);
}
g_value_unset (&tmp_value);
}
void
gtk_container_add_with_args (GtkContainer *container,
GtkWidget *widget,
const gchar *first_arg_name,
...)
gtk_container_child_get_valist (GtkContainer *container,
GtkWidget *child,
const gchar *first_property_name,
va_list var_args)
{
const gchar *name;
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_if_fail (child->parent == GTK_WIDGET (container));
g_object_ref (container);
g_object_ref (child);
name = first_property_name;
while (name)
{
GValue value = { 0, };
GParamSpec *pspec;
gchar *error;
pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool,
name,
G_OBJECT_TYPE (container),
TRUE);
if (!pspec)
{
g_warning ("%s: container class `%s' has no child property named `%s'",
G_STRLOC,
G_OBJECT_TYPE_NAME (container),
name);
break;
}
if (!(pspec->flags & G_PARAM_READABLE))
{
g_warning ("%s: child property `%s' of container class `%s' is not readable",
G_STRLOC,
pspec->name,
G_OBJECT_TYPE_NAME (container));
break;
}
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
container_get_child_property (container, child, pspec, &value);
G_VALUE_LCOPY (&value, var_args, 0, &error);
if (error)
{
g_warning ("%s: %s", G_STRLOC, error);
g_free (error);
g_value_unset (&value);
break;
}
g_value_unset (&value);
name = va_arg (var_args, gchar*);
}
g_object_unref (child);
g_object_unref (container);
}
void
gtk_container_child_set_valist (GtkContainer *container,
GtkWidget *child,
const gchar *first_property_name,
va_list var_args)
{
GObject *object;
GObjectNotifyQueue *nqueue;
const gchar *name;
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_if_fail (child->parent == GTK_WIDGET (container));
g_object_ref (container);
g_object_ref (child);
object = G_OBJECT (container);
nqueue = g_object_notify_queue_freeze (G_OBJECT (child), _gtk_widget_child_property_notify_context);
name = first_property_name;
while (name)
{
GValue value = { 0, };
gchar *error = NULL;
GParamSpec *pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool,
name,
G_OBJECT_TYPE (container),
TRUE);
if (!pspec)
{
g_warning ("%s: container class `%s' has no child property named `%s'",
G_STRLOC,
G_OBJECT_TYPE_NAME (container),
name);
break;
}
if (!(pspec->flags & G_PARAM_WRITABLE))
{
g_warning ("%s: child property `%s' of container class `%s' is not writable",
G_STRLOC,
pspec->name,
G_OBJECT_TYPE_NAME (container));
break;
}
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec));
G_VALUE_COLLECT (&value, var_args, 0, &error);
if (error)
{
g_warning ("%s: %s", G_STRLOC, error);
g_free (error);
/* we purposely leak the value here, it might not be
* in a sane state if an error condition occoured
*/
break;
}
container_set_child_property (container, child, pspec, &value, nqueue);
g_value_unset (&value);
name = va_arg (var_args, gchar*);
}
g_object_notify_queue_thaw (G_OBJECT (child), nqueue);
g_object_unref (container);
g_object_unref (child);
}
void
gtk_container_add_with_properties (GtkContainer *container,
GtkWidget *widget,
const gchar *first_prop_name,
...)
{
g_return_if_fail (container != NULL);
g_return_if_fail (GTK_IS_CONTAINER (container));
@ -284,325 +459,121 @@ gtk_container_add_with_args (GtkContainer *container,
gtk_widget_ref (GTK_WIDGET (container));
gtk_widget_ref (widget);
gtk_widget_freeze_child_notify (widget);
gtk_signal_emit (GTK_OBJECT (container), container_signals[ADD], widget);
if (widget->parent)
{
va_list var_args;
GSList *arg_list = NULL;
GSList *info_list = NULL;
gchar *error;
va_start (var_args, first_arg_name);
error = gtk_container_child_args_collect (GTK_OBJECT_TYPE (container),
&arg_list,
&info_list,
first_arg_name,
var_args);
va_start (var_args, first_prop_name);
gtk_container_child_set_valist (container, widget, first_prop_name, var_args);
va_end (var_args);
if (error)
{
g_warning ("gtk_container_add_with_args(): %s", error);
g_free (error);
}
else
{
GSList *slist_arg;
GSList *slist_info;
slist_arg = arg_list;
slist_info = info_list;
while (slist_arg)
{
gtk_container_arg_set (container, widget, slist_arg->data, slist_info->data);
slist_arg = slist_arg->next;
slist_info = slist_info->next;
}
gtk_args_collect_cleanup (arg_list, info_list);
}
}
gtk_widget_thaw_child_notify (widget);
gtk_widget_unref (widget);
gtk_widget_unref (GTK_WIDGET (container));
}
void
gtk_container_addv (GtkContainer *container,
GtkWidget *widget,
guint n_args,
GtkArg *args)
{
g_return_if_fail (container != NULL);
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (widget->parent == NULL);
gtk_widget_ref (GTK_WIDGET (container));
gtk_widget_ref (widget);
gtk_signal_emit (GTK_OBJECT (container), container_signals[ADD], widget);
if (widget->parent)
{
GtkArg *max_args;
for (max_args = args + n_args; args < max_args; args++)
gtk_container_arg_set (container, widget, args, NULL);
}
gtk_widget_unref (widget);
gtk_widget_unref (GTK_WIDGET (container));
}
void
gtk_container_child_setv (GtkContainer *container,
GtkWidget *child,
guint n_args,
GtkArg *args)
{
GtkArg *max_args;
g_return_if_fail (container != NULL);
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (child != NULL);
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_if_fail (child->parent != NULL);
if (n_args)
g_return_if_fail (args != NULL);
for (max_args = args + n_args; args < max_args; args++)
gtk_container_arg_set (container, child, args, NULL);
}
void
gtk_container_child_getv (GtkContainer *container,
GtkWidget *child,
guint n_args,
GtkArg *args)
{
GtkArg *max_args;
g_return_if_fail (container != NULL);
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (child != NULL);
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_if_fail (child->parent != NULL);
if (n_args)
g_return_if_fail (args != NULL);
for (max_args = args + n_args; args < max_args; args++)
gtk_container_arg_get (container, child, args, NULL);
}
void
gtk_container_child_set (GtkContainer *container,
GtkWidget *child,
const gchar *first_arg_name,
const gchar *first_prop_name,
...)
{
va_list var_args;
GSList *arg_list = NULL;
GSList *info_list = NULL;
gchar *error;
g_return_if_fail (container != NULL);
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (child != NULL);
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_if_fail (child->parent != NULL);
g_return_if_fail (child->parent == GTK_WIDGET (container));
va_start (var_args, first_arg_name);
error = gtk_container_child_args_collect (GTK_OBJECT_TYPE (container),
&arg_list,
&info_list,
first_arg_name,
var_args);
va_start (var_args, first_prop_name);
gtk_container_child_set_valist (container, child, first_prop_name, var_args);
va_end (var_args);
if (error)
{
g_warning ("gtk_container_child_set(): %s", error);
g_free (error);
}
else
{
GSList *slist_arg;
GSList *slist_info;
slist_arg = arg_list;
slist_info = info_list;
while (slist_arg)
{
gtk_container_arg_set (container, child, slist_arg->data, slist_info->data);
slist_arg = slist_arg->next;
slist_info = slist_info->next;
}
gtk_args_collect_cleanup (arg_list, info_list);
}
}
void
gtk_container_arg_set (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
GtkArgInfo *info)
gtk_container_child_get (GtkContainer *container,
GtkWidget *child,
const gchar *first_prop_name,
...)
{
GtkContainerClass *class;
va_list var_args;
g_return_if_fail (container != NULL);
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (child != NULL);
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_if_fail (arg != NULL);
if (!info)
{
gchar *error;
error = gtk_arg_get_info (GTK_OBJECT_TYPE (container),
container_child_arg_info_ht,
arg->name,
&info);
if (error)
{
g_warning ("gtk_container_arg_set(): %s", error);
g_free (error);
return;
}
}
g_return_if_fail (info->arg_flags & GTK_ARG_CHILD_ARG);
if (! (info->arg_flags & GTK_ARG_WRITABLE))
{
g_warning ("gtk_container_arg_set(): argument \"%s\" is not writable",
info->full_name);
return;
}
if (info->type != arg->type)
{
g_warning ("gtk_container_arg_set(): argument \"%s\" has invalid type `%s'",
info->full_name,
gtk_type_name (arg->type));
return;
}
class = gtk_type_class (info->class_type);
g_assert (class->set_child_arg != NULL);
class->set_child_arg (container, child, arg, info->arg_id);
g_return_if_fail (child->parent == GTK_WIDGET (container));
va_start (var_args, first_prop_name);
gtk_container_child_get_valist (container, child, first_prop_name, var_args);
va_end (var_args);
}
void
gtk_container_arg_get (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
GtkArgInfo *info)
gtk_container_class_install_child_property (GtkContainerClass *class,
guint property_id,
GParamSpec *pspec)
{
GtkContainerClass *class;
g_return_if_fail (container != NULL);
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (child != NULL);
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_if_fail (arg != NULL);
if (!info)
g_return_if_fail (GTK_IS_CONTAINER_CLASS (class));
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
if (pspec->flags & G_PARAM_WRITABLE)
g_return_if_fail (class->set_child_property != NULL);
if (pspec->flags & G_PARAM_READABLE)
g_return_if_fail (class->get_child_property != NULL);
g_return_if_fail (property_id > 0);
g_return_if_fail (PARAM_SPEC_PARAM_ID (pspec) == 0); /* paranoid */
if (pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY))
g_return_if_fail ((pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY)) == 0);
if (g_param_spec_pool_lookup (_gtk_widget_child_property_pool, pspec->name, G_OBJECT_CLASS_TYPE (class), FALSE))
{
gchar *error;
error = gtk_arg_get_info (GTK_OBJECT_TYPE (container),
container_child_arg_info_ht,
arg->name,
&info);
if (error)
{
g_warning ("gtk_container_arg_get(): %s", error);
g_free (error);
arg->type = GTK_TYPE_INVALID;
return;
}
}
g_return_if_fail (info->arg_flags & GTK_ARG_CHILD_ARG);
if (! (info->arg_flags & GTK_ARG_READABLE))
{
g_warning ("gtk_container_arg_get(): argument \"%s\" is not readable",
info->full_name);
arg->type = GTK_TYPE_INVALID;
g_warning (G_STRLOC ": class `%s' already contains a property named `%s'",
G_OBJECT_CLASS_NAME (class),
pspec->name);
return;
}
class = gtk_type_class (info->class_type);
g_assert (class->get_child_arg != NULL);
arg->type = info->type;
class->get_child_arg (container, child, arg, info->arg_id);
g_param_spec_ref (pspec);
g_param_spec_sink (pspec);
PARAM_SPEC_SET_PARAM_ID (pspec, property_id);
g_param_spec_pool_insert (_gtk_widget_child_property_pool, pspec, G_OBJECT_CLASS_TYPE (class));
}
void
gtk_container_add_child_arg_type (const gchar *arg_name,
GtkType arg_type,
guint arg_flags,
guint arg_id)
GParamSpec*
gtk_container_class_find_child_property (GObjectClass *class,
const gchar *property_name)
{
g_return_if_fail (arg_name != NULL);
g_return_if_fail (arg_type > GTK_TYPE_NONE);
g_return_if_fail (arg_id > 0);
g_return_if_fail ((arg_flags & GTK_ARG_READWRITE) == GTK_ARG_READWRITE);
/* g_return_if_fail ((arg_flags & GTK_ARG_CHILD_ARG) != 0); */
g_return_val_if_fail (GTK_IS_CONTAINER_CLASS (class), NULL);
g_return_val_if_fail (property_name != NULL, NULL);
arg_flags |= GTK_ARG_CHILD_ARG;
arg_flags &= GTK_ARG_MASK;
gtk_arg_type_new_static (GTK_TYPE_CONTAINER,
arg_name,
GTK_STRUCT_OFFSET (GtkContainerClass, n_child_args),
container_child_arg_info_ht,
arg_type,
arg_flags,
arg_id);
return g_param_spec_pool_lookup (_gtk_widget_child_property_pool,
property_name,
G_OBJECT_CLASS_TYPE (class),
TRUE);
}
gchar*
gtk_container_child_args_collect (GtkType object_type,
GSList **arg_list_p,
GSList **info_list_p,
const gchar *first_arg_name,
va_list var_args)
GParamSpec** /* free result */
gtk_container_class_list_child_properties (GObjectClass *class,
guint *n_properties)
{
return gtk_args_collect (object_type,
container_child_arg_info_ht,
arg_list_p,
info_list_p,
first_arg_name,
var_args);
GParamSpec **pspecs;
guint n;
g_return_val_if_fail (GTK_IS_CONTAINER_CLASS (class), NULL);
pspecs = g_param_spec_pool_list (_gtk_widget_child_property_pool,
G_OBJECT_CLASS_TYPE (class),
&n);
if (n_properties)
*n_properties = n;
return pspecs;
}
gchar*
gtk_container_child_arg_get_info (GtkType object_type,
const gchar *arg_name,
GtkArgInfo **info_p)
{
return gtk_arg_get_info (object_type,
container_child_arg_info_ht,
arg_name,
info_p);
}
GtkArg*
gtk_container_query_child_args (GtkType class_type,
guint32 **arg_flags,
guint *n_args)
{
g_return_val_if_fail (n_args != NULL, NULL);
*n_args = 0;
g_return_val_if_fail (gtk_type_is_a (class_type, GTK_TYPE_CONTAINER), NULL);
return gtk_args_query (class_type, container_child_arg_info_ht, arg_flags, n_args);
}
static void
gtk_container_add_unimplemented (GtkContainer *container,
GtkWidget *widget)

View File

@ -72,32 +72,31 @@ struct _GtkContainer
struct _GtkContainerClass
{
GtkWidgetClass parent_class;
guint n_child_args;
void (* add) (GtkContainer *container,
void (*add) (GtkContainer *container,
GtkWidget *widget);
void (* remove) (GtkContainer *container,
void (*remove) (GtkContainer *container,
GtkWidget *widget);
void (* check_resize) (GtkContainer *container);
void (* forall) (GtkContainer *container,
void (*check_resize) (GtkContainer *container);
void (*forall) (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callback_data);
void (* set_focus_child) (GtkContainer *container,
void (*set_focus_child) (GtkContainer *container,
GtkWidget *widget);
GtkType (*child_type) (GtkContainer *container);
void (*set_child_arg) (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
guint arg_id);
void (*get_child_arg) (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
guint arg_id);
gchar* (*composite_name) (GtkContainer *container,
GtkWidget *child);
GtkType (*child_type) (GtkContainer *container);
gchar* (*composite_name) (GtkContainer *container,
GtkWidget *child);
void (*set_child_property) (GtkContainer *container,
GtkWidget *child,
guint property_id,
const GValue *value,
GParamSpec *pspec);
void (*get_child_property) (GtkContainer *container,
GtkWidget *child,
guint property_id,
GValue *value,
GParamSpec *pspec);
/* Padding for future expansion */
GtkFunction pad1;
GtkFunction pad2;
@ -150,77 +149,43 @@ void gtk_container_resize_children (GtkContainer *container);
GtkType gtk_container_child_type (GtkContainer *container);
/* the `arg_name' argument needs to be a const static string */
void gtk_container_add_child_arg_type (const gchar *arg_name,
GtkType arg_type,
guint arg_flags,
guint arg_id);
/* Allocate a GtkArg array of size nargs that hold the
* names and types of the args that can be used with
* gtk_container_child_getv/gtk_container_child_setv.
* if (arg_flags!=NULL),
* (*arg_flags) will be set to point to a newly allocated
* guint array that holds the flags of the args.
* It is the callers response to do a
* g_free (returned_args); g_free (*arg_flags).
*/
GtkArg* gtk_container_query_child_args (GtkType class_type,
guint32 **arg_flags,
guint *nargs);
/* gtk_container_child_getv() sets an arguments type and value, or just
* its type to GTK_TYPE_INVALID.
* if GTK_FUNDAMENTAL_TYPE (arg->type) == GTK_TYPE_STRING, it's the callers
* response to do a g_free (GTK_VALUE_STRING (arg));
*/
void gtk_container_child_getv (GtkContainer *container,
GtkWidget *child,
guint n_args,
GtkArg *args);
void gtk_container_child_setv (GtkContainer *container,
GtkWidget *child,
guint n_args,
GtkArg *args);
void gtk_container_class_install_child_property (GtkContainerClass *cclass,
guint property_id,
GParamSpec *pspec);
GParamSpec* gtk_container_class_find_child_property (GObjectClass *cclass,
const gchar *property_name);
GParamSpec** gtk_container_class_list_child_properties (GObjectClass *cclass,
guint *n_properties);
void gtk_container_add_with_properties (GtkContainer *container,
GtkWidget *widget,
const gchar *first_prop_name,
...);
void gtk_container_child_set (GtkContainer *container,
GtkWidget *child,
const gchar *first_prop_name,
...);
void gtk_container_child_get (GtkContainer *container,
GtkWidget *child,
const gchar *first_prop_name,
...);
void gtk_container_child_set_valist (GtkContainer *container,
GtkWidget *child,
const gchar *first_property_name,
va_list var_args);
void gtk_container_child_get_valist (GtkContainer *container,
GtkWidget *child,
const gchar *first_property_name,
va_list var_args);
#define GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID(object, property_id, pspec) \
G_OBJECT_WARN_INVALID_PSPEC ((object), "child property id", (property_id), (pspec))
/* gtk_container_add_with_args() takes a variable argument list of the form:
* (..., gchar *arg_name, ARG_VALUES, [repeatedly name/value pairs,] NULL)
* where ARG_VALUES type depend on the argument and can consist of
* more than one c-function argument.
*/
void gtk_container_add_with_args (GtkContainer *container,
GtkWidget *widget,
const gchar *first_arg_name,
...);
void gtk_container_addv (GtkContainer *container,
GtkWidget *widget,
guint n_args,
GtkArg *args);
void gtk_container_child_set (GtkContainer *container,
GtkWidget *child,
const gchar *first_arg_name,
...);
/* Non-public methods */
void gtk_container_queue_resize (GtkContainer *container);
void gtk_container_clear_resize_widgets (GtkContainer *container);
void gtk_container_arg_set (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
GtkArgInfo *info);
void gtk_container_arg_get (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
GtkArgInfo *info);
gchar* gtk_container_child_args_collect (GtkType object_type,
GSList **arg_list_p,
GSList **info_list_p,
const gchar *first_arg_name,
va_list args);
gchar* gtk_container_child_arg_get_info (GtkType object_type,
const gchar *arg_name,
GtkArgInfo **info_p);
void gtk_container_forall (GtkContainer *container,
GtkCallback callback,
gpointer callback_data);

View File

@ -72,13 +72,13 @@ enum {
};
enum {
CHILD_ARG_0,
CHILD_ARG_TAB_LABEL,
CHILD_ARG_MENU_LABEL,
CHILD_ARG_POSITION,
CHILD_ARG_TAB_EXPAND,
CHILD_ARG_TAB_FILL,
CHILD_ARG_TAB_PACK
CHILD_PROP_0,
CHILD_PROP_TAB_LABEL,
CHILD_PROP_MENU_LABEL,
CHILD_PROP_POSITION,
CHILD_PROP_TAB_EXPAND,
CHILD_PROP_TAB_FILL,
CHILD_PROP_TAB_PACK
};
#define GTK_NOTEBOOK_PAGE(_glist_) ((GtkNotebookPage *)((GList *)(_glist_))->data)
@ -160,14 +160,16 @@ static gint gtk_notebook_focus (GtkWidget *widget,
GtkDirectionType direction);
/*** GtkContainer Methods ***/
static void gtk_notebook_set_child_arg (GtkContainer *container,
static void gtk_notebook_set_child_property (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
guint arg_id);
static void gtk_notebook_get_child_arg (GtkContainer *container,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_notebook_get_child_property (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
guint arg_id);
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gtk_notebook_add (GtkContainer *container,
GtkWidget *widget);
static void gtk_notebook_remove (GtkContainer *container,
@ -279,18 +281,13 @@ gtk_notebook_get_type (void)
static void
gtk_notebook_class_init (GtkNotebookClass *class)
{
GObjectClass *gobject_class;
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
GtkBindingSet *binding_set;
gobject_class = G_OBJECT_CLASS (class);
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
container_class = (GtkContainerClass*) class;
parent_class = gtk_type_class (gtk_container_get_type ());
parent_class = g_type_class_peek_parent (class);
gobject_class->set_property = gtk_notebook_set_property;
gobject_class->get_property = gtk_notebook_get_property;
@ -316,8 +313,8 @@ gtk_notebook_class_init (GtkNotebookClass *class)
container_class->remove = gtk_notebook_remove;
container_class->forall = gtk_notebook_forall;
container_class->set_focus_child = gtk_notebook_set_focus_child;
container_class->get_child_arg = gtk_notebook_get_child_arg;
container_class->set_child_arg = gtk_notebook_set_child_arg;
container_class->get_child_property = gtk_notebook_get_child_property;
container_class->set_child_property = gtk_notebook_set_child_property;
container_class->child_type = gtk_notebook_child_type;
class->switch_page = gtk_notebook_real_switch_page;
@ -334,92 +331,108 @@ gtk_notebook_class_init (GtkNotebookClass *class)
G_MAXINT,
0,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_TAB_POS,
g_param_spec_enum ("tab_pos",
g_object_class_install_property (gobject_class,
PROP_TAB_POS,
g_param_spec_enum ("tab_pos",
_("Tab Position"),
_("Which side of the notebook holds the tabs"),
GTK_TYPE_POSITION_TYPE,
GTK_POS_TOP,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_TAB_BORDER,
g_param_spec_uint ("tab_border",
g_object_class_install_property (gobject_class,
PROP_TAB_BORDER,
g_param_spec_uint ("tab_border",
_("Tab Border"),
_("Width of the border around the tab labels"),
0,
G_MAXUINT,
2,
G_PARAM_WRITABLE));
g_object_class_install_property (gobject_class,
PROP_TAB_HBORDER,
g_param_spec_uint ("tab_hborder",
g_object_class_install_property (gobject_class,
PROP_TAB_HBORDER,
g_param_spec_uint ("tab_hborder",
_("Horizontal Tab Border"),
_("Width of the horizontal border of tab labels"),
0,
G_MAXUINT,
2,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_TAB_VBORDER,
g_param_spec_uint ("tab_vborder",
g_object_class_install_property (gobject_class,
PROP_TAB_VBORDER,
g_param_spec_uint ("tab_vborder",
_("Vertical Tab Border"),
_("Width of the vertical border of tab labels"),
0,
G_MAXUINT,
2,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_SHOW_TABS,
g_param_spec_boolean ("show_tabs",
g_object_class_install_property (gobject_class,
PROP_SHOW_TABS,
g_param_spec_boolean ("show_tabs",
_("Show Tabs"),
_("Whether tabs should be shown or not"),
TRUE,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_SHOW_BORDER,
g_param_spec_boolean ("show_border",
g_object_class_install_property (gobject_class,
PROP_SHOW_BORDER,
g_param_spec_boolean ("show_border",
_("Show Border"),
_("Whether the border should be shown or not"),
TRUE,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_SCROLLABLE,
g_param_spec_boolean ("scrollable",
g_object_class_install_property (gobject_class,
PROP_SCROLLABLE,
g_param_spec_boolean ("scrollable",
_("Scrollable"),
_("If TRUE, scroll arrows are added if there are to many tabs to fit"),
FALSE,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_ENABLE_POPUP,
g_param_spec_boolean ("enable_popup",
g_object_class_install_property (gobject_class,
PROP_ENABLE_POPUP,
g_param_spec_boolean ("enable_popup",
_("Enable Popup"),
_("If TRUE, pressing the right mouse button on the notebook pops up a menu that you can use to go to a page"),
FALSE,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_HOMOGENEOUS,
g_param_spec_boolean ("homogeneous",
g_object_class_install_property (gobject_class,
PROP_HOMOGENEOUS,
g_param_spec_boolean ("homogeneous",
_("Homogeneous"),
_("Whether tabs should have homogeneous sizes"),
FALSE,
G_PARAM_READWRITE));
gtk_container_add_child_arg_type ("GtkNotebook::tab_label", GTK_TYPE_STRING, GTK_ARG_READWRITE, CHILD_ARG_TAB_LABEL);
gtk_container_add_child_arg_type ("GtkNotebook::menu_label", GTK_TYPE_STRING, GTK_ARG_READWRITE, CHILD_ARG_MENU_LABEL);
gtk_container_add_child_arg_type ("GtkNotebook::position", GTK_TYPE_INT, GTK_ARG_READWRITE, CHILD_ARG_POSITION);
gtk_container_add_child_arg_type ("GtkNotebook::tab_fill", GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_TAB_FILL);
gtk_container_add_child_arg_type ("GtkNotebook::tab_pack", GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_TAB_PACK);
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_TAB_LABEL,
g_param_spec_string ("tab_label", NULL, NULL,
NULL,
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_MENU_LABEL,
g_param_spec_string ("menu_label", NULL, NULL,
NULL,
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_POSITION,
g_param_spec_int ("position", NULL, NULL,
-1, G_MAXINT, 0,
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_TAB_EXPAND,
g_param_spec_boolean ("tab_expand", NULL, NULL,
TRUE,
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_TAB_FILL,
g_param_spec_boolean ("tab_fill", NULL, NULL,
TRUE,
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_TAB_PACK,
g_param_spec_boolean ("tab_pack", NULL, NULL,
TRUE,
G_PARAM_READWRITE));
notebook_signals[SWITCH_PAGE] =
gtk_signal_new ("switch_page",
GTK_RUN_LAST,
@ -429,7 +442,6 @@ gtk_notebook_class_init (GtkNotebookClass *class)
GTK_TYPE_NONE, 2,
GTK_TYPE_POINTER,
GTK_TYPE_UINT);
notebook_signals[FOCUS_TAB] =
g_signal_newc ("focus_tab",
G_TYPE_FROM_CLASS (object_class),
@ -439,7 +451,6 @@ gtk_notebook_class_init (GtkNotebookClass *class)
gtk_marshal_VOID__ENUM,
G_TYPE_NONE, 1,
GTK_TYPE_NOTEBOOK_TAB);
notebook_signals[SELECT_PAGE] =
g_signal_newc ("select_page",
G_TYPE_FROM_CLASS (object_class),
@ -451,22 +462,18 @@ gtk_notebook_class_init (GtkNotebookClass *class)
G_TYPE_BOOLEAN);
binding_set = gtk_binding_set_by_class (object_class);
gtk_binding_entry_add_signal (binding_set,
GDK_Return, 0,
"select_page", 1,
G_TYPE_BOOLEAN, TRUE);
gtk_binding_entry_add_signal (binding_set,
GDK_KP_Enter, 0,
"select_page", 1,
G_TYPE_BOOLEAN, TRUE);
gtk_binding_entry_add_signal (binding_set,
GDK_space, 0,
"select_page", 1,
G_TYPE_BOOLEAN, FALSE);
gtk_binding_entry_add_signal (binding_set,
GDK_Home, 0,
"focus_tab", 1,
@ -1477,64 +1484,67 @@ gtk_notebook_style_set (GtkWidget *widget,
* gtk_notebook_forall
*/
static void
gtk_notebook_set_child_arg (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
guint arg_id)
gtk_notebook_set_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
gboolean expand;
gboolean fill;
GtkPackType pack_type;
switch (arg_id)
switch (property_id)
{
case CHILD_ARG_TAB_LABEL:
case CHILD_PROP_TAB_LABEL:
/* a NULL pointer indicates a default_tab setting, otherwise
* we need to set the associated label
*/
gtk_notebook_set_tab_label_text (GTK_NOTEBOOK (container), child,
GTK_VALUE_STRING(*arg));
g_value_get_string (value));
break;
case CHILD_ARG_MENU_LABEL:
case CHILD_PROP_MENU_LABEL:
gtk_notebook_set_menu_label_text (GTK_NOTEBOOK (container), child,
GTK_VALUE_STRING (*arg));
g_value_get_string (value));
break;
case CHILD_ARG_POSITION:
case CHILD_PROP_POSITION:
gtk_notebook_reorder_child (GTK_NOTEBOOK (container), child,
GTK_VALUE_INT (*arg));
g_value_get_int (value));
break;
case CHILD_ARG_TAB_EXPAND:
case CHILD_PROP_TAB_EXPAND:
gtk_notebook_query_tab_label_packing (GTK_NOTEBOOK (container), child,
&expand, &fill, &pack_type);
gtk_notebook_set_tab_label_packing (GTK_NOTEBOOK (container), child,
GTK_VALUE_BOOL (*arg),
g_value_get_boolean (value),
fill, pack_type);
break;
case CHILD_ARG_TAB_FILL:
case CHILD_PROP_TAB_FILL:
gtk_notebook_query_tab_label_packing (GTK_NOTEBOOK (container), child,
&expand, &fill, &pack_type);
gtk_notebook_set_tab_label_packing (GTK_NOTEBOOK (container), child,
expand,
GTK_VALUE_BOOL (*arg),
g_value_get_boolean (value),
pack_type);
break;
case CHILD_ARG_TAB_PACK:
case CHILD_PROP_TAB_PACK:
gtk_notebook_query_tab_label_packing (GTK_NOTEBOOK (container), child,
&expand, &fill, &pack_type);
gtk_notebook_set_tab_label_packing (GTK_NOTEBOOK (container), child,
expand, fill,
GTK_VALUE_BOOL (*arg));
g_value_get_enum (value));
break;
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
}
}
static void
gtk_notebook_get_child_arg (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
guint arg_id)
gtk_notebook_get_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GList *list;
GtkNotebook *notebook;
@ -1545,53 +1555,51 @@ gtk_notebook_get_child_arg (GtkContainer *container,
notebook = GTK_NOTEBOOK (container);
arg->type = GTK_TYPE_INVALID;
list = CHECK_FIND_CHILD (notebook, child);
if (!list)
{
arg->type = GTK_TYPE_INVALID;
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
return;
}
switch (arg_id)
switch (property_id)
{
case CHILD_ARG_TAB_LABEL:
case CHILD_PROP_TAB_LABEL:
label = gtk_notebook_get_tab_label (notebook, child);
if (label && GTK_IS_LABEL (label))
GTK_VALUE_STRING (*arg) = g_strdup (GTK_LABEL (label)->label);
g_value_set_string (value, GTK_LABEL (label)->label);
else
GTK_VALUE_STRING (*arg) = NULL;
g_value_set_string (value, NULL);
break;
case CHILD_ARG_MENU_LABEL:
case CHILD_PROP_MENU_LABEL:
label = gtk_notebook_get_menu_label (notebook, child);
if (label && GTK_IS_LABEL (label))
GTK_VALUE_STRING (*arg) = g_strdup (GTK_LABEL (label)->label);
g_value_set_string (value, GTK_LABEL (label)->label);
else
GTK_VALUE_STRING (*arg) = NULL;
g_value_set_string (value, NULL);
break;
case CHILD_ARG_POSITION:
GTK_VALUE_INT (*arg) = g_list_position (notebook->children, list);
case CHILD_PROP_POSITION:
g_value_set_int (value, g_list_position (notebook->children, list));
break;
case CHILD_ARG_TAB_EXPAND:
case CHILD_PROP_TAB_EXPAND:
gtk_notebook_query_tab_label_packing (GTK_NOTEBOOK (container), child,
&expand, NULL, NULL);
GTK_VALUE_BOOL (*arg) = expand;
g_value_set_boolean (value, expand);
break;
case CHILD_ARG_TAB_FILL:
case CHILD_PROP_TAB_FILL:
gtk_notebook_query_tab_label_packing (GTK_NOTEBOOK (container), child,
NULL, &fill, NULL);
GTK_VALUE_BOOL (*arg) = fill;
g_value_set_boolean (value, fill);
break;
case CHILD_ARG_TAB_PACK:
case CHILD_PROP_TAB_PACK:
gtk_notebook_query_tab_label_packing (GTK_NOTEBOOK (container), child,
NULL, NULL, &pack_type);
GTK_VALUE_BOOL (*arg) = pack_type;
g_value_set_enum (value, pack_type);
break;
default:
arg->type = GTK_TYPE_INVALID;
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
}
}
@ -3802,6 +3810,8 @@ gtk_notebook_insert_page_menu (GtkNotebook *notebook,
g_return_if_fail (tab_label == NULL || GTK_IS_WIDGET (tab_label));
g_return_if_fail (menu_label == NULL || GTK_IS_WIDGET (menu_label));
gtk_widget_freeze_child_notify (child);
page = g_new (GtkNotebookPage, 1);
page->child = child;
page->requisition.width = 0;
@ -3900,6 +3910,14 @@ gtk_notebook_insert_page_menu (GtkNotebook *notebook,
"mnemonic_activate",
(GtkSignalFunc) gtk_notebook_mnemonic_activate_switch_page,
notebook);
gtk_widget_child_notify (child, "tab_expand");
gtk_widget_child_notify (child, "tab_fill");
gtk_widget_child_notify (child, "tab_pack");
gtk_widget_child_notify (child, "tab_label");
gtk_widget_child_notify (child, "menu_label");
gtk_widget_child_notify (child, "position");
gtk_widget_thaw_child_notify (child);
}
/**
@ -4515,6 +4533,7 @@ gtk_notebook_set_tab_label (GtkNotebook *notebook,
gtk_widget_show (page->tab_label);
gtk_widget_queue_resize (GTK_WIDGET (notebook));
}
gtk_widget_child_notify (child, "tab_label");
}
/**
@ -4538,6 +4557,7 @@ gtk_notebook_set_tab_label_text (GtkNotebook *notebook,
if (tab_text)
tab_label = gtk_label_new (tab_text);
gtk_notebook_set_tab_label (notebook, child, tab_label);
gtk_widget_child_notify (child, "tab_label");
}
/**
@ -4617,6 +4637,7 @@ gtk_notebook_set_menu_label (GtkNotebook *notebook,
if (notebook->menu)
gtk_notebook_menu_item_create (notebook, list);
gtk_widget_child_notify (child, "menu_label");
}
/**
@ -4639,6 +4660,7 @@ gtk_notebook_set_menu_label_text (GtkNotebook *notebook,
if (menu_text)
menu_label = gtk_label_new (menu_text);
gtk_notebook_set_menu_label (notebook, child, menu_label);
gtk_widget_child_notify (child, "menu_label");
}
/* Helper function called when pages are reordered
@ -4691,22 +4713,26 @@ gtk_notebook_set_tab_label_packing (GtkNotebook *notebook,
return;
page = list->data;
expand = expand != FALSE;
fill = fill != FALSE;
if (page->pack == pack_type && page->expand == expand && page->fill == fill)
return;
gtk_widget_freeze_child_notify (child);
page->expand = expand;
gtk_widget_child_notify (child, "tab_expand");
page->fill = fill;
gtk_widget_child_notify (child, "tab_fill");
if (page->pack != pack_type)
{
page->pack = pack_type;
gtk_notebook_child_reordered (notebook, page);
}
if (!notebook->show_tabs)
return;
gtk_notebook_pages_allocate (notebook);
gtk_widget_child_notify (child, "tab_pack");
gtk_widget_child_notify (child, "position");
if (notebook->show_tabs)
gtk_notebook_pages_allocate (notebook);
gtk_widget_thaw_child_notify (child);
}
/**
@ -4788,9 +4814,15 @@ gtk_notebook_reorder_child (GtkNotebook *notebook,
if (notebook->focus_tab == list)
notebook->focus_tab = new_list;
gtk_widget_freeze_child_notify (child);
/* Move around the menu items if necesary */
gtk_notebook_child_reordered (notebook, page);
gtk_widget_child_notify (child, "tab_pack");
gtk_widget_child_notify (child, "position");
if (notebook->show_tabs)
gtk_notebook_pages_allocate (notebook);
gtk_widget_thaw_child_notify (child);
}

View File

@ -28,7 +28,6 @@
#define __GTK_OBJECT_H__
#include <gtk/gtkarg.h>
#include <gtk/gtkenums.h>
#include <gtk/gtktypeutils.h>
#include <gtk/gtkdebug.h>

View File

@ -54,7 +54,6 @@ static guint settings_install_property_parser (GtkSettingsClass *class,
static gpointer parent_class = NULL;
static GtkSettings *the_singleton = NULL;
static GQuark quark_property_parser = 0;
static GQuark quark_property_id = 0;
static GSList *object_list = NULL;
static guint class_n_properties = 0;
@ -89,8 +88,8 @@ gtk_settings_get_type (void)
static void
gtk_settings_init (GtkSettings *settings)
{
GObjectClass *gobject_class = G_OBJECT_GET_CLASS (settings);
guint i;
GParamSpec **pspecs, **p;
guint i = 0;
g_datalist_init (&settings->queued_settings);
object_list = g_slist_prepend (object_list, settings);
@ -99,15 +98,24 @@ gtk_settings_init (GtkSettings *settings)
* notification for them (at least notification for internal properties
* will instantly be caught)
*/
settings->property_values = g_new0 (GValue, class_n_properties);
for (i = 0; i < class_n_properties; i++)
pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (settings), NULL);
for (p = pspecs; *p; p++)
if ((*p)->owner_type == G_OBJECT_TYPE (settings))
i++;
settings->property_values = g_new0 (GValue, i);
i = 0;
for (p = pspecs; *p; p++)
{
GParamSpec *pspec = gobject_class->property_specs[i]; // FIXME: g_object_list_properties(this_class_type)
GParamSpec *pspec = *p;
if (pspec->owner_type != G_OBJECT_TYPE (settings))
continue;
g_value_init (settings->property_values + i, G_PARAM_SPEC_VALUE_TYPE (pspec));
g_param_value_set_default (pspec, settings->property_values + i);
g_object_notify (G_OBJECT (settings), pspec->name);
i++;
}
g_free (pspecs);
}
static void
@ -125,8 +133,6 @@ gtk_settings_class_init (GtkSettingsClass *class)
gobject_class->notify = gtk_settings_notify;
quark_property_parser = g_quark_from_static_string ("gtk-rc-property-parser");
quark_property_id = g_quark_try_string ("GObject-property-id");
g_assert (quark_property_id != 0); /* special quarks from GObjectClass */
result = settings_install_property_parser (class,
g_param_spec_int ("gtk-double-click-time",
@ -286,7 +292,7 @@ static void
gtk_settings_notify (GObject *object,
GParamSpec *pspec)
{
guint property_id = GPOINTER_TO_UINT (g_param_spec_get_qdata ((pspec), quark_property_id));
guint property_id = pspec->param_id;
gint double_click_time;
#if 1

View File

@ -18,7 +18,6 @@
*/
#include "gtksignal.h"
#include "gtkargcollector.c"
#include "gtkmarshal.c"
@ -345,93 +344,6 @@ gtk_signal_emitv (GtkObject *object,
g_value_unset (params + 0);
}
static gboolean
gtk_signal_collect_args (GtkArg *args,
guint n_args,
const GtkType *arg_types,
GtkType return_type,
va_list var_args)
{
register GtkArg *last_arg;
register gboolean failed = FALSE;
for (last_arg = args + n_args; args < last_arg; args++)
{
register gchar *error;
args->name = NULL;
args->type = *(arg_types++);
GTK_ARG_COLLECT_VALUE (args,
var_args,
error);
if (error)
{
failed = TRUE;
g_warning ("gtk_signal_collect_args(): %s", error);
g_free (error);
}
}
args->type = return_type;
args->name = NULL;
return_type = GTK_FUNDAMENTAL_TYPE (return_type);
if (return_type != G_TYPE_NONE)
{
if (return_type != 0) /* FIXME: check for IS_ARG */
{
GTK_VALUE_POINTER (*args) = va_arg (var_args, gpointer);
if (GTK_VALUE_POINTER (*args) == NULL)
{
failed = TRUE;
g_warning ("gtk_signal_collect_args(): invalid NULL pointer for return argument type `%s'",
gtk_type_name (args->type));
}
}
else
{
failed = TRUE;
g_warning ("gtk_signal_collect_args(): unsupported return argument type `%s'",
gtk_type_name (args->type));
}
}
else
GTK_VALUE_POINTER (*args) = NULL;
return failed;
}
#if 0
void
gtk_signal_emit (GtkObject *object,
guint signal_id,
...)
{
GtkArg args[SIGNAL_MAX_PARAMS + 1];
GSignalQuery query;
gboolean abort;
va_list var_args;
g_return_if_fail (GTK_IS_OBJECT (object));
g_signal_query (signal_id, &query);
g_return_if_fail (query.signal_id != 0);
g_return_if_fail (query.n_params < SIGNAL_MAX_PARAMS);
va_start (var_args, signal_id);
abort = gtk_signal_collect_args (args,
query.n_params,
query.param_types,
query.return_type,
var_args);
va_end (var_args);
if (!abort)
gtk_signal_emitv (object, signal_id, args);
}
#endif
void
gtk_signal_emit (GtkObject *object,
guint signal_id,
@ -451,9 +363,7 @@ gtk_signal_emit_by_name (GtkObject *object,
const gchar *name,
...)
{
GtkArg args[SIGNAL_MAX_PARAMS + 1];
GSignalQuery query;
gboolean abort;
va_list var_args;
g_return_if_fail (GTK_IS_OBJECT (object));
@ -461,18 +371,10 @@ gtk_signal_emit_by_name (GtkObject *object,
g_signal_query (g_signal_lookup (name, GTK_OBJECT_TYPE (object)), &query);
g_return_if_fail (query.signal_id != 0);
g_return_if_fail (query.n_params < SIGNAL_MAX_PARAMS);
va_start (var_args, name);
abort = gtk_signal_collect_args (args,
query.n_params,
query.param_types,
query.return_type,
var_args);
g_signal_emit_valist (G_OBJECT (object), query.signal_id, 0, var_args);
va_end (var_args);
if (!abort)
gtk_signal_emitv (object, query.signal_id, args);
}
void

View File

@ -39,15 +39,15 @@ enum
enum
{
CHILD_ARG_0,
CHILD_ARG_LEFT_ATTACH,
CHILD_ARG_RIGHT_ATTACH,
CHILD_ARG_TOP_ATTACH,
CHILD_ARG_BOTTOM_ATTACH,
CHILD_ARG_X_OPTIONS,
CHILD_ARG_Y_OPTIONS,
CHILD_ARG_X_PADDING,
CHILD_ARG_Y_PADDING
CHILD_PROP_0,
CHILD_PROP_LEFT_ATTACH,
CHILD_PROP_RIGHT_ATTACH,
CHILD_PROP_TOP_ATTACH,
CHILD_PROP_BOTTOM_ATTACH,
CHILD_PROP_X_OPTIONS,
CHILD_PROP_Y_OPTIONS,
CHILD_PROP_X_PADDING,
CHILD_PROP_Y_PADDING
};
@ -76,14 +76,16 @@ static void gtk_table_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_table_set_child_arg (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
guint arg_id);
static void gtk_table_get_child_arg (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
guint arg_id);
static void gtk_table_set_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_table_get_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
GValue *value,
GParamSpec *pspec);
static GtkType gtk_table_child_type (GtkContainer *container);
@ -129,15 +131,10 @@ static void
gtk_table_class_init (GtkTableClass *class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
container_class = (GtkContainerClass*) class;
parent_class = gtk_type_class (gtk_container_get_type ());
parent_class = g_type_class_peek_parent (class);
gobject_class->finalize = gtk_table_finalize;
@ -153,8 +150,8 @@ gtk_table_class_init (GtkTableClass *class)
container_class->remove = gtk_table_remove;
container_class->forall = gtk_table_forall;
container_class->child_type = gtk_table_child_type;
container_class->set_child_arg = gtk_table_set_child_arg;
container_class->get_child_arg = gtk_table_get_child_arg;
container_class->set_child_property = gtk_table_set_child_property;
container_class->get_child_property = gtk_table_get_child_property;
g_object_class_install_property (gobject_class,
@ -166,7 +163,6 @@ gtk_table_class_init (GtkTableClass *class)
G_MAXUINT,
0,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_N_COLUMNS,
g_param_spec_uint ("n_columns",
@ -176,7 +172,6 @@ gtk_table_class_init (GtkTableClass *class)
G_MAXUINT,
0,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_ROW_SPACING,
g_param_spec_uint ("row_spacing",
@ -186,7 +181,6 @@ gtk_table_class_init (GtkTableClass *class)
G_MAXUINT,
0,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_COLUMN_SPACING,
g_param_spec_uint ("column_spacing",
@ -196,7 +190,6 @@ gtk_table_class_init (GtkTableClass *class)
G_MAXUINT,
0,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_HOMOGENEOUS,
g_param_spec_boolean ("homogeneous",
@ -205,14 +198,46 @@ gtk_table_class_init (GtkTableClass *class)
FALSE,
G_PARAM_READWRITE));
gtk_container_add_child_arg_type ("GtkTable::left_attach", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_LEFT_ATTACH);
gtk_container_add_child_arg_type ("GtkTable::right_attach", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_RIGHT_ATTACH);
gtk_container_add_child_arg_type ("GtkTable::top_attach", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_TOP_ATTACH);
gtk_container_add_child_arg_type ("GtkTable::bottom_attach", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_BOTTOM_ATTACH);
gtk_container_add_child_arg_type ("GtkTable::x_options", GTK_TYPE_ATTACH_OPTIONS, GTK_ARG_READWRITE, CHILD_ARG_X_OPTIONS);
gtk_container_add_child_arg_type ("GtkTable::y_options", GTK_TYPE_ATTACH_OPTIONS, GTK_ARG_READWRITE, CHILD_ARG_Y_OPTIONS);
gtk_container_add_child_arg_type ("GtkTable::x_padding", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_X_PADDING);
gtk_container_add_child_arg_type ("GtkTable::y_padding", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_Y_PADDING);
gtk_container_class_install_child_property (container_class,
CHILD_PROP_LEFT_ATTACH,
g_param_spec_uint ("left_attach", NULL, NULL,
0, 65535, 0,
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_RIGHT_ATTACH,
g_param_spec_uint ("right_attach", NULL, NULL,
1, 65535, 1,
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_TOP_ATTACH,
g_param_spec_uint ("top_attach", NULL, NULL,
0, 65535, 0,
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_BOTTOM_ATTACH,
g_param_spec_uint ("bottom_attach", NULL, NULL,
1, 65535, 1,
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_X_OPTIONS,
g_param_spec_flags ("x_options", NULL, NULL,
GTK_TYPE_ATTACH_OPTIONS, GTK_EXPAND | GTK_FILL,
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_Y_OPTIONS,
g_param_spec_flags ("y_options", NULL, NULL,
GTK_TYPE_ATTACH_OPTIONS, GTK_EXPAND | GTK_FILL,
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_X_PADDING,
g_param_spec_uint ("x_padding", NULL, NULL,
0, 65535, 0,
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_Y_PADDING,
g_param_spec_uint ("y_padding", NULL, NULL,
0, 65535, 0,
G_PARAM_READWRITE));
}
static GtkType
@ -288,16 +313,16 @@ gtk_table_set_property (GObject *object,
}
static void
gtk_table_set_child_arg (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
guint arg_id)
gtk_table_set_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GtkTable *table;
GtkTable *table = GTK_TABLE (container);
GtkTableChild *table_child;
GList *list;
table = GTK_TABLE (container);
table_child = NULL;
for (list = table->children; list; list = list->next)
{
@ -307,61 +332,59 @@ gtk_table_set_child_arg (GtkContainer *container,
break;
}
if (!list)
return;
switch (arg_id)
{
case CHILD_ARG_LEFT_ATTACH:
table_child->left_attach = GTK_VALUE_UINT (*arg);
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
return;
}
switch (property_id)
{
case CHILD_PROP_LEFT_ATTACH:
table_child->left_attach = g_value_get_uint (value);
if (table_child->right_attach <= table_child->left_attach)
table_child->right_attach = table_child->left_attach + 1;
if (table_child->right_attach >= table->ncols)
gtk_table_resize (table, table->ncols, table_child->right_attach);
break;
case CHILD_ARG_RIGHT_ATTACH:
if (GTK_VALUE_UINT (*arg) > 0)
{
table_child->right_attach = GTK_VALUE_UINT (*arg);
if (table_child->right_attach <= table_child->left_attach)
table_child->left_attach = table_child->right_attach - 1;
if (table_child->right_attach >= table->ncols)
gtk_table_resize (table, table->ncols, table_child->right_attach);
}
case CHILD_PROP_RIGHT_ATTACH:
table_child->right_attach = g_value_get_uint (value);
if (table_child->right_attach <= table_child->left_attach)
table_child->left_attach = table_child->right_attach - 1;
if (table_child->right_attach >= table->ncols)
gtk_table_resize (table, table->ncols, table_child->right_attach);
break;
case CHILD_ARG_TOP_ATTACH:
table_child->top_attach = GTK_VALUE_UINT (*arg);
case CHILD_PROP_TOP_ATTACH:
table_child->top_attach = g_value_get_uint (value);
if (table_child->bottom_attach <= table_child->top_attach)
table_child->bottom_attach = table_child->top_attach + 1;
if (table_child->bottom_attach >= table->nrows)
gtk_table_resize (table, table_child->bottom_attach, table->ncols);
break;
case CHILD_ARG_BOTTOM_ATTACH:
if (GTK_VALUE_UINT (*arg) > 0)
{
table_child->bottom_attach = GTK_VALUE_UINT (*arg);
if (table_child->bottom_attach <= table_child->top_attach)
table_child->top_attach = table_child->bottom_attach - 1;
if (table_child->bottom_attach >= table->nrows)
gtk_table_resize (table, table_child->bottom_attach, table->ncols);
}
case CHILD_PROP_BOTTOM_ATTACH:
table_child->bottom_attach = g_value_get_uint (value);
if (table_child->bottom_attach <= table_child->top_attach)
table_child->top_attach = table_child->bottom_attach - 1;
if (table_child->bottom_attach >= table->nrows)
gtk_table_resize (table, table_child->bottom_attach, table->ncols);
break;
case CHILD_ARG_X_OPTIONS:
table_child->xexpand = (GTK_VALUE_FLAGS (*arg) & GTK_EXPAND) != 0;
table_child->xshrink = (GTK_VALUE_FLAGS (*arg) & GTK_SHRINK) != 0;
table_child->xfill = (GTK_VALUE_FLAGS (*arg) & GTK_FILL) != 0;
case CHILD_PROP_X_OPTIONS:
table_child->xexpand = (g_value_get_flags (value) & GTK_EXPAND) != 0;
table_child->xshrink = (g_value_get_flags (value) & GTK_SHRINK) != 0;
table_child->xfill = (g_value_get_flags (value) & GTK_FILL) != 0;
break;
case CHILD_ARG_Y_OPTIONS:
table_child->yexpand = (GTK_VALUE_FLAGS (*arg) & GTK_EXPAND) != 0;
table_child->yshrink = (GTK_VALUE_FLAGS (*arg) & GTK_SHRINK) != 0;
table_child->yfill = (GTK_VALUE_FLAGS (*arg) & GTK_FILL) != 0;
case CHILD_PROP_Y_OPTIONS:
table_child->yexpand = (g_value_get_flags (value) & GTK_EXPAND) != 0;
table_child->yshrink = (g_value_get_flags (value) & GTK_SHRINK) != 0;
table_child->yfill = (g_value_get_flags (value) & GTK_FILL) != 0;
break;
case CHILD_ARG_X_PADDING:
table_child->xpadding = GTK_VALUE_UINT (*arg);
case CHILD_PROP_X_PADDING:
table_child->xpadding = g_value_get_uint (value);
break;
case CHILD_ARG_Y_PADDING:
table_child->ypadding = GTK_VALUE_UINT (*arg);
case CHILD_PROP_Y_PADDING:
table_child->ypadding = g_value_get_uint (value);
break;
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
}
if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (table))
@ -369,16 +392,16 @@ gtk_table_set_child_arg (GtkContainer *container,
}
static void
gtk_table_get_child_arg (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
guint arg_id)
gtk_table_get_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GtkTable *table;
GtkTable *table = GTK_TABLE (container);
GtkTableChild *table_child;
GList *list;
table = GTK_TABLE (container);
table_child = NULL;
for (list = table->children; list; list = list->next)
{
@ -388,40 +411,43 @@ gtk_table_get_child_arg (GtkContainer *container,
break;
}
if (!list)
return;
switch (arg_id)
{
case CHILD_ARG_LEFT_ATTACH:
GTK_VALUE_UINT (*arg) = table_child->left_attach;
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
return;
}
switch (property_id)
{
case CHILD_PROP_LEFT_ATTACH:
g_value_set_uint (value, table_child->left_attach);
break;
case CHILD_ARG_RIGHT_ATTACH:
GTK_VALUE_UINT (*arg) = table_child->right_attach;
case CHILD_PROP_RIGHT_ATTACH:
g_value_set_uint (value, table_child->right_attach);
break;
case CHILD_ARG_TOP_ATTACH:
GTK_VALUE_UINT (*arg) = table_child->top_attach;
case CHILD_PROP_TOP_ATTACH:
g_value_set_uint (value, table_child->top_attach);
break;
case CHILD_ARG_BOTTOM_ATTACH:
GTK_VALUE_UINT (*arg) = table_child->bottom_attach;
case CHILD_PROP_BOTTOM_ATTACH:
g_value_set_uint (value, table_child->bottom_attach);
break;
case CHILD_ARG_X_OPTIONS:
GTK_VALUE_FLAGS (*arg) = (table_child->xexpand * GTK_EXPAND |
table_child->xshrink * GTK_SHRINK |
table_child->xfill * GTK_FILL);
case CHILD_PROP_X_OPTIONS:
g_value_set_flags (value, (table_child->xexpand * GTK_EXPAND |
table_child->xshrink * GTK_SHRINK |
table_child->xfill * GTK_FILL));
break;
case CHILD_ARG_Y_OPTIONS:
GTK_VALUE_FLAGS (*arg) = (table_child->yexpand * GTK_EXPAND |
table_child->yshrink * GTK_SHRINK |
table_child->yfill * GTK_FILL);
case CHILD_PROP_Y_OPTIONS:
g_value_set_flags (value, (table_child->yexpand * GTK_EXPAND |
table_child->yshrink * GTK_SHRINK |
table_child->yfill * GTK_FILL));
break;
case CHILD_ARG_X_PADDING:
GTK_VALUE_UINT (*arg) = table_child->xpadding;
case CHILD_PROP_X_PADDING:
g_value_set_uint (value, table_child->xpadding);
break;
case CHILD_ARG_Y_PADDING:
GTK_VALUE_UINT (*arg) = table_child->ypadding;
case CHILD_PROP_Y_PADDING:
g_value_set_uint (value, table_child->ypadding);
break;
default:
arg->type = GTK_TYPE_INVALID;
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
}
}

View File

@ -42,7 +42,8 @@
#include "gtkprivate.h"
#include "gdk/gdk.h"
#include "gdk/gdkprivate.h" /* Used in gtk_reset_shapes_recurse to avoid copy */
#include "gobject/gvaluecollector.h"
#include <gobject/gvaluecollector.h>
#include <gobject/gobjectnotifyqueue.c>
#include "gdk/gdkkeysyms.h"
#include "gtkintl.h"
#include "gtkaccessible.h"
@ -66,6 +67,7 @@ enum {
STYLE_SET,
DIRECTION_CHANGED,
GRAB_NOTIFY,
CHILD_NOTIFY,
ADD_ACCELERATOR,
REMOVE_ACCELERATOR,
ACTIVATE_MNEMONIC,
@ -144,78 +146,77 @@ struct _GtkStateData
guint use_forall : 1;
};
static void gtk_widget_class_init (GtkWidgetClass *klass);
static void gtk_widget_init (GtkWidget *widget);
static void gtk_widget_set_property (GObject *object,
/* --- prototypes --- */
static void gtk_widget_class_init (GtkWidgetClass *klass);
static void gtk_widget_init (GtkWidget *widget);
static void gtk_widget_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_widget_get_property (GObject *object,
static void gtk_widget_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gtk_widget_shutdown (GObject *object);
static void gtk_widget_real_destroy (GtkObject *object);
static void gtk_widget_finalize (GObject *object);
static void gtk_widget_real_show (GtkWidget *widget);
static void gtk_widget_real_hide (GtkWidget *widget);
static void gtk_widget_real_map (GtkWidget *widget);
static void gtk_widget_real_unmap (GtkWidget *widget);
static void gtk_widget_real_realize (GtkWidget *widget);
static void gtk_widget_real_unrealize (GtkWidget *widget);
static void gtk_widget_real_size_request (GtkWidget *widget,
static void gtk_widget_shutdown (GObject *object);
static void gtk_widget_real_destroy (GtkObject *object);
static void gtk_widget_finalize (GObject *object);
static void gtk_widget_real_show (GtkWidget *widget);
static void gtk_widget_real_hide (GtkWidget *widget);
static void gtk_widget_real_map (GtkWidget *widget);
static void gtk_widget_real_unmap (GtkWidget *widget);
static void gtk_widget_real_realize (GtkWidget *widget);
static void gtk_widget_real_unrealize (GtkWidget *widget);
static void gtk_widget_real_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_widget_real_size_allocate (GtkWidget *widget,
static void gtk_widget_real_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static gboolean gtk_widget_real_key_press_event (GtkWidget *widget,
GdkEventKey *event);
static gboolean gtk_widget_real_key_release_event (GtkWidget *widget,
GdkEventKey *event);
static gboolean gtk_widget_real_focus_in_event (GtkWidget *widget,
GdkEventFocus *event);
static gboolean gtk_widget_real_focus_out_event (GtkWidget *widget,
GdkEventFocus *event);
static void gtk_widget_style_set (GtkWidget *widget,
static void gtk_widget_style_set (GtkWidget *widget,
GtkStyle *previous_style);
static void gtk_widget_direction_changed (GtkWidget *widget,
static void gtk_widget_direction_changed (GtkWidget *widget,
GtkTextDirection previous_direction);
static void gtk_widget_real_grab_focus (GtkWidget *focus_widget);
static gboolean gtk_widget_real_focus (GtkWidget *widget,
GtkDirectionType direction);
static void gtk_widget_real_grab_focus (GtkWidget *focus_widget);
static void gtk_widget_dispatch_child_properties_changed (GtkWidget *object,
guint n_pspecs,
GParamSpec **pspecs);
static gboolean gtk_widget_real_key_press_event (GtkWidget *widget,
GdkEventKey *event);
static gboolean gtk_widget_real_key_release_event (GtkWidget *widget,
GdkEventKey *event);
static gboolean gtk_widget_real_focus_in_event (GtkWidget *widget,
GdkEventFocus *event);
static gboolean gtk_widget_real_focus_out_event (GtkWidget *widget,
GdkEventFocus *event);
static gboolean gtk_widget_real_focus (GtkWidget *widget,
GtkDirectionType direction);
static GdkColormap* gtk_widget_peek_colormap (void);
static GtkStyle* gtk_widget_peek_style (void);
static PangoContext* gtk_widget_peek_pango_context (GtkWidget *widget);
static void gtk_widget_reparent_container_child (GtkWidget *widget,
gpointer client_data);
static void gtk_widget_propagate_state (GtkWidget *widget,
GtkStateData *data);
static void gtk_widget_set_style_internal (GtkWidget *widget,
GtkStyle *style,
gboolean initial_emission);
static void gtk_widget_set_style_recurse (GtkWidget *widget,
gpointer client_data);
static gint gtk_widget_event_internal (GtkWidget *widget,
GdkEvent *event);
static void gtk_widget_propagate_hierarchy_changed (GtkWidget *widget,
gpointer client_data);
static gboolean gtk_widget_real_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling);
static void gtk_widget_aux_info_destroy (GtkWidgetAuxInfo *aux_info);
static void gtk_widget_do_uposition (GtkWidget *widget);
static AtkObject* gtk_widget_real_get_accessible (GtkWidget *widget);
static void gtk_widget_accessible_interface_init (AtkImplementorIface *iface);
static AtkObject* gtk_widget_ref_accessible (AtkImplementor *implementor);
static GdkColormap* gtk_widget_peek_colormap (void);
static GtkStyle* gtk_widget_peek_style (void);
static PangoContext *gtk_widget_peek_pango_context (GtkWidget *widget);
static void gtk_widget_reparent_container_child (GtkWidget *widget,
gpointer client_data);
static void gtk_widget_propagate_state (GtkWidget *widget,
GtkStateData *data);
static void gtk_widget_set_style_internal (GtkWidget *widget,
GtkStyle *style,
gboolean initial_emission);
static void gtk_widget_set_style_recurse (GtkWidget *widget,
gpointer client_data);
static gint gtk_widget_event_internal (GtkWidget *widget,
GdkEvent *event);
static void gtk_widget_propagate_hierarchy_changed (GtkWidget *widget,
gpointer client_data);
static gboolean gtk_widget_real_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling);
static void gtk_widget_aux_info_destroy (GtkWidgetAuxInfo *aux_info);
static void gtk_widget_do_uposition (GtkWidget *widget);
static AtkObject* gtk_widget_real_get_accessible (GtkWidget *widget);
static void gtk_widget_accessible_interface_init (AtkImplementorIface *iface);
static AtkObject * gtk_widget_ref_accessible (AtkImplementor *implementor);
/* --- variables --- */
static gpointer parent_class = NULL;
static guint widget_signals[LAST_SIGNAL] = { 0 };
static GMemChunk *aux_info_mem_chunk = NULL;
static GdkColormap *default_colormap = NULL;
static GtkStyle *gtk_default_style = NULL;
@ -224,28 +225,22 @@ static GSList *style_stack = NULL;
static guint composite_child_stack = 0;
static GtkTextDirection gtk_default_direction = GTK_TEXT_DIR_LTR;
static GParamSpecPool *style_property_spec_pool = NULL;
static GQuark quark_property_parser = 0;
static GQuark quark_aux_info = 0;
static GQuark quark_event_mask = 0;
static GQuark quark_extension_event_mode = 0;
static GQuark quark_parent_window = 0;
static GQuark quark_saved_default_style = 0;
static GQuark quark_shape_info = 0;
static GQuark quark_colormap = 0;
static GQuark quark_pango_context = 0;
static GQuark quark_rc_style = 0;
static GQuark quark_accessible_object = 0;
static GQuark quark_property_parser = 0;
static GQuark quark_aux_info = 0;
static GQuark quark_event_mask = 0;
static GQuark quark_extension_event_mode = 0;
static GQuark quark_parent_window = 0;
static GQuark quark_saved_default_style = 0;
static GQuark quark_shape_info = 0;
static GQuark quark_colormap = 0;
static GQuark quark_pango_context = 0;
static GQuark quark_rc_style = 0;
static GQuark quark_accessible_object = 0;
GParamSpecPool *_gtk_widget_child_property_pool = NULL;
GObjectNotifyContext *_gtk_widget_child_property_notify_context = NULL;
/*****************************************
* gtk_widget_get_type:
*
* arguments:
*
* results:
*****************************************/
/* --- functions --- */
GtkType
gtk_widget_get_type (void)
{
@ -283,21 +278,41 @@ gtk_widget_get_type (void)
return widget_type;
}
/*****************************************
* gtk_widget_class_init:
*
* arguments:
*
* results:
*****************************************/
static void
child_property_notify_dispatcher (GObject *object,
guint n_pspecs,
GParamSpec **pspecs)
{
GTK_WIDGET_GET_CLASS (object)->dispatch_child_properties_changed (GTK_WIDGET (object), n_pspecs, pspecs);
}
static void
gtk_widget_class_init (GtkWidgetClass *klass)
{
static GObjectNotifyContext cpn_context = { 0, NULL, NULL };
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkBindingSet *binding_set;
parent_class = gtk_type_class (GTK_TYPE_OBJECT);
parent_class = g_type_class_peek_parent (klass);
quark_property_parser = g_quark_from_static_string ("gtk-rc-property-parser");
quark_aux_info = g_quark_from_static_string ("gtk-aux-info");
quark_event_mask = g_quark_from_static_string ("gtk-event-mask");
quark_extension_event_mode = g_quark_from_static_string ("gtk-extension-event-mode");
quark_parent_window = g_quark_from_static_string ("gtk-parent-window");
quark_saved_default_style = g_quark_from_static_string ("gtk-saved-default-style");
quark_shape_info = g_quark_from_static_string ("gtk-shape-info");
quark_colormap = g_quark_from_static_string ("gtk-colormap");
quark_pango_context = g_quark_from_static_string ("gtk-pango-context");
quark_rc_style = g_quark_from_static_string ("gtk-rc-style");
quark_accessible_object = g_quark_from_static_string ("gtk-accessible-object");
style_property_spec_pool = g_param_spec_pool_new (FALSE);
_gtk_widget_child_property_pool = g_param_spec_pool_new (TRUE);
cpn_context.quark_notify_queue = g_quark_from_static_string ("GtkWidget-child-property-notify-queue");
cpn_context.dispatcher = child_property_notify_dispatcher;
_gtk_widget_child_property_notify_context = &cpn_context;
gobject_class->shutdown = gtk_widget_shutdown;
gobject_class->finalize = gtk_widget_finalize;
@ -308,6 +323,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
klass->activate_signal = 0;
klass->set_scroll_adjustments_signal = 0;
klass->dispatch_child_properties_changed = gtk_widget_dispatch_child_properties_changed;
klass->show = gtk_widget_real_show;
klass->show_all = gtk_widget_show;
klass->hide = gtk_widget_real_hide;
@ -323,6 +339,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
klass->hierarchy_changed = NULL;
klass->style_set = gtk_widget_style_set;
klass->direction_changed = gtk_widget_direction_changed;
klass->grab_notify = NULL;
klass->child_notify = NULL;
klass->add_accelerator = (void*) gtk_accel_group_handle_add;
klass->remove_accelerator = (void*) gtk_accel_group_handle_remove;
klass->mnemonic_activate = gtk_widget_real_mnemonic_activate;
@ -359,26 +377,9 @@ gtk_widget_class_init (GtkWidgetClass *klass)
klass->drag_motion = NULL;
klass->drag_drop = NULL;
klass->drag_data_received = NULL;
/* Accessibility support */
klass->get_accessible = gtk_widget_real_get_accessible;
klass->get_accessible = gtk_widget_real_get_accessible; /* Accessibility support */
klass->no_expose_event = NULL;
quark_property_parser = g_quark_from_static_string ("gtk-rc-property-parser");
quark_aux_info = g_quark_from_static_string ("gtk-aux-info");
quark_event_mask = g_quark_from_static_string ("gtk-event-mask");
quark_extension_event_mode = g_quark_from_static_string ("gtk-extension-event-mode");
quark_parent_window = g_quark_from_static_string ("gtk-parent-window");
quark_saved_default_style = g_quark_from_static_string ("gtk-saved-default-style");
quark_shape_info = g_quark_from_static_string ("gtk-shape-info");
quark_colormap = g_quark_from_static_string ("gtk-colormap");
quark_pango_context = g_quark_from_static_string ("gtk-pango-context");
quark_rc_style = g_quark_from_static_string ("gtk-rc-style");
quark_accessible_object = g_quark_from_static_string ("gtk-accessible-object");
style_property_spec_pool = g_param_spec_pool_new (FALSE);
g_object_class_install_property (gobject_class,
PROP_NAME,
g_param_spec_string ("name",
@ -533,8 +534,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
GDK_TYPE_EXTENSION_MODE,
GDK_EXTENSION_EVENTS_NONE,
G_PARAM_READWRITE));
widget_signals[SHOW] =
gtk_signal_new ("show",
GTK_RUN_FIRST,
@ -641,6 +640,15 @@ gtk_widget_class_init (GtkWidgetClass *klass)
gtk_marshal_VOID__BOOLEAN,
GTK_TYPE_NONE, 1,
GTK_TYPE_BOOL);
widget_signals[CHILD_NOTIFY] =
g_signal_newc ("child_notify",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS,
G_STRUCT_OFFSET (GtkWidgetClass, child_notify),
NULL, NULL,
g_cclosure_marshal_VOID__PARAM,
G_TYPE_NONE,
1, G_TYPE_PARAM);
widget_signals[ADD_ACCELERATOR] =
gtk_accel_group_create_add (GTK_CLASS_TYPE (object_class), GTK_RUN_LAST,
GTK_SIGNAL_OFFSET (GtkWidgetClass, add_accelerator));
@ -1024,10 +1032,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
GTK_TYPE_NONE, 0);
binding_set = gtk_binding_set_by_class (klass);
gtk_binding_entry_add_signal (binding_set, GDK_F10, GDK_SHIFT_MASK,
"popup_menu", 0);
gtk_binding_entry_add_signal (binding_set, GDK_Menu, 0,
"popup_menu", 0);
@ -1153,14 +1159,6 @@ gtk_widget_set_property (GObject *object,
}
}
/*****************************************
* gtk_widget_get_property:
*
* arguments:
*
* results:
*****************************************/
static void
gtk_widget_get_property (GObject *object,
guint prop_id,
@ -1250,9 +1248,9 @@ gtk_widget_get_property (GObject *object,
case PROP_EVENTS:
eventp = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_event_mask);
if (!eventp)
g_value_set_int (value, 0);
g_value_set_flags (value, 0);
else
g_value_set_int (value, *eventp);
g_value_set_flags (value, *eventp);
break;
case PROP_EXTENSION_EVENTS:
modep = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_extension_event_mode);
@ -1267,14 +1265,6 @@ gtk_widget_get_property (GObject *object,
}
}
/*****************************************
* gtk_widget_init:
*
* arguments:
*
* results:
*****************************************/
static void
gtk_widget_init (GtkWidget *widget)
{
@ -1309,6 +1299,83 @@ gtk_widget_init (GtkWidget *widget)
}
static void
gtk_widget_dispatch_child_properties_changed (GtkWidget *widget,
guint n_pspecs,
GParamSpec **pspecs)
{
GtkWidget *container = widget->parent;
guint i;
for (i = 0; widget->parent == container && i < n_pspecs; i++)
g_signal_emit (widget, widget_signals[CHILD_NOTIFY], g_quark_from_string (pspecs[i]->name), pspecs[i]);
}
void
gtk_widget_freeze_child_notify (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
if (!G_OBJECT (widget)->ref_count)
return;
g_object_ref (widget);
g_object_notify_queue_freeze (G_OBJECT (widget), _gtk_widget_child_property_notify_context);
g_object_unref (widget);
}
void
gtk_widget_child_notify (GtkWidget *widget,
const gchar *child_property)
{
GParamSpec *pspec;
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (child_property != NULL);
if (!G_OBJECT (widget)->ref_count || !widget->parent)
return;
g_object_ref (widget);
pspec = g_param_spec_pool_lookup (_gtk_widget_child_property_pool,
child_property,
G_OBJECT_TYPE (widget->parent),
TRUE);
if (!pspec)
g_warning ("%s: container class `%s' has no child property named `%s'",
G_STRLOC,
G_OBJECT_TYPE_NAME (widget->parent),
child_property);
else
{
GObjectNotifyQueue *nqueue = g_object_notify_queue_freeze (G_OBJECT (widget), _gtk_widget_child_property_notify_context);
g_object_notify_queue_add (G_OBJECT (widget), nqueue, pspec);
g_object_notify_queue_thaw (G_OBJECT (widget), nqueue);
}
g_object_unref (widget);
}
void
gtk_widget_thaw_child_notify (GtkWidget *widget)
{
GObjectNotifyQueue *nqueue;
g_return_if_fail (GTK_IS_WIDGET (widget));
if (!G_OBJECT (widget)->ref_count)
return;
g_object_ref (widget);
nqueue = g_object_notify_queue_from_object (G_OBJECT (widget), _gtk_widget_child_property_notify_context);
if (!nqueue || !nqueue->freeze_count)
g_warning (G_STRLOC ": child-property-changed notification for %s(%p) is not frozen",
G_OBJECT_TYPE_NAME (widget), widget);
else
g_object_notify_queue_thaw (G_OBJECT (widget), nqueue);
g_object_unref (widget);
}
/**
* gtk_widget_new:
* @type: type ID of the widget to create
@ -1389,6 +1456,7 @@ gtk_widget_queue_clear_child (GtkWidget *widget)
void
gtk_widget_unparent (GtkWidget *widget)
{
GObjectNotifyQueue *nqueue;
GtkWidget *toplevel;
GtkWidget *old_parent;
@ -1401,6 +1469,7 @@ gtk_widget_unparent (GtkWidget *widget)
*/
g_object_freeze_notify (G_OBJECT (widget));
nqueue = g_object_notify_queue_freeze (G_OBJECT (widget), _gtk_widget_child_property_notify_context);
/* unset focused and default children properly, this code
* should eventually move into some gtk_window_unparent_branch() or
@ -1516,6 +1585,9 @@ gtk_widget_unparent (GtkWidget *widget)
gtk_widget_propagate_hierarchy_changed (widget, NULL);
g_object_notify (G_OBJECT (widget), "parent");
g_object_thaw_notify (G_OBJECT (widget));
if (!widget->parent)
g_object_notify_queue_clear (G_OBJECT (widget), nqueue);
g_object_notify_queue_thaw (G_OBJECT (widget), nqueue);
gtk_widget_unref (widget);
}

View File

@ -236,6 +236,11 @@ struct _GtkWidgetClass
*/
guint set_scroll_adjustments_signal;
/* seldomly overidden */
void (*dispatch_child_properties_changed) (GtkWidget *widget,
guint n_pspecs,
GParamSpec **pspecs);
/* basics */
void (* show) (GtkWidget *widget);
void (* show_all) (GtkWidget *widget);
@ -260,6 +265,8 @@ struct _GtkWidgetClass
GtkTextDirection previous_direction);
void (* grab_notify) (GtkWidget *widget,
gboolean was_grabbed);
void (* child_notify) (GtkWidget *widget,
GParamSpec *pspec);
/* accelerators */
void (* add_accelerator) (GtkWidget *widget,
@ -278,7 +285,7 @@ struct _GtkWidgetClass
gboolean group_cycling);
/* explicit focus */
void (* grab_focus) (GtkWidget *widget);
void (* grab_focus) (GtkWidget *widget);
gboolean (* focus) (GtkWidget *widget,
GtkDirectionType direction);
@ -507,6 +514,11 @@ gboolean gtk_widget_intersect (GtkWidget *widget,
GdkRegion *gtk_widget_region_intersect (GtkWidget *widget,
GdkRegion *region);
void gtk_widget_freeze_child_notify (GtkWidget *widget);
void gtk_widget_child_notify (GtkWidget *widget,
const gchar *child_property);
void gtk_widget_thaw_child_notify (GtkWidget *widget);
gboolean gtk_widget_is_focus (GtkWidget *widget);
void gtk_widget_grab_focus (GtkWidget *widget);
void gtk_widget_grab_default (GtkWidget *widget);

View File

@ -35,8 +35,8 @@ get_param_specs (GType type,
*/
/* Use private interface for now, fix later */
*specs = class->property_specs;
*n_specs = class->n_property_specs;
*specs = NULL; /* class->property_specs; */
*n_specs = 0; /* class->n_property_specs; */
}
typedef struct

View File

@ -47,8 +47,6 @@
#define sleep(n) _sleep(n)
#endif
#include "prop-editor.h"
#include "circles.xbm"
#include "test.xpm"
@ -3533,15 +3531,6 @@ entry_toggle_sensitive (GtkWidget *checkbutton,
gtk_widget_set_sensitive (entry, GTK_TOGGLE_BUTTON(checkbutton)->active);
}
static void
entry_props_clicked (GtkWidget *button,
GObject *entry)
{
GtkWidget *window = create_prop_editor (entry, 0);
gtk_window_set_title (GTK_WINDOW (window), "Entry Properties");
}
static void
create_entry (void)
{
@ -3595,12 +3584,6 @@ create_entry (void)
gtk_editable_select_region (GTK_EDITABLE (entry), 0, 5);
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
button = gtk_button_new_with_mnemonic ("_Props");
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (entry_props_clicked),
entry);
cb = gtk_combo_new ();
gtk_combo_set_popdown_strings (GTK_COMBO (cb), cbitems);
gtk_entry_set_text (GTK_ENTRY (GTK_COMBO(cb)->entry), "hello world \n\n\n foo");
@ -7488,15 +7471,6 @@ toggle_shrink (GtkWidget *widget, GtkWidget *child)
gtk_widget_unref (child);
}
static void
paned_props_clicked (GtkWidget *button,
GObject *paned)
{
GtkWidget *window = create_prop_editor (paned, GTK_TYPE_PANED);
gtk_window_set_title (GTK_WINDOW (window), "Paned Properties");
}
GtkWidget *
create_pane_options (GtkPaned *paned,
const gchar *frame_label,
@ -7506,7 +7480,6 @@ create_pane_options (GtkPaned *paned,
GtkWidget *frame;
GtkWidget *table;
GtkWidget *label;
GtkWidget *button;
GtkWidget *check_button;
frame = gtk_frame_new (frame_label);
@ -7557,13 +7530,6 @@ create_pane_options (GtkPaned *paned,
GTK_SIGNAL_FUNC (toggle_shrink),
paned->child2);
button = gtk_button_new_with_mnemonic ("_Properties");
gtk_table_attach_defaults (GTK_TABLE (table), button,
0, 2, 3, 4);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (paned_props_clicked),
paned);
return frame;
}
@ -9125,266 +9091,6 @@ create_progress_bar (void)
gtk_widget_destroy (pdata->window);
}
/*
* Properties
*/
typedef struct {
int x;
int y;
gboolean found;
gboolean first;
GtkWidget *res_widget;
} FindWidgetData;
static void
find_widget (GtkWidget *widget, FindWidgetData *data)
{
GtkAllocation new_allocation;
gint x_offset = 0;
gint y_offset = 0;
new_allocation = widget->allocation;
if (data->found || !GTK_WIDGET_MAPPED (widget))
return;
/* Note that in the following code, we only count the
* position as being inside a WINDOW widget if it is inside
* widget->window; points that are outside of widget->window
* but within the allocation are not counted. This is consistent
* with the way we highlight drag targets.
*/
if (!GTK_WIDGET_NO_WINDOW (widget))
{
new_allocation.x = 0;
new_allocation.y = 0;
}
if (widget->parent && !data->first)
{
GdkWindow *window = widget->window;
while (window != widget->parent->window)
{
gint tx, ty, twidth, theight;
gdk_window_get_size (window, &twidth, &theight);
if (new_allocation.x < 0)
{
new_allocation.width += new_allocation.x;
new_allocation.x = 0;
}
if (new_allocation.y < 0)
{
new_allocation.height += new_allocation.y;
new_allocation.y = 0;
}
if (new_allocation.x + new_allocation.width > twidth)
new_allocation.width = twidth - new_allocation.x;
if (new_allocation.y + new_allocation.height > theight)
new_allocation.height = theight - new_allocation.y;
gdk_window_get_position (window, &tx, &ty);
new_allocation.x += tx;
x_offset += tx;
new_allocation.y += ty;
y_offset += ty;
window = gdk_window_get_parent (window);
}
}
if ((data->x >= new_allocation.x) && (data->y >= new_allocation.y) &&
(data->x < new_allocation.x + new_allocation.width) &&
(data->y < new_allocation.y + new_allocation.height))
{
/* First, check if the drag is in a valid drop site in
* one of our children
*/
if (GTK_IS_CONTAINER (widget))
{
FindWidgetData new_data = *data;
new_data.x -= x_offset;
new_data.y -= y_offset;
new_data.found = FALSE;
new_data.first = FALSE;
gtk_container_forall (GTK_CONTAINER (widget),
(GtkCallback)find_widget,
&new_data);
data->found = new_data.found;
if (data->found)
data->res_widget = new_data.res_widget;
}
/* If not, and this widget is registered as a drop site, check to
* emit "drag_motion" to check if we are actually in
* a drop site.
*/
if (!data->found)
{
data->found = TRUE;
data->res_widget = widget;
}
}
}
static GtkWidget *
find_widget_at_pointer (void)
{
GtkWidget *widget = NULL;
GdkWindow *pointer_window;
gint x, y;
FindWidgetData data;
pointer_window = gdk_window_at_pointer (NULL, NULL);
if (pointer_window)
gdk_window_get_user_data (pointer_window, (gpointer*) &widget);
if (widget)
{
gdk_window_get_pointer (widget->window,
&x, &y, NULL);
data.x = x;
data.y = y;
data.found = FALSE;
data.first = TRUE;
find_widget (widget, &data);
if (data.found)
return data.res_widget;
return widget;
}
return NULL;
}
struct PropertiesData {
GtkWidget **window;
GdkCursor *cursor;
gboolean in_query;
gint handler;
};
static void
destroy_properties (GtkWidget *widget,
struct PropertiesData *data)
{
if (data->window)
{
*data->window = NULL;
data->window = NULL;
}
if (data->cursor)
{
gdk_cursor_destroy (data->cursor);
data->cursor = NULL;
}
if (data->handler)
{
gtk_signal_disconnect (widget, data->handler);
data->handler = 0;
}
g_free (data);
}
static gint
property_query_event (GtkWidget *widget,
GdkEvent *event,
struct PropertiesData *data)
{
GtkWidget *res_widget = NULL;
if (!data->in_query)
return FALSE;
if (event->type == GDK_BUTTON_RELEASE)
{
gtk_grab_remove (widget);
gdk_pointer_ungrab (GDK_CURRENT_TIME);
res_widget = find_widget_at_pointer ();
if (res_widget)
create_prop_editor (G_OBJECT (res_widget), 0);
data->in_query = FALSE;
}
return FALSE;
}
static void
query_properties (GtkButton *button,
struct PropertiesData *data)
{
gint failure;
gtk_signal_connect (GTK_OBJECT (button), "event",
(GtkSignalFunc) property_query_event, data);
if (!data->cursor)
data->cursor = gdk_cursor_new (GDK_TARGET);
failure = gdk_pointer_grab (GTK_WIDGET (button)->window,
TRUE,
GDK_BUTTON_RELEASE_MASK,
NULL,
data->cursor,
GDK_CURRENT_TIME);
gtk_grab_add (GTK_WIDGET (button));
data->in_query = TRUE;
}
static void
create_properties (void)
{
static GtkWidget *window = NULL;
GtkWidget *button;
struct PropertiesData *data;
data = g_new (struct PropertiesData, 1);
data->window = &window;
data->in_query = FALSE;
data->cursor = NULL;
data->handler = 0;
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
data->handler = gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC(destroy_properties),
data);
gtk_window_set_title (GTK_WINDOW (window), "test properties");
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
button = gtk_button_new_with_label ("Query properties");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC(query_properties),
data);
gtk_container_add (GTK_CONTAINER (window), button);
}
if (!GTK_WIDGET_VISIBLE (window))
gtk_widget_show_all (window);
else
gtk_widget_destroy (window);
}
/*
* Color Preview
*/
@ -9794,7 +9500,7 @@ scroll_test_configure (GtkWidget *widget, GdkEventConfigure *event,
static void
scroll_test_adjustment_changed (GtkAdjustment *adj, GtkWidget *widget)
{
gint source_min = (int)adj->value - scroll_test_pos;
/* gint source_min = (int)adj->value - scroll_test_pos; */
gint dy;
dy = scroll_test_pos - (int)adj->value;
@ -10604,7 +10310,6 @@ create_main_window (void)
{ "preview color", create_color_preview },
{ "preview gray", create_gray_preview },
{ "progress bar", create_progress_bar },
{ "properties", create_properties },
{ "radio buttons", create_radio_buttons },
{ "range controls", create_range_controls },
{ "rc file", create_rc_file },