No issues found
1 /*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Lesser General Public
4 * License as published by the Free Software Foundation; either
5 * version 2 of the License, or (at your option) version 3.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Lesser General Public License for more details.
11 *
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with the program; if not, see <http://www.gnu.org/licenses/>
14 *
15 *
16 * Authors:
17 * Chris Lahey <clahey@ximian.com>
18 *
19 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
20 *
21 */
22
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27 #include <glib/gi18n.h>
28
29 #include "e-text-event-processor.h"
30 #include "e-util.h"
31
32 static void e_text_event_processor_set_property (GObject *object,
33 guint property_id,
34 const GValue *value,
35 GParamSpec *pspec);
36 static void e_text_event_processor_get_property (GObject *object,
37 guint property_id,
38 GValue *value,
39 GParamSpec *pspec);
40
41 enum {
42 PROP_0,
43 PROP_ALLOW_NEWLINES
44 };
45
46 enum {
47 E_TEP_EVENT,
48 E_TEP_LAST_SIGNAL
49 };
50
51 static guint e_tep_signals[E_TEP_LAST_SIGNAL] = { 0 };
52
53 G_DEFINE_TYPE (
54 ETextEventProcessor,
55 e_text_event_processor,
56 G_TYPE_OBJECT)
57
58 static void
59 e_text_event_processor_class_init (ETextEventProcessorClass *class)
60 {
61 GObjectClass *object_class;
62
63 object_class = (GObjectClass *) class;
64
65 object_class->set_property = e_text_event_processor_set_property;
66 object_class->get_property = e_text_event_processor_get_property;
67
68 e_tep_signals[E_TEP_EVENT] = g_signal_new (
69 "command",
70 G_OBJECT_CLASS_TYPE (object_class),
71 G_SIGNAL_RUN_LAST,
72 G_STRUCT_OFFSET (ETextEventProcessorClass, command),
73 NULL, NULL,
74 g_cclosure_marshal_VOID__POINTER,
75 G_TYPE_NONE, 1,
76 G_TYPE_POINTER);
77
78 g_object_class_install_property (
79 object_class,
80 PROP_ALLOW_NEWLINES,
81 g_param_spec_boolean (
82 "allow_newlines",
83 "Allow newlines",
84 "Allow newlines",
85 FALSE,
86 G_PARAM_READWRITE));
87
88 class->event = NULL;
89 class->command = NULL;
90 }
91
92 static void
93 e_text_event_processor_init (ETextEventProcessor *tep)
94 {
95 tep->allow_newlines = TRUE;
96 }
97
98 gint
99 e_text_event_processor_handle_event (ETextEventProcessor *tep,
100 ETextEventProcessorEvent *event)
101 {
102 if (E_TEXT_EVENT_PROCESSOR_GET_CLASS (tep)->event)
103 return E_TEXT_EVENT_PROCESSOR_GET_CLASS (tep)->event (tep, event);
104 else
105 return 0;
106 }
107
108 /* Set_arg handler for the text item */
109 static void
110 e_text_event_processor_set_property (GObject *object,
111 guint property_id,
112 const GValue *value,
113 GParamSpec *pspec)
114 {
115 ETextEventProcessor *tep = E_TEXT_EVENT_PROCESSOR (object);
116
117 switch (property_id) {
118 case PROP_ALLOW_NEWLINES:
119 tep->allow_newlines = g_value_get_boolean (value);
120 break;
121 default:
122 return;
123 }
124 }
125
126 /* Get_arg handler for the text item */
127 static void
128 e_text_event_processor_get_property (GObject *object,
129 guint property_id,
130 GValue *value,
131 GParamSpec *pspec)
132 {
133 ETextEventProcessor *tep = E_TEXT_EVENT_PROCESSOR (object);
134
135 switch (property_id) {
136 case PROP_ALLOW_NEWLINES:
137 g_value_set_boolean (value, tep->allow_newlines);
138 break;
139 default:
140 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
141 break;
142 }
143 }