Commit dac3b3a1 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Add boxed type for GtkRequistion. Use it for ::size-request.

Sun Apr  1 21:37:22 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkwidget.[ch] gtk/gtktypeutils.c gtk/gtk-boxed.defs:
	Add boxed type for GtkRequistion. Use it for ::size-request.

	* gtk/gtkstyle.[ch] gtk/gtktypeutils.c gtk/gtk-boxed.defs:
        Add a new GtkBorder structure useful for geometry properties
	for widgets. Add corresponding GTK_TYPE_BORDER.

	* gtk/gtkwidget.c (gtk_widget_class_install_style_property):
	Support automatic parser selection like
	gtk_settings_install_property_parser().

	* gtk/gtksettings.c (_gtk_rc_property_select_parser): Export
	functionality for use by gtk_widget_class_install_style_property.
	Support GTK_TYPE_BORDER, GTK_TYPE_REQUISITION.

Sun Apr  1 20:48:59 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkentry.c (gtk_entry_class_init): Make invisible-char
	g_param_spec_unichar().
parent d3b826ba
Sun Apr 1 21:37:22 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] gtk/gtktypeutils.c gtk/gtk-boxed.defs:
Add boxed type for GtkRequistion. Use it for ::size-request.
* gtk/gtkstyle.[ch] gtk/gtktypeutils.c gtk/gtk-boxed.defs:
Add a new GtkBorder structure useful for geometry properties
for widgets. Add corresponding GTK_TYPE_BORDER.
* gtk/gtkwidget.c (gtk_widget_class_install_style_property):
Support automatic parser selection like
gtk_settings_install_property_parser().
* gtk/gtksettings.c (_gtk_rc_property_select_parser): Export
functionality for use by gtk_widget_class_install_style_property.
Support GTK_TYPE_BORDER, GTK_TYPE_REQUISITION.
Sun Apr 1 20:48:59 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c (gtk_entry_class_init): Make invisible-char
g_param_spec_unichar().
Sun Apr 1 23:41:37 2001 Tim Janik <timj@gtk.org>
* gdk/x11/gdkwindow-x11.c (gdk_window_focus): raise window for non
......
Sun Apr 1 21:37:22 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] gtk/gtktypeutils.c gtk/gtk-boxed.defs:
Add boxed type for GtkRequistion. Use it for ::size-request.
* gtk/gtkstyle.[ch] gtk/gtktypeutils.c gtk/gtk-boxed.defs:
Add a new GtkBorder structure useful for geometry properties
for widgets. Add corresponding GTK_TYPE_BORDER.
* gtk/gtkwidget.c (gtk_widget_class_install_style_property):
Support automatic parser selection like
gtk_settings_install_property_parser().
* gtk/gtksettings.c (_gtk_rc_property_select_parser): Export
functionality for use by gtk_widget_class_install_style_property.
Support GTK_TYPE_BORDER, GTK_TYPE_REQUISITION.
Sun Apr 1 20:48:59 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c (gtk_entry_class_init): Make invisible-char
g_param_spec_unichar().
Sun Apr 1 23:41:37 2001 Tim Janik <timj@gtk.org>
* gdk/x11/gdkwindow-x11.c (gdk_window_focus): raise window for non
......
Sun Apr 1 21:37:22 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] gtk/gtktypeutils.c gtk/gtk-boxed.defs:
Add boxed type for GtkRequistion. Use it for ::size-request.
* gtk/gtkstyle.[ch] gtk/gtktypeutils.c gtk/gtk-boxed.defs:
Add a new GtkBorder structure useful for geometry properties
for widgets. Add corresponding GTK_TYPE_BORDER.
* gtk/gtkwidget.c (gtk_widget_class_install_style_property):
Support automatic parser selection like
gtk_settings_install_property_parser().
* gtk/gtksettings.c (_gtk_rc_property_select_parser): Export
functionality for use by gtk_widget_class_install_style_property.
Support GTK_TYPE_BORDER, GTK_TYPE_REQUISITION.
Sun Apr 1 20:48:59 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c (gtk_entry_class_init): Make invisible-char
g_param_spec_unichar().
Sun Apr 1 23:41:37 2001 Tim Janik <timj@gtk.org>
* gdk/x11/gdkwindow-x11.c (gdk_window_focus): raise window for non
......
Sun Apr 1 21:37:22 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] gtk/gtktypeutils.c gtk/gtk-boxed.defs:
Add boxed type for GtkRequistion. Use it for ::size-request.
* gtk/gtkstyle.[ch] gtk/gtktypeutils.c gtk/gtk-boxed.defs:
Add a new GtkBorder structure useful for geometry properties
for widgets. Add corresponding GTK_TYPE_BORDER.
* gtk/gtkwidget.c (gtk_widget_class_install_style_property):
Support automatic parser selection like
gtk_settings_install_property_parser().
* gtk/gtksettings.c (_gtk_rc_property_select_parser): Export
functionality for use by gtk_widget_class_install_style_property.
Support GTK_TYPE_BORDER, GTK_TYPE_REQUISITION.
Sun Apr 1 20:48:59 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c (gtk_entry_class_init): Make invisible-char
g_param_spec_unichar().
Sun Apr 1 23:41:37 2001 Tim Janik <timj@gtk.org>
* gdk/x11/gdkwindow-x11.c (gdk_window_focus): raise window for non
......
Sun Apr 1 21:37:22 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] gtk/gtktypeutils.c gtk/gtk-boxed.defs:
Add boxed type for GtkRequistion. Use it for ::size-request.
* gtk/gtkstyle.[ch] gtk/gtktypeutils.c gtk/gtk-boxed.defs:
Add a new GtkBorder structure useful for geometry properties
for widgets. Add corresponding GTK_TYPE_BORDER.
* gtk/gtkwidget.c (gtk_widget_class_install_style_property):
Support automatic parser selection like
gtk_settings_install_property_parser().
* gtk/gtksettings.c (_gtk_rc_property_select_parser): Export
functionality for use by gtk_widget_class_install_style_property.
Support GTK_TYPE_BORDER, GTK_TYPE_REQUISITION.
Sun Apr 1 20:48:59 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c (gtk_entry_class_init): Make invisible-char
g_param_spec_unichar().
Sun Apr 1 23:41:37 2001 Tim Janik <timj@gtk.org>
* gdk/x11/gdkwindow-x11.c (gdk_window_focus): raise window for non
......
Sun Apr 1 21:37:22 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] gtk/gtktypeutils.c gtk/gtk-boxed.defs:
Add boxed type for GtkRequistion. Use it for ::size-request.
* gtk/gtkstyle.[ch] gtk/gtktypeutils.c gtk/gtk-boxed.defs:
Add a new GtkBorder structure useful for geometry properties
for widgets. Add corresponding GTK_TYPE_BORDER.
* gtk/gtkwidget.c (gtk_widget_class_install_style_property):
Support automatic parser selection like
gtk_settings_install_property_parser().
* gtk/gtksettings.c (_gtk_rc_property_select_parser): Export
functionality for use by gtk_widget_class_install_style_property.
Support GTK_TYPE_BORDER, GTK_TYPE_REQUISITION.
Sun Apr 1 20:48:59 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c (gtk_entry_class_init): Make invisible-char
g_param_spec_unichar().
Sun Apr 1 23:41:37 2001 Tim Janik <timj@gtk.org>
* gdk/x11/gdkwindow-x11.c (gdk_window_focus): raise window for non
......
Sun Apr 1 21:37:22 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] gtk/gtktypeutils.c gtk/gtk-boxed.defs:
Add boxed type for GtkRequistion. Use it for ::size-request.
* gtk/gtkstyle.[ch] gtk/gtktypeutils.c gtk/gtk-boxed.defs:
Add a new GtkBorder structure useful for geometry properties
for widgets. Add corresponding GTK_TYPE_BORDER.
* gtk/gtkwidget.c (gtk_widget_class_install_style_property):
Support automatic parser selection like
gtk_settings_install_property_parser().
* gtk/gtksettings.c (_gtk_rc_property_select_parser): Export
functionality for use by gtk_widget_class_install_style_property.
Support GTK_TYPE_BORDER, GTK_TYPE_REQUISITION.
Sun Apr 1 20:48:59 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.c (gtk_entry_class_init): Make invisible-char
g_param_spec_unichar().
Sun Apr 1 23:41:37 2001 Tim Janik <timj@gtk.org>
* gdk/x11/gdkwindow-x11.c (gdk_window_focus): raise window for non
......
......@@ -13,10 +13,19 @@
gtk_accel_group_ref
gtk_accel_group_unref)
(define-boxed GtkBorder
gtk_border_copy
gtk_border_free
"sizeof(GtkBorder)")
(define-boxed GtkSelectionData
gtk_selection_data_copy
gtk_selection_data_free)
(define-boxed GtkRequisition
gtk_requisition_copy
gtk_requisition_free
"sizeof(GtkRequisition)")
;;; Gdk boxed types
......
......@@ -402,14 +402,11 @@ gtk_entry_class_init (GtkEntryClass *class)
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (gobject_class,
PROP_INVISIBLE_CHAR,
g_param_spec_int ("invisible_char",
_("Invisible character"),
_("The character to use when masking entry contents (in \"password mode\")"),
0,
G_MAXINT,
'*',
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_param_spec_unichar ("invisible_char",
_("Invisible character"),
_("The character to use when masking entry contents (in \"password mode\")"),
'*',
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_object_class_install_property (gobject_class,
PROP_ACTIVATES_DEFAULT,
......
......@@ -375,6 +375,23 @@ settings_install_property_parser (GtkSettingsClass *class,
return class_n_properties;
}
GtkRcPropertyParser
_gtk_rc_property_parser_for_type (GType type)
{
if (type == GTK_TYPE_GDK_COLOR)
return gtk_rc_property_parse_color;
else if (type == GTK_TYPE_REQUISITION)
return gtk_rc_property_parse_requisition;
else if (type == GTK_TYPE_BORDER)
return gtk_rc_property_parse_border;
else if (G_TYPE_FUNDAMENTAL (type) == G_TYPE_ENUM && G_TYPE_IS_DERIVED (type))
return gtk_rc_property_parse_enum;
else if (G_TYPE_FUNDAMENTAL (type) == G_TYPE_FLAGS && G_TYPE_IS_DERIVED (type))
return gtk_rc_property_parse_flags;
else
return NULL;
}
void
gtk_settings_install_property (GtkSettings *settings,
GParamSpec *pspec)
......@@ -384,17 +401,8 @@ gtk_settings_install_property (GtkSettings *settings,
g_return_if_fail (GTK_IS_SETTINGS (settings));
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
/* convenient automatic parser selection
*/
if (G_PARAM_SPEC_VALUE_TYPE (pspec) == GTK_TYPE_GDK_COLOR)
parser = gtk_rc_property_parse_color;
else if (G_TYPE_FUNDAMENTAL (G_PARAM_SPEC_VALUE_TYPE (pspec)) == G_TYPE_ENUM &&
G_TYPE_IS_DERIVED (G_PARAM_SPEC_VALUE_TYPE (pspec)))
parser = gtk_rc_property_parse_enum;
else if (G_TYPE_FUNDAMENTAL (G_PARAM_SPEC_VALUE_TYPE (pspec)) == G_TYPE_FLAGS &&
G_TYPE_IS_DERIVED (G_PARAM_SPEC_VALUE_TYPE (pspec)))
parser = gtk_rc_property_parse_flags;
parser = _gtk_rc_property_parser_for_type (G_PARAM_SPEC_VALUE_TYPE (pspec));
settings_install_property_parser (GTK_SETTINGS_GET_CLASS (settings), pspec, parser);
}
......@@ -689,3 +697,94 @@ gtk_rc_property_parse_flags (const GParamSpec *pspec,
return success;
}
static gboolean
get_braced_int (GScanner *scanner,
gboolean first,
gboolean last,
gint *value)
{
if (first)
{
g_scanner_get_next_token (scanner);
if (scanner->token != '{')
return FALSE;
}
g_scanner_get_next_token (scanner);
if (scanner->token != G_TOKEN_INT)
return FALSE;
*value = scanner->value.v_int;
if (last)
{
g_scanner_get_next_token (scanner);
if (scanner->token != '}')
return FALSE;
}
else
{
g_scanner_get_next_token (scanner);
if (scanner->token != ',')
return FALSE;
}
return TRUE;
}
gboolean
gtk_rc_property_parse_requisition (const GParamSpec *pspec,
const GString *gstring,
GValue *property_value)
{
GtkRequisition requisition;
GScanner *scanner;
gboolean success = FALSE;
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
g_return_val_if_fail (G_VALUE_HOLDS_BOXED (property_value), FALSE);
scanner = gtk_rc_scanner_new ();
g_scanner_input_text (scanner, gstring->str, gstring->len);
if (get_braced_int (scanner, TRUE, FALSE, &requisition.width) &&
get_braced_int (scanner, FALSE, TRUE, &requisition.height))
{
g_value_set_boxed (property_value, &requisition);
success = TRUE;
}
g_scanner_destroy (scanner);
return success;
}
gboolean
gtk_rc_property_parse_border (const GParamSpec *pspec,
const GString *gstring,
GValue *property_value)
{
GtkBorder border;
GScanner *scanner;
gboolean success = FALSE;
g_return_val_if_fail (G_IS_PARAM_SPEC (pspec), FALSE);
g_return_val_if_fail (G_VALUE_HOLDS_BOXED (property_value), FALSE);
scanner = gtk_rc_scanner_new ();
g_scanner_input_text (scanner, gstring->str, gstring->len);
if (get_braced_int (scanner, TRUE, FALSE, &border.left) &&
get_braced_int (scanner, FALSE, FALSE, &border.right) &&
get_braced_int (scanner, FALSE, FALSE, &border.top) &&
get_braced_int (scanner, FALSE, TRUE, &border.bottom))
{
g_value_set_boxed (property_value, &border);
success = TRUE;
}
g_scanner_destroy (scanner);
return success;
}
......@@ -77,15 +77,21 @@ void gtk_settings_install_property_parser (GtkSettings *settings,
GtkRcPropertyParser parser);
/* --- precoded parsing functions --- */
gboolean gtk_rc_property_parse_color (const GParamSpec *pspec,
const GString *gstring,
GValue *property_value);
gboolean gtk_rc_property_parse_enum (const GParamSpec *pspec,
const GString *gstring,
GValue *property_value);
gboolean gtk_rc_property_parse_flags (const GParamSpec *pspec,
const GString *gstring,
GValue *property_value);
gboolean gtk_rc_property_parse_color (const GParamSpec *pspec,
const GString *gstring,
GValue *property_value);
gboolean gtk_rc_property_parse_enum (const GParamSpec *pspec,
const GString *gstring,
GValue *property_value);
gboolean gtk_rc_property_parse_flags (const GParamSpec *pspec,
const GString *gstring,
GValue *property_value);
gboolean gtk_rc_property_parse_requisition (const GParamSpec *pspec,
const GString *gstring,
GValue *property_value);
gboolean gtk_rc_property_parse_border (const GParamSpec *pspec,
const GString *gstring,
GValue *property_value);
/*< private >*/
void gtk_settings_set_property_value (GtkSettings *settings,
......@@ -104,6 +110,8 @@ void gtk_settings_set_double_property (GtkSettings *settings,
gdouble v_double,
const gchar *origin);
GtkRcPropertyParser _gtk_rc_property_parser_for_type (GType type);
#ifdef __cplusplus
}
#endif /* __cplusplus */
......
......@@ -4620,3 +4620,15 @@ gtk_paint_resize_grip (GtkStyle *style,
edge, x, y, width, height);
}
GtkBorder *
gtk_border_copy (const GtkBorder *border)
{
return (GtkBorder *)g_memdup (border, sizeof (GtkBorder));
}
void
gtk_border_free (GtkBorder *border)
{
g_free (border);
}
......@@ -46,6 +46,7 @@ extern "C" {
/* Some forward declarations needed to rationalize the header
* files.
*/
typedef struct _GtkBorder GtkBorder;
typedef struct _GtkStyle GtkStyle;
typedef struct _GtkStyleClass GtkStyleClass;
typedef struct _GtkThemeEngine GtkThemeEngine;
......@@ -400,6 +401,14 @@ struct _GtkStyleClass
};
struct _GtkBorder
{
gint left;
gint right;
gint top;
gint bottom;
};
GType gtk_style_get_type (void) G_GNUC_CONST;
GtkStyle* gtk_style_new (void);
GtkStyle* gtk_style_copy (GtkStyle *style);
......@@ -815,6 +824,9 @@ void gtk_paint_resize_grip (GtkStyle *style,
gint height);
GtkBorder *gtk_border_copy (const GtkBorder *border);
void gtk_border_free (GtkBorder *border);
/* --- private API --- */
const GValue* _gtk_style_peek_property_value (GtkStyle *style,
GType widget_type,
......
......@@ -170,8 +170,8 @@ gtk_type_init (GTypeDebugFlags debug_flags)
else if (builtin_info[i].parent == GTK_TYPE_BOXED)
{
static const gchar *copy_types[] = {
"GtkSelectionData", "GdkEvent", "GdkColor", "GtkTextIter", "PangoTabArray",
"PangoFontDescription", "GtkTreeIter", "GtkTreePath",
"GtkSelectionData", "GdkEvent", "GdkColor", "GtkBorder", "GtkTextIter", "PangoTabArray",
"PangoFontDescription", "GtkTreeIter", "GtkTreePath", "GtkRequisition"
};
gboolean ref_counted = TRUE;
guint j;
......
......@@ -569,10 +569,10 @@ gtk_widget_class_init (GtkWidgetClass *klass)
GTK_RUN_FIRST,
GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, size_request),
gtk_marshal_VOID__POINTER,
gtk_marshal_VOID__BOXED,
GTK_TYPE_NONE, 1,
GTK_TYPE_POINTER);
widget_signals[SIZE_ALLOCATE] =
GTK_TYPE_REQUISITION | G_VALUE_NOCOPY_CONTENTS);
widget_signals[SIZE_ALLOCATE] =
gtk_signal_new ("size_allocate",
GTK_RUN_FIRST,
GTK_CLASS_TYPE (object_class),
......@@ -5383,7 +5383,14 @@ void
gtk_widget_class_install_style_property (GtkWidgetClass *class,
GParamSpec *pspec)
{
gtk_widget_class_install_style_property_parser (class, pspec, NULL);
GtkRcPropertyParser parser;
g_return_if_fail (GTK_IS_WIDGET_CLASS (class));
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
parser = _gtk_rc_property_parser_for_type (G_PARAM_SPEC_VALUE_TYPE (pspec));
gtk_widget_class_install_style_property_parser (class, pspec, parser);
}
void
......@@ -5634,3 +5641,16 @@ gtk_widget_class_path (GtkWidget *widget,
g_strreverse (*path_p);
}
}
GtkRequisition *
gtk_requisition_copy (const GtkRequisition *requisition)
{
return (GtkRequisition *)g_memdup (requisition, sizeof (GtkRequisition));
}
void
gtk_requisition_free (GtkRequisition *requisition)
{
g_free (requisition);
}
......@@ -673,6 +673,9 @@ void gtk_widget_class_path (GtkWidget *widget,
gchar **path,
gchar **path_reversed);
GtkRequisition *gtk_requisition_copy (const GtkRequisition *requisition);
void gtk_requisition_free (GtkRequisition *requisition);
#if defined (GTK_TRACE_OBJECTS) && defined (__GNUC__)
# define gtk_widget_ref gtk_object_ref
# define gtk_widget_unref gtk_object_unref
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment