Commit 9860caa5 authored by Tim Janik's avatar Tim Janik Committed by Tim Janik

new function gtk_container_child_arg_set, similar to

Wed Jun 24 14:14:32 1998  Tim Janik  <timj@gtk.org>

        * gtk/gtkcontainer.c: new function gtk_container_child_arg_set, similar
        to gtk_container_child_arg_setv, but takes a variable argument list.
        new function gtk_container_get_child_arg_type, which is needed by
        gtk_object_collect_args.

        * gtk/gtkobject.c: changed prototype for gtk_object_collect_args, to
        take a function pointer to figure the argument type.
        adapted callers to pass gtk_object_get_arg_type.
        * gtk/gtkwidget.c: adapted gtk_object_collect_args callers to pass
        gtk_object_get_arg_type..

        * gtk/gtkpacker.h:
        * gtk/gtkpacker.c:
        (gtk_packer_reorder_child): new function to change the packing order
        of a child.
        (gtk_packer_size_request):
        (gtk_packer_size_allocate): take container->border_width into acount.

        * gtk/gtkpacker.c: implemented widget arguments:
        "GtkPacker::spacing", "GtkPacker::border_width", "GtkPacker::pad_x",
        "GtkPacker::pad_y", "GtkPacker::ipad_x", "GtkPacker::ipad_y".
        implemented child arguments:
        "GtkPacker::side", "GtkPacker::anchor", "GtkPacker::expand",
        "GtkPacker::fill_x", "GtkPacker::fill_y", "GtkPacker::use_default",
        "GtkPacker::border_width", "GtkPacker::pad_x", "GtkPacker::pad_y",
        "GtkPacker::ipad_x", "GtkPacker::ipad_y", "GtkPacker::position".

        * gtk/gtkmisc.c (gtk_misc_set_arg): for padding args, set the padding,
        not the alignment.

        * gtk/gtkeventbox.h:
        * gtk/gtkeventbox.c: GtkType and macro fixups.

        * gtk/testgtk.c (entry_toggle_sensitive): new function to toggle
        sensitivity of an entry.

        * gtk/gtkstyle.c (gtk_style_new): support normal grey as default color
        for insensitive base.

        * gtk/gtkentry.c (gtk_entry_realize): set the window backgrounds
        widget state dependent.
        (gtk_entry_style_set): likewise.
        (gtk_entry_state_changed): set background color on state changes.
        (gtk_entry_draw_text): for non selected text, use state dependent
        colors.

        * gtk/gtktogglebutton.c: support for widget arguments
        "GtkToggleButton::active" and "GtkToggleButton::draw_indicator".
parent 14bd8cf9
......@@ -40,8 +40,8 @@ enum {
ARG_CHILD
};
typedef struct _GtkLArgInfo GtkLArgInfo;
struct _GtkLArgInfo
typedef struct _GtkChildArgInfo GtkChildArgInfo;
struct _GtkChildArgInfo
{
gchar *name;
GtkType type;
......@@ -116,13 +116,14 @@ static void gtk_container_show_all (GtkWidget *widget);
static void gtk_container_hide_all (GtkWidget *widget);
GtkArg* gtk_object_collect_args (guint *n_args,
GtkType (*) (const gchar*),
va_list args1,
va_list args2);
static guint container_signals[LAST_SIGNAL] = { 0 };
static GHashTable *arg_info_ht = NULL;
static GHashTable *child_arg_info_ht = NULL;
static GtkWidgetClass *parent_class = NULL;
......@@ -310,7 +311,7 @@ gtk_container_add_child_arg_type (const gchar *arg_name,
guint arg_flags,
guint arg_id)
{
GtkLArgInfo *info;
GtkChildArgInfo *info;
gchar class_part[1024];
gchar *arg_part;
GtkType class_type;
......@@ -340,7 +341,7 @@ gtk_container_add_child_arg_type (const gchar *arg_name,
return;
}
info = g_new (GtkLArgInfo, 1);
info = g_new (GtkChildArgInfo, 1);
info->name = g_strdup (arg_name);
info->type = arg_type;
info->class_type = class_type;
......@@ -348,25 +349,25 @@ gtk_container_add_child_arg_type (const gchar *arg_name,
info->arg_id = arg_id;
info->seq_id = ++((GtkContainerClass*) gtk_type_class (class_type))->n_child_args;
if (!arg_info_ht)
arg_info_ht = g_hash_table_new (g_str_hash, g_str_equal);
if (!child_arg_info_ht)
child_arg_info_ht = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (arg_info_ht, info->name, info);
g_hash_table_insert (child_arg_info_ht, info->name, info);
}
typedef struct
{
GList *arg_list;
GtkType class_type;
} GtkQueryLArgData;
} GtkQueryChildArgData;
static void
gtk_query_larg_foreach (gpointer key,
gpointer value,
gpointer user_data)
gtk_query_child_arg_foreach (gpointer key,
gpointer value,
gpointer user_data)
{
register GtkLArgInfo *info;
register GtkQueryLArgData *data;
register GtkChildArgInfo *info;
register GtkQueryChildArgData *data;
info = value;
data = user_data;
......@@ -375,13 +376,55 @@ gtk_query_larg_foreach (gpointer key,
data->arg_list = g_list_prepend (data->arg_list, info);
}
GtkType
gtk_container_get_child_arg_type (const gchar *arg_name)
{
GtkChildArgInfo *info;
gchar buffer[128];
gchar *t;
g_return_val_if_fail (arg_name != NULL, 0);
if (!child_arg_info_ht)
return GTK_TYPE_INVALID;
if (!arg_name || strlen (arg_name) > 120)
{
/* security audit
*/
g_warning ("gtk_container_get_child_arg_type(): argument `arg_name' exceeds maximum size.");
return GTK_TYPE_INVALID;
}
t = strchr (arg_name, ':');
if (!t || (t[0] != ':') || (t[1] != ':'))
{
g_warning ("gtk_container_get_child_arg_type(): invalid arg name: \"%s\"\n", arg_name);
return GTK_TYPE_INVALID;
}
t = strchr (t + 2, ':');
if (t)
{
strncpy (buffer, arg_name, (long) (t - arg_name));
buffer[(long) (t - arg_name)] = '\0';
arg_name = buffer;
}
info = g_hash_table_lookup (child_arg_info_ht, arg_name);
if (info)
return info->type;
return GTK_TYPE_INVALID;
}
GtkArg*
gtk_container_query_child_args (GtkType class_type,
guint32 **arg_flags,
guint *n_args)
{
GtkArg *args;
GtkQueryLArgData query_data;
GtkQueryChildArgData query_data;
if (arg_flags)
*arg_flags = NULL;
......@@ -389,7 +432,7 @@ gtk_container_query_child_args (GtkType class_type,
*n_args = 0;
g_return_val_if_fail (gtk_type_is_a (class_type, GTK_TYPE_CONTAINER), NULL);
if (!arg_info_ht)
if (!child_arg_info_ht)
return NULL;
/* make sure the types class has been initialized, because
......@@ -399,7 +442,7 @@ gtk_container_query_child_args (GtkType class_type,
query_data.arg_list = NULL;
query_data.class_type = class_type;
g_hash_table_foreach (arg_info_ht, gtk_query_larg_foreach, &query_data);
g_hash_table_foreach (child_arg_info_ht, gtk_query_child_arg_foreach, &query_data);
if (query_data.arg_list)
{
......@@ -422,7 +465,7 @@ gtk_container_query_child_args (GtkType class_type,
do
{
GtkLArgInfo *info;
GtkChildArgInfo *info;
info = list->data;
list = list->prev;
......@@ -457,12 +500,12 @@ gtk_container_child_arg_getv (GtkContainer *container,
g_return_if_fail (child != NULL);
g_return_if_fail (GTK_IS_WIDGET (child));
if (!arg_info_ht)
if (!child_arg_info_ht)
return;
for (i = 0; i < n_args; i++)
{
GtkLArgInfo *info;
GtkChildArgInfo *info;
gchar *lookup_name;
gchar *d;
......@@ -477,7 +520,7 @@ gtk_container_child_arg_getv (GtkContainer *container,
if (d)
*d = 0;
info = g_hash_table_lookup (arg_info_ht, lookup_name);
info = g_hash_table_lookup (child_arg_info_ht, lookup_name);
}
else
info = NULL;
......@@ -514,6 +557,33 @@ gtk_container_child_arg_getv (GtkContainer *container,
}
}
void
gtk_container_child_arg_set (GtkContainer *container,
GtkWidget *child,
...)
{
GtkArg *args;
guint n_args;
va_list args1;
va_list args2;
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);
va_start (args1, child);
va_start (args2, child);
args = gtk_object_collect_args (&n_args, gtk_container_get_child_arg_type, args1, args2);
gtk_container_child_arg_setv (container, child, n_args, args);
g_free (args);
va_end (args1);
va_end (args2);
}
void
gtk_container_child_arg_setv (GtkContainer *container,
GtkWidget *child,
......@@ -527,12 +597,12 @@ gtk_container_child_arg_setv (GtkContainer *container,
g_return_if_fail (child != NULL);
g_return_if_fail (GTK_IS_WIDGET (child));
if (!arg_info_ht)
if (!child_arg_info_ht)
return;
for (i = 0; i < n_args; i++)
{
GtkLArgInfo *info;
GtkChildArgInfo *info;
gchar *lookup_name;
gchar *d;
gboolean arg_ok;
......@@ -545,7 +615,7 @@ gtk_container_child_arg_setv (GtkContainer *container,
if (d)
*d = 0;
info = g_hash_table_lookup (arg_info_ht, lookup_name);
info = g_hash_table_lookup (child_arg_info_ht, lookup_name);
}
else
info = NULL;
......@@ -612,7 +682,7 @@ gtk_container_add_with_args (GtkContainer *container,
va_start (args1, widget);
va_start (args2, widget);
args = gtk_object_collect_args (&n_args, args1, args2);
args = gtk_object_collect_args (&n_args, gtk_container_get_child_arg_type, args1, args2);
gtk_container_child_arg_setv (container, widget, n_args, args);
g_free (args);
......
......@@ -138,10 +138,11 @@ void gtk_container_add_child_arg_type (const gchar *arg_name,
GtkType arg_type,
guint arg_flags,
guint arg_id);
GtkType gtk_container_get_child_arg_type (const gchar *arg_name);
/* Allocate a GtkArg array of size nargs that hold the
* names and types of the args that can be used with
* gtk_container_child_arg_get/gtk_container_child_arg_set.
* gtk_container_child_arg_getv/gtk_container_child_arg_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.
......@@ -178,7 +179,10 @@ void gtk_container_add_with_argv (GtkContainer *container,
GtkWidget *widget,
guint n_args,
GtkArg *args);
void gtk_container_child_arg_set (GtkContainer *container,
GtkWidget *child,
...);
/* Non-public methods */
void gtk_container_queue_resize (GtkContainer *container);
......
......@@ -68,6 +68,8 @@ static void gtk_entry_draw_cursor_on_drawable
GdkDrawable *drawable);
static void gtk_entry_style_set (GtkWidget *widget,
GtkStyle *previous_style);
static void gtk_entry_state_changed (GtkWidget *widget,
GtkStateType previous_state);
static void gtk_entry_queue_draw (GtkEntry *entry);
static gint gtk_entry_timer (gpointer data);
static gint gtk_entry_position (GtkEntry *entry,
......@@ -250,7 +252,8 @@ gtk_entry_class_init (GtkEntryClass *class)
widget_class->key_press_event = gtk_entry_key_press;
widget_class->focus_in_event = gtk_entry_focus_in;
widget_class->focus_out_event = gtk_entry_focus_out;
widget_class->style_set = gtk_entry_style_set;
widget_class->style_set = gtk_entry_style_set;
widget_class->state_changed = gtk_entry_state_changed;
editable_class->insert_text = gtk_entry_insert_text;
editable_class->delete_text = gtk_entry_delete_text;
......@@ -508,8 +511,8 @@ gtk_entry_realize (GtkWidget *widget)
widget->style = gtk_style_attach (widget->style, widget->window);
gdk_window_set_background (widget->window, &widget->style->base[GTK_STATE_NORMAL]);
gdk_window_set_background (entry->text_area, &widget->style->base[GTK_STATE_NORMAL]);
gdk_window_set_background (widget->window, &widget->style->base[GTK_WIDGET_STATE (widget)]);
gdk_window_set_background (entry->text_area, &widget->style->base[GTK_WIDGET_STATE (widget)]);
#ifdef USE_XIM
if (gdk_im_ready ())
......@@ -635,7 +638,7 @@ gtk_entry_draw_focus (GtkWidget *widget)
else
{
gdk_draw_rectangle (widget->window,
widget->style->base_gc[GTK_WIDGET_STATE(widget)],
widget->style->base_gc[GTK_WIDGET_STATE (widget)],
FALSE, x + 2, y + 2, width - 5, height - 5);
}
......@@ -1284,7 +1287,7 @@ gtk_entry_draw_text (GtkEntry *entry)
if (selection_start_pos > start_pos)
gdk_draw_text (drawable, widget->style->font,
widget->style->fg_gc[GTK_STATE_NORMAL],
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
start_xoffset, y,
toprint,
selection_start_pos - start_pos);
......@@ -1310,7 +1313,7 @@ gtk_entry_draw_text (GtkEntry *entry)
if (selection_end_pos < end_pos)
gdk_draw_text (drawable, widget->style->font,
widget->style->fg_gc[GTK_STATE_NORMAL],
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
selection_end_xoffset, y,
toprint + selection_end_pos - start_pos,
end_pos - selection_end_pos);
......@@ -2242,8 +2245,25 @@ gtk_entry_style_set (GtkWidget *widget,
entry->scroll_offset = entry->char_offset[scroll_char];
gtk_entry_adjust_scroll (entry);
gdk_window_set_background (widget->window, &widget->style->base[GTK_STATE_NORMAL]);
gdk_window_set_background (entry->text_area, &widget->style->base[GTK_STATE_NORMAL]);
gdk_window_set_background (widget->window, &widget->style->base[GTK_WIDGET_STATE (widget)]);
gdk_window_set_background (entry->text_area, &widget->style->base[GTK_WIDGET_STATE (widget)]);
}
if (GTK_WIDGET_DRAWABLE (widget))
gdk_window_clear (widget->window);
}
static void
gtk_entry_state_changed (GtkWidget *widget,
GtkStateType previous_state)
{
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_ENTRY (widget));
if (GTK_WIDGET_REALIZED (widget))
{
gdk_window_set_background (widget->window, &widget->style->base[GTK_WIDGET_STATE (widget)]);
gdk_window_set_background (GTK_ENTRY (widget)->text_area, &widget->style->base[GTK_WIDGET_STATE (widget)]);
}
if (GTK_WIDGET_DRAWABLE (widget))
......
......@@ -33,10 +33,10 @@ static gint gtk_event_box_expose (GtkWidget *widget,
GdkEventExpose *event);
guint
GtkType
gtk_event_box_get_type (void)
{
static guint event_box_type = 0;
static GtkType event_box_type = 0;
if (!event_box_type)
{
......
......@@ -8,7 +8,7 @@
*
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
......@@ -26,15 +26,18 @@
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
#define GTK_EVENT_BOX(obj) GTK_CHECK_CAST (obj, gtk_event_box_get_type (), GtkEventBox)
#define GTK_EVENT_BOX_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_event_box_get_type (), GtkEventBoxClass)
#define GTK_IS_EVENT_BOX(obj) GTK_CHECK_TYPE (obj, gtk_event_box_get_type ())
#define GTK_TYPE_EVENT_BOX (gtk_event_box_get_type ())
#define GTK_EVENT_BOX(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_EVENT_BOX, GtkEventBox))
#define GTK_EVENT_BOX_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_EVENT_BOX, GtkEventBoxClass))
#define GTK_IS_EVENT_BOX(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_EVENT_BOX))
#define GTK_IS_EVENT_BOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_EVENT_BOX))
typedef struct _GtkEventBox GtkEventBox;
typedef struct _GtkEventBox GtkEventBox;
typedef struct _GtkEventBoxClass GtkEventBoxClass;
struct _GtkEventBox
......@@ -47,8 +50,8 @@ struct _GtkEventBoxClass
GtkBinClass parent_class;
};
guint gtk_event_box_get_type (void);
GtkWidget* gtk_event_box_new (void);
GtkType gtk_event_box_get_type (void);
GtkWidget* gtk_event_box_new (void);
#ifdef __cplusplus
}
......
......@@ -103,10 +103,10 @@ gtk_misc_set_arg (GtkMisc *misc,
gtk_misc_set_alignment (misc, misc->xalign, GTK_VALUE_DOUBLE (*arg));
break;
case ARG_XPAD:
gtk_misc_set_alignment (misc, GTK_VALUE_INT (*arg), misc->ypad);
gtk_misc_set_padding (misc, GTK_VALUE_INT (*arg), misc->ypad);
break;
case ARG_YPAD:
gtk_misc_set_alignment (misc, misc->xpad, GTK_VALUE_INT (*arg));
gtk_misc_set_padding (misc, misc->xpad, GTK_VALUE_INT (*arg));
break;
default:
break;
......
......@@ -76,6 +76,7 @@ static void gtk_object_finalize (GtkObject *object);
static void gtk_object_notify_weaks (GtkObject *object);
GtkArg* gtk_object_collect_args (guint *nargs,
GtkType (*) (const gchar*),
va_list args1,
va_list args2);
......@@ -619,7 +620,7 @@ gtk_object_new (GtkType type,
va_start (args1, type);
va_start (args2, type);
args = gtk_object_collect_args (&nargs, args1, args2);
args = gtk_object_collect_args (&nargs, gtk_object_get_arg_type, args1, args2);
gtk_object_setv (obj, nargs, args);
g_free (args);
......@@ -846,7 +847,7 @@ gtk_object_set (GtkObject *object,
va_start (args1, object);
va_start (args2, object);
args = gtk_object_collect_args (&nargs, args1, args2);
args = gtk_object_collect_args (&nargs, gtk_object_get_arg_type, args1, args2);
gtk_object_setv (object, nargs, args);
g_free (args);
......@@ -1001,7 +1002,7 @@ GtkType
gtk_object_get_arg_type (const gchar *arg_name)
{
GtkArgInfo *info;
gchar buffer[1024];
gchar buffer[128];
gchar *t;
g_return_val_if_fail (arg_name != NULL, 0);
......@@ -1009,18 +1010,18 @@ gtk_object_get_arg_type (const gchar *arg_name)
if (!arg_info_ht)
return GTK_TYPE_INVALID;
if (!arg_name || strlen (arg_name) > 1000)
if (!arg_name || strlen (arg_name) > 120)
{
/* security audit
*/
g_warning ("gtk_object_get_arg_type(): argument `arg_name' exceeds maximum size.");
return 0;
return GTK_TYPE_INVALID;
}
t = strchr (arg_name, ':');
if (!t || (t[0] != ':') || (t[1] != ':'))
{
g_warning ("invalid arg name: \"%s\"\n", arg_name);
g_warning ("gtk_object_get_arg_type(): invalid arg name: \"%s\"\n", arg_name);
return GTK_TYPE_INVALID;
}
......@@ -1032,7 +1033,7 @@ gtk_object_get_arg_type (const gchar *arg_name)
arg_name = buffer;
}
info = g_hash_table_lookup (arg_info_ht, (gpointer) arg_name);
info = g_hash_table_lookup (arg_info_ht, arg_name);
if (info)
return info->type;
......@@ -1360,6 +1361,7 @@ gtk_object_check_class_cast (GtkObjectClass *klass,
GtkArg*
gtk_object_collect_args (guint *nargs,
GtkType (*get_arg_type) (const gchar*),
va_list args1,
va_list args2)
{
......@@ -1381,7 +1383,7 @@ gtk_object_collect_args (guint *nargs,
continue;
}
type = gtk_object_get_arg_type (name);
type = get_arg_type (name);
switch (GTK_FUNDAMENTAL_TYPE (type))
{
......@@ -1458,7 +1460,7 @@ gtk_object_collect_args (guint *nargs,
for (i = 0; i < n; i++)
{
args[i].name = va_arg (args2, char *);
args[i].type = gtk_object_get_arg_type (args[i].name);
args[i].type = get_arg_type (args[i].name);
switch (GTK_FUNDAMENTAL_TYPE (args[i].type))
{
......
......@@ -89,6 +89,32 @@ terms specified in this license.
#include "gtkpacker.h"
enum {
ARG_0,
ARG_SPACING,
ARG_D_BORDER_WIDTH,
ARG_D_PAD_X,
ARG_D_PAD_Y,
ARG_D_IPAD_X,
ARG_D_IPAD_Y
};
enum {
CHILD_ARG_0,
CHILD_ARG_SIDE,
CHILD_ARG_ANCHOR,
CHILD_ARG_EXPAND,
CHILD_ARG_FILL_X,
CHILD_ARG_FILL_Y,
CHILD_ARG_USE_DEFAULT,
CHILD_ARG_BORDER_WIDTH,
CHILD_ARG_PAD_X,
CHILD_ARG_PAD_Y,
CHILD_ARG_I_PAD_X,
CHILD_ARG_I_PAD_Y,
CHILD_ARG_POSITION
};
static void gtk_packer_class_init (GtkPackerClass *klass);
static void gtk_packer_init (GtkPacker *packer);
static void gtk_packer_map (GtkWidget *widget);
......@@ -108,8 +134,22 @@ static void gtk_packer_remove (GtkContainer *container,
static void gtk_packer_foreach (GtkContainer *container,
GtkCallback callback,
gpointer callback_data);
static void gtk_packer_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_packer_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_packer_get_child_arg (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
guint arg_id);
static void gtk_packer_set_child_arg (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
guint arg_id);
static GtkType gtk_packer_child_type (GtkContainer *container);
static GtkPackerClass *parent_class;
......@@ -127,11 +167,11 @@ gtk_packer_get_type (void)
sizeof (GtkPackerClass),
(GtkClassInitFunc) gtk_packer_class_init,
(GtkObjectInitFunc) gtk_packer_init,
(GtkArgSetFunc) NULL,
(GtkArgGetFunc) NULL
(GtkArgSetFunc) gtk_packer_set_arg,
(GtkArgGetFunc) gtk_packer_get_arg
};
packer_type = gtk_type_unique (gtk_container_get_type (), &packer_info);
packer_type = gtk_type_unique (GTK_TYPE_CONTAINER, &packer_info);
}
return packer_type;
......@@ -145,8 +185,28 @@ gtk_packer_class_init (GtkPackerClass *klass)
widget_class = (GtkWidgetClass*) klass;
container_class = (GtkContainerClass*) klass;
parent_class = gtk_type_class (gtk_container_get_type ());
parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
gtk_object_add_arg_type ("GtkPacker::spacing", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_SPACING);
gtk_object_add_arg_type ("GtkPacker::default_border_width", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_D_BORDER_WIDTH);
gtk_object_add_arg_type ("GtkPacker::default_pad_x", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_D_PAD_X);
gtk_object_add_arg_type ("GtkPacker::default_pad_y", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_D_PAD_Y);
gtk_object_add_arg_type ("GtkPacker::default_ipad_x", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_D_IPAD_X);
gtk_object_add_arg_type ("GtkPacker::default_ipad_y", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_D_IPAD_Y);
gtk_container_add_child_arg_type ("GtkPacker::side", GTK_TYPE_SIDE_TYPE, GTK_ARG_READWRITE, CHILD_ARG_SIDE);
gtk_container_add_child_arg_type ("GtkPacker::anchor", GTK_TYPE_ANCHOR_TYPE, GTK_ARG_READWRITE, CHILD_ARG_ANCHOR);
gtk_container_add_child_arg_type ("GtkPacker::expand", GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_EXPAND);
gtk_container_add_child_arg_type ("GtkPacker::fill_x", GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_FILL_X);
gtk_container_add_child_arg_type ("GtkPacker::fill_y", GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_FILL_Y);
gtk_container_add_child_arg_type ("GtkPacker::use_default", GTK_TYPE_BOOL, GTK_ARG_READWRITE, CHILD_ARG_USE_DEFAULT);
gtk_container_add_child_arg_type ("GtkPacker::border_width", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_BORDER_WIDTH);
gtk_container_add_child_arg_type ("GtkPacker::pad_x", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_PAD_X);
gtk_container_add_child_arg_type ("GtkPacker::pad_y", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_PAD_Y);
gtk_container_add_child_arg_type ("GtkPacker::ipad_x", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_I_PAD_X);
gtk_container_add_child_arg_type ("GtkPacker::ipad_y", GTK_TYPE_UINT, GTK_ARG_READWRITE, CHILD_ARG_I_PAD_Y);
gtk_container_add_child_arg_type ("GtkPacker::position", GTK_TYPE_LONG, GTK_ARG_READWRITE, CHILD_ARG_POSITION);
widget_class->map = gtk_packer_map;
widget_class->unmap = gtk_packer_unmap;
widget_class->draw = gtk_packer_draw;
......@@ -159,6 +219,85 @@ gtk_packer_class_init (GtkPackerClass *klass)
container_class->remove = gtk_packer_remove;
container_class->foreach = gtk_packer_foreach;
container_class->child_type = gtk_packer_child_type;
container_class->get_child_arg = gtk_packer_get_child_arg;
container_class->set_child_arg = gtk_packer_set_child_arg;
}
static void
gtk_packer_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id)
{
GtkPacker *packer;
packer = GTK_PACKER (object);
switch (arg_id)
{
case ARG_SPACING:
gtk_packer_set_spacing (packer, GTK_VALUE_UINT (*arg));
break;
case ARG_D_BORDER_WIDTH:
gtk_packer_set_default_border_width (packer, GTK_VALUE_UINT (*arg));
break;
case ARG_D_PAD_X:
gtk_packer_set_default_pad (packer,
GTK_VALUE_UINT (*arg),
packer->default_pad_y);
break;
case ARG_D_PAD_Y:
gtk_packer_set_default_pad (packer,
packer->default_pad_x,
GTK_VALUE_UINT (*arg));
break;
case ARG_D_IPAD_X:
gtk_packer_set_default_ipad (packer,
GTK_VALUE_UINT (*arg),
packer->default_i_pad_y);
break;
case ARG_D_IPAD_Y:
gtk_packer_set_default_ipad (packer,
packer->default_i_pad_x,
GTK_VALUE_UINT (*arg));
break;
default:
break;
}
}
static void
gtk_packer_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id)
{
GtkPacker *packer;
packer = GTK_PACKER (object);
switch (arg_id)
{
case ARG_SPACING:
GTK_VALUE_UINT (*arg) = packer->spacing;
break;
case ARG_D_BORDER_WIDTH:
GTK_VALUE_UINT (*arg) = packer->default_border_width;
break;
case ARG_D_PAD_X:
GTK_VALUE_UINT (*arg) = packer->default_pad_x;
break;
case ARG_D_PAD_Y:
GTK_VALUE_UINT (*arg) = packer->default_pad_y;
break;
case ARG_D_IPAD_X:
GTK_VALUE_UINT (*arg) = packer->default_i_pad_x;
break;
case ARG_D_IPAD_Y:
GTK_VALUE_UINT (*arg) = packer->default_i_pad_y;
break;
default:
arg->type = GTK_TYPE_INVALID;
break;
}
}
static GtkType
......@@ -167,6 +306,181 @@ gtk_packer_child_type (GtkContainer *container)
return GTK_TYPE_WIDGET;
}
static void
gtk_packer_set_child_arg (GtkContainer *container,
GtkWidget *child,
GtkArg *arg,
guint arg_id)
{
GtkPacker *packer;
GtkPackerChild *child_info = NULL;
packer = GTK_PACKER (container);
if (arg_id != CHILD_ARG_POSITION)
{
GList *list;
list = packer->children;
while (list)
{
child_info = list->data;
if (child_info->widget == child)
break;
list = list->next;
}
if (!list)
return;
}
switch (arg_id)
{
case CHILD_ARG_SIDE:
child_info->side = GTK_VALUE_ENUM (*arg);
break;
case CHILD_ARG_ANCHOR:
child_info->anchor = GTK_VALUE_ENUM (*arg);
break;
case CHILD_ARG_EXPAND:
if (GTK_VALUE_BOOL (*arg))
child_info->options |= GTK_PACK_EXPAND;
else
child_info->options &= ~GTK_PACK_EXPAND;
break;
case CHILD_ARG_FILL_X<