1 #ifndef _GNM_WBC_GTK_IMPL_H_
2 # define _GNM_WBC_GTK_IMPL_H_
3 
4 #include <gnumeric.h>
5 #include <wbc-gtk.h>
6 #include <workbook-control-priv.h>
7 #include <style.h>
8 #include <widgets/gnm-expr-entry.h>
9 #include <widgets/gnm-notebook.h>
10 #include <gui-util.h>
11 
12 #include <goffice/goffice.h>
13 
14 G_BEGIN_DECLS
15 
16 struct _WBCGtk {
17 	WorkbookControl	base;
18 
19 	GtkWidget   *toplevel;
20 
21 	GtkBuilder  *gui;
22 
23 	/* The area that contains the sheet and the sheet tabs.  */
24 	GtkWidget   *notebook_area;
25 
26 	/* The notebook that contains the sheets.  */
27 	GtkNotebook *snotebook;
28 
29 	/* The notebook that contains the sheet tabs.  */
30 	GnmNotebook *bnotebook;
31 
32 	/* The GtkPaned that contains the sheet tabs and the status area.  */
33 	GtkPaned    *tabs_paned;
34 
35 	GtkWidget   *progress_bar;
36 
37 	struct {
38 		GnmExprEntry *entry; /* The real edit line */
39 		GnmExprEntry *temp_entry; /* A tmp overlay eg from a guru */
40 		GtkWidget *guru;
41 		gulong         signal_changed, signal_insert, signal_delete;
42 		gulong         signal_cursor_pos, signal_selection_bound;
43 		PangoAttrList *cell_attrs;   /* Attrs from cell format. */
44 		PangoAttrList *markup;	     /* just the markup */
45 		PangoAttrList *full_content; /* cell_attrs+markup */
46 		PangoAttrList *cur_fmt;	/* attrs for new text (depends on position) */
47 	} edit_line;
48 
49 	/* While editing these should be visible */
50 	GtkWidget *ok_button, *cancel_button;
51 
52 	/* While not editing these should be visible */
53 	GtkWidget *func_button;
54 
55 	gboolean    updating_ui;
56 	gboolean    inside_editing;
57 
58 	/* Auto completion */
59 	GnmComplete	*auto_complete;
60 	gboolean	 auto_completing;
61 	char		*auto_complete_text;
62 
63 	/* Used to detect if the user has backspaced, so we turn off auto-complete */
64 	int              auto_max_size;
65 
66 	/* Keep track of whether the last key pressed was END, so end-mode works */
67 	gboolean last_key_was_end;
68 
69 	SheetControlGUI *rangesel;
70 
71 	GtkWidget  *table;
72 	GtkWidget  *auto_expr_label;
73 	GtkWidget  *status_text;
74 
75 	/* Widgets whose visibility should be copied.  */
76 	GHashTable *visibility_widgets;
77 
78 	gboolean is_fullscreen;
79 	GOUndo *undo_for_fullscreen;
80 	GSList *hide_for_fullscreen;
81 
82 	/* Edit area */
83 	GtkWidget *selection_descriptor;	/* A GtkEntry */
84 
85 	/* Autosave */
86         gboolean   autosave_prompt;
87         gint       autosave_time;
88         guint      autosave_timer;
89 
90 	PangoFontDescription *font_desc;
91 
92 	SheetControlGUI *active_scg;
93 	gulong sig_view_changed;
94 	gulong sig_auto_expr_text, sig_auto_expr_attrs;
95 	gulong sig_show_horizontal_scrollbar, sig_show_vertical_scrollbar;
96 	gulong sig_show_notebook_tabs;
97 	gulong sig_sheet_order, sig_notify_uri, sig_notify_dirty;
98 	gpointer sig_wbv;
99 
100 /**********************************************/
101 	GtkWidget	 *status_area;
102 	GtkUIManager     *ui;
103 	GtkActionGroup   *permanent_actions, *actions, *font_actions,
104 			 *data_only_actions, *semi_permanent_actions;
105 	struct {
106 		GtkActionGroup   *actions;
107 		guint		  merge_id;
108 	} file_history, toolbar, windows, templates;
109 
110 	guint template_loader_handler;
111 
112 	GOActionComboStack	*undo_haction, *redo_haction;
113 	GtkAction		*undo_vaction, *redo_vaction;
114 	GOActionComboColor	*fore_color, *back_color;
115 	GtkAction               *font_name_haction, *font_name_vaction;
116 	GOActionComboText	*zoom_haction;
117 	GtkAction               *zoom_vaction;
118 	GOActionComboPixmaps	*borders, *halignment, *valignment;
119 	struct {
120 		GtkToggleAction	 *bold, *italic, *underline, *d_underline,
121 			*sl_underline, *dl_underline;
122 		GtkToggleAction	 *superscript, *subscript, *strikethrough;
123 	} font;
124 	struct {
125 		GtkToggleAction	 *left, *center, *right, *center_across_selection;
126 	} h_align;
127 	struct {
128 		GtkToggleAction	 *top, *center, *bottom;
129 	} v_align;
130 
131 	GtkWidget *menu_zone, *toolbar_zones[4];
132 	GHashTable *custom_uis;
133 
134 	guint idle_update_style_feedback;
135 
136 	/* When editing a cell: the cell (may be NULL) */
137 	GnmCell     *editing_cell;
138 	Sheet       *editing_sheet;
139 	gboolean     editing;
140 
141 	SheetObject	 *new_object;	/* A newly created object that has yet to be realized */
142 
143 	char *preferred_geometry;
144 };
145 
146 typedef struct {
147 	WorkbookControlClass base;
148 
149 	/* signals */
150 	void (*markup_changed)		(WBCGtk const *wbcg);
151 } WBCGtkClass;
152 
153 #define GNM_RESPONSE_SAVE_ALL -1000
154 #define GNM_RESPONSE_DISCARD_ALL -1001
155 
156 /* Protected functions */
157 gboolean wbc_gtk_close		(WBCGtk *wbcg);
158 void	 wbcg_insert_sheet	(GtkWidget *ignored, WBCGtk *wbcg);
159 void	 wbcg_append_sheet	(GtkWidget *ignored, WBCGtk *wbcg);
160 void	 wbcg_clone_sheet	(GtkWidget *ignored, WBCGtk *wbcg);
161 
162 void	 wbc_gtk_init_editline	(WBCGtk *wbcg);
163 void	 wbc_gtk_init_actions	(WBCGtk *wbcg);
164 void	 wbc_gtk_markup_changer	(WBCGtk *wbcg);
165 
166 void     wbcg_font_action_set_font_desc (GtkAction *act, PangoFontDescription *desc);
167 
168 gboolean wbc_gtk_load_templates (WBCGtk *gtk);
169 
170 GtkAction *wbcg_find_action (WBCGtk *wbcg, const char *name);
171 
172 G_MODULE_EXPORT void set_uifilename (char const *name, GnmActionEntry const *actions, int nb);
173 
174 G_END_DECLS
175 
176 #endif /* _GNM_WBC_GTK_IMPL_H_ */
177