Select the correct item for a main view longpress
[maepad.git] / src / ui / interface.h
blob4806537b94d60285aaa769e4505e907a38c1741a
1 /*
2 * This file is part of MaePad
3 * Copyright (c) 2010 Thomas Perl <thp@thpinfo.com>
4 * http://thpinfo.com/2010/maepad/
6 * Based on Maemopad+:
7 * Copyright (c) 2006-2008 Kemal Hadimli
8 * Copyright (c) 2008 Thomas Perl
10 * This software is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public License
12 * as published by the Free Software Foundation; either version 2.1 of
13 * the License, or (at your option) any later version.
15 * This software is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this software; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23 * 02110-1301 USA
27 #ifndef INTERFACE_H
28 #define INTERFACE_H
30 #include <gtk/gtk.h>
31 #include <appdata.h>
32 #include <sqlite3.h>
33 #include <ui/sketchwidget.h>
34 #include <config.h>
36 #include "../he/he-fullscreen-button.h"
38 /**
39 * If you want to have finger-friendly support (i.e. big fonts in
40 * checklists, big scrollbars in checklists, texts and sketches),
41 * uncomment the following #define line.
42 **/
43 /* #define MAEMOPADPLUS_FINGER_FRIENDLY */
44 #define MAEMOPADPLUS_FINGER_FONT "sans 20"
46 #include <hildon/hildon-program.h>
47 #include <hildon/hildon-color-button.h>
48 #include <wptextview.h>
49 #include <wptextbuffer.h>
51 #define NEW_SEL_LOGIC
52 #define EXPANDING_ROWS
55 #ifndef EXPANDING_ROWS
56 #error EXPANDING_ROWS is needed for NEW_SEL_LOGIC
57 #endif
59 #define _(String) gettext(String)
61 #define USE_TEMP_TABLES
63 #ifdef USE_TEMP_TABLES
64 #define TEMPTABLE_KEYWORD " TEMP"
65 #else
66 #define TEMPTABLE_KEYWORD ""
67 #endif
69 typedef enum {
70 RESPONSE_CREATE_NEW = 1,
71 RESPONSE_OPEN_FILE,
72 RESPONSE_QUIT,
73 } SetupResponse;
76 * confirmation responses
78 #define CONFRESP_YES 1
79 #define CONFRESP_NO 2
80 #define CONFRESP_OK 3
81 #define CONFRESP_CANCEL 4
82 #define CONFRESP_ERROR 5
84 #define BRUSHSIZE_COUNT 7
86 #define SKETCHNODE_X 288
87 #define SKETCHNODE_Y 96
88 #define SKETCHNODE_RX 144
89 #define SKETCHNODE_RY 48
91 typedef enum
93 NODE_UNKNOWN = 0,
94 NODE_TEXT,
95 NODE_SKETCH,
96 NODE_CHECKLIST
97 } nodeType;
99 typedef enum
101 NODEFLAG_NONE = 0,
102 NODEFLAG_SKETCHLINES = 1 << 0,
103 NODEFLAG_SKETCHGRAPH = 1 << 1,
104 NODEFLAG_WORDWRAP = 1 << 2
106 * NODEFLAG_OTHER = 1 << 3
107 * NODEFLAG_OTHER2 = 1 << 4
109 } nodeFlag;
111 enum
113 NODE_NAME,
114 NODE_PIXBUF,
115 NODE_DATA,
116 N_COLUMNS
119 enum
121 CHECKNODE_CHECKED,
122 CHECKNODE_TEXT,
123 CHECKNODE_COLOR,
124 CHECKNODE_BOLD,
125 CHECKNODE_STRIKE,
126 CHECKNODE_ICON_NAME,
127 CHECKN_COLUMNS
130 typedef enum
132 CHECKSTYLE_CHECKED = 1 << 0,
133 CHECKSTYLE_BOLD = 1 << 1,
134 CHECKSTYLE_STRIKE = 1 << 2
135 } checklistStyle;
137 typedef struct _nodeData nodeData;
138 struct _nodeData
140 unsigned int sql3id;
142 nodeType typ;
143 gchar *name;
144 GdkPixbuf *namepix;
146 unsigned long lastMod;
147 unsigned int flags;
151 * Struct to include view's information
153 typedef struct _MainView MainView;
154 struct _MainView
157 * Handle to app's data
159 AppData *data;
162 * Items for menu
164 GtkWidget *tools_item;
165 GtkWidget *delete_node_item;
166 GtkWidget *rename_node_item;
167 GtkWidget *export_node_item;
168 GtkWidget *move_node_item;
169 GtkWidget *move_up_node_item;
170 GtkWidget *move_down_node_item;
171 GtkWidget *move_to_bottom_node_item;
172 GtkWidget *move_to_top_node_item;
173 GtkWidget *tools_brushsize;
174 GtkWidget *tools_pagestyle;
175 GtkWidget *tools_shape;
176 GtkWidget *tools_font;
177 GtkWidget *tools_wordwrap;
178 GtkWidget *tools_color;
179 GtkWidget *tools_pressure;
181 GtkWidget *brushsizemenu;
182 GtkWidget *sketchlinesmenu;
183 GtkWidget *shapemenu;
186 * Toolbar
188 GtkWidget *toolbar;
189 GtkWidget *iconw;
192 * GtkToolItem* cut_tb;
193 * GtkToolItem* copy_tb;
194 * GtkToolItem* paste_tb;
195 * GtkToolItem* separator_tb2;
197 GtkToolItem *bold_tb, *italic_tb, *underline_tb, *bullet_tb, *strikethru_tb, *check_tb, *checkadd_tb, *checkedit_tb, *checkdel_tb;
199 GtkToolItem *font_tb;
200 GtkToolItem *colorbutton_tb;
202 GdkColor* current_color;
204 GtkToolItem *brushsize_tb;
205 GtkWidget *brushsizemenuitems[BRUSHSIZE_COUNT];
207 GtkToolItem *eraser_tb;
209 GtkToolItem *sketchlines_tb;
210 GtkWidget *sketchlinesmenuitems[3];
212 GtkToolItem *undo_tb;
213 GtkToolItem *redo_tb;
215 GtkToolItem *shape_tb;
216 GtkWidget *shapemenuitems[4];
218 GtkToolItem* fullscreen_tb;
221 * Textview related
223 GtkWidget *scrolledwindow; /* textview is under this widget */
224 GtkWidget *textview; /* widget that shows the text */
225 WPTextBuffer *buffer; /* buffer that contains the text */
226 GtkClipboard *clipboard; /* clipboard for copy/paste */
228 GtkWidget *listscroll; /* checklist is under this widget */
229 GtkWidget *listview; /*checklist */
230 GtkTreeViewColumn *listtextcol;
232 gboolean checklist_edited; /* set to TRUE when the checklist is "dirty" and needs to be saved */
234 GtkWidget *treeview;
235 GtkWidget *scrolledtree; /* scrolledwindow for the tree */
236 GtkWidget* action_area_button_add; /* "Add new node" button in action area */
238 /* Node list item on which a longpress has been carried out */
239 GtkTreePath* node_list_longpress_path;
241 SketchWidget *sk;
243 /* AppMenu stuff */
244 GtkWidget* main_view_app_menu;
245 GtkWidget* menu_button_new;
246 GtkWidget* menu_button_open;
247 GtkWidget* menu_button_save;
248 GtkWidget* menu_button_about;
250 GtkWidget* node_view_app_menu;
251 GtkWidget* menu_button_rename;
252 GtkWidget* menu_button_delete;
253 GtkWidget* menu_button_export;
254 GtkWidget* menu_button_clear;
255 GtkWidget* menu_button_square;
256 GtkWidget* menu_button_filled;
257 /* End AppMenu stuff */
259 gboolean can_show_node_view;
261 HeFullscreenButton* node_view_fullscreen_button;
263 guint busyrefcount;
265 gboolean file_edited; /* for node operations and notification of new stuff in tmptable */
266 gchar *file_name;
267 gboolean loading;
269 sqlite3 *db;
271 #ifdef NEW_SEL_LOGIC
272 nodeData *cansel_node;
273 guint32 cansel_time;
274 #endif
276 gboolean newnodedialog_createchild;
279 #define datatable_name "nodes"
280 #define datatable_tmpname "tmpnodes"
281 #define datatable_backupname "nodesbackup"
283 #define datatable "( \
284 nodeid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, \
285 parent INTEGER NOT NULL DEFAULT 0, \
286 bodytype INTEGER NOT NULL DEFAULT 0, \
287 name TEXT, \
288 body TEXT, \
289 nameblob BLOB, \
290 bodyblob BLOB, \
291 lastmodified INTEGER NOT NULL DEFAULT 0, \
292 ord INTEGER NOT NULL DEFAULT 0, \
293 flags INTEGER NOT NULL DEFAULT 0);"
295 #define dataindex "(parent, ord);"
297 #define misctable_name "settings"
298 #define misctable "(skey TEXT UNIQUE, sval TEXT);"
300 #define datatableversion 1
302 #define checklisttable_name "checklists"
303 #define checklisttable_tmpname "tmpchecklists"
304 #define checklisttable_backupname "checklistsbackup"
306 #define checklisttable "( \
307 idx INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, \
308 nodeid INTEGER NOT NULL DEFAULT 0, \
309 name TEXT, \
310 style INTEGER NOT NULL DEFAULT 0, \
311 color INTEGER NOT NULL DEFAULT 0, \
312 ord INTEGER NOT NULL DEFAULT 0);"
313 #define checklistindex "(nodeid, ord);"
315 #define checklisttableversion 1
318 * Publics:
320 void sk_set_brushsize(MainView * main, guint bsize);
321 void _toggle_tool_button_set_inconsistent(GtkToggleToolButton *button, gboolean inconsistent);
322 MainView *interface_main_view_new(AppData * data);
323 void interface_main_view_destroy(MainView * main);
324 gchar *interface_file_chooser(MainView * mainview, GtkFileChooserAction action, gchar * suggname, gchar * suggext);
326 /* Get the window that should be used as parent for dialogs */
327 GtkWindow*
328 mainview_get_dialog_parent(MainView* mainview);
330 SetupResponse interface_initial_setup(MainView* main);
332 #endif