Added an "allow_newlines" argument.
2000-10-27 Christopher James Lahey <clahey@helixcode.com> * gal/e-text/e-entry.c, gal/e-text/e-text-event-processor-emacs-like.c, gal/e-text/e-text-event-processor-emacs-like.h, gal/e-text/e-text-event-processor.c, gal/e-text/e-text-event-processor.h, gal/e-text/e-text.c: Added an "allow_newlines" argument. svn path=/trunk/; revision=6226
This commit is contained in:
committed by
Chris Lahey
parent
0e9dae0eb6
commit
dfdfa72ec5
@ -303,7 +303,7 @@ e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, ETextEventPro
|
||||
break;
|
||||
case GDK_Return:
|
||||
case GDK_KP_Enter:
|
||||
if (key.state & GDK_CONTROL_MASK) {
|
||||
if ((key.state & GDK_CONTROL_MASK) || (!tep->allow_newlines)) {
|
||||
command.action = E_TEP_ACTIVATE;
|
||||
command.position = E_TEP_SELECTION;
|
||||
} else {
|
||||
|
||||
@ -48,7 +48,7 @@ struct _ETextEventProcessorEmacsLike
|
||||
ETextEventProcessor parent;
|
||||
|
||||
/* object specific fields */
|
||||
gboolean mouse_down;
|
||||
guint mouse_down : 1;
|
||||
};
|
||||
|
||||
struct _ETextEventProcessorEmacsLikeClass
|
||||
|
||||
@ -25,11 +25,15 @@
|
||||
static void e_text_event_processor_init (ETextEventProcessor *card);
|
||||
static void e_text_event_processor_class_init (ETextEventProcessorClass *klass);
|
||||
|
||||
static void e_text_event_processor_set_arg (GtkObject *object, GtkArg *arg, guint arg_id);
|
||||
static void e_text_event_processor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
|
||||
|
||||
static GtkObjectClass *parent_class = NULL;
|
||||
|
||||
/* The arguments we take */
|
||||
enum {
|
||||
ARG_0
|
||||
ARG_0,
|
||||
ARG_ALLOW_NEWLINES,
|
||||
};
|
||||
|
||||
enum {
|
||||
@ -67,30 +71,37 @@ e_text_event_processor_get_type (void)
|
||||
static void
|
||||
e_text_event_processor_class_init (ETextEventProcessorClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
object_class = (GtkObjectClass*) klass;
|
||||
object_class = (GtkObjectClass*) klass;
|
||||
|
||||
parent_class = gtk_type_class (gtk_object_get_type ());
|
||||
parent_class = gtk_type_class (gtk_object_get_type ());
|
||||
|
||||
e_tep_signals[E_TEP_EVENT] =
|
||||
gtk_signal_new ("command",
|
||||
GTK_RUN_LAST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (ETextEventProcessorClass, command),
|
||||
gtk_marshal_NONE__POINTER,
|
||||
GTK_TYPE_NONE, 1,
|
||||
GTK_TYPE_POINTER);
|
||||
e_tep_signals[E_TEP_EVENT] =
|
||||
gtk_signal_new ("command",
|
||||
GTK_RUN_LAST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (ETextEventProcessorClass, command),
|
||||
gtk_marshal_NONE__POINTER,
|
||||
GTK_TYPE_NONE, 1,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
gtk_object_class_add_signals (object_class, e_tep_signals, E_TEP_LAST_SIGNAL);
|
||||
gtk_object_class_add_signals (object_class, e_tep_signals, E_TEP_LAST_SIGNAL);
|
||||
|
||||
klass->event = NULL;
|
||||
klass->command = NULL;
|
||||
gtk_object_add_arg_type ("ETextEventProcessor::allow_newlines", GTK_TYPE_BOOL,
|
||||
GTK_ARG_READWRITE, ARG_ALLOW_NEWLINES);
|
||||
|
||||
klass->event = NULL;
|
||||
klass->command = NULL;
|
||||
|
||||
object_class->set_arg = e_text_event_processor_set_arg;
|
||||
object_class->get_arg = e_text_event_processor_get_arg;
|
||||
}
|
||||
|
||||
static void
|
||||
e_text_event_processor_init (ETextEventProcessor *tep)
|
||||
{
|
||||
tep->allow_newlines = TRUE;
|
||||
}
|
||||
|
||||
gint
|
||||
@ -102,3 +113,34 @@ e_text_event_processor_handle_event (ETextEventProcessor *tep, ETextEventProcess
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set_arg handler for the text item */
|
||||
static void
|
||||
e_text_event_processor_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
|
||||
{
|
||||
ETextEventProcessor *tep = E_TEXT_EVENT_PROCESSOR (object);
|
||||
|
||||
switch (arg_id) {
|
||||
case ARG_ALLOW_NEWLINES:
|
||||
tep->allow_newlines = GTK_VALUE_BOOL (*arg);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get_arg handler for the text item */
|
||||
static void
|
||||
e_text_event_processor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
|
||||
{
|
||||
ETextEventProcessor *tep = E_TEXT_EVENT_PROCESSOR (object);
|
||||
|
||||
switch (arg_id) {
|
||||
case ARG_ALLOW_NEWLINES:
|
||||
GTK_VALUE_BOOL (*arg) = tep->allow_newlines;
|
||||
break;
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,10 +45,10 @@ typedef struct _ETextEventProcessorClass ETextEventProcessorClass;
|
||||
|
||||
struct _ETextEventProcessor
|
||||
{
|
||||
GtkObject parent;
|
||||
GtkObject parent;
|
||||
|
||||
/* object specific fields */
|
||||
|
||||
/* object specific fields */
|
||||
guint allow_newlines : 1;
|
||||
};
|
||||
|
||||
struct _ETextEventProcessorClass
|
||||
|
||||
@ -62,8 +62,7 @@ enum {
|
||||
ARG_LINE_WRAP,
|
||||
ARG_BREAK_CHARACTERS,
|
||||
ARG_MAX_LINES,
|
||||
ARG_WIDTH,
|
||||
ARG_HEIGHT
|
||||
ARG_ALLOW_NEWLINES,
|
||||
};
|
||||
|
||||
static void
|
||||
@ -233,6 +232,11 @@ et_get_arg (GtkObject *o, GtkArg *arg, guint arg_id)
|
||||
"max_lines", >K_VALUE_INT (*arg),
|
||||
NULL);
|
||||
break;
|
||||
case ARG_ALLOW_NEWLINES:
|
||||
gtk_object_get(GTK_OBJECT(ee->item),
|
||||
"allow_newlines", >K_VALUE_BOOL (*arg),
|
||||
NULL);
|
||||
break;
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
break;
|
||||
@ -346,6 +350,12 @@ et_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
|
||||
"max_lines", GTK_VALUE_INT (*arg),
|
||||
NULL);
|
||||
break;
|
||||
|
||||
case ARG_ALLOW_NEWLINES:
|
||||
gtk_object_set(GTK_OBJECT(ee->item),
|
||||
"allow_newlines", GTK_VALUE_BOOL (*arg),
|
||||
NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -414,6 +424,8 @@ e_entry_class_init (GtkObjectClass *object_class)
|
||||
GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_BREAK_CHARACTERS);
|
||||
gtk_object_add_arg_type ("EEntry::max_lines",
|
||||
GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_MAX_LINES);
|
||||
gtk_object_add_arg_type ("EEntry::allow_newlines",
|
||||
GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_ALLOW_NEWLINES);
|
||||
}
|
||||
|
||||
E_MAKE_TYPE(e_entry, "EEntry", EEntry, e_entry_class_init, e_entry_init, PARENT_TYPE);
|
||||
|
||||
@ -303,7 +303,7 @@ e_text_event_processor_emacs_like_event (ETextEventProcessor *tep, ETextEventPro
|
||||
break;
|
||||
case GDK_Return:
|
||||
case GDK_KP_Enter:
|
||||
if (key.state & GDK_CONTROL_MASK) {
|
||||
if ((key.state & GDK_CONTROL_MASK) || (!tep->allow_newlines)) {
|
||||
command.action = E_TEP_ACTIVATE;
|
||||
command.position = E_TEP_SELECTION;
|
||||
} else {
|
||||
|
||||
@ -48,7 +48,7 @@ struct _ETextEventProcessorEmacsLike
|
||||
ETextEventProcessor parent;
|
||||
|
||||
/* object specific fields */
|
||||
gboolean mouse_down;
|
||||
guint mouse_down : 1;
|
||||
};
|
||||
|
||||
struct _ETextEventProcessorEmacsLikeClass
|
||||
|
||||
@ -25,11 +25,15 @@
|
||||
static void e_text_event_processor_init (ETextEventProcessor *card);
|
||||
static void e_text_event_processor_class_init (ETextEventProcessorClass *klass);
|
||||
|
||||
static void e_text_event_processor_set_arg (GtkObject *object, GtkArg *arg, guint arg_id);
|
||||
static void e_text_event_processor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
|
||||
|
||||
static GtkObjectClass *parent_class = NULL;
|
||||
|
||||
/* The arguments we take */
|
||||
enum {
|
||||
ARG_0
|
||||
ARG_0,
|
||||
ARG_ALLOW_NEWLINES,
|
||||
};
|
||||
|
||||
enum {
|
||||
@ -67,30 +71,37 @@ e_text_event_processor_get_type (void)
|
||||
static void
|
||||
e_text_event_processor_class_init (ETextEventProcessorClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
object_class = (GtkObjectClass*) klass;
|
||||
object_class = (GtkObjectClass*) klass;
|
||||
|
||||
parent_class = gtk_type_class (gtk_object_get_type ());
|
||||
parent_class = gtk_type_class (gtk_object_get_type ());
|
||||
|
||||
e_tep_signals[E_TEP_EVENT] =
|
||||
gtk_signal_new ("command",
|
||||
GTK_RUN_LAST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (ETextEventProcessorClass, command),
|
||||
gtk_marshal_NONE__POINTER,
|
||||
GTK_TYPE_NONE, 1,
|
||||
GTK_TYPE_POINTER);
|
||||
e_tep_signals[E_TEP_EVENT] =
|
||||
gtk_signal_new ("command",
|
||||
GTK_RUN_LAST,
|
||||
object_class->type,
|
||||
GTK_SIGNAL_OFFSET (ETextEventProcessorClass, command),
|
||||
gtk_marshal_NONE__POINTER,
|
||||
GTK_TYPE_NONE, 1,
|
||||
GTK_TYPE_POINTER);
|
||||
|
||||
gtk_object_class_add_signals (object_class, e_tep_signals, E_TEP_LAST_SIGNAL);
|
||||
gtk_object_class_add_signals (object_class, e_tep_signals, E_TEP_LAST_SIGNAL);
|
||||
|
||||
klass->event = NULL;
|
||||
klass->command = NULL;
|
||||
gtk_object_add_arg_type ("ETextEventProcessor::allow_newlines", GTK_TYPE_BOOL,
|
||||
GTK_ARG_READWRITE, ARG_ALLOW_NEWLINES);
|
||||
|
||||
klass->event = NULL;
|
||||
klass->command = NULL;
|
||||
|
||||
object_class->set_arg = e_text_event_processor_set_arg;
|
||||
object_class->get_arg = e_text_event_processor_get_arg;
|
||||
}
|
||||
|
||||
static void
|
||||
e_text_event_processor_init (ETextEventProcessor *tep)
|
||||
{
|
||||
tep->allow_newlines = TRUE;
|
||||
}
|
||||
|
||||
gint
|
||||
@ -102,3 +113,34 @@ e_text_event_processor_handle_event (ETextEventProcessor *tep, ETextEventProcess
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set_arg handler for the text item */
|
||||
static void
|
||||
e_text_event_processor_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
|
||||
{
|
||||
ETextEventProcessor *tep = E_TEXT_EVENT_PROCESSOR (object);
|
||||
|
||||
switch (arg_id) {
|
||||
case ARG_ALLOW_NEWLINES:
|
||||
tep->allow_newlines = GTK_VALUE_BOOL (*arg);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get_arg handler for the text item */
|
||||
static void
|
||||
e_text_event_processor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
|
||||
{
|
||||
ETextEventProcessor *tep = E_TEXT_EVENT_PROCESSOR (object);
|
||||
|
||||
switch (arg_id) {
|
||||
case ARG_ALLOW_NEWLINES:
|
||||
GTK_VALUE_BOOL (*arg) = tep->allow_newlines;
|
||||
break;
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,10 +45,10 @@ typedef struct _ETextEventProcessorClass ETextEventProcessorClass;
|
||||
|
||||
struct _ETextEventProcessor
|
||||
{
|
||||
GtkObject parent;
|
||||
GtkObject parent;
|
||||
|
||||
/* object specific fields */
|
||||
|
||||
/* object specific fields */
|
||||
guint allow_newlines : 1;
|
||||
};
|
||||
|
||||
struct _ETextEventProcessorClass
|
||||
|
||||
@ -85,6 +85,7 @@ enum {
|
||||
ARG_WIDTH,
|
||||
ARG_HEIGHT,
|
||||
ARG_DRAW_BORDERS,
|
||||
ARG_ALLOW_NEWLINES,
|
||||
};
|
||||
|
||||
|
||||
@ -280,6 +281,8 @@ e_text_class_init (ETextClass *klass)
|
||||
GTK_TYPE_DOUBLE, GTK_ARG_READABLE, ARG_HEIGHT);
|
||||
gtk_object_add_arg_type ("EText::draw_borders",
|
||||
GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_DRAW_BORDERS);
|
||||
gtk_object_add_arg_type ("EText::allow_newlines",
|
||||
GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_ALLOW_NEWLINES);
|
||||
|
||||
if (!clipboard_atom)
|
||||
clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE);
|
||||
@ -1016,8 +1019,9 @@ e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
|
||||
if ( text->tep && text->tep_command_id )
|
||||
gtk_signal_disconnect(GTK_OBJECT(text->tep),
|
||||
text->tep_command_id);
|
||||
if ( text->tep )
|
||||
if ( text->tep ) {
|
||||
gtk_object_unref(GTK_OBJECT(text->tep));
|
||||
}
|
||||
text->tep = E_TEXT_EVENT_PROCESSOR(GTK_VALUE_OBJECT (*arg));
|
||||
gtk_object_ref(GTK_OBJECT(text->tep));
|
||||
text->tep_command_id =
|
||||
@ -1278,6 +1282,13 @@ e_text_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
|
||||
}
|
||||
break;
|
||||
|
||||
case ARG_ALLOW_NEWLINES:
|
||||
_get_tep(text);
|
||||
gtk_object_set (GTK_OBJECT (text->tep),
|
||||
"allow_newlines", GTK_VALUE_BOOL (*arg),
|
||||
NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@ -1417,6 +1428,17 @@ e_text_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
|
||||
GTK_VALUE_BOOL (*arg) = text->draw_borders;
|
||||
break;
|
||||
|
||||
case ARG_ALLOW_NEWLINES:
|
||||
{
|
||||
gboolean allow_newlines;
|
||||
_get_tep(text);
|
||||
gtk_object_get (GTK_OBJECT (text->tep),
|
||||
"allow_newlines", &allow_newlines,
|
||||
NULL);
|
||||
GTK_VALUE_BOOL (*arg) = allow_newlines;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
arg->type = GTK_TYPE_INVALID;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user