forked from AuroraMiddleware/gtk
Make GtkEditable use signals instead of calling klass->... for stuff. Could someone look at the get_chars routine to see how to return the value properly?
This commit is contained in:
parent
4a6a72fe6c
commit
ab37cadbfe
@ -37,9 +37,14 @@ enum {
|
|||||||
CHANGED,
|
CHANGED,
|
||||||
INSERT_TEXT,
|
INSERT_TEXT,
|
||||||
DELETE_TEXT,
|
DELETE_TEXT,
|
||||||
|
UPDATE_TEXT,
|
||||||
|
GET_CHARS,
|
||||||
|
SET_SELECTION,
|
||||||
|
SET_POSITION,
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void gtk_editable_class_init (GtkEditableClass *klass);
|
static void gtk_editable_class_init (GtkEditableClass *klass);
|
||||||
static void gtk_editable_init (GtkEditable *editable);
|
static void gtk_editable_init (GtkEditable *editable);
|
||||||
static void gtk_editable_finalize (GtkObject *object);
|
static void gtk_editable_finalize (GtkObject *object);
|
||||||
@ -63,6 +68,14 @@ static void gtk_editable_marshal_signal_2 (GtkObject * object,
|
|||||||
GtkSignalFunc func,
|
GtkSignalFunc func,
|
||||||
gpointer func_data,
|
gpointer func_data,
|
||||||
GtkArg * args);
|
GtkArg * args);
|
||||||
|
static gchar* gtk_editable_marshal_signal_3 (GtkObject * object,
|
||||||
|
GtkSignalFunc func,
|
||||||
|
gpointer func_data,
|
||||||
|
GtkArg * args);
|
||||||
|
static void gtk_editable_marshal_signal_4 (GtkObject * object,
|
||||||
|
GtkSignalFunc func,
|
||||||
|
gpointer func_data,
|
||||||
|
GtkArg * args);
|
||||||
|
|
||||||
static GtkWidgetClass *parent_class = NULL;
|
static GtkWidgetClass *parent_class = NULL;
|
||||||
static guint editable_signals[LAST_SIGNAL] = { 0 };
|
static guint editable_signals[LAST_SIGNAL] = { 0 };
|
||||||
@ -81,6 +94,15 @@ typedef void (*GtkTextSignal2) (GtkObject * object,
|
|||||||
gint arg2,
|
gint arg2,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
|
||||||
|
typedef gchar* (*GtkTextSignal3)(GtkObject * object,
|
||||||
|
gint arg1,
|
||||||
|
gint arg2,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
|
typedef void (*GtkTextSignal4) (GtkObject * object,
|
||||||
|
gint arg1,
|
||||||
|
gpointer data);
|
||||||
|
|
||||||
guint
|
guint
|
||||||
gtk_editable_get_type (void)
|
gtk_editable_get_type (void)
|
||||||
{
|
{
|
||||||
@ -153,7 +175,40 @@ gtk_editable_class_init (GtkEditableClass *class)
|
|||||||
GTK_TYPE_NONE,
|
GTK_TYPE_NONE,
|
||||||
2,
|
2,
|
||||||
GTK_TYPE_INT,
|
GTK_TYPE_INT,
|
||||||
GTK_TYPE_INT);
|
GTK_TYPE_INT);
|
||||||
|
|
||||||
|
editable_signals[UPDATE_TEXT] =
|
||||||
|
gtk_signal_new ("update_text", GTK_RUN_LAST,
|
||||||
|
object_class->type,
|
||||||
|
GTK_SIGNAL_OFFSET(GtkEditableClass, update_text),
|
||||||
|
gtk_editable_marshal_signal_2,
|
||||||
|
GTK_TYPE_NONE, 2,
|
||||||
|
GTK_TYPE_INT, GTK_TYPE_INT);
|
||||||
|
|
||||||
|
editable_signals[GET_CHARS] =
|
||||||
|
gtk_signal_new ("get_chars", GTK_RUN_LAST,
|
||||||
|
object_class->type,
|
||||||
|
GTK_SIGNAL_OFFSET(GtkEditableClass, get_chars),
|
||||||
|
gtk_editable_marshal_signal_3,
|
||||||
|
GTK_TYPE_STRING, 2,
|
||||||
|
GTK_TYPE_INT,
|
||||||
|
GTK_TYPE_INT);
|
||||||
|
|
||||||
|
editable_signals[SET_SELECTION] =
|
||||||
|
gtk_signal_new ("set_selection", GTK_RUN_LAST,
|
||||||
|
object_class->type,
|
||||||
|
GTK_SIGNAL_OFFSET(GtkEditableClass, set_selection),
|
||||||
|
gtk_editable_marshal_signal_2,
|
||||||
|
GTK_TYPE_NONE, 2,
|
||||||
|
GTK_TYPE_INT, GTK_TYPE_INT);
|
||||||
|
|
||||||
|
editable_signals[SET_SELECTION] =
|
||||||
|
gtk_signal_new ("set_position", GTK_RUN_LAST,
|
||||||
|
object_class->type,
|
||||||
|
GTK_SIGNAL_OFFSET(GtkEditableClass, set_position),
|
||||||
|
gtk_editable_marshal_signal_4,
|
||||||
|
GTK_TYPE_NONE, 1,
|
||||||
|
GTK_TYPE_INT);
|
||||||
|
|
||||||
gtk_object_class_add_signals (object_class, editable_signals, LAST_SIGNAL);
|
gtk_object_class_add_signals (object_class, editable_signals, LAST_SIGNAL);
|
||||||
|
|
||||||
@ -168,6 +223,8 @@ gtk_editable_class_init (GtkEditableClass *class)
|
|||||||
class->get_chars = NULL;
|
class->get_chars = NULL;
|
||||||
class->set_selection = NULL;
|
class->set_selection = NULL;
|
||||||
class->changed = NULL;
|
class->changed = NULL;
|
||||||
|
class->set_position = NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -299,7 +356,7 @@ gtk_editable_update_text (GtkEditable *editable,
|
|||||||
|
|
||||||
klass = GTK_EDITABLE_CLASS (GTK_OBJECT (editable)->klass);
|
klass = GTK_EDITABLE_CLASS (GTK_OBJECT (editable)->klass);
|
||||||
|
|
||||||
klass->update_text (editable, start_pos, end_pos);
|
gtk_signal_emit (GTK_OBJECT (editable), editable_signals[UPDATE_TEXT], start_pos, end_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
gchar *
|
||||||
@ -314,7 +371,9 @@ gtk_editable_get_chars (GtkEditable *editable,
|
|||||||
|
|
||||||
klass = GTK_EDITABLE_CLASS (GTK_OBJECT (editable)->klass);
|
klass = GTK_EDITABLE_CLASS (GTK_OBJECT (editable)->klass);
|
||||||
|
|
||||||
return klass->get_chars (editable, start, end);
|
gtk_signal_emit (GTK_OBJECT (editable), editable_signals[GET_CHARS], start, end);
|
||||||
|
g_warning("GtkEditable:get_chars should not be a signal...?\n");
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -329,7 +388,7 @@ gtk_editable_set_selection (GtkEditable *editable,
|
|||||||
|
|
||||||
klass = GTK_EDITABLE_CLASS (GTK_OBJECT (editable)->klass);
|
klass = GTK_EDITABLE_CLASS (GTK_OBJECT (editable)->klass);
|
||||||
|
|
||||||
klass->set_selection (editable, start_pos, end_pos);
|
gtk_signal_emit (GTK_OBJECT (editable), editable_signals[SET_SELECTION], start_pos, end_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -343,7 +402,7 @@ gtk_editable_set_position (GtkEditable *editable,
|
|||||||
|
|
||||||
klass = GTK_EDITABLE_CLASS (GTK_OBJECT (editable)->klass);
|
klass = GTK_EDITABLE_CLASS (GTK_OBJECT (editable)->klass);
|
||||||
|
|
||||||
return klass->set_position (editable, position);
|
gtk_signal_emit (GTK_OBJECT (editable), editable_signals[SET_POSITION], position);
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
gint
|
||||||
@ -669,3 +728,33 @@ gtk_editable_marshal_signal_2 (GtkObject * object,
|
|||||||
GTK_VALUE_INT (args[1]),
|
GTK_VALUE_INT (args[1]),
|
||||||
func_data);
|
func_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
gtk_editable_marshal_signal_3 (GtkObject * object,
|
||||||
|
GtkSignalFunc func,
|
||||||
|
gpointer func_data,
|
||||||
|
GtkArg * args)
|
||||||
|
{
|
||||||
|
GtkTextSignal3 rfunc;
|
||||||
|
|
||||||
|
rfunc = (GtkTextSignal3) func;
|
||||||
|
|
||||||
|
return (*rfunc) (object, GTK_VALUE_INT (args[0]),
|
||||||
|
GTK_VALUE_INT (args[1]),
|
||||||
|
func_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_editable_marshal_signal_4 (GtkObject * object,
|
||||||
|
GtkSignalFunc func,
|
||||||
|
gpointer func_data,
|
||||||
|
GtkArg * args)
|
||||||
|
{
|
||||||
|
GtkTextSignal4 rfunc;
|
||||||
|
|
||||||
|
rfunc = (GtkTextSignal4) func;
|
||||||
|
|
||||||
|
(*rfunc) (object, GTK_VALUE_INT (args[0]),
|
||||||
|
func_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user