Added properties. Based on patch by Lee Mallabone.

2001-05-21  Alexander Larsson  <alexl@redhat.com>

	* gtk/gtkfontsel.c:
	Added properties. Based on patch by Lee Mallabone.

	* gtk/gtkruler.c:
	* gtk/gtkhruler.c:
	* gtk/gtkvruler.c:
	* gtk/gtktext.c:
	* gtk/gtktextview.c:
	Converted GtkArg to GParam. Based on patches by John Margaglione.

	* tests/Makefile.am:
	* tests/testtext.c:
	Add a property editor to testtext.
This commit is contained in:
Alexander Larsson 2001-05-22 00:11:10 +00:00 committed by Alexander Larsson
parent 479810cac7
commit 811543ce37
15 changed files with 656 additions and 204 deletions

View File

@ -1,3 +1,19 @@
2001-05-21 Alexander Larsson <alexl@redhat.com>
* gtk/gtkfontsel.c:
Added properties. Based on patch by Lee Mallabone.
* gtk/gtkruler.c:
* gtk/gtkhruler.c:
* gtk/gtkvruler.c:
* gtk/gtktext.c:
* gtk/gtktextview.c:
Converted GtkArg to GParam. Based on patches by John Margaglione.
* tests/Makefile.am:
* tests/testtext.c:
Add a property editor to testtext.
Mon May 21 11:29:21 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtk{h,v,}paned.c: Only show the separator if

View File

@ -1,3 +1,19 @@
2001-05-21 Alexander Larsson <alexl@redhat.com>
* gtk/gtkfontsel.c:
Added properties. Based on patch by Lee Mallabone.
* gtk/gtkruler.c:
* gtk/gtkhruler.c:
* gtk/gtkvruler.c:
* gtk/gtktext.c:
* gtk/gtktextview.c:
Converted GtkArg to GParam. Based on patches by John Margaglione.
* tests/Makefile.am:
* tests/testtext.c:
Add a property editor to testtext.
Mon May 21 11:29:21 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtk{h,v,}paned.c: Only show the separator if

View File

@ -1,3 +1,19 @@
2001-05-21 Alexander Larsson <alexl@redhat.com>
* gtk/gtkfontsel.c:
Added properties. Based on patch by Lee Mallabone.
* gtk/gtkruler.c:
* gtk/gtkhruler.c:
* gtk/gtkvruler.c:
* gtk/gtktext.c:
* gtk/gtktextview.c:
Converted GtkArg to GParam. Based on patches by John Margaglione.
* tests/Makefile.am:
* tests/testtext.c:
Add a property editor to testtext.
Mon May 21 11:29:21 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtk{h,v,}paned.c: Only show the separator if

View File

@ -1,3 +1,19 @@
2001-05-21 Alexander Larsson <alexl@redhat.com>
* gtk/gtkfontsel.c:
Added properties. Based on patch by Lee Mallabone.
* gtk/gtkruler.c:
* gtk/gtkhruler.c:
* gtk/gtkvruler.c:
* gtk/gtktext.c:
* gtk/gtktextview.c:
Converted GtkArg to GParam. Based on patches by John Margaglione.
* tests/Makefile.am:
* tests/testtext.c:
Add a property editor to testtext.
Mon May 21 11:29:21 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtk{h,v,}paned.c: Only show the separator if

View File

@ -1,3 +1,19 @@
2001-05-21 Alexander Larsson <alexl@redhat.com>
* gtk/gtkfontsel.c:
Added properties. Based on patch by Lee Mallabone.
* gtk/gtkruler.c:
* gtk/gtkhruler.c:
* gtk/gtkvruler.c:
* gtk/gtktext.c:
* gtk/gtktextview.c:
Converted GtkArg to GParam. Based on patches by John Margaglione.
* tests/Makefile.am:
* tests/testtext.c:
Add a property editor to testtext.
Mon May 21 11:29:21 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtk{h,v,}paned.c: Only show the separator if

View File

@ -1,3 +1,19 @@
2001-05-21 Alexander Larsson <alexl@redhat.com>
* gtk/gtkfontsel.c:
Added properties. Based on patch by Lee Mallabone.
* gtk/gtkruler.c:
* gtk/gtkhruler.c:
* gtk/gtkvruler.c:
* gtk/gtktext.c:
* gtk/gtktextview.c:
Converted GtkArg to GParam. Based on patches by John Margaglione.
* tests/Makefile.am:
* tests/testtext.c:
Add a property editor to testtext.
Mon May 21 11:29:21 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtk{h,v,}paned.c: Only show the separator if

View File

@ -1,3 +1,19 @@
2001-05-21 Alexander Larsson <alexl@redhat.com>
* gtk/gtkfontsel.c:
Added properties. Based on patch by Lee Mallabone.
* gtk/gtkruler.c:
* gtk/gtkhruler.c:
* gtk/gtkvruler.c:
* gtk/gtktext.c:
* gtk/gtktextview.c:
Converted GtkArg to GParam. Based on patches by John Margaglione.
* tests/Makefile.am:
* tests/testtext.c:
Add a property editor to testtext.
Mon May 21 11:29:21 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtk{h,v,}paned.c: Only show the separator if

View File

@ -76,7 +76,22 @@ static const guint16 font_sizes[] = {
32, 36, 40, 48, 56, 64, 72
};
enum {
PROP_0,
PROP_FONT_NAME,
PROP_FONT,
PROP_PREVIEW_TEXT
};
static void gtk_font_selection_class_init (GtkFontSelectionClass *klass);
static void gtk_font_selection_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_font_selection_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gtk_font_selection_init (GtkFontSelection *fontsel);
static void gtk_font_selection_finalize (GObject *object);
@ -111,6 +126,8 @@ static void gtk_font_selection_expose_list (GtkWidget *w,
GdkEventExpose *event,
gpointer data);
static void gtk_font_selection_preview_changed (GtkWidget *entry,
GtkFontSelection *fontsel);
/* Misc. utility functions. */
static void gtk_font_selection_load_font (GtkFontSelection *fs);
@ -160,9 +177,84 @@ gtk_font_selection_class_init(GtkFontSelectionClass *klass)
font_selection_parent_class = gtk_type_class (GTK_TYPE_VBOX);
gobject_class->set_property = gtk_font_selection_set_property;
gobject_class->get_property = gtk_font_selection_get_property;
g_object_class_install_property (gobject_class,
PROP_FONT_NAME,
g_param_spec_string ("font_name",
_("Font name"),
_("The X string that represents this font."),
NULL,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_FONT,
g_param_spec_boxed ("font",
_("Font"),
_("The GdkFont that is currently selected."),
GDK_TYPE_FONT,
G_PARAM_READABLE));
g_object_class_install_property (gobject_class,
PROP_PREVIEW_TEXT,
g_param_spec_string ("preview_text",
_("Preview text"),
_("The text to display in order to demonstrate the selected font."),
PREVIEW_TEXT,
G_PARAM_READWRITE));
gobject_class->finalize = gtk_font_selection_finalize;
}
static void
gtk_font_selection_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkFontSelection *fontsel;
fontsel = GTK_FONT_SELECTION (object);
switch (prop_id)
{
case PROP_FONT_NAME:
gtk_font_selection_set_font_name (fontsel, g_value_get_string (value));
break;
case PROP_PREVIEW_TEXT:
gtk_font_selection_set_preview_text (fontsel, g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void gtk_font_selection_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkFontSelection *fontsel;
fontsel = GTK_FONT_SELECTION (object);
switch (prop_id)
{
case PROP_FONT_NAME:
g_value_set_string (value, gtk_font_selection_get_font_name (fontsel));
break;
case PROP_FONT:
g_value_set_object (value, G_OBJECT (gtk_font_selection_get_font (fontsel)));
break;
case PROP_PREVIEW_TEXT:
g_value_set_string (value, gtk_font_selection_get_preview_text (fontsel));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_font_selection_init(GtkFontSelection *fontsel)
{
@ -311,6 +403,9 @@ gtk_font_selection_init(GtkFontSelection *fontsel)
fontsel->preview_entry = gtk_entry_new ();
gtk_widget_show (fontsel->preview_entry);
gtk_signal_connect (GTK_OBJECT (fontsel->preview_entry), "changed",
(GtkSignalFunc) gtk_font_selection_preview_changed,
fontsel);
gtk_widget_set_usize (fontsel->preview_entry, -1, INITIAL_PREVIEW_HEIGHT);
gtk_box_pack_start (GTK_BOX (text_box), fontsel->preview_entry,
TRUE, TRUE, 0);
@ -347,6 +442,12 @@ gtk_font_selection_finalize (GObject *object)
(* G_OBJECT_CLASS (font_selection_parent_class)->finalize) (object);
}
static void
gtk_font_selection_preview_changed (GtkWidget *entry,
GtkFontSelection *fontsel)
{
g_object_notify (G_OBJECT (fontsel), "preview_text");
}
/* This is called when the clist is exposed. Here we scroll to the current
font if necessary. */
@ -793,6 +894,8 @@ gtk_font_selection_set_font_name (GtkFontSelection *fontsel,
pango_font_description_free (fontsel->font_desc);
fontsel->font_desc = new_desc;
g_object_notify (G_OBJECT (fontsel), "font_name");
g_object_notify (G_OBJECT (fontsel), "font");
return TRUE;
}

View File

@ -122,6 +122,7 @@ gtk_hruler_motion_notify (GtkWidget *widget,
x = event->x;
ruler->position = ruler->lower + ((ruler->upper - ruler->lower) * x) / widget->allocation.width;
g_object_notify (G_OBJECT (ruler), "position");
/* Make sure the ruler has been allocated already */
if (ruler->backing_store != NULL)

View File

@ -25,13 +25,14 @@
*/
#include "gtkruler.h"
#include "gtkintl.h"
enum {
ARG_0,
ARG_LOWER,
ARG_UPPER,
ARG_POSITION,
ARG_MAX_SIZE
PROP_0,
PROP_LOWER,
PROP_UPPER,
PROP_POSITION,
PROP_MAX_SIZE
};
static void gtk_ruler_class_init (GtkRulerClass *klass);
@ -43,12 +44,14 @@ static void gtk_ruler_size_allocate (GtkWidget *widget,
static gint gtk_ruler_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_ruler_make_pixmap (GtkRuler *ruler);
static void gtk_ruler_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_ruler_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_ruler_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_ruler_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static GtkWidgetClass *parent_class;
@ -88,16 +91,18 @@ gtk_ruler_get_type (void)
static void
gtk_ruler_class_init (GtkRulerClass *class)
{
GObjectClass *gobject_class;
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
gobject_class = G_OBJECT_CLASS (class);
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
parent_class = gtk_type_class (GTK_TYPE_WIDGET);
object_class->set_arg = gtk_ruler_set_arg;
object_class->get_arg = gtk_ruler_get_arg;
gobject_class->set_property = gtk_ruler_set_property;
gobject_class->get_property = gtk_ruler_get_property;
widget_class->realize = gtk_ruler_realize;
widget_class->unrealize = gtk_ruler_unrealize;
@ -107,14 +112,45 @@ gtk_ruler_class_init (GtkRulerClass *class)
class->draw_ticks = NULL;
class->draw_pos = NULL;
gtk_object_add_arg_type ("GtkRuler::lower", GTK_TYPE_DOUBLE,
GTK_ARG_READWRITE, ARG_LOWER);
gtk_object_add_arg_type ("GtkRuler::upper", GTK_TYPE_DOUBLE,
GTK_ARG_READWRITE, ARG_UPPER);
gtk_object_add_arg_type ("GtkRuler::position", GTK_TYPE_DOUBLE,
GTK_ARG_READWRITE, ARG_POSITION);
gtk_object_add_arg_type ("GtkRuler::max_size", GTK_TYPE_DOUBLE,
GTK_ARG_READWRITE, ARG_MAX_SIZE);
g_object_class_install_property (gobject_class,
PROP_LOWER,
g_param_spec_double ("lower",
_("Lower"),
_("Lower limit of ruler"),
-G_MAXDOUBLE,
G_MAXDOUBLE,
0.0,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_UPPER,
g_param_spec_double ("upper",
_("Upper"),
_("Upper limit of ruler"),
-G_MAXDOUBLE,
G_MAXDOUBLE,
0.0,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_POSITION,
g_param_spec_double ("position",
_("Position"),
_("Position of mark on the ruler"),
-G_MAXDOUBLE,
G_MAXDOUBLE,
0.0,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_MAX_SIZE,
g_param_spec_double ("max_size",
_("Max Size"),
_("Maximum size of the ruler"),
-G_MAXDOUBLE,
G_MAXDOUBLE,
0.0,
G_PARAM_READWRITE));
}
static void
@ -134,56 +170,58 @@ gtk_ruler_init (GtkRuler *ruler)
}
static void
gtk_ruler_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id)
gtk_ruler_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkRuler *ruler = GTK_RULER (object);
switch (arg_id)
switch (prop_id)
{
case ARG_LOWER:
gtk_ruler_set_range (ruler, GTK_VALUE_DOUBLE (*arg), ruler->upper,
case PROP_LOWER:
gtk_ruler_set_range (ruler, g_value_get_double (value), ruler->upper,
ruler->position, ruler->max_size);
break;
case ARG_UPPER:
gtk_ruler_set_range (ruler, ruler->lower, GTK_VALUE_DOUBLE (*arg),
case PROP_UPPER:
gtk_ruler_set_range (ruler, ruler->lower, g_value_get_double (value),
ruler->position, ruler->max_size);
break;
case ARG_POSITION:
case PROP_POSITION:
gtk_ruler_set_range (ruler, ruler->lower, ruler->upper,
GTK_VALUE_DOUBLE (*arg), ruler->max_size);
g_value_get_double (value), ruler->max_size);
break;
case ARG_MAX_SIZE:
case PROP_MAX_SIZE:
gtk_ruler_set_range (ruler, ruler->lower, ruler->upper,
ruler->position, GTK_VALUE_DOUBLE (*arg));
ruler->position, g_value_get_double (value));
break;
}
}
static void
gtk_ruler_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id)
gtk_ruler_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkRuler *ruler = GTK_RULER (object);
switch (arg_id)
switch (prop_id)
{
case ARG_LOWER:
GTK_VALUE_DOUBLE (*arg) = ruler->lower;
case PROP_LOWER:
g_value_set_double (value, ruler->lower);
break;
case ARG_UPPER:
GTK_VALUE_DOUBLE (*arg) = ruler->upper;
case PROP_UPPER:
g_value_set_double (value, ruler->upper);
break;
case ARG_POSITION:
GTK_VALUE_DOUBLE (*arg) = ruler->position;
case PROP_POSITION:
g_value_set_double (value, ruler->position);
break;
case ARG_MAX_SIZE:
GTK_VALUE_DOUBLE (*arg) = ruler->max_size;
case PROP_MAX_SIZE:
g_value_set_double (value, ruler->max_size);
break;
default:
arg->type = GTK_TYPE_INVALID;
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
@ -211,10 +249,26 @@ gtk_ruler_set_range (GtkRuler *ruler,
g_return_if_fail (ruler != NULL);
g_return_if_fail (GTK_IS_RULER (ruler));
ruler->lower = lower;
ruler->upper = upper;
ruler->position = position;
ruler->max_size = max_size;
if (ruler->lower != lower)
{
ruler->lower = lower;
g_object_notify (G_OBJECT (ruler), "lower");
}
if (ruler->upper != upper)
{
ruler->upper = upper;
g_object_notify (G_OBJECT (ruler), "upper");
}
if (ruler->position != position)
{
ruler->position = position;
g_object_notify (G_OBJECT (ruler), "position");
}
if (ruler->max_size != max_size)
{
ruler->max_size = max_size;
g_object_notify (G_OBJECT (ruler), "max_size");
}
if (GTK_WIDGET_DRAWABLE (ruler))
gtk_widget_queue_draw (GTK_WIDGET (ruler));

View File

@ -35,6 +35,7 @@
#include "gtktext.h"
#include "line-wrap.xbm"
#include "line-arrow.xbm"
#include "gtkintl.h"
#define INITIAL_BUFFER_SIZE 1024
@ -95,11 +96,11 @@
#define CACHE_DATA(c) (*(LineParams*)(c)->data)
enum {
ARG_0,
ARG_HADJUSTMENT,
ARG_VADJUSTMENT,
ARG_LINE_WRAP,
ARG_WORD_WRAP
PROP_0,
PROP_HADJUSTMENT,
PROP_VADJUSTMENT,
PROP_LINE_WRAP,
PROP_WORD_WRAP
};
typedef struct _TextProperty TextProperty;
@ -195,12 +196,14 @@ struct _LineParams
static void gtk_text_class_init (GtkTextClass *klass);
static void gtk_text_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_text_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_text_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_text_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gtk_text_init (GtkText *text);
static void gtk_text_destroy (GtkObject *object);
static void gtk_text_finalize (GObject *object);
@ -533,20 +536,21 @@ gtk_text_get_type (void)
static void
gtk_text_class_init (GtkTextClass *class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
GObjectClass *gobject_class;
GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkOldEditableClass *old_editable_class;
gobject_class = G_OBJECT_CLASS (class);
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
old_editable_class = (GtkOldEditableClass*) class;
parent_class = gtk_type_class (GTK_TYPE_OLD_EDITABLE);
gobject_class->finalize = gtk_text_finalize;
object_class->set_arg = gtk_text_set_arg;
object_class->get_arg = gtk_text_get_arg;
gobject_class->set_property = gtk_text_set_property;
gobject_class->get_property = gtk_text_get_property;
object_class->destroy = gtk_text_destroy;
widget_class->realize = gtk_text_realize;
@ -584,23 +588,38 @@ gtk_text_class_init (GtkTextClass *class)
class->set_scroll_adjustments = gtk_text_set_adjustments;
gtk_object_add_arg_type ("GtkText::hadjustment",
GTK_TYPE_ADJUSTMENT,
GTK_ARG_READWRITE,
ARG_HADJUSTMENT);
gtk_object_add_arg_type ("GtkText::vadjustment",
GTK_TYPE_ADJUSTMENT,
GTK_ARG_READWRITE,
ARG_VADJUSTMENT);
gtk_object_add_arg_type ("GtkText::line_wrap",
GTK_TYPE_BOOL,
GTK_ARG_READWRITE,
ARG_LINE_WRAP);
gtk_object_add_arg_type ("GtkText::word_wrap",
GTK_TYPE_BOOL,
GTK_ARG_READWRITE,
ARG_WORD_WRAP);
g_object_class_install_property (gobject_class,
PROP_HADJUSTMENT,
g_param_spec_object ("hadjustment",
_("Horizontal Adjustment"),
_("Horizontal adjustment for the text widget"),
GTK_TYPE_ADJUSTMENT,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_VADJUSTMENT,
g_param_spec_object ("vadjustment",
_("Vertical Adjustment"),
_("Vertical adjustment for the text widget"),
GTK_TYPE_ADJUSTMENT,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_LINE_WRAP,
g_param_spec_boolean ("line_wrap",
_("Line Wrap"),
_("Whether lines are wrapped at widget edges"),
TRUE,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_WORD_WRAP,
g_param_spec_boolean ("word_wrap",
_("Word Wrap"),
_("Whether words are wrapped at widget edges"),
FALSE,
G_PARAM_READWRITE));
widget_class->set_scroll_adjustments_signal =
gtk_signal_new ("set_scroll_adjustments",
GTK_RUN_LAST,
@ -611,62 +630,65 @@ gtk_text_class_init (GtkTextClass *class)
}
static void
gtk_text_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id)
gtk_text_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkText *text;
text = GTK_TEXT (object);
switch (arg_id)
switch (prop_id)
{
case ARG_HADJUSTMENT:
case PROP_HADJUSTMENT:
gtk_text_set_adjustments (text,
GTK_VALUE_POINTER (*arg),
g_value_get_object (value),
text->vadj);
break;
case ARG_VADJUSTMENT:
case PROP_VADJUSTMENT:
gtk_text_set_adjustments (text,
text->hadj,
GTK_VALUE_POINTER (*arg));
g_value_get_object (value));
break;
case ARG_LINE_WRAP:
gtk_text_set_line_wrap (text, GTK_VALUE_BOOL (*arg));
case PROP_LINE_WRAP:
gtk_text_set_line_wrap (text, g_value_get_boolean (value));
break;
case ARG_WORD_WRAP:
gtk_text_set_word_wrap (text, GTK_VALUE_BOOL (*arg));
case PROP_WORD_WRAP:
gtk_text_set_word_wrap (text, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_text_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id)
gtk_text_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkText *text;
text = GTK_TEXT (object);
switch (arg_id)
switch (prop_id)
{
case ARG_HADJUSTMENT:
GTK_VALUE_POINTER (*arg) = text->hadj;
case PROP_HADJUSTMENT:
g_value_set_object (value, text->hadj);
break;
case ARG_VADJUSTMENT:
GTK_VALUE_POINTER (*arg) = text->vadj;
case PROP_VADJUSTMENT:
g_value_set_object (value, text->vadj);
break;
case ARG_LINE_WRAP:
GTK_VALUE_BOOL (*arg) = text->line_wrap;
case PROP_LINE_WRAP:
g_value_set_boolean (value, text->line_wrap);
break;
case ARG_WORD_WRAP:
GTK_VALUE_BOOL (*arg) = text->word_wrap;
case PROP_WORD_WRAP:
g_value_set_boolean (value, text->word_wrap);
break;
default:
arg->type = GTK_TYPE_INVALID;
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
@ -757,6 +779,8 @@ gtk_text_set_word_wrap (GtkText *text,
recompute_geometry (text);
gtk_widget_queue_draw (GTK_WIDGET (text));
}
g_object_notify (G_OBJECT (text), "word_wrap");
}
void
@ -773,6 +797,8 @@ gtk_text_set_line_wrap (GtkText *text,
recompute_geometry (text);
gtk_widget_queue_draw (GTK_WIDGET (text));
}
g_object_notify (G_OBJECT (text), "line_wrap");
}
void
@ -848,6 +874,8 @@ gtk_text_set_adjustments (GtkText *text,
(GtkSignalFunc) gtk_text_adjustment_destroyed,
text);
gtk_text_adjustment (hadj, text);
g_object_notify (G_OBJECT (text), "hadjustment");
}
if (text->vadj != vadj)
@ -866,6 +894,8 @@ gtk_text_set_adjustments (GtkText *text,
(GtkSignalFunc) gtk_text_adjustment_destroyed,
text);
gtk_text_adjustment (vadj, text);
g_object_notify (G_OBJECT (text), "vadjustment");
}
}

View File

@ -114,32 +114,35 @@ enum
enum
{
ARG_0,
ARG_HEIGHT_LINES,
ARG_WIDTH_COLUMNS,
ARG_PIXELS_ABOVE_LINES,
ARG_PIXELS_BELOW_LINES,
ARG_PIXELS_INSIDE_WRAP,
ARG_EDITABLE,
ARG_WRAP_MODE,
ARG_JUSTIFY,
ARG_LEFT_MARGIN,
ARG_RIGHT_MARGIN,
ARG_INDENT,
ARG_TABS,
LAST_ARG
PROP_0,
PROP_HEIGHT_LINES,
PROP_WIDTH_COLUMNS,
PROP_PIXELS_ABOVE_LINES,
PROP_PIXELS_BELOW_LINES,
PROP_PIXELS_INSIDE_WRAP,
PROP_EDITABLE,
PROP_WRAP_MODE,
PROP_JUSTIFICATION,
PROP_LEFT_MARGIN,
PROP_RIGHT_MARGIN,
PROP_INDENT,
PROP_TABS,
PROP_CURSOR_VISIBLE,
LAST_PROP
};
static void gtk_text_view_init (GtkTextView *text_view);
static void gtk_text_view_class_init (GtkTextViewClass *klass);
static void gtk_text_view_destroy (GtkObject *object);
static void gtk_text_view_finalize (GObject *object);
static void gtk_text_view_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_text_view_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_text_view_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_text_view_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gtk_text_view_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_text_view_size_allocate (GtkWidget *widget,
@ -443,8 +446,8 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
/* Default handlers and virtual methods
*/
object_class->set_arg = gtk_text_view_set_arg;
object_class->get_arg = gtk_text_view_get_arg;
gobject_class->set_property = gtk_text_view_set_property;
gobject_class->get_property = gtk_text_view_get_property;
object_class->destroy = gtk_text_view_destroy;
gobject_class->finalize = gtk_text_view_finalize;
@ -492,34 +495,131 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
klass->set_scroll_adjustments = gtk_text_view_set_scroll_adjustments;
/*
* Arguments
* Properties
*/
gtk_object_add_arg_type ("GtkTextView::height_lines", GTK_TYPE_INT,
GTK_ARG_READWRITE, ARG_HEIGHT_LINES);
gtk_object_add_arg_type ("GtkTextView::width_columns", GTK_TYPE_INT,
GTK_ARG_READWRITE, ARG_WIDTH_COLUMNS);
gtk_object_add_arg_type ("GtkTextView::pixels_above_lines", GTK_TYPE_INT,
GTK_ARG_READWRITE, ARG_PIXELS_ABOVE_LINES);
gtk_object_add_arg_type ("GtkTextView::pixels_below_lines", GTK_TYPE_INT,
GTK_ARG_READWRITE, ARG_PIXELS_BELOW_LINES);
gtk_object_add_arg_type ("GtkTextView::pixels_inside_wrap", GTK_TYPE_INT,
GTK_ARG_READWRITE, ARG_PIXELS_INSIDE_WRAP);
gtk_object_add_arg_type ("GtkTextView::editable", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_EDITABLE);
g_object_class_install_property (gobject_class,
PROP_HEIGHT_LINES,
g_param_spec_int ("height_lines",
_("Line Height"),
_("The height of a line"),
0,
G_MAXINT,
0,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_WIDTH_COLUMNS,
g_param_spec_int ("width_columns",
_("Column Width"),
_("The width of a column"),
0,
G_MAXINT,
0,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_PIXELS_ABOVE_LINES,
g_param_spec_int ("pixels_above_lines",
_("Pixels Above Lines"),
_("Pixels of blank space above paragraphs"),
0,
G_MAXINT,
0,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_PIXELS_BELOW_LINES,
g_param_spec_int ("pixels_below_lines",
_("Pixels Below Lines"),
_("Pixels of blank space below paragraphs"),
0,
G_MAXINT,
0,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_PIXELS_INSIDE_WRAP,
g_param_spec_int ("pixels_inside_wrap",
_("Pixels Inside Wrap"),
_("Pixels of blank space between wrapped lines in a paragraph"),
0,
G_MAXINT,
0,
G_PARAM_READWRITE));
gtk_object_add_arg_type ("GtkTextView::wrap_mode", GTK_TYPE_WRAP_MODE,
GTK_ARG_READWRITE, ARG_WRAP_MODE);
gtk_object_add_arg_type ("GtkTextView::justify", GTK_TYPE_JUSTIFICATION,
GTK_ARG_READWRITE, ARG_JUSTIFY);
gtk_object_add_arg_type ("GtkTextView::left_margin", GTK_TYPE_INT,
GTK_ARG_READWRITE, ARG_LEFT_MARGIN);
gtk_object_add_arg_type ("GtkTextView::right_margin", GTK_TYPE_INT,
GTK_ARG_READWRITE, ARG_RIGHT_MARGIN);
gtk_object_add_arg_type ("GtkTextView::indent", GTK_TYPE_INT,
GTK_ARG_READWRITE, ARG_INDENT);
gtk_object_add_arg_type ("GtkTextView::tabs", GTK_TYPE_PANGO_TAB_ARRAY,
GTK_ARG_READWRITE, ARG_TABS);
g_object_class_install_property (gobject_class,
PROP_EDITABLE,
g_param_spec_boolean ("editable",
_("Editable"),
_("Whether the text can be modified by the user"),
TRUE,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_WRAP_MODE,
g_param_spec_enum ("wrap_mode",
_("Wrap Mode"),
_("Whether to wrap lines never, at word boundaries, or at character boundaries"),
GTK_TYPE_WRAP_MODE,
GTK_WRAP_NONE,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_JUSTIFICATION,
g_param_spec_enum ("justification",
_("Justification"),
_("Left, right, or center justification"),
GTK_TYPE_JUSTIFICATION,
GTK_JUSTIFY_LEFT,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_LEFT_MARGIN,
g_param_spec_int ("left_margin",
_("Left Margin"),
_("Width of the left margin in pixels"),
0,
G_MAXINT,
0,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_RIGHT_MARGIN,
g_param_spec_int ("right_margin",
_("Right Margin"),
_("Width of the right margin in pixels"),
0,
G_MAXINT,
0,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_INDENT,
g_param_spec_int ("indent",
_("Indent"),
_("Amount to indent the paragraph, in pixels"),
0,
G_MAXINT,
0,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_TABS,
g_param_spec_boxed ("tabs",
_("Tabs"),
_("Custom tabs for this text"),
GTK_TYPE_PANGO_TAB_ARRAY,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_CURSOR_VISIBLE,
g_param_spec_boolean ("cursor_visible",
_("Cursor Visible"),
_("If the insertion cursor is shown"),
TRUE,
G_PARAM_READWRITE));
/*
* Signals
*/
@ -1597,6 +1697,8 @@ gtk_text_view_set_wrap_mode (GtkTextView *text_view,
gtk_text_layout_default_style_changed (text_view->layout);
}
}
g_object_notify (G_OBJECT (text_view), "wrap_mode");
}
/**
@ -1641,6 +1743,8 @@ gtk_text_view_set_editable (GtkTextView *text_view,
gtk_text_layout_default_style_changed (text_view->layout);
}
}
g_object_notify (G_OBJECT (text_view), "editable");
}
/**
@ -1676,6 +1780,8 @@ gtk_text_view_set_pixels_above_lines (GtkTextView *text_view,
gtk_text_layout_default_style_changed (text_view->layout);
}
}
g_object_notify (G_OBJECT (text_view), "pixels_above_lines");
}
gint
@ -1702,6 +1808,8 @@ gtk_text_view_set_pixels_below_lines (GtkTextView *text_view,
gtk_text_layout_default_style_changed (text_view->layout);
}
}
g_object_notify (G_OBJECT (text_view), "pixels_below_lines");
}
gint
@ -1728,6 +1836,7 @@ gtk_text_view_set_pixels_inside_wrap (GtkTextView *text_view,
gtk_text_layout_default_style_changed (text_view->layout);
}
}
g_object_notify (G_OBJECT (text_view), "pixels_inside_wrap");
}
gint
@ -1754,6 +1863,8 @@ gtk_text_view_set_justification (GtkTextView *text_view,
gtk_text_layout_default_style_changed (text_view->layout);
}
}
g_object_notify (G_OBJECT (text_view), "justification");
}
GtkJustification
@ -1780,6 +1891,8 @@ gtk_text_view_set_left_margin (GtkTextView *text_view,
gtk_text_layout_default_style_changed (text_view->layout);
}
}
g_object_notify (G_OBJECT (text_view), "left_margin");
}
gint
@ -1806,6 +1919,8 @@ gtk_text_view_set_right_margin (GtkTextView *text_view,
gtk_text_layout_default_style_changed (text_view->layout);
}
}
g_object_notify (G_OBJECT (text_view), "right_margin");
}
gint
@ -1832,6 +1947,7 @@ gtk_text_view_set_indent (GtkTextView *text_view,
gtk_text_layout_default_style_changed (text_view->layout);
}
}
g_object_notify (G_OBJECT (text_view), "indent");
}
gint
@ -1864,6 +1980,8 @@ gtk_text_view_set_tabs (GtkTextView *text_view,
gtk_text_layout_default_style_changed (text_view->layout);
}
g_object_notify (G_OBJECT (text_view), "tabs");
}
PangoTabArray*
@ -1908,6 +2026,8 @@ gtk_text_view_set_cursor_visible (GtkTextView *text_view,
}
}
}
g_object_notify (G_OBJECT (text_view), "cursor_visible");
}
/**
@ -2015,60 +2135,67 @@ gtk_text_view_finalize (GObject *object)
}
static void
gtk_text_view_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
gtk_text_view_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkTextView *text_view;
text_view = GTK_TEXT_VIEW (object);
switch (arg_id)
switch (prop_id)
{
case ARG_HEIGHT_LINES:
case PROP_HEIGHT_LINES:
g_warning ("FIXME");
break;
case ARG_WIDTH_COLUMNS:
case PROP_WIDTH_COLUMNS:
g_warning ("FIXME");
break;
case ARG_PIXELS_ABOVE_LINES:
gtk_text_view_set_pixels_above_lines (text_view, GTK_VALUE_INT (*arg));
case PROP_PIXELS_ABOVE_LINES:
gtk_text_view_set_pixels_above_lines (text_view, g_value_get_int (value));
break;
case ARG_PIXELS_BELOW_LINES:
gtk_text_view_set_pixels_below_lines (text_view, GTK_VALUE_INT (*arg));
case PROP_PIXELS_BELOW_LINES:
gtk_text_view_set_pixels_below_lines (text_view, g_value_get_int (value));
break;
case ARG_PIXELS_INSIDE_WRAP:
gtk_text_view_set_pixels_inside_wrap (text_view, GTK_VALUE_INT (*arg));
case PROP_PIXELS_INSIDE_WRAP:
gtk_text_view_set_pixels_inside_wrap (text_view, g_value_get_int (value));
break;
case ARG_EDITABLE:
gtk_text_view_set_editable (text_view, GTK_VALUE_BOOL (*arg));
case PROP_EDITABLE:
gtk_text_view_set_editable (text_view, g_value_get_boolean (value));
break;
case ARG_WRAP_MODE:
gtk_text_view_set_wrap_mode (text_view, GTK_VALUE_ENUM (*arg));
case PROP_WRAP_MODE:
gtk_text_view_set_wrap_mode (text_view, g_value_get_enum (value));
break;
case ARG_JUSTIFY:
gtk_text_view_set_justification (text_view, GTK_VALUE_ENUM (*arg));
case PROP_JUSTIFICATION:
gtk_text_view_set_justification (text_view, g_value_get_enum (value));
break;
case ARG_LEFT_MARGIN:
gtk_text_view_set_left_margin (text_view, GTK_VALUE_INT (*arg));
case PROP_LEFT_MARGIN:
gtk_text_view_set_left_margin (text_view, g_value_get_int (value));
break;
case ARG_RIGHT_MARGIN:
gtk_text_view_set_right_margin (text_view, GTK_VALUE_INT (*arg));
case PROP_RIGHT_MARGIN:
gtk_text_view_set_right_margin (text_view, g_value_get_int (value));
break;
case ARG_INDENT:
gtk_text_view_set_indent (text_view, GTK_VALUE_INT (*arg));
case PROP_INDENT:
gtk_text_view_set_indent (text_view, g_value_get_int (value));
break;
case ARG_TABS:
gtk_text_view_set_tabs (text_view, GTK_VALUE_POINTER (*arg));
case PROP_TABS:
gtk_text_view_set_tabs (text_view, g_value_get_object (value));
break;
case PROP_CURSOR_VISIBLE:
gtk_text_view_set_cursor_visible (text_view, g_value_get_boolean (value));
break;
default:
@ -2078,64 +2205,71 @@ gtk_text_view_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
}
static void
gtk_text_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
gtk_text_view_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkTextView *text_view;
text_view = GTK_TEXT_VIEW (object);
switch (arg_id)
switch (prop_id)
{
case ARG_HEIGHT_LINES:
case PROP_HEIGHT_LINES:
g_warning ("FIXME");
break;
case ARG_WIDTH_COLUMNS:
case PROP_WIDTH_COLUMNS:
g_warning ("FIXME");
break;
case ARG_PIXELS_ABOVE_LINES:
GTK_VALUE_INT (*arg) = text_view->pixels_above_lines;
case PROP_PIXELS_ABOVE_LINES:
g_value_set_int (value, text_view->pixels_above_lines);
break;
case ARG_PIXELS_BELOW_LINES:
GTK_VALUE_INT (*arg) = text_view->pixels_below_lines;
case PROP_PIXELS_BELOW_LINES:
g_value_set_int (value, text_view->pixels_below_lines);
break;
case ARG_PIXELS_INSIDE_WRAP:
GTK_VALUE_INT (*arg) = text_view->pixels_inside_wrap;
case PROP_PIXELS_INSIDE_WRAP:
g_value_set_int (value, text_view->pixels_inside_wrap);
break;
case ARG_EDITABLE:
GTK_VALUE_BOOL (*arg) = text_view->editable;
case PROP_EDITABLE:
g_value_set_boolean (value, text_view->editable);
break;
case ARG_WRAP_MODE:
GTK_VALUE_ENUM (*arg) = text_view->wrap_mode;
case PROP_WRAP_MODE:
g_value_set_enum (value, text_view->wrap_mode);
break;
case ARG_JUSTIFY:
GTK_VALUE_ENUM (*arg) = text_view->justify;
case PROP_JUSTIFICATION:
g_value_set_enum (value, text_view->justify);
break;
case ARG_LEFT_MARGIN:
GTK_VALUE_INT (*arg) = text_view->left_margin;
case PROP_LEFT_MARGIN:
g_value_set_int (value, text_view->left_margin);
break;
case ARG_RIGHT_MARGIN:
GTK_VALUE_INT (*arg) = text_view->right_margin;
case PROP_RIGHT_MARGIN:
g_value_set_int (value, text_view->right_margin);
break;
case ARG_INDENT:
GTK_VALUE_INT (*arg) = text_view->indent;
case PROP_INDENT:
g_value_set_int (value, text_view->indent);
break;
case ARG_TABS:
GTK_VALUE_POINTER (*arg) = gtk_text_view_get_tabs (text_view);
case PROP_TABS:
g_value_set_object (value, gtk_text_view_get_tabs (text_view));
break;
case PROP_CURSOR_VISIBLE:
g_value_set_boolean (value, text_view->cursor_visible);
break;
default:
arg->type = GTK_TYPE_INVALID;
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}

View File

@ -122,6 +122,7 @@ gtk_vruler_motion_notify (GtkWidget *widget,
y = event->y;
ruler->position = ruler->lower + ((ruler->upper - ruler->lower) * y) / widget->allocation.height;
g_object_notify (G_OBJECT (ruler), "position");
/* Make sure the ruler has been allocated already */
if (ruler->backing_store != NULL)

View File

@ -83,6 +83,10 @@ testtreeview_SOURCES = \
prop-editor.c \
testtreeview.c
testtext_SOURCES = \
prop-editor.c \
testtext.c
EXTRA_DIST += @STRIP_BEGIN@ \
prop-editor.h \
testgtk.1 \

View File

@ -7,6 +7,8 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "prop-editor.h"
typedef struct _Buffer Buffer;
typedef struct _View View;
@ -1080,6 +1082,16 @@ do_remove_tags (gpointer callback_data,
}
}
static void
do_properties (gpointer callback_data,
guint callback_action,
GtkWidget *widget)
{
View *view = view_from_widget (widget);
create_prop_editor (G_OBJECT (view->text_view), 0);
}
enum
{
RESPONSE_FORWARD,
@ -1253,6 +1265,7 @@ static GtkItemFactoryEntry menu_items[] =
{ "/Attributes/Color cycles", NULL, do_apply_colors, TRUE, NULL },
{ "/Attributes/No colors", NULL, do_apply_colors, FALSE, NULL },
{ "/Attributes/Remove all tags", NULL, do_remove_tags, 0, NULL },
{ "/Attributes/Properties", NULL, do_properties, 0, NULL },
{ "/_Test", NULL, 0, 0, "<Branch>" },
{ "/Test/_Example", NULL, do_example, 0, NULL },
};