forked from AuroraMiddleware/gtk
gtk_*_get_arg() and gtk_*_set_arg() implementations. new arg
Sun Jan 18 03:57:52 1998 Tim Janik <timj@psynet.net> * gtk/gtkframe.c: gtk_*_get_arg() and gtk_*_set_arg() implementations. * gtk/gtkobject.c: new arg `GtkObject::object_signal' similar to `GtkObject::signal'. check for class type in gtk_object_{setv|getv}. * gtk/gtkobject.c: * gtk/gtksignal.c: * gtk/gtktypeutils.h: * gtk/gtktypeutils.c: added GTK_TYPE_DOUBLE. * gtk/gtkwidget.c: new args `has_focus' and `has_default'. * gtk/gtkwindow.c: new arg `window_position'.
This commit is contained in:
parent
e35fb5486f
commit
1e764e1b41
@ -18,9 +18,23 @@
|
||||
#include <string.h>
|
||||
#include "gtkframe.h"
|
||||
|
||||
enum {
|
||||
ARG_0,
|
||||
ARG_LABEL,
|
||||
ARG_LABEL_XALIGN,
|
||||
ARG_LABEL_YALIGN,
|
||||
ARG_SHADOW
|
||||
};
|
||||
|
||||
|
||||
static void gtk_frame_class_init (GtkFrameClass *klass);
|
||||
static void gtk_frame_init (GtkFrame *frame);
|
||||
static void gtk_frame_set_arg (GtkFrame *frame,
|
||||
GtkArg *arg,
|
||||
guint arg_id);
|
||||
static void gtk_frame_get_arg (GtkFrame *frame,
|
||||
GtkArg *arg,
|
||||
guint arg_id);
|
||||
static void gtk_frame_destroy (GtkObject *object);
|
||||
static void gtk_frame_paint (GtkWidget *widget,
|
||||
GdkRectangle *area);
|
||||
@ -51,8 +65,8 @@ gtk_frame_get_type ()
|
||||
sizeof (GtkFrameClass),
|
||||
(GtkClassInitFunc) gtk_frame_class_init,
|
||||
(GtkObjectInitFunc) gtk_frame_init,
|
||||
(GtkArgSetFunc) NULL,
|
||||
(GtkArgGetFunc) NULL,
|
||||
(GtkArgSetFunc) gtk_frame_set_arg,
|
||||
(GtkArgGetFunc) gtk_frame_get_arg,
|
||||
};
|
||||
|
||||
frame_type = gtk_type_unique (gtk_bin_get_type (), &frame_info);
|
||||
@ -72,6 +86,11 @@ gtk_frame_class_init (GtkFrameClass *class)
|
||||
|
||||
parent_class = gtk_type_class (gtk_bin_get_type ());
|
||||
|
||||
gtk_object_add_arg_type ("GtkFrame::label", GTK_TYPE_STRING, ARG_LABEL);
|
||||
gtk_object_add_arg_type ("GtkFrame::label_xalign", GTK_TYPE_DOUBLE, ARG_LABEL_XALIGN);
|
||||
gtk_object_add_arg_type ("GtkFrame::label_yalign", GTK_TYPE_DOUBLE, ARG_LABEL_YALIGN);
|
||||
gtk_object_add_arg_type ("GtkFrame::shadow", GTK_TYPE_ENUM, ARG_SHADOW);
|
||||
|
||||
object_class->destroy = gtk_frame_destroy;
|
||||
|
||||
widget_class->draw = gtk_frame_draw;
|
||||
@ -93,6 +112,53 @@ gtk_frame_init (GtkFrame *frame)
|
||||
frame->label_yalign = 0.5;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_frame_set_arg (GtkFrame *frame,
|
||||
GtkArg *arg,
|
||||
guint arg_id)
|
||||
{
|
||||
switch (arg_id)
|
||||
{
|
||||
case ARG_LABEL:
|
||||
gtk_frame_set_label (frame, GTK_VALUE_STRING (*arg));
|
||||
break;
|
||||
case ARG_LABEL_XALIGN:
|
||||
gtk_frame_set_label_align (frame, GTK_VALUE_DOUBLE (*arg), frame->label_yalign);
|
||||
break;
|
||||
case ARG_LABEL_YALIGN:
|
||||
gtk_frame_set_label_align (frame, frame->label_xalign, GTK_VALUE_DOUBLE (*arg));
|
||||
break;
|
||||
case ARG_SHADOW:
|
||||
gtk_frame_set_shadow_type (frame, GTK_VALUE_ENUM (*arg));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_frame_get_arg (GtkFrame *frame,
|
||||
GtkArg *arg,
|
||||
guint arg_id)
|
||||
{
|
||||
switch (arg_id)
|
||||
{
|
||||
case ARG_LABEL:
|
||||
GTK_VALUE_STRING (*arg) = g_strdup (frame->label);
|
||||
break;
|
||||
case ARG_LABEL_XALIGN:
|
||||
GTK_VALUE_DOUBLE (*arg) = frame->label_xalign;
|
||||
break;
|
||||
case ARG_LABEL_YALIGN:
|
||||
GTK_VALUE_DOUBLE (*arg) = frame->label_yalign;
|
||||
break;
|
||||
case ARG_SHADOW:
|
||||
GTK_VALUE_ENUM (*arg) = frame->shadow_type;
|
||||
break;
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
gtk_frame_new (const gchar *label)
|
||||
{
|
||||
|
@ -31,7 +31,8 @@ enum {
|
||||
enum {
|
||||
ARG_0,
|
||||
ARG_USER_DATA,
|
||||
ARG_SIGNAL
|
||||
ARG_SIGNAL,
|
||||
ARG_OBJECT_SIGNAL
|
||||
};
|
||||
|
||||
|
||||
@ -136,6 +137,7 @@ gtk_object_class_init (GtkObjectClass *class)
|
||||
|
||||
gtk_object_add_arg_type ("GtkObject::user_data", GTK_TYPE_POINTER, ARG_USER_DATA);
|
||||
gtk_object_add_arg_type ("GtkObject::signal", GTK_TYPE_SIGNAL, ARG_SIGNAL);
|
||||
gtk_object_add_arg_type ("GtkObject::object_signal", GTK_TYPE_SIGNAL, ARG_OBJECT_SIGNAL);
|
||||
|
||||
object_signals[DESTROY] =
|
||||
gtk_signal_new ("destroy",
|
||||
@ -185,15 +187,25 @@ gtk_object_set_arg (GtkObject *object,
|
||||
gtk_object_set_user_data (object, GTK_VALUE_POINTER (*arg));
|
||||
break;
|
||||
case ARG_SIGNAL:
|
||||
if ((arg->name[11 + 6] != ':') || (arg->name[11 + 7] != ':'))
|
||||
if ((arg->name[9 + 2 + 6] != ':') || (arg->name[9 + 2 + 7] != ':'))
|
||||
{
|
||||
g_print ("invalid signal argument: \"%s\"\n", arg->name);
|
||||
g_warning ("invalid signal argument: \"%s\"\n", arg->name);
|
||||
return;
|
||||
}
|
||||
gtk_signal_connect (object, arg->name + 11 + 8,
|
||||
gtk_signal_connect (object, arg->name + 9 + 2 + 6 + 2,
|
||||
(GtkSignalFunc) GTK_VALUE_SIGNAL (*arg).f,
|
||||
GTK_VALUE_SIGNAL (*arg).d);
|
||||
break;
|
||||
case ARG_OBJECT_SIGNAL:
|
||||
if ((arg->name[9 + 2 + 13] != ':') || (arg->name[9 + 2 + 14] != ':'))
|
||||
{
|
||||
g_warning ("invalid signal argument: \"%s\"\n", arg->name);
|
||||
return;
|
||||
}
|
||||
gtk_signal_connect_object (object, arg->name + 9 + 2 + 13 + 2,
|
||||
(GtkSignalFunc) GTK_VALUE_SIGNAL (*arg).f,
|
||||
(GtkObject*) GTK_VALUE_SIGNAL (*arg).d);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,6 +220,7 @@ gtk_object_get_arg (GtkObject *object,
|
||||
GTK_VALUE_POINTER (*arg) = gtk_object_get_user_data (object);
|
||||
break;
|
||||
case ARG_SIGNAL:
|
||||
case ARG_OBJECT_SIGNAL:
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
break;
|
||||
@ -381,6 +394,13 @@ gtk_object_getv (GtkObject *object,
|
||||
g_free (lookup_name);
|
||||
continue;
|
||||
}
|
||||
else if (!gtk_type_is_a (object->klass->type, info->class_type))
|
||||
{
|
||||
g_warning ("invalid arg for %s: \"%s\"\n", gtk_type_name (object->klass->type), lookup_name);
|
||||
args[i].type = GTK_TYPE_INVALID;
|
||||
g_free (lookup_name);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
g_free (lookup_name);
|
||||
|
||||
@ -510,13 +530,13 @@ gtk_object_set (GtkObject *object,
|
||||
*****************************************/
|
||||
|
||||
void
|
||||
gtk_object_setv (GtkObject *obj,
|
||||
gtk_object_setv (GtkObject *object,
|
||||
guint nargs,
|
||||
GtkArg *args)
|
||||
{
|
||||
int i;
|
||||
|
||||
g_return_if_fail (obj != NULL);
|
||||
g_return_if_fail (object != NULL);
|
||||
|
||||
if (!arg_info_ht)
|
||||
return;
|
||||
@ -553,13 +573,18 @@ gtk_object_setv (GtkObject *obj,
|
||||
g_warning ("invalid arg type for: \"%s\"\n", lookup_name);
|
||||
arg_ok = FALSE;
|
||||
}
|
||||
else if (!gtk_type_is_a (object->klass->type, info->class_type))
|
||||
{
|
||||
g_warning ("invalid arg for %s: \"%s\"\n", gtk_type_name (object->klass->type), lookup_name);
|
||||
arg_ok = FALSE;
|
||||
}
|
||||
|
||||
g_free (lookup_name);
|
||||
|
||||
if (!arg_ok)
|
||||
continue;
|
||||
|
||||
gtk_type_set_arg (obj, info->class_type, &args[i], info->arg_id);
|
||||
gtk_type_set_arg (object, info->class_type, &args[i], info->arg_id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1074,6 +1099,9 @@ gtk_object_collect_args (guint *nargs,
|
||||
case GTK_TYPE_FLOAT:
|
||||
(void) va_arg (args1, gfloat);
|
||||
break;
|
||||
case GTK_TYPE_DOUBLE:
|
||||
(void) va_arg (args1, gdouble);
|
||||
break;
|
||||
case GTK_TYPE_STRING:
|
||||
(void) va_arg (args1, gchar*);
|
||||
break;
|
||||
@ -1160,6 +1188,9 @@ gtk_object_collect_args (guint *nargs,
|
||||
case GTK_TYPE_FLOAT:
|
||||
GTK_VALUE_FLOAT(args[i]) = va_arg (args2, gfloat);
|
||||
break;
|
||||
case GTK_TYPE_DOUBLE:
|
||||
GTK_VALUE_DOUBLE(args[i]) = va_arg (args2, gdouble);
|
||||
break;
|
||||
case GTK_TYPE_STRING:
|
||||
GTK_VALUE_STRING(args[i]) = va_arg (args2, gchar*);
|
||||
break;
|
||||
|
@ -1209,6 +1209,9 @@ gtk_params_get (GtkArg *params,
|
||||
case GTK_TYPE_FLOAT:
|
||||
GTK_VALUE_FLOAT(params[i]) = va_arg (args, gfloat);
|
||||
break;
|
||||
case GTK_TYPE_DOUBLE:
|
||||
GTK_VALUE_DOUBLE(params[i]) = va_arg (args, gdouble);
|
||||
break;
|
||||
case GTK_TYPE_STRING:
|
||||
GTK_VALUE_STRING(params[i]) = va_arg (args, gchar*);
|
||||
break;
|
||||
@ -1291,6 +1294,9 @@ gtk_params_get (GtkArg *params,
|
||||
case GTK_TYPE_FLOAT:
|
||||
params[i].d.pointer_data = va_arg (args, gfloat*);
|
||||
break;
|
||||
case GTK_TYPE_DOUBLE:
|
||||
params[i].d.pointer_data = va_arg (args, gdouble*);
|
||||
break;
|
||||
case GTK_TYPE_STRING:
|
||||
params[i].d.pointer_data = va_arg (args, gchar**);
|
||||
break;
|
||||
|
@ -444,6 +444,7 @@ gtk_type_init_builtin_types ()
|
||||
{ GTK_TYPE_LONG, "long" },
|
||||
{ GTK_TYPE_ULONG, "ulong" },
|
||||
{ GTK_TYPE_FLOAT, "float" },
|
||||
{ GTK_TYPE_DOUBLE, "double" },
|
||||
{ GTK_TYPE_STRING, "string" },
|
||||
{ GTK_TYPE_ENUM, "enum" },
|
||||
{ GTK_TYPE_FLAGS, "flags" },
|
||||
|
@ -40,6 +40,7 @@ typedef enum
|
||||
GTK_TYPE_LONG,
|
||||
GTK_TYPE_ULONG,
|
||||
GTK_TYPE_FLOAT,
|
||||
GTK_TYPE_DOUBLE,
|
||||
GTK_TYPE_STRING,
|
||||
GTK_TYPE_ENUM,
|
||||
GTK_TYPE_FLAGS,
|
||||
@ -100,6 +101,7 @@ struct _GtkArg
|
||||
glong long_data;
|
||||
gulong ulong_data;
|
||||
gfloat float_data;
|
||||
gdouble double_data;
|
||||
gchar *string_data;
|
||||
gpointer pointer_data;
|
||||
GtkObject *object_data;
|
||||
@ -134,6 +136,7 @@ struct _GtkArg
|
||||
#define GTK_VALUE_LONG(a) ((a).d.long_data)
|
||||
#define GTK_VALUE_ULONG(a) ((a).d.ulong_data)
|
||||
#define GTK_VALUE_FLOAT(a) ((a).d.float_data)
|
||||
#define GTK_VALUE_DOUBLE(a) ((a).d.double_data)
|
||||
#define GTK_VALUE_STRING(a) ((a).d.string_data)
|
||||
#define GTK_VALUE_ENUM(a) ((a).d.int_data)
|
||||
#define GTK_VALUE_FLAGS(a) ((a).d.int_data)
|
||||
@ -153,6 +156,7 @@ struct _GtkArg
|
||||
#define GTK_RETLOC_LONG(a) ((glong*)(a).d.pointer_data)
|
||||
#define GTK_RETLOC_ULONG(a) ((gulong*)(a).d.pointer_data)
|
||||
#define GTK_RETLOC_FLOAT(a) ((gfloat*)(a).d.pointer_data)
|
||||
#define GTK_RETLOC_DOUBLE(a) ((gdouble*)(a).d.pointer_data)
|
||||
#define GTK_RETLOC_STRING(a) ((gchar**)(a).d.pointer_data)
|
||||
#define GTK_RETLOC_ENUM(a) ((gint*)(a).d.pointer_data)
|
||||
#define GTK_RETLOC_FLAGS(a) ((gint*)(a).d.pointer_data)
|
||||
|
@ -89,7 +89,9 @@ enum {
|
||||
ARG_VISIBLE,
|
||||
ARG_SENSITIVE,
|
||||
ARG_CAN_FOCUS,
|
||||
ARG_HAS_FOCUS,
|
||||
ARG_CAN_DEFAULT,
|
||||
ARG_HAS_DEFAULT,
|
||||
ARG_EVENTS,
|
||||
ARG_EXTENSION_EVENTS,
|
||||
ARG_NAME,
|
||||
@ -260,7 +262,9 @@ gtk_widget_class_init (GtkWidgetClass *klass)
|
||||
gtk_object_add_arg_type ("GtkWidget::visible", GTK_TYPE_BOOL, ARG_VISIBLE);
|
||||
gtk_object_add_arg_type ("GtkWidget::sensitive", GTK_TYPE_BOOL, ARG_SENSITIVE);
|
||||
gtk_object_add_arg_type ("GtkWidget::can_focus", GTK_TYPE_BOOL, ARG_CAN_FOCUS);
|
||||
gtk_object_add_arg_type ("GtkWidget::has_focus", GTK_TYPE_BOOL, ARG_HAS_FOCUS);
|
||||
gtk_object_add_arg_type ("GtkWidget::can_default", GTK_TYPE_BOOL, ARG_CAN_DEFAULT);
|
||||
gtk_object_add_arg_type ("GtkWidget::has_default", GTK_TYPE_BOOL, ARG_HAS_DEFAULT);
|
||||
gtk_object_add_arg_type ("GtkWidget::events", GTK_TYPE_GDK_EVENT_MASK, ARG_EVENTS);
|
||||
gtk_object_add_arg_type ("GtkWidget::extension_events", GTK_TYPE_GDK_EVENT_MASK, ARG_EXTENSION_EVENTS);
|
||||
gtk_object_add_arg_type ("GtkWidget::name", GTK_TYPE_STRING, ARG_NAME);
|
||||
@ -716,12 +720,20 @@ gtk_widget_set_arg (GtkWidget *widget,
|
||||
else
|
||||
GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
|
||||
break;
|
||||
case ARG_HAS_FOCUS:
|
||||
if (GTK_VALUE_BOOL (*arg))
|
||||
gtk_widget_grab_focus (widget);
|
||||
break;
|
||||
case ARG_CAN_DEFAULT:
|
||||
if (GTK_VALUE_BOOL (*arg))
|
||||
GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_DEFAULT);
|
||||
else
|
||||
GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_DEFAULT);
|
||||
break;
|
||||
case ARG_HAS_DEFAULT:
|
||||
if (GTK_VALUE_BOOL (*arg))
|
||||
gtk_widget_grab_default (widget);
|
||||
break;
|
||||
case ARG_EVENTS:
|
||||
gtk_widget_set_events (widget, GTK_VALUE_FLAGS (*arg));
|
||||
break;
|
||||
@ -796,9 +808,15 @@ gtk_widget_get_arg (GtkWidget *widget,
|
||||
case ARG_CAN_FOCUS:
|
||||
GTK_VALUE_BOOL (*arg) = GTK_WIDGET_CAN_FOCUS (widget);
|
||||
break;
|
||||
case ARG_HAS_FOCUS:
|
||||
GTK_VALUE_BOOL (*arg) = GTK_WIDGET_HAS_FOCUS (widget);
|
||||
break;
|
||||
case ARG_CAN_DEFAULT:
|
||||
GTK_VALUE_BOOL (*arg) = GTK_WIDGET_CAN_DEFAULT (widget);
|
||||
break;
|
||||
case ARG_HAS_DEFAULT:
|
||||
GTK_VALUE_BOOL (*arg) = GTK_WIDGET_HAS_DEFAULT (widget);
|
||||
break;
|
||||
case ARG_EVENTS:
|
||||
eventp = gtk_object_get_data (GTK_OBJECT (widget), event_key);
|
||||
if (!eventp)
|
||||
|
@ -34,7 +34,8 @@ enum {
|
||||
ARG_TITLE,
|
||||
ARG_AUTO_SHRINK,
|
||||
ARG_ALLOW_SHRINK,
|
||||
ARG_ALLOW_GROW
|
||||
ARG_ALLOW_GROW,
|
||||
ARG_WIN_POS
|
||||
};
|
||||
|
||||
typedef gint (*GtkWindowSignal1) (GtkObject *object,
|
||||
@ -153,6 +154,7 @@ gtk_window_class_init (GtkWindowClass *klass)
|
||||
gtk_object_add_arg_type ("GtkWindow::auto_shrink", GTK_TYPE_BOOL, ARG_AUTO_SHRINK);
|
||||
gtk_object_add_arg_type ("GtkWindow::allow_shrink", GTK_TYPE_BOOL, ARG_ALLOW_SHRINK);
|
||||
gtk_object_add_arg_type ("GtkWindow::allow_grow", GTK_TYPE_BOOL, ARG_ALLOW_GROW);
|
||||
gtk_object_add_arg_type ("GtkWindow::window_position", GTK_TYPE_ENUM, ARG_WIN_POS);
|
||||
|
||||
window_signals[MOVE_RESIZE] =
|
||||
gtk_signal_new ("move_resize",
|
||||
@ -234,16 +236,19 @@ gtk_window_set_arg (GtkWindow *window,
|
||||
window->type = GTK_VALUE_ENUM (*arg);
|
||||
break;
|
||||
case ARG_TITLE:
|
||||
gtk_window_set_title (window, GTK_VALUE_STRING(*arg));
|
||||
gtk_window_set_title (window, GTK_VALUE_STRING (*arg));
|
||||
break;
|
||||
case ARG_AUTO_SHRINK:
|
||||
window->auto_shrink = (GTK_VALUE_BOOL(*arg) != FALSE);
|
||||
window->auto_shrink = (GTK_VALUE_BOOL (*arg) != FALSE);
|
||||
break;
|
||||
case ARG_ALLOW_SHRINK:
|
||||
window->allow_shrink = (GTK_VALUE_BOOL(*arg) != FALSE);
|
||||
window->allow_shrink = (GTK_VALUE_BOOL (*arg) != FALSE);
|
||||
break;
|
||||
case ARG_ALLOW_GROW:
|
||||
window->allow_grow = (GTK_VALUE_BOOL(*arg) != FALSE);
|
||||
window->allow_grow = (GTK_VALUE_BOOL (*arg) != FALSE);
|
||||
break;
|
||||
case ARG_WIN_POS:
|
||||
gtk_window_position (window, GTK_VALUE_ENUM (*arg));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -256,19 +261,22 @@ gtk_window_get_arg (GtkWindow *window,
|
||||
switch (arg_id)
|
||||
{
|
||||
case ARG_TYPE:
|
||||
GTK_VALUE_ENUM(*arg) = window->type;
|
||||
GTK_VALUE_ENUM (*arg) = window->type;
|
||||
break;
|
||||
case ARG_TITLE:
|
||||
GTK_VALUE_STRING(*arg) = g_strdup (window->title);
|
||||
GTK_VALUE_STRING (*arg) = g_strdup (window->title);
|
||||
break;
|
||||
case ARG_AUTO_SHRINK:
|
||||
GTK_VALUE_BOOL(*arg) = window->auto_shrink;
|
||||
GTK_VALUE_BOOL (*arg) = window->auto_shrink;
|
||||
break;
|
||||
case ARG_ALLOW_SHRINK:
|
||||
GTK_VALUE_BOOL(*arg) = window->allow_shrink;
|
||||
GTK_VALUE_BOOL (*arg) = window->allow_shrink;
|
||||
break;
|
||||
case ARG_ALLOW_GROW:
|
||||
GTK_VALUE_BOOL(*arg) = window->allow_grow;
|
||||
GTK_VALUE_BOOL (*arg) = window->allow_grow;
|
||||
break;
|
||||
case ARG_WIN_POS:
|
||||
GTK_VALUE_ENUM (*arg) = window->position;
|
||||
break;
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
|
Loading…
Reference in New Issue
Block a user