Commit 81517a6d authored by Tim Janik's avatar Tim Janik Committed by Tim Janik

signdness corrections all ove the place. implementation of object

Thu Jul 16 18:24:41 1998  Tim Janik  <timj@gtk.org>

        * gtk/gtknotebook.h:
        * gtk/gtknotebook.c: signdness corrections all ove the place.
        implementation of object arguments: GtkNotebook::enable_popup,
        GtkNotebook::tab_pos, GtkNotebook::tab_border, GtkNotebook::show_tabs,
        GtkNotebook::show_border, GtkNotebook::scrollable and GtkNotebook::page.
        begun implementation of child args, we have GtkNotebook::tab_label, but
        GtkNotebook::menu_label and GtkNotebook::position still lack the
        implementation.
        (gtk_notebook_remove_page):
        (gtk_notebook_current_page): allow negative indices (-1) as alias for
        the last page.

        * gtk/gtkentry.h:
        * gtk/gtkentry.c: GtkType and macro fixups. implementation of object
        arguments GtkEntry::max_length and GtkEntry::visibility.
        (gtk_entry_adjust_scroll): queue a redraw.

        * gtk/gtkeditable.h:
        * gtk/gtkeditable.c: GtkType und macro fixups. implementation of
        object arguments GtkEditable::text_position and GtkEditable::editable.
        new (action) signal GtkEditable::set_editable.
        provide a default handler for GtkEditable::changed that queues a redraw.

        * gtk/gtktext.h:
        * gtk/gtktext.c: GtkType und macro fixups. override GtkEditable::
        set_editable.
parent 5e3acecc
Thu Jul 16 18:24:41 1998 Tim Janik <timj@gtk.org>
* gtk/gtknotebook.h:
* gtk/gtknotebook.c: signdness corrections all ove the place.
implementation of object arguments: GtkNotebook::enable_popup,
GtkNotebook::tab_pos, GtkNotebook::tab_border, GtkNotebook::show_tabs,
GtkNotebook::show_border, GtkNotebook::scrollable and GtkNotebook::page.
begun implementation of child args, we have GtkNotebook::tab_label, but
GtkNotebook::menu_label and GtkNotebook::position still lack the
implementation.
(gtk_notebook_remove_page):
(gtk_notebook_current_page): allow negative indices (-1) as alias for
the last page.
* gtk/gtkentry.h:
* gtk/gtkentry.c: GtkType and macro fixups. implementation of object
arguments GtkEntry::max_length and GtkEntry::visibility.
(gtk_entry_adjust_scroll): queue a redraw.
* gtk/gtkeditable.h:
* gtk/gtkeditable.c: GtkType und macro fixups. implementation of
object arguments GtkEditable::text_position and GtkEditable::editable.
new (action) signal GtkEditable::set_editable.
provide a default handler for GtkEditable::changed that queues a redraw.
* gtk/gtktext.h:
* gtk/gtktext.c: GtkType und macro fixups. override GtkEditable::
set_editable.
Thu Jul 16 14:42:11 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_button_release): fix for sigsegv in
......
Thu Jul 16 18:24:41 1998 Tim Janik <timj@gtk.org>
* gtk/gtknotebook.h:
* gtk/gtknotebook.c: signdness corrections all ove the place.
implementation of object arguments: GtkNotebook::enable_popup,
GtkNotebook::tab_pos, GtkNotebook::tab_border, GtkNotebook::show_tabs,
GtkNotebook::show_border, GtkNotebook::scrollable and GtkNotebook::page.
begun implementation of child args, we have GtkNotebook::tab_label, but
GtkNotebook::menu_label and GtkNotebook::position still lack the
implementation.
(gtk_notebook_remove_page):
(gtk_notebook_current_page): allow negative indices (-1) as alias for
the last page.
* gtk/gtkentry.h:
* gtk/gtkentry.c: GtkType and macro fixups. implementation of object
arguments GtkEntry::max_length and GtkEntry::visibility.
(gtk_entry_adjust_scroll): queue a redraw.
* gtk/gtkeditable.h:
* gtk/gtkeditable.c: GtkType und macro fixups. implementation of
object arguments GtkEditable::text_position and GtkEditable::editable.
new (action) signal GtkEditable::set_editable.
provide a default handler for GtkEditable::changed that queues a redraw.
* gtk/gtktext.h:
* gtk/gtktext.c: GtkType und macro fixups. override GtkEditable::
set_editable.
Thu Jul 16 14:42:11 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_button_release): fix for sigsegv in
......
Thu Jul 16 18:24:41 1998 Tim Janik <timj@gtk.org>
* gtk/gtknotebook.h:
* gtk/gtknotebook.c: signdness corrections all ove the place.
implementation of object arguments: GtkNotebook::enable_popup,
GtkNotebook::tab_pos, GtkNotebook::tab_border, GtkNotebook::show_tabs,
GtkNotebook::show_border, GtkNotebook::scrollable and GtkNotebook::page.
begun implementation of child args, we have GtkNotebook::tab_label, but
GtkNotebook::menu_label and GtkNotebook::position still lack the
implementation.
(gtk_notebook_remove_page):
(gtk_notebook_current_page): allow negative indices (-1) as alias for
the last page.
* gtk/gtkentry.h:
* gtk/gtkentry.c: GtkType and macro fixups. implementation of object
arguments GtkEntry::max_length and GtkEntry::visibility.
(gtk_entry_adjust_scroll): queue a redraw.
* gtk/gtkeditable.h:
* gtk/gtkeditable.c: GtkType und macro fixups. implementation of
object arguments GtkEditable::text_position and GtkEditable::editable.
new (action) signal GtkEditable::set_editable.
provide a default handler for GtkEditable::changed that queues a redraw.
* gtk/gtktext.h:
* gtk/gtktext.c: GtkType und macro fixups. override GtkEditable::
set_editable.
Thu Jul 16 14:42:11 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_button_release): fix for sigsegv in
......
Thu Jul 16 18:24:41 1998 Tim Janik <timj@gtk.org>
* gtk/gtknotebook.h:
* gtk/gtknotebook.c: signdness corrections all ove the place.
implementation of object arguments: GtkNotebook::enable_popup,
GtkNotebook::tab_pos, GtkNotebook::tab_border, GtkNotebook::show_tabs,
GtkNotebook::show_border, GtkNotebook::scrollable and GtkNotebook::page.
begun implementation of child args, we have GtkNotebook::tab_label, but
GtkNotebook::menu_label and GtkNotebook::position still lack the
implementation.
(gtk_notebook_remove_page):
(gtk_notebook_current_page): allow negative indices (-1) as alias for
the last page.
* gtk/gtkentry.h:
* gtk/gtkentry.c: GtkType and macro fixups. implementation of object
arguments GtkEntry::max_length and GtkEntry::visibility.
(gtk_entry_adjust_scroll): queue a redraw.
* gtk/gtkeditable.h:
* gtk/gtkeditable.c: GtkType und macro fixups. implementation of
object arguments GtkEditable::text_position and GtkEditable::editable.
new (action) signal GtkEditable::set_editable.
provide a default handler for GtkEditable::changed that queues a redraw.
* gtk/gtktext.h:
* gtk/gtktext.c: GtkType und macro fixups. override GtkEditable::
set_editable.
Thu Jul 16 14:42:11 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_button_release): fix for sigsegv in
......
Thu Jul 16 18:24:41 1998 Tim Janik <timj@gtk.org>
* gtk/gtknotebook.h:
* gtk/gtknotebook.c: signdness corrections all ove the place.
implementation of object arguments: GtkNotebook::enable_popup,
GtkNotebook::tab_pos, GtkNotebook::tab_border, GtkNotebook::show_tabs,
GtkNotebook::show_border, GtkNotebook::scrollable and GtkNotebook::page.
begun implementation of child args, we have GtkNotebook::tab_label, but
GtkNotebook::menu_label and GtkNotebook::position still lack the
implementation.
(gtk_notebook_remove_page):
(gtk_notebook_current_page): allow negative indices (-1) as alias for
the last page.
* gtk/gtkentry.h:
* gtk/gtkentry.c: GtkType and macro fixups. implementation of object
arguments GtkEntry::max_length and GtkEntry::visibility.
(gtk_entry_adjust_scroll): queue a redraw.
* gtk/gtkeditable.h:
* gtk/gtkeditable.c: GtkType und macro fixups. implementation of
object arguments GtkEditable::text_position and GtkEditable::editable.
new (action) signal GtkEditable::set_editable.
provide a default handler for GtkEditable::changed that queues a redraw.
* gtk/gtktext.h:
* gtk/gtktext.c: GtkType und macro fixups. override GtkEditable::
set_editable.
Thu Jul 16 14:42:11 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_button_release): fix for sigsegv in
......
Thu Jul 16 18:24:41 1998 Tim Janik <timj@gtk.org>
* gtk/gtknotebook.h:
* gtk/gtknotebook.c: signdness corrections all ove the place.
implementation of object arguments: GtkNotebook::enable_popup,
GtkNotebook::tab_pos, GtkNotebook::tab_border, GtkNotebook::show_tabs,
GtkNotebook::show_border, GtkNotebook::scrollable and GtkNotebook::page.
begun implementation of child args, we have GtkNotebook::tab_label, but
GtkNotebook::menu_label and GtkNotebook::position still lack the
implementation.
(gtk_notebook_remove_page):
(gtk_notebook_current_page): allow negative indices (-1) as alias for
the last page.
* gtk/gtkentry.h:
* gtk/gtkentry.c: GtkType and macro fixups. implementation of object
arguments GtkEntry::max_length and GtkEntry::visibility.
(gtk_entry_adjust_scroll): queue a redraw.
* gtk/gtkeditable.h:
* gtk/gtkeditable.c: GtkType und macro fixups. implementation of
object arguments GtkEditable::text_position and GtkEditable::editable.
new (action) signal GtkEditable::set_editable.
provide a default handler for GtkEditable::changed that queues a redraw.
* gtk/gtktext.h:
* gtk/gtktext.c: GtkType und macro fixups. override GtkEditable::
set_editable.
Thu Jul 16 14:42:11 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_button_release): fix for sigsegv in
......
Thu Jul 16 18:24:41 1998 Tim Janik <timj@gtk.org>
* gtk/gtknotebook.h:
* gtk/gtknotebook.c: signdness corrections all ove the place.
implementation of object arguments: GtkNotebook::enable_popup,
GtkNotebook::tab_pos, GtkNotebook::tab_border, GtkNotebook::show_tabs,
GtkNotebook::show_border, GtkNotebook::scrollable and GtkNotebook::page.
begun implementation of child args, we have GtkNotebook::tab_label, but
GtkNotebook::menu_label and GtkNotebook::position still lack the
implementation.
(gtk_notebook_remove_page):
(gtk_notebook_current_page): allow negative indices (-1) as alias for
the last page.
* gtk/gtkentry.h:
* gtk/gtkentry.c: GtkType and macro fixups. implementation of object
arguments GtkEntry::max_length and GtkEntry::visibility.
(gtk_entry_adjust_scroll): queue a redraw.
* gtk/gtkeditable.h:
* gtk/gtkeditable.c: GtkType und macro fixups. implementation of
object arguments GtkEditable::text_position and GtkEditable::editable.
new (action) signal GtkEditable::set_editable.
provide a default handler for GtkEditable::changed that queues a redraw.
* gtk/gtktext.h:
* gtk/gtktext.c: GtkType und macro fixups. override GtkEditable::
set_editable.
Thu Jul 16 14:42:11 1998 Lars Hamann <lars@gtk.org>
* gtk/gtkctree.c (gtk_ctree_button_release): fix for sigsegv in
......
......@@ -38,6 +38,7 @@ enum {
DELETE_TEXT,
/* Binding actions */
ACTIVATE,
SET_EDITABLE,
MOVE_CURSOR,
MOVE_WORD,
MOVE_PAGE,
......@@ -52,8 +53,21 @@ enum {
LAST_SIGNAL
};
enum {
ARG_0,
ARG_TEXT_POSITION,
ARG_EDITABLE
};
static void gtk_editable_class_init (GtkEditableClass *klass);
static void gtk_editable_init (GtkEditable *editable);
static void gtk_editable_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_editable_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_editable_finalize (GtkObject *object);
static gint gtk_editable_selection_clear (GtkWidget *widget,
GdkEventSelection *event);
......@@ -68,9 +82,11 @@ static void gtk_editable_set_selection (GtkEditable *editable,
gint end);
static guint32 gtk_editable_get_event_time (GtkEditable *editable);
static void gtk_real_editable_cut_clipboard (GtkEditable *editable);
static void gtk_real_editable_copy_clipboard (GtkEditable *editable);
static void gtk_real_editable_paste_clipboard (GtkEditable *editable);
static void gtk_editable_real_cut_clipboard (GtkEditable *editable);
static void gtk_editable_real_copy_clipboard (GtkEditable *editable);
static void gtk_editable_real_paste_clipboard (GtkEditable *editable);
static void gtk_editable_real_set_editable (GtkEditable *editable,
gboolean is_editable);
static void gtk_editable_marshal_signal_1 (GtkObject * object,
......@@ -107,10 +123,10 @@ typedef void (*GtkEditableSignal3) (GtkObject * object,
gint arg1,
gpointer data);
guint
GtkType
gtk_editable_get_type (void)
{
static guint editable_type = 0;
static GtkType editable_type = 0;
if (!editable_type)
{
......@@ -126,7 +142,7 @@ gtk_editable_get_type (void)
(GtkClassInitFunc) NULL,
};
editable_type = gtk_type_unique (gtk_widget_get_type (), &editable_info);
editable_type = gtk_type_unique (GTK_TYPE_WIDGET, &editable_info);
}
return editable_type;
......@@ -141,7 +157,7 @@ gtk_editable_class_init (GtkEditableClass *class)
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
parent_class = gtk_type_class (gtk_widget_get_type ());
parent_class = gtk_type_class (GTK_TYPE_WIDGET);
editable_signals[CHANGED] =
gtk_signal_new ("changed",
......@@ -182,6 +198,15 @@ gtk_editable_class_init (GtkEditableClass *class)
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
editable_signals[SET_EDITABLE] =
gtk_signal_new ("set-editable",
GTK_RUN_LAST | GTK_RUN_ACTION,
object_class->type,
GTK_SIGNAL_OFFSET (GtkEditableClass, set_editable),
gtk_editable_marshal_signal_3,
GTK_TYPE_NONE, 1,
GTK_TYPE_BOOL);
editable_signals[MOVE_CURSOR] =
gtk_signal_new ("move_cursor",
GTK_RUN_LAST | GTK_RUN_ACTION,
......@@ -282,6 +307,11 @@ gtk_editable_class_init (GtkEditableClass *class)
gtk_object_class_add_signals (object_class, editable_signals, LAST_SIGNAL);
gtk_object_add_arg_type ("GtkEditable::text_position", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_TEXT_POSITION);
gtk_object_add_arg_type ("GtkEditable::editable", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_EDITABLE);
object_class->set_arg = gtk_editable_set_arg;
object_class->get_arg = gtk_editable_get_arg;
object_class->finalize = gtk_editable_finalize;
widget_class->selection_clear_event = gtk_editable_selection_clear;
......@@ -289,9 +319,10 @@ gtk_editable_class_init (GtkEditableClass *class)
class->insert_text = NULL;
class->delete_text = NULL;
class->changed = NULL;
class->changed = (void (*) (GtkEditable*)) gtk_widget_queue_draw;
class->activate = NULL;
class->set_editable = gtk_editable_real_set_editable;
class->move_cursor = NULL;
class->move_word = NULL;
......@@ -303,9 +334,9 @@ gtk_editable_class_init (GtkEditableClass *class)
class->kill_word = NULL;
class->kill_line = NULL;
class->cut_clipboard = gtk_real_editable_cut_clipboard;
class->copy_clipboard = gtk_real_editable_copy_clipboard;
class->paste_clipboard = gtk_real_editable_paste_clipboard;
class->cut_clipboard = gtk_editable_real_cut_clipboard;
class->copy_clipboard = gtk_editable_real_copy_clipboard;
class->paste_clipboard = gtk_editable_real_paste_clipboard;
class->update_text = NULL;
class->get_chars = NULL;
......@@ -313,6 +344,51 @@ gtk_editable_class_init (GtkEditableClass *class)
class->set_position = NULL;
}
static void
gtk_editable_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id)
{
GtkEditable *editable;
editable = GTK_EDITABLE (object);
switch (arg_id)
{
case ARG_TEXT_POSITION:
gtk_editable_set_position (editable, GTK_VALUE_INT (*arg));
break;
case ARG_EDITABLE:
gtk_editable_set_editable (editable, GTK_VALUE_BOOL (*arg));
break;
default:
break;
}
}
static void
gtk_editable_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id)
{
GtkEditable *editable;
editable = GTK_EDITABLE (object);
switch (arg_id)
{
case ARG_TEXT_POSITION:
GTK_VALUE_INT (*arg) = editable->current_pos;
break;
case ARG_EDITABLE:
GTK_VALUE_BOOL (*arg) = editable->editable;
break;
default:
arg->type = GTK_TYPE_INVALID;
break;
}
}
static void
gtk_editable_init (GtkEditable *editable)
{
......@@ -492,6 +568,9 @@ gtk_editable_set_position (GtkEditable *editable,
gint
gtk_editable_get_position (GtkEditable *editable)
{
g_return_val_if_fail (editable != NULL, -1);
g_return_val_if_fail (GTK_IS_EDITABLE (editable), -1);
return editable->current_pos;
}
......@@ -688,6 +767,9 @@ gtk_editable_delete_selection (GtkEditable *editable)
guint start;
guint end;
g_return_if_fail (editable != NULL);
g_return_if_fail (GTK_IS_EDITABLE (editable));
if (!editable->editable)
return;
......@@ -713,6 +795,8 @@ gtk_editable_claim_selection (GtkEditable *editable,
gboolean claim,
guint32 time)
{
g_return_if_fail (editable != NULL);
g_return_if_fail (GTK_IS_EDITABLE (editable));
g_return_if_fail (GTK_WIDGET_REALIZED (editable));
editable->has_selection = FALSE;
......@@ -735,6 +819,9 @@ gtk_editable_select_region (GtkEditable *editable,
gint start,
gint end)
{
g_return_if_fail (editable != NULL);
g_return_if_fail (GTK_IS_EDITABLE (editable));
if (GTK_WIDGET_REALIZED (editable))
gtk_editable_claim_selection (editable, start != end, GDK_CURRENT_TIME);
......@@ -785,36 +872,72 @@ gtk_editable_get_event_time (GtkEditable *editable)
void
gtk_editable_cut_clipboard (GtkEditable *editable)
{
g_return_if_fail (editable != NULL);
g_return_if_fail (GTK_IS_EDITABLE (editable));
gtk_signal_emit (GTK_OBJECT (editable), editable_signals[CUT_CLIPBOARD]);
}
void
gtk_editable_copy_clipboard (GtkEditable *editable)
{
g_return_if_fail (editable != NULL);
g_return_if_fail (GTK_IS_EDITABLE (editable));
gtk_signal_emit (GTK_OBJECT (editable), editable_signals[COPY_CLIPBOARD]);
}
void
gtk_editable_paste_clipboard (GtkEditable *editable)
{
g_return_if_fail (editable != NULL);
g_return_if_fail (GTK_IS_EDITABLE (editable));
gtk_signal_emit (GTK_OBJECT (editable), editable_signals[PASTE_CLIPBOARD]);
}
void
gtk_editable_set_editable (GtkEditable *editable,
gboolean is_editable)
{
g_return_if_fail (editable != NULL);
g_return_if_fail (GTK_IS_EDITABLE (editable));
gtk_signal_emit (GTK_OBJECT (editable), editable_signals[SET_EDITABLE], is_editable != FALSE);
}
static void
gtk_real_editable_cut_clipboard (GtkEditable *editable)
gtk_editable_real_set_editable (GtkEditable *editable,
gboolean is_editable)
{
gtk_real_editable_copy_clipboard (editable);
gtk_editable_delete_selection (editable);
g_return_if_fail (editable != NULL);
g_return_if_fail (GTK_IS_EDITABLE (editable));
editable->editable = is_editable != FALSE;
gtk_widget_queue_draw (GTK_WIDGET (editable));
}
static void
gtk_real_editable_copy_clipboard (GtkEditable *editable)
gtk_editable_real_cut_clipboard (GtkEditable *editable)
{
guint32 time = gtk_editable_get_event_time (editable);
g_return_if_fail (editable != NULL);
g_return_if_fail (GTK_IS_EDITABLE (editable));
gtk_editable_real_copy_clipboard (editable);
gtk_editable_delete_selection (editable);
}
static void
gtk_editable_real_copy_clipboard (GtkEditable *editable)
{
guint32 time;
gint selection_start_pos;
gint selection_end_pos;
g_return_if_fail (editable != NULL);
g_return_if_fail (GTK_IS_EDITABLE (editable));
time = gtk_editable_get_event_time (editable);
selection_start_pos = MIN (editable->selection_start_pos, editable->selection_end_pos);
selection_end_pos = MAX (editable->selection_start_pos, editable->selection_end_pos);
......@@ -830,10 +953,14 @@ gtk_real_editable_copy_clipboard (GtkEditable *editable)
}
static void
gtk_real_editable_paste_clipboard (GtkEditable *editable)
gtk_editable_real_paste_clipboard (GtkEditable *editable)
{
guint32 time = gtk_editable_get_event_time (editable);
guint32 time;
g_return_if_fail (editable != NULL);
g_return_if_fail (GTK_IS_EDITABLE (editable));
time = gtk_editable_get_event_time (editable);
if (editable->editable)
gtk_selection_convert (GTK_WIDGET(editable),
clipboard_atom, ctext_atom, time);
......@@ -842,6 +969,9 @@ gtk_real_editable_paste_clipboard (GtkEditable *editable)
void
gtk_editable_changed (GtkEditable *editable)
{
g_return_if_fail (editable != NULL);
g_return_if_fail (GTK_IS_EDITABLE (editable));
gtk_signal_emit (GTK_OBJECT (editable), editable_signals[CHANGED]);
}
......
......@@ -26,12 +26,15 @@
#ifdef __cplusplus
extern "C" {
#pragma }
#endif /* __cplusplus */
#define GTK_EDITABLE(obj) GTK_CHECK_CAST (obj, gtk_editable_get_type (), GtkEditable)
#define GTK_EDITABLE_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_editable_get_type (), GtkEditableClass)
#define GTK_IS_EDITABLE(obj) GTK_CHECK_TYPE (obj, gtk_editable_get_type ())
#define GTK_TYPE_EDITABLE (gtk_editable_get_type ())
#define GTK_EDITABLE(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_EDITABLE, GtkEditable))
#define GTK_EDITABLE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_EDITABLE, GtkEditableClass))
#define GTK_IS_EDITABLE(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_EDITABLE))
#define GTK_IS_EDITABLE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_EDITABLE))
typedef struct _GtkEditable GtkEditable;
......@@ -70,6 +73,8 @@ struct _GtkEditableClass
/* Bindings actions */
void (* activate) (GtkEditable *editable);
void (* set_editable) (GtkEditable *editable,
gboolean is_editable);
void (* move_cursor) (GtkEditable *editable,
gint x,
gint y);
......@@ -110,7 +115,7 @@ struct _GtkEditableClass
gint position);
};
guint gtk_editable_get_type (void);
GtkType gtk_editable_get_type (void);
void gtk_editable_select_region (GtkEditable *editable,
gint start,
gint end);
......@@ -121,7 +126,7 @@ void gtk_editable_insert_text (GtkEditable *editable,
void gtk_editable_delete_text (GtkEditable *editable,
gint start_pos,
gint end_pos);
gchar * gtk_editable_get_chars (GtkEditable *editable,
gchar* gtk_editable_get_chars (GtkEditable *editable,
gint start_pos,
gint end_pos);
void gtk_editable_cut_clipboard (GtkEditable *editable);
......@@ -136,6 +141,8 @@ void gtk_editable_changed (GtkEditable *editable);
void gtk_editable_set_position (GtkEditable *editable,
gint position);
gint gtk_editable_get_position (GtkEditable *editable);
void gtk_editable_set_editable (GtkEditable *editable,
gboolean is_editable);
#ifdef __cplusplus
......
......@@ -33,8 +33,21 @@
#define DRAW_TIMEOUT 20
#define INNER_BORDER 2
enum {
ARG_0,
ARG_MAX_LENGTH,
ARG_VISIBILITY,
};
static void gtk_entry_class_init (GtkEntryClass *klass);
static void gtk_entry_init (GtkEntry *entry);
static void gtk_entry_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_entry_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_entry_finalize (GtkObject *object);
static void gtk_entry_realize (GtkWidget *widget);
static void gtk_entry_unrealize (GtkWidget *widget);
......@@ -200,10 +213,10 @@ static GtkTextFunction alt_keys[26] =
};
guint
GtkType
gtk_entry_get_type (void)
{
static guint entry_type = 0;
static GtkType entry_type = 0;
if (!entry_type)
{
......@@ -219,7 +232,7 @@ gtk_entry_get_type (void)
(GtkClassInitFunc) NULL,
};
entry_type = gtk_type_unique (gtk_editable_get_type (), &entry_info);
entry_type = gtk_type_unique (GTK_TYPE_EDITABLE, &entry_info);
}
return entry_type;
......@@ -235,9 +248,13 @@ gtk_entry_class_init (GtkEntryClass *class)
object_class = (GtkObjectClass*) class;
widget_class = (GtkWidgetClass*) class;
editable_class = (GtkEditableClass*) class;
parent_class = gtk_type_class (GTK_TYPE_EDITABLE);
parent_class = gtk_type_class (gtk_editable_get_type ());
gtk_object_add_arg_type ("GtkEntry::max_length", GTK_TYPE_UINT, GTK_ARG_READWRITE, ARG_MAX_LENGTH);
gtk_object_add_arg_type ("GtkEntry::visibility", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_VISIBILITY);
object_class->set_arg = gtk_entry_set_arg;
object_class->get_arg = gtk_entry_get_arg;
object_class->finalize = gtk_entry_finalize;
widget_class->realize = gtk_entry_realize;
......@@ -274,6 +291,51 @@ gtk_entry_class_init (GtkEntryClass *class)
editable_class->set_position = gtk_entry_set_position_from_editable;
}
static void
gtk_entry_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id)
{
GtkEntry *entry;
entry = GTK_ENTRY (object);
switch (arg_id)
{
case ARG_MAX_LENGTH:
gtk_entry_set_max_length (entry, GTK_VALUE_UINT (*arg));
break;
case ARG_VISIBILITY:
gtk_entry_set_visibility (entry, GTK_VALUE_BOOL (*arg));
break;
default:
break;
}
}
static void
gtk_entry_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id)
{
GtkEntry *entry;
entry = GTK_ENTRY (object);
switch (arg_id)
{
case ARG_MAX_LENGTH:
GTK_VALUE_UINT (*arg) = entry->text_max_length;
break;
case ARG_VISIBILITY:
GTK_VALUE_BOOL (*arg) = entry->visible;
break;
default:
arg->type = GTK_TYPE_INVALID;
break;
}
}
static void
gtk_entry_init (GtkEntry *entry)
{
......@@ -300,15 +362,17 @@ gtk_entry_init (GtkEntry *entry)
GtkWidget*
gtk_entry_new (void)
{
return GTK_WIDGET (gtk_type_new (gtk_entry_get_type ()));
return GTK_WIDGET (gtk_type_new (GTK_TYPE_ENTRY));
}
GtkWidget*
gtk_entry_new_with_max_length (guint16 max)
{
GtkEntry *entry;
entry = gtk_type_new (gtk_entry_get_type ());
entry = gtk_type_new (GTK_TYPE_ENTRY);
entry->text_max_length = max;
return GTK_WIDGET (entry);
}
......@@ -380,6 +444,7 @@ gtk_entry_set_position (GtkEntry *entry,
GTK_EDITABLE(entry)->current_pos = entry->text_length;
else
GTK_EDITABLE(entry)->current_pos = position;
gtk_entry_adjust_scroll (entry);
}
static void
......@@ -403,13 +468,12 @@ gtk_entry_set_visibility (GtkEntry *entry,
void
gtk_entry_set_editable(GtkEntry *entry,
gboolean editable)
gboolean editable)
{
g_return_if_fail (entry != NULL);
g_return_if_fail (GTK_IS_ENTRY (entry));
GTK_EDITABLE (entry)->editable = editable;
gtk_entry_queue_draw (entry);
gtk_editable_set_editable (GTK_EDITABLE (entry), editable);
}
gchar*
......@@ -1471,9 +1535,10 @@ gtk_entry_adjust_scroll (GtkEntry *entry)
if (xoffset < 0)
entry->scroll_offset += xoffset;
else if (xoffset > text_area_width)
entry->scroll_offset += xoffset - text_area_width + 1;
gtk_widget_queue_draw (GTK_WIDGET (entry));
}
static void
......