Initial support for full-text searching
[maemopadplus.git] / src / ui / interface.h
blob12704ed32aea3cdbff92b367672a2935fe33111a
1 /*
2 * This file is part of maemopad+
5 * This software is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation; either version 2.1 of
8 * the License, or (at your option) any later version.
10 * This software is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this software; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 * 02110-1301 USA
22 #ifndef INTERFACE_H
23 #define INTERFACE_H
25 #include <gtk/gtk.h>
26 #include <appdata.h>
27 #include <sqlite3.h>
28 #include <ui/sketchwidget.h>
29 #include <config.h>
31 /**
32 * If you want to have finger-friendly support (i.e. big fonts in
33 * checklists, big scrollbars in checklists, texts and sketches),
34 * uncomment the following #define line.
35 **/
36 /* #define MAEMOPADPLUS_FINGER_FRIENDLY */
37 #define MAEMOPADPLUS_FINGER_FONT "sans 20"
39 #include <hildon/hildon-program.h>
40 #include <hildon/hildon-color-button.h>
41 #include <wptextview.h>
42 #include <wptextbuffer.h>
44 #define NEW_SEL_LOGIC
45 #define EXPANDING_ROWS
48 #ifndef EXPANDING_ROWS
49 #error EXPANDING_ROWS is needed for NEW_SEL_LOGIC
50 #endif
52 #define _(String) gettext(String)
54 #define USE_TEMP_TABLES
56 #ifdef USE_TEMP_TABLES
57 #define TEMPTABLE_KEYWORD " TEMP"
58 #else
59 #define TEMPTABLE_KEYWORD ""
60 #endif
63 * confirmation responses
65 #define CONFRESP_YES 1
66 #define CONFRESP_NO 2
67 #define CONFRESP_OK 3
68 #define CONFRESP_CANCEL 4
69 #define CONFRESP_ERROR 5
71 #define BRUSHSIZE_COUNT 7
73 #define SKETCHNODE_X 288
74 #define SKETCHNODE_Y 96
75 #define SKETCHNODE_RX 144
76 #define SKETCHNODE_RY 48
78 typedef enum
80 NODE_UNKNOWN = 0,
81 NODE_TEXT,
82 NODE_SKETCH,
83 NODE_CHECKLIST
84 } nodeType;
86 typedef enum
88 NODEFLAG_NONE = 0,
89 NODEFLAG_SKETCHLINES = 1 << 0,
90 NODEFLAG_SKETCHGRAPH = 1 << 1,
91 NODEFLAG_WORDWRAP = 1 << 2
93 * NODEFLAG_OTHER = 1 << 3
94 * NODEFLAG_OTHER2 = 1 << 4
96 } nodeFlag;
98 enum
100 NODE_NAME,
101 NODE_PIXBUF,
102 NODE_DATA,
103 NODE_BGCOLOR,
104 N_COLUMNS
107 enum
109 CHECKNODE_CHECKED,
110 CHECKNODE_TEXT,
111 CHECKNODE_COLOR,
112 CHECKNODE_BOLD,
113 CHECKNODE_STRIKE,
114 CHECKN_COLUMNS
117 typedef enum
119 CHECKSTYLE_CHECKED = 1 << 0,
120 CHECKSTYLE_BOLD = 1 << 1,
121 CHECKSTYLE_STRIKE = 1 << 2
122 } checklistStyle;
124 typedef struct _nodeData nodeData;
125 struct _nodeData
127 unsigned int sql3id;
129 nodeType typ;
130 gchar *name;
131 GdkPixbuf *namepix;
133 unsigned long lastMod;
134 unsigned int flags;
141 * Struct to include view's information
143 typedef struct _MainView MainView;
144 struct _MainView
147 * Handle to app's data
149 AppData *data;
151 guint viewflags;
152 /*old (guint fullscreen): 0:normal 1:notree-normal 2:normal-full 3:notree-full 4:justdoc-full */
153 /*new (guint viewflags): 1:tree 2:toolbar 4:fullscreen*/
156 * Items for menu
158 GtkWidget *file_item;
159 GtkWidget *tools_item;
160 GtkWidget *new_node_item;
161 GtkWidget *delete_node_item;
162 GtkWidget *rename_node_item;
163 GtkWidget *expand_collapse_node_item;
164 GtkWidget *export_node_item;
165 GtkWidget *move_node_item;
166 GtkWidget *move_up_node_item;
167 GtkWidget *move_down_node_item;
168 GtkWidget *move_to_bottom_node_item;
169 GtkWidget *move_to_top_node_item;
170 GtkWidget *new_item;
171 GtkWidget *open_item;
172 GtkWidget *save_item;
173 GtkWidget *edit_item;
174 GtkWidget *cut_item;
175 GtkWidget *copy_item;
176 GtkWidget *paste_item;
177 GtkWidget *clear_item;
178 GtkWidget *tools_brushsize;
179 GtkWidget *tools_pagestyle;
180 GtkWidget *tools_shape;
181 GtkWidget *tools_font;
182 GtkWidget *tools_wordwrap;
183 GtkWidget *tools_color;
184 GtkWidget *tools_pressure;
185 GtkWidget *view_item;
187 GtkWidget *brushsizemenu;
188 GtkWidget *sketchlinesmenu;
189 GtkWidget *viewmenu;
190 GtkWidget *shapemenu;
193 * Toolbar
195 GtkWidget *toolbar;
196 GtkWidget *iconw;
198 GtkToolItem *toggletree_tb;
200 GtkToolItem *new_tb;
203 * GtkToolItem* open_tb;
205 GtkToolItem *save_tb;
206 GtkToolItem *separator_tb1;
209 * GtkToolItem* cut_tb;
210 * GtkToolItem* copy_tb;
211 * GtkToolItem* paste_tb;
212 * GtkToolItem* separator_tb2;
214 GtkToolItem *bold_tb, *italic_tb, *underline_tb, *bullet_tb, *strikethru_tb, *check_tb, *checkadd_tb, *checkdel_tb;
216 GtkToolItem *font_tb;
217 GtkWidget *colorbutton;
218 GtkToolItem *colorbutton_tb;
219 GtkWidget *viewmenuitems[3];
221 GtkToolItem *brushsize_tb;
222 GtkWidget *brushsizemenuitems[BRUSHSIZE_COUNT];
224 GtkToolItem *eraser_tb;
226 GtkToolItem *sketchlines_tb;
227 GtkWidget *sketchlinesmenuitems[3];
229 GtkToolItem *undo_tb;
230 GtkToolItem *redo_tb;
232 GtkToolItem *shape_tb;
233 GtkWidget *shapemenuitems[4];
235 GtkEntry *search_entry;
238 * Textview related
240 GtkWidget *scrolledwindow; /* textview is under this widget */
241 GtkWidget *textview; /* widget that shows the text */
242 WPTextBuffer *buffer; /* buffer that contains the text */
243 GtkClipboard *clipboard; /* clipboard for copy/paste */
245 GtkWidget *listscroll; /* checklist is under this widget */
246 GtkWidget *listview; /*checklist */
247 GtkTreeViewColumn *listtextcol;
249 GtkWidget *treeview;
250 GtkWidget *scrolledtree; /* scrolledwindow for the tree */
251 GtkWidget *hpaned; /* hpaned between tree and document */
253 SketchWidget *sk;
254 guint brushsize_backup;
256 GdkCursor *cursorBusy;
257 guint busyrefcount;
259 gboolean file_edited; /* for node operations and notification of new stuff in tmptable */
260 gchar *file_name;
261 gboolean loading;
263 /* For highlighting searches */
264 char* color_highlight;
266 sqlite3 *db;
268 #ifdef NEW_SEL_LOGIC
269 nodeData *cansel_node;
270 guint32 cansel_time;
271 #endif
273 gboolean newnodedialog_createchild;
277 /* Initial size and increment for the search result node ID array */
278 #define SEARCH_RESULTS_ARRAY_SIZE 64
280 /* Saves the found node IDs after a search */
281 typedef struct _SearchResults SearchResults;
282 struct _SearchResults {
283 int *ids;
284 int current_size;
285 int index;
286 MainView *main_view;
290 #define datatable_name "nodes"
291 #define datatable_tmpname "tmpnodes"
292 #define datatable_backupname "nodesbackup"
294 #define datatable "( \
295 nodeid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, \
296 parent INTEGER NOT NULL DEFAULT 0, \
297 bodytype INTEGER NOT NULL DEFAULT 0, \
298 name TEXT, \
299 body TEXT, \
300 nameblob BLOB, \
301 bodyblob BLOB, \
302 lastmodified INTEGER NOT NULL DEFAULT 0, \
303 ord INTEGER NOT NULL DEFAULT 0, \
304 flags INTEGER NOT NULL DEFAULT 0);"
306 #define dataindex "(parent, ord);"
308 #define misctable_name "settings"
309 #define misctable "(skey TEXT UNIQUE, sval TEXT);"
311 #define datatableversion 1
313 #define checklisttable_name "checklists"
314 #define checklisttable_tmpname "tmpchecklists"
315 #define checklisttable_backupname "checklistsbackup"
317 #define checklisttable "( \
318 idx INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, \
319 nodeid INTEGER NOT NULL DEFAULT 0, \
320 name TEXT, \
321 style INTEGER NOT NULL DEFAULT 0, \
322 color INTEGER NOT NULL DEFAULT 0, \
323 ord INTEGER NOT NULL DEFAULT 0);"
324 #define checklistindex "(nodeid, ord);"
326 #define checklisttableversion 1
329 * Publics:
331 void sk_set_brushsize(MainView * main, guint bsize);
332 void _toggle_tool_button_set_inconsistent(GtkToggleToolButton *button, gboolean inconsistent);
333 MainView *interface_main_view_new(AppData * data);
334 void interface_main_view_destroy(MainView * main);
335 gchar *interface_file_chooser(MainView * mainview, GtkFileChooserAction action, gchar * suggname, gchar * suggext);
336 gint interface_create_new_file(MainView * main);
338 #endif