1 /* Bluefish HTML Editor
2  * html_diag.h - general functions to create HTML dialogs
3  *
4  * Copyright (C) 2000-2011 Olivier Sessink
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef __HTML_DIAG_H_
21 #define __HTML_DIAG_H_
22 
23 #include "../bluefish.h"
24 
25 /*to be used in the function get_curlang_option_value() */
26 typedef enum {
27 	self_close_singleton_tags,
28 	lang_is_XHTML
29 } Tlangoptions;
30 gboolean get_curlang_option_value(Tbfwin *bfwin, Tlangoptions option);
31 
32 /* these will slowly be replaced by vars in bfwin->session */
33 typedef struct {
34 /*        GList *classlist;
35         GList *colorlist;
36         GList *targetlist;
37         GList *urllist;
38         GList *fontlist;*/
39 	GList *positionlist;
40 } Trecent_attribs;
41 extern Trecent_attribs recent_attribs;
42 
43 typedef struct {
44 	GtkWidget *name;
45 	GtkWidget *val;
46 	GtkWidget *dest;
47 	gint type;
48 } Tphpvarins;					/* this struct contains a src and dest widget for PHP variable generation */
49 
50 typedef struct {
51 	gchar *item;
52 	gchar *value;
53 } Ttagitem;
54 
55 typedef struct {
56 	GList *taglist;
57 	gint pos;
58 	gint end;
59 } Ttagpopup;
60 
61 typedef struct {
62 	gint pos;
63 	gint end;
64 } Treplacerange;
65 
66 /* the frame wizard uses dynamic widgets, this value should be lower
67 then (number of combo's)/2 or lower then (number of clist's)
68 else the dialog will segfault */
69 #define MAX_FRAMES_IN_FRAMEWIZARD 5
70 
71 typedef struct {
72 	GtkWidget *dialog;
73 	GtkWidget *vbox;
74 	GtkWidget *obut;
75 	GtkWidget *cbut;
76 	GtkWidget *entry[20];
77 	GtkWidget *combo[11];
78 	GtkWidget *radio[14];
79 	GtkWidget *spin[8];
80 	GtkWidget *check[8];
81 	GtkWidget *clist[5];
82 	GtkWidget *text[1];
83 	GtkWidget *attrwidget[20];	/* all attribute widgets should go in here */
84 	Treplacerange range;
85 	GtkTextMark *mark_ins;
86 	GtkTextMark *mark_sel;
87 	Tphpvarins php_var_ins;
88 	GtkWidget *phpbutton;
89 	gboolean tobedestroyed;		/* this will be set to TRUE on destroy */
90 	Tdocument *doc;
91 	Tbfwin *bfwin;
92 } Thtml_diag;
93 
94 void html_diag_destroy_cb(GtkWidget * widget, Thtml_diag * dg);
95 
96 void html_diag_cancel_clicked_cb(GtkWidget * widget, gpointer data);
97 
98 Thtml_diag *html_diag_new(Tbfwin * bfwin, gchar * title);
99 GtkWidget *html_diag_table_in_vbox(Thtml_diag * dg, gint rows, gint cols);
100 void html_diag_finish(Thtml_diag * dg, GCallback ok_func);
101 
102 GtkWidget *html_diag_combobox_with_popdown(const gchar *setstring, GList *poplist, gboolean editable);
103 GtkWidget *html_diag_combobox_with_popdown_sized(const gchar *setstring, GList *poplist, gboolean editable, gint width);
104 
105 
106 void parse_html_for_dialogvalues(gchar * dialogitems[], gchar * dialogvalues[]
107 								 , gchar ** custom, Ttagpopup * data);
108 void fill_dialogvalues(gchar * dialogitems[], gchar * dialogvalues[]
109 					   , gchar ** custom, Ttagpopup * data, Thtml_diag * diag);
110 
111 void parse_existence_for_dialog(gchar * valuestring, GtkWidget * checkbox);
112 void parse_integer_for_dialog(gchar * valuestring, GtkWidget * spin, GtkWidget * entry, GtkWidget * checkbox);
113 gchar *insert_string_if_string(const gchar * inputstring, gchar * itemname, gchar * string2add2,
114 							   const gchar * defaultvalue);
115 gchar *insert_string_if_entry(GtkEntry * entry, gchar * itemname, gchar * string2add2, gchar * defaultvalue);
116 gchar *insert_string_if_combobox(GtkComboBox * combobox, gchar * itemname, gchar * string2add2,
117 								 gchar * defaultvalue);
118 gchar *insert_integer_if_spin(GtkWidget * spin, gchar * itemname, gchar * string2add2, gboolean ispercentage,
119 							  gint dontinsertonvalue);
120 gchar *insert_if_spin(GtkWidget *spin, gchar * itemname, gchar * string2add2, gboolean ispercentage);
121 gchar *insert_attr_if_checkbox(GtkWidget * checkbox, gchar * itemname, gchar * string2add2);
122 gchar *format_entry_into_string(GtkEntry * entry, gchar * formatstring);
123 GList *add_entry_to_stringlist(GList * which_list, GtkWidget * entry);
124 
125 GtkWidget *generic_table_inside_notebookframe(GtkWidget * notebook, const gchar * title, gint rows,
126 											  gint cols);
127 void generic_class_id_style_section(Thtml_diag * dg, gint firstattrwidget, GtkWidget * table,
128 									gint firstrowintable, gchar ** tagvalues, gint firsttagvalue);
129 
130 #endif							/* __HTML_DIAG_H_ */
131