1 /*  cssed (c) Iago Rubio 2003, 2005 - A tiny CSS editor.
2  *
3  *  This program is free software; you can redistribute it and/or modify
4  *  it under the terms of the GNU General Public License as published by
5  *  the Free Software Foundation; either version 2 of the License, or
6  *  (at your option) any later version.
7  *
8  *  This program is distributed in the hope that it will be useful,
9  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  *  GNU Library General Public License for more details.
12  *
13  *  You should have received a copy of the GNU General Public License
14  *  along with this program; if not, write to the Free Software
15  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16  */
17 
18 #ifdef HAVE_CONFIG_H
19 #  include <config.h>
20 #endif
21 
22 #include <string.h>
23 
24 #include <gtk/gtk.h>
25 
26 #include "cssdialogs-strings.h"
27 #include "cssedwindow.h"
28 #include "document.h"
29 #include "utils.h"
30 #include "support.h"
31 
32 enum {
33 	COL_RIGHT,
34 	COL_BELOW,
35 	COL_BLUR,
36 	COL_COLOR
37 };
38 
39 enum {
40 	COL_GENERIC,
41 	COL_SPECIFIC
42 };
43 
44 gchar*
cssdialog_angle_property_get_string(CssedWindow * window,gpointer data)45 cssdialog_angle_property_get_string	( CssedWindow* window, gpointer data )
46 {
47 	GtkWidget *entry_angle;
48 	GtkWidget *combo_entry_units;
49 	gchar* output_string;
50 	gchar *angle;
51 	gchar *units;
52 	GtkWidget* parent;
53 	CssedDoc* doc;
54 
55 	parent = GTK_WIDGET(data);
56 	doc = document_get_current( window );
57 
58 	entry_angle = lookup_widget ( parent, "entry_angle");
59 	combo_entry_units =
60 		lookup_widget (parent, "combo_entry_units");
61 
62 	angle = gtk_editable_get_chars (GTK_EDITABLE (entry_angle), 0, -1);
63 	units = gtk_editable_get_chars (GTK_EDITABLE (combo_entry_units), 0,-1);
64 
65 	if (strlen (angle) > 0)
66 		output_string = g_strdup_printf("%s", angle);
67 	else
68 		output_string = g_strdup_printf("0");
69 
70 	output_string = allocated_buffer_add_string(output_string, units);
71 
72 	g_free(angle);
73 	g_free(units);
74 
75 	return output_string;
76 }
77 
78 gchar*
cssdialog_background_property_get_string(CssedWindow * window,gpointer data)79 cssdialog_background_property_get_string	( CssedWindow* window, gpointer data )
80 {
81 	GtkWidget *colorselection;
82 	GtkWidget *checkbutton_bg_color;
83 	GtkWidget *combo_entry_bg_color;
84 	GtkWidget *checkbutton_bg_position;
85 	GtkWidget *radiobutton_bg_pos_perclen;
86 //	GtkWidget *radiobutton_bg_pos_fixed;
87 	GtkWidget *spinbutton_upper_left;
88 	GtkWidget *combo_entry_bg_perclen_upper_left;
89 	GtkWidget *combo_entry_bg_pos_fixed;
90 	GtkWidget *spinbutton_lower_right;
91 //	GtkWidget *combo_entry_lower_right;
92 	GtkWidget *checkbutton_bg_image;
93 //	GtkWidget *combo_entry_bg_image;
94 	GtkWidget *entry_uri;
95 	GtkWidget *checkbutton_bg_repeat;
96 	GtkWidget *combo_entry_bg_repeat;
97 	GtkWidget *checkbutton_bg_attachment;
98 	GtkWidget *combo_entry_bg_attachment;
99 	gchar *output_string;
100 	gchar *colorstr;
101 	GdkColor gdkcolor;
102 	gchar *position;
103 	gchar *position_upper_left;
104 	gchar *position_lower_right;
105 	gchar *position_upper_left_unit;
106 	gint nposition_uper_left;
107 	gint nposition_lower_right;
108 	gfloat fposition_uper_left;
109 	gfloat fposition_lower_right;
110 	gchar *imagestr;
111 	gchar *repeatstr;
112 	gchar *attachmentstr;
113 	gboolean bimage;
114 	gboolean bcolor;
115 	gboolean bposition;
116 	gboolean bposperclen;
117 	gboolean brepeat;
118 	gboolean battachment;
119 	GtkWidget* parent;
120 	CssedDoc* doc;
121 
122 	doc = document_get_current( window );
123 	parent = GTK_WIDGET(data);
124 
125 	checkbutton_bg_image =
126 		lookup_widget (parent, "checkbutton_bg_image");
127 	bimage = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
128 					       					(checkbutton_bg_image));
129 	checkbutton_bg_color =
130 		lookup_widget (parent, "checkbutton_bg_color");
131 	bcolor = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
132 					       					(checkbutton_bg_color));
133 	checkbutton_bg_position = lookup_widget (parent,"checkbutton_bg_position");
134 	bposition =
135 		gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(checkbutton_bg_position));
136 	checkbutton_bg_repeat = lookup_widget (parent, "checkbutton_bg_repeat");
137 	brepeat = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
138 					      					(checkbutton_bg_repeat));
139 	checkbutton_bg_attachment =
140 		lookup_widget (parent,
141 			       "checkbutton_bg_attachment");
142 	battachment =
143 		gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
144 					      (checkbutton_bg_attachment));
145 
146 	if (!bimage && !bcolor && !bposition && !brepeat && !battachment)
147 	{
148 		// background none then
149 		output_string = g_strdup("none");
150 		document_write_error_to_program_output(doc,_("background dialog: no value selected, defaulting to none"),WARNING_COLOR_STRING);
151 		return output_string;
152 	}
153 	output_string = g_strdup("");
154 	// image
155 	if (bimage)
156 	{
157 		entry_uri = lookup_widget ( parent, "entry_uri");
158 		imagestr =
159 			gtk_editable_get_chars (GTK_EDITABLE (entry_uri), 0, -1);
160 		output_string = allocated_buffer_add_string(output_string, "url(\"");
161 		output_string = allocated_buffer_add_string(output_string, imagestr);
162 		output_string = allocated_buffer_add_string(output_string, "\") ");
163 		g_free (imagestr);
164 	}
165 
166 	// bgcolor
167 	if (bcolor)
168 	{
169 		combo_entry_bg_color =
170 			lookup_widget (parent,
171 				       "combo_entry_bg_color");
172 		colorstr =
173 			gtk_editable_get_chars (GTK_EDITABLE
174 						(combo_entry_bg_color), 0,
175 						-1);
176 
177 		if (strcmp (colorstr, CSS_STR_USE_COLORSEL) == 0)
178 		{
179 			g_free (colorstr);
180 			colorselection =
181 				lookup_widget (parent,
182 					       "colorselection");
183 			gtk_color_selection_get_current_color
184 				(GTK_COLOR_SELECTION (colorselection),
185 				 &gdkcolor);
186 			colorstr =
187 				gdk_color_to_rgb_triplet_string (&gdkcolor);
188 		}
189 		output_string = allocated_buffer_add_string(output_string, colorstr);
190 		output_string = allocated_buffer_add_string(output_string, " ");
191 		g_free (colorstr);
192 	}
193 	//position
194 	if (bposition)
195 	{
196 		// perclen
197 		radiobutton_bg_pos_perclen =
198 			lookup_widget (parent,
199 				       "radiobutton_bg_pos_perclen");
200 		bposperclen =
201 			gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
202 						      (radiobutton_bg_pos_perclen));
203 		if (bposperclen)
204 		{
205 			spinbutton_upper_left =
206 				lookup_widget (parent,
207 					       "spinbutton_upper_left");
208 			spinbutton_lower_right =
209 				lookup_widget (parent,
210 					       "spinbutton_lower_right");
211 			combo_entry_bg_perclen_upper_left =
212 				lookup_widget (parent,
213 					       "combo_entry_unit");
214 
215 			position_upper_left_unit =
216 				gtk_editable_get_chars (GTK_EDITABLE
217 							(combo_entry_bg_perclen_upper_left),
218 							0, -1);
219 /**/		if( strcmp( position_upper_left_unit, "em") == 0 ||
220 				strcmp( position_upper_left_unit, "in") == 0 )
221 			{
222 				fposition_uper_left = (gfloat)
223 					gtk_spin_button_get_value_as_float
224 					(GTK_SPIN_BUTTON (spinbutton_upper_left));
225 				fposition_lower_right = (gfloat)
226 					gtk_spin_button_get_value_as_float
227 					(GTK_SPIN_BUTTON (spinbutton_lower_right));
228 
229 				position_upper_left =
230 					g_strdup_printf ("%0.2f%s", fposition_uper_left,
231 							 position_upper_left_unit);
232 				position_lower_right =
233 					g_strdup_printf ("%0.2f%s", fposition_lower_right,
234 							 position_upper_left_unit);
235 			}else{
236 				nposition_uper_left =
237 					gtk_spin_button_get_value_as_int
238 					(GTK_SPIN_BUTTON (spinbutton_upper_left));
239 				nposition_lower_right =
240 					gtk_spin_button_get_value_as_int
241 					(GTK_SPIN_BUTTON (spinbutton_lower_right));
242 
243 				position_upper_left =
244 					g_strdup_printf ("%d%s", nposition_uper_left,
245 							 position_upper_left_unit);
246 				position_lower_right =
247 					g_strdup_printf ("%d%s",
248 							 nposition_lower_right,
249 							 position_upper_left_unit);
250 			}
251 
252 			//g_strdup_printf
253 			output_string = allocated_buffer_add_string(output_string, position_upper_left);
254 			output_string = allocated_buffer_add_string(output_string, " ");
255 			output_string = allocated_buffer_add_string(output_string, position_lower_right);
256 			output_string = allocated_buffer_add_string(output_string, " ");
257 
258 			g_free (position_upper_left_unit);
259 			g_free (position_lower_right);
260 			g_free (position_upper_left);
261 		}
262 		else
263 		{
264 			combo_entry_bg_pos_fixed =
265 				lookup_widget (parent,
266 					       "combo_entry_bg_pos_fixed");
267 			position =
268 				gtk_editable_get_chars (GTK_EDITABLE
269 							(combo_entry_bg_pos_fixed),
270 							-0, -1);
271 			output_string = allocated_buffer_add_string(output_string, position);
272 			output_string = allocated_buffer_add_string(output_string, " ");
273 			g_free (position);
274 		}
275 	}
276 	//repeat
277 	if (brepeat)
278 	{
279 		combo_entry_bg_repeat =	lookup_widget (parent, "combo_entry_bg_repeat");
280 		repeatstr =	gtk_editable_get_chars (GTK_EDITABLE(combo_entry_bg_repeat),
281 							-0,	-1);
282 		output_string = allocated_buffer_add_string(output_string, repeatstr);
283 		output_string = allocated_buffer_add_string(output_string, " ");
284 		g_free (repeatstr);
285 	}
286 	//attachment
287 	if (battachment)
288 	{
289 		combo_entry_bg_attachment =
290 			lookup_widget (parent,
291 				       "combo_entry_bg_attachment");
292 		attachmentstr =
293 			gtk_editable_get_chars (GTK_EDITABLE
294 						(combo_entry_bg_attachment),
295 						-0, -1);
296 
297 		output_string = allocated_buffer_add_string(output_string, attachmentstr);
298 		g_free (attachmentstr);
299 	}
300 
301 	return output_string;
302 }
303 
304 gchar*
cssdialog_border_properties_get_string(CssedWindow * window,gpointer data)305 cssdialog_border_properties_get_string	( CssedWindow* window, gpointer data )
306 {
307 	GtkWidget *checkbutton_border_length;
308 	GtkWidget *combo_entry_border_length_selector;
309 	GtkWidget *spinbutton_len;
310 	GtkWidget *combo_entry_len;
311 	GtkWidget *checkbutton_border_style;
312 	GtkWidget *combo_entry_border_style;
313 	GtkWidget *checkbutton_border_color;
314 	GtkWidget *combo_entry_border_color;
315 	GtkWidget *colorselection;
316 	GdkColor gdkcolor;
317 	gboolean blength;
318 	gboolean bstyle;
319 	gboolean bcolor;
320 	gchar *strlength;
321 	gchar *strunit;
322 	gchar *strlenunit;
323 	gchar *strstyle;
324 	gchar *strcolor;
325 	gchar* output_string;
326 	gint len;
327 	gfloat flen;
328 	GtkWidget* parent;
329 	CssedDoc* doc;
330 
331 	parent = GTK_WIDGET(data);
332 	doc = document_get_current( window );
333 
334 	checkbutton_border_length =
335 		lookup_widget (parent,
336 			       "checkbutton_border_length");
337 	checkbutton_border_style =
338 		lookup_widget (parent,
339 			       "checkbutton_border_style");
340 	checkbutton_border_color =
341 		lookup_widget (parent,
342 			       "checkbutton_border_color");
343 
344 	blength =
345 		gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
346 					      (checkbutton_border_length));
347 	bstyle = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
348 					       (checkbutton_border_style));
349 	bcolor = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
350 					       (checkbutton_border_color));
351 
352 	if (!blength && !bstyle && !bcolor)
353 	{
354 		output_string = g_strdup("none");
355 		document_write_error_to_program_output(doc,_("border dialog: no value selected defaulting to \"none\""),WARNING_COLOR_STRING);
356 	}
357 	else
358 	{
359 		output_string = g_strdup(""); // empty but not NULL string
360 		// length
361 		if (blength)
362 		{
363 			combo_entry_border_length_selector =
364 				lookup_widget (parent,
365 					       "combo_entry_border_length_selector");
366 			strlength =
367 				gtk_editable_get_chars (GTK_EDITABLE
368 							(combo_entry_border_length_selector),
369 							-0, -1);
370 
371 			if (strcmp (strlength, CSS_STR_USE_LENGTH) == 0)
372 			{
373 				spinbutton_len =
374 					lookup_widget (parent,
375 						       "spinbutton_len");
376 
377 				combo_entry_len =
378 					lookup_widget (parent,
379 						       "combo_entry_len");
380 				strunit =
381 					gtk_editable_get_chars (GTK_EDITABLE
382 								(combo_entry_len),
383 								-0, -1);
384 
385 				if( strcmp( strunit, "em" ) == 0 ||
386 					strcmp( strunit, "in" ) == 0  ){
387 					flen = (gfloat) gtk_spin_button_get_value_as_float( GTK_SPIN_BUTTON
388 															(spinbutton_len) );
389 					strlenunit =g_strdup_printf ("%0.2f%s ", flen, strunit);
390 				}else{
391 					len = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON
392 															(spinbutton_len) );
393 					strlenunit =g_strdup_printf ("%d%s ", len, strunit);
394 				}
395 
396 				output_string = allocated_buffer_add_string(output_string, strlenunit);
397 				g_free (strlenunit);
398 				g_free (strunit);
399 			}
400 			else
401 			{
402 				output_string = allocated_buffer_add_string(output_string, strlength);
403 				output_string = allocated_buffer_add_string(output_string, " ");
404 			}
405 			g_free (strlength);
406 		}
407 		// style
408 		if (bstyle)
409 		{
410 			combo_entry_border_style =
411 				lookup_widget (parent,
412 					       "combo_entry_border_style");
413 			strstyle =
414 				gtk_editable_get_chars (GTK_EDITABLE
415 							(combo_entry_border_style),
416 							-0, -1);
417 			output_string = allocated_buffer_add_string(output_string, strstyle);
418 			output_string = allocated_buffer_add_string(output_string, " ");
419 			g_free (strstyle);
420 		}
421 		// color
422 		if (bcolor)
423 		{
424 			combo_entry_border_color =
425 				lookup_widget (parent,
426 					       "combo_entry_border_color");
427 			strcolor =
428 				gtk_editable_get_chars (GTK_EDITABLE
429 							(combo_entry_border_color),
430 							-0, -1);
431 
432 			if (strcmp (strcolor, CSS_STR_USE_COLORSEL) == 0)
433 			{
434 				g_free (strcolor);
435 				colorselection =
436 					lookup_widget (parent,
437 						       "colorselection");
438 				gtk_color_selection_get_current_color
439 					(GTK_COLOR_SELECTION (colorselection),
440 					 &gdkcolor);
441 				strcolor =
442 					gdk_color_to_rgb_triplet_string
443 					(&gdkcolor);
444 				output_string = allocated_buffer_add_string(output_string, strcolor);
445 			}
446 			else
447 			{
448 				output_string = allocated_buffer_add_string(output_string, strcolor);
449 			}
450 			g_free (strcolor);
451 		}
452 	}
453 	return output_string;
454 }
455 
456 gchar*
cssdialog_border_width_properties_get_string(CssedWindow * window,gpointer data)457 cssdialog_border_width_properties_get_string ( CssedWindow* window, gpointer data )
458 {
459 	GtkWidget *checkbutton_border_width_top;
460 	GtkWidget *combo_entry_border_width_top_units;
461 	GtkWidget *combo_entry_border_width_top_selector;
462 	GtkWidget *spinbutton_border_width_top;
463 	GtkWidget *checkbutton_border_width_right;
464 	GtkWidget *combo_entry_border_width_right_units;
465 	GtkWidget *combo_entry_border_width_right_selector;
466 	GtkWidget *spinbutton_border_width_right;
467 	GtkWidget *checkbutton_border_width_bottom;
468 	GtkWidget *combo_entry_border_width_bottom_units;
469 	GtkWidget *combo_entry_border_width_bottom_selector;
470 	GtkWidget *spinbutton_border_width_bottom;
471 	GtkWidget *checkbutton_border_width_left;
472 	GtkWidget *combo_entry_border_width_left_units;
473 	GtkWidget *combo_entry_border_width_left_selector;
474 	GtkWidget *spinbutton_border_width_left;
475 	gboolean btop;
476 	gboolean bright;
477 	gboolean bbottom;
478 	gboolean bleft;
479 	gchar *strout_top;
480 	gchar *strlength_top;
481 	gchar *strunit_top;
482 	gchar *strout_right;
483 	gchar *strlength_right;
484 	gchar *strunit_right;
485 	gchar *strout_bottom;
486 	gchar *strlength_bottom;
487 	gchar *strunit_bottom;
488 	gchar *strout_left;
489 	gchar *strlength_left;
490 	gchar *strunit_left;
491 	gint nlength;
492 	gfloat flength;
493 	gchar* output_string;
494 	GtkWidget* parent;
495 	CssedDoc* doc;
496 
497 	parent = GTK_WIDGET(data);
498 	doc = document_get_current( window );
499 
500 	checkbutton_border_width_top =
501 		lookup_widget (parent,
502 			       "checkbutton_border_width_top");
503 	checkbutton_border_width_right =
504 		lookup_widget (parent,
505 			       "checkbutton_border_width_right");
506 	checkbutton_border_width_bottom =
507 		lookup_widget (parent,
508 			       "checkbutton_border_width_bottom");
509 	checkbutton_border_width_left =
510 		lookup_widget (parent,
511 			       "checkbutton_border_width_left");
512 
513 	btop = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
514 					     (checkbutton_border_width_top));
515 	bright = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
516 					       (checkbutton_border_width_right));
517 	bbottom =
518 		gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
519 					      (checkbutton_border_width_bottom));
520 	bleft = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
521 					      (checkbutton_border_width_left));
522 
523 	if (!btop && !bright && !bbottom && !bleft)
524 	{
525 		output_string = g_strdup("none");
526 		document_write_error_to_program_output(doc,_("border width single dialog: no value selected defaulting to \"none\""),WARNING_COLOR_STRING);
527 	}
528 	else
529 	{
530 		output_string = g_strdup("");
531 		// TOP
532 		if ( btop )
533 		{
534 			combo_entry_border_width_top_selector =
535 				lookup_widget (parent,
536 					       "combo_entry_border_width_top_selector");
537 			strlength_top =
538 				gtk_editable_get_chars (GTK_EDITABLE
539 							(combo_entry_border_width_top_selector),
540 							-0, -1);
541 			if (strcmp (strlength_top, CSS_STR_USE_LENGTH) == 0)
542 			{
543 				combo_entry_border_width_top_units =
544 					lookup_widget (parent,
545 						       "combo_entry_border_width_top_units");
546 				strunit_top =
547 					gtk_editable_get_chars (GTK_EDITABLE
548 								(combo_entry_border_width_top_units),
549 								-0, -1);
550 				spinbutton_border_width_top =
551 					lookup_widget (parent,
552 						       "spinbutton_border_width_top");
553 
554 				if( strcmp( strunit_top, "em" ) == 0 ||
555 					strcmp( strunit_top, "in" ) == 0 ){
556 					flength = (gfloat)
557 						gtk_spin_button_get_value_as_float
558 						(GTK_SPIN_BUTTON
559 						 (spinbutton_border_width_top));
560 					strout_top =
561 						g_strdup_printf ("%0.2f%s", flength,
562 								 strunit_top);
563 				}else{
564 					nlength =
565 						gtk_spin_button_get_value_as_int
566 						(GTK_SPIN_BUTTON
567 						 (spinbutton_border_width_top));
568 					strout_top =
569 						g_strdup_printf ("%d%s", nlength,
570 								 strunit_top);
571 				}
572 
573 				output_string = allocated_buffer_add_string(output_string, strout_top);
574 				output_string = allocated_buffer_add_string(output_string, " ");
575 				g_free (strout_top);
576 				g_free (strunit_top);
577 			}
578 			else
579 			{
580 				output_string = allocated_buffer_add_string(output_string, strlength_top);
581 				output_string = allocated_buffer_add_string(output_string, " ");
582 			}
583 			g_free (strlength_top);
584 		}
585 		// RIGHT
586 		if (bright)
587 		{
588 			combo_entry_border_width_right_selector =
589 				lookup_widget (parent,
590 					       "combo_entry_border_width_right_selector");
591 			strlength_right =
592 				gtk_editable_get_chars (GTK_EDITABLE
593 							(combo_entry_border_width_right_selector),
594 							-0, -1);
595 			if (strcmp (strlength_right, CSS_STR_USE_LENGTH) == 0)
596 			{
597 				combo_entry_border_width_right_units =
598 					lookup_widget (parent,
599 						       "combo_entry_border_width_right_units");
600 				strunit_right =
601 					gtk_editable_get_chars (GTK_EDITABLE
602 								(combo_entry_border_width_right_units),
603 								-0, -1);
604 				spinbutton_border_width_right =
605 					lookup_widget (parent,
606 						       "spinbutton_border_width_right");
607 				nlength =
608 					gtk_spin_button_get_value_as_int
609 					(GTK_SPIN_BUTTON
610 					 (spinbutton_border_width_right));
611 				strout_right =
612 					g_strdup_printf ("%d%s", nlength,
613 							 strunit_right);
614 				output_string = allocated_buffer_add_string(output_string, strout_right);
615 				output_string = allocated_buffer_add_string(output_string, " ");
616 				g_free (strout_right);
617 				g_free (strunit_right);
618 			}
619 			else
620 			{
621 				output_string = allocated_buffer_add_string(output_string, strlength_right);
622 				output_string = allocated_buffer_add_string(output_string, " ");
623 			}
624 			g_free (strlength_right);
625 		}
626 		// BOTTOM
627 		if (bbottom)
628 		{
629 			combo_entry_border_width_bottom_selector =
630 				lookup_widget (parent,
631 					       "combo_entry_border_width_bottom_selector");
632 			strlength_bottom =
633 				gtk_editable_get_chars (GTK_EDITABLE
634 							(combo_entry_border_width_bottom_selector),
635 							-0, -1);
636 			if (strcmp (strlength_bottom, CSS_STR_USE_LENGTH) == 0)
637 			{
638 				combo_entry_border_width_bottom_units =
639 					lookup_widget (parent,
640 						       "combo_entry_border_width_bottom_units");
641 				strunit_bottom =
642 					gtk_editable_get_chars (GTK_EDITABLE
643 								(combo_entry_border_width_bottom_units),
644 								-0, -1);
645 				spinbutton_border_width_bottom =
646 					lookup_widget (parent,
647 						       "spinbutton_border_width_bottom");
648 				nlength =
649 					gtk_spin_button_get_value_as_int
650 					(GTK_SPIN_BUTTON
651 					 (spinbutton_border_width_bottom));
652 				strout_bottom =
653 					g_strdup_printf ("%d%s", nlength,
654 							 strunit_bottom);
655 				output_string = allocated_buffer_add_string(output_string, strout_bottom);
656 				output_string = allocated_buffer_add_string(output_string, " ");
657 				g_free (strout_bottom);
658 				g_free (strunit_bottom);
659 			}
660 			else
661 			{
662 				output_string = allocated_buffer_add_string(output_string, strlength_bottom);
663 				output_string = allocated_buffer_add_string(output_string, " ");
664 			}
665 			g_free (strlength_bottom);
666 		}
667 		// LEFT
668 		if (bleft)
669 		{
670 			combo_entry_border_width_left_selector =
671 				lookup_widget (parent,
672 					       "combo_entry_border_width_left_selector");
673 			strlength_left =
674 				gtk_editable_get_chars (GTK_EDITABLE
675 							(combo_entry_border_width_left_selector),
676 							-0, -1);
677 			if (strcmp (strlength_left, CSS_STR_USE_LENGTH) == 0)
678 			{
679 				combo_entry_border_width_left_units =
680 					lookup_widget (parent,
681 						       "combo_entry_border_width_left_units");
682 				strunit_left =
683 					gtk_editable_get_chars (GTK_EDITABLE
684 								(combo_entry_border_width_left_units),
685 								-0, -1);
686 				spinbutton_border_width_left =
687 					lookup_widget (parent,
688 						       "spinbutton_border_width_left");
689 				nlength =
690 					gtk_spin_button_get_value_as_int
691 					(GTK_SPIN_BUTTON
692 					 (spinbutton_border_width_left));
693 				strout_left =
694 					g_strdup_printf ("%d%s", nlength,
695 							 strunit_left);
696 				output_string = allocated_buffer_add_string(output_string, strout_left);
697 				output_string = allocated_buffer_add_string(output_string, " ");
698 				g_free (strout_left);
699 				g_free (strunit_left);
700 			}
701 			else
702 			{
703 				output_string = allocated_buffer_add_string(output_string, strlength_left);
704 				output_string = allocated_buffer_add_string(output_string, " ");
705 			}
706 			g_free (strlength_left);
707 		}
708 	}
709 
710 	return output_string;
711 }
712 gchar*
cssdialog_border_width_single_get_string(CssedWindow * window,gpointer data)713 cssdialog_border_width_single_get_string ( CssedWindow* window, gpointer data )
714 {
715 	GtkWidget *combo_entry_selector;
716 	GtkWidget *spinbutton_length;
717 	GtkWidget *combo_entry_units;
718 	gchar *strwidth;
719 	gchar *strunit;
720 	gchar *strout;
721 	gchar* output_string;
722 	gint len;
723 	GtkWidget* parent;
724 	CssedDoc* doc;
725 
726 	parent = GTK_WIDGET(data);
727 	doc = document_get_current( window );
728 
729 	combo_entry_selector =
730 		lookup_widget (parent, "combo_entry_selector");
731 
732 	strwidth =
733 		gtk_editable_get_chars (GTK_EDITABLE (combo_entry_selector), 0, -1);
734 
735 	output_string = g_strdup("");
736 
737 	if (strcmp (strwidth,CSS_STR_USE_PERCLEN) == 0)
738 	{
739 		spinbutton_length =
740 			lookup_widget (parent,
741 				       "spinbutton_length");
742 		combo_entry_units =
743 			lookup_widget (parent,
744 				       "combo_entry_units");
745 		len = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON
746 							(spinbutton_length));
747 		strunit =
748 			gtk_editable_get_chars (GTK_EDITABLE
749 						(combo_entry_units), 0, -1);
750 		strout = g_strdup_printf ("%d%s", len, strunit);
751 		output_string = allocated_buffer_add_string(output_string, strout);
752 		g_free (strout);
753 		g_free (strunit);
754 	}
755 	else
756 	{
757 		output_string = allocated_buffer_add_string(output_string, strwidth);
758 	}
759 	g_free (strwidth);
760 
761 	return output_string;
762 }
763 
764 gchar*
cssdialog_counter_increment_reset_get_string(CssedWindow * window,gpointer data)765 cssdialog_counter_increment_reset_get_string ( CssedWindow* window, gpointer data )
766 {
767 	GtkTreeModel *list_store;
768 	GtkWidget *spinbutton;
769 	GtkWidget *entry;
770 	GtkWidget *treeview;
771 	GtkTreeIter iter;
772 	gboolean valid;
773 	gchar *strout;
774 	gchar *str_data;
775 	gint int_data;
776 	gchar* output_string;
777 	GtkWidget* parent;
778 	CssedDoc* doc;
779 
780 	parent = GTK_WIDGET(data);
781 	doc = document_get_current( window );
782 
783 	spinbutton =
784 		lookup_widget (parent,
785 			       "spinbutton_counter_increment_reset_step");
786 	entry = lookup_widget (parent,
787 			       "entry_counter_increment_reset_identifyer");
788 
789 	treeview = lookup_widget (parent, "treeview");
790 	list_store = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
791 	valid = gtk_tree_model_get_iter_first (list_store, &iter);
792 
793 	if (valid)
794 	{	// there are values in the store
795 		// parse the list
796 		output_string = g_strdup("");
797 		while (valid)
798 		{
799 			gtk_tree_model_get (list_store, &iter,
800 					    0, &str_data, 1, &int_data, -1);
801 
802 			strout = g_strdup_printf(" %s %d",str_data,int_data);
803 			output_string = allocated_buffer_add_string(output_string, strout);
804 
805 			g_free (strout);
806 			g_free (str_data);
807 			valid = gtk_tree_model_iter_next (list_store, &iter);
808 		}
809 	}
810 	else
811 	{
812 		output_string = g_strdup("");
813 		spinbutton =
814 			lookup_widget (parent,
815 				       "spinbutton_counter_increment_reset_step");
816 		entry = lookup_widget (parent,
817 				       "entry_counter_increment_reset_identifyer");
818 
819 		str_data =
820 			gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
821 		int_data =
822 			gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON
823 							  (spinbutton));
824 
825 		strout = g_strdup_printf("%s %d ",str_data,int_data);
826 		output_string = allocated_buffer_add_string(output_string, strout);
827 
828 		g_free (strout);
829 		g_free (str_data);
830 	}
831 	return output_string;
832 }
833 
834 gchar*
cssdialog_string_properties_get_string(CssedWindow * window,gpointer data)835 cssdialog_string_properties_get_string( CssedWindow* window, gpointer data )
836 {
837 	GtkWidget *entry_string_property_dialog;
838 	gchar *string;
839 	gchar* output_string;
840 	GtkWidget* parent;
841 	CssedDoc* doc;
842 
843 	parent = GTK_WIDGET(data);
844 	doc = document_get_current( window );
845 
846 	entry_string_property_dialog =
847 		lookup_widget (parent, "entry_string_property_dialog");
848 
849 	string = gtk_editable_get_chars (GTK_EDITABLE
850 					 (entry_string_property_dialog), 0,
851 					 -1);
852 	if (strlen (string) > 0)
853 	{
854 		output_string = g_strdup_printf("\"%s\"",string);
855 		g_free(string);
856 		return output_string;
857 	}else{
858 		return NULL;
859 	}
860 }
861 
862 gchar*
cssdialog_uri_value_get_string(CssedWindow * window,gpointer data)863 cssdialog_uri_value_get_string ( CssedWindow* window, gpointer data )
864 {
865 	GtkWidget *entry_uri_value_dialog;
866 	gchar *string;
867 	gchar* output_string;
868 	GtkWidget* parent;
869 	CssedDoc* doc;
870 
871 	parent = GTK_WIDGET(data);
872 	doc = document_get_current( window );
873 
874 	entry_uri_value_dialog =
875 	lookup_widget (parent, "entry_uri_value_dialog");
876 
877 	string = gtk_editable_get_chars (GTK_EDITABLE
878 					 (entry_uri_value_dialog), 0, -1);
879 
880 	if (strlen (string) > 0)
881 	{
882 		output_string = g_strdup_printf("url(\"%s\")",string);
883 		g_free(string);
884 		return output_string;
885 	}else{
886 		return NULL;
887 	}
888 }
889 
890 gchar*
cssdialog_attr_value_get_string(CssedWindow * window,gpointer data)891 cssdialog_attr_value_get_string ( CssedWindow* window, gpointer data )
892 {
893 	GtkWidget *entry_attribute_value_dialog;
894 	gchar *string;
895 	gchar* output_string;
896 	GtkWidget* parent;
897 	CssedDoc* doc;
898 
899 	parent = GTK_WIDGET(data);
900 	doc = document_get_current( window );
901 
902 	entry_attribute_value_dialog =
903 		lookup_widget (parent,
904 			       "entry_attribute_value_dialog");
905 
906 	string = gtk_editable_get_chars (GTK_EDITABLE
907 					 (entry_attribute_value_dialog), 0,
908 					 -1);
909 
910 	if (strlen (string) > 0)
911 	{
912 		output_string = g_strdup_printf("attr(\"%s\")",string);
913 		g_free(string);
914 		return output_string;
915 	}else{
916 		return NULL;
917 	}
918 }
919 
920 gchar*
cssdialog_counter_property_get_string(CssedWindow * window,gpointer data)921 cssdialog_counter_property_get_string ( CssedWindow* window, gpointer data )
922 {
923 	GtkWidget *entry_counter_identifier;
924 	GtkWidget *checkbutton_after;
925 	GtkWidget *entry_string_after;
926 	GtkWidget *checkbutton_before;
927 	GtkWidget *entry_string_before;
928 	GtkWidget *checkbutton_list_style_tyle;
929 	GtkWidget *combo_entry_list_style_type;
930 	gchar *stridentifier;
931 	gchar *strafter;
932 	gchar *strbefore;
933 	gchar *strstyle;
934 	gboolean bafter;
935 	gboolean bbefore;
936 	gboolean bstyle;
937 	gchar* output_string;
938 	GtkWidget* parent;
939 	CssedDoc* doc;
940 
941 	parent = GTK_WIDGET(data);
942 	doc = document_get_current( window );
943 
944 	entry_counter_identifier =
945 		lookup_widget (parent,
946 			       "entry_counter_identifier");
947 	stridentifier =
948 		gtk_editable_get_chars (GTK_EDITABLE
949 					(entry_counter_identifier), 0, -1);
950 
951 	if(strlen(stridentifier) > 0){
952 		output_string = g_strdup("");
953 
954 		checkbutton_after =
955 			lookup_widget (parent,
956 				       "checkbutton_after");
957 		checkbutton_before =
958 			lookup_widget (parent,
959 				       "checkbutton_before");
960 		checkbutton_list_style_tyle =
961 			lookup_widget (parent,
962 				       "checkbutton_list_style_tyle");
963 
964 		bafter = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
965 						       (checkbutton_after));
966 		bbefore =
967 			gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
968 						      (checkbutton_before));
969 		bstyle = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
970 						       (checkbutton_list_style_tyle));
971 
972 		if (bafter)
973 		{
974 			entry_string_after =
975 				lookup_widget (parent,
976 					       "entry_string_after");
977 			strafter =
978 				gtk_editable_get_chars (GTK_EDITABLE
979 							(entry_string_after),
980 							0, -1);
981 			output_string = allocated_buffer_add_string(output_string, " \"");
982 			output_string = allocated_buffer_add_string(output_string, strafter);
983 			output_string = allocated_buffer_add_string(output_string, "\" ");
984 			g_free (strafter);
985 		}
986 
987 		// add the identifier
988 		output_string = allocated_buffer_add_string(output_string, " counter( ");
989 		output_string = allocated_buffer_add_string(output_string, stridentifier);
990 
991 		if (bstyle)
992 		{
993 			combo_entry_list_style_type =
994 				lookup_widget (parent,
995 					       "combo_entry_list_style_type");
996 			strstyle =
997 				gtk_editable_get_chars (GTK_EDITABLE
998 							(combo_entry_list_style_type),
999 							0, -1);
1000 			output_string = allocated_buffer_add_string(output_string, ", ");
1001 			output_string = allocated_buffer_add_string(output_string, strstyle);
1002 			g_free (strstyle);
1003 		}
1004 
1005 		output_string = allocated_buffer_add_string(output_string, " )");
1006 
1007 		if (bbefore)
1008 		{
1009 			entry_string_before =
1010 				lookup_widget (parent,
1011 					       "entry_string_before");
1012 			strbefore =
1013 				gtk_editable_get_chars (GTK_EDITABLE
1014 							(entry_string_before),
1015 							0, -1);
1016 			output_string = allocated_buffer_add_string(output_string, " \"");
1017 			output_string = allocated_buffer_add_string(output_string, strbefore);
1018 			output_string = allocated_buffer_add_string(output_string, "\" ");
1019 			g_free (strbefore);
1020 		}
1021 
1022 		g_free(stridentifier);
1023 		return output_string;
1024 	}else{
1025 		return NULL;
1026 	}
1027 }
1028 
1029 gchar*
cssdialog_font_property_get_string(CssedWindow * window,gpointer data)1030 cssdialog_font_property_get_string ( CssedWindow* window, gpointer data )
1031 {
1032 	GtkWidget *radiobutton_system_fonts;
1033 	GtkWidget *combo_entry_system_fonts;
1034 	GtkWidget *checkbutton_size;
1035 	GtkWidget *combo_entry_font_size_selector;
1036 	GtkWidget *spinbutton_font_size;
1037 	GtkWidget *combo_entry_font_size_units;
1038 	GtkWidget *checkbutton_line_height;
1039 	GtkWidget *spinbutton_line_height;
1040 	GtkWidget *combo_entry_line_height_selector_and_units;
1041 	GtkWidget *checkbutton_style;
1042 	GtkWidget *combo_entry_style;
1043 	GtkWidget *checkbutton_variant;
1044 	GtkWidget *combo_entry_variant;
1045 	GtkWidget *checkbutton_weight;
1046 	GtkWidget *combo_entry_weight;
1047 	GtkWidget *checkbutton_font_family;
1048 	GtkWidget *combo_entry_font_family;
1049 	GtkWidget *checkbutton_generic_family;
1050 	GtkWidget *combo_entry_generic_family;
1051 	GtkWidget *checkbutton_use_font_set;
1052 	GtkWidget *treeview;
1053 	GtkTreeModel *list_store;
1054 	GtkTreeIter iter;
1055 	gboolean valid;
1056 	gboolean bsystemfonts;
1057 	gboolean bsize;
1058 	gboolean bheight;
1059 	gboolean bstyle;
1060 	gboolean bvariant;
1061 	gboolean bweight;
1062 	gboolean bfontfamily;
1063 	gboolean bgenericfamily;
1064 	gboolean bfontset;
1065 	gchar* strfullsize;
1066 	gchar* strsize;
1067 	gchar* strsize_units;
1068 	gint nsize;
1069 	gfloat fsize;
1070 	gchar* strlheight;
1071 	gchar* strfullheight;
1072 	gint nheight;
1073 	gfloat fheight;
1074 	gchar* strstyle;
1075 	gchar* strvariant;
1076 	gchar* strweight;
1077 	gchar* str_set_font;
1078 	gchar* str_set_generic;
1079 	gchar* str_font_family;
1080 	gchar* str_gen_family;
1081 	gchar* output_string;
1082 	GtkWidget* parent;
1083 	CssedDoc* doc;
1084 
1085 	parent = GTK_WIDGET(data);
1086 	doc = document_get_current( window );
1087 
1088 	radiobutton_system_fonts =
1089 		lookup_widget (parent,
1090 			       "radiobutton_system_fonts");
1091 
1092 	bsystemfonts = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
1093 				      (radiobutton_system_fonts));
1094 
1095 	if( bsystemfonts ){
1096 		combo_entry_system_fonts = lookup_widget (parent,
1097 									"combo_entry_system_fonts");
1098 		output_string = gtk_editable_get_chars(
1099 							GTK_EDITABLE(combo_entry_system_fonts),
1100 							0,
1101 							-1);
1102 		return output_string;
1103 	}else {
1104 		checkbutton_size =
1105 			lookup_widget (parent, "checkbutton_size");
1106 		checkbutton_line_height =
1107 			lookup_widget (parent, "checkbutton_line_height");
1108 		checkbutton_style =
1109 			lookup_widget (parent, "checkbutton_style");
1110 		checkbutton_variant =
1111 			lookup_widget (parent, "checkbutton_variant");
1112 		checkbutton_weight =
1113 			lookup_widget (parent, "checkbutton_weight");
1114 		checkbutton_font_family =
1115 			lookup_widget (parent,"checkbutton_font_family");
1116 		checkbutton_generic_family =
1117 			lookup_widget (parent, "checkbutton_generic_family");
1118 		checkbutton_use_font_set =
1119 			lookup_widget (parent, "checkbutton_use_font_set");
1120 
1121 		bsize = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
1122 				      (checkbutton_size));
1123 		bheight = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
1124 				      (checkbutton_line_height));
1125 		bstyle = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
1126 				      (checkbutton_style));
1127 		bvariant = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
1128 				      (checkbutton_variant));
1129 		bweight = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
1130 				      (checkbutton_weight));
1131 		bfontfamily = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
1132 				      (checkbutton_font_family));
1133 		bgenericfamily = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
1134 				      (checkbutton_generic_family));
1135 		bfontset = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
1136 				      (checkbutton_use_font_set));
1137 
1138 		if( bsize || bheight || bstyle || bvariant || bweight || bfontfamily ||
1139 			bgenericfamily || bfontset)
1140 		{
1141 			output_string = g_strdup("");
1142 			// font size
1143 			if( bsize ){
1144 				combo_entry_font_size_selector =
1145 				lookup_widget (parent,
1146 							   "combo_entry_font_size_selector");
1147 
1148 				strsize = gtk_editable_get_chars(
1149 							GTK_EDITABLE(combo_entry_font_size_selector),
1150 							0,-1);
1151 				if( strcmp(strsize,CSS_STR_USE_PERCLEN) == 0){
1152 					spinbutton_font_size =
1153 						lookup_widget (parent, "spinbutton_font_size");
1154 					combo_entry_font_size_units =
1155 						lookup_widget (parent,
1156 								"combo_entry_font_size_units");
1157 					strsize_units = gtk_editable_get_chars(
1158 								GTK_EDITABLE(combo_entry_font_size_units),0,-1);
1159 
1160 					if( strcmp(strsize_units, "em") == 0  ||
1161 						strcmp(strsize_units, "em") == 0  ){
1162 						fsize = (gfloat) gtk_spin_button_get_value_as_float(
1163 										GTK_SPIN_BUTTON(spinbutton_font_size));
1164 						strfullsize = g_strdup_printf("%0.2f%s ", fsize,
1165 										strsize_units);
1166 					}else{
1167 						nsize = gtk_spin_button_get_value_as_int(
1168 										GTK_SPIN_BUTTON(spinbutton_font_size));
1169 						strfullsize = g_strdup_printf("%d%s ", nsize,
1170 										strsize_units);
1171 					}
1172 
1173 					output_string = allocated_buffer_add_string(output_string, strfullsize);
1174 
1175 					g_free( strfullsize );
1176 					g_free(	strsize_units );
1177 
1178 				}else{
1179 					output_string = allocated_buffer_add_string(output_string, strsize);
1180 				}
1181 				output_string = allocated_buffer_add_string(output_string, " ");
1182 				g_free(strsize);
1183 			}
1184 
1185 			// line height "use number"
1186 			if( bheight ){
1187 				combo_entry_line_height_selector_and_units =
1188 					lookup_widget (parent,
1189 									"combo_entry_line_height_selector_and_units");
1190 				strlheight = gtk_editable_get_chars(
1191 					GTK_EDITABLE(combo_entry_line_height_selector_and_units),0,-1);
1192 
1193 				spinbutton_line_height = lookup_widget (parent,
1194 										"spinbutton_line_height");
1195 				if( strcmp(strlheight, CSS_STR_USE_NUM) == 0){
1196 					nheight = gtk_spin_button_get_value_as_int(
1197 								GTK_SPIN_BUTTON(spinbutton_line_height));
1198 					strfullheight = g_strdup_printf("%d", nheight);
1199 
1200 					output_string = allocated_buffer_add_string(output_string, strfullheight);
1201 					g_free(strfullheight);
1202 				}else{
1203 					if( strcmp(strlheight, "em") == 0  ||
1204 						strcmp(strlheight, "in") == 0  ){
1205 						fheight = (gfloat) gtk_spin_button_get_value_as_float(
1206 										GTK_SPIN_BUTTON(spinbutton_line_height));
1207 						strfullheight = g_strdup_printf("%0.2f%s ", fheight,
1208 														strlheight);
1209 					}else{
1210 						nheight = gtk_spin_button_get_value_as_int(
1211 									GTK_SPIN_BUTTON(spinbutton_line_height));
1212 						strfullheight = g_strdup_printf("%d%s", nheight,
1213 														strlheight);
1214 					}
1215 
1216 					output_string = allocated_buffer_add_string(output_string, strfullheight);
1217 				}
1218 
1219 				output_string = allocated_buffer_add_string(output_string, " ");
1220 				g_free(strlheight);
1221 			}
1222 
1223 			// style
1224 			if( bstyle ){
1225 				combo_entry_style =
1226 					lookup_widget (parent, "combo_entry_style");
1227 				strstyle = gtk_editable_get_chars(
1228 					GTK_EDITABLE(combo_entry_style),0,-1);
1229 				output_string = allocated_buffer_add_string(output_string, strstyle);
1230 				output_string = allocated_buffer_add_string(output_string, " ");
1231 				g_free(strstyle);
1232 			}
1233 			// variant
1234 			if( bvariant ){
1235 				combo_entry_variant =
1236 					lookup_widget (parent, "combo_entry_variant");
1237 				strvariant = gtk_editable_get_chars(
1238 					GTK_EDITABLE(combo_entry_variant),0,-1);
1239 				output_string = allocated_buffer_add_string(output_string, strvariant);
1240 				output_string = allocated_buffer_add_string(output_string, " ");
1241 				g_free(strvariant);
1242 			}
1243 			// weight
1244 			if( bweight ){
1245 				combo_entry_weight =
1246 					lookup_widget (parent, "combo_entry_weight");
1247 				strweight = gtk_editable_get_chars(
1248 					GTK_EDITABLE(combo_entry_weight),0,-1);
1249 				output_string = allocated_buffer_add_string(output_string, strweight);
1250 				output_string = allocated_buffer_add_string(output_string, " ");
1251 				g_free(strweight);
1252 			}
1253 			// font set
1254 			if ( bfontset ){
1255 				treeview = lookup_widget (parent, "treeview");
1256 				list_store = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
1257 				valid = gtk_tree_model_get_iter_first (list_store, &iter);
1258 
1259 				if (valid)
1260 				{	// there are values in the store
1261 					// parser the list
1262 					while (valid)
1263 					{
1264 						gtk_tree_model_get (list_store, &iter,
1265 									0, &str_set_font, 1, &str_set_generic, -1);
1266 
1267 						if( strlen(str_set_font) > 0){
1268 							output_string = allocated_buffer_add_string(output_string, "\"");
1269 							output_string = allocated_buffer_add_string(output_string, str_set_font);
1270 							output_string = allocated_buffer_add_string(output_string, "\"");
1271 						}
1272 
1273 						if( ( strlen(str_set_generic) > 0 ) &&
1274 							( strlen(str_set_font)    > 0 )  ){
1275 							output_string = allocated_buffer_add_string(output_string, " , ");
1276 						}
1277 
1278 						if( strlen(str_set_generic) > 0){
1279 							output_string = allocated_buffer_add_string(output_string, str_set_generic);
1280 						}
1281 
1282 						g_free (str_set_font);
1283 						g_free (str_set_generic);
1284 						valid = gtk_tree_model_iter_next (list_store, &iter);
1285 						if( valid ){
1286 							output_string = allocated_buffer_add_string(output_string, " , ");
1287 						}else{
1288 							output_string = allocated_buffer_add_string(output_string, " ");
1289 						}
1290 					}
1291 				}
1292 			}else{
1293 				// font family
1294 				if( bfontfamily ){
1295 					combo_entry_font_family =
1296 						lookup_widget (parent, "combo_entry_font_family");
1297 					str_font_family = gtk_editable_get_chars(
1298 							GTK_EDITABLE(combo_entry_font_family),0,-1);
1299 					output_string = allocated_buffer_add_string(output_string, "\"");
1300 					output_string = allocated_buffer_add_string(output_string, str_font_family);
1301 					output_string = allocated_buffer_add_string(output_string, "\"");
1302 					g_free(str_font_family);
1303 				}
1304 
1305 				if( bgenericfamily ){
1306 					if (bfontfamily) {
1307 						output_string = allocated_buffer_add_string(output_string, " , ");
1308 					}
1309 					combo_entry_generic_family =
1310 						lookup_widget (parent, "combo_entry_generic_family");
1311 					str_gen_family = gtk_editable_get_chars(
1312 							GTK_EDITABLE(combo_entry_generic_family),0,-1);
1313 					output_string = allocated_buffer_add_string(output_string, str_gen_family);
1314 					g_free(str_gen_family);
1315 				}
1316 			}
1317 		}else{
1318 			return NULL;
1319 		}
1320 	}
1321 	return output_string;
1322 }
1323 
1324 
1325 gchar*
cssdialog_font_family_get_string(CssedWindow * window,gpointer data)1326 cssdialog_font_family_get_string ( CssedWindow* window, gpointer data )
1327 {
1328 	GtkWidget *radiobutton_system_fonts;
1329 	GtkWidget *combo_entry_system_fonts;
1330 	GtkWidget *checkbutton_font_family;
1331 	GtkWidget *combo_entry_font_family;
1332 	GtkWidget *checkbutton_generic_family;
1333 	GtkWidget *combo_entry_generic_family;
1334 	GtkWidget *checkbutton_font_set;
1335 	GtkWidget *treeview;
1336 	GtkTreeModel *list_store;
1337 	GtkTreeIter iter;
1338 	gboolean valid;
1339 	gboolean bsystemfonts;
1340 	gboolean bfontfamily;
1341 	gboolean bgenericfamily;
1342 	gboolean bfontset;
1343 	gchar* str_set_font;
1344 	gchar* str_set_generic;
1345 	gchar* str_font_family;
1346 	gchar* str_gen_family;
1347 	gchar* output_string;
1348 	GtkWidget* parent;
1349 	CssedDoc* doc;
1350 
1351 	parent = GTK_WIDGET(data);
1352 	doc = document_get_current( window );
1353 
1354 	radiobutton_system_fonts = lookup_widget(parent,"radiobutton_system_fonts");
1355 	checkbutton_font_family = lookup_widget(parent,"checkbutton_font_family");
1356 	checkbutton_generic_family = lookup_widget(parent,"checkbutton_generic_family");
1357 	checkbutton_font_set = lookup_widget(parent,"checkbutton_font_set");
1358 
1359 	bsystemfonts = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton_system_fonts));
1360 	bfontfamily = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_font_family));
1361 	bgenericfamily = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_generic_family));
1362 	bfontset = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_font_set));
1363 
1364 	if( bsystemfonts ){
1365 		combo_entry_system_fonts = lookup_widget(parent,"combo_entry_system_fonts");
1366 		output_string = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_system_fonts),0,-1);
1367 		return output_string;
1368 	}else{
1369 		if( bfontset ){
1370 			treeview = lookup_widget (parent, "treeview");
1371 			list_store = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
1372 			valid = gtk_tree_model_get_iter_first (list_store, &iter);
1373 
1374 			if (valid)
1375 			{	// there are values in the store
1376 				// parser the list
1377 				output_string = g_strdup("");
1378 				while (valid)
1379 				{
1380 					gtk_tree_model_get (list_store, &iter,
1381 								0, &str_set_font, 1, &str_set_generic, -1);
1382 
1383 					if( strlen(str_set_font) > 0){
1384 						output_string = allocated_buffer_add_string(output_string, "\"");
1385 						output_string = allocated_buffer_add_string(output_string, str_set_font);
1386 						output_string = allocated_buffer_add_string(output_string, "\"");
1387 					}
1388 
1389 					if( ( strlen(str_set_generic) > 0 ) &&
1390 						( strlen(str_set_font)    > 0 )  ){
1391 						output_string = allocated_buffer_add_string(output_string, " , ");
1392 					}
1393 
1394 					if( strlen(str_set_generic) > 0){
1395 						output_string = allocated_buffer_add_string(output_string, str_set_generic);
1396 					}
1397 
1398 					g_free (str_set_font);
1399 					g_free (str_set_generic);
1400 					valid = gtk_tree_model_iter_next (list_store, &iter);
1401 					if( valid ){
1402 						output_string = allocated_buffer_add_string(output_string, " , ");
1403 					}else{
1404 						output_string = allocated_buffer_add_string(output_string, " ");
1405 					}
1406 				}
1407 				return output_string;
1408 			}else { // not valid, nothing in the list
1409 				return NULL;
1410 			}
1411 		}else {
1412 			if( bfontfamily || bgenericfamily){
1413 				output_string = g_strdup("");
1414 
1415 				combo_entry_font_family = lookup_widget(parent,"combo_entry_font_family");
1416 				combo_entry_generic_family = lookup_widget(parent,"combo_entry_generic_family");
1417 				str_font_family = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_font_family),0,-1);
1418 				str_gen_family = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_generic_family),0,-1);
1419 
1420 				if( bfontfamily ){
1421 					output_string = allocated_buffer_add_string(output_string, "\"");
1422 					output_string = allocated_buffer_add_string(output_string, str_font_family);
1423 					output_string = allocated_buffer_add_string(output_string, "\"");
1424 				}
1425 				if( bfontfamily && bgenericfamily){
1426 					output_string = allocated_buffer_add_string(output_string, " , ");
1427 				}
1428 				if( bgenericfamily ){
1429 					output_string = allocated_buffer_add_string(output_string, str_gen_family);
1430 				}
1431 				g_free(str_font_family);
1432 				g_free(str_gen_family);
1433 
1434 				return output_string;
1435 			}else{
1436 				return NULL;
1437 			}
1438 		}
1439 	}
1440 }
1441 
1442 gchar*
cssdialog_font_size_get_string(CssedWindow * window,gpointer data)1443 cssdialog_font_size_get_string( CssedWindow* window, gpointer data )
1444 {
1445 	GtkWidget *combo_entry_font_size;
1446 	GtkWidget *spinbutton_font_size;
1447 	GtkWidget *combo_entry_font_size_units;
1448 	gchar* strsize;
1449 	gchar* strunit;
1450 	gint nsize;
1451 	gfloat fsize;
1452 	gchar* output_string;
1453 	GtkWidget* parent;
1454 	CssedDoc* doc;
1455 
1456 	parent = GTK_WIDGET(data);
1457 	doc = document_get_current( window );
1458 
1459 	combo_entry_font_size = lookup_widget(parent,"combo_entry_font_size");
1460 	strsize = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_font_size),0,-1);
1461 
1462 	if( strcmp(CSS_STR_USE_PERCLEN,strsize) == 0 ){
1463 		output_string = g_strdup("");
1464 		spinbutton_font_size = lookup_widget(parent,"spinbutton_font_size");
1465 		combo_entry_font_size_units = lookup_widget(parent,"combo_entry_font_size_units");
1466 		strunit = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_font_size_units),0,-1);
1467 
1468 		if( strcmp(strunit, "em") == 0  ||
1469 			strcmp(strunit, "in") == 0  ){
1470 			fsize = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_font_size));
1471 			output_string = g_strdup_printf("%0.2f%s",fsize,strunit);
1472 		}else{
1473 			nsize = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_font_size));
1474 			output_string = g_strdup_printf("%d%s",nsize,strunit);
1475 		}
1476 
1477 		g_free(strunit);
1478 		g_free(strsize);
1479 		return output_string;
1480 	}else{
1481 		return strsize;
1482 	}
1483 }
1484 gchar*
cssdialog_frecuenzy_property_get_string(CssedWindow * window,gpointer data)1485 cssdialog_frecuenzy_property_get_string( CssedWindow* window, gpointer data )
1486 {
1487 	GtkWidget *spinbutton_frecuency;
1488 	GtkWidget *combo_entry_frecuency;
1489 	gint nfreq;
1490 	gchar* output_string;
1491 	gchar* unit;
1492 	GtkWidget* parent;
1493 	CssedDoc* doc;
1494 
1495 	parent = GTK_WIDGET(data);
1496 	doc = document_get_current( window );
1497 
1498 	spinbutton_frecuency = lookup_widget(parent,"spinbutton_frecuency");
1499 	combo_entry_frecuency = lookup_widget(parent,"combo_entry_frecuency");
1500 
1501 	unit = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_frecuency),0,-1);
1502 	nfreq = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON
1503 				(spinbutton_frecuency));
1504 	output_string = g_strdup_printf("%d%s",nfreq,unit);
1505 
1506 	g_free(unit);
1507 	return output_string;
1508 }
1509 
1510 gchar*
cssdialog_identifier_value_get_string(CssedWindow * window,gpointer data)1511 cssdialog_identifier_value_get_string( CssedWindow* window, gpointer data )
1512 {
1513 	GtkWidget *entry_identifier;
1514 	gchar* output_string;
1515 	GtkWidget* parent;
1516 	CssedDoc* doc;
1517 
1518 	parent = GTK_WIDGET(data);
1519 	doc = document_get_current( window );
1520 
1521 	entry_identifier = lookup_widget(parent,"entry_identifier");
1522 	output_string = gtk_editable_get_chars(GTK_EDITABLE(entry_identifier),0,-1);
1523 
1524 	if( strlen(output_string) > 0){
1525 		return output_string;
1526 	}else{
1527 		g_free( output_string );
1528 		return NULL;
1529 	}
1530 }
1531 
1532 gchar*
cssdialog_integer_value_get_string(CssedWindow * window,gpointer data)1533 cssdialog_integer_value_get_string( CssedWindow* window, gpointer data )
1534 {
1535 	GtkWidget *spinbutton_integer;
1536 	gchar* output_string;
1537 	gint ninteger;
1538 	GtkWidget* parent;
1539 	CssedDoc* doc;
1540 
1541 	parent = GTK_WIDGET(data);
1542 	doc = document_get_current( window );
1543 
1544 	spinbutton_integer = lookup_widget(parent,"spinbutton_integer");
1545 	ninteger = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_integer));
1546 
1547 	output_string = g_strdup_printf(" %d", ninteger );
1548 
1549 	return output_string;
1550 }
1551 
1552 gchar*
cssdialog_length_value_get_string(CssedWindow * window,gpointer data)1553 cssdialog_length_value_get_string ( CssedWindow* window, gpointer data )
1554 {
1555 	GtkWidget *spinbutton_length;
1556 	GtkWidget *combo_entry_length;
1557 	gchar* strunit;
1558 	gint nlength;
1559 	gfloat flength;
1560 	gchar* output_string;
1561 	GtkWidget* parent;
1562 	CssedDoc* doc;
1563 
1564 	parent = GTK_WIDGET(data);
1565 	doc = document_get_current( window );
1566 
1567 	spinbutton_length = lookup_widget(parent,"spinbutton_length");
1568 	combo_entry_length = lookup_widget(parent,"combo_entry_length");
1569 	strunit = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_length),0,-1);
1570 
1571 	if( strcmp(strunit, "em") == 0  ||
1572 		strcmp(strunit, "in") == 0  ){
1573 		flength = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_length));
1574 		output_string = g_strdup_printf("%0.2f%s",flength,strunit);
1575 	}else{
1576 		nlength = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_length));
1577 		output_string = g_strdup_printf(" %d%s", nlength,strunit);
1578 	}
1579 
1580 	g_free (strunit);
1581 	return 	output_string;
1582 }
1583 
1584 gchar*
cssdialog_list_style_get_string(CssedWindow * window,gpointer data)1585 cssdialog_list_style_get_string ( CssedWindow* window, gpointer data )
1586 {
1587 	GtkWidget *checkbutton_type;
1588 	GtkWidget *combo_entry_type;
1589 	GtkWidget *checkbutton_position;
1590 	GtkWidget *combo_entry_position;
1591 	GtkWidget *checkbutton_image;
1592 	GtkWidget *entry_image;
1593 	gboolean bpos;
1594 	gboolean btype;
1595 	gboolean bimage;
1596 	gchar* strytype;
1597 	gchar* strpos;
1598 	gchar* strimage;
1599 	gchar* output_string;
1600 	GtkWidget* parent;
1601 	CssedDoc* doc;
1602 
1603 	parent = GTK_WIDGET(data);
1604 	doc = document_get_current( window );
1605 
1606 	checkbutton_type = lookup_widget(parent,"checkbutton_type");
1607 	checkbutton_position = lookup_widget(parent,"checkbutton_position");
1608 	checkbutton_image = lookup_widget(parent,"checkbutton_image");
1609 
1610 	btype = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_type));
1611 	bpos = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_position));
1612 	bimage = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_image));
1613 
1614 	if( btype || bpos || bimage ){
1615 		output_string = g_strdup("");
1616 		if( btype || bpos ){
1617 			if( btype ){
1618 				combo_entry_type = lookup_widget(parent,"combo_entry_type");
1619 				strytype = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_type),
1620 							0,-1);
1621 				output_string = allocated_buffer_add_string(output_string, strytype);
1622 				g_free (strytype);
1623 			}
1624 
1625 			if( bpos ){
1626 				combo_entry_position = lookup_widget(parent,"combo_entry_position");
1627 				strpos = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_position),
1628 							0,-1);
1629 				if( btype ) output_string = allocated_buffer_add_string(output_string, " ");
1630 				output_string = allocated_buffer_add_string(output_string, strpos);
1631 				g_free (strpos);
1632 			}
1633 		}
1634 		if( bimage ){
1635 			entry_image = lookup_widget(parent,"entry_image");
1636 			strimage = gtk_editable_get_chars(GTK_EDITABLE(entry_image),
1637 							0,-1);
1638 			if( strlen(strimage) > 0) {
1639 					output_string = allocated_buffer_add_string(output_string, " url(\"");
1640 					output_string = allocated_buffer_add_string(output_string, strimage);
1641 					output_string = allocated_buffer_add_string(output_string, "\")");
1642 			}else{
1643 				document_write_error_to_program_output(
1644 							doc,
1645 							_("list style dialog: image is selected but empty, ignoring ..."),
1646 							WARNING_COLOR_STRING);
1647 			}
1648 			g_free (strimage);
1649 		}
1650 		return output_string;
1651 	}else{
1652 		return NULL;
1653 	}
1654 }
1655 gchar*
cssdialog_margin_property_get_string(CssedWindow * window,gpointer data)1656 cssdialog_margin_property_get_string ( CssedWindow* window, gpointer data )
1657 {
1658 	GtkWidget *checkbutton_top;
1659 	GtkWidget *spinbutton_top;
1660 	GtkWidget *combo_entry_top;
1661 	GtkWidget *checkbutton_right;
1662 	GtkWidget *spinbutton_right;
1663 	GtkWidget *combo_entry_right;
1664 	GtkWidget *checkbutton_bottom;
1665 	GtkWidget *spinbutton_bottom;
1666 	GtkWidget *combo_entry_bottom;
1667 	GtkWidget *checkbutton_left;
1668 	GtkWidget *spinbutton_left;
1669 	GtkWidget *combo_entry_left;
1670 	gboolean b_top;
1671 	gboolean b_right;
1672 	gboolean b_bottom;
1673 	gboolean b_left;
1674 	gchar* strtop;
1675 	gchar* strtop_unit;
1676 	gint ntop;
1677 	gfloat ftop;
1678 	gchar* strright;
1679 	gchar* strright_unit;
1680 	gint nright;
1681 	gfloat fright;
1682 	gchar* strbottom;
1683 	gchar* strbottom_unit = NULL;
1684 	gint nbottom;
1685 	gfloat fbottom;
1686 	gchar* strleft;
1687 	gchar* strleft_unit;
1688 	gint nleft;
1689 	gfloat fleft;
1690 	gint count;
1691 	gchar* output_string;
1692 	GtkWidget* parent;
1693 	CssedDoc* doc;
1694 
1695 	parent = GTK_WIDGET(data);
1696 	doc = document_get_current( window );
1697 
1698 	checkbutton_top = lookup_widget(parent,"checkbutton_top");
1699 	checkbutton_right = lookup_widget(parent,"checkbutton_right");
1700 	checkbutton_bottom = lookup_widget(parent,"checkbutton_bottom");
1701 	checkbutton_left = lookup_widget(parent,"checkbutton_left");
1702 
1703 	b_top = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_top));
1704 	b_right = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_right));
1705 	b_bottom = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_bottom));
1706 	b_left = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_left));
1707 
1708 	if( !b_top && !b_right && !b_bottom && !b_left ){
1709 		return NULL;
1710 	}else{
1711 		count = 0;
1712 		output_string = g_strdup("");
1713 		if( b_top ){
1714 			count++;
1715 			spinbutton_top = lookup_widget(parent,"spinbutton_top");
1716 			combo_entry_top = lookup_widget(parent,"combo_entry_top");
1717 			strtop_unit = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_top),0,-1);
1718 
1719 			if( strcmp(strtop_unit, "em") == 0 ||
1720 				strcmp(strtop_unit, "in") == 0 )
1721 			{
1722 				ftop = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_top));
1723 				strtop = g_strdup_printf("%0.2f%s ", ftop, strtop_unit);
1724 			}else{
1725 				ntop = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_top));
1726 				strtop = g_strdup_printf("%d%s ", ntop, strtop_unit);
1727 			}
1728 
1729 			output_string = allocated_buffer_add_string(output_string,  strtop);
1730 			g_free(strtop);
1731 			g_free(strtop_unit);
1732 		}
1733 
1734 		if( b_right ){
1735 			count++;
1736 			spinbutton_right = lookup_widget(parent,"spinbutton_right");
1737 			combo_entry_right = lookup_widget(parent,"combo_entry_right");
1738 			strright_unit = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_right),0,-1);
1739 
1740 			if( strcmp(strright_unit, "em") == 0 ||
1741 				strcmp(strright_unit, "in") == 0 )
1742 			{
1743 				fright = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_right));
1744 				strright = g_strdup_printf("%0.2f%s ", fright, strright_unit);
1745 			}else{
1746 				nright = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_right));
1747 				strright = g_strdup_printf("%d%s ", nright, strright_unit);
1748 			}
1749 
1750 			output_string = allocated_buffer_add_string(output_string,  strright);
1751 			g_free(strright);
1752 			g_free(strright_unit);
1753 		}
1754 		if( b_bottom ){
1755 			count++;
1756 			spinbutton_bottom = lookup_widget(parent,"spinbutton_bottom");
1757 			combo_entry_bottom = lookup_widget(parent,"combo_entry_bottom");
1758 			strbottom_unit = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_bottom),0,-1);
1759 
1760 			if( strcmp(strbottom_unit, "em") == 0 ||
1761 				strcmp(strbottom_unit, "in") == 0 )
1762 			{
1763 				fbottom = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_bottom));
1764 				strbottom = g_strdup_printf("%0.2f%s ",  fbottom, strbottom_unit);
1765 			}else{
1766 				nbottom =  gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_bottom));
1767 				strbottom = g_strdup_printf("%d%s ", nbottom, strbottom_unit);
1768 			}
1769 
1770 			output_string = allocated_buffer_add_string(output_string,  strbottom);
1771 			g_free(strbottom);
1772 			g_free(strbottom_unit);
1773 		}
1774 		if( b_left ){
1775 			count++;
1776 			spinbutton_left = lookup_widget(parent,"spinbutton_left");
1777 			combo_entry_left = lookup_widget(parent,"combo_entry_left");
1778 			strleft_unit = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_left),0,-1);
1779 
1780 			if( strcmp(strbottom_unit, "em") == 0 ||
1781 				strcmp(strbottom_unit, "in") == 0 )
1782 			{
1783 				fleft = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_left));
1784 				strleft = g_strdup_printf("%0.2f%s ",  fleft, strleft_unit);
1785 			}else{
1786 				nleft = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_left));
1787 				strleft = g_strdup_printf("%d%s ", nleft, strleft_unit);
1788 			}
1789 
1790 			output_string = allocated_buffer_add_string(output_string, strleft);
1791 			g_free(strleft);
1792 			g_free(strleft_unit);
1793 		}
1794 
1795 
1796 		if( count == 1){
1797 			document_write_error_to_program_output(
1798 					doc,
1799 					_("margin: only one value used. Will be applied to all margins."),
1800 					WARNING_COLOR_STRING
1801 					);
1802 		}else if( count == 2 ){
1803 			document_write_error_to_program_output(
1804 					doc,
1805 					_("margin: two values used. First will be applied to top/bottom, second to left/right."),
1806 					WARNING_COLOR_STRING
1807 					);
1808 		}else if(count == 3 ){
1809 			document_write_error_to_program_output(
1810 					doc,
1811 					_("margin: three values used. First will be used to top, second to left/right and third to bottom."),
1812 					WARNING_COLOR_STRING
1813 					);
1814 		}
1815 		return output_string;
1816 	}
1817 }
1818 
1819 gchar*
cssdialog_margin_width_get_string(CssedWindow * window,gpointer data)1820 cssdialog_margin_width_get_string ( CssedWindow* window, gpointer data )
1821 {
1822 	GtkWidget *spinbutton_margin_width;
1823 	GtkWidget *combo_entry_margin_width_units;
1824 	gchar* output_string;
1825 	gchar* strunit;
1826 	gint nwidth;
1827 	gfloat fwidth;
1828 	GtkWidget* parent;
1829 	CssedDoc* doc;
1830 
1831 	parent = GTK_WIDGET(data);
1832 	doc = document_get_current( window );
1833 
1834 	spinbutton_margin_width = lookup_widget(parent, "spinbutton_margin_width");
1835 	combo_entry_margin_width_units = lookup_widget(parent, "combo_entry_margin_width_units");
1836 	strunit = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_margin_width_units),0,-1);
1837 
1838 	if( strcmp(strunit, "em") == 0  ||
1839 		strcmp(strunit, "in") == 0  ){
1840 		fwidth = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_margin_width));
1841 		output_string = g_strdup_printf("%0.2f%s", fwidth, strunit);
1842 	}else{
1843 		nwidth = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_margin_width));
1844 		output_string = g_strdup_printf("%d%s",nwidth,strunit);
1845 	}
1846 
1847 	g_free (strunit);
1848 	return output_string;
1849 }
1850 
1851 gchar*
cssdialog_number_value_get_string(CssedWindow * window,gpointer data)1852 cssdialog_number_value_get_string ( CssedWindow* window, gpointer data )
1853 {
1854 	GtkWidget *spinbutton_number;
1855 	gfloat number;
1856 	gchar* output_string;
1857 	GtkWidget* parent;
1858 	CssedDoc* doc;
1859 
1860 	parent = GTK_WIDGET(data);
1861 	doc = document_get_current( window );
1862 
1863 	spinbutton_number = lookup_widget(parent,"spinbutton_number");
1864 
1865 	number = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_number));
1866 	output_string = g_strdup_printf(" %0.2f", number);
1867 	return output_string;
1868 }
1869 
1870 gchar*
cssdialog_padding_property_get_string(CssedWindow * window,gpointer data)1871 cssdialog_padding_property_get_string ( CssedWindow* window, gpointer data )
1872 {
1873 	GtkWidget *checkbutton_top;
1874 	GtkWidget *spinbutton_top;
1875 	GtkWidget *combo_entry_top;
1876 	GtkWidget *checkbutton_left;
1877 	GtkWidget *spinbutton_left;
1878 	GtkWidget *combo_entry_left;
1879 	GtkWidget *checkbutton_bottom;
1880 	GtkWidget *spinbutton_bottom;
1881 	GtkWidget *combo_entry_bottom;
1882 	GtkWidget *checkbutton_right;
1883 	GtkWidget *spinbutton_right;
1884 	GtkWidget *combo_entry_right;
1885 	gboolean b_top;
1886 	gboolean b_left;
1887 	gboolean b_bottom;
1888 	gboolean b_right;
1889 	gint ntop;
1890 	gint nleft;
1891 	gint nbottom;
1892 	gint nright;
1893 	gfloat ftop;
1894 	gfloat fleft;
1895 	gfloat fbottom;
1896 	gfloat fright;
1897 	gchar* strtop;
1898 	gchar* strleft;
1899 	gchar* strbottom;
1900 	gchar* strright;
1901 	gchar* strtop_unit;
1902 	gchar* strleft_unit;
1903 	gchar* strbottom_unit = NULL;
1904 	gchar* strright_unit;
1905 	gint count;
1906 	gchar* output_string;
1907 	GtkWidget* parent;
1908 	CssedDoc* doc;
1909 
1910 	parent = GTK_WIDGET(data);
1911 	doc = document_get_current( window );
1912 
1913 	checkbutton_top = lookup_widget(parent, "checkbutton_top");
1914 	checkbutton_left = lookup_widget(parent, "checkbutton_left");
1915 	checkbutton_bottom = lookup_widget(parent, "checkbutton_bottom");
1916 	checkbutton_right = lookup_widget(parent, "checkbutton_right");
1917 
1918 	b_top = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_top));
1919 	b_left = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_left));
1920 	b_bottom = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_bottom));
1921 	b_right = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_right));
1922 
1923 	if( !b_top && !b_right && !b_bottom && !b_left ){
1924 		return NULL;
1925 	}else{
1926 		count = 0;
1927 		output_string = g_strdup("");
1928 		if( b_top ){
1929 			count++;
1930 			spinbutton_top  = lookup_widget(parent, "spinbutton_top");
1931 			combo_entry_top = lookup_widget(parent, "combo_entry_top");
1932 			strtop_unit = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_top),0,-1);
1933 
1934 			if( strcmp(strtop_unit, "em") == 0 ||
1935 				strcmp(strtop_unit, "in") == 0 )
1936 			{
1937 				ftop = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_top));
1938 				strtop = g_strdup_printf("%0.2f%s ", ftop, strtop_unit);
1939 			}else{
1940 				ntop = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_top));
1941 				strtop = g_strdup_printf("%d%s ", ntop, strtop_unit);
1942 			}
1943 
1944 			output_string = allocated_buffer_add_string(output_string,  strtop);
1945 			g_free(strtop);
1946 			g_free(strtop_unit);
1947 		}
1948 		if( b_right ){
1949 			count++;
1950 			spinbutton_right = lookup_widget(parent,"spinbutton_right");
1951 			combo_entry_right = lookup_widget(parent,"combo_entry_right");
1952 			strright_unit = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_right),0,-1);
1953 
1954 			if( strcmp(strright_unit, "em") == 0 ||
1955 				strcmp(strright_unit, "in") == 0 )
1956 			{
1957 				fright = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_right));
1958 				strright = g_strdup_printf("%0.2f%s ", fright, strright_unit);
1959 			}else{
1960 				nright = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_right));
1961 				strright = g_strdup_printf("%d%s ", nright, strright_unit);
1962 			}
1963 
1964 			output_string = allocated_buffer_add_string(output_string,  strright);
1965 			g_free(strright);
1966 			g_free(strright_unit);
1967 		}
1968 		if( b_bottom ){
1969 			count++;
1970 			spinbutton_bottom = lookup_widget(parent,"spinbutton_bottom");
1971 			combo_entry_bottom = lookup_widget(parent,"combo_entry_bottom");
1972 			strbottom_unit = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_bottom),0,-1);
1973 
1974 			if( strcmp(strbottom_unit, "em") == 0 ||
1975 				strcmp(strbottom_unit, "in") == 0 )
1976 			{
1977 				fbottom = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_bottom));
1978 				strbottom = g_strdup_printf("%0.2f%s ",  fbottom, strbottom_unit);
1979 			}else{
1980 				nbottom =  gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_bottom));
1981 				strbottom = g_strdup_printf("%d%s ", nbottom, strbottom_unit);
1982 			}
1983 
1984 			output_string = allocated_buffer_add_string(output_string, strbottom);
1985 			g_free(strbottom);
1986 			g_free(strbottom_unit);
1987 		}
1988 		if( b_left ){
1989 			count++;
1990 			spinbutton_left = lookup_widget(parent,"spinbutton_left");
1991 			combo_entry_left = lookup_widget(parent,"combo_entry_left");
1992 			strleft_unit = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_left),0,-1);
1993 
1994 			if( strcmp(strbottom_unit, "em") == 0 ||
1995 				strcmp(strbottom_unit, "in") == 0 )
1996 			{
1997 				fleft = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_left));
1998 				strleft = g_strdup_printf("%0.2f%s ",  fleft, strleft_unit);
1999 			}else{
2000 				nleft = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_left));
2001 				strleft = g_strdup_printf("%d%s ", nleft, strleft_unit);
2002 			}
2003 
2004 			output_string = allocated_buffer_add_string(output_string, strleft);
2005 			g_free(strleft);
2006 			g_free(strleft_unit);
2007 		}
2008 
2009 		if( count == 1){
2010 			document_write_error_to_program_output(doc,_("padding: only one value used. Will be applied to all sides."),WARNING_COLOR_STRING);
2011 		}else if( count == 2 ){
2012 			document_write_error_to_program_output(doc,_("padding: two values used. First will be applied to top/bottom, second to left/right."),WARNING_COLOR_STRING);
2013 		}else if(count == 3 ){
2014 			document_write_error_to_program_output(doc,_("padding: three values used. First will be used to top, second to left/right and third to bottom."),WARNING_COLOR_STRING);
2015 		}
2016 
2017 		return output_string;
2018 	}
2019 }
2020 
2021 gchar*
cssdialog_outline_property_get_string(CssedWindow * window,gpointer data)2022 cssdialog_outline_property_get_string ( CssedWindow* window, gpointer data )
2023 {
2024 	GtkWidget *checkbutton_length;
2025 	GtkWidget *combo_entry_length_selector;
2026 	GtkWidget *spinbutton_length;
2027 	GtkWidget *combo_entry_length_units;
2028 	GtkWidget *checkbutton_style;
2029 	GtkWidget *combo_entry_style;
2030 	GtkWidget *checkbutton_color;
2031 	GtkWidget *combo_entry_color;
2032 	GtkWidget *colorselection;
2033 	gboolean b_length;
2034 	gboolean b_style;
2035 	gboolean b_color;
2036 	gint nlength;
2037 	gfloat flength;
2038 	gchar* strlength_units;
2039 	gchar* strlength;
2040 	gchar* strlength_and_unit;
2041 	gchar* strstyle;
2042 	gchar* strcolor;
2043 	gchar* gdk_color_to_string;
2044 	GdkColor color;
2045 	gchar* output_string;
2046 	GtkWidget* parent;
2047 	CssedDoc* doc;
2048 
2049 	parent = GTK_WIDGET(data);
2050 	doc = document_get_current( window );
2051 
2052 	checkbutton_length  = lookup_widget(parent,"checkbutton_length");
2053 	checkbutton_style = lookup_widget(parent,"checkbutton_style");
2054 	checkbutton_color = lookup_widget(parent,"checkbutton_color");
2055 
2056 	b_length = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_length));
2057 	b_style = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_style));
2058 	b_color = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_color));
2059 
2060 	if ( !b_length && !b_style && !b_color ){
2061 		return NULL;
2062 	}else{
2063 		output_string = g_strdup("");
2064 		if( b_length ){
2065 			combo_entry_length_selector = lookup_widget(parent,"combo_entry_length_selector") ;
2066 			strlength = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_length_selector),
2067 								0,-1);
2068 			if( strcmp(strlength,CSS_STR_USE_PERCLEN) == 0){
2069 				spinbutton_length  = lookup_widget(parent,"spinbutton_length");
2070 				combo_entry_length_units = lookup_widget(parent,"combo_entry_length_units");
2071 				strlength_units = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_length_units),
2072 								0,-1);
2073 
2074 				if( strcmp(strlength_units, "em") == 0 ||
2075 					strcmp(strlength_units, "in") == 0 )
2076 				{
2077 					flength = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_length));
2078 					strlength_and_unit = g_strdup_printf("%0.2f%s", flength, strlength_units);
2079 				}else{
2080 					nlength = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_length));
2081 					strlength_and_unit = g_strdup_printf("%d%s", nlength, strlength_units);
2082 				}
2083 
2084 				output_string = allocated_buffer_add_string(output_string, strlength_and_unit);
2085 				g_free(strlength_units);
2086 				g_free(strlength_and_unit);
2087 			}else{
2088 				output_string = allocated_buffer_add_string(output_string, strlength);
2089 			}
2090 			g_free(strlength);
2091 			if( b_style || b_color ){
2092 				output_string = allocated_buffer_add_string(output_string," ");
2093 			}
2094 		}
2095 		if( b_style ){
2096 			combo_entry_style = lookup_widget(parent,"combo_entry_style");
2097 			strstyle = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_style),0,-1);
2098 			output_string = allocated_buffer_add_string(output_string,strstyle);
2099 			if( b_color ){
2100 				output_string = allocated_buffer_add_string(output_string, " ");
2101 			}
2102 			g_free(strstyle);
2103 		}
2104 		if( b_color ){
2105 			combo_entry_color = lookup_widget(parent,"combo_entry_color");
2106 			strcolor = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_color),0,-1);
2107 			if( strcmp(strcolor,CSS_STR_USE_COLORSEL) == 0 ){
2108 				colorselection = lookup_widget(parent,"colorselection");
2109 				gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(colorselection),&color);
2110 				gdk_color_to_string = gdk_color_to_rgb_triplet_string(&color);
2111 				output_string = allocated_buffer_add_string(output_string, gdk_color_to_string );
2112 				g_free(gdk_color_to_string);
2113 			}else{
2114 				output_string = allocated_buffer_add_string(output_string, strcolor);
2115 			}
2116 			g_free(strcolor);
2117 		}
2118 		return output_string;
2119 	}
2120 }
2121 
2122 gchar*
cssdialog_pause_property_get_string(CssedWindow * window,gpointer data)2123 cssdialog_pause_property_get_string( CssedWindow* window, gpointer data )
2124 {
2125 	GtkWidget *checkbutton_after;
2126 	GtkWidget *spinbutton_after;
2127 	GtkWidget *combo_entry_after;
2128 	GtkWidget *checkbutton_before;
2129 	GtkWidget *spinbutton_before;
2130 	GtkWidget *combo_entry_before;
2131 	gboolean b_after;
2132 	gboolean b_before;
2133 	gchar* strafter;
2134 	gchar* strafter_unit;
2135 	gint nafter;
2136 	gchar* strbefore;
2137 	gchar* strbefore_unit;
2138 	gint nbefore;
2139 	gchar* output_string;
2140 	GtkWidget* parent;
2141 	CssedDoc* doc;
2142 
2143 	parent = GTK_WIDGET(data);
2144 	doc = document_get_current( window );
2145 
2146 	checkbutton_after = lookup_widget(parent,"checkbutton_after");
2147 	checkbutton_before = lookup_widget(parent,"checkbutton_before");
2148 
2149 	b_after = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_after));
2150 	b_before = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_before));
2151 
2152 	if(!b_after && !b_before){
2153 		return NULL;
2154 	}else{
2155 		output_string = g_strdup("");
2156 		if( b_after ){
2157 			spinbutton_after = lookup_widget(parent,"spinbutton_after");
2158 			combo_entry_after = lookup_widget(parent,"combo_entry_after");
2159 			strafter_unit = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_after),0,-1);
2160 			nafter = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_after));
2161 			strafter = g_strdup_printf("%d%s",nafter,strafter_unit);
2162 			output_string = allocated_buffer_add_string(output_string,strafter);
2163 			if( b_before ){
2164 				output_string = allocated_buffer_add_string(output_string," ");
2165 			}
2166 			g_free(strafter_unit);
2167 			g_free(strafter);
2168 		}
2169 		if( b_before ){
2170 			if( !b_after ){
2171 				output_string = allocated_buffer_add_string(output_string, " 0ms ");
2172 				document_write_error_to_program_output(doc,_("pause dialog: only pause before selected, defaulting pause-after to 0 millisecond."),WARNING_COLOR_STRING);
2173 			}
2174 			spinbutton_before = lookup_widget(parent,"spinbutton_before");
2175 			combo_entry_before = lookup_widget(parent,"combo_entry_before");
2176 			strbefore_unit = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_before),0,-1);
2177 			nbefore = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_before));
2178 			strbefore = g_strdup_printf("%d%s",nbefore,strbefore_unit);
2179 			output_string = allocated_buffer_add_string(output_string, strbefore);
2180 			g_free(strbefore_unit);
2181 			g_free(strbefore);
2182 		}
2183 		return output_string;
2184 	}
2185 }
2186 
2187 gchar*
cssdialog_percentage_value_get_string(CssedWindow * window,gpointer data)2188 cssdialog_percentage_value_get_string( CssedWindow* window, gpointer data )
2189 {
2190 	GtkWidget *spinbutton_percentage;
2191 	gchar* output_string;
2192 	gint npercentage;
2193 	GtkWidget* parent;
2194 	CssedDoc* doc;
2195 
2196 	parent = GTK_WIDGET(data);
2197 	doc = document_get_current( window );
2198 
2199 	spinbutton_percentage = lookup_widget(parent,"spinbutton_percentage");
2200 	npercentage = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_percentage));
2201 	output_string = g_strdup_printf(" %d",npercentage);
2202 
2203 	return output_string;
2204 }
2205 gchar*
cssdialog_percentage_length_value_get_string(CssedWindow * window,gpointer data)2206 cssdialog_percentage_length_value_get_string( CssedWindow* window, gpointer data )
2207 {
2208 	GtkWidget *spinbutton_perclen;
2209 	GtkWidget *combo_entry_perclen_units;
2210 	gchar* output_string;
2211 	gchar* strunit;
2212 	gint npercentage;
2213 	gfloat fpercentage;
2214 	GtkWidget* parent;
2215 	CssedDoc* doc;
2216 
2217 	parent = GTK_WIDGET(data);
2218 	doc = document_get_current( window );
2219 
2220 	spinbutton_perclen = lookup_widget(parent,"spinbutton_perclen");
2221 	combo_entry_perclen_units = lookup_widget(parent,"combo_entry_perclen_units");
2222 	strunit = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_perclen_units),0,-1);
2223 
2224 	if( strcmp(strunit, "em") == 0 ||
2225 		strcmp(strunit, "in") == 0 )
2226 	{
2227 		fpercentage = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_perclen));
2228 		output_string = g_strdup_printf(" %0.2f%s", fpercentage, strunit);
2229 	}else{
2230 		npercentage = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_perclen));
2231 		output_string = g_strdup_printf(" %d%s", npercentage, strunit);
2232 	}
2233 
2234 	g_free (strunit);
2235 	return output_string;
2236 }
2237 gchar*
cssdialog_play_during_property_get_string(CssedWindow * window,gpointer data)2238 cssdialog_play_during_property_get_string ( CssedWindow* window, gpointer data )
2239 {
2240 	GtkWidget *entry_uri;
2241 	GtkWidget *checkbutton_repeat;
2242 	GtkWidget *checkbutton_mix;
2243 	gchar* struri;
2244 	gboolean b_repeat;
2245 	gboolean b_mix;
2246 	gchar* output_string;
2247 	GtkWidget* parent;
2248 	CssedDoc* doc;
2249 
2250 	parent = GTK_WIDGET(data);
2251 	doc = document_get_current( window );
2252 
2253 	entry_uri = lookup_widget(parent,"entry_uri");
2254 	struri = gtk_editable_get_chars(GTK_EDITABLE(entry_uri),0,-1);
2255 
2256 	if( strlen(struri) > 0){
2257 		output_string = g_strdup("");
2258 		checkbutton_repeat = lookup_widget(parent,"checkbutton_repeat");
2259 		checkbutton_mix = lookup_widget(parent,"checkbutton_mix");
2260 		b_repeat = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_repeat));
2261 		b_mix = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_mix));
2262 
2263 		output_string = allocated_buffer_add_string(output_string, " url(\"");
2264 		output_string = allocated_buffer_add_string(output_string, struri);
2265 		output_string = allocated_buffer_add_string(output_string, "\")");
2266 
2267 		if( b_repeat ) output_string = allocated_buffer_add_string(output_string, " repeat");
2268 		if( b_mix ) output_string = allocated_buffer_add_string(output_string, " mix");
2269 
2270 		g_free(struri);
2271 		return output_string;
2272 	}else{
2273 		g_free(struri);
2274 		return NULL;
2275 	}
2276 }
2277 
2278 gchar*
cssdialog_quotes_property_get_string(CssedWindow * window,gpointer data)2279 cssdialog_quotes_property_get_string( CssedWindow* window, gpointer data )
2280 {
2281 	GtkWidget *treeview;
2282 	GtkTreeModel *list_store;
2283 	GtkTreeIter iter;
2284 	gboolean valid;
2285 	gchar* stropen;
2286 	gchar* strclose;
2287 	gchar* output_string;
2288 	GtkWidget* parent;
2289 	CssedDoc* doc;
2290 
2291 	parent = GTK_WIDGET(data);
2292 	doc = document_get_current( window );
2293 
2294 	treeview = lookup_widget (parent, "treeview");
2295 	list_store = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
2296 	valid = gtk_tree_model_get_iter_first (list_store, &iter);
2297 
2298 	if (valid)
2299 	{	// there are values in the store
2300 		// parse the list
2301 		output_string = g_strdup("");
2302 		while (valid)
2303 		{
2304 			gtk_tree_model_get (list_store, &iter,
2305 						0, &stropen, 1, &strclose, -1);
2306 
2307 			// the callback on_button_quotes_property_dialog_add_clicked()
2308 			// ensures that no empty values can be passed.
2309 			if( strcmp(stropen,"\"") == 0 ){
2310 				output_string = allocated_buffer_add_string(output_string, " '");
2311 				output_string = allocated_buffer_add_string(output_string, stropen);
2312 				output_string = allocated_buffer_add_string(output_string, "'");
2313 			}else{
2314 				output_string = allocated_buffer_add_string(output_string, " \"");
2315 				output_string = allocated_buffer_add_string(output_string, stropen);
2316 				output_string = allocated_buffer_add_string(output_string, "\"");
2317 			}
2318 
2319 			if( strcmp(strclose,"\"") == 0 ){
2320 				output_string = allocated_buffer_add_string(output_string, " '");
2321 				output_string = allocated_buffer_add_string(output_string, strclose);
2322 				output_string = allocated_buffer_add_string(output_string, "'");
2323 			}else{
2324 				output_string = allocated_buffer_add_string(output_string, " \"");
2325 				output_string = allocated_buffer_add_string(output_string, strclose);
2326 				output_string = allocated_buffer_add_string(output_string, "\"");
2327 			}
2328 
2329 			g_free (stropen);
2330 			g_free (strclose);
2331 			valid = gtk_tree_model_iter_next (list_store, &iter);
2332 			if( valid ){
2333 				output_string = allocated_buffer_add_string(output_string, " , ");
2334 			}
2335 		}
2336 		return output_string;
2337 	}else { // not valid nothing in the list
2338 		return NULL;
2339 	}
2340 }
2341 
2342 gchar*
cssdialog_shape_value_get_string(CssedWindow * window,gpointer data)2343 cssdialog_shape_value_get_string ( CssedWindow* window, gpointer data )
2344 {
2345 	GtkWidget *spinbutton_top;
2346 	GtkWidget *combo_entry_top;
2347 	GtkWidget *spinbutton_right;
2348 	GtkWidget *combo_entry_right;
2349 	GtkWidget *spinbutton_bottom;
2350 	GtkWidget *combo_entry_bottom;
2351 	GtkWidget *spinbutton_left;
2352 	GtkWidget *combo_entry_left;
2353 	gchar* output_string;
2354 	gchar* str_top_units;
2355 	gchar* str_left_units;
2356 	gchar* str_bottom_units;
2357 	gchar* str_right_units;
2358 	gint ntop;
2359 	gint nleft;
2360 	gint nbottom;
2361 	gint nright;
2362 	gfloat ftop;
2363 	gfloat fleft;
2364 	gfloat fbottom;
2365 	gfloat fright;
2366 	gchar* helper_str;
2367 	GtkWidget* parent;
2368 	CssedDoc* doc;
2369 
2370 	parent = GTK_WIDGET(data);
2371 	doc = document_get_current( window );
2372 
2373 	spinbutton_top = lookup_widget(parent,"spinbutton_top");
2374 	combo_entry_top = lookup_widget(parent,"combo_entry_top");
2375 	spinbutton_right = lookup_widget(parent,"spinbutton_right");
2376 	combo_entry_right = lookup_widget(parent,"combo_entry_right");
2377 	spinbutton_bottom = lookup_widget(parent,"spinbutton_bottom");
2378 	combo_entry_bottom = lookup_widget(parent,"combo_entry_bottom");
2379 	spinbutton_left = lookup_widget(parent,"spinbutton_left");
2380 	combo_entry_left = lookup_widget(parent,"combo_entry_left");
2381 
2382 	str_top_units = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_top),0,-1);
2383 	str_left_units = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_right),0,-1);
2384 	str_bottom_units = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_bottom),0,-1);
2385 	str_right_units = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_left),0,-1);
2386 
2387 	output_string =  g_strdup("rect(  ");
2388 
2389 	if( strcmp(str_top_units, "em") == 0 ||
2390 		strcmp(str_top_units, "in") == 0 )
2391 	{
2392 		ftop = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_top));
2393 		helper_str= g_strdup_printf("%0.2f%s, ", ftop, str_top_units);
2394 		output_string = allocated_buffer_add_string(output_string, helper_str);
2395 		g_free(helper_str);
2396 	}else{
2397 		ntop = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_top));
2398 		helper_str= g_strdup_printf("%d%s, ", ntop, str_top_units);
2399 		output_string = allocated_buffer_add_string(output_string, helper_str);
2400 		g_free(helper_str);
2401 	}
2402 
2403 	if( strcmp(str_left_units, "em") == 0 ||
2404 		strcmp(str_left_units, "in") == 0 )
2405 	{
2406 		fleft = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_left));
2407 		helper_str= g_strdup_printf("%0.2f%s, ", fleft, str_left_units);
2408 		output_string = allocated_buffer_add_string(output_string, helper_str);
2409 		g_free(helper_str);
2410 	}else{
2411 		nleft = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_left));
2412 		helper_str= g_strdup_printf("%d%s, ", nleft, str_left_units);
2413 		output_string = allocated_buffer_add_string(output_string, helper_str);
2414 		g_free(helper_str);
2415 	}
2416 
2417 	if( strcmp(str_bottom_units, "em") == 0 ||
2418 		strcmp(str_bottom_units, "in") == 0 )
2419 	{
2420 		fbottom = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_bottom));
2421 		helper_str= g_strdup_printf("%0.2f%s, ", fbottom, str_bottom_units);
2422 		output_string = allocated_buffer_add_string(output_string, helper_str);
2423 		g_free(helper_str);
2424 	}else{
2425 		nbottom = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_bottom));
2426 		helper_str= g_strdup_printf("%d%s, ", nbottom, str_bottom_units);
2427 		output_string = allocated_buffer_add_string(output_string, helper_str);
2428 		g_free(helper_str);
2429 	}
2430 
2431 	if( strcmp(str_right_units, "em") == 0 ||
2432 		strcmp(str_right_units, "in") == 0 )
2433 	{
2434 		fright = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_right));
2435 		helper_str= g_strdup_printf("%0.2f%s )", fright, str_right_units);
2436 		output_string = allocated_buffer_add_string(output_string, helper_str);
2437 		g_free(helper_str);
2438 	}else{
2439 		nright = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_right));
2440 		helper_str= g_strdup_printf("%d%s )", nright, str_right_units);
2441 		output_string = allocated_buffer_add_string(output_string, helper_str);
2442 		g_free(helper_str);
2443 	}
2444 
2445 	g_free (str_top_units);
2446 	g_free (str_left_units);
2447 	g_free (str_bottom_units);
2448 	g_free (str_right_units);
2449 
2450 	return output_string;
2451 }
2452 
2453 gchar*
cssdialog_size_length_value_get_string(CssedWindow * window,gpointer data)2454 cssdialog_size_length_value_get_string( CssedWindow* window, gpointer data )
2455 {
2456 	GtkWidget *spinbutton_width;
2457 	GtkWidget *combo_entry_width;
2458 	GtkWidget *spinbutton_height;
2459 	GtkWidget *combo_entry_height;
2460 	gchar* output_string;
2461 	gchar* strwidth_units;
2462 	gchar* strheight_units;
2463 	gfloat fwidth;
2464 //	gfloat fheight;
2465 	gint nwidth;
2466 //	gint nheight;
2467 	gchar* helper_str;
2468 	GtkWidget* parent;
2469 	CssedDoc* doc;
2470 
2471 	parent = GTK_WIDGET(data);
2472 	doc = document_get_current( window );
2473 
2474 	spinbutton_width = lookup_widget(parent,"spinbutton_width");
2475 	combo_entry_width = lookup_widget(parent,"combo_entry_width");
2476 	spinbutton_height = lookup_widget(parent,"spinbutton_height");
2477 	combo_entry_height = lookup_widget(parent,"combo_entry_height");
2478 
2479 	strwidth_units = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_width ),0,-1);
2480 	strheight_units  = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_height ),0,-1) ;
2481 
2482 	output_string = g_strdup("");
2483 
2484 	if( strcmp(strwidth_units, "em") == 0 ||
2485 		strcmp(strwidth_units, "in") == 0 )
2486 	{
2487 		fwidth = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_width));
2488 		helper_str= g_strdup_printf("%0.2f%s ", fwidth, strwidth_units);
2489 		output_string = allocated_buffer_add_string(output_string, helper_str);
2490 		g_free(helper_str);
2491 	}else{
2492 		nwidth = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_width));
2493 		helper_str= g_strdup_printf("%d%s ", nwidth, strwidth_units);
2494 		output_string = allocated_buffer_add_string(output_string, helper_str);
2495 		g_free(helper_str);
2496 	}
2497 
2498 	if( strcmp(strheight_units, "em") == 0 ||
2499 		strcmp(strheight_units, "in") == 0 )
2500 	{
2501 		fwidth = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_width));
2502 		helper_str= g_strdup_printf("%0.2f%s", fwidth, strheight_units);
2503 		output_string = allocated_buffer_add_string(output_string, helper_str);
2504 		g_free(helper_str);
2505 	}else{
2506 		nwidth = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_width));
2507 		helper_str= g_strdup_printf("%d%s", nwidth, strheight_units);
2508 		output_string = allocated_buffer_add_string(output_string, helper_str);
2509 		g_free(helper_str);
2510 	}
2511 
2512 	g_free (strwidth_units);
2513 	g_free (strheight_units);
2514 
2515 	return output_string;
2516 }
2517 gchar*
cssdialog_text_shadow_value_get_string(CssedWindow * window,gpointer data)2518 cssdialog_text_shadow_value_get_string ( CssedWindow* window, gpointer data )
2519 
2520 {
2521 	GtkTreeModel *list_store;
2522 	GtkTreeIter iter;
2523 	GtkWidget *spinbutton_right;
2524 	GtkWidget *combo_entry_right;
2525 	GtkWidget *spinbutton_below;
2526 	GtkWidget *combo_entry_below;
2527 	GtkWidget *checkbutton_blur;
2528 	GtkWidget *spinbutton_blur;
2529 	GtkWidget *combo_entry_blur;
2530 	GtkWidget *checkbutton_use_color;
2531 	GtkWidget *combo_entry_use_color;
2532 	GtkWidget *colorselection;
2533 	GtkWidget *checkbutton_use_shadow_list;
2534 	GtkWidget *treeview;
2535 	gboolean b_use_list;
2536 	gchar* str_right_units;
2537 	gchar* str_right;
2538 	gfloat fright;
2539 	gint nright;
2540 	gchar* str_below_units;
2541 	gchar* str_below;
2542 	gfloat fbelow;
2543 	gint nbelow;
2544 	gchar* str_blur_units;
2545 	gchar* str_blur;
2546 	gfloat fblur;
2547 	gint nblur;
2548 	gboolean b_blur;
2549 	gchar* strcolor;
2550 	gchar* strrgbcolor;
2551 	GdkColor gdkcolor;
2552 	gboolean b_color;
2553 	gboolean valid;
2554 	gchar* output_string;
2555 	GtkWidget* parent;
2556 	CssedDoc* doc;
2557 
2558 	parent = GTK_WIDGET(data);
2559 	doc = document_get_current( window );
2560 
2561 	checkbutton_use_shadow_list = lookup_widget(parent,"checkbutton_use_shadow_list");
2562 	b_use_list = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_use_shadow_list));
2563 
2564 	if( b_use_list ){
2565 		treeview = lookup_widget(parent,"treeview");
2566 		document_write_error_to_program_output(doc,_("text shadow dialog: using list values, ignoring other dialog choices."),WARNING_COLOR_STRING);
2567 		list_store = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
2568 		valid = gtk_tree_model_get_iter_first (list_store, &iter);
2569 		output_string = g_strdup("");
2570 		if (valid)
2571 		{	// there are values in the store
2572 			// parse the list
2573 			output_string = g_strdup("");
2574 			while (valid)
2575 			{
2576 				gtk_tree_model_get (list_store, &iter,
2577 							COL_RIGHT, &str_right,
2578 							COL_BELOW, &str_below,
2579 							COL_BLUR, &str_blur,
2580 							COL_COLOR, &strcolor, 	-1);
2581 
2582 				output_string = allocated_buffer_add_string(output_string, str_right);
2583 				output_string = allocated_buffer_add_string(output_string, " ");
2584 				output_string = allocated_buffer_add_string(output_string, str_below);
2585 
2586 				if ( str_blur != NULL ){
2587 					if(  strlen(str_blur) > 0 ){
2588 						output_string = allocated_buffer_add_string(output_string, " ");
2589 						output_string = allocated_buffer_add_string(output_string, str_blur);
2590 					}
2591 					g_free (str_blur);
2592 				}
2593 
2594 				if( strcolor != NULL ){
2595 					if( strlen(strcolor) > 0  ){
2596 						output_string = allocated_buffer_add_string(output_string, " ");
2597 						output_string = allocated_buffer_add_string(output_string, strcolor);
2598 					}
2599 				}
2600 
2601 				g_free (str_right);
2602 				g_free (str_below);
2603 
2604 				valid = gtk_tree_model_iter_next (list_store, &iter);
2605 				if( valid ){
2606 					output_string = allocated_buffer_add_string(output_string, " , ");
2607 				}
2608 			}
2609 			return output_string;
2610 		}else { // nothing in the list
2611 			return NULL;
2612 		}
2613 	}else{ // don't use list
2614 		output_string = g_strdup("");
2615 		checkbutton_blur = lookup_widget(parent,"checkbutton_blur");
2616 		checkbutton_use_color = lookup_widget(parent,"checkbutton_use_color");
2617 
2618 		b_blur = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_blur));
2619 		b_color = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_use_color));
2620 
2621 		spinbutton_right = lookup_widget(parent,"spinbutton_right");
2622 		combo_entry_right = lookup_widget(parent,"combo_entry_right");
2623 		spinbutton_below = lookup_widget(parent,"spinbutton_below");
2624 		combo_entry_below = lookup_widget(parent,"combo_entry_below");
2625 		spinbutton_blur = lookup_widget(parent,"spinbutton_blur");
2626 		combo_entry_blur = lookup_widget(parent,"combo_entry_blur");
2627 		combo_entry_use_color = lookup_widget(parent,"combo_entry_use_color");
2628 		colorselection = lookup_widget(parent,"colorselection");
2629 
2630 		str_right_units = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_right),0,-1);
2631 		if( strcmp(str_right_units, "em") == 0 ||
2632 			strcmp(str_right_units, "in") == 0 )
2633 		{
2634 			fright = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_right));
2635 			str_right= g_strdup_printf("%0.2f%s", fright, str_right_units);
2636 		}else{
2637 			nright = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_right));
2638 			str_right = g_strdup_printf("%d%s", nright, str_right_units);
2639 		}
2640 
2641 		str_below_units = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_below),0,-1);
2642 		if( strcmp(str_below_units, "em") == 0 ||
2643 			strcmp(str_below_units, "in") == 0 )
2644 		{
2645 			fbelow = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_below));
2646 			str_below = g_strdup_printf("%0.2f%s", fbelow, str_below_units);
2647 		}else{
2648 			nbelow = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_below));
2649 			str_below = g_strdup_printf("%d%s", nbelow, str_below_units);
2650 		}
2651 
2652 		output_string = allocated_buffer_add_string(output_string, str_right);
2653 		output_string = allocated_buffer_add_string(output_string, " ");
2654 		output_string = allocated_buffer_add_string(output_string, str_below);
2655 
2656 		if( b_blur ){
2657 			spinbutton_blur = lookup_widget(parent,"spinbutton_blur");
2658 			combo_entry_blur = lookup_widget(parent,"combo_entry_blur");
2659 
2660 			str_blur_units = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_blur),0,-1);
2661 			if( strcmp(str_blur_units, "em") == 0 ||
2662 				strcmp(str_blur_units, "in") == 0 )
2663 			{
2664 				fblur = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_blur));
2665 				str_blur = g_strdup_printf("%0.2f%s", fblur, str_blur_units);
2666 			}else{
2667 				nblur = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_blur));
2668 				str_blur = g_strdup_printf("%d%s", nblur, str_blur_units);
2669 			}
2670 
2671 			output_string = allocated_buffer_add_string(output_string, " ");
2672 			output_string = allocated_buffer_add_string(output_string, str_blur);
2673 
2674 			g_free( str_blur_units );
2675 			g_free( str_blur );
2676 		}
2677 
2678 		if( b_color ){
2679 			combo_entry_use_color = lookup_widget(parent,"combo_entry_use_color");
2680 			colorselection = lookup_widget(parent,"colorselection");
2681 			strcolor = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_use_color),0,-1);
2682 			if( strcmp(strcolor,CSS_STR_USE_COLORSEL) == 0){
2683 				gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(colorselection),
2684 					&gdkcolor);
2685 				strrgbcolor = gdk_color_to_rgb_triplet_string(&gdkcolor);
2686 			}else{
2687 				strrgbcolor = g_strdup(strcolor);
2688 			}
2689 			output_string = allocated_buffer_add_string(output_string, " ");
2690 			output_string = allocated_buffer_add_string(output_string, strrgbcolor);
2691 			g_free(strcolor);
2692 			g_free( strrgbcolor );
2693 		}
2694 
2695 		g_free( str_right_units );
2696 		g_free( str_below_units );
2697 		g_free( str_below );
2698 		g_free( str_right );
2699 
2700 		return output_string;
2701 	}
2702 }
2703 
2704 gchar*
cssdialog_voice_family_value_get_string(CssedWindow * window,gpointer data)2705 cssdialog_voice_family_value_get_string ( CssedWindow* window, gpointer data )
2706 {
2707 	GtkWidget *combo_entry_generic;
2708 	GtkWidget *entry_specific_voice;
2709 	GtkWidget *checkbutton_voice_set;
2710 	GtkWidget *treeview;
2711 	GtkTreeModel *list_store;
2712 	GtkTreeIter iter;
2713 	gboolean valid;
2714 	gboolean b_set;
2715 	gchar* str_generic;
2716 	gchar* str_specific;
2717 	gchar* output_string;
2718 	GtkWidget* parent;
2719 	CssedDoc* doc;
2720 
2721 	parent = GTK_WIDGET(data);
2722 	doc = document_get_current( window );
2723 
2724 	checkbutton_voice_set = lookup_widget(parent,"checkbutton_voice_set");
2725 	b_set = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_voice_set));
2726 
2727 	if( b_set ){
2728 		treeview = lookup_widget(parent,"treeview");
2729 		list_store = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
2730 		valid = gtk_tree_model_get_iter_first (list_store, &iter);
2731 
2732 		if (valid)
2733 		{
2734 			output_string = g_strdup("");
2735 			while (valid)
2736 			{
2737 				gtk_tree_model_get (list_store, &iter,
2738 							COL_GENERIC, &str_generic,
2739 							COL_SPECIFIC, &str_specific, 	-1);
2740 
2741 				if ( str_specific != NULL ){
2742 					if( strlen(str_specific) > 0  ){
2743 						output_string = allocated_buffer_add_string(output_string, " \"");
2744 						output_string = allocated_buffer_add_string(output_string, str_specific);
2745 						output_string = allocated_buffer_add_string(output_string, "\"");
2746 						if( (strlen(str_generic) > 0 ) && (str_generic != NULL) ){
2747 							output_string = allocated_buffer_add_string(output_string, ",");
2748 						}
2749 					}
2750 				}
2751 
2752 				if( str_generic != NULL ){
2753 					if( strlen(str_generic) > 0  ){
2754 						output_string = allocated_buffer_add_string(output_string, " ");
2755 						output_string = allocated_buffer_add_string(output_string, str_generic);
2756 					}
2757 				}
2758 
2759 				g_free (str_generic);
2760 				g_free (str_specific);
2761 
2762 				valid = gtk_tree_model_iter_next (list_store, &iter);
2763 				if( valid ){
2764 					output_string = allocated_buffer_add_string(output_string,  ",");
2765 				}
2766 			}
2767 
2768 			return output_string;
2769 		}else {
2770 			return NULL;
2771 		}
2772 	}else{
2773 		output_string = g_strdup("");
2774 
2775 		combo_entry_generic = lookup_widget(parent,"combo_entry_generic");
2776 		entry_specific_voice = lookup_widget(parent,"entry_specific_voice");
2777 
2778 		str_generic = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_generic),0,-1);
2779 		str_specific = gtk_editable_get_chars(GTK_EDITABLE(entry_specific_voice),0,-1);
2780 
2781 
2782 		if( (  strlen(str_generic) > 0 ) || ( strlen(str_specific) > 0  ) ){
2783 			if( strlen(str_specific) > 0  ){
2784 				output_string = allocated_buffer_add_string(output_string,  " \"");
2785 				output_string = allocated_buffer_add_string(output_string,  str_specific);
2786 				output_string = allocated_buffer_add_string(output_string,  "\"");
2787 
2788 				if( (strlen(str_generic) > 0 ) && (str_generic != NULL) ){
2789 					output_string = allocated_buffer_add_string(output_string,  ",");
2790 				}
2791 			}
2792 			if(  strlen(str_generic) > 0 ){
2793 				output_string = allocated_buffer_add_string(output_string,  " ");
2794 				output_string = allocated_buffer_add_string(output_string,  str_generic);
2795 			}
2796 		}else{
2797 			g_free (str_generic);
2798 			g_free (str_specific);
2799 			return NULL;
2800 		}
2801 
2802 		g_free (str_generic);
2803 		g_free (str_specific);
2804 
2805 		return output_string;
2806 	}
2807 }
2808 gchar*
cssdialog_border_width_style_color_value_get_string(CssedWindow * window,gpointer data)2809 cssdialog_border_width_style_color_value_get_string ( CssedWindow* window, gpointer data )
2810 {
2811 	GtkWidget *checkbutton_length;
2812 	GtkWidget *combo_entry_length;
2813 	GtkWidget *spinbutton_length;
2814 	GtkWidget *combo_entry_length_units;
2815 	GtkWidget *checkbutton_color;
2816 	GtkWidget *combo_entry_color;
2817 	GtkWidget *colorselection;
2818 	GtkWidget *checkbutton_style;
2819 	GtkWidget *combo_entry_style;
2820 	gboolean b_length;
2821 	gboolean b_style;
2822 	gboolean b_color;
2823 	gchar* str_length_units;
2824 	gchar* str_length;
2825 	gchar* str_legth_and_units;
2826 	gint nlength;
2827 	gfloat flength;
2828 	gchar* strstyle;
2829 	gchar* str_color;
2830 	gchar* str_rgb_color;
2831 	GdkColor gdkcolor;
2832 	gchar* output_string;
2833 	GtkWidget* parent;
2834 	CssedDoc* doc;
2835 
2836 	parent = GTK_WIDGET(data);
2837 	doc = document_get_current( window );
2838 
2839 	checkbutton_length = lookup_widget(parent,"checkbutton_length");
2840 	checkbutton_color = lookup_widget(parent,"checkbutton_color");
2841 	checkbutton_style = lookup_widget(parent,"checkbutton_style");
2842 
2843 	b_length = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_length));
2844 	b_style = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_style));
2845 	b_color =  gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton_color));
2846 
2847 	if( !b_length && !b_style && !b_color ){
2848 		return NULL;
2849 	}else{
2850 		output_string = g_strdup("");
2851 		if( b_length ){
2852 			combo_entry_length = lookup_widget(parent,"combo_entry_length");
2853 
2854 			str_length	= gtk_editable_get_chars(GTK_EDITABLE(combo_entry_length),0,-1);
2855 			if( strcmp(str_length,CSS_STR_USE_LENGTH) == 0 ){
2856 				spinbutton_length = lookup_widget(parent,"spinbutton_length");
2857 				combo_entry_length_units = lookup_widget(parent,"combo_entry_length_units");
2858 
2859 				str_length_units = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_length_units),0,-1);
2860 
2861 				if( strcmp(str_length_units, "em") == 0 ||
2862 					strcmp(str_length_units, "in") == 0 )
2863 				{
2864 					flength = (gfloat) gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinbutton_length));
2865 					str_legth_and_units = g_strdup_printf("%0.2f%s", flength, str_length_units);
2866 				}else{
2867 					nlength = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinbutton_length));
2868 					str_legth_and_units = g_strdup_printf("%d%s", nlength, str_length_units);
2869 				}
2870 
2871 				output_string = allocated_buffer_add_string(output_string,  str_legth_and_units);
2872 
2873 				if( b_style || b_color ){
2874 					output_string = allocated_buffer_add_string(output_string,  " ");
2875 				}
2876 
2877 				g_free(str_length_units);
2878 				g_free(str_legth_and_units);
2879 
2880 			}else{
2881 				output_string = allocated_buffer_add_string(output_string,  str_length);
2882 				if( b_style || b_color ){
2883 					output_string = allocated_buffer_add_string(output_string,  " ");
2884 				}
2885 			}
2886 			g_free( str_length );
2887 		}
2888 
2889 		if( b_style ){
2890 			combo_entry_style = lookup_widget(parent,"combo_entry_style");
2891 			strstyle = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_style),0,-1);
2892 			output_string = allocated_buffer_add_string(output_string,  strstyle);
2893 			if(  b_color ){
2894 				output_string = allocated_buffer_add_string(output_string,  " ");
2895 			}
2896 			g_free(strstyle);
2897 		}
2898 
2899 		if( b_color ){
2900 			combo_entry_color = lookup_widget(parent,"combo_entry_color");
2901 			str_color= gtk_editable_get_chars(GTK_EDITABLE(combo_entry_color),0,-1);
2902 
2903 			if( strcmp(str_color,CSS_STR_USE_COLORSEL) == 0 ){
2904 				colorselection = lookup_widget(parent,"colorselection");
2905 				gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(colorselection),&gdkcolor);
2906 				str_rgb_color = gdk_color_to_rgb_triplet_string(&gdkcolor);
2907 				output_string = allocated_buffer_add_string(output_string,  str_rgb_color);
2908 				g_free(str_rgb_color);
2909 			}else{
2910 				output_string = allocated_buffer_add_string(output_string,  str_color);
2911 			}
2912 			g_free(	str_color );
2913 		}
2914 
2915 		return output_string;
2916 	}
2917 }
2918 gchar*
cssdialog_color_selector_get_string(CssedWindow * window,gpointer data)2919 cssdialog_color_selector_get_string ( CssedWindow* window, gpointer data )
2920 {
2921 	GtkWidget *radiobutton_named;
2922 	GtkWidget *combo_entry_named;
2923 	GtkWidget *colorselection;
2924 	gboolean b_use_named_color;
2925 	GdkColor gdkcolor;
2926 	gchar* output_string;
2927 	GtkWidget* parent;
2928 	CssedDoc* doc;
2929 
2930 	parent = GTK_WIDGET(data);
2931 	doc = document_get_current( window );
2932 
2933 	radiobutton_named = lookup_widget(parent,"radiobutton_named");
2934 	combo_entry_named = lookup_widget(parent,"combo_entry_named");
2935 	colorselection = lookup_widget(parent,"colorselection");
2936 
2937 	b_use_named_color = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton_named));
2938 
2939 	if( b_use_named_color ){
2940 		output_string = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_named),0,-1);
2941 	}else{
2942 		gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(colorselection),
2943 			&gdkcolor );
2944 		output_string = gdk_color_to_rgb_triplet_string(&gdkcolor);
2945 	}
2946 	return output_string;
2947 }
2948 
2949 gchar*
cssdialog_border_style_get_string(CssedWindow * window,gpointer data)2950 cssdialog_border_style_get_string( CssedWindow* window, gpointer data )
2951 {
2952 	GtkWidget *combo_entry_style;
2953 	gchar* output_string;
2954 	GtkWidget* parent;
2955 	CssedDoc* doc;
2956 
2957 	parent = GTK_WIDGET(data);
2958 	doc = document_get_current( window );
2959 
2960 	combo_entry_style = lookup_widget(parent,"combo_entry_style");
2961 	output_string = gtk_editable_get_chars(GTK_EDITABLE(combo_entry_style),0,-1);
2962 	return 	output_string;
2963 }
2964 
2965