Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ev-form-field.c
Go to the documentation of this file.
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; c-indent-level: 8 -*- */
2 /* this file is part of evince, a gnome document viewer
3  *
4  * Copyright (C) 2007 Carlos Garcia Campos <carlosgc@gnome.org>
5  * Copyright (C) 2006 Julien Rebetez
6  *
7  * Evince is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * Evince is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  */
21 
22 #include <config.h>
23 #include "ev-form-field.h"
24 
25 static void ev_form_field_init (EvFormField *field);
26 static void ev_form_field_class_init (EvFormFieldClass *klass);
27 static void ev_form_field_text_init (EvFormFieldText *field_text);
29 static void ev_form_field_button_init (EvFormFieldButton *field_button);
31 static void ev_form_field_choice_init (EvFormFieldChoice *field_choice);
33 static void ev_form_field_signature_init (EvFormFieldSignature *field_choice);
35 
36 G_DEFINE_ABSTRACT_TYPE (EvFormField, ev_form_field, G_TYPE_OBJECT)
38 G_DEFINE_TYPE (EvFormFieldButton, ev_form_field_button, EV_TYPE_FORM_FIELD)
39 G_DEFINE_TYPE (EvFormFieldChoice, ev_form_field_choice, EV_TYPE_FORM_FIELD)
40 G_DEFINE_TYPE (EvFormFieldSignature, ev_form_field_signature, EV_TYPE_FORM_FIELD)
41 
42 static void
44 {
45  field->page = NULL;
46  field->changed = FALSE;
47  field->is_read_only = FALSE;
48 }
49 
50 static void
51 ev_form_field_finalize (GObject *object)
52 {
53  EvFormField *field = EV_FORM_FIELD (object);
54 
55  g_object_unref (field->page);
56  field->page = NULL;
57 
58  g_clear_object (&field->activation_link);
59 
60  (* G_OBJECT_CLASS (ev_form_field_parent_class)->finalize) (object);
61 }
62 
63 static void
65 {
66  GObjectClass *object_class = G_OBJECT_CLASS (klass);
67 
68  object_class->finalize = ev_form_field_finalize;
69 }
70 
71 static void
72 ev_form_field_text_finalize (GObject *object)
73 {
74  EvFormFieldText *field_text = EV_FORM_FIELD_TEXT (object);
75 
76  if (field_text->text) {
77  g_free (field_text->text);
78  field_text->text = NULL;
79  }
80 
81  (* G_OBJECT_CLASS (ev_form_field_text_parent_class)->finalize) (object);
82 }
83 
84 static void
86 {
87 }
88 
89 static void
91 {
92  GObjectClass *object_class = G_OBJECT_CLASS (klass);
93 
94  object_class->finalize = ev_form_field_text_finalize;
95 }
96 
97 static void
99 {
100 }
101 
102 static void
104 {
105 }
106 
107 static void
109 {
110  EvFormFieldChoice *field_choice = EV_FORM_FIELD_CHOICE (object);
111 
112  if (field_choice->selected_items) {
113  g_list_free (field_choice->selected_items);
114  field_choice->selected_items = NULL;
115  }
116 
117  if (field_choice->text) {
118  g_free (field_choice->text);
119  field_choice->text = NULL;
120  }
121 
122  (* G_OBJECT_CLASS (ev_form_field_choice_parent_class)->finalize) (object);
123 }
124 
125 static void
127 {
128 }
129 
130 static void
132 {
133  GObjectClass *object_class = G_OBJECT_CLASS (klass);
134 
135  object_class->finalize = ev_form_field_choice_finalize;
136 }
137 
138 static void
140 {
141 }
142 
143 static void
145 {
146 }
147 
148 EvFormField *
150  EvFormFieldTextType type)
151 {
152  EvFormField *field;
153 
154  g_return_val_if_fail (id >= 0, NULL);
155  g_return_val_if_fail (type >= EV_FORM_FIELD_TEXT_NORMAL &&
156  type <= EV_FORM_FIELD_TEXT_FILE_SELECT, NULL);
157 
158  field = EV_FORM_FIELD (g_object_new (EV_TYPE_FORM_FIELD_TEXT, NULL));
159  field->id = id;
160  EV_FORM_FIELD_TEXT (field)->type = type;
161 
162  return field;
163 }
164 
165 EvFormField *
168 {
169  EvFormField *field;
170 
171  g_return_val_if_fail (id >= 0, NULL);
172  g_return_val_if_fail (type >= EV_FORM_FIELD_BUTTON_PUSH &&
173  type <= EV_FORM_FIELD_BUTTON_RADIO, NULL);
174 
175  field = EV_FORM_FIELD (g_object_new (EV_TYPE_FORM_FIELD_BUTTON, NULL));
176  field->id = id;
177  EV_FORM_FIELD_BUTTON (field)->type = type;
178 
179  return field;
180 }
181 
182 EvFormField *
185 {
186  EvFormField *field;
187 
188  g_return_val_if_fail (id >= 0, NULL);
189  g_return_val_if_fail (type >= EV_FORM_FIELD_CHOICE_COMBO &&
190  type <= EV_FORM_FIELD_CHOICE_LIST, NULL);
191 
192  field = EV_FORM_FIELD (g_object_new (EV_TYPE_FORM_FIELD_CHOICE, NULL));
193  field->id = id;
194  EV_FORM_FIELD_CHOICE (field)->type = type;
195 
196  return field;
197 }
198 
199 EvFormField *
201 {
202  EvFormField *field;
203 
204  g_return_val_if_fail (id >= 0, NULL);
205 
206  field = EV_FORM_FIELD (g_object_new (EV_TYPE_FORM_FIELD_SIGNATURE, NULL));
207  field->id = id;
208 
209  return field;
210 }
211