~ubuntu-branches/ubuntu/natty/bluefish/natty-proposed

« back to all changes in this revision

Viewing changes to src/menu.c

  • Committer: Bazaar Package Importer
  • Author(s): Davide Puricelli (evo)
  • Date: 2005-04-23 17:05:18 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20050423170518-pb8zi3vg32cm6g04
Tags: 1.0-1
* Acknowledge NMU, thanks Leo; closes: #291222.
* Updated debian/ files, thanks Daniel Leidert. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Bluefish HTML Editor
2
 
 * menu.c - the home of the pulldowns
3
 
 *
4
 
 * Copyright (C) 1998-2001 Olivier Sessink, Chris Mazuc and Roland Steinbach
 
1
/* Copyright (C) 1998-2000 Olivier Sessink, Chris Mazuc and Roland Steinbach
 
2
 * Copyright (C) 2000-2002 Olivier Sessink and Roland Steinbach
 
3
 * Copyright (C) 2002-2004 Olivier Sessink
 
4
 * this file has 
 
5
 * content-type: UTF8 
 
6
 * and it is important you keep it UTF-8 !!!
5
7
 *
6
8
 * This program is free software; you can redistribute it and/or modify
7
9
 * it under the terms of the GNU General Public License as published by
17
19
 * along with this program; if not, write to the Free Software
18
20
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
21
 */
20
 
#include "config.h"
21
 
#include "default_include.h"
22
 
 
23
 
#include <string.h>
24
 
#include <dirent.h>
25
 
#include <sys/types.h>
26
 
 
27
 
#include <stdio.h>
28
 
#include <stdlib.h>
 
22
#include <gtk/gtk.h>
 
23
#include <stdlib.h> /* atoi */
 
24
#include <string.h> /* strchr() */
 
25
#include <gdk/gdkkeysyms.h>
 
26
 
 
27
/* #define DEBUG */
29
28
 
30
29
#include "bluefish.h"
31
 
#include "bf_lib.h"
32
 
#include "callbacks.h"  /* repeat_last_insert_cb , view_in_netscape_cb*/
 
30
#include "bfspell.h"
 
31
#include "bookmark.h"
 
32
#include "pixmap.h"
 
33
#include "document.h"                   /* file_open etc. */
 
34
#include "highlight.h" /* doc_highlight_full */
 
35
#include "menu.h" /* my own .h file */
 
36
#include "undo_redo.h" /* undo_cb() redo_cb() etc. */
 
37
#include "snr2.h" /* search_cb, replace_cb */
 
38
#include "gui.h" /* go_to_line_win_cb */
 
39
#include "stringlist.h"         /* free_stringlist() */
 
40
#include "bf_lib.h"  /* append_string_to_file() */
 
41
#include "gtk_easy.h" /* window_full, bf_stock_ok_button */
 
42
#include "preferences.h" /* open_preferences_menu_cb */
33
43
#include "html.h"
 
44
#include "html2.h"
 
45
#include "html_table.h"
34
46
#include "html_form.h"
35
 
#include "html_table.h"
36
 
#include "coloursel.h"  /* sel_colour_cb() */
37
 
#include "html2.h"
38
 
#include "javascript.h"
39
 
#include "document.h"                   /* file_open etc. */
40
 
#include "project.h"            /* project_open etc. */
41
 
#include "interface.h"                  /* show_about_window_cb() */
42
 
#include "stringlist.h"                 /* edit_stringlist() */
43
 
#include "init.h"                               /* save_config_files() */
44
 
#include "snr2.h"                               /* the new search and replace */
45
 
#include "wml.h"
46
 
#include "images.h"
47
47
#include "wizards.h"
48
 
#include "ref_dialog.h"
49
 
#include "configure.h"
50
 
#include "bf_perl.h"
51
 
#include "menu.h" /* my own .h file */
52
 
 
53
 
#ifdef UNDO2
54
 
#include "undo2.h"
55
 
#else
56
 
#include "undo.h"
57
 
#endif /* UNDO2 */
58
 
 
59
 
#include "gtk_easy.h"
60
 
#include "highlight.h"
61
 
#include "toolbars.h"
62
 
 
63
 
 
64
 
/***************************************************************************/
65
 
void save_menu_shortcuts();
66
 
void load_menu_shortcuts();
67
 
static void edit_some_list_lcb(GtkWidget * widget, gpointer data);
68
 
#ifdef ENABLE_NLS
69
 
gchar *menu_translate(const gchar * path, gpointer data);
70
 
#endif /* ENABLE_NLS */
71
 
static void insert_char_cb(GtkWidget * widget, gint data);
72
 
void get_main_menu(GtkWidget * window, GtkWidget ** menubar);
73
 
 
74
 
 
75
 
/***************************************************************************/
76
 
#ifdef IMAGEMAP_EDITOR_TEST
77
 
void make_imagemap_win(GtkWidget * widget, gpointer data);
78
 
#endif
79
 
 
80
 
/* I wish there was a better way to show he names of the different chars */
81
 
/* as in actually show them in parenthesis */
82
 
/* 
83
 
gtk_text accelerators are:
84
 
<control>a beginning of line
85
 
<control>e end
86
 
<control>n next line
87
 
<control>p previous line
88
 
<control>b left
89
 
<control>f right
90
 
<alt>b backwards one word
91
 
<alt>f forward one word
92
 
<control>h backspace
93
 
<control>d delete
94
 
<control>w delete backward word
95
 
<alt>d delete forward line
96
 
<control>k delete to end of line
97
 
<control>u delete line
98
 
 
99
 
<control>x cut
100
 
<control>c copy
101
 
<control>v paste
 
48
#include "image.h"
 
49
#include "rcfile.h" /* rcfile_save_configfile_menu_cb */
 
50
#include "rpopup.h"
 
51
#include "project.h"
 
52
#include "about.h"
 
53
 
 
54
#include "outputbox.h" /* temporary */
 
55
 
 
56
/*
 
57
The callback for an ItemFactory entry can take two forms. If callback_action is zero, it is of the following form:
 
58
void callback(void)
 
59
otherwise it is of the form:
 
60
void callback( gpointer callback_data,guint callback_action, GtkWidget *widget)
 
61
callback_data is a pointer to an arbitrary piece of data and is set during the call to gtk_item_factory_create_items().
 
62
 
 
63
we want to pass the Tbfwin* so we should never use a callback_action of zero
102
64
*/
 
65
static void menu_file_operations_cb(Tbfwin *bfwin,guint callback_action, GtkWidget *widget) {
 
66
        switch(callback_action) {
 
67
        case 1:
 
68
                file_new_cb(NULL,bfwin);
 
69
        break;
 
70
        case 2:
 
71
                file_open_cb(NULL,bfwin);
 
72
        break;
 
73
#ifdef EXTERNAL_GREP
 
74
#ifdef EXTERNAL_FIND
 
75
        case 3:
 
76
                file_open_advanced_cb(NULL,bfwin);
 
77
        break;
 
78
#endif
 
79
#endif
 
80
        case 4:
 
81
                doc_reload(bfwin->current_document);
 
82
        break;
 
83
        case 5:
 
84
                file_save_cb(NULL, bfwin);
 
85
        break;
 
86
        case 6:
 
87
                file_save_as_cb(NULL, bfwin);
 
88
        break;
 
89
        case 7:
 
90
                file_move_to_cb(NULL, bfwin);
 
91
        break;
 
92
        case 8:
 
93
                file_save_all_cb(NULL, bfwin);
 
94
        break;
 
95
        case 9:
 
96
                file_close_cb(NULL, bfwin);
 
97
        break;
 
98
        case 10:
 
99
                edit_cut_cb(NULL, bfwin);
 
100
        break;
 
101
        case 11:
 
102
                edit_copy_cb(NULL, bfwin);
 
103
        break;
 
104
        case 12:
 
105
                edit_paste_cb(NULL, bfwin);
 
106
        break;
 
107
        case 13:
 
108
                edit_select_all_cb(NULL, bfwin);
 
109
        break;
 
110
        case 14:
 
111
                search_cb(NULL, bfwin);
 
112
        break;
 
113
        case 16:
 
114
                search_again_cb(NULL, bfwin);
 
115
        break;
 
116
        case 17:
 
117
                replace_cb(NULL, bfwin);
 
118
        break;
 
119
        case 19:
 
120
                replace_again_cb(NULL, bfwin);
 
121
        break;
 
122
        case 20:
 
123
                undo_cb(NULL, bfwin);
 
124
        break;
 
125
        case 21:
 
126
                redo_cb(NULL, bfwin);
 
127
        break;
 
128
        case 22:
 
129
                undo_all_cb(NULL, bfwin);
 
130
        break;
 
131
        case 23:
 
132
                redo_all_cb(NULL, bfwin);
 
133
        break;
 
134
        case 24:
 
135
                file_close_all_cb(NULL,bfwin);
 
136
        break;
 
137
#ifdef HAVE_GNOME_VFS
 
138
        case 25:
 
139
                file_open_url_cb(NULL, bfwin);
 
140
        break;
 
141
#endif
 
142
        case 26:
 
143
                file_open_from_selection(bfwin);
 
144
        break;
 
145
        case 27:
 
146
                search_from_selection(bfwin);
 
147
        break;
 
148
        default:
 
149
                g_print("menu_file_operations_cb, unknown action, abort!\n");
 
150
                exit(123);
 
151
        }
 
152
}
 
153
static void menu_html_dialogs_lcb(Tbfwin *bfwin,guint callback_action, GtkWidget *widget) {
 
154
        switch (callback_action) {
 
155
        case 1:
 
156
                body_dialog(bfwin,NULL);
 
157
        break;
 
158
        case 2:
 
159
                DEBUG_MSG("menu_html_dialogs_lcb,calling quickanchor_dialog with bfwin=%p and data=NULL\n",bfwin);
 
160
                quickanchor_dialog(bfwin,NULL);
 
161
        break;
 
162
        case 3:
 
163
                email_dialog(bfwin,NULL);
 
164
        break;
 
165
        case 4:
 
166
                quickrule_dialog(bfwin,NULL);
 
167
        break;
 
168
        case 5:
 
169
                font_dialog(bfwin,NULL);
 
170
        break;
 
171
        case 6:
 
172
                basefont_dialog(bfwin,NULL);
 
173
        break;
 
174
        case 7:
 
175
                quicklist_dialog(bfwin,NULL);
 
176
        break;
 
177
        case 8:
 
178
                meta_dialog(bfwin,NULL);
 
179
        break;
 
180
        case 9:
 
181
                embed_dialog(bfwin,NULL);
 
182
        break;
 
183
        case 10:
 
184
                image_insert_dialog(bfwin,NULL);
 
185
        break;
 
186
        case 11:
 
187
                thumbnail_insert_dialog(bfwin);
 
188
        break;
 
189
        case 12:
 
190
                tablewizard_dialog(bfwin);
 
191
        break;
 
192
        case 13:
 
193
                tabledialog_dialog(bfwin,NULL);
 
194
        break;
 
195
        case 14:
 
196
                tablerowdialog_dialog(bfwin,NULL);
 
197
        break;
 
198
        case 15:
 
199
                tableheaddialog_dialog(bfwin,NULL);
 
200
        break;
 
201
        case 16:
 
202
                tabledatadialog_dialog(bfwin,NULL);
 
203
        break;
 
204
        case 17:
 
205
                span_dialog(bfwin,NULL);
 
206
        break;
 
207
        case 18:
 
208
                div_dialog(bfwin,NULL);
 
209
        break;
 
210
        case 19:
 
211
                framewizard_dialog(bfwin);
 
212
        break;
 
213
        case 20:
 
214
                frameset_dialog(bfwin,NULL);
 
215
        break;
 
216
        case 21:
 
217
                frame_dialog(bfwin,NULL);
 
218
        break;
 
219
        case 22:
 
220
                formdialog_dialog(bfwin,NULL);
 
221
        break;
 
222
        case 23:
 
223
                inputdialog_dialog(bfwin, NULL, "submit");
 
224
        break;
 
225
        case 24:
 
226
                inputdialog_dialog(bfwin, NULL, "text");
 
227
        break;
 
228
        case 25:
 
229
                buttondialog_dialog(bfwin, NULL);
 
230
        break;
 
231
        case 26:
 
232
                textareadialog_dialog(bfwin,NULL);
 
233
        break;
 
234
        case 29:
 
235
                selectdialog_dialog(bfwin,NULL);
 
236
        break;
 
237
        case 30:
 
238
                optiondialog_dialog(bfwin,NULL);
 
239
        break;
 
240
        case 31:
 
241
                optgroupdialog_dialog(bfwin,NULL);
 
242
        break;
 
243
        case 32:
 
244
                quickstart_dialog(bfwin,NULL);
 
245
        break;
 
246
        case 33:
 
247
                inputdialog_dialog(bfwin, NULL, NULL);
 
248
        break;
 
249
        case 34:
 
250
                insert_time_dialog(bfwin);
 
251
        break;
 
252
        case 35:
 
253
                linkdialog_dialog(bfwin,NULL);
 
254
        break;
 
255
        case 36:
 
256
                new_css_dialog(NULL,bfwin);
 
257
        case 37:
 
258
                sel_colour_cb(NULL,bfwin);      
 
259
        break;
 
260
        case 38:
 
261
                edit_tag_under_cursor_cb(bfwin);
 
262
        break;
 
263
        default:
 
264
                g_print("menu_file_operations_cb, unknown action, abort!\n");
 
265
                exit(123);
 
266
        }
 
267
}
 
268
#ifdef HAVE_LIBASPELL
 
269
static void spell_check_menu_cb(Tbfwin *bfwin,guint callback_action, GtkWidget *widget) {
 
270
        spell_check_cb(NULL, bfwin);
 
271
}
 
272
#endif /* HAVE_LIBASPELL */
 
273
 
 
274
static void menu_bmark_operations_cb(Tbfwin *bfwin,guint callback_action, GtkWidget *widget) {
 
275
        switch(callback_action) {
 
276
        case 1:
 
277
           bmark_add(bfwin);
 
278
        break;
 
279
/*      case 2:
 
280
           bmark_add_perm(bfwin);
 
281
        break;*/
 
282
        default:
 
283
                        g_print("Bmark action no. %d\n",callback_action);
 
284
        }
 
285
}
 
286
 
 
287
static void toggle_doc_property(Tbfwin *bfwin,guint callback_action, GtkWidget *widget) {
 
288
        switch(callback_action) {
 
289
        case 1:
 
290
                bfwin->current_document->wrapstate = GTK_CHECK_MENU_ITEM(widget)->active;
 
291
                doc_set_wrap(bfwin->current_document);
 
292
                break;
 
293
        case 2:
 
294
                bfwin->current_document->linenumberstate = GTK_CHECK_MENU_ITEM(widget)->active;
 
295
                document_set_line_numbers(bfwin->current_document, bfwin->current_document->linenumberstate);
 
296
                break;
 
297
        case 3:
 
298
                bfwin->current_document->autoclosingtag = GTK_CHECK_MENU_ITEM(widget)->active;
 
299
                break;
 
300
        case 4:
 
301
                main_v->props.autoindent = GTK_CHECK_MENU_ITEM(widget)->active;
 
302
                break;
 
303
        }
 
304
}
103
305
 
104
306
static GtkItemFactoryEntry menu_items[] = {
105
307
        {N_("/_File"), NULL, NULL, 0, "<Branch>"},
106
308
        {N_("/File/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
107
 
        {N_("/File/_New"), "F8", file_new_cb, 0, NULL},
108
 
        {N_("/File/_Open..."), "<control>O", file_open_cb, 0, NULL},
109
 
        {N_("/File/Open advanced..."), NULL, file_open_cb, 1, NULL},
110
 
        {N_("/File/Open from the web..."), NULL, open_from_web_cb, 0, NULL},
111
 
        {N_("/File/Open recent"), NULL, NULL, 0, "<Branch>"},
112
 
        {N_("/File/Open recent/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
113
 
        {N_("/File/Revert to saved"), NULL, revert_to_saved_cb, 0, NULL},
114
 
        {N_("/File/Insert..."), NULL, file_insert_cb, 0, NULL},
115
 
        {N_("/File/sep2"), NULL, NULL, 0, "<Separator>"},
116
 
        {N_("/File/_Save"), "<control>S", file_save_cb, 0, NULL},
117
 
        {N_("/File/Save _as..."), NULL, file_save_as_cb, 0, NULL},
118
 
        {N_("/File/Move to..."), NULL, file_move_to_cb, 0, NULL},
119
 
        {N_("/File/Save all"), NULL, file_save_all_cb, 0, NULL},
 
309
        {N_("/File/_New"), "<control>n", menu_file_operations_cb, 1, "<StockItem>", GTK_STOCK_NEW},
 
310
        {N_("/File/New _Window"), "<shift><control>n", gui_window_menu_cb, 1, "<Item>"},        
 
311
        {N_("/File/_Open..."), "<control>O", menu_file_operations_cb, 2, "<StockItem>", GTK_STOCK_OPEN},
 
312
        {N_("/File/Open _recent"), NULL, NULL, 0, "<Branch>"},
 
313
        {N_("/File/Open recent/tearoff1"), NULL, NULL, 0, "<Tearoff>"}, 
 
314
#ifdef EXTERNAL_GREP
 
315
#ifdef EXTERNAL_FIND
 
316
        {N_("/File/Open Ad_vanced..."), "<shift><control>O", menu_file_operations_cb, 3, "<Item>"},
 
317
#endif /* EXTERNAL_FIND */
 
318
#endif /* EXTERNAL_GREP */
 
319
#ifdef HAVE_GNOME_VFS
 
320
        {N_("/File/Open _URL..."), NULL, menu_file_operations_cb, 25, "<Item>"},
 
321
#endif /* HAVE_GNOME_VFS */
 
322
        {N_("/File/Open _from selection"), NULL, menu_file_operations_cb, 26, "<Item>"},
 
323
        {N_("/File/sep1"), NULL, NULL, 0, "<Separator>"},
 
324
        {N_("/File/_Save"), "<control>S", menu_file_operations_cb, 5, "<StockItem>", GTK_STOCK_SAVE},
 
325
        {N_("/File/Save _As..."), "<shift><control>S", menu_file_operations_cb, 6, "<StockItem>", GTK_STOCK_SAVE_AS},
 
326
        {N_("/File/Sav_e All"), NULL, menu_file_operations_cb, 8, "<Item>"},
 
327
        {N_("/File/Rever_t to Saved"), NULL, menu_file_operations_cb, 4, "<StockItem>", GTK_STOCK_REVERT_TO_SAVED},
 
328
        {N_("/File/sep2"), NULL, NULL, 0, "<Separator>"},       
 
329
        {N_("/File/_Insert..."), NULL, file_insert_menucb, 1, "<Item>"},        
 
330
        {N_("/File/Rena_me..."), "F2", menu_file_operations_cb, 7, "<Item>"},
120
331
        {N_("/File/sep3"), NULL, NULL, 0, "<Separator>"},
121
 
        {N_("/File/Close"), NULL, file_close_cb, 0, NULL},
122
 
        {N_("/File/Close all"), NULL, file_close_all_cb, 0, NULL},
 
332
        {N_("/File/_Close"), "<control>w", menu_file_operations_cb, 9, "<StockItem>", GTK_STOCK_CLOSE},
 
333
        {N_("/File/Close A_ll"), "<shift><control>w", menu_file_operations_cb, 24, "<Item>"},
 
334
        {N_("/File/Close Win_dow"), NULL, gui_window_menu_cb, 2, "<Item>"},
123
335
        {N_("/File/sep4"), NULL, NULL, 0, "<Separator>"},
124
 
        {N_("/File/Print..."), NULL, file_print_cb, 0, NULL},
125
 
        {N_("/File/sep5"), NULL, NULL, 0, "<Separator>"},
126
 
        {N_("/File/Quit"), "<control>Q", cya_later, 0, NULL},
 
336
        {N_("/File/_Quit"), "<control>Q", bluefish_exit_request, 0, "<StockItem>", GTK_STOCK_QUIT},
127
337
        {N_("/_Edit"), NULL, NULL, 0, "<Branch>"},
128
 
        {N_("/_Edit/Tearoff1"), NULL, NULL, 0, "<Tearoff>"},
129
 
        {N_("/Edit/Cut"), "<control>x", cut_cb, 0, NULL},
130
 
        {N_("/Edit/Copy"), "<control>c", copy_cb, 0, NULL},
131
 
        {N_("/Edit/Paste"), "<control>v", paste_cb, 0, NULL},
 
338
        {N_("/Edit/Tearoff1"), NULL, NULL, 0, "<Tearoff>"},
 
339
        {N_("/Edit/_Undo"), "<control>z", menu_file_operations_cb, 20, "<StockItem>", GTK_STOCK_UNDO},
 
340
        {N_("/Edit/_Redo"), "<shift><control>z", menu_file_operations_cb, 21, "<StockItem>", GTK_STOCK_REDO},
 
341
        {N_("/Edit/Undo All"), NULL, menu_file_operations_cb, 22, "<Item>"},
 
342
        {N_("/Edit/Redo All"), NULL, menu_file_operations_cb, 23, "<Item>"},
 
343
        {N_("/Edit/sep1"), NULL, NULL, 0, "<Separator>"},       
 
344
        {N_("/Edit/Cu_t"), "<control>x", menu_file_operations_cb, 10, "<StockItem>", GTK_STOCK_CUT},
 
345
        {N_("/Edit/_Copy"), "<control>c", menu_file_operations_cb, 11, "<StockItem>", GTK_STOCK_COPY},
 
346
        {N_("/Edit/_Paste"), "<control>v", menu_file_operations_cb, 12, "<StockItem>", GTK_STOCK_PASTE},
132
347
        {N_("/Edit/sep2"), NULL, NULL, 0, "<Separator>"},
133
 
        {N_("/Edit/Select all"), "<control>F8", sel_all_cb, 0, NULL},
134
 
        {N_("/Edit/Go to line..."), "<control>g", go_to_line_win_cb, 0, NULL},
 
348
        {N_("/Edit/Select _All"), NULL, menu_file_operations_cb, 13, "<Item>"},
135
349
        {N_("/Edit/sep3"), NULL, NULL, 0, "<Separator>"},
136
 
        {N_("/Edit/Find..."), "F6", search_cb, 0, NULL},
137
 
        {N_("/Edit/New find..."), NULL, new_search_cb, 0, NULL},
138
 
        {N_("/Edit/Find again"), "<shift>F6", search_again_cb, 0, NULL},
139
 
        {N_("/Edit/Replace..."), "F7", replace_cb, 0, NULL},
140
 
        {N_("/Edit/New replace..."), NULL, new_replace_cb, 0, NULL},
141
 
        {N_("/Edit/Replace again"), "<shift>F7", replace_again_cb, 0, NULL},
142
 
        {N_("/_Edit/Replace special"), NULL, NULL, 0, "<Branch>"},
143
 
        {N_("/_Edit/Replace special/Tearoff1"), NULL, NULL, 0, "<Tearoff>"},
144
 
        {N_("/Edit/Replace special/Replace iso 8859-1 chars"), NULL, iso8859_1_replace_cb, 0, NULL},
145
 
        {N_("/Edit/Replace special/Replace ascii chars"), NULL, ascii_replace_cb, 0, NULL},
146
 
        {N_("/Edit/Replace special/Escape double quotes"), "<shift>F10", escape_quotes_replace_cb, 0, NULL},
 
350
        {N_("/Edit/_Find..."), "<control>f", menu_file_operations_cb, 14, "<StockItem>", GTK_STOCK_FIND},
 
351
        {N_("/Edit/Find A_gain"), "<control>g", menu_file_operations_cb, 16, "<Item>"},
 
352
        {N_("/Edit/Find from selection"), NULL, menu_file_operations_cb, 27, "<Item>"},
 
353
        {N_("/Edit/R_eplace..."), "<control>h", menu_file_operations_cb, 17, "<StockItem>", GTK_STOCK_FIND_AND_REPLACE},
 
354
        {N_("/Edit/Replace Agai_n"), "<shift><control>h", menu_file_operations_cb, 19, "<Item>"},
 
355
        {N_("/Edit/Replace special"), NULL, NULL, 0, "<Branch>"},
 
356
        {N_("/Edit/Replace special/Tearoff1"), NULL, NULL, 0, "<Tearoff>"},
 
357
        {N_("/Edit/Replace special/_ASCII to HTML Entities"), NULL, doc_convert_asciichars_in_selection, 1, "<Item>"},
 
358
        {N_("/Edit/Replace special/_ISO8859 to HTML Entities"), NULL, doc_convert_asciichars_in_selection, 2, "<Item>"},
 
359
        {N_("/Edit/Replace special/_Both Types to HTML Entities"), NULL, doc_convert_asciichars_in_selection, 3, "<Item>"},
 
360
        {N_("/Edit/Replace special/To _Uppercase"), NULL, doc_convert_asciichars_in_selection, 4, "<Item>"},
 
361
        {N_("/Edit/Replace special/To _Lowercase"), NULL, doc_convert_asciichars_in_selection, 5, "<Item>"},
147
362
        {N_("/Edit/sep4"), NULL, NULL, 0, "<Separator>"},
148
 
        {N_("/Edit/Undo"), "<control>z", undo_cb, 0, NULL},
149
 
        {N_("/Edit/Redo"), "<control>r", redo_cb, 0, NULL},
150
 
        {N_("/Edit/Undo all"), NULL, undo_all_cb, 0, NULL},
151
 
        {N_("/Edit/Redo all"), NULL, redo_all_cb, 0, NULL},
 
363
        {N_("/Edit/S_hift Right"), NULL, menu_indent_cb, 2, "<ImageItem>", pixmap_indent},
 
364
        {N_("/Edit/Shift _Left"), NULL, menu_indent_cb, 1, "<ImageItem>", pixmap_unindent},
152
365
        {N_("/Edit/sep5"), NULL, NULL, 0, "<Separator>"},
153
 
        {N_("/Edit/Selection to uppercase"), NULL, selection_to_uppercase_cb, 0, NULL},
154
 
        {N_("/Edit/Selection to lowercase"), NULL, selection_to_lowercase_cb, 0, NULL},
 
366
        {N_("/Edit/Add _Bookmark"), "<control>d", menu_bmark_operations_cb, 1, "<Item>"},       
155
367
        {N_("/Edit/sep6"), NULL, NULL, 0, "<Separator>"},
156
 
        {N_("/Edit/Indent region"), NULL, indent_region_cb, 0, NULL},
157
 
        {N_("/Edit/Unindent region"), NULL, unindent_region_cb, 0, NULL},
158
 
        {N_("/Edit/sep7"), NULL, NULL, 0, "<Separator>"},
159
 
        {N_("/Edit/Word Count"), NULL, word_count_cb, 0, NULL},
 
368
        {N_("/Edit/Save Sett_ings"), NULL, rcfile_save_configfile_menu_cb, 0, "<Item>"},
 
369
        {N_("/Edit/Save Shortcut _Keys"), NULL, rcfile_save_configfile_menu_cb, 3, "<Item>"},   
 
370
        {N_("/Edit/Preference_s"), NULL, open_preferences_menu_cb, 0, "<StockItem>", GTK_STOCK_PREFERENCES},
160
371
        {N_("/_View"), NULL, NULL, 0, "<Branch>"},
161
 
        {N_("/_View/Tearoff1"), NULL, NULL, 0, "<Tearoff>"},
162
 
        {N_("/View/View in _Netscape"), NULL, view_in_netscape_cb, 0, NULL},
163
 
        {N_("/View/_Drag 'n Drop Window"), NULL, dndwin_cb, 0, NULL},
164
 
#ifdef HAVE_IMAGE_LIBS
165
 
        {N_("/View/_Preview image under cursor"), NULL, preview_image_by_position_cb, 0, NULL},
166
 
#endif
167
 
#ifdef WITH_INTERNAL_PREVIEW
168
 
   {N_("/View/_Preview "), "F4" , preview_cb, 0, NULL},
169
 
#endif
170
 
 
171
 
        {N_("/View/sep1"), NULL, NULL, 0, "<Separator>"},
172
 
        {N_("/View/Next document"), "F1", notebook_next_document_cb, 0, NULL},
173
 
        {N_("/View/Previous document"), "F2", notebook_prev_document_cb, 0, NULL},
174
 
        {N_("/View/sep3"), NULL, NULL, 0, "<Separator>"},
175
 
        {N_("/View/Highlight syntax"), NULL, toggle_highlight_syntax_cb, 0, "<ToggleItem>"},
176
 
        {N_("/View/Refresh highlighting"), "F5", refresh_hi_cb, 0, NULL},
177
 
        {N_("/View/sep2"), NULL, NULL, 0, "<Separator>"},
178
 
        {N_("/View/Document status"), "F3", show_document_status_cb, 0, NULL},
179
 
        {N_("/_Project"), NULL, NULL, 0, "<Branch>"},
180
 
        {N_("/Project/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
181
 
        {N_("/Project/Open..."), NULL, project_open_cb, 0, NULL},
182
 
        {N_("/Project/Close"), NULL, project_close_cb, 0, NULL},
183
 
        {N_("/Project/Save"), NULL, project_save_cb, 0, NULL},
184
 
        {N_("/Project/Save as..."), NULL, project_save_as_cb, 0, NULL},
185
 
        {N_("/Project/sep1"), NULL, NULL, 0, "<Separator>"},
186
 
        {N_("/Project/Edit..."), NULL, project_edit_cb, 0, NULL},
187
 
        {N_("/Project/sep2"), NULL, NULL, 0, "<Separator>"},
188
 
        {N_("/Project/Add current document"), NULL, project_add_document_cb, 0, NULL},
189
 
        {N_("/Project/Add all open documents"), NULL, project_add_document_cb, 1, NULL},
190
 
        {N_("/_Project/Files"), NULL, NULL, 0, "<Branch>"},
191
 
        {N_("/Project/Files/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
 
372
        {N_("/View/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
 
373
        {N_("/View/View _Main Toolbar"), NULL, gui_toggle_hidewidget_cb, 1, "<ToggleItem>"},
 
374
        {N_("/View/View _HTML Toolbar"), NULL, gui_toggle_hidewidget_cb, 2, "<ToggleItem>"},
 
375
        {N_("/View/View _Custom Menu"), NULL, gui_toggle_hidewidget_cb, 3, "<ToggleItem>"},
 
376
        {N_("/View/View _Sidebar"), "F9", gui_toggle_hidewidget_cb, 4, "<ToggleItem>"},
192
377
        {N_("/_Tags"), NULL, NULL, 0, "<Branch>"},
193
378
        {N_("/Tags/Tearoff1"), NULL, NULL, 0, "<Tearoff>"},
194
 
        {N_("/Tags/Repeat last"), "F4", repeat_last_insert_cb, 0, NULL},
195
 
        {N_("/Tags/Headings"), NULL, NULL, 0, "<Branch>"},
 
379
/*      {N_("/Tags/Repeat last"), "F4", repeat_last_insert_cb, 0, NULL},*/
 
380
        {N_("/Tags/_Headings"), NULL, NULL, 0, "<Branch>"},
196
381
        {N_("/Tags/Headings/Tearoff1"), NULL, NULL, 0, "<Tearoff>"},
197
 
        {N_("/Tags/Headings/H1"), "<alt>F1", general_html_cb, 18, NULL},
198
 
        {N_("/Tags/Headings/H2"), "<alt>F2", general_html_cb, 19, NULL},
199
 
        {N_("/Tags/Headings/H3"), "<alt>F3", general_html_cb, 20, NULL},
200
 
        {N_("/Tags/Headings/H4"), "<alt>F4", general_html_cb, 21, NULL},
201
 
        {N_("/Tags/Headings/H5"), "<alt>F5", general_html_cb, 22, NULL},
202
 
        {N_("/Tags/Headings/H6"), "<alt>F6", general_html_cb, 23, NULL},
203
 
        {N_("/Tags/Special"), NULL, NULL, 0, "<Branch>"},
 
382
        {N_("/Tags/Headings/H_1"), "<control><alt>1", general_html_menu_cb, 18, "<ImageItem>",pixmap_fonth1},
 
383
        {N_("/Tags/Headings/H_2"), "<control><alt>2", general_html_menu_cb, 19, "<ImageItem>",pixmap_fonth2},
 
384
        {N_("/Tags/Headings/H_3"), "<control><alt>3", general_html_menu_cb, 20, "<ImageItem>",pixmap_fonth3},
 
385
        {N_("/Tags/Headings/H_4"), "<control><alt>4", general_html_menu_cb, 21, "<ImageItem>",pixmap_fonth4},
 
386
        {N_("/Tags/Headings/H_5"), "<control><alt>5", general_html_menu_cb, 22, "<ImageItem>",pixmap_fonth5},
 
387
        {N_("/Tags/Headings/H_6"), "<control><alt>6", general_html_menu_cb, 23, "<ImageItem>",pixmap_fonth6},
 
388
        {N_("/Tags/_Special"), NULL, NULL, 0, "<Branch>"},
204
389
        {N_("/Tags/Special/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
205
 
        {N_("/Tags/Special/Accent"), NULL, NULL, 0, "<Branch>"},
 
390
        {N_("/Tags/Special/_Accent"), NULL, NULL, 0, "<Branch>"},
206
391
        {N_("/Tags/Special/Accent/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
207
 
        {N_("/Tags/Special/Accent/Uppercase"), NULL, NULL, 0, "<Branch>"},
208
 
        {N_("/Tags/Special/Accent/Uppercase/A-I"), NULL, NULL, 0, "<Branch>"},
 
392
        {N_("/Tags/Special/Accent/_Uppercase"), NULL, NULL, 0, "<Branch>"},
 
393
        {N_("/Tags/Special/Accent/Uppercase/_A-I"), NULL, NULL, 0, "<Branch>"},
209
394
        {N_("/Tags/Special/Accent/Uppercase/A-I/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
210
 
        {N_("/Tags/Special/Accent/Uppercase/A-I/A grave"), NULL, insert_char_cb, 0, NULL},
211
 
        {N_("/Tags/Special/Accent/Uppercase/A-I/A acute"), NULL, insert_char_cb, 1, NULL},
212
 
        {N_("/Tags/Special/Accent/Uppercase/A-I/A circumflex"), NULL, insert_char_cb, 2, NULL},
213
 
        {N_("/Tags/Special/Accent/Uppercase/A-I/A tilde"), NULL, insert_char_cb, 3, NULL},
214
 
        {N_("/Tags/Special/Accent/Uppercase/A-I/AE ligature"), NULL, insert_char_cb, 4, NULL},
215
 
        {N_("/Tags/Special/Accent/Uppercase/A-I/A diaeresis"), NULL, insert_char_cb, 5, NULL},
216
 
        {N_("/Tags/Special/Accent/Uppercase/A-I/A ring"), NULL, insert_char_cb, 6, NULL},
217
 
        {N_("/Tags/Special/Accent/Uppercase/A-I/C cedilla"), NULL, insert_char_cb, 7, NULL},
218
 
        {N_("/Tags/Special/Accent/Uppercase/A-I/E grave"), NULL, insert_char_cb, 8, NULL},
219
 
        {N_("/Tags/Special/Accent/Uppercase/A-I/E acute"), NULL, insert_char_cb, 9, NULL},
220
 
        {N_("/Tags/Special/Accent/Uppercase/A-I/E circumflex"), NULL, insert_char_cb, 10, NULL},
221
 
        {N_("/Tags/Special/Accent/Uppercase/A-I/E diaeresis"), NULL, insert_char_cb, 11, NULL},
222
 
        {N_("/Tags/Special/Accent/Uppercase/A-I/I grave"), NULL, insert_char_cb, 12, NULL},
223
 
        {N_("/Tags/Special/Accent/Uppercase/A-I/I acute"), NULL, insert_char_cb, 13, NULL},
224
 
        {N_("/Tags/Special/Accent/Uppercase/A-I/I circumflex"), NULL, insert_char_cb, 14, NULL},
225
 
        {N_("/Tags/Special/Accent/Uppercase/A-I/I diaeresis"), NULL, insert_char_cb, 15, NULL},
226
 
        {N_("/Tags/Special/Accent/Uppercase/J-Z"), NULL, NULL, 0, "<Branch>"},
 
395
        {N_("/Tags/Special/Accent/Uppercase/A-I/A grave À"), NULL, insert_char_cb, 100, "<Item>"},
 
396
        {N_("/Tags/Special/Accent/Uppercase/A-I/A acute Á"), NULL, insert_char_cb, 1, "<Item>"},
 
397
        {N_("/Tags/Special/Accent/Uppercase/A-I/A circumflex Â"), NULL, insert_char_cb, 2, "<Item>"},
 
398
        {N_("/Tags/Special/Accent/Uppercase/A-I/A tilde Ã"), NULL, insert_char_cb, 3, "<Item>"},
 
399
        {N_("/Tags/Special/Accent/Uppercase/A-I/AE ligature Æ"), NULL, insert_char_cb, 4, "<Item>"},
 
400
        {N_("/Tags/Special/Accent/Uppercase/A-I/A diaeresis Ä"), NULL, insert_char_cb, 5, "<Item>"},
 
401
        {N_("/Tags/Special/Accent/Uppercase/A-I/A ring Å"), NULL, insert_char_cb, 6, "<Item>"},
 
402
        {N_("/Tags/Special/Accent/Uppercase/A-I/C cedilla Ç"), NULL, insert_char_cb, 7, "<Item>"},
 
403
        {N_("/Tags/Special/Accent/Uppercase/A-I/E grave È"), NULL, insert_char_cb, 8, "<Item>"},
 
404
        {N_("/Tags/Special/Accent/Uppercase/A-I/E acute É"), NULL, insert_char_cb, 9, "<Item>"},
 
405
        {N_("/Tags/Special/Accent/Uppercase/A-I/E circumflex Ê"), NULL, insert_char_cb, 10, "<Item>"},
 
406
        {N_("/Tags/Special/Accent/Uppercase/A-I/E diaeresis Ë"), NULL, insert_char_cb, 11, "<Item>"},
 
407
        {N_("/Tags/Special/Accent/Uppercase/A-I/I grave Ì"), NULL, insert_char_cb, 12, "<Item>"},
 
408
        {N_("/Tags/Special/Accent/Uppercase/A-I/I acute Í"), NULL, insert_char_cb, 13, "<Item>"},
 
409
        {N_("/Tags/Special/Accent/Uppercase/A-I/I circumflex Î"), NULL, insert_char_cb, 14, "<Item>"},
 
410
        {N_("/Tags/Special/Accent/Uppercase/A-I/I diaeresis Ï"), NULL, insert_char_cb, 15, "<Item>"},
 
411
        {N_("/Tags/Special/Accent/Uppercase/_J-Z"), NULL, NULL, 0, "<Branch>"},
227
412
        {N_("/Tags/Special/Accent/Uppercase/J-Z/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
228
 
        {N_("/Tags/Special/Accent/Uppercase/J-Z/N tilde"), NULL, insert_char_cb, 16, NULL},
229
 
        {N_("/Tags/Special/Accent/Uppercase/J-Z/O grave"), NULL, insert_char_cb, 17, NULL},
230
 
        {N_("/Tags/Special/Accent/Uppercase/J-Z/O acute"), NULL, insert_char_cb, 18, NULL},
231
 
        {N_("/Tags/Special/Accent/Uppercase/J-Z/O circumflex"), NULL, insert_char_cb, 19, NULL},
232
 
        {N_("/Tags/Special/Accent/Uppercase/J-Z/O tilde"), NULL, insert_char_cb, 20, NULL},
233
 
        {N_("/Tags/Special/Accent/Uppercase/J-Z/O diaeresis"), NULL, insert_char_cb, 21, NULL},
234
 
        {N_("/Tags/Special/Accent/Uppercase/J-Z/O slash"), NULL, insert_char_cb, 22, NULL},
235
 
        {N_("/Tags/Special/Accent/Uppercase/J-Z/U grave"), NULL, insert_char_cb, 23, NULL},
236
 
        {N_("/Tags/Special/Accent/Uppercase/J-Z/U acute"), NULL, insert_char_cb, 24, NULL},
237
 
        {N_("/Tags/Special/Accent/Uppercase/J-Z/U circumflex"), NULL, insert_char_cb, 25, NULL},
238
 
        {N_("/Tags/Special/Accent/Uppercase/J-Z/U diaeresis"), NULL,
239
 
         insert_char_cb, 26, NULL},
240
 
        {N_("/Tags/Special/Accent/Uppercase/J-Z/Y acute"), NULL, insert_char_cb,
241
 
         27, NULL},
242
 
        {N_("/Tags/Special/Accent/Lowercase"), NULL, NULL, 0, "<Branch>"},
243
 
        {N_("/Tags/Special/Accent/Lowercase/A-I"), NULL, NULL, 0, "<Branch>"},
244
 
        {N_("/Tags/Special/Accent/Lowercase/A-I/tearoff1"), NULL, NULL, 0,
245
 
         "<Tearoff>"},
246
 
        {N_("/Tags/Special/Accent/Lowercase/A-I/a grave"), NULL, insert_char_cb,
247
 
         28, NULL},
248
 
        {N_("/Tags/Special/Accent/Lowercase/A-I/a acute"), NULL, insert_char_cb,
249
 
         29, NULL},
250
 
        {N_("/Tags/Special/Accent/Lowercase/A-I/a circumflex"), NULL,
251
 
         insert_char_cb, 30, NULL},
252
 
        {N_("/Tags/Special/Accent/Lowercase/A-I/a tilde"), NULL, insert_char_cb,
253
 
         31, NULL},
254
 
        {N_("/Tags/Special/Accent/Lowercase/A-I/a ring"), NULL, insert_char_cb,
255
 
         32, NULL},
256
 
        {N_("/Tags/Special/Accent/Lowercase/A-I/ae ligature"), NULL,
257
 
         insert_char_cb, 33, NULL},
258
 
        {N_("/Tags/Special/Accent/Lowercase/A-I/a diaeresis"), NULL,
259
 
         insert_char_cb, 34, NULL},
260
 
        {N_("/Tags/Special/Accent/Lowercase/A-I/c cedilla"), NULL, insert_char_cb,
261
 
         35, NULL},
262
 
        {N_("/Tags/Special/Accent/Lowercase/A-I/e grave"), NULL, insert_char_cb,
263
 
         36, NULL},
264
 
        {N_("/Tags/Special/Accent/Lowercase/A-I/e acute"), NULL, insert_char_cb,
265
 
         37, NULL},
266
 
        {N_("/Tags/Special/Accent/Lowercase/A-I/e circumflex"), NULL,
267
 
         insert_char_cb, 38, NULL},
268
 
        {N_("/Tags/Special/Accent/Lowercase/A-I/e diaeresis"), NULL,
269
 
         insert_char_cb, 39, NULL},
270
 
        {N_("/Tags/Special/Accent/Lowercase/A-I/i grave"), NULL, insert_char_cb,
271
 
         40, NULL},
272
 
        {N_("/Tags/Special/Accent/Lowercase/A-I/i acute"), NULL, insert_char_cb,
273
 
         41, NULL},
274
 
        {N_("/Tags/Special/Accent/Lowercase/A-I/i circumflex"), NULL,
275
 
         insert_char_cb, 42, NULL},
276
 
        {N_("/Tags/Special/Accent/Lowercase/A-I/i diaeresis"), NULL,
277
 
         insert_char_cb, 43, NULL},
278
 
        {N_("/Tags/Special/Accent/Lowercase/J-Z"), NULL, NULL, 0, "<Branch>"},
279
 
        {N_("/Tags/Special/Accent/Lowercase/J-Z/tearoff1"), NULL, NULL, 0,
280
 
         "<Tearoff>"},
281
 
        {N_("/Tags/Special/Accent/Lowercase/J-Z/n tilde"), NULL, insert_char_cb,
282
 
         44, NULL},
283
 
        {N_("/Tags/Special/Accent/Lowercase/J-Z/o grave"), NULL, insert_char_cb,
284
 
         45, NULL},
285
 
        {N_("/Tags/Special/Accent/Lowercase/J-Z/o acute"), NULL, insert_char_cb,
286
 
         46, NULL},
287
 
        {N_("/Tags/Special/Accent/Lowercase/J-Z/o circumflex"), NULL,
288
 
         insert_char_cb, 47, NULL},
289
 
        {N_("/Tags/Special/Accent/Lowercase/J-Z/o tilde"), NULL, insert_char_cb,
290
 
         48, NULL},
291
 
        {N_("/Tags/Special/Accent/Lowercase/J-Z/o diaeresis"), NULL,
292
 
         insert_char_cb, 49, NULL},
293
 
        {N_("/Tags/Special/Accent/Lowercase/J-Z/o slash"), NULL, insert_char_cb,
294
 
         50, NULL},
295
 
        {N_("/Tags/Special/Accent/Lowercase/J-Z/u grave"), NULL, insert_char_cb,
296
 
         51, NULL},
297
 
        {N_("/Tags/Special/Accent/Lowercase/J-Z/u acute"), NULL, insert_char_cb,
298
 
         52, NULL},
299
 
        {N_("/Tags/Special/Accent/Lowercase/J-Z/u circumflex"), NULL,
300
 
         insert_char_cb, 53, NULL},
301
 
        {N_("/Tags/Special/Accent/Lowercase/J-Z/u diaeresis"), NULL,
302
 
         insert_char_cb, 54, NULL},
303
 
        {N_("/Tags/Special/Accent/Lowercase/J-Z/y acute"), NULL, insert_char_cb,
304
 
         55, NULL},
305
 
        {N_("/Tags/Special/Accent/Lowercase/J-Z/y diaeresis"), NULL,
306
 
         insert_char_cb, 56, NULL},
 
413
        {N_("/Tags/Special/Accent/Uppercase/J-Z/N tilde Ñ"), NULL, insert_char_cb, 16, "<Item>"},
 
414
        {N_("/Tags/Special/Accent/Uppercase/J-Z/O grave Ò"), NULL, insert_char_cb, 17, "<Item>"},
 
415
        {N_("/Tags/Special/Accent/Uppercase/J-Z/O acute Ó"), NULL, insert_char_cb, 18, "<Item>"},
 
416
        {N_("/Tags/Special/Accent/Uppercase/J-Z/O circumflex Ô"), NULL, insert_char_cb, 19, "<Item>"},
 
417
        {N_("/Tags/Special/Accent/Uppercase/J-Z/OE ligature"), NULL, insert_char_cb, 100, "<Item>"},
 
418
        {N_("/Tags/Special/Accent/Uppercase/J-Z/O tilde Õ"), NULL, insert_char_cb, 20, "<Item>"},
 
419
        {N_("/Tags/Special/Accent/Uppercase/J-Z/O diaeresis Ö"), NULL, insert_char_cb, 21, "<Item>"},
 
420
        {N_("/Tags/Special/Accent/Uppercase/J-Z/O slash Ø"), NULL, insert_char_cb, 22, "<Item>"},
 
421
        {N_("/Tags/Special/Accent/Uppercase/J-Z/U grave Ù"), NULL, insert_char_cb, 23, "<Item>"},
 
422
        {N_("/Tags/Special/Accent/Uppercase/J-Z/U acute Ú"), NULL, insert_char_cb, 24, "<Item>"},
 
423
        {N_("/Tags/Special/Accent/Uppercase/J-Z/U circumflex Û"), NULL, insert_char_cb, 25, "<Item>"},
 
424
        {N_("/Tags/Special/Accent/Uppercase/J-Z/U diaeresis Ü"), NULL, insert_char_cb, 26, "<Item>"},
 
425
        {N_("/Tags/Special/Accent/Uppercase/J-Z/Y acute Ý"), NULL, insert_char_cb, 27, "<Item>"},
 
426
        {N_("/Tags/Special/Accent/_Lowercase"), NULL, NULL, 0, "<Branch>"},
 
427
        {N_("/Tags/Special/Accent/Lowercase/_A-I"), NULL, NULL, 0, "<Branch>"},
 
428
        {N_("/Tags/Special/Accent/Lowercase/A-I/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
 
429
        {N_("/Tags/Special/Accent/Lowercase/A-I/a grave à"), NULL, insert_char_cb, 28, "<Item>"},
 
430
        {N_("/Tags/Special/Accent/Lowercase/A-I/a acute á"), NULL, insert_char_cb, 29, "<Item>"},
 
431
        {N_("/Tags/Special/Accent/Lowercase/A-I/a circumflex â"), NULL, insert_char_cb, 30, "<Item>"},
 
432
        {N_("/Tags/Special/Accent/Lowercase/A-I/a tilde ã"), NULL, insert_char_cb, 31, "<Item>"},
 
433
        {N_("/Tags/Special/Accent/Lowercase/A-I/a ring å"), NULL, insert_char_cb, 32, "<Item>"},
 
434
        {N_("/Tags/Special/Accent/Lowercase/A-I/ae ligature æ"), NULL, insert_char_cb, 33, "<Item>"},
 
435
        {N_("/Tags/Special/Accent/Lowercase/A-I/a diaeresis ä"), NULL, insert_char_cb, 34, "<Item>"},
 
436
        {N_("/Tags/Special/Accent/Lowercase/A-I/c cedilla ç"), NULL, insert_char_cb, 35, "<Item>"},
 
437
        {N_("/Tags/Special/Accent/Lowercase/A-I/e grave è"), NULL, insert_char_cb, 36, "<Item>"},
 
438
        {N_("/Tags/Special/Accent/Lowercase/A-I/e acute é"), NULL, insert_char_cb, 37, "<Item>"},
 
439
        {N_("/Tags/Special/Accent/Lowercase/A-I/e circumflex ê"), NULL, insert_char_cb, 38, "<Item>"},
 
440
        {N_("/Tags/Special/Accent/Lowercase/A-I/e diaeresis ë"), NULL, insert_char_cb, 39, "<Item>"},
 
441
        {N_("/Tags/Special/Accent/Lowercase/A-I/i grave ì"), NULL, insert_char_cb, 40, "<Item>"},
 
442
        {N_("/Tags/Special/Accent/Lowercase/A-I/i acute í"), NULL, insert_char_cb, 41, "<Item>"},
 
443
        {N_("/Tags/Special/Accent/Lowercase/A-I/i circumflex î"), NULL, insert_char_cb, 42, "<Item>"},
 
444
        {N_("/Tags/Special/Accent/Lowercase/A-I/i diaeresis ï"), NULL, insert_char_cb, 43, "<Item>"},
 
445
        {N_("/Tags/Special/Accent/Lowercase/_J-Z"), NULL, NULL, 0, "<Branch>"},
 
446
        {N_("/Tags/Special/Accent/Lowercase/J-Z/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
 
447
        {N_("/Tags/Special/Accent/Lowercase/J-Z/n tilde ñ"), NULL, insert_char_cb, 44, "<Item>"},
 
448
        {N_("/Tags/Special/Accent/Lowercase/J-Z/o grave ò"), NULL, insert_char_cb, 45, "<Item>"},
 
449
        {N_("/Tags/Special/Accent/Lowercase/J-Z/o acute ó"), NULL, insert_char_cb,46, "<Item>"},
 
450
        {N_("/Tags/Special/Accent/Lowercase/J-Z/oe ligature æ"), NULL, insert_char_cb,99, "<Item>"},
 
451
        {N_("/Tags/Special/Accent/Lowercase/J-Z/o circumflex ô"), NULL, insert_char_cb, 47, "<Item>"},
 
452
        {N_("/Tags/Special/Accent/Lowercase/J-Z/o tilde õ"), NULL, insert_char_cb, 48, "<Item>"},
 
453
        {N_("/Tags/Special/Accent/Lowercase/J-Z/o diaeresis ö"), NULL, insert_char_cb, 49, "<Item>"},
 
454
        {N_("/Tags/Special/Accent/Lowercase/J-Z/o slash ø"), NULL, insert_char_cb, 50, "<Item>"},
 
455
        {N_("/Tags/Special/Accent/Lowercase/J-Z/u grave ù"), NULL, insert_char_cb, 51, "<Item>"},
 
456
        {N_("/Tags/Special/Accent/Lowercase/J-Z/u acute ú"), NULL, insert_char_cb, 52, "<Item>"},
 
457
        {N_("/Tags/Special/Accent/Lowercase/J-Z/u circumflex û"), NULL, insert_char_cb, 53, "<Item>"},
 
458
        {N_("/Tags/Special/Accent/Lowercase/J-Z/u diaeresis ü"), NULL, insert_char_cb, 54, "<Item>"},
 
459
        {N_("/Tags/Special/Accent/Lowercase/J-Z/y acute ý"), NULL, insert_char_cb, 55, "<Item>"},
 
460
        {N_("/Tags/Special/Accent/Lowercase/J-Z/y diaeresis ÿ"), NULL, insert_char_cb, 56, "<Item>"},
307
461
        {N_("/Tags/Special/Accent/separator"), NULL, NULL, 0, "<Separator>"},
308
 
        {N_("/Tags/Special/Accent/Umlaut"), NULL, insert_char_cb, 57, NULL},
309
 
        {N_("/Tags/Special/Accent/Acute"), NULL, insert_char_cb, 58, NULL},
310
 
        {N_("/Tags/Special/Accent/Cedilla"), NULL, insert_char_cb, 59, NULL},
311
 
        {N_("/Tags/Special/Currency"), NULL, NULL, 0, "<Branch>"},
 
462
        {N_("/Tags/Special/Accent/U_mlaut ¨"), NULL, insert_char_cb, 57, "<Item>"},
 
463
        {N_("/Tags/Special/Accent/_Acute ´"), NULL, insert_char_cb, 58, "<Item>"},
 
464
        {N_("/Tags/Special/Accent/_Cedilla ¸"), NULL, insert_char_cb, 59, "<Item>"},
 
465
        {N_("/Tags/Special/_Currency"), NULL, NULL, 0, "<Branch>"},
312
466
        {N_("/Tags/Special/Currency/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
313
 
        {N_("/Tags/Special/Currency/Cent sign"), NULL, insert_char_cb,
314
 
         60, NULL},
315
 
        {N_("/Tags/Special/Currency/Pound sterling"), NULL, insert_char_cb,
316
 
         61, NULL},
317
 
        {N_("/Tags/Special/Currency/Currency sign"), NULL, insert_char_cb,
318
 
         62, NULL},
319
 
        {N_("/Tags/Special/Currency/Yen sign"), NULL, insert_char_cb, 63, NULL},
320
 
        {N_("/Tags/Special/Math-Science"), NULL, NULL, 0, "<Branch>"},
 
467
        {N_("/Tags/Special/Currency/_Cent sign ¢"), NULL, insert_char_cb, 60, "<Item>"},
 
468
        {N_("/Tags/Special/Currency/_Pound sterling £"), NULL, insert_char_cb, 61, "<Item>"},
 
469
        {N_("/Tags/Special/Currency/C_urrency sign ¤"), NULL, insert_char_cb, 62, "<Item>"},
 
470
        {N_("/Tags/Special/Currency/_Yen sign ¥"), NULL, insert_char_cb, 63, "<Item>"},
 
471
        {N_("/Tags/Special/Currency/_Euro "), NULL, insert_char_cb, 98, "<Item>"},
 
472
        {N_("/Tags/Special/_Math-Science"), NULL, NULL, 0, "<Branch>"},
321
473
        {N_("/Tags/Special/Math-Science/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
322
 
        {N_("/Tags/Special/Math-Science/Logical not sign"), "<alt>1", insert_char_cb,
323
 
         64, NULL},
324
 
        {N_("/Tags/Special/Math-Science/Multiplication sign"), "<alt>8",
325
 
         insert_char_cb, 65, NULL},
326
 
        {N_("/Tags/Special/Math-Science/Division sign"), "<alt>slash", insert_char_cb,
327
 
         66, NULL},
328
 
        {N_("/Tags/Special/Math-Science/Plus-minus sign"), NULL, insert_char_cb,
329
 
         67, NULL},
330
 
        {N_("/Tags/Special/Math-Science/Less-than sign"), "<alt>comma", insert_char_cb,
331
 
         68, NULL},
332
 
        {N_("/Tags/Special/Math-Science/Greater-than sign"), "<alt>period", insert_char_cb,
333
 
         69, NULL},
334
 
        {N_("/Tags/Special/Math-Science/Superscript 1"), NULL, insert_char_cb,
335
 
         70, NULL},
336
 
        {N_("/Tags/Special/Math-Science/Superscript 2"), NULL, insert_char_cb,
337
 
         71, NULL},
338
 
        {N_("/Tags/Special/Math-Science/Superscript 3"), NULL, insert_char_cb,
339
 
         72, NULL},
340
 
        {N_("/Tags/Special/Math-Science/One quarter"), NULL, insert_char_cb,
341
 
         73, NULL},
342
 
        {N_("/Tags/Special/Math-Science/One half"), NULL, insert_char_cb,
343
 
         74, NULL},
344
 
        {N_("/Tags/Special/Math-Science/Three quarters"), NULL, insert_char_cb,
345
 
         75, NULL},
346
 
        {N_("/Tags/Special/Math-Science/Degree sign"), NULL, insert_char_cb,
347
 
         76, NULL},
348
 
        {N_("/Tags/Special/Non Latin"), NULL, NULL, 0, "<Branch>"},
 
474
        {N_("/Tags/Special/Math-Science/Logical _not sign ¬"), NULL, insert_char_cb, 64, "<Item>"},
 
475
        {N_("/Tags/Special/Math-Science/_Multiplication sign ×"), NULL, insert_char_cb, 65, "<Item>"},
 
476
        {N_("/Tags/Special/Math-Science/_Division sign ÷"), "<control><alt>slash", insert_char_cb, 66, "<Item>"},
 
477
        {N_("/Tags/Special/Math-Science/_Plus-minus sign ±"), NULL, insert_char_cb, 67, "<Item>"},
 
478
        {N_("/Tags/Special/Math-Science/_Less-than sign <"), "<control><alt>comma", insert_char_cb, 68, "<Item>"},
 
479
        {N_("/Tags/Special/Math-Science/_Greater-than sign >"), "<control><alt>period", insert_char_cb, 69, "<Item>"},
 
480
        {N_("/Tags/Special/Math-Science/Superscript _1 ¹"), NULL, insert_char_cb, 70, "<Item>"},
 
481
        {N_("/Tags/Special/Math-Science/Superscript _2 ²"), NULL, insert_char_cb, 71, "<Item>"},
 
482
        {N_("/Tags/Special/Math-Science/Superscript _3 ³"), NULL, insert_char_cb, 72, "<Item>"},
 
483
        {N_("/Tags/Special/Math-Science/One _quarter ¼"), NULL, insert_char_cb, 73, "<Item>"},
 
484
        {N_("/Tags/Special/Math-Science/One _half ½"), NULL, insert_char_cb, 74, "<Item>"},
 
485
        {N_("/Tags/Special/Math-Science/_Three quarters ¾"), NULL, insert_char_cb, 75, "<Item>"},
 
486
        {N_("/Tags/Special/Math-Science/Deg_ree sign °"), NULL, insert_char_cb, 76, "<Item>"},
 
487
        {N_("/Tags/Special/_Non Latin"), NULL, NULL, 0, "<Branch>"},
349
488
        {N_("/Tags/Special/Non Latin/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
350
 
        {N_("/Tags/Special/Non Latin/ETH (Icelandic)"), NULL, insert_char_cb,
351
 
         77, NULL},
352
 
        {N_("/Tags/Special/Non Latin/THORN (Icelandic)"), NULL, insert_char_cb,
353
 
         78, NULL},
354
 
        {N_("/Tags/Special/Non Latin/eth (Icelandic)"), NULL, insert_char_cb,
355
 
         79, NULL},
356
 
        {N_("/Tags/Special/Non Latin/thorn"), NULL, insert_char_cb, 80, NULL},
357
 
        {N_("/Tags/Special/Non Latin/Sharp s"), NULL, insert_char_cb, 81, NULL},
358
 
        {N_("/Tags/Special/Non Latin/Micro sign"), NULL, insert_char_cb,
359
 
         82, NULL},
360
 
        {N_("/Tags/Special/Other"), NULL, NULL, 0, "<Branch>"},
 
489
        {N_("/Tags/Special/Non Latin/_ETH (Icelandic) Ð"), NULL, insert_char_cb, 77, "<Item>"},
 
490
        {N_("/Tags/Special/Non Latin/_THORN (Icelandic) Þ"), NULL, insert_char_cb, 78, "<Item>"},
 
491
        {N_("/Tags/Special/Non Latin/et_h (Icelandic) ð"), NULL, insert_char_cb, 79, "<Item>"},
 
492
        {N_("/Tags/Special/Non Latin/th_orn ÿ"), NULL, insert_char_cb, 80, "<Item>"},
 
493
        {N_("/Tags/Special/Non Latin/Sharp _s ß"), NULL, insert_char_cb, 81, "<Item>"},
 
494
        {N_("/Tags/Special/Non Latin/_Micro sign µ"), NULL, insert_char_cb, 82, "<Item>"},
 
495
        {N_("/Tags/Special/_Other"), NULL, NULL, 0, "<Branch>"},
361
496
        {N_("/Tags/Special/Other/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
362
 
        {N_("/Tags/Special/Other/Non-breaking space"), NULL, insert_char_cb,
363
 
         83, NULL},
364
 
        {N_("/Tags/Special/Other/Section sign"), NULL, insert_char_cb,
365
 
         84, NULL},
366
 
        {N_("/Tags/Special/Other/Copyright sign"), NULL, insert_char_cb,
367
 
         85, NULL},
368
 
        {N_("/Tags/Special/Other/Left angle quotes"), NULL, insert_char_cb,
369
 
         86, NULL},
370
 
        {N_("/Tags/Special/Other/Right angle quotes"), NULL, insert_char_cb,
371
 
         87, NULL},
372
 
        {N_("/Tags/Special/Other/Registered trademark"), NULL, insert_char_cb,
373
 
         88, NULL},
374
 
        {N_("/Tags/Special/Other/Inverted exclamation"), NULL, insert_char_cb,
375
 
         89, NULL},
376
 
        {N_("/Tags/Special/Other/Inverted question mark"), NULL, insert_char_cb,
377
 
         90, NULL},
378
 
        {N_("/Tags/Special/Other/Feminine ordinal"), NULL, insert_char_cb,
379
 
         91, NULL},
380
 
        {N_("/Tags/Special/Other/Masculine ordinal"), NULL, insert_char_cb,
381
 
         92, NULL},
382
 
        {N_("/Tags/Special/Other/Pilcrow (paragraph sign)"), NULL, insert_char_cb,
383
 
         93, NULL},
384
 
        {N_("/Tags/Special/Other/Broken bar"), NULL, insert_char_cb, 94, NULL},
385
 
        {N_("/Tags/Special/Other/Soft hypen"), "<alt>minus", insert_char_cb, 95, NULL},
386
 
        {N_("/Tags/Special/Other/Spacing macron"), NULL, insert_char_cb,
387
 
         96, NULL},
388
 
        {N_("/Tags/Special/Other/Middle dot"), NULL, insert_char_cb,
389
 
         97, NULL},
390
 
        {N_("/Tags/Format by layout"), NULL, NULL, 0, "<Branch>"},
 
497
        {N_("/Tags/Special/Other/_Non-breaking space"), NULL, insert_char_cb, 83, "<Item>"},
 
498
        {N_("/Tags/Special/Other/_Section sign §"), NULL, insert_char_cb, 84, "<Item>"},
 
499
        {N_("/Tags/Special/Other/_Copyright sign ©"), NULL, insert_char_cb, 85, "<Item>"},
 
500
        {N_("/Tags/Special/Other/_Left angle quotes «"), NULL, insert_char_cb, 86, "<Item>"},
 
501
        {N_("/Tags/Special/Other/_Right angle quotes »"), NULL, insert_char_cb, 87, "<Item>"},
 
502
        {N_("/Tags/Special/Other/Registered _trademark ®"), NULL, insert_char_cb, 88, "<Item>"},
 
503
        {N_("/Tags/Special/Other/Inverted _exclamation ¡"), NULL, insert_char_cb, 89, "<Item>"},
 
504
        {N_("/Tags/Special/Other/Inverted _question mark ¿"), NULL, insert_char_cb, 90, "<Item>"},
 
505
        {N_("/Tags/Special/Other/_Feminine ordinal ª"), NULL, insert_char_cb, 91, "<Item>"},
 
506
        {N_("/Tags/Special/Other/_Masculine ordinal º"), NULL, insert_char_cb, 92, "<Item>"},
 
507
        {N_("/Tags/Special/Other/_Pilcrow (paragraph sign) ¶"), NULL, insert_char_cb, 93, "<Item>"},
 
508
        {N_("/Tags/Special/Other/_Broken bar ¦"), NULL, insert_char_cb, 94, "<Item>"},
 
509
        {N_("/Tags/Special/Other/Soft _hypen -"), NULL, insert_char_cb, 95, "<Item>"},
 
510
        {N_("/Tags/Special/Other/Spa_cing macron ¯"), NULL, insert_char_cb, 96, "<Item>"},
 
511
        {N_("/Tags/Special/Other/Middle _dot ·"), NULL, insert_char_cb, 97, "<Item>"},
 
512
        {N_("/Tags/_Format by layout"), NULL, NULL, 0, "<Branch>"},
391
513
        {N_("/Tags/Format by layout/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
392
 
        {N_("/Tags/Format by layout/Bold"), "<alt>v", general_html_cb, 1, NULL},
393
 
        {N_("/Tags/Format by layout/Italic"), "<alt>i", general_html_cb, 2, NULL},
394
 
        {N_("/Tags/Format by layout/Underline"), "<alt>u", general_html_cb, 3, NULL},
395
 
        {N_("/Tags/Format by layout/Strikeout"), "<alt>s", general_html_cb, 4, NULL},   
396
 
        {N_("/Tags/Format by context"), NULL, NULL, 0, "<Branch>"},
 
514
        {N_("/Tags/Format by layout/_Bold"), "<control><alt>b", general_html_menu_cb, 1, "<ImageItem>",pixmap_bold},
 
515
        {N_("/Tags/Format by layout/_Italic"), "<control><alt>i", general_html_menu_cb, 2, "<ImageItem>",pixmap_italic},
 
516
        {N_("/Tags/Format by layout/_Underline"), "<control><alt>u", general_html_menu_cb, 3, "<ImageItem>",pixmap_underline},
 
517
        {N_("/Tags/Format by layout/_Strikeout"), "<control><alt>s", general_html_menu_cb, 4, "<Item>"},
 
518
        {N_("/Tags/Format by layout/Sm_all"), NULL, general_html_menu_cb, 56, "<Item>"},
 
519
        {N_("/Tags/Format by layout/Bi_g"), NULL, general_html_menu_cb, 57, "<Item>"},
 
520
        
 
521
        {N_("/Tags/F_ormat by context"), NULL, NULL, 0, "<Branch>"},
397
522
        {N_("/Tags/Format by context/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
398
 
        {N_("/Tags/Format by context/Strong"), NULL, general_html_cb, 16, NULL},
399
 
        {N_("/Tags/Format by context/Emphasis"), NULL, general_html_cb, 17, NULL},
400
 
        {N_("/Tags/Format by context/Define"), NULL, general_html_cb, 48, NULL},
401
 
        {N_("/Tags/Format by context/Code"), NULL, general_html_cb, 49, NULL},
402
 
        {N_("/Tags/Format by context/Sample"), NULL, general_html_cb, 50, NULL},
403
 
        {N_("/Tags/Format by context/Keyboard"), NULL, general_html_cb, 51, NULL},
404
 
        {N_("/Tags/Format by context/Variable"), NULL, general_html_cb, 52, NULL},
405
 
        {N_("/Tags/Format by context/Citation"), NULL, general_html_cb, 53, NULL},
406
 
        {N_("/Tags/Format by context/Abbreviation"), NULL, general_html_cb, 54, NULL},
407
 
        {N_("/Tags/Format by context/Acronym"), NULL, general_html_cb, 55, NULL},
408
 
        {N_("/Tags/Format general"), NULL, NULL, 0, "<Branch>"},
 
523
        {N_("/Tags/Format by context/_Strong"), "<control><alt>g", general_html_menu_cb, 16, "<ImageItem>",pixmap_bold},
 
524
        {N_("/Tags/Format by context/_Emphasis"), "<control><alt>e", general_html_menu_cb, 17, "<ImageItem>",pixmap_italic},
 
525
        {N_("/Tags/Format by context/_Define"), NULL, general_html_menu_cb, 48, "<ImageItem>",pixmap_dfn},
 
526
        {N_("/Tags/Format by context/_Code"), NULL, general_html_menu_cb, 49, "<ImageItem>",pixmap_code},
 
527
        {N_("/Tags/Format by context/Sa_mple"), NULL, general_html_menu_cb, 50, "<ImageItem>",pixmap_samp},
 
528
        {N_("/Tags/Format by context/_Keyboard"), NULL, general_html_menu_cb, 51, "<ImageItem>",pixmap_kbd},
 
529
        {N_("/Tags/Format by context/_Variable"), NULL, general_html_menu_cb, 52, "<ImageItem>",pixmap_var},
 
530
        {N_("/Tags/Format by context/Ci_tation"), NULL, general_html_menu_cb, 53, "<ImageItem>",pixmap_cite},
 
531
        {N_("/Tags/Format by context/_Abbreviation"), NULL, general_html_menu_cb, 54, "<ImageItem>",pixmap_abbr},
 
532
        {N_("/Tags/Format by context/Ac_ronym"), NULL, general_html_menu_cb, 55, "<ImageItem>",pixmap_acronym},
 
533
        {N_("/Tags/Format _general"), NULL, NULL, 0, "<Branch>"},
409
534
        {N_("/Tags/Format general/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
410
 
        {N_("/Tags/Format general/Paragraph"), "<alt>P", general_html_cb, 5, NULL},
411
 
        {N_("/Tags/Format general/Break"),  "<Control><Alt>r", general_html_cb, 6, NULL},
412
 
        {N_("/Tags/Format general/Break clear all"), NULL, general_html_cb, 41, NULL},
413
 
        {N_("/Tags/Format general/Non-Breaking Space"), "<alt>n", general_html_cb, 7, NULL},
414
 
        {N_("/Tags/Format general/<separator>"), NULL, NULL, 0, "<Separator>"},
415
 
        {N_("/Tags/Format general/Font Size +1"), "<control>equal", general_html_cb, 11, NULL},
416
 
        {N_("/Tags/Format general/Font Size -1"), "<control>minus", general_html_cb, 12, NULL},
417
 
        {N_("/Tags/Format general/<separator>"), NULL, NULL, 0, "<Separator>"},
418
 
        {N_("/Tags/Format general/Preformatted Text"), "<Control><Alt>p", general_html_cb, 13, NULL},
419
 
        {N_("/Tags/Format general/Subscript"), "<alt><shift>s", general_html_cb, 14, NULL},
420
 
        {N_("/Tags/Format general/Superscript"), "<alt><control>s", general_html_cb, 15, NULL},
421
 
        {N_("/Tags/Format general/<separator>"), NULL, NULL, 0, "<Separator>"},
422
 
        {N_("/Tags/Format general/Center"), "<alt>c", general_html_cb, 8, NULL},
423
 
        {N_("/Tags/Format general/Align right"), "<Alt>r", general_html_cb, 9, NULL},
424
 
        {N_("/Tags/Table"), NULL, NULL, 0, "<Branch>"},
 
535
        {N_("/Tags/Format general/_Paragraph"), "<control><alt>p", general_html_menu_cb, 5, "<ImageItem>",pixmap_paragraph},
 
536
        {N_("/Tags/Format general/_Break"),  "<control><alt>k", general_html_menu_cb, 6, "<ImageItem>",pixmap_brbreak},
 
537
        {N_("/Tags/Format general/Break clear _all"), NULL, general_html_menu_cb, 41, "<ImageItem>",pixmap_breakall},
 
538
        {N_("/Tags/Format general/_Non-Breaking Space"), "<control><alt>n", general_html_menu_cb, 7, "<ImageItem>",pixmap_nbsp},
 
539
        {N_("/Tags/Format general/<separator>"), NULL, NULL, 0, "<Separator>"},
 
540
        {N_("/Tags/Format general/Font Si_ze +1"), "<control><alt>equal", general_html_menu_cb, 11, "<ImageItem>",pixmap_fontp1},
 
541
        {N_("/Tags/Format general/Font _Size -1"), "<control><alt>minus", general_html_menu_cb, 12, "<ImageItem>",pixmap_fontm1},
 
542
        {N_("/Tags/Format general/<separator>"), NULL, NULL, 0, "<Separator>"},
 
543
        {N_("/Tags/Format general/Preformatted _Text"), "<Control><Alt>f", general_html_menu_cb, 13, "<ImageItem>",pixmap_fontpre},
 
544
        {N_("/Tags/Format general/Su_bscript"), NULL, general_html_menu_cb, 14, "<ImageItem>",pixmap_fontsub},
 
545
        {N_("/Tags/Format general/Su_perscript"), NULL, general_html_menu_cb, 15, "<ImageItem>",pixmap_fontsuper},
 
546
        {N_("/Tags/Format general/<separator>"), NULL, NULL, 0, "<Separator>"},
 
547
        {N_("/Tags/Format general/_Center"), NULL, general_html_menu_cb, 8, "<ImageItem>",pixmap_center},
 
548
        {N_("/Tags/Format general/Align _right"), "<control><Alt>r", general_html_menu_cb, 9, "<ImageItem>",pixmap_right},
 
549
        {N_("/Tags/_Table"), NULL, NULL, 0, "<Branch>"},
425
550
        {N_("/Tags/Table/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
426
 
        {N_("/Tags/Table/Table"), NULL, general_html_cb, 24, NULL},
427
 
        {N_("/Tags/Table/Tablerow"), NULL, general_html_cb, 25, NULL},
428
 
        {N_("/Tags/Table/Tableheader"), NULL, general_html_cb, 26, NULL},
429
 
        {N_("/Tags/Table/Tabledata"), NULL, general_html_cb, 27, NULL},
430
 
        {N_("/Tags/Table/Tablecaption"), NULL, general_html_cb, 28, NULL},
431
 
        {N_("/Tags/List"), NULL, NULL, 0, "<Branch>"},
 
551
        {N_("/Tags/Table/_Table"), "<control><alt>t", general_html_menu_cb, 24, "<ImageItem>", pixmap_table2},
 
552
        {N_("/Tags/Table/Table _Row"), NULL, general_html_menu_cb, 25, "<ImageItem>", pixmap_table_tr2},
 
553
        {N_("/Tags/Table/Table _Header"), NULL, general_html_menu_cb, 26, "<ImageItem>", pixmap_table_th2},
 
554
        {N_("/Tags/Table/Table _Data"), NULL, general_html_menu_cb, 27, "<ImageItem>", pixmap_table_td2},
 
555
        {N_("/Tags/Table/Table _Caption"), NULL, general_html_menu_cb, 28, "<ImageItem>", pixmap_table_capt},
 
556
        {N_("/Tags/_List"), NULL, NULL, 0, "<Branch>"},
432
557
        {N_("/Tags/List/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
433
 
        {N_("/Tags/List/Unordered list"), NULL, general_html_cb, 33, NULL},
434
 
        {N_("/Tags/List/Ordered list"), NULL, general_html_cb, 34, NULL},
435
 
        {N_("/Tags/List/List item"), "<alt>l", general_html_cb, 35, NULL},
436
 
        {N_("/Tags/List/Definition list"), NULL, general_html_cb, 36, NULL},
437
 
        {N_("/Tags/List/Definition term"), NULL, general_html_cb, 37, NULL},
438
 
        {N_("/Tags/List/Definition"), NULL, general_html_cb, 38, NULL},
439
 
        {N_("/Tags/List/menu"), NULL, general_html_cb, 39, NULL},
440
 
        {N_("/Tags/Insert Generator META-Tag"), NULL, general_html_cb, 47, NULL},
441
 
        {N_("/Tags/Comment"), NULL, general_html_cb, 10, NULL},
442
 
        {N_("/_Dialogs"), NULL, NULL, 0, "<Branch>"},
 
558
        {N_("/Tags/List/Unordered _List"), "<control><alt>L", general_html_menu_cb, 33, "<ImageItem>", pixmap_list_ul},
 
559
        {N_("/Tags/List/_Ordered List"), "<control><alt>O", general_html_menu_cb, 34, "<ImageItem>", pixmap_list_ol},
 
560
        {N_("/Tags/List/List Ite_m"), "<control><alt>M", general_html_menu_cb, 35, "<ImageItem>", pixmap_list_li},
 
561
        {N_("/Tags/List/De_finition List"), NULL, general_html_menu_cb, 36, "<ImageItem>", pixmap_list_dl},
 
562
        {N_("/Tags/List/Definition _Term"), NULL, general_html_menu_cb, 37, "<ImageItem>", pixmap_list_dt},
 
563
        {N_("/Tags/List/_Definition"), NULL, general_html_menu_cb, 38, "<ImageItem>", pixmap_list_dd},
 
564
        {N_("/Tags/List/Men_u"), NULL, general_html_menu_cb, 39, "<Item>"},
 
565
        {N_("/Tags/Fo_rm"), NULL, NULL, 0, "<Branch>"},
 
566
        {N_("/Tags/Form/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
 
567
        {N_("/Tags/Form/_Form"), NULL, general_html_menu_cb, 67, "<ImageItem>", pixmap_form},
 
568
        {N_("/Tags/Form/_Button"), NULL, general_html_menu_cb, 58, "<Item>"},
 
569
        {N_("/Tags/Form/_Input"), NULL, general_html_menu_cb, 65, "<Item>"},
 
570
        {N_("/Tags/Form/_Textarea"), NULL, general_html_menu_cb, 66, "<Item>"},
 
571
/*      {N_("/Tags/Form/"), NULL, general_html_menu_cb, , "<Item>"},*/
 
572
        {N_("/Tags/_Misc"), NULL, NULL, 0, "<Branch>"},
 
573
        {N_("/Tags/Misc/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
 
574
        {N_("/Tags/Misc/Insert Generator _META-Tag"), NULL, general_html_menu_cb, 47, "<Item>"},
 
575
        {N_("/Tags/Misc/_Span"), NULL, general_html_menu_cb, 60, "<Item>"},
 
576
        {N_("/Tags/Misc/_Div"), NULL, general_html_menu_cb, 62, "<Item>"},
 
577
        {N_("/Tags/Misc/_Link"), NULL, general_html_menu_cb, 61, "<Item>"},
 
578
        {N_("/Tags/Misc/S_cript"), NULL, general_html_menu_cb, 59, "<Item>"},
 
579
        {N_("/Tags/Misc/_Anchor"), NULL, general_html_menu_cb, 63, "<ImageItem>", pixmap_anchor},
 
580
        {N_("/Tags/Misc/_Image"), NULL, general_html_menu_cb, 64, "<ImageItem>", pixmap_image},
 
581
/*      {N_("/Tags/Misc/"), NULL, general_html_menu_cb, , "<Item>"},*/
 
582
        {N_("/Tags/_Comment"), "<control><alt>C", general_html_menu_cb, 10, "<ImageItem>", pixmap_comment},
 
583
        {N_("/Dial_ogs"), NULL, NULL, 0, "<Branch>"},
443
584
        {N_("/Dialogs/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
444
 
        {N_("/Dialogs/General"), NULL, NULL, 0, "<Branch>"},
 
585
        {N_("/Dialogs/_General"), NULL, NULL, 0, "<Branch>"},
445
586
        {N_("/Dialogs/General/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
446
 
        {N_("/Dialogs/General/Quickstart..."), "<alt>q", quickstart_cb, 0, NULL},
 
587
        {N_("/Dialogs/General/_Quickstart..."), "<shift><alt>q", menu_html_dialogs_lcb, 32, "<ImageItem>", pixmap_quick_start},
447
588
/*      {N_("/Dialogs/General/DTD"), NULL, dtd_cb, 0, NULL},
448
589
        {N_("/Dialogs/General/Head"), NULL, head_cb, 0, NULL}, */
449
 
        {N_("/Dialogs/General/Body..."), NULL, body_cb, 0, NULL},
450
 
        {N_("/Dialogs/General/Anchor..."), "<alt>a", quickanchor_cb, 0, NULL},
451
 
        {N_("/Dialogs/General/Email..."), NULL, email_cb, 0, NULL},
452
 
        {N_("/Dialogs/General/Rule..."), "<alt>h", quickrule_cb, 0, NULL},
453
 
        {N_("/Dialogs/General/Font..."), NULL, fontdialog_cb, 0, NULL},
454
 
        {N_("/Dialogs/General/Basefont..."), NULL, basefont_cb, 0, NULL},
455
 
        {N_("/Dialogs/General/Quicklist..."), NULL, quicklist_cb, 0, NULL},
456
 
        {N_("/Dialogs/General/Meta..."), "<alt>m", meta_cb, 0, NULL},
457
 
        {N_("/Dialogs/General/Embed..."), NULL, embed_cb, 0, NULL},
458
 
        {N_("/Dialogs/General/Select colour..."), NULL, sel_colour_cb, 0, NULL},
459
 
        {N_("/Dialogs/General/Insert time..."), NULL, insert_time_cb, 0, NULL},
460
 
        {N_("/Dialogs/General/Insert image..."), "<control>i", image_insert_dialog_cb, 0, NULL},
461
 
#if HAVE_LIBGDK_IMLIB
462
 
        {N_("/Dialogs/General/Insert thumbnail..."), "<control>t", image_thumbnail_dialog_cb, 0, NULL},
463
 
#endif
464
 
        {N_("/Dialogs/Table"), NULL, NULL, 0, "<Branch>"},
 
590
        {N_("/Dialogs/General/_Body..."), "<shift><alt>B", menu_html_dialogs_lcb, 1, "<ImageItem>", pixmap_body},
 
591
        {N_("/Dialogs/General/_Anchor..."), "<shift><alt>a", menu_html_dialogs_lcb, 2, "<ImageItem>", pixmap_anchor},
 
592
        {N_("/Dialogs/General/_Email..."), "<shift><alt>e", menu_html_dialogs_lcb, 3, "<Item>"},
 
593
        {N_("/Dialogs/General/_Rule..."), "<shift><alt>r", menu_html_dialogs_lcb, 4, "<ImageItem>", pixmap_hrule},
 
594
        {N_("/Dialogs/General/_Font..."), "<shift><alt>f", menu_html_dialogs_lcb, 5, "<Item>"},
 
595
        {N_("/Dialogs/General/Basef_ont..."), NULL, menu_html_dialogs_lcb, 6, "<Item>"},
 
596
        {N_("/Dialogs/General/Quick_list..."), "<shift><alt>L", menu_html_dialogs_lcb, 7, "<ImageItem>", pixmap_list},
 
597
        {N_("/Dialogs/General/_Meta..."), "<shift><alt>m", menu_html_dialogs_lcb, 8, "<Item>"},
 
598
        {N_("/Dialogs/General/Embe_d..."), NULL, menu_html_dialogs_lcb, 9, "<Item>"},
 
599
        {N_("/Dialogs/General/Select _Color..."), NULL, menu_html_dialogs_lcb, 37, "<Item>"},
 
600
        {N_("/Dialogs/General/Insert _Time..."), NULL, menu_html_dialogs_lcb, 34, "<Item>"},
 
601
        {N_("/Dialogs/General/Insert _Image..."), "<shift><alt>I", menu_html_dialogs_lcb, 10, "<ImageItem>", pixmap_image},
 
602
        {N_("/Dialogs/General/Insert T_humbnail..."), "<shift><alt>N", menu_html_dialogs_lcb, 11, "<ImageItem>", pixmap_thumbnail},
 
603
        {N_("/Dialogs/_Table"), NULL, NULL, 0, "<Branch>"},
465
604
        {N_("/Dialogs/Table/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
466
 
        {N_("/Dialogs/Table/Table..."), NULL, tabledialog_cb, 0, NULL},
467
 
        {N_("/Dialogs/Table/Tablerow..."), NULL, tablerowdialog_cb, 0, NULL},
468
 
        {N_("/Dialogs/Table/Tablehead..."), NULL, tableheaddialog_cb, 0, NULL},
469
 
        {N_("/Dialogs/Table/Tabledata..."), NULL, tabledatadialog_cb, 0, NULL},
470
 
        {N_("/Dialogs/CSS"), NULL, NULL, 0, "<Branch>"},
 
605
        {N_("/Dialogs/Table/Table _Wizard..."), NULL, menu_html_dialogs_lcb, 12, "<ImageItem>", pixmap_tablewhiz},
 
606
        {N_("/Dialogs/Table/_Table..."), "<shift><alt>T", menu_html_dialogs_lcb, 13, "<ImageItem>", pixmap_table},
 
607
        {N_("/Dialogs/Table/Table _Row..."), NULL, menu_html_dialogs_lcb, 14, "<ImageItem>", pixmap_table_tr},
 
608
        {N_("/Dialogs/Table/Table _Head..."), NULL, menu_html_dialogs_lcb, 15, "<ImageItem>", pixmap_table_th},
 
609
        {N_("/Dialogs/Table/Table _Data..."), NULL, menu_html_dialogs_lcb, 16, "<ImageItem>", pixmap_table_td},
 
610
        {N_("/Dialogs/_CSS"), NULL, NULL, 0, "<Branch>"},
471
611
        {N_("/Dialogs/CSS/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
472
 
        {N_("/Dialogs/CSS/Create style..."), NULL, new_css_dialog, 0, NULL},
473
 
        {N_("/Dialogs/CSS/Span..."), NULL, span_dialog, 0, NULL},
474
 
        {N_("/Dialogs/CSS/Div..."), NULL, div_dialog, 0, NULL},
475
 
#ifdef OLD_CSS_DIALOG
476
 
        {N_("/Dialogs/CSS/Add class..."), NULL, insert_class, 0, NULL},
477
 
#endif
478
 
        {N_("/Dialogs/CSS/Style..."), NULL, general_html_cb, 42, NULL},
479
 
        {N_("/Dialogs/CSS/Link to stylesheet..."), NULL, link_cb, 0, NULL},
480
 
        {N_("/Dialogs/Frame"), NULL, NULL, 0, "<Branch>"},
 
612
        {N_("/Dialogs/CSS/_Create Style..."), "<shift><alt>S", menu_html_dialogs_lcb, 36, "<ImageItem>",pixmap_cssnewstyle},
 
613
        {N_("/Dialogs/CSS/S_pan..."), NULL, menu_html_dialogs_lcb, 17, "<ImageItem>",pixmap_cssspan},
 
614
        {N_("/Dialogs/CSS/_Div..."), "<shift><alt>D", menu_html_dialogs_lcb, 18, "<ImageItem>",pixmap_cssdiv},
 
615
        {N_("/Dialogs/CSS/_Style..."), NULL, general_html_menu_cb, 42, "<ImageItem>",pixmap_cssstyle},
 
616
        {N_("/Dialogs/CSS/_Link to Stylesheet..."), NULL, menu_html_dialogs_lcb, 35, "<Item>"},
 
617
        {N_("/Dialogs/_Frame"), NULL, NULL, 0, "<Branch>"},
481
618
        {N_("/Dialogs/Frame/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
482
 
        {N_("/Dialogs/Frame/Frameset..."), NULL, framesetdialog_cb, 0, NULL},
483
 
        {N_("/Dialogs/Frame/Frame..."), NULL, framedialog_cb, 0, NULL},
484
 
        {N_("/Dialogs/Form"), NULL, NULL, 0, "<Branch>"},
 
619
        {N_("/Dialogs/Frame/Frame _Wizard..."), NULL, menu_html_dialogs_lcb, 19, "<ImageItem>", pixmap_framewhiz},
 
620
        {N_("/Dialogs/Frame/Frame_set..."), NULL, menu_html_dialogs_lcb, 20, "<ImageItem>", pixmap_frameset},
 
621
        {N_("/Dialogs/Frame/_Frame..."), NULL, menu_html_dialogs_lcb, 21, "<ImageItem>", pixmap_frame},
 
622
        {N_("/Dialogs/F_orm"), NULL, NULL, 0, "<Branch>"},
485
623
        {N_("/Dialogs/Form/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
486
 
        {N_("/Dialogs/Form/Form..."), NULL, formdialog_cb, 0, NULL},
487
 
        {N_("/Dialogs/Form/Input button..."), NULL, buttondialog_cb, 0, NULL},
488
 
        {N_("/Dialogs/Form/Text..."), NULL, textdialog_cb, 0, NULL},
489
 
        {N_("/Dialogs/Form/Hidden..."), NULL, hiddendialog_cb, 0, NULL},
490
 
        {N_("/Dialogs/Form/Textarea..."), NULL, textareadialog_cb, 0, NULL},
491
 
        {N_("/Dialogs/Form/Radio buttons..."), NULL, radiodialog_cb, 0, NULL},
492
 
        {N_("/Dialogs/Form/Check buttons..."), NULL, checkdialog_cb, 0, NULL},
493
 
        {N_("/Dialogs/Form/Select..."), NULL, selectdialog_cb, 0, NULL},
494
 
        {N_("/Dialogs/Form/Option..."), NULL, optiondialog_cb, 0, NULL},
495
 
        {N_("/Dialogs/Form/Option group..."), NULL, optgroupdialog_cb, 0, NULL},
496
 
        {N_("/Dialogs/Javascript"), NULL, NULL, 0, "<Branch>"},
 
624
        {N_("/Dialogs/Form/F_orm..."), NULL, menu_html_dialogs_lcb, 22, "<ImageItem>", pixmap_form},
 
625
        {N_("/Dialogs/Form/_Input..."), NULL, menu_html_dialogs_lcb, 33, "<Item>"},
 
626
        {N_("/Dialogs/Form/Input Buttons..."), NULL, menu_html_dialogs_lcb, 23, "<ImageItem>", pixmap_form_submit},
 
627
        {N_("/Dialogs/Form/Input Text..."), NULL, menu_html_dialogs_lcb, 24, "<ImageItem>", pixmap_form_text},
 
628
        {N_("/Dialogs/Form/Text_area..."), NULL, menu_html_dialogs_lcb, 26, "<ImageItem>", pixmap_form_textarea},
 
629
        {N_("/Dialogs/Form/_Select..."), NULL, menu_html_dialogs_lcb, 29, "<ImageItem>", pixmap_form_select},
 
630
        {N_("/Dialogs/Form/O_ption..."), NULL, menu_html_dialogs_lcb, 30, "<ImageItem>", pixmap_form_option},
 
631
        {N_("/Dialogs/Form/Option _Group..."), NULL, menu_html_dialogs_lcb, 31, "<ImageItem>",pixmap_form_optiongroup },
 
632
        {N_("/Dialogs/Form/_Button..."), NULL, menu_html_dialogs_lcb, 25, "<Item>"},
 
633
/*      {N_("/Dialogs/Javascript"), NULL, NULL, 0, "<Branch>"},
497
634
        {N_("/Dialogs/Javascript/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
498
635
        {N_("/Dialogs/Javascript/Mouseover Script"), NULL, mouseover_script_cb, 0, NULL},
499
636
        {N_("/Dialogs/Javascript/Netscape 4 Resize Bugfix Script"), NULL, ns47_bugfix_script_cb, 0, NULL},
518
655
        {N_("/Dialogs/WML/Refresh"), NULL, general_wml_cb, 8, NULL},
519
656
        {N_("/Dialogs/WML/Noop"), NULL, general_wml_cb, 9, NULL},
520
657
        {N_("/Dialogs/WML/sep13"), NULL, NULL, 0, "<Separator>"},
521
 
        {N_("/Dialogs/WML/Set Variable..."), NULL, vardialog_cb, 0, NULL},
522
 
#ifdef IMAGEMAP_EDITOR_TEST
523
 
        {N_("/Dialogs/imagemap development..."), NULL, make_imagemap_win, 0, NULL},
524
 
#endif
 
658
        {N_("/Dialogs/WML/Set Variable..."), NULL, vardialog_cb, 0, NULL},*/
 
659
        {N_("/Dialogs/sep1"), NULL, NULL, 0, "<Separator>"},
 
660
        {N_("/Dialogs/_Edit tag under cursor..."), "F3", menu_html_dialogs_lcb, 38, "<ImageItem>", pixmap_edit_tag},
 
661
        {N_("/_Document"), NULL, NULL, 0, "<Branch>"},
 
662
        {N_("/Document/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
 
663
        {N_("/Document/_Increase Tabsize"), NULL, gui_change_tabsize, 1, "<Item>"},
 
664
        {N_("/Document/_Decrease Tabsize"), NULL, gui_change_tabsize, 0, "<Item>"},
 
665
        {N_("/Document/_Auto Indent"), NULL, toggle_doc_property, 4, "<ToggleItem>"},
 
666
        {N_("/Document/sep1"), NULL, NULL, 0, "<Separator>"},
 
667
        {N_("/Document/Auto Close H_TML tags"), "<control>T", toggle_doc_property, 3, "<ToggleItem>"},
 
668
        {N_("/Document/_Wrap"), NULL, toggle_doc_property, 1, "<ToggleItem>"},
 
669
        {N_("/Document/_Line Numbers"), NULL, toggle_doc_property, 2, "<ToggleItem>"},
 
670
        {N_("/Document/sep2"), NULL, NULL, 0, "<Separator>"},
 
671
        {N_("/Document/_Highlight Syntax"), NULL, doc_toggle_highlighting_cb, 1, "<ToggleItem>"},
 
672
        {N_("/Document/_Update Highlighting"), "F5", doc_update_highlighting, 0, "<Item>"},
 
673
        {N_("/Document/sep3"), NULL, NULL, 0, "<Separator>"},
 
674
        {N_("/Document/Document Ty_pe"), NULL, NULL, 0, "<Branch>"},
 
675
        {N_("/Document/Document Type/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
 
676
        {N_("/Document/Character _Encoding"), NULL, NULL, 0, "<Branch>"},
 
677
        {N_("/Document/Character Encoding/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
 
678
        {N_("/Document/sep4"), NULL, NULL, 0, "<Separator>"},
 
679
#ifdef HAVE_LIBASPELL
 
680
        {N_("/Document/Check _Spelling..."), NULL, spell_check_menu_cb, 0, "<StockItem>", GTK_STOCK_SPELL_CHECK},
 
681
#endif /* HAVE_LIBASPELL */
 
682
        {N_("/Document/_Floating window"), NULL, file_floatingview_menu_cb, 1, "<Item>"},                       
 
683
        {N_("/Document/Word _Count"), NULL, word_count_cb, 1, "<Item>"},
 
684
        {N_("/_Go"), NULL, NULL, 0, "<Branch>"},
 
685
        {N_("/Go/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
 
686
        {N_("/Go/_Previous document"), NULL, gui_notebook_switch, 1, "<StockItem>", GTK_STOCK_GO_BACK},
 
687
        {N_("/Go/_Next document"), NULL, gui_notebook_switch, 2, "<StockItem>", GTK_STOCK_GO_FORWARD},
 
688
        {N_("/Go/sep1"), NULL, NULL, 0, "<Separator>"},
 
689
        {N_("/Go/_First document"), NULL, gui_notebook_switch, 3, "<StockItem>", GTK_STOCK_GOTO_FIRST},
 
690
        {N_("/Go/L_ast document"), NULL, gui_notebook_switch, 4, "<StockItem>", GTK_STOCK_GOTO_LAST},
 
691
        {N_("/Go/sep1"), NULL, NULL, 0, "<Separator>"}, 
 
692
        {N_("/Go/Goto _Line"), "<control>l", go_to_line_win_cb, 1, "<StockItem>", GTK_STOCK_JUMP_TO},
 
693
        {N_("/Go/Goto _Selection"), NULL, go_to_line_from_selection_cb, 1, "<Item>"},
 
694
        {N_("/_Project"), NULL, NULL, 0, "<Branch>"},
 
695
        {N_("/Project/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
 
696
        {N_("/Project/_New Project"), NULL, project_menu_cb, 6, "<Item>"},
 
697
        {N_("/Project/_Open Project..."), NULL, project_menu_cb, 1, "<Item>"},
 
698
        {N_("/Project/Open _recent"), NULL, NULL, 0, "<Branch>"},               
 
699
        {N_("/Project/Open recent/tearoff1"), NULL, NULL, 0, "<Tearoff>"},      
 
700
        {N_("/Project/sep1"), NULL, NULL, 0, "<Separator>"},
 
701
        {N_("/Project/_Save"), NULL, project_menu_cb, 2, "<Item>"},
 
702
        {N_("/Project/Save _as..."), NULL, project_menu_cb, 3, "<Item>"},
 
703
        {N_("/Project/Save & _close"), NULL, project_menu_cb, 4, "<Item>"},
 
704
        {N_("/Project/sep2"), NULL, NULL, 0, "<Separator>"},
 
705
        {N_("/Project/E_dit Project Options..."), NULL, project_menu_cb, 5, "<StockItem>", GTK_STOCK_PREFERENCES},
525
706
        {N_("/E_xternal"), NULL, NULL, 0, "<Branch>"},
526
 
        {N_("/External/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
527
 
        {N_("/External/Weblint..."), NULL, run_weblint_cb, 0, NULL},
528
 
        {N_("/External/sep1"), NULL, NULL, 0, "<Separator>"},
529
 
        {N_("/External/Filters"), NULL, NULL, 0, "<Branch>"},
530
 
        {N_("/External/Filters/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
531
 
        {N_("/External/Commands"), NULL, NULL, 0, "<Branch>"},
 
707
        {N_("/External/tearoff1"), NULL, NULL, 0, "<Tearoff>"}, 
 
708
/*      {N_("/External/_Commands"), NULL, NULL, 0, "<Branch>"},
532
709
        {N_("/External/Commands/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
533
 
#ifdef PERL
534
 
        {N_("/_Perl"), NULL, NULL, 0, "<Branch>"},
535
 
        {N_("/Perl/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
536
 
        {N_("/Perl/Status..."), NULL, perl_status_cb, 0, NULL},
537
 
        {N_("/Perl/Strip CR Codes"), NULL, perl_strip_cr_cb, 0, NULL},
538
 
#endif
539
 
        {N_("/_Options"), NULL, NULL, 0, "<Branch>"},
540
 
        {N_("/Options/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
541
 
        {N_("/Options/Preferences..."), NULL, configure_cb, 0, NULL},
542
 
        {N_("/Options/View Main toolbar"), NULL, toggle_main_toolbar_cb, 0, "<ToggleItem>"},
543
 
        {N_("/Options/View HTML toolbar"), NULL, toggle_html_toolbar_cb, 0, "<ToggleItem>"},
544
 
        {N_("/Options/View Custom toolbar"), NULL, toggle_cust_menubar_cb, 0, "<ToggleItem>"},
545
 
        {N_("/Options/View Filebrowser"), NULL, toggle_filebrowser_cb, 0, "<ToggleItem>"},
546
 
        {N_("/Options/sep2"), NULL, NULL, 0, "<Separator>"},
547
 
        {N_("/Options/_Lists"), NULL, NULL, 0, "<Branch>"},
548
 
        {N_("/Options/Lists/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
549
 
        {N_("/Options/Lists/External filters..."), NULL, edit_some_list_lcb, 1, NULL},
550
 
        {N_("/Options/Lists/External programs..."), NULL, edit_some_list_lcb, 2, NULL},
551
 
        {N_("/Options/Lists/Syntax highlighting..."), NULL, edit_some_list_lcb, 3, NULL},
552
 
        {N_("/Options/Lists/Reset syntax highlighting"), NULL, reset_syntax_highlighting_lcb, 0, NULL},
553
 
        {N_("/Options/sep1"), NULL, NULL, 0, "<Separator>"},
554
 
        {N_("/Options/Save config"), NULL, save_config_files, 0, NULL},
555
 
        {N_("/Options/Save shortcut key settings"), NULL, save_menu_shortcuts, 0, NULL},
 
710
        {N_("/External/_Outputbox"), NULL, NULL, 0, "<Branch>"},
 
711
        {N_("/External/Outputbox/tearoff1"), NULL, NULL, 0, "<Tearoff>"},
 
712
        {N_("/External/sep1"), NULL, NULL, 0, "<Separator>"},*/
556
713
        {N_("/_Help"), NULL, NULL, 0, "<Branch>"},
557
 
        {N_("/Help/_About..."), NULL, show_about_window_cb, 0, NULL}
558
 
};
559
 
 
560
 
static gchar *sp_chars[] = {
561
 
        "&Agrave;", "&Aacute;", "&Acirc;", "&Atilde;", "&AElig;",
562
 
        "&Auml;", "&Aring;", "&Ccedil;", "&Egrave;", "&Eacute;",
563
 
        "&Ecirc;", "&Euml;", "&Igrave;", "&Iacute;", "&Icirc;",
564
 
        "&Iuml;", "&Ntilde;", "&Ograve;", "&Oacute;", "&Ocirc;",
565
 
        "&Otilde;", "&Ouml;", "&Oslash;", "&Ugrave;", "&Uacute;",
566
 
        "&Ucirc;", "&Uuml;", "&Yacute;", "&agrave;", "&aacute;",
567
 
        "&acirc;", "&atilde;", "&aring;", "&aelig;", "&auml;",
568
 
        "&ccedil;", "&egrave;", "&eacute;", "&ecirc;", "&euml;",
569
 
        "&igrave;", "&iacute;", "&icirc;", "&iuml;", "&ntilde;",
570
 
        "&ograve;", "&oacute;", "&ocirc;", "&otilde;", "&ouml;",
571
 
        "&oslash;", "&ugrave;", "&uacute;", "&ucirc;", "&uuml;",
572
 
        "&yacute;", "&yuml;", "&uml;", "&acute;", "&cedil;", "&cent;",
573
 
        "&pound;", "&curren;", "&yen;", "&not;", "&mult;", "&divide;",
574
 
        "&plusmn;", "&lt;", "&gt;", "&sup1;", "&sup2;", "&sup3;",
575
 
        "&frac14;", "&frac12;", "&frac34;", "&deg;", "&ETH;", "&THORN;",
576
 
        "&eth;", "&thorn;", "&szlig;", "&micro;", "&nbsp;", "&sect;",
577
 
        "&copy;", "&laquo;", "&raquo;", "&reg;", "&iexcl;", "&iquest;",
578
 
        "&ordf;", "&ordm;", "&para;", "&brvbar;", "&shy;", "&macr;",
579
 
        "&middot;"
580
 
};
581
 
#ifndef PATH_MAX
582
 
#define PATH_MAX 1024
583
 
#endif
584
 
 
585
 
void save_menu_shortcuts() {
586
 
        gchar *filename;
587
 
        
588
 
        filename = g_malloc(PATH_MAX+1);
589
 
        filename = strncat(strncpy(filename, g_get_home_dir(), PATH_MAX), "/.bluefish/menudump", PATH_MAX);
590
 
        gtk_item_factory_dump_rc(filename, NULL, TRUE);
591
 
        g_free(filename);
592
 
}
593
 
 
594
 
void load_menu_shortcuts() {
595
 
        gchar *filename;
596
 
        
597
 
        filename = g_malloc(PATH_MAX+1);
598
 
        filename = strncat(strncpy(filename, g_get_home_dir(), PATH_MAX), "/.bluefish/menudump", PATH_MAX);
599
 
        gtk_item_factory_parse_rc(filename);
600
 
        g_free(filename);
601
 
}
602
 
 
603
 
static void make_external_commands() {
604
 
        make_external_menu_entries(2);
605
 
}
606
 
static void make_external_filters() {
607
 
        make_external_menu_entries(1);
608
 
}
609
 
 
610
 
static void edit_some_list_lcb(GtkWidget * widget, gpointer data)
611
 
{
612
 
        switch (GPOINTER_TO_INT(data)) {
613
 
        case 1:
614
 
                {
615
 
                gchar *titles[] = { _("name"), _("command"), NULL};
616
 
                estrl_dialog(&main_v->props.external_filters, _("Bluefish configuration - external filters"), 7, 2, &titles[0], make_external_filters);
617
 
                }
618
 
                break;
619
 
        case 2:
620
 
                {
621
 
                gchar *titles[] = { _("name"), _("command"), NULL};
622
 
                estrl_dialog(&main_v->props.external_commands, _("Bluefish configuration - external commands"), 7, 2, &titles[0], make_external_commands);
623
 
                }
624
 
                break;
625
 
        case 3:
626
 
                {
627
 
                gchar *titles[] = {_("color"), _("regex pattern"), NULL};
628
 
                estrl_dialog(&main_v->props.syntax_configstrings, _("Bluefish configuration - syntax highlighting"), 8, 2, &titles[0], make_syntax_struct_list);
629
 
                }
630
 
                break;
631
 
        default:
632
 
 
633
 
                break;
634
 
        }
635
 
}
636
 
 
637
 
 
638
 
/***************************************************************************/
639
 
/* takes care of inserting the special characters */
640
 
static void insert_char_cb(GtkWidget * widget, gint data)
641
 
{
642
 
        insert_dbl_text(sp_chars[data], NULL);
 
714
        {N_("/Help/_About..."), NULL, about_dialog_create, 0, "<Item>"},        
 
715
};
 
716
 
 
717
#ifdef ENABLE_NLS
 
718
gchar *menu_translate(const gchar * path, gpointer data) {
 
719
        gchar *retval;
 
720
/*      static gchar *menupath = NULL;
 
721
        if (menupath) g_free(menupath);
 
722
        menupath = g_strdup(path);
 
723
        if ((strstr(path, "/tearoff1") != NULL) 
 
724
                        || (strstr(path, "/---") != NULL) 
 
725
                        || (strstr(path, "/sep1") != NULL)) {
 
726
                DEBUG_MSG("menu_translate, nogettext returning %s for %s\n", menupath, path);
 
727
                return menupath;
 
728
        }*/
 
729
        retval = gettext(path);
 
730
        return retval;
 
731
}
 
732
#endif       
 
733
 
 
734
/************************************************/
 
735
/* generic functions for dynamic created menu's */
 
736
/************************************************/
 
737
 
 
738
typedef struct {
 
739
        Tbfwin *bfwin;
 
740
        GtkWidget *menuitem;
 
741
        gpointer data;
 
742
        gulong signal_id;
 
743
} Tbfw_dynmenu;
 
744
#define BFW_DYNMENU(var) ((Tbfw_dynmenu *)(var))
 
745
 
 
746
static Tbfw_dynmenu *find_bfw_dynmenu_by_data_in_list(GList *thelist, gpointer data) {
 
747
        GList *tmplist = g_list_first(thelist);
 
748
        while (tmplist) {
 
749
                if (BFW_DYNMENU(tmplist->data)->data == data) return BFW_DYNMENU(tmplist->data);
 
750
                tmplist = g_list_next(tmplist);
 
751
        }
 
752
        return NULL;
 
753
}
 
754
 
 
755
/*
 
756
NOT IN USE
 
757
static Tbfw_dynmenu *find_bfw_dynmenu_by_label_in_list(GList *itemlist, gchar *label) {
 
758
        GList *tmplist;
 
759
 
 
760
        tmplist = g_list_first(itemlist);
 
761
        while (tmplist) {
 
762
                if(!strcmp(GTK_LABEL(GTK_BIN(BFW_DYNMENU(tmplist->data)->menuitem)->child)->label, label)) {
 
763
                        return BFW_DYNMENU(tmplist->data);
 
764
                }
 
765
                tmplist = g_list_next(tmplist);
 
766
        }
 
767
        return NULL;
 
768
}
 
769
*/
 
770
 
 
771
static GtkWidget *remove_menuitem_in_list_by_label(const gchar *labelstring, GList **menuitemlist) {
 
772
        GList *tmplist;
 
773
        gpointer tmp;
 
774
 
 
775
        tmplist = g_list_first(*menuitemlist);
 
776
        while (tmplist) {
 
777
                DEBUG_MSG("remove_recent_entry, tmplist=%p, data=%p\n", tmplist, tmplist->data);
 
778
                DEBUG_MSG("remove_recent_entry, tmplist->data=%s\n",GTK_LABEL(GTK_BIN(tmplist->data)->child)->label);
 
779
                if(!strcmp(GTK_LABEL(GTK_BIN(tmplist->data)->child)->label, labelstring)) {
 
780
                        tmp = tmplist->data;
 
781
                        *menuitemlist = g_list_remove(*menuitemlist, tmplist->data);
 
782
                        DEBUG_MSG("remove_recent_entry, returning %p\n", tmp);
 
783
                        return tmp;
 
784
                }
 
785
                tmplist = g_list_next(tmplist);
 
786
        }
 
787
        return NULL;
 
788
}
 
789
 
 
790
/* the result of this function can be added to the menuitem-list */
 
791
static GtkWidget *create_dynamic_menuitem(Tbfwin *bfwin, gchar *menubasepath, const gchar *label, GCallback callback, gpointer data, gint menu_insert_offset) {
 
792
        GtkWidget *tmp, *menu;
 
793
        GtkItemFactory *factory;
 
794
 
 
795
        /* add it to bfwin->menubar */
 
796
        factory = gtk_item_factory_from_widget(bfwin->menubar);
 
797
        menu = gtk_item_factory_get_widget(factory, menubasepath);
 
798
        DEBUG_MSG("create_dynamic_menuitem, menubar=%p, menu=%p basepath=%s, label=%s\n", bfwin->menubar, menu, menubasepath,label);
 
799
        if (menu != NULL) {
 
800
                tmp = gtk_menu_item_new_with_label(label);
 
801
                g_signal_connect(G_OBJECT(tmp), "activate",callback, data);
 
802
 
 
803
                gtk_widget_show(tmp);
 
804
                if (menu_insert_offset == -1) {
 
805
                        gtk_menu_shell_append(GTK_MENU_SHELL(menu),tmp);
 
806
                } else {
 
807
                        gtk_menu_shell_insert(GTK_MENU_SHELL(menu),tmp,menu_insert_offset);
 
808
                }
 
809
                return tmp;
 
810
        } else {
 
811
                DEBUG_MSG("create_dynamic_menuitem, NO MENU FOR BASEPATH %s\n", menubasepath);
 
812
                return NULL;
 
813
        }
 
814
}
 
815
 
 
816
static void create_parent_and_tearoff(gchar *menupath, GtkItemFactory *ifactory) {
 
817
        char *basepath;
 
818
        GtkWidget *widg=NULL;
 
819
        GtkItemFactoryEntry entry;
 
820
 
 
821
        basepath = g_strndup(menupath, (strlen(menupath) - strlen(strrchr(menupath, '/'))));
 
822
        DEBUG_MSG("create_parent_and_tearoff, basepath=%s for menupath=%s\n", basepath, menupath);
 
823
        widg = gtk_item_factory_get_widget(ifactory, basepath);
 
824
        if (!widg) {
 
825
                DEBUG_MSG("create_parent_and_tearoff, no widget found for %s, will create it\n", basepath);
 
826
                create_parent_and_tearoff(basepath, ifactory);
 
827
                entry.path = g_strconcat(basepath, "/tearoff1", NULL);
 
828
                entry.accelerator = NULL;
 
829
                entry.callback = NULL;
 
830
                entry.callback_action = 0;
 
831
                entry.item_type = "<Tearoff>";
 
832
                gtk_item_factory_create_item(ifactory, &entry, NULL, 2);
 
833
                g_free(entry.path);
 
834
        }
 
835
        g_free(basepath);
 
836
}       
 
837
 
 
838
static void menu_current_document_type_change(GtkMenuItem *menuitem,Tbfw_dynmenu *bdm) {
 
839
        DEBUG_MSG("menu_current_document_type_change, started for hlset %p\n", bdm->data);
 
840
        if (GTK_CHECK_MENU_ITEM(menuitem)->active) {
 
841
                if (doc_set_filetype(bdm->bfwin->current_document, bdm->data)) {
 
842
                        doc_highlight_full(bdm->bfwin->current_document);
 
843
                } else {
 
844
                        menu_current_document_set_toggle_wo_activate(bdm->bfwin,bdm->bfwin->current_document->hl, NULL);
 
845
                }
 
846
        }
 
847
        doc_set_statusbar_editmode_encoding(bdm->bfwin->current_document);
 
848
        DEBUG_MSG("menu_current_document_type_change, finished\n");
 
849
}
 
850
 
 
851
void filetype_menus_empty() {
 
852
        GList *tmplist = g_list_first(main_v->bfwinlist);
 
853
        while (tmplist) {
 
854
                Tbfwin *bfwin = BFWIN(tmplist->data);
 
855
                GList *tmplist2 = g_list_first(bfwin->menu_filetypes);
 
856
                while (tmplist2) {
 
857
                        Tbfw_dynmenu *bdm = BFW_DYNMENU(tmplist2->data);
 
858
                        g_signal_handler_disconnect(bdm->menuitem,bdm->signal_id);
 
859
                        gtk_widget_destroy(bdm->menuitem);
 
860
                        g_free(bdm);
 
861
                        tmplist2 = g_list_next(tmplist2);
 
862
                }
 
863
                tmplist = g_list_next(tmplist);
 
864
        }
 
865
}
 
866
 
 
867
void filetype_menu_rebuild(Tbfwin *bfwin,GtkItemFactory *item_factory) {
 
868
        GSList *group=NULL;
 
869
        GtkWidget *parent_menu;
 
870
        GList *tmplist = g_list_last(main_v->filetypelist);
 
871
        if (!item_factory) {
 
872
                item_factory = gtk_item_factory_from_widget(bfwin->menubar);
 
873
        }
 
874
        DEBUG_MSG("filetype_menu_rebuild, adding filetypes in menu\n");
 
875
        bfwin->menu_filetypes = NULL;
 
876
        parent_menu = gtk_item_factory_get_widget(item_factory, N_("/Document/Document Type"));
 
877
        while (tmplist) {
 
878
                Tfiletype *filetype = (Tfiletype *)tmplist->data;
 
879
                if (filetype->editable) {
 
880
                        Tbfw_dynmenu *bdm = g_new(Tbfw_dynmenu,1);
 
881
                        bdm->data = filetype;
 
882
                        bdm->bfwin = bfwin;
 
883
                        bdm->menuitem = gtk_radio_menu_item_new_with_label(group, filetype->type);
 
884
                        bdm->signal_id = g_signal_connect(G_OBJECT(bdm->menuitem), "activate",G_CALLBACK(menu_current_document_type_change), (gpointer) bdm);
 
885
                        gtk_widget_show(bdm->menuitem);
 
886
                        gtk_menu_insert(GTK_MENU(parent_menu), bdm->menuitem, 1);
 
887
                        group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(bdm->menuitem));
 
888
                        bfwin->menu_filetypes = g_list_append(bfwin->menu_filetypes, bdm);
 
889
                }
 
890
                tmplist = g_list_previous(tmplist);
 
891
        }
643
892
}
644
893
 
645
894
/* 
646
895
 * menu factory crap, thanks to the gtk tutorial for this
647
896
 * both the 1.0 and the 1.2 code is directly from the tutorial
648
897
 */
649
 
void get_main_menu(GtkWidget * window, GtkWidget ** menubar)
650
 
{
 
898
void menu_create_main(Tbfwin *bfwin, GtkWidget *vbox) {
651
899
        GtkItemFactory *item_factory;
652
900
        GtkAccelGroup *accel_group;
653
901
        gint nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]);
654
902
        accel_group = gtk_accel_group_new();
655
 
        item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group);
 
903
        item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<bluefishmain>", accel_group);
656
904
#ifdef ENABLE_NLS
657
 
        gtk_item_factory_set_translate_func(item_factory, menu_translate, "<main>", NULL);
658
 
#endif
659
 
        gtk_item_factory_create_items(item_factory, nmenu_items, menu_items, NULL);
660
 
        gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
661
 
        if (menubar)
662
 
                *menubar = gtk_item_factory_get_widget(item_factory, "<main>");
663
 
        setup_toggle_item(item_factory, "/Options/View Main toolbar", main_v->props.v_main_tb);
664
 
        setup_toggle_item(item_factory, "/Options/View HTML toolbar", main_v->props.v_html_tb);
665
 
        setup_toggle_item(item_factory, "/Options/View Custom toolbar", main_v->props.v_custom_tb);
666
 
        setup_toggle_item(item_factory, "/Options/View Filebrowser", main_v->props.v_filebrowser);
667
 
        setup_toggle_item(item_factory, "/View/Highlight syntax", main_v->props.cont_highlight_update);
668
 
}
669
 
 
670
 
 
671
 
/*********************************************************************/
 
905
        gtk_item_factory_set_translate_func(item_factory, menu_translate, "<bluefishmain>", NULL);
 
906
#endif
 
907
        gtk_item_factory_create_items(item_factory, nmenu_items, menu_items, bfwin);
 
908
        gtk_window_add_accel_group(GTK_WINDOW(bfwin->main_window), accel_group);
 
909
        bfwin->menubar = gtk_item_factory_get_widget(item_factory, "<bluefishmain>");
 
910
        gtk_box_pack_start(GTK_BOX(vbox), bfwin->menubar, FALSE, TRUE, 0);
 
911
        gtk_accel_map_add_entry("<bluefishmain>/Edit/Shift Right", GDK_period, GDK_CONTROL_MASK);
 
912
        gtk_accel_map_add_entry("<bluefishmain>/Edit/Shift Left", GDK_comma, GDK_CONTROL_MASK);
 
913
        gtk_accel_map_add_entry("<bluefishmain>/Go/Previous document", GDK_Page_Up, GDK_CONTROL_MASK);
 
914
        gtk_accel_map_add_entry("<bluefishmain>/Go/Next document", GDK_Page_Down, GDK_CONTROL_MASK);
 
915
        gtk_accel_map_add_entry("<bluefishmain>/Go/First document", GDK_Page_Up, GDK_SHIFT_MASK | GDK_CONTROL_MASK);
 
916
        gtk_accel_map_add_entry("<bluefishmain>/Go/Last document", GDK_Page_Down, GDK_SHIFT_MASK | GDK_CONTROL_MASK);   
 
917
        gtk_widget_show(bfwin->menubar);
 
918
 
 
919
        setup_toggle_item(item_factory, "/View/View Main Toolbar", main_v->props.view_main_toolbar);
 
920
        setup_toggle_item(item_factory, "/View/View HTML Toolbar", main_v->props.view_html_toolbar);
 
921
        setup_toggle_item(item_factory, "/View/View Custom Menu", main_v->props.view_custom_menu);
 
922
        setup_toggle_item(item_factory, "/View/View Sidebar", main_v->props.view_left_panel);
 
923
        setup_toggle_item(item_factory, "/Document/Auto Indent", main_v->props.autoindent);
 
924
        set_project_menu_widgets(bfwin, FALSE);
 
925
        filetype_menu_rebuild(bfwin, item_factory);
 
926
}
 
927
 
 
928
 
 
929
/*************************************************************/
 
930
/*               Output Box handling                         */
 
931
/*************************************************************/
 
932
static GtkWidget *dynamic_menu_append_spacing(Tbfwin *bfwin, gchar *basepath) {
 
933
        GtkItemFactory *factory;
 
934
        GtkWidget *menu, *menuitem;
 
935
        factory = gtk_item_factory_from_widget(bfwin->menubar);
 
936
        menu = gtk_item_factory_get_widget(factory, basepath);
 
937
        menuitem = gtk_menu_item_new();
 
938
        gtk_widget_show(menuitem);
 
939
        gtk_menu_shell_append(GTK_MENU_SHELL(menu),menuitem);
 
940
        return menuitem;
 
941
}
 
942
 
 
943
static void menu_outputbox_lcb(GtkMenuItem *menuitem,Tbfw_dynmenu *bdm) {
 
944
        gchar **arr = (gchar **)bdm->data;
 
945
        outputbox(bdm->bfwin,arr[1], atoi(arr[2]), atoi(arr[3]), atoi(arr[4]), arr[5], (arr[6][0]=='1'));
 
946
}
 
947
 
 
948
/*******************************************************************/
 
949
/*               Open Recent menu handling                         */
 
950
/*******************************************************************/
 
951
/* the only required header */
 
952
static GtkWidget *create_recent_entry(Tbfwin *bfwin, const gchar *filename, gboolean is_project, gboolean check_for_duplicates);
 
953
/*******************************************************************/
 
954
 
 
955
static GtkWidget *remove_recent_entry(Tbfwin *bfwin, const gchar *filename, gboolean is_project) {
 
956
        GList *tmplist;
 
957
        GList **worklist;
 
958
        gpointer tmp;
 
959
 
 
960
        worklist = (is_project) ? &bfwin->menu_recent_projects : &bfwin->menu_recent_files;
 
961
 
 
962
        if(strcmp(filename, "last") ==0) {
 
963
                tmplist = g_list_first(*worklist);
 
964
                if (tmplist) {
 
965
                        tmp = tmplist->data;
 
966
                        DEBUG_MSG("remove_recent_entry, remove last entry\n");
 
967
                        *worklist = g_list_remove(*worklist, tmplist->data);
 
968
                        return tmp;
 
969
                } else {
 
970
                        DEBUG_MSG("remove_recent_entry, worklist contained no items, returning NULL\n");
 
971
                        return NULL;
 
972
                }
 
973
        }       else {
 
974
                return remove_menuitem_in_list_by_label(filename, worklist);
 
975
        }
 
976
}
 
977
 
 
978
static void open_recent_project_cb(GtkWidget *widget, Tbfwin *bfwin) {
 
979
        gchar *filename = GTK_LABEL(GTK_BIN(widget)->child)->label;
 
980
        DEBUG_MSG("open_recent_project_cb, started, filename is %s\n", filename);
 
981
        project_open_from_file(bfwin, filename);
 
982
        add_to_recent_list(bfwin,filename, 0, TRUE);
 
983
}
 
984
 
 
985
/* open_recent_file
 
986
 * This function should be called when a menu from the Open Recent list
 
987
 * has been selected. */
 
988
static void open_recent_file_cb(GtkWidget *widget, Tbfwin *bfwin) {
 
989
        gboolean success;
 
990
        gchar *filename = GTK_LABEL(GTK_BIN(widget)->child)->label;
 
991
        DEBUG_MSG("open_recent_file_cb, started, filename is %s\n", filename);
 
992
 
 
993
        statusbar_message(bfwin,_("Loading file(s)..."),2000);
 
994
        flush_queue();
 
995
        success = (doc_new_with_file(bfwin,filename, FALSE, FALSE) != NULL);
 
996
        if (!success) {
 
997
                gchar *message = g_strconcat(_("The filename was:\n"), filename, NULL);
 
998
                warning_dialog(bfwin->main_window,_("Could not open file\n"), message);
 
999
                g_free(message);
 
1000
                return;
 
1001
        }
 
1002
        DEBUG_MSG("open_recent_file_cb, document %s opened\n", filename);
 
1003
        add_to_recent_list(bfwin,filename, 0, FALSE);
 
1004
}
 
1005
 
 
1006
/* create_recent_entry
 
1007
 * This function builds the gtkitemfactoryentry and inserts it at the
 
1008
 * bfwin->menubar. Furthermore, it returns a pointer to it, so that
 
1009
 * this pointer can be added in the main_v->recent_files list */
 
1010
static GtkWidget *create_recent_entry(Tbfwin *bfwin, const gchar *filename, gboolean is_project, gboolean check_for_duplicates) {
 
1011
        GtkWidget *tmp;
 
1012
 
 
1013
        if (check_for_duplicates) {
 
1014
                tmp = remove_recent_entry(bfwin,filename,is_project);
 
1015
                if (tmp) {
 
1016
                        gtk_widget_hide(tmp);
 
1017
                        gtk_widget_destroy(tmp);
 
1018
                }
 
1019
        }
 
1020
        if (is_project) {
 
1021
                return  create_dynamic_menuitem(bfwin,N_("/Project/Open recent")
 
1022
                        , filename, G_CALLBACK(open_recent_project_cb), bfwin
 
1023
                        , 1);
 
1024
        } else {
 
1025
                return  create_dynamic_menuitem(bfwin,N_("/File/Open recent")
 
1026
                        , filename, G_CALLBACK(open_recent_file_cb), bfwin
 
1027
                        , 1);
 
1028
        }
 
1029
}
 
1030
 
 
1031
GList *recent_menu_from_list(Tbfwin *bfwin, GList *startat, gboolean is_project) {
 
1032
        GList *retlist=NULL, *tmplist=startat;
 
1033
        while (tmplist) {
 
1034
                DEBUG_MSG("recent_menu_init, adding recent project %s\n",(gchar *)tmplist->data);
 
1035
                retlist = g_list_append(retlist, create_recent_entry(bfwin,tmplist->data,is_project,FALSE));
 
1036
                tmplist = g_list_next(tmplist);
 
1037
        }
 
1038
        return retlist;
 
1039
}
 
1040
 
 
1041
/* void recent_menu_from_file(Tbfwin *bfwin, gchar *file_name, gboolean is_project) {
 
1042
        gchar *filename;
 
1043
        GList *inputlist, *recentfiles=NULL, *tmplist, **worklist;
 
1044
        gint num;
 
1045
        worklist = (is_project) ? &bfwin->menu_recent_projects : &bfwin->menu_recent_files;
 
1046
        / * empty any existing menu * /
 
1047
        tmplist = g_list_first(*worklist);
 
1048
        while (tmplist) {
 
1049
                gtk_widget_destroy(tmplist->data);
 
1050
                tmplist = g_list_next(tmplist);
 
1051
        }
 
1052
        
 
1053
        filename = g_strconcat(g_get_home_dir(), file_name, NULL);
 
1054
        inputlist = get_stringlist(filename, NULL);
 
1055
        / * the last entry in inputlist is the most recent file * /
 
1056
        tmplist = g_list_first(inputlist);
 
1057
        while (tmplist) {
 
1058
                recentfiles = add_to_history_stringlist(recentfiles, (gchar *)tmplist->data, TRUE);
 
1059
                tmplist = g_list_next(tmplist);
 
1060
        }
 
1061
        free_stringlist(inputlist);
 
1062
        num = g_list_length(recentfiles) - main_v->props.max_recent_files;
 
1063
        *worklist = recent_menu_from_list(bfwin, g_list_nth(recentfiles, (num > 0)?num:0), is_project);
 
1064
        put_stringlist_limited(filename, recentfiles, main_v->props.max_recent_files);
 
1065
        free_stringlist(recentfiles);
 
1066
        g_free(filename);
 
1067
}*/
 
1068
 
 
1069
/* recent_menu_init()
 
1070
 * Gets the list of documents from .bluefish/recentlist and inserts
 
1071
 * it at the File-->Open Recent menu. If the file doesn't exist (probably
 
1072
 * because this is the first time Bluefish is running) then a menu
 
1073
 * item telling that no recent files exist will appear */
 
1074
void recent_menu_init(Tbfwin *bfwin) {
 
1075
/*      recent_menu_from_file(bfwin, "/.bluefish/recentlist", FALSE);
 
1076
        recent_menu_from_file(bfwin, "/.bluefish/recentprojects", TRUE);*/
 
1077
        recent_menu_from_list(bfwin, bfwin->session->recent_files, FALSE);
 
1078
        recent_menu_from_list(bfwin, main_v->globses.recent_projects, TRUE);
 
1079
}
 
1080
 
 
1081
/* when a project is opened, the recent menu should show the recent files
 
1082
from that project */
 
1083
void recent_menu_init_project(Tbfwin *bfwin) {
 
1084
        gint num;
 
1085
        GList *tmplist = g_list_first(bfwin->menu_recent_files);
 
1086
        while (tmplist) {
 
1087
                gtk_widget_destroy(tmplist->data);
 
1088
                tmplist = g_list_next(tmplist);
 
1089
        }
 
1090
        num = g_list_length(bfwin->session->recent_files) - main_v->props.max_recent_files;
 
1091
        bfwin->menu_recent_files = recent_menu_from_list(bfwin, g_list_nth(bfwin->session->recent_files, (num > 0)?num:0), FALSE);
 
1092
}
 
1093
 
 
1094
/* Add_to_recent_list
 
1095
 * This should be called when a new file is opened, i.e. from
 
1096
 * file_open_cb, it adds a new entry which also appears in the
 
1097
 * menu bar, and (if nessecary) deletes the last entry */
 
1098
void add_to_recent_list(Tbfwin *bfwin,gchar *filename, gint closed_file, gboolean is_project) {
 
1099
        DEBUG_MSG("add_to_recent_list, started for %s\n", filename);
 
1100
        if (closed_file) {
 
1101
                GList *tmplist = g_list_first(main_v->bfwinlist);
 
1102
                while (tmplist) {
 
1103
                        Tbfwin *curbfwin = BFWIN(tmplist->data);
 
1104
                        if (!curbfwin->project || curbfwin == bfwin || is_project) {
 
1105
                                GtkWidget *tmp;
 
1106
                                GList **worklist;
 
1107
                                worklist = (is_project) ? &curbfwin->menu_recent_projects : &curbfwin->menu_recent_files;
 
1108
                                
 
1109
                                /* First of all, create the entry and insert it at the list*/
 
1110
                                *worklist = g_list_append(*worklist,create_recent_entry(curbfwin,filename,is_project,TRUE));
 
1111
        
 
1112
                                DEBUG_MSG("add_to_recent_list, inserted item in menu\n");
 
1113
                                if(g_list_length(*worklist) > main_v->props.max_recent_files) {
 
1114
                                        tmp = remove_recent_entry(bfwin,"last",is_project);
 
1115
                                        if (tmp) {
 
1116
                                                DEBUG_MSG("add_to_recent_list, list too long, entry %s to be deleted\n", GTK_LABEL(GTK_BIN(tmp)->child)->label);
 
1117
                                                gtk_widget_hide(tmp);
 
1118
                                                gtk_widget_destroy(tmp);
 
1119
                                        }
 
1120
                                }
 
1121
                        }
 
1122
                        tmplist = g_list_next(tmplist);
 
1123
                }
 
1124
        }
 
1125
        if (is_project) {
 
1126
                main_v->globses.recent_projects = add_to_history_stringlist(main_v->globses.recent_projects, filename, FALSE,TRUE);
 
1127
        } else {
 
1128
                bfwin->session->recent_files = add_to_history_stringlist(bfwin->session->recent_files, filename, FALSE,TRUE);
 
1129
        }
 
1130
 
 
1131
 
 
1132
/*      } else {
 
1133
                / * once we get rid of the other ways to store recent files this will be the only line we still need * /
 
1134
                if (is_project) {
 
1135
                        main_v->globses.recent_projects = add_to_history_stringlist(main_v->globses.recent_projects, filename, TRUE);
 
1136
                } else {
 
1137
                        bfwin->session->recent_files = add_to_history_stringlist(bfwin->session->recent_files, filename, TRUE);
 
1138
                }
 
1139
                DEBUG_MSG("add_to_recent_list, added to session recent_files, length=%d\n",g_list_length(bfwin->session->recent_files));
 
1140
                if (bfwin->project) {
 
1141
                        / * we do nothing when the file is opened, since opened files are anyway opened again in a project * /
 
1142
                } else {
 
1143
                        gchar *tmpfilename, *recentfile;
 
1144
                        recentfile = g_strconcat(g_get_home_dir(), (is_project) ? "/.bluefish/recentprojects" : "/.bluefish/recentlist", NULL);
 
1145
                        / * save the new list * /
 
1146
                        tmpfilename = g_strconcat(filename, "\n", NULL);
 
1147
                        DEBUG_MSG("add_to_recent_list, trying to append to %s\n", recentfile);
 
1148
                        append_string_to_file(recentfile, tmpfilename);
 
1149
                        g_free(recentfile);
 
1150
                        g_free(tmpfilename);
 
1151
                }
 
1152
                * /
 
1153
        } */
 
1154
}
 
1155
/*****************/
 
1156
/* Windows !!    */
 
1157
/*****************/
 
1158
 
 
1159
static void remove_all_window_entries_in_window(Tbfwin *menubfwin) {
 
1160
        GList *tmplist = g_list_first(menubfwin->menu_windows);
 
1161
        DEBUG_MSG("removing all window entries in menubfwin %p\n",menubfwin);
 
1162
        while (tmplist) {
 
1163
                Tbfw_dynmenu *bdm = BFW_DYNMENU(tmplist->data);
 
1164
                /*g_signal_handler_disconnect(bdm->menuitem,bdm->signal_id);*/
 
1165
                DEBUG_MSG("remove_all_window_entries_in_window, destroy menuitem=%p\n",bdm->menuitem);
 
1166
                gtk_widget_destroy(bdm->menuitem);
 
1167
                g_free(bdm);
 
1168
                tmplist = g_list_next(tmplist);
 
1169
        }
 
1170
        g_list_free(menubfwin->menu_windows);
 
1171
        menubfwin->menu_windows = NULL;
 
1172
}
 
1173
static void remove_window_entry_from_window(Tbfwin *menubfwin, Tbfwin *tobfwin) {
 
1174
        Tbfw_dynmenu *bdm = find_bfw_dynmenu_by_data_in_list(menubfwin->menu_windows, tobfwin);
 
1175
        DEBUG_MSG("remove_window_entry_from_window, menuwin=%p, found bdm=%p\n",menubfwin,bdm);
 
1176
        if (bdm) {
 
1177
                /*g_signal_handler_disconnect(bdm->menuitem,bdm->signal_id);*/
 
1178
                DEBUG_MSG("remove_window_entry_from_window, destroy menuitem=%p\n",bdm->menuitem);
 
1179
                gtk_widget_destroy(bdm->menuitem);
 
1180
                menubfwin->menu_windows = g_list_remove(menubfwin->menu_windows,bdm);
 
1181
                g_free(bdm);
 
1182
                
 
1183
        }
 
1184
}
 
1185
static void rename_window_entry_from_window(Tbfwin *menubfwin, Tbfwin *tobfwin, gchar *newtitle) {
 
1186
        Tbfw_dynmenu *bdm = find_bfw_dynmenu_by_data_in_list(menubfwin->menu_windows, tobfwin);
 
1187
        DEBUG_MSG("rename_window_entry_from_window, menubfwin=%p, found bdm=%p\n",menubfwin,bdm);
 
1188
        if (bdm) {
 
1189
                GtkWidget *label = gtk_bin_get_child(GTK_BIN(bdm->menuitem));
 
1190
                DEBUG_MSG("rename_window_entry_from_window, setting label to have title %s\n",newtitle);
 
1191
                gtk_label_set_text(GTK_LABEL(label), newtitle);
 
1192
        }
 
1193
}       
 
1194
static void menu_window_lcb(GtkWidget *widget, Tbfw_dynmenu *bdm) {
 
1195
        gtk_window_present(GTK_WINDOW(BFWIN(bdm->data)->main_window));
 
1196
}
 
1197
static void add_window_entry(Tbfwin *menubfwin, Tbfwin *tobfwin) {
 
1198
        const gchar *winname;
 
1199
        Tbfw_dynmenu *bdm = g_new(Tbfw_dynmenu,1);
 
1200
        bdm->bfwin = menubfwin;
 
1201
        bdm->data = tobfwin;
 
1202
        winname = gtk_window_get_title(GTK_WINDOW(tobfwin->main_window));
 
1203
        DEBUG_MSG("add_window_entry, menubfwin=%p, bdm=%p with title %s\n",menubfwin,bdm,winname);
 
1204
        bdm->menuitem = create_dynamic_menuitem(menubfwin,_("/Windows"),winname,G_CALLBACK(menu_window_lcb),(gpointer)bdm,-1);
 
1205
        DEBUG_MSG("add_window_entry, menuitem=%p\n",bdm->menuitem);
 
1206
        menubfwin->menu_windows = g_list_append(menubfwin->menu_windows, bdm);
 
1207
}
 
1208
void add_window_entry_to_all_windows(Tbfwin *tobfwin) {
 
1209
        GList *tmplist = g_list_first(main_v->bfwinlist);
 
1210
        while (tmplist) {
 
1211
                if (tmplist->data != tobfwin) {
 
1212
                        add_window_entry(BFWIN(tmplist->data), tobfwin);
 
1213
                }
 
1214
                tmplist = g_list_next(tmplist);
 
1215
        }
 
1216
}
 
1217
void add_allwindows_entries_to_window(Tbfwin *menubfwin) {
 
1218
        GList *tmplist = g_list_first(main_v->bfwinlist);
 
1219
        while (tmplist) {
 
1220
                if (tmplist->data != menubfwin) {
 
1221
                        add_window_entry(menubfwin, BFWIN(tmplist->data));
 
1222
                }
 
1223
                tmplist = g_list_next(tmplist);
 
1224
        }
 
1225
}       
 
1226
void remove_window_entry_from_all_windows(Tbfwin *tobfwin) {
 
1227
        GList *tmplist = g_list_first(main_v->bfwinlist);
 
1228
        while (tmplist) {
 
1229
                remove_window_entry_from_window(BFWIN(tmplist->data), tobfwin);
 
1230
                tmplist = g_list_next(tmplist);
 
1231
        }
 
1232
        remove_all_window_entries_in_window(tobfwin);
 
1233
}
 
1234
void rename_window_entry_in_all_windows(Tbfwin *tobfwin, gchar *newtitle) {
 
1235
        GList *tmplist = g_list_first(main_v->bfwinlist);
 
1236
        while (tmplist) {
 
1237
                rename_window_entry_from_window(BFWIN(tmplist->data), tobfwin, newtitle);
 
1238
                tmplist = g_list_next(tmplist);
 
1239
        }
 
1240
}
 
1241
 
 
1242
/*****************/
 
1243
/* Browsers!!    */
 
1244
/*****************/
 
1245
 
 
1246
static void view_in_browser(Tbfwin *bfwin, gchar *browser) {
 
1247
        if (bfwin->current_document->filename) {
 
1248
                Tconvert_table *table, *tmpt;
 
1249
                gchar *command;
 
1250
                table = tmpt = g_new(Tconvert_table, 2);
 
1251
                tmpt->my_int = 's';
 
1252
                if (bfwin->project && bfwin->project->webdir 
 
1253
                                && bfwin->project->basedir && strlen(bfwin->project->webdir)>2
 
1254
                                && strlen(bfwin->project->basedir)>2 
 
1255
                                && strncmp(bfwin->current_document->filename, bfwin->project->basedir, strlen(bfwin->project->basedir))==0
 
1256
                                ) {
 
1257
                        tmpt->my_char = g_strconcat(bfwin->project->webdir, &bfwin->current_document->filename[strlen(bfwin->project->basedir)], NULL);
 
1258
                } else {
 
1259
                        tmpt->my_char = g_strdup(bfwin->current_document->filename);
 
1260
                }
 
1261
                tmpt++;
 
1262
                tmpt->my_char = NULL;
 
1263
                command = replace_string_printflike(browser, table);
 
1264
                g_free(table->my_char);
 
1265
                g_free(table);
 
1266
                DEBUG_MSG("view_in_browser, should start %s now\n", command);
 
1267
                system(command);
 
1268
                g_free(command);
 
1269
        } else {
 
1270
                warning_dialog(bfwin->main_window,_("Could not view file in browser, the file does not yet have a name\n"), NULL);
 
1271
        }
 
1272
}
 
1273
 
 
1274
void browser_toolbar_cb(GtkWidget *widget, Tbfwin *bfwin) {
 
1275
        GList *tmplist = g_list_first(main_v->props.browsers);
 
1276
        if (tmplist && tmplist->data) {
 
1277
                gchar **arr = tmplist->data;
 
1278
                DEBUG_MSG("first browser in main_v->props.browsers(%p) is %s with command %s\n", main_v->props.browsers, arr[0], arr[1]);
 
1279
                view_in_browser(bfwin,arr[1]);
 
1280
        }
 
1281
}
 
1282
 
 
1283
static void browser_lcb(GtkWidget *widget, Tbfw_dynmenu *bdm) {
 
1284
        gchar **arr = (gchar **)bdm->data;
 
1285
        if (!bdm->bfwin->current_document->filename || bdm->bfwin->current_document->modified) {
 
1286
                file_save_cb(NULL, bdm->bfwin);
 
1287
        }
 
1288
        view_in_browser(bdm->bfwin,arr[1]);
 
1289
}
 
1290
static void external_command_lcb(GtkWidget *widget, Tbfw_dynmenu *bdm) {
 
1291
        gchar *secure_tempname = NULL, *secure_tempname2 = NULL;
 
1292
        gboolean need_s=FALSE, need_f=FALSE, need_i=FALSE;
 
1293
        gchar **arr = (gchar **)bdm->data;
 
1294
        /* now check if
 
1295
         * %s - current document filename
 
1296
         * %f - output filename that we need to read after the command has finished (filter)
 
1297
         * %i - input filename for the filter
 
1298
         */
 
1299
        need_f = (strstr(arr[1], "%f") != NULL);
 
1300
        need_i = (strstr(arr[1], "%i") != NULL);
 
1301
        need_s = (strstr(arr[1], "%s") != NULL);
 
1302
 
 
1303
        if (need_s) {
 
1304
                file_save_cb(NULL, bdm->bfwin);
 
1305
                if (!bdm->bfwin->current_document->filename) {
 
1306
                        return;
 
1307
                }
 
1308
                if (bdm->bfwin->current_document->filename[0] == '/'){
 
1309
                        /* for local files we chdir() to their directory */
 
1310
                        gchar *tmpstring = g_path_get_dirname(bdm->bfwin->current_document->filename);
 
1311
                        chdir(tmpstring);
 
1312
                        g_free(tmpstring);
 
1313
                }
 
1314
        }
 
1315
        if (need_f || need_s || need_i) {
 
1316
                gchar *command;
 
1317
                Tconvert_table *table, *tmpt;
 
1318
                table = tmpt = g_new(Tconvert_table, 4);
 
1319
                if (need_s) {
 
1320
                        DEBUG_MSG("adding 's' to table\n");
 
1321
                        tmpt->my_int = 's';
 
1322
                        tmpt->my_char = bdm->bfwin->current_document->filename;
 
1323
                        tmpt++;
 
1324
                }
 
1325
                if (need_f) {
 
1326
                        secure_tempname = create_secure_dir_return_filename();
 
1327
                        DEBUG_MSG("adding 'f' to table\n");
 
1328
                        tmpt->my_int = 'f';
 
1329
                        tmpt->my_char = secure_tempname;
 
1330
                        tmpt++;
 
1331
                }
 
1332
                if (need_i) {
 
1333
                        gchar *buffer;
 
1334
                        GtkTextIter itstart, itend;
 
1335
                        gtk_text_buffer_get_bounds(bdm->bfwin->current_document->buffer,&itstart,&itend);
 
1336
                        secure_tempname2 = create_secure_dir_return_filename();
 
1337
                        DEBUG_MSG("adding 'i' to table\n");
 
1338
                        tmpt->my_int = 'i';
 
1339
                        tmpt->my_char = secure_tempname2;
 
1340
                        tmpt++;
 
1341
                        /* now we also save the current filename (or in the future the selection) to this file */
 
1342
                        buffer = gtk_text_buffer_get_text(bdm->bfwin->current_document->buffer,&itstart,&itend,FALSE);
 
1343
                        buffer_to_file(BFWIN(bdm->bfwin), buffer, secure_tempname2);
 
1344
                        g_free(buffer);
 
1345
                }
 
1346
                tmpt->my_char = NULL;
 
1347
                command = replace_string_printflike(arr[1], table);
 
1348
                g_free(table);
 
1349
                system(command);
 
1350
                g_free(command);
 
1351
                if (need_f) {
 
1352
                        gint end;
 
1353
                        gchar *buf = NULL;
 
1354
                        gboolean suc6;
 
1355
                        /* empty textbox and fill from file secure_tempname */
 
1356
                        end = doc_get_max_offset(bdm->bfwin->current_document);
 
1357
                        suc6 = g_file_get_contents(secure_tempname, &buf, NULL, NULL);
 
1358
                        if (suc6 && buf) {
 
1359
                                if (strlen(buf)) {
 
1360
                                        doc_replace_text(bdm->bfwin->current_document, buf, 0, end);
 
1361
                                }
 
1362
                                g_free(buf);
 
1363
                        }
 
1364
                }
 
1365
                if (secure_tempname) remove_secure_dir_and_filename(secure_tempname);
 
1366
                if (secure_tempname2) remove_secure_dir_and_filename(secure_tempname2);
 
1367
        } else {
 
1368
                DEBUG_MSG("external_command_lcb, about to start %s\n", arr[1]);
 
1369
                system(arr[1]);
 
1370
        }
 
1371
}
 
1372
/**
 
1373
 * external_menu_rebuild:
 
1374
 * @bfwin: #Tbfwin*
 
1375
 *
 
1376
 * rebuild the browsers, external commands and outputbox menu's
 
1377
 *
 
1378
 * Return value: void
 
1379
 */
 
1380
void external_menu_rebuild(Tbfwin *bfwin) {
 
1381
        GList *tmplist;
 
1382
        
 
1383
        /* first cleanup all menu's */
 
1384
        tmplist = g_list_first(bfwin->menu_external);
 
1385
        while (tmplist) {
 
1386
                Tbfw_dynmenu *bdm = (Tbfw_dynmenu *)tmplist->data;
 
1387
                DEBUG_MSG("external_menu_rebuild,destroying,bfwin=%p,bdm=%p,menuitem=%p\n",bfwin,bdm,bdm->menuitem);
 
1388
                gtk_widget_destroy(bdm->menuitem);
 
1389
                g_free(bdm);
 
1390
                tmplist = g_list_next(tmplist);
 
1391
        }
 
1392
        g_list_free(bfwin->menu_external);
 
1393
        bfwin->menu_external = NULL;
 
1394
 
 
1395
        tmplist = g_list_first(bfwin->menu_outputbox);
 
1396
        while (tmplist) {
 
1397
                gtk_widget_destroy(BFW_DYNMENU(tmplist->data)->menuitem);
 
1398
                g_free(BFW_DYNMENU(tmplist->data));
 
1399
                tmplist = g_list_next(tmplist);
 
1400
        }
 
1401
        g_list_free(bfwin->menu_outputbox);
 
1402
        bfwin->menu_outputbox = NULL;
 
1403
        
 
1404
        if (main_v->props.ext_outputbox_in_submenu) {
 
1405
                create_parent_and_tearoff(N_("/External/Outputbox/"), gtk_item_factory_from_widget(bfwin->menubar));
 
1406
        }
 
1407
        if (main_v->props.ext_commands_in_submenu) {
 
1408
                create_parent_and_tearoff(N_("/External/Commands/"), gtk_item_factory_from_widget(bfwin->menubar));
 
1409
        }
 
1410
        if (main_v->props.ext_browsers_in_submenu) {
 
1411
                create_parent_and_tearoff(N_("/External/Browsers/"), gtk_item_factory_from_widget(bfwin->menubar));
 
1412
        }
 
1413
 
 
1414
        if (!main_v->props.ext_browsers_in_submenu) {
 
1415
                Tbfw_dynmenu *bdm = g_new(Tbfw_dynmenu,1);
 
1416
                bdm->menuitem = dynamic_menu_append_spacing(bfwin,N_("/External"));
 
1417
                bfwin->menu_external = g_list_append(bfwin->menu_external,bdm);
 
1418
        } 
 
1419
        tmplist = g_list_first(main_v->props.browsers);
 
1420
        while (tmplist) {
 
1421
                gchar **arr = tmplist->data;
 
1422
                /*  arr[0] = name
 
1423
                 *  arr[1] = command
 
1424
                 */
 
1425
                if (count_array(arr)==2) {
 
1426
                        Tbfw_dynmenu *bdm = g_new(Tbfw_dynmenu,1);
 
1427
                        gchar *tmp1;
 
1428
                        if (main_v->props.ext_browsers_in_submenu) {
 
1429
                                tmp1 = N_("/External/Browsers");
 
1430
                        } else {
 
1431
                                tmp1 = N_("/External");
 
1432
                        }
 
1433
                        bdm->bfwin = bfwin;
 
1434
                        bdm->data = arr;
 
1435
                        DEBUG_MSG("external_menu_rebuild,Adding browser %s with command %s to the menu at %s\n", arr[0], arr[1], tmp1);
 
1436
                        bdm->menuitem = create_dynamic_menuitem(bfwin,tmp1,arr[0],G_CALLBACK(browser_lcb),bdm,-1);
 
1437
                        DEBUG_MSG("external_menu_rebuild,creating,bfwin=%p,bdm=%p,menuitem=%p\n",bfwin,bdm,bdm->menuitem);
 
1438
                        bfwin->menu_external = g_list_append(bfwin->menu_external, bdm);
 
1439
                }
 
1440
#ifdef DEBUG
 
1441
                else {
 
1442
                        DEBUG_MSG("need count=2 for browser menu! %p has count %d\n", arr, count_array(arr));
 
1443
                }
 
1444
#endif
 
1445
                tmplist = g_list_next(tmplist);
 
1446
        }
 
1447
        
 
1448
        if (!main_v->props.ext_commands_in_submenu) {
 
1449
                Tbfw_dynmenu *bdm = g_new(Tbfw_dynmenu,1);
 
1450
                bdm->menuitem = dynamic_menu_append_spacing(bfwin,N_("/External"));
 
1451
                bfwin->menu_external = g_list_append(bfwin->menu_external,bdm);
 
1452
        }
 
1453
        
 
1454
        tmplist = g_list_first(main_v->props.external_commands);
 
1455
        while (tmplist) {
 
1456
                gchar **arr = tmplist->data;
 
1457
                /*  arr[0] = name
 
1458
                 *  arr[1] = command
 
1459
                 */
 
1460
                if (count_array(arr)==2) {
 
1461
                        gchar *tmp1;
 
1462
                        Tbfw_dynmenu *bdm = g_new(Tbfw_dynmenu,1);
 
1463
                        if (main_v->props.ext_commands_in_submenu) {
 
1464
                                tmp1 = N_("/External/Commands");
 
1465
                        } else {
 
1466
                                tmp1 = N_("/External");
 
1467
                        }
 
1468
                        bdm->bfwin = bfwin;
 
1469
                        bdm->data = arr;
 
1470
                        bdm->menuitem = create_dynamic_menuitem(bfwin,tmp1,arr[0],G_CALLBACK(external_command_lcb),bdm,-1);
 
1471
                        bfwin->menu_external = g_list_append(bfwin->menu_external, bdm);
 
1472
                }
 
1473
                tmplist = g_list_next(tmplist);
 
1474
        }
 
1475
 
 
1476
        /* the outputbox */     
 
1477
        if (!main_v->props.ext_outputbox_in_submenu) {
 
1478
                Tbfw_dynmenu *bdm = g_new(Tbfw_dynmenu,1);
 
1479
                bdm->menuitem = dynamic_menu_append_spacing(bfwin,N_("/External"));
 
1480
                bfwin->menu_outputbox = g_list_append(bfwin->menu_outputbox, bdm);
 
1481
        }
 
1482
        
 
1483
        tmplist = g_list_first(main_v->props.outputbox);
 
1484
        while (tmplist) {
 
1485
                gchar **arr = tmplist->data;
 
1486
                /* outputbox(gchar *pattern, gint file_subpat, gint line_subpat, gint output_subpat, gchar *command, gboolean show_all_output)
 
1487
                 * arr[0] = name
 
1488
                 * arr[1] = pattern
 
1489
                 * arr[2] = file subpattern
 
1490
                 * arr[3] = line subpattern
 
1491
                 * arr[4] = output subpattern
 
1492
                 * arr[5] = command
 
1493
                 * arr[6] = show_all_output
 
1494
                 */
 
1495
                if (count_array(arr)==7) {
 
1496
                        Tbfw_dynmenu *bdm = g_new(Tbfw_dynmenu,1);
 
1497
                        gchar *tmp1;
 
1498
                        if (main_v->props.ext_outputbox_in_submenu) {
 
1499
                                tmp1 = N_("/External/Outputbox");
 
1500
                        } else {
 
1501
                                tmp1 = N_("/External");
 
1502
                        }
 
1503
                        bdm->data = arr;
 
1504
                        bdm->bfwin = bfwin;
 
1505
                        bdm->menuitem = create_dynamic_menuitem(bfwin,tmp1,arr[0],G_CALLBACK(menu_outputbox_lcb),(gpointer)bdm,-1);
 
1506
                        bfwin->menu_outputbox = g_list_append(bfwin->menu_outputbox,bdm);
 
1507
                }
 
1508
                tmplist = g_list_next(tmplist);
 
1509
        }
 
1510
}
 
1511
 
 
1512
static void menu_current_document_encoding_change(GtkMenuItem *menuitem,Tbfw_dynmenu *bdm) {
 
1513
        if (GTK_CHECK_MENU_ITEM(menuitem)->active) {
 
1514
                gchar *encoding = (gchar *)bdm->data;
 
1515
                Tbfwin *bfwin = bdm->bfwin;
 
1516
                if (encoding && (!bfwin->current_document->encoding || strcmp(encoding,bfwin->current_document->encoding)!=0)) {
 
1517
                        if (bfwin->current_document->encoding) {
 
1518
                                g_free(bfwin->current_document->encoding);
 
1519
                        }
 
1520
                        bfwin->current_document->encoding = g_strdup(encoding);
 
1521
                        if (main_v->props.auto_set_encoding_meta) {
 
1522
                                update_encoding_meta_in_file(bfwin->current_document, bfwin->current_document->encoding);
 
1523
                        }
 
1524
                        doc_set_statusbar_editmode_encoding(bfwin->current_document);
 
1525
                        DEBUG_MSG("menu_current_document_encoding_change, set to %s\n", encoding);
 
1526
                }
 
1527
        }
 
1528
}
 
1529
 
 
1530
void encoding_menu_rebuild(Tbfwin *bfwin) {
 
1531
        GSList *group=NULL;
 
1532
        GtkWidget *parent_menu;
 
1533
        GList *tmplist;
 
1534
        tmplist = g_list_first(bfwin->menu_encodings);
 
1535
        while (tmplist) {
 
1536
                Tbfw_dynmenu *bdm = tmplist->data;
 
1537
                gtk_widget_destroy(GTK_WIDGET(bdm->menuitem));
 
1538
                g_free(bdm);
 
1539
                tmplist = g_list_next(tmplist);
 
1540
        }
 
1541
        g_list_free(bfwin->menu_encodings);
 
1542
        bfwin->menu_encodings = NULL;
 
1543
 
 
1544
        tmplist = g_list_last(main_v->props.encodings);
 
1545
        parent_menu = gtk_item_factory_get_widget(gtk_item_factory_from_widget(bfwin->menubar), N_("/Document/Character Encoding"));
 
1546
        while (tmplist) {
 
1547
                gchar **strarr = (gchar **)tmplist->data;
 
1548
                if (count_array(strarr)==2) {
 
1549
                        Tbfw_dynmenu *bdm = g_new(Tbfw_dynmenu,1);
 
1550
                        bdm->menuitem = gtk_radio_menu_item_new_with_label(group, strarr[0]);
 
1551
                        bdm->data = strarr[1];
 
1552
                        bdm->bfwin = bfwin;
 
1553
                        g_signal_connect(G_OBJECT(bdm->menuitem), "activate",G_CALLBACK(menu_current_document_encoding_change), (gpointer) bdm);
 
1554
                        gtk_widget_show(bdm->menuitem);
 
1555
                        gtk_menu_insert(GTK_MENU(parent_menu), bdm->menuitem, 1);
 
1556
                        group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(bdm->menuitem));
 
1557
                        bfwin->menu_encodings = g_list_append(bfwin->menu_encodings, bdm);
 
1558
                }
 
1559
                tmplist = g_list_previous(tmplist);
 
1560
        }
 
1561
}
 
1562
 
 
1563
void menu_current_document_set_toggle_wo_activate(Tbfwin *bfwin, Tfiletype *filetype, gchar *encoding) {
 
1564
        Tbfw_dynmenu *bdm = find_bfw_dynmenu_by_data_in_list(bfwin->menu_filetypes, filetype);
 
1565
        if (bdm && filetype && bdm->menuitem && !GTK_CHECK_MENU_ITEM(bdm->menuitem)->active) {
 
1566
                DEBUG_MSG("setting widget from hlset %p active\n", bfwin->current_document->hl);
 
1567
                g_signal_handler_disconnect(G_OBJECT(bdm->menuitem),bdm->signal_id);
 
1568
                gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(bdm->menuitem), TRUE);
 
1569
                bdm->signal_id = g_signal_connect(G_OBJECT(bdm->menuitem), "activate",G_CALLBACK(menu_current_document_type_change), (gpointer) bdm);
 
1570
        }
 
1571
#ifdef DEBUG
 
1572
         else {
 
1573
                DEBUG_MSG("widget from filetype %p is already active, or filetype does not have a widget!!\n", bfwin->current_document->hl);
 
1574
         }
 
1575
#endif
 
1576
        if (encoding) {
 
1577
                GList *tmplist;
 
1578
                tmplist = g_list_first(main_v->props.encodings);
 
1579
                while (tmplist) {
 
1580
                        gchar **tmparr = (gchar **)tmplist->data;
 
1581
                        if (strcmp(tmparr[1], encoding)==0) {
 
1582
                                Tbfw_dynmenu *bdm = find_bfw_dynmenu_by_data_in_list(bfwin->menu_encodings, tmparr[1]);
 
1583
                                if (bdm) {
 
1584
                                        g_signal_handlers_block_matched(G_OBJECT(bdm->menuitem), G_SIGNAL_MATCH_FUNC,
 
1585
                                                        0, 0, NULL, menu_current_document_encoding_change, NULL);
 
1586
                                        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(bdm->menuitem),TRUE);
 
1587
                                        g_signal_handlers_unblock_matched(G_OBJECT(bdm->menuitem), G_SIGNAL_MATCH_FUNC,
 
1588
                                                        0, 0, NULL, menu_current_document_encoding_change, NULL);
 
1589
                                }
 
1590
                                break;
 
1591
                        }
 
1592
                        tmplist = g_list_next(tmplist); 
 
1593
                }
 
1594
        }
 
1595
}
 
1596
 
 
1597
 
 
1598
/***************/
 
1599
/* custom menu */
 
1600
/***************/
672
1601
#define MAX_TEXT_ENTRY 10
673
 
 
674
1602
typedef struct {
675
1603
        GtkWidget *dialog;
676
1604
        GtkWidget *textentry[MAX_TEXT_ENTRY];
677
1605
        gint type;
678
1606
        gchar **array;
 
1607
        Tbfwin *bfwin;
679
1608
} Tcust_con_struc;
680
1609
 
 
1610
typedef struct {
 
1611
        GtkItemFactoryEntry entry;
 
1612
        gint type;
 
1613
        gchar **array;
 
1614
        Tbfwin *bfwin;
 
1615
} Tcmenu_entry;
 
1616
 
681
1617
/*
682
 
Tcust_con_struc->array[0] = title / menupath
683
 
Tcust_con_struc->array[1] = type:
684
 
                                                                                0 = custom dialog
685
 
                                                                                1 = custom search and replace
 
1618
instead of having one list where both insert and replace types have their
 
1619
place, I changed that to 2 arraylists:
 
1620
main_v->props.cmenu_insert
 
1621
main_v->props.cmenu_replace
686
1622
 
687
 
** for dialog **
688
 
Tcust_con_struc->array[2] = formatstring before, containing %0, %1... that should be replaced by the 
 
1623
** for insert **
 
1624
array[0] = title / menupath
 
1625
array[1] = formatstring before, containing %0, %1... that should be replaced by the 
689
1626
                                values from the dialog
690
 
Tcust_con_struc->array[3] = formatstring after
691
 
Tcust_con_struc->array[4] = number of variables from the dialog
692
 
Tcust_con_struc->array[5..] = the description of those variables
 
1627
array[2] = formatstring after
 
1628
array[3] = number of variables from the dialog
 
1629
array[4..] = the description of those variables
693
1630
 
694
 
** for search and replace **
695
 
Tcust_con_struc->array[2] = search pattern, containing %0 etc.
696
 
Tcust_con_struc->array[3] = replace pattern, containing %0 etc.
697
 
Tcust_con_struc->array[4] = replace where:
698
 
                                                                                0 = from beginning
699
 
                                                                                1 = from cursor
700
 
                                                                                2 = selection (selection required)
701
 
                                                                                3 = all open documents
702
 
                                                                                4 = ask
703
 
Tcust_con_struc->array[5] = replace type:
704
 
                                                                                0 = normal
705
 
                                                                                1 = regular expression
706
 
Tcust_con_struc->array[6] = case sensitivity:
707
 
                                                                                0 = no
708
 
                                                                                1 = yes
709
 
Tcust_con_struc->array[7] = number of variables from the dialog
710
 
Tcust_con_struc->array[8..] = the description of those variables
 
1631
** for replace **
 
1632
array[0] = title / menupath
 
1633
array[1] = search pattern, containing %0 etc.
 
1634
array[2] = replace pattern, containing %0 etc.
 
1635
array[3] = replace where:
 
1636
                                                        0 = from beginning
 
1637
                                                        1 = from cursor
 
1638
                                                        2 = selection (selection required)
 
1639
                                                        3 = all open documents
 
1640
                                                        4 = ask
 
1641
array[4] = replace type:
 
1642
                                                        0 = normal
 
1643
                                                        1 = regular expression
 
1644
array[5] = case sensitivity:
 
1645
                                                        0 = no
 
1646
                                                        1 = yes
 
1647
array[6] = number of variables from the dialog
 
1648
array[7..] = the description of those variables
711
1649
*/
712
1650
 
713
 
 
714
 
static gchar *replace_with(gchar numc, gchar **array) {
715
 
        gint numi, i;
716
 
 
717
 
        numi = ((int) numc) -48;
718
 
        for (i=0; array[i] != NULL; i++) {
719
 
                DEBUG_MSG("replace_with, i=%d, searching for numi=%d\n", i, numi);
720
 
                if (i == numi) {
721
 
                        DEBUG_MSG("replace_with, returning %d= %s\n", i, array[i]);
722
 
                        return array[i];
723
 
                }
724
 
        }
725
 
        return NULL;
726
 
}
727
 
 
728
 
 
729
 
static gchar *replace_string(gchar *in_string, gchar **array) {
730
 
        gchar *tmp3;
731
 
        gchar *found, *search_in, *freestr;
732
 
        gchar *newstring, *tmpnewstring, *begin, *replace_w;
733
 
 
734
 
        newstring = g_strdup("");
735
 
        freestr = search_in = begin = g_strdup(in_string);
736
 
        while ( (search_in) && (found = strchr(search_in, '%')) ) {
737
 
                DEBUG_MSG("replace_string, found=%s, search_in=%s\n", found, search_in);
738
 
                tmp3 = found;
739
 
                DEBUG_MSG("replace_string, char=%c\n", *tmp3);
740
 
                tmp3++;
741
 
                DEBUG_MSG("replace_string, char=%c\n", *tmp3);
742
 
                if ((replace_w = replace_with(*tmp3, array))) {
743
 
                        *found = '\0';
744
 
                        tmpnewstring = newstring;
745
 
                        newstring = g_strconcat(tmpnewstring, begin, replace_w, NULL);
746
 
                        DEBUG_MSG("replace_string, newstring=%s\n", newstring);
747
 
                        g_free(tmpnewstring);
748
 
                        begin = ++tmp3;
749
 
                        search_in = tmp3;
750
 
                } else if (*tmp3 == '\0') {
751
 
                        DEBUG_MSG("replace_string, *tmp3 = \\0, found end of string\n");
752
 
                        search_in = NULL;
753
 
                } else {
754
 
                        search_in = ++found;
755
 
                        DEBUG_MSG("replace_string, search_in=%s\n", search_in);
756
 
                }
757
 
        }
758
 
        tmpnewstring = newstring;
759
 
        newstring = g_strconcat(tmpnewstring, begin,NULL);
760
 
        DEBUG_MSG("replace_string, newstring=%s\n", newstring);
761
 
        g_free(tmpnewstring);
762
 
        
763
 
        g_free(freestr);
764
 
        return newstring;
765
 
}
766
 
 
767
 
static void cust_con_struc_dialog_destroy_lcb(GtkWidget *widget, GdkEvent *event,  Tcust_con_struc *ccs) {
 
1651
static void cust_con_struc_dialog_destroy_lcb(GtkWidget *widget, Tcust_con_struc *ccs) {
768
1652
        window_destroy(ccs->dialog);
769
1653
        g_free(ccs);
770
1654
}
771
1655
 
772
1656
static void cust_con_struc_dialog_cancel_lcb(GtkWidget *widget, gpointer data) {
773
 
        cust_con_struc_dialog_destroy_lcb(NULL, NULL, data);
 
1657
        cust_con_struc_dialog_destroy_lcb(NULL, data);
774
1658
}
775
1659
 
776
1660
static void cust_con_struc_dialog_ok_lcb(GtkWidget *widget, Tcust_con_struc *ccs) {
777
 
        gchar **dialogarray;
 
1661
        Tconvert_table *table, *tmpt;
778
1662
        gint num_vars, i;
779
1663
 
780
1664
        DEBUG_MSG("cust_con_struc_dialog_ok_lcb, ccs at %p\n", ccs);
782
1666
        DEBUG_MSG("cust_con_struc_dialog_ok_lcb, array[0] at %p, *array=%p\n", ccs->array[0], *ccs->array);
783
1667
        if (ccs->type == 0) {
784
1668
                gchar *before=NULL, *after=NULL;
785
 
                num_vars = atoi(ccs->array[4]);
 
1669
                num_vars = atoi(ccs->array[3]);
786
1670
                DEBUG_MSG("cust_con_struc_dialog_ok_lcb, num_vars=%d, ccs->array[3]=%s\n", num_vars, ccs->array[3]);
787
 
                dialogarray = g_malloc((num_vars+1) * sizeof(char *));
 
1671
                table = tmpt = g_new(Tconvert_table, num_vars+2);
 
1672
                tmpt->my_int = '%';
 
1673
                tmpt->my_char = g_strdup("%");
 
1674
                tmpt++;
788
1675
                for (i=0; i<num_vars; i++) {
789
 
                        dialogarray[i] = gtk_editable_get_chars(GTK_EDITABLE(ccs->textentry[i]), 0, -1);
790
 
                        DEBUG_MSG("cust_con_struc_dialog_ok_lcb, i=%d, dialogarray[i]=%s\n", i, dialogarray[i]);
 
1676
                        DEBUG_MSG("cust_con_struc_dialog_ok_lcb, tmpt=%p, i=%d\n", tmpt, i);
 
1677
                        tmpt->my_int = 48 + i;
 
1678
                        tmpt->my_char = gtk_editable_get_chars(GTK_EDITABLE(ccs->textentry[i]), 0, -1);
 
1679
                        tmpt++;
791
1680
                }
792
 
                dialogarray[i] = NULL;
793
 
                DEBUG_MSG("cust_con_struc_dialog_ok_lcb, i=%d, dialogarray[i]=%p\n", i, dialogarray[i]);
 
1681
                DEBUG_MSG("cust_con_struc_dialog_ok_lcb, setting tmpt(%p) to NULL\n", tmpt);
 
1682
                tmpt->my_char = NULL;
794
1683
 
 
1684
                if (strlen(ccs->array[1])) {
 
1685
                        DEBUG_MSG("cust_con_struc_dialog_ok_lcb, ccs->array[1]=%s\n",ccs->array[1] );
 
1686
                        before = replace_string_printflike(ccs->array[1], table);
 
1687
                }
795
1688
                if (strlen(ccs->array[2])) {
796
 
                        DEBUG_MSG("cust_con_struc_dialog_ok_lcb, ccs->array[2]=%s\n",ccs->array[2] );
797
 
                        before = replace_string(ccs->array[2], dialogarray);
798
 
                }
799
 
                if (strlen(ccs->array[3])) {
800
 
                        after = replace_string(ccs->array[3], dialogarray);
801
 
                }
802
 
                insert_dbl_text(before, after);
803
 
                g_strfreev(dialogarray);
 
1689
                        after = replace_string_printflike(ccs->array[2], table);
 
1690
                }
 
1691
                doc_insert_two_strings(ccs->bfwin->current_document, before, after);
 
1692
                tmpt = table;
 
1693
                while (tmpt->my_char) {
 
1694
                        DEBUG_MSG("cust_con_struc_dialog_ok_lcb, tmpt=%p, about to free(%p) %s\n", tmpt, tmpt->my_char, tmpt->my_char);
 
1695
                        g_free(tmpt->my_char);
 
1696
                        tmpt++;
 
1697
                }
 
1698
                g_free(table);
804
1699
 
805
1700
                if (before) {
806
1701
                        g_free(before);
810
1705
                }
811
1706
        } else {
812
1707
                gchar *search=NULL, *replace=NULL;
813
 
                num_vars = atoi(ccs->array[7]);
814
 
                dialogarray = g_malloc((num_vars+1) * sizeof(char *));
 
1708
                num_vars = atoi(ccs->array[6]);
 
1709
                table = tmpt = g_new(Tconvert_table, num_vars+1);
815
1710
                for (i=0; i<num_vars; i++) {
816
 
                        dialogarray[i] = gtk_editable_get_chars(GTK_EDITABLE(ccs->textentry[i]), 0, -1);
817
 
                        DEBUG_MSG("cust_con_struc_dialog_ok_lcb, i=%d, dialogarray[i]=%s\n", i, dialogarray[i]);
818
 
                }
819
 
                dialogarray[i] = NULL;
 
1711
                        tmpt->my_int = 48 + i;
 
1712
                        tmpt->my_char = gtk_editable_get_chars(GTK_EDITABLE(ccs->textentry[i]), 0, -1);
 
1713
                        tmpt++;
 
1714
                }
 
1715
                tmpt->my_char = NULL;
 
1716
                if (strlen(ccs->array[1])) {
 
1717
                        DEBUG_MSG("cust_con_struc_dialog_ok_lcb, ccs->array[1]=%s\n",ccs->array[1] );
 
1718
                        search = replace_string_printflike(ccs->array[1], table);
 
1719
                }
820
1720
                if (strlen(ccs->array[2])) {
821
 
                        DEBUG_MSG("cust_con_struc_dialog_ok_lcb, ccs->array[2]=%s\n",ccs->array[2] );
822
 
                        search = replace_string(ccs->array[2], dialogarray);
823
 
                }
824
 
                if (strlen(ccs->array[3])) {
825
 
                        replace = replace_string(ccs->array[3], dialogarray);
 
1721
                        replace = replace_string_printflike(ccs->array[2], table);
826
1722
                } else {
827
1723
                        replace = g_strdup("");
828
1724
                }
829
 
                snr2_run_extern_replace(search, atoi(ccs->array[4]),
830
 
                                atoi(ccs->array[5]), atoi(ccs->array[6]), replace);
831
 
                g_strfreev(dialogarray);
 
1725
                snr2_run_extern_replace(ccs->bfwin->current_document, search, atoi(ccs->array[3]),
 
1726
                                atoi(ccs->array[4]), atoi(ccs->array[5]), replace, TRUE);
 
1727
                
 
1728
                tmpt = table;
 
1729
                while (tmpt->my_char) {
 
1730
                        g_free(tmpt->my_char);
 
1731
                        tmpt++;
 
1732
                }
 
1733
                g_free(table);
 
1734
                
832
1735
                if (search) {
833
1736
                        g_free(search);
834
1737
                }
839
1742
        cust_con_struc_dialog_cancel_lcb(NULL, ccs);
840
1743
}
841
1744
 
842
 
static void cust_con_struc_dialog(gchar **array, gint type) {
 
1745
static void cust_con_struc_dialog(Tbfwin *bfwin, gchar **array, gint type) {
843
1746
        Tcust_con_struc *ccs;
844
1747
        GtkWidget *vbox, *hbox, *okb, *cancb;
845
1748
        gint i, num_vars;
846
1749
 
847
1750
        ccs = g_malloc(sizeof(Tcust_con_struc));
848
1751
        ccs->type = type;
 
1752
        ccs->bfwin = bfwin;
849
1753
        DEBUG_MSG("cust_con_struc_dialog_cb, ccs at %p\n", ccs);
850
1754
        ccs->array = array;
851
1755
        DEBUG_MSG("cust_con_struc_dialog_cb, array at %p, &array[0]=%p\n", ccs->array, &ccs->array[0]);
852
1756
        DEBUG_MSG("cust_con_struc_dialog_cb, array[0] at %p, *array=%p\n", ccs->array[0], *ccs->array);
853
 
        ccs->dialog = window_full(ccs->array[0], GTK_WIN_POS_MOUSE, GTK_WINDOW_DIALOG, 
854
 
                        5, cust_con_struc_dialog_cancel_lcb, ccs);
 
1757
        ccs->dialog = window_full2(ccs->array[0], GTK_WIN_POS_MOUSE,  
 
1758
                        5, G_CALLBACK(cust_con_struc_dialog_destroy_lcb), ccs, TRUE, NULL);
855
1759
        vbox = gtk_vbox_new(TRUE, 0);
856
1760
        gtk_container_add(GTK_CONTAINER(ccs->dialog), vbox);
857
1761
        DEBUG_MSG("cust_con_struc_dialog_cb, ccs->array[0]=%s\n", ccs->array[0]);
858
1762
        
859
1763
        if (type == 0) {
860
 
                num_vars = atoi(ccs->array[4]);
 
1764
                num_vars = atoi(ccs->array[3]);
861
1765
        } else {
862
 
                num_vars = atoi(ccs->array[7]);
 
1766
                num_vars = atoi(ccs->array[6]);
863
1767
        }
864
1768
        DEBUG_MSG("cust_con_struc_dialog_cb, num_vars=%d\n", num_vars);
865
1769
 
866
1770
        for (i=0; i<num_vars; i++) {
867
1771
                hbox = gtk_hbox_new(FALSE, 0);
868
1772
                if (type ==0) {
869
 
                        gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(ccs->array[i+5]), TRUE, TRUE, 2);
 
1773
                        gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(ccs->array[i+4]), TRUE, TRUE, 2);
870
1774
                } else {
871
 
                        gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(ccs->array[i+8]), TRUE, TRUE, 2);
 
1775
                        gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(ccs->array[i+7]), TRUE, TRUE, 2);
872
1776
                }
873
1777
                ccs->textentry[i] = gtk_entry_new();
874
1778
                DEBUG_MSG("cust_con_struc_dialog_cb, textentry[%d]=%p\n", i, ccs->textentry[i]);
 
1779
                gtk_entry_set_activates_default(GTK_ENTRY(ccs->textentry[i]), TRUE);
875
1780
                gtk_box_pack_start(GTK_BOX(hbox), ccs->textentry[i], TRUE, TRUE, 0);            
876
1781
                gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
877
1782
        }
878
 
 
879
 
        hbox = gtk_hbox_new(TRUE, 0);
880
 
        okb = bf_stock_ok_button(cust_con_struc_dialog_ok_lcb, ccs);
881
 
        cancb = bf_stock_cancel_button(cust_con_struc_dialog_cancel_lcb, ccs);
882
 
        gtk_box_pack_start(GTK_BOX(hbox), okb, TRUE, TRUE, 0);
883
 
        gtk_box_pack_start(GTK_BOX(hbox), cancb, TRUE, TRUE, 0);
884
 
        gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
 
1783
        
 
1784
        gtk_box_pack_start(GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 12);
 
1785
        hbox = gtk_hbutton_box_new();
 
1786
        gtk_hbutton_box_set_layout_default(GTK_BUTTONBOX_END);
 
1787
        gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbox), 12);
 
1788
        okb = bf_stock_ok_button(G_CALLBACK(cust_con_struc_dialog_ok_lcb), ccs);
 
1789
        cancb = bf_stock_cancel_button(G_CALLBACK(cust_con_struc_dialog_cancel_lcb), ccs);
 
1790
        gtk_box_pack_start(GTK_BOX(hbox),cancb , FALSE, FALSE, 0);
 
1791
        gtk_box_pack_start(GTK_BOX(hbox),okb , FALSE, FALSE, 0);
 
1792
        gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
885
1793
 
886
1794
        gtk_widget_grab_focus(ccs->textentry[0]);
 
1795
        gtk_widget_grab_default(okb);
887
1796
        gtk_widget_show_all(ccs->dialog);
888
1797
}
889
 
/*****************************************************************************/
890
 
 
891
 
 
892
 
typedef struct {
893
 
        GtkItemFactoryEntry entry;
894
 
        gchar **array;
895
 
} Tcmenu_entry;
896
 
 
897
 
static void cust_menu_lcb(GtkWidget * widget, gpointer data) {
898
 
        Tcmenu_entry *cmentry;
899
 
 
900
 
        cmentry = (Tcmenu_entry *) g_list_nth_data(main_v->cmenu_arrays, GPOINTER_TO_INT(data));
901
 
        if (strcmp(cmentry->array[1], "0") ==0) {
902
 
                DEBUG_MSG("cust_menu_lcb, a custom dialog, array[4]=%s\n", cmentry->array[4]);
903
 
                if (atoi(cmentry->array[4]) > 0) {
904
 
                     cust_con_struc_dialog(cmentry->array, 0);
 
1798
 
 
1799
 
 
1800
static void cust_menu_lcb(Tcmenu_entry *cmentry,guint callback_action,GtkWidget *widget) {
 
1801
        if (cmentry->type == 0) {
 
1802
                DEBUG_MSG("cust_menu_lcb, a custom insert, array[3]=%s\n", cmentry->array[3]);
 
1803
                if (atoi(cmentry->array[3]) > 0) {
 
1804
                     cust_con_struc_dialog(cmentry->bfwin,cmentry->array, 0);
905
1805
                } else {
906
 
                     insert_dbl_text (cmentry->array[2],cmentry->array[3]);
 
1806
                     doc_insert_two_strings(cmentry->bfwin->current_document, cmentry->array[1],cmentry->array[2]);
907
1807
                }
908
1808
        } else {
909
 
                DEBUG_MSG("cust_menu_lcb, count_array(cmentry->array)=%d\n", count_array(cmentry->array));
910
 
                DEBUG_MSG("cust_menu_lcb, a custom search and replace!, cmentry->array[7]=%s\n", cmentry->array[7]);
911
 
                if (strcmp(cmentry->array[4], "2")==0 && !GTK_EDITABLE(main_v->current_document->textbox)->has_selection) {
912
 
                        error_dialog(_("Bluefish error"), _("This custom search and replace requires a selection"));
 
1809
                DEBUG_MSG("cust_menu_lcb, a custom replace!, cmentry->array[6]=%s\n", cmentry->array[6]);
 
1810
                if (strcmp(cmentry->array[3], "2")==0 && !doc_has_selection(cmentry->bfwin->current_document)) {
 
1811
                        warning_dialog(cmentry->bfwin->main_window,_("This custom search and replace requires a selection"), NULL);
913
1812
                        return;
914
1813
                }
915
 
                if (atoi(cmentry->array[7]) > 0) {
916
 
                        cust_con_struc_dialog(cmentry->array, 1);
 
1814
                if (atoi(cmentry->array[6]) > 0) {
 
1815
                        cust_con_struc_dialog(cmentry->bfwin,cmentry->array, 1);
917
1816
                } else {
918
 
                     snr2_run_extern_replace(cmentry->array[2], atoi(cmentry->array[4]),
919
 
                                                        atoi(cmentry->array[5]), atoi(cmentry->array[6]), cmentry->array[3]);
 
1817
                     snr2_run_extern_replace(cmentry->bfwin->current_document,cmentry->array[1], atoi(cmentry->array[3]),
 
1818
                                                        atoi(cmentry->array[4]), atoi(cmentry->array[5]), cmentry->array[2],TRUE);
920
1819
                }
921
1820
        }
922
1821
}
923
1822
 
924
 
static void create_parent_and_tearoff(gchar *menupath, GtkItemFactory *ifactory) {
925
 
        char *basepath;
926
 
        GtkWidget *widg=NULL;
927
 
        GtkItemFactoryEntry entry;
928
 
 
929
 
        basepath = g_strndup(menupath, (strlen(menupath) - strlen(strrchr(menupath, '/'))));
930
 
        DEBUG_MSG("create_parent_and_tearoff, basepath=%s\n", basepath);
931
 
        widg = gtk_item_factory_get_widget(ifactory, basepath);
932
 
        if (!widg) {
933
 
                create_parent_and_tearoff(basepath, ifactory);
934
 
                entry.path = g_strconcat(basepath, "/sep", NULL);
935
 
                entry.accelerator = NULL;
936
 
                entry.callback = NULL;
937
 
                entry.callback_action = 0;
938
 
                entry.item_type = "<Tearoff>";
939
 
                gtk_item_factory_create_item(ifactory, &entry, NULL, 2);
940
 
                g_free(entry.path);
941
 
        }
942
 
}
943
 
 
944
 
static gchar **convert_old_cmenu_entry(gchar **old_entry) {
945
 
        gchar ** new_entry;
946
 
        gint i, j, count = count_array(old_entry) + 1;
947
 
 
948
 
        DEBUG_MSG("convert_old_cmenu_entry, converting %s\n", old_entry[0]);
949
 
        new_entry = g_malloc((count+1) * sizeof(gchar *) );
950
 
        for (i=0; i<count;i++) {
951
 
                j = i > 0 ? i+1 : i;
952
 
                new_entry[j] = g_strdup(old_entry[i]);
953
 
        }
954
 
        new_entry[1] = g_strdup("0");
955
 
        new_entry[count] = NULL;
956
 
        return new_entry;
957
 
}
958
 
 
959
 
static void fill_cust_menubar() {
 
1823
static Tcmenu_entry *create_cmentry(Tbfwin *bfwin,const gchar *menupath, gint count, gchar **array, GtkItemFactory *ifactory, gint type) {
 
1824
        Tcmenu_entry *cmentry = g_malloc0(sizeof(Tcmenu_entry));
 
1825
        cmentry->bfwin = bfwin;
 
1826
        cmentry->entry.path = g_strdup(menupath);
 
1827
        DEBUG_MSG("create_cmentry, entry.path=%s, count=%d\n", cmentry->entry.path, count);
 
1828
        cmentry->entry.callback = cust_menu_lcb;
 
1829
        cmentry->entry.callback_action = count;
 
1830
        cmentry->array = array;
 
1831
        cmentry->type = type;
 
1832
        create_parent_and_tearoff(cmentry->entry.path, ifactory);
 
1833
        gtk_item_factory_create_item(ifactory, &cmentry->entry, cmentry, 1);
 
1834
        return cmentry;
 
1835
}
 
1836
 
 
1837
static void fill_cust_menubar(Tbfwin *bfwin) {
960
1838
        GtkItemFactory *ifactory;
961
1839
        gint count;
962
1840
        gchar **splittedstring;
963
1841
        GList *tmplist;
964
1842
        Tcmenu_entry *cmentry;
965
1843
 
966
 
        ifactory = gtk_item_factory_from_widget(main_v->cmenu);
 
1844
        ifactory = gtk_item_factory_from_widget(bfwin->menu_cmenu);
967
1845
 
968
 
        tmplist = g_list_first(main_v->cmenu_arrays);
 
1846
        tmplist = g_list_first(bfwin->menu_cmenu_entries);
969
1847
        while (tmplist) {
970
1848
                cmentry = (Tcmenu_entry *) tmplist->data;
971
1849
                gtk_item_factory_delete_entry(ifactory, &cmentry->entry);
974
1852
                g_free(cmentry);
975
1853
                tmplist = g_list_next(tmplist);
976
1854
        }
977
 
        g_list_free(main_v->cmenu_arrays);
978
 
        main_v->cmenu_arrays = NULL;
 
1855
        g_list_free(bfwin->menu_cmenu_entries);
 
1856
        bfwin->menu_cmenu_entries = NULL;
979
1857
 
980
1858
        count = 0;
981
 
        tmplist = g_list_first(main_v->props.cust_menu);
982
 
        while (tmplist) {
983
 
                gint count2;
984
 
                splittedstring = (gchar **) tmplist->data;
985
 
                count2 = count_array(splittedstring);
986
 
                
987
 
                /* this is for backwards compatibility with bluefish < 0.7 */
988
 
                if (count2 < 4) {
989
 
                        tmplist = g_list_next(tmplist);
990
 
                        continue;
991
 
                }
992
 
                DEBUG_MSG("fill_cust_menubar, splittedstring[1]='%s'\n", splittedstring[1]);
993
 
                if ((strcmp(splittedstring[1], "0") != 0) && (strcmp(splittedstring[1], "1") != 0)) {
994
 
                        gchar **new_splittedstring = convert_old_cmenu_entry(splittedstring);
995
 
                        tmplist->data = new_splittedstring;
996
 
                        g_strfreev (splittedstring);
997
 
                        splittedstring = new_splittedstring;
998
 
                }
999
 
 
1000
 
                if (count2 < 5) {
1001
 
                        DEBUG_MSG("fill_cust_menubar, array count < 4, this is invalid\n");
1002
 
                        tmplist = g_list_next(tmplist);
1003
 
                        continue;
1004
 
                }
1005
 
                if ((strcmp(splittedstring[1] , "1")==0) && (count2 < 8)) {
1006
 
                        DEBUG_MSG("fill_cust_menubar, type 1, array count < 8, this is invalid\n");
1007
 
                        tmplist = g_list_next(tmplist);
1008
 
                        continue;
1009
 
                }
1010
 
                
1011
 
                cmentry = g_malloc0(sizeof(Tcmenu_entry));
1012
 
                cmentry->entry.path = g_strdup(splittedstring[0]);
1013
 
                DEBUG_MSG("fill_cust_menubar, entry.path=%s, count=%d\n", cmentry->entry.path, count);
1014
 
                cmentry->entry.callback = cust_menu_lcb;
1015
 
                cmentry->entry.callback_action = count;
1016
 
                cmentry->array = splittedstring;
1017
 
                create_parent_and_tearoff(cmentry->entry.path, ifactory);
1018
 
                gtk_item_factory_create_item(ifactory, &cmentry->entry, GINT_TO_POINTER(count), 2);
1019
 
                main_v->cmenu_arrays = g_list_append(main_v->cmenu_arrays, cmentry);
1020
 
                count++;
1021
 
                tmplist = g_list_next(tmplist);
1022
 
        }
1023
 
}
1024
 
 
1025
 
static GList *add_ar(GList *list, gchar **ar) {
1026
 
        gchar **tmp = ar, **array;
1027
 
        gint count = count_array(ar);
1028
 
 
1029
 
        array = g_malloc((count+1) * sizeof(gchar *) );
1030
 
        count=0;
1031
 
        while (*tmp) {
1032
 
                array[count] = g_strdup(*tmp);
1033
 
                count++;
1034
 
                tmp++;
1035
 
        }
1036
 
        array[count] = NULL;
1037
 
        return g_list_append(list, array);
1038
 
}
1039
 
/* the format of the array is explained above */
1040
 
 
1041
 
void reset_cust_menu_list_cb(GtkWidget * widget, gpointer data)
1042
 
{
1043
 
        gchar *ar1[]= {N_("/php/ibase/ibase fetch row"), "0", "while ($%1 = ibase_fetch_row($%0)) {\n   echo $%1[0];\n", "\n}\nibase_free_result($%0);\n", "2", _("ibase result variable name"), _("row variable name"), NULL};
1044
 
        gchar *ar2[]= {N_("/php/mysql/mysql fetch row"), "0", "while ($%1 = mysql_fetch_row($%0)) {\n   echo $%1[0];\n", "\n}\nmysql_free_result($%0);\n", "2", _("mysql result variable name"), _("row variable name"), NULL};
1045
 
        gchar *ar3[]= {N_("/php/mysql/mysql connect"), "0", "$mysql_id = mysql_connect('%0', '%1', '%2');\nmysql_select_db('%3', $mysql_id);\n", "", "4", _("mysql host"), _("mysql username"), _("mysql password"), _("database name"), NULL};
1046
 
        gchar *ar4[]= {N_("/php/ibase/ibase connect"), "0", "$ibase_id = ibase_connect('%0:%1', '%2', '%3');\n", "", "4", _("ibase host"), _("ibase database path"), _("ibase username"), _("ibase password"), NULL};
1047
 
        gchar *ar5[]= {N_("/php/general/while each in array list"), "0", "while (list($key, $val) = each($%0)) {\n      ", "\n}\n", "1", _("array name"), NULL};
1048
 
        gchar *ar6[]= {N_("/sql/select all from table"), "0", "SELECT * FROM %0", "", "1", _("table name"), NULL};
1049
 
        gchar *ar7[] = {N_("/php/general/mail"), "0", "mail(\"%0\", \"%1\", $%2);\n", "", "3", _("email adress"), _("subject"), _("mail body variable name"),  NULL};
1050
 
        gchar *ar8[] = {N_("/php/general/for loop"), "0", "for ($%0 = %1; $%0 <= %2; $%0++) {\n ", "\n}\n", "3", _("loop variable name"), _("from value"), _("to value"),  NULL};
1051
 
        gchar *ar9[] = {N_("/php/ibase/query"), "0", "$%0 = ibase_query(%1, %2);\nif (ibase_errmsg() != 0){\n   echo 'Error: '.%2.' returned '.ibase_errmsg().\"<br>\\n\";\n}\n", "", "3", _("result variable name"), _("ibase connection id name"), _("query string (quoted) or variable (including $)"),  NULL};
1052
 
        gchar *ar10[] = {N_("/php/general/include file"), "0", "include('%0');\n", "", "1", _("filename to include"), NULL};
1053
 
        gchar *ar11[] = {N_("/php/general/require file"), "0", "require('%0');\n", "", "1", _("filename to require"), NULL};
1054
 
        gchar *ar12[] = {N_("/php/general/if isset"), "0", "if (isset($%0)) {\n ", "\n}", "1", _("variable name to test for"), NULL};
1055
 
        gchar *ar13[] = {N_("/php/general/if not isset"), "0", "if (!isset($%0)) {\n    ", "\n}", "1", _("variable name to test for"), NULL};
1056
 
        gchar *ar14[] = {N_("/php/mysql/query"), "0", "$%0 = mysql_query(%2, %1);\n", "", "3", _("result variable name"), _("mysql connection id name"), _("query string (quoted) or variable (including $)"),  NULL};
1057
 
        gchar *ar15[] = {N_("/html/font symbol"), "0", "<font face=\"Symbol\">", "</font>", NULL};
1058
 
        gchar *ar16[] = {N_("/html/div with class"), "0", "<div class=\"%0\">", "</div>", "1", _("CSS class name"), NULL};
1059
 
        gchar *ar17[] = {N_("/html/span with class"), "0", "<span class=\"%0\">", "</span>", "1", _("CSS class name"), NULL};
1060
 
        gchar *ar18[]= {N_("/php/php block"), "0", "\n<?php\n", "\n?>\n", NULL};
1061
 
        gchar *ar19[]= {N_("/html/made with bluefish"), "0", "<a href=\"http://bluefish.openoffice.nl/\">Made with the Bluefish HTML editor</a>", "", NULL};
1062
 
        gchar *ar20[]= {N_("/html/meta keywords"), "0", "<meta name=\"keywords\" value=\"%0\">", "", "1", _("keywords, space separated"), NULL};
1063
 
        gchar *ar21[]= {N_("/html/meta refresh (client pull)"), "0", "<meta http-equiv=\"refresh\" content=\"%0; URL=%1\">", "", "2", _("refresh time, in seconds"), _("URL to redirect to"), NULL};
1064
 
        gchar *ar22[]= {N_("/active html/form"), "0", "<form method=\"POST\" action=\"<?php echo $SCRIPT_NAME ?>\">\n\n", "</form>", NULL};
1065
 
        gchar *ar23[]= {N_("/active html/form and action"), "0", "<?php if (isset($submitted)) {\n//form submit code here\n} else { ?>\n<form method=\"POST\" action=\"<?php echo $SCRIPT_NAME ?>\">\n\n<input type=\"submit\" name=\"submitted\" value=\"%0\"></form>\n<?php } // end of form ?>", "", "1", _("Submit button text"), NULL};
1066
 
        gchar *ar24[]= {N_("/active html/input text"), "0", "<input type=\"text\" name=\"%0\" value=\"<?php if (isset($%0)) { echo $%0; } ?>\">", "", "1", _("variable name"), NULL};
1067
 
        gchar *ar25[]= {N_("/active html/input checkbox"), "0", "<input type=\"checkbox\" name=\"%0\" value=\"%1\" <?php if (isset($%0)) { echo 'checked'; } ?>>", "", "2", _("variable name"), _("value when checked"), NULL};
1068
 
        gchar *ar26[]= {N_("/active html/textarea"), "0", "<textarea name=\"%0\" rows=\"20\" cols=\"40\"><?php if (isset($%0)) { echo $%0; } ?></textarea>", "", "1", _("variable name"), NULL};
1069
 
        gchar *ar27[]= {N_("/active html/select options/from array"), "0", "<select name=\"%0\">\n<?php\nwhile(list($key, $val)=each($%1)) {\n\tif (isset($%0) && ($%0 == $val)) {\n\t\techo '<option value=\"'.$key.'\" selected>'.$val.'</option>';\n\t} else {\n\t\techo '<option value=\"'.$key.'\">'.$val.'</option>';\n\t}\n}\n?></select>", "", "2", _("variable name"), _("array name containing options"), NULL};
1070
 
        gchar *ar28[]= {N_("/active html/select options/from mysql result"), "0", "<select name=\"%0\">\n<?php\nwhile($row = mysql_fetch_row($%1)) {\n\tif (isset($%0) && ($%0 == $row[%2])) {\n\t\techo '<option value=\"'.$row[%2].'\" selected>'.$row[%3].'</option>';\n\t} else {\n\t\techo '<option value=\"'.$row[%2].'\">'.$row[%3].'</option>';\n\t}\n}\n?></select>", "", "4", _("variable name"), _("mysql query result"), _("index of the value"), _("index of the label"), NULL};
1071
 
        gchar *ar29[]= {N_("/active html/select options/from ibase result"), "0", "<select name=\"%0\">\n<?php\nwhile($row = ibase_fetch_row($%1)) {\n\tif (isset($%0) && ($%0 == $row[%2])) {\n\t\techo '<option value=\"'.$row[%2].'\" selected>'.$row[%3].'</option>';\n\t} else {\n\t\techo '<option value=\"'.$row[%2].'\">'.$row[%3].'</option>';\n\t}\n}\n?></select>", "", "4", _("variable name"), _("ibase query result"), _("index of the value"), _("index of the label"), NULL};
1072
 
        gchar *ar30[]= {N_("/DHTML/mouseover image"), "0", "<a href=\"\" onMouseOver=\"bfmovepic('%0', '%2')\" onMouseOut=\"bfmovepic('%0', '%1')\"><img src=\"%1\" name=\"%0\"></a>", "", "3", _("unique name"), _("onMouseOut src"), _("onMouseOver src"), NULL};
1073
 
        gchar *ar31[]= {N_("/php/odbc/odbc connect"), "0", "$odbc_id = odbc_connect('%0', '%1', '%2');\n", "", "3", _("odbc data source name"), _("username"), _("password"), NULL};
1074
 
        gchar *ar32[]= {N_("/php/odbc/odbc exec query"), "0", "$%0 = odbc_exec(%1, %2);\n", "", "3", _("result variable name"), _("odbc connection id name"), _("query string (quoted) or variable (including $)"), NULL};
1075
 
        gchar *ar33[]= {N_("/php/odbc/odbc fetch row"), "0", "while($success = odbc_fetch_row($%0)) {\n\t\n}", "", "1", _("result variable name"), NULL};
1076
 
        gchar *ar34[]= {N_("/php/general/echo date"), "0", "echo date(\"l dS of F Y h:i:s A\");", "", NULL};
1077
 
        gchar *ar35[]= {N_("/php/filesystem/open and echo file"), "0", "$fd = fopen(%0, 'r');\nwhile (!feof($fd)) {\n\t$buffer = fgets($fd, 4096);\n\techo $buffer;\n}\nfclose($fd);", "", "1", _("file (quoted) or variable (including $)"), NULL};
1078
 
        gchar *ar36[]= {N_("/php/general/location header"), "0", "header('Location: '.%0);", "", "1", _("location (URL) to redirect to (quoted) or variable (including $)"), NULL};
1079
 
        gchar *ar37[]= {N_("/apache/basic password required"), "0", "AuthName \"%1\"\nAuthType Basic\nrequire valid-user\nAuthUserFile %0\n", "", "2", _("full path to password file"), _("security description"), NULL};
1080
 
        gchar *ar38[]= {N_("/apache/deny access to .inc"), "0", "<FilesMatch \"\\.inc$\">\n     Order allow,deny\n      Deny from all\n</FilesMatch>", "", "0", NULL};  
1081
 
        gchar *ar39[]= {N_("/replace/strip <font>"), "1", "(<font[^>]*>|</font>)", "", "0", "1", "0", "0", NULL};
1082
 
        gchar *ar40[]= {N_("/replace/strip <any tag> in selection"), "1", "(<%0[^>]*>|</%0>)", "", "2", "1", "0", "1", "tag name, like td, font or a", NULL};
1083
 
        gchar *ar41[]= {N_("/replace/convert <td> in <th> in selection"), "1", "(<|</)(td)([^>]*)(>)", "\\0th\\2>", "2", "1", "0", "0", NULL};
1084
 
        gchar *ar42[]= {N_("/replace/convert <any tag> in <any other tag> in selection"), "1", "(<|</)(%0)([^>]*)(>)", "\\0%1\\2>", "2", "1", "0", "2", "any tag name", "any other tag name", NULL};
1085
 
        free_arraylist(main_v->props.cust_menu);
1086
 
 
1087
 
        main_v->props.cust_menu = NULL;
1088
 
 
1089
 
/* generated in BASH 2 using:
1090
 
for ((i=1;i<37;i++)) ; do echo "main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar$i);"; done
1091
 
*/
1092
 
 
1093
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar1);
1094
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar2);
1095
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar3);
1096
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar4);
1097
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar5);
1098
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar6);
1099
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar7);
1100
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar8);
1101
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar9);
1102
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar10);
1103
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar11);
1104
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar12);
1105
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar13);
1106
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar14);
1107
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar15);
1108
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar16);
1109
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar17);
1110
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar18);
1111
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar19);
1112
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar20);
1113
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar21);
1114
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar22);
1115
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar23);
1116
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar24);
1117
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar25);
1118
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar26);
1119
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar27);
1120
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar28);
1121
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar29);
1122
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar30);
1123
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar31);
1124
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar32);
1125
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar33);
1126
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar34);
1127
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar35);
1128
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar36);
1129
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar37);
1130
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar38);
1131
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar39);
1132
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar40);
1133
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar41);
1134
 
        main_v->props.cust_menu = add_ar(main_v->props.cust_menu, ar42);
1135
 
        fill_cust_menubar();
 
1859
        tmplist = g_list_first(main_v->props.cmenu_insert);
 
1860
        while (tmplist) {
 
1861
                gint count2;
 
1862
                splittedstring = (gchar **) tmplist->data;
 
1863
                count2 = count_array(splittedstring);
 
1864
                if (count2 >= 4) {
 
1865
                        cmentry = create_cmentry(bfwin,splittedstring[0], count, splittedstring, ifactory, 0);
 
1866
                        bfwin->menu_cmenu_entries = g_list_append(bfwin->menu_cmenu_entries, cmentry);
 
1867
                }
 
1868
                count++;
 
1869
                tmplist = g_list_next(tmplist);
 
1870
        }
 
1871
        tmplist = g_list_first(main_v->props.cmenu_replace);
 
1872
        while (tmplist) {
 
1873
                gint count2;
 
1874
                splittedstring = (gchar **) tmplist->data;
 
1875
                count2 = count_array(splittedstring);
 
1876
                if (count2 >= 4) {
 
1877
                        cmentry = create_cmentry(bfwin,splittedstring[0], count, splittedstring, ifactory, 1);
 
1878
                        bfwin->menu_cmenu_entries = g_list_append(bfwin->menu_cmenu_entries, cmentry);
 
1879
                }
 
1880
                count++;
 
1881
                tmplist = g_list_next(tmplist);
 
1882
        }
 
1883
}
 
1884
 
 
1885
static void cmenu_reset_lcb(Tbfwin *bfwin,guint callback_action,GtkWidget *widget) {
 
1886
        GList *tmplist;
 
1887
        rcfile_parse_custom_menu(TRUE, FALSE);
 
1888
        tmplist = g_list_first(main_v->bfwinlist);
 
1889
        while (tmplist) {
 
1890
                fill_cust_menubar(BFWIN(tmplist->data));
 
1891
                tmplist = g_list_next(tmplist);
 
1892
        }
 
1893
}
 
1894
static void cmenu_load_new_lcb(Tbfwin *bfwin,guint callback_action,GtkWidget *widget) {
 
1895
        GList *tmplist;
 
1896
        rcfile_parse_custom_menu(FALSE, TRUE);
 
1897
        tmplist = g_list_first(main_v->bfwinlist);
 
1898
        while (tmplist) {
 
1899
                fill_cust_menubar(BFWIN(tmplist->data));
 
1900
                tmplist = g_list_next(tmplist);
 
1901
        }
 
1902
}
 
1903
/* function declaration needed here */
 
1904
void cmenu_editor(Tbfwin *bfwin,guint callback_action,GtkWidget *widget);
 
1905
 
 
1906
void make_cust_menubar(Tbfwin *bfwin, GtkWidget *cust_handle_box) {
 
1907
        static GtkItemFactoryEntry cust_menu[] = {
 
1908
                {N_("/_Custom menu"), NULL, NULL, 0, "<Branch>"},
 
1909
                {N_("/Custom menu/sep"), NULL, NULL, 0, "<Tearoff>"},
 
1910
                {N_("/Custom menu/Edit custom menu..."), NULL, cmenu_editor, 0, NULL},
 
1911
                {N_("/Custom menu/Reset"), NULL, cmenu_reset_lcb, 0, NULL},
 
1912
                {N_("/Custom menu/Load new"), NULL, cmenu_load_new_lcb, 0, NULL}
 
1913
        };
 
1914
        GtkItemFactory *item_factory;
 
1915
        GtkAccelGroup *accel_group;
 
1916
        gint nmenu_items = sizeof(cust_menu) / sizeof(cust_menu[0]);
 
1917
 
 
1918
        DEBUG_MSG("make_cust_menubar, started\n");
 
1919
 
 
1920
        /* this should only happen once !!!!!!!!!! */
 
1921
        accel_group = gtk_accel_group_new();
 
1922
        item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<bluefishcustom>", accel_group);
 
1923
#ifdef ENABLE_NLS
 
1924
        gtk_item_factory_set_translate_func(item_factory, menu_translate, "<bluefishcustom>", NULL);
 
1925
#endif
 
1926
        gtk_item_factory_create_items(item_factory, nmenu_items, cust_menu, bfwin);
 
1927
        gtk_window_add_accel_group(GTK_WINDOW(bfwin->main_window), accel_group);
 
1928
 
 
1929
        bfwin->menu_cmenu = gtk_item_factory_get_widget(item_factory, "<bluefishcustom>");
 
1930
        gtk_container_add(GTK_CONTAINER(bfwin->custom_menu_hb), bfwin->menu_cmenu);
 
1931
        gtk_widget_show(bfwin->menu_cmenu);
 
1932
 
 
1933
        fill_cust_menubar(bfwin);
 
1934
 
 
1935
        DEBUG_MSG("make_cust_menubar, finished\n");
1136
1936
}
1137
1937
 
1138
1938
/*******************************************************************/
1139
1939
/*               Custom menu editor                                */
1140
1940
/*******************************************************************/
1141
 
 
1142
1941
typedef struct {
1143
1942
        GtkWidget *win;
1144
1943
        GtkWidget *type[2];
1145
 
        GtkWidget *clist;
 
1944
        GtkListStore *lstore;
 
1945
        GtkWidget *lview;
1146
1946
        GtkWidget *label1;
1147
1947
        GtkWidget *label2;
1148
1948
        GtkWidget *menupath;
1149
 
        GtkWidget *before;
1150
 
        GtkWidget *after;
 
1949
/*      GtkWidget *befv;*/
 
1950
        GtkTextBuffer *befb;
 
1951
/*      GtkWidget *aftv;*/
 
1952
        GtkTextBuffer *aftb;
1151
1953
        GtkWidget *num;
1152
1954
        gchar **lastarray;
1153
1955
        GtkWidget *dynvbox;
1155
1957
        GtkWidget *descriptions[MAX_TEXT_ENTRY];
1156
1958
        GtkWidget *csnr_box;
1157
1959
        GtkWidget *region;
1158
 
        GtkWidget *is_regex;
 
1960
        GtkWidget *matching;
1159
1961
        GtkWidget *is_case_sens;
1160
 
        GList *worklist;
 
1962
/*      GList *worklist;*/
 
1963
        GList *worklist_insert;
 
1964
        GList *worklist_replace;
 
1965
        Tbfwin *bfwin;
1161
1966
} Tcmenu_editor;
1162
1967
 
1163
 
static void cme_destroy_lcb(GtkWidget *widget, GdkEvent *event, Tcmenu_editor* cme) {
 
1968
static void cme_destroy_lcb(GtkWidget *widget, Tcmenu_editor* cme) {
1164
1969
        window_destroy(cme->win);
1165
 
        free_arraylist(cme->worklist);
 
1970
        free_arraylist(cme->worklist_insert);
 
1971
        free_arraylist(cme->worklist_replace);
1166
1972
        g_free(cme);
1167
1973
}
1168
1974
 
1169
1975
static void cme_close_lcb(GtkWidget *widget, gpointer data) {
1170
 
        cme_destroy_lcb(NULL, NULL, data);
 
1976
        cme_destroy_lcb(NULL, data);
1171
1977
}
1172
1978
 
1173
1979
static void cme_ok_lcb(GtkWidget *widget, Tcmenu_editor *cme) {
1174
1980
        GList *tmplist;
1175
 
 
1176
 
        tmplist = main_v->props.cust_menu;
1177
 
        main_v->props.cust_menu = cme->worklist;
1178
 
        cme->worklist = tmplist;
1179
 
        cme_destroy_lcb(NULL, NULL, cme);
1180
 
        fill_cust_menubar();
1181
 
}
1182
 
 
1183
 
static void cme_clist_unselect_lcb(GtkWidget * widget, gint row, gint column, GdkEventButton * event, Tcmenu_editor *cme) {
1184
 
        gint i;
1185
 
 
1186
 
        DEBUG_MSG("cme_clist_unselect_lcb, column=%d, row=%d\n", column, row);
1187
 
        gtk_entry_set_text(GTK_ENTRY(cme->menupath), "");
1188
 
        gtk_editable_delete_text(GTK_EDITABLE(cme->before), 0, -1);
1189
 
        gtk_editable_delete_text(GTK_EDITABLE(cme->after), 0, -1);
1190
 
        gtk_spin_button_set_value(GTK_SPIN_BUTTON(cme->num), 0);
1191
 
        for (i = 0 ; i < MAX_TEXT_ENTRY; i++) {
1192
 
                gtk_entry_set_text(GTK_ENTRY(cme->descriptions[i]), "");
 
1981
        DEBUG_MSG("cme_ok_lcb, start cmenu_insert=%p, worklist_insert=%p\n",main_v->props.cmenu_insert, cme->worklist_insert);
 
1982
        pointer_switch_addresses((gpointer)&main_v->props.cmenu_insert, (gpointer)&cme->worklist_insert);
 
1983
        DEBUG_MSG("cme_ok_lcb, after cmenu_insert=%p, worklist_insert=%p\n",main_v->props.cmenu_insert, cme->worklist_insert);
 
1984
        pointer_switch_addresses((gpointer)&main_v->props.cmenu_replace, (gpointer)&cme->worklist_replace);
 
1985
        cme_destroy_lcb(NULL, cme);
 
1986
        tmplist = g_list_first(main_v->bfwinlist);
 
1987
        while (tmplist) {
 
1988
                fill_cust_menubar(BFWIN(tmplist->data));
 
1989
                tmplist = g_list_next(tmplist);
1193
1990
        }
1194
 
        cme->lastarray = NULL;
1195
 
        DEBUG_MSG("cme_clist_unselect_lcb, lastarray=%p\n", cme->lastarray);
1196
1991
}
1197
1992
 
1198
1993
static void cme_create_entries(Tcmenu_editor *cme, gint num) {
1207
2002
        }
1208
2003
}
1209
2004
 
 
2005
static gboolean cme_iter_at_pointer(GtkTreeIter *iter, gpointer pointer, Tcmenu_editor *cme) {
 
2006
        gpointer tmp;
 
2007
        gboolean cont;
 
2008
        cont = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(cme->lstore),iter);
 
2009
        while (cont) {
 
2010
                gtk_tree_model_get(GTK_TREE_MODEL(cme->lstore),iter,2,&tmp,-1);
 
2011
                if (pointer == tmp) {
 
2012
                        return TRUE;
 
2013
                }
 
2014
                cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(cme->lstore),iter);
 
2015
        }
 
2016
        return FALSE;
 
2017
}
 
2018
 
 
2019
static void cme_lview_selection_changed(GtkTreeSelection *selection, Tcmenu_editor *cme) {
 
2020
        GtkTreeIter iter;
 
2021
        GtkTreeModel *model;
 
2022
        if (gtk_tree_selection_get_selected (selection,&model,&iter)) {
 
2023
                gint num=0, i;
 
2024
                gint type=0;
 
2025
 
 
2026
                gtk_tree_model_get(model, &iter, 1, &type, 2, &cme->lastarray, -1);
 
2027
                
 
2028
                DEBUG_MSG("cme_clist_select_lcb, lastarray=%p, lastarray[0]=%s, type=%d\n", cme->lastarray, cme->lastarray[0], type);
 
2029
 
 
2030
                DEBUG_MSG("cme_clist_select_lcb, cme->lastarray[0]=%s, [i]='%s'\n", cme->lastarray[0], cme->lastarray[1]);
 
2031
                gtk_entry_set_text(GTK_ENTRY(cme->menupath), cme->lastarray[0]);
 
2032
 
 
2033
                DEBUG_MSG("cme_clist_select_lcb, cme->lastarray[1]='%s'\n", cme->lastarray[1]);
 
2034
                gtk_text_buffer_set_text(cme->befb, cme->lastarray[1], -1);
 
2035
 
 
2036
                DEBUG_MSG("cme_clist_select_lcb, cme->lastarray[2]='%s'\n", cme->lastarray[2]);
 
2037
                gtk_text_buffer_set_text(cme->aftb, cme->lastarray[2], -1);
 
2038
 
 
2039
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cme->type[type]), TRUE);
 
2040
                if (type == 0) {
 
2041
                        DEBUG_MSG("cme_clist_select_lcb, type=0, custom dialog\n");
 
2042
                        gtk_widget_hide(cme->csnr_box);
 
2043
                
 
2044
                        num = atoi(cme->lastarray[3]);
 
2045
                        DEBUG_MSG("cme_clist_select_lcb, num=%d\n", num);
 
2046
                        gtk_spin_button_set_value(GTK_SPIN_BUTTON(cme->num), num);
 
2047
        
 
2048
                        cme_create_entries(cme, num);
 
2049
                        DEBUG_MSG("cme_clist_select_lcb, %d entries created\n", num);
 
2050
                        for (i = 0 ; i < num; i++) {
 
2051
                                gtk_entry_set_text(GTK_ENTRY(cme->descriptions[i]), cme->lastarray[i+4]);
 
2052
                        }
 
2053
                        for (i = num ; i < MAX_TEXT_ENTRY; i++) {
 
2054
                                gtk_entry_set_text(GTK_ENTRY(cme->descriptions[i]), "");
 
2055
                        }
 
2056
                } else if (type == 1) {
 
2057
                        static Tconvert_table table1[] = {{0, "0"}, {1, "1"}, {0, NULL}};
 
2058
/*                      static Tconvert_table table2[] = {{0, N_("in current document")}, {1, N_("from cursor")}, {2, N_("in selection")}, {3, N_("in all open documents")}, {0,NULL}};
 
2059
                        static Tconvert_table table3[] = {{0, N_("normal")}, {1, N_("posix regular expressions")}, {2, N_("perl regular expressions")}, {0, NULL}};*/
 
2060
                        gint converti;
 
2061
                        /*gchar *convertc;*/
 
2062
                        DEBUG_MSG("cme_clist_select_lcb, type=1, custom search and replace\n");
 
2063
                        gtk_widget_show(cme->csnr_box);
 
2064
                        DEBUG_MSG("cme_clist_select_lcb, cme->lastarray[4]=%s\n", cme->lastarray[4]);
 
2065
                        
 
2066
                        /*gtk_editable_delete_text(GTK_EDITABLE(GTK_COMBO(cme->matching)->entry), 0, -1);
 
2067
                        converti = atoi(cme->lastarray[4]);
 
2068
                        convertc = table_convert_int2char(table3, converti);
 
2069
                        if (convertc) {
 
2070
                                gint pos=0;
 
2071
                                gtk_editable_insert_text(GTK_EDITABLE(GTK_COMBO(cme->matching)->entry), convertc, strlen(convertc), &pos);
 
2072
                        }*/
 
2073
                        converti = atoi(cme->lastarray[4]);
 
2074
                        gtk_option_menu_set_history(GTK_OPTION_MENU(cme->matching),converti);
 
2075
 
 
2076
                        DEBUG_MSG("cme_clist_select_lcb, cme->lastarray[5]=%s\n", cme->lastarray[5]);
 
2077
                        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cme->is_case_sens), table_convert_char2int(table1, cme->lastarray[5], tcc2i_full_match));
 
2078
                        
 
2079
                        /*gtk_editable_delete_text(GTK_EDITABLE(GTK_COMBO(cme->region)->entry), 0, -1);
 
2080
                        converti = atoi(cme->lastarray[3]);
 
2081
                        convertc = table_convert_int2char(table2, converti);
 
2082
                        if (convertc) {
 
2083
                                gint pos=0;
 
2084
                                gtk_editable_insert_text(GTK_EDITABLE(GTK_COMBO(cme->region)->entry), convertc, strlen(convertc), &pos);
 
2085
                        }*/
 
2086
                        converti = atoi(cme->lastarray[3]);
 
2087
                        gtk_option_menu_set_history(GTK_OPTION_MENU(cme->region),converti);
 
2088
 
 
2089
                        num = atoi(cme->lastarray[6]);
 
2090
                        gtk_spin_button_set_value(GTK_SPIN_BUTTON(cme->num), num);
 
2091
        
 
2092
                        cme_create_entries(cme, num);
 
2093
                        for (i = 0 ; i < num; i++) {
 
2094
                                gtk_entry_set_text(GTK_ENTRY(cme->descriptions[i]), cme->lastarray[i+7]);
 
2095
                        }
 
2096
                        for (i = num ; i < MAX_TEXT_ENTRY; i++) {
 
2097
                                gtk_entry_set_text(GTK_ENTRY(cme->descriptions[i]), "");
 
2098
                        }
 
2099
                }
 
2100
                DEBUG_MSG("cme_clist_select_lcb, finished\n");
 
2101
        } else {
 
2102
                gint i;
 
2103
                gtk_entry_set_text(GTK_ENTRY(cme->menupath), "");
 
2104
                {
 
2105
                        GtkTextIter itstart, itend;
 
2106
                        gtk_text_buffer_get_bounds(cme->befb,&itstart,&itend);
 
2107
                        gtk_text_buffer_delete(cme->befb,&itstart,&itend);
 
2108
                        gtk_text_buffer_get_bounds(cme->aftb,&itstart,&itend);
 
2109
                        gtk_text_buffer_delete(cme->aftb,&itstart,&itend);
 
2110
                }
 
2111
                gtk_spin_button_set_value(GTK_SPIN_BUTTON(cme->num), 0);
 
2112
                for (i = 0 ; i < MAX_TEXT_ENTRY; i++) {
 
2113
                        gtk_entry_set_text(GTK_ENTRY(cme->descriptions[i]), "");
 
2114
                }
 
2115
                cme->lastarray = NULL;
 
2116
                DEBUG_MSG("cme_clist_unselect_lcb, lastarray=%p\n", cme->lastarray);
 
2117
        }
 
2118
}
 
2119
 
1210
2120
static void cme_spin_changed_lcb(GtkWidget *widget, Tcmenu_editor *cme) {
1211
2121
        cme_create_entries(cme, gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(cme->num)));
1212
2122
}
1215
2125
        if (GTK_TOGGLE_BUTTON(cme->type[1])->active) {
1216
2126
                DEBUG_MSG("cme_clist_select_lcb, type[1] is active\n");
1217
2127
                gtk_widget_show(cme->csnr_box);
1218
 
                gtk_label_set_text(GTK_LABEL(cme->label1), _("Search pattern"));
1219
 
                gtk_label_set_text(GTK_LABEL(cme->label2), _("Replace string"));
 
2128
                gtk_label_set_text(GTK_LABEL(cme->label1), _("Search Pattern"));
 
2129
                gtk_label_set_text(GTK_LABEL(cme->label2), _("Replace String"));
1220
2130
        } else {
1221
2131
                gtk_widget_hide(cme->csnr_box);
1222
 
                gtk_label_set_text(GTK_LABEL(cme->label1), _("Formatstring before"));
1223
 
                gtk_label_set_text(GTK_LABEL(cme->label2), _("Formatstring after"));
1224
 
        }
1225
 
}
1226
 
 
1227
 
static void cme_clist_select_lcb(GtkWidget * widget, gint row, gint column, GdkEventButton * event, Tcmenu_editor *cme) {
1228
 
        gint num=0, pos=0, i;
1229
 
        gint type=0;
1230
 
 
1231
 
        DEBUG_MSG("cme_clist_select_lcb, row=%d\n", row);
1232
 
        cme->lastarray = g_list_nth_data(cme->worklist, row);
1233
 
        DEBUG_MSG("cme_clist_select_lcb, lastarray=%p\n", cme->lastarray);
1234
 
 
1235
 
        i = count_array(cme->lastarray);
1236
 
        if (i<5) {
1237
 
                DEBUG_MSG("cme_clist_select_lcb, invalid array count! (1)\n");
1238
 
                cme->lastarray = NULL;
1239
 
                return;
1240
 
        }
1241
 
        if (strcmp(cme->lastarray[1], "0")==0) {
1242
 
                type = 0;
1243
 
                DEBUG_MSG("cme_clist_select_lcb, type=%d\n", type);
1244
 
        }
1245
 
        if (strcmp(cme->lastarray[1], "1")==0) {
1246
 
                type = 1;
1247
 
                if (i < 8) {
1248
 
                        DEBUG_MSG("cme_clist_select_lcb, invalid array count (2)!\n");
1249
 
                        cme->lastarray = NULL;
1250
 
                        return;
1251
 
                }
1252
 
                DEBUG_MSG("cme_clist_select_lcb, type=%d\n", type);
1253
 
        }
1254
 
        if (type > 1) {
1255
 
                DEBUG_MSG("cme_clist_select_lcb, invalid type! (type=%d)\n", type);
1256
 
                cme->lastarray = NULL;
1257
 
                return;
1258
 
        }
1259
 
 
1260
 
        DEBUG_MSG("cme_clist_select_lcb, cme->lastarray[0]=%s, [i]='%s'\n", cme->lastarray[0], cme->lastarray[1]);
1261
 
        gtk_entry_set_text(GTK_ENTRY(cme->menupath), cme->lastarray[0]);
1262
 
        
1263
 
        gtk_editable_delete_text(GTK_EDITABLE(cme->before), 0, -1);
1264
 
        DEBUG_MSG("cme_clist_select_lcb, cme->lastarray[2]='%s'\n", cme->lastarray[2]);
1265
 
        gtk_editable_insert_text(GTK_EDITABLE(cme->before), cme->lastarray[2], strlen(cme->lastarray[2]), &pos);
1266
 
        gtk_editable_delete_text(GTK_EDITABLE(cme->after), 0, -1);
1267
 
        DEBUG_MSG("cme_clist_select_lcb, cme->lastarray[3]='%s'\n", cme->lastarray[3]);
1268
 
        pos = 0;
1269
 
        gtk_editable_insert_text(GTK_EDITABLE(cme->after), cme->lastarray[3], strlen(cme->lastarray[3]), &pos);
1270
 
        DEBUG_MSG("cme_clist_select_lcb, type=%d\n", type);
1271
 
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cme->type[type]), TRUE);
1272
 
        if (type == 0) {
1273
 
                DEBUG_MSG("cme_clist_select_lcb, type=0, custom dialog\n");
1274
 
                gtk_widget_hide(cme->csnr_box);
1275
 
                
1276
 
                num = atoi(cme->lastarray[4]);
1277
 
                DEBUG_MSG("cme_clist_select_lcb, num=%d\n", num);
1278
 
                gtk_spin_button_set_value(GTK_SPIN_BUTTON(cme->num), num);
1279
 
        
1280
 
                cme_create_entries(cme, num);
1281
 
                DEBUG_MSG("cme_clist_select_lcb, %d entries created\n", num);
1282
 
                for (i = 0 ; i < num; i++) {
1283
 
                        gtk_entry_set_text(GTK_ENTRY(cme->descriptions[i]), cme->lastarray[i+5]);
1284
 
                }
1285
 
                for (i = num ; i < MAX_TEXT_ENTRY; i++) {
1286
 
                        gtk_entry_set_text(GTK_ENTRY(cme->descriptions[i]), "");
1287
 
                }
1288
 
        }
1289
 
        if (type == 1) {
1290
 
                static Tconvert_table table1[] = {{0, "0"}, {1, "1"}, NULL};
1291
 
                static Tconvert_table table2[] = {{0, "current document"}, {1, "from cursor"}, {2, "in selection"}, {3, "in all open documents"}, NULL};
1292
 
                gint regioni;
1293
 
                gchar *regionc;
1294
 
                DEBUG_MSG("cme_clist_select_lcb, type=1, custom search and replace\n");
1295
 
                gtk_widget_show(cme->csnr_box);
1296
 
                DEBUG_MSG("cme_clist_select_lcb, cme->lastarray[5]=%s\n", cme->lastarray[5]);
1297
 
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cme->is_regex), table_convert_char2int(table1, cme->lastarray[5]));
1298
 
                DEBUG_MSG("cme_clist_select_lcb, cme->lastarray[6]=%s\n", cme->lastarray[6]);
1299
 
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cme->is_case_sens), table_convert_char2int(table1, cme->lastarray[6]));
1300
 
                
1301
 
                gtk_editable_delete_text(GTK_EDITABLE(GTK_COMBO(cme->region)->entry), 0, -1);
1302
 
                regioni = atoi(cme->lastarray[4]);
1303
 
                regionc = table_convert_int2char(table2, regioni);
1304
 
                if (regionc) {
1305
 
                        gtk_editable_insert_text(GTK_EDITABLE(GTK_COMBO(cme->region)->entry), regionc, strlen(regionc), &pos);
1306
 
                }
1307
 
 
1308
 
                num = atoi(cme->lastarray[7]);
1309
 
                gtk_spin_button_set_value(GTK_SPIN_BUTTON(cme->num), num);
1310
 
        
1311
 
                cme_create_entries(cme, num);
1312
 
                for (i = 0 ; i < num; i++) {
1313
 
                        gtk_entry_set_text(GTK_ENTRY(cme->descriptions[i]), cme->lastarray[i+8]);
1314
 
                }
1315
 
                for (i = num ; i < MAX_TEXT_ENTRY; i++) {
1316
 
                        gtk_entry_set_text(GTK_ENTRY(cme->descriptions[i]), "");
1317
 
                }
1318
 
        }
1319
 
        DEBUG_MSG("cme_clist_select_lcb, finished\n");
1320
 
}
1321
 
 
1322
 
static gchar **cme_create_array(Tcmenu_editor *cme) {
 
2132
                gtk_label_set_text(GTK_LABEL(cme->label1), _("Formatstring Before"));
 
2133
                gtk_label_set_text(GTK_LABEL(cme->label2), _("Formatstring After"));
 
2134
        }
 
2135
}
 
2136
 
 
2137
static gchar **cme_create_array(Tcmenu_editor *cme, gboolean is_update) {
1323
2138
        gchar **newarray;
1324
2139
        gint num, i, type;
1325
2140
        
1332
2147
                type = 0;
1333
2148
        }
1334
2149
        if (type == 0) {
1335
 
                newarray = g_malloc0((num+6) * sizeof(char *));
 
2150
                newarray = g_malloc0((num+5) * sizeof(char *));
1336
2151
        } else {
1337
 
                newarray = g_malloc0((num+9) * sizeof(char *));
 
2152
                newarray = g_malloc0((num+8) * sizeof(char *));
1338
2153
        }
 
2154
        DEBUG_MSG("cme_create_array, newarray at %p\n",newarray);
1339
2155
        newarray[0] = gtk_editable_get_chars(GTK_EDITABLE(cme->menupath), 0, -1);
1340
 
        if (newarray[0][0] != '/') {
1341
 
                DEBUG_MSG("cme_create_array, menupath does not start with slash, returning NULL\n");
1342
 
                g_free(newarray[0]);
1343
 
                g_free(newarray);
1344
 
                return (NULL);
 
2156
        {
 
2157
                gboolean invalid=is_update;
 
2158
                GList *tmplist = g_list_first(cme->worklist_insert);
 
2159
                while (tmplist) {
 
2160
                        gchar **tmparr = (gchar **)tmplist->data;
 
2161
                        if (strcmp(tmparr[0],newarray[0])==0) {
 
2162
                                /* if it is an update they path should exist already, else is should not */
 
2163
                                invalid = (!is_update);
 
2164
                                break;
 
2165
                        }
 
2166
                        tmplist = g_list_next(tmplist);
 
2167
                }
 
2168
                tmplist = g_list_first(cme->worklist_replace);
 
2169
                while (tmplist) {
 
2170
                        gchar **tmparr = (gchar **)tmplist->data;
 
2171
                        if (strcmp(tmparr[0],newarray[0])==0) {
 
2172
                                /* if it is an update they path should exist already, else is should not */
 
2173
                                invalid = (!is_update);
 
2174
                                break;
 
2175
                        }
 
2176
                        tmplist = g_list_next(tmplist);
 
2177
                }
 
2178
                if (invalid) {
 
2179
                        if (is_update) {
 
2180
                                warning_dialog(cme->bfwin->main_window,_("The menupath you want to update does not exist yet"), _("Try 'add' instead."));
 
2181
                        } else {
 
2182
                                warning_dialog(cme->bfwin->main_window,_("The menupath you want to add already exists."), NULL);
 
2183
                        }
 
2184
                }
 
2185
                if (newarray[0][0] != '/') {
 
2186
                        DEBUG_MSG("cme_create_array, menupath does not start with slash, returning NULL\n");
 
2187
                        warning_dialog(cme->bfwin->main_window,_("The menupath should start with a / character"), NULL);
 
2188
                        invalid = TRUE;
 
2189
                }
 
2190
                if (invalid) {
 
2191
                        g_free(newarray[0]);
 
2192
                        g_free(newarray);
 
2193
                        return (NULL);
 
2194
                }
1345
2195
        }
1346
 
        
1347
2196
        if (type == 0) {
1348
 
                newarray[1] = g_strdup("0");
1349
 
 
1350
 
                newarray[4] = gtk_editable_get_chars(GTK_EDITABLE(cme->num), 0, -1);
1351
 
                DEBUG_MSG("cme_create_array, newarray[4]=%s\n", newarray[4]);
 
2197
                newarray[3] = gtk_editable_get_chars(GTK_EDITABLE(cme->num), 0, -1);
1352
2198
                for (i = 0 ; i < num; i++) {
1353
 
                        DEBUG_MSG("cme_create_array, adding descriptions[%d] to newarray[%d]\n", i, i+5);
1354
 
                        newarray[5+i] = gtk_editable_get_chars(GTK_EDITABLE(cme->descriptions[i]), 0, -1);
 
2199
                        DEBUG_MSG("cme_create_array, adding descriptions[%d] to newarray[%d]\n", i, i+4);
 
2200
                        newarray[4+i] = gtk_editable_get_chars(GTK_EDITABLE(cme->descriptions[i]), 0, -1);
1355
2201
                }
1356
 
                DEBUG_MSG("cme_create_array, setting newarray[%d] to NULL\n",i+5);
1357
 
                newarray[5+i] = NULL;
 
2202
                DEBUG_MSG("cme_create_array, setting newarray[%d] to NULL\n",i+4);
 
2203
                newarray[4+i] = NULL;
1358
2204
        } else {
1359
 
                static Tconvert_table table2[] = {{0, "current document"}, {1, "from cursor"}, {2, "in selection"}, {3, "in all open documents"}, NULL};
1360
 
                gint regioni;
1361
 
                gchar *regionc;
1362
 
                newarray[1] = g_strdup("1");
1363
 
                regionc = gtk_editable_get_chars(GTK_EDITABLE(GTK_COMBO(cme->region)->entry), 0, -1);
1364
 
                regioni = table_convert_char2int(table2, regionc);
1365
 
                g_free(regionc);
1366
 
                newarray[4] = g_strdup_printf("%d", regioni);
1367
 
                newarray[5] = g_strdup_printf("%d", GTK_TOGGLE_BUTTON(cme->is_regex)->active);
1368
 
                newarray[6] = g_strdup_printf("%d", GTK_TOGGLE_BUTTON(cme->is_case_sens)->active);
 
2205
/*              static Tconvert_table table2[] = {{0, N_("in current document")}, {1, N_("from cursor")}, {2, N_("in selection")}, {3, N_("in all open documents")}, {0,NULL}};
 
2206
                static Tconvert_table table3[] = {{0, N_("normal")}, {1, N_("posix regular expressions")}, {2, N_("perl regular expressions")}, {0, NULL}};*/
 
2207
                gint converti;
 
2208
/*              gchar *convertc;
 
2209
                convertc = gtk_editable_get_chars(GTK_EDITABLE(GTK_COMBO(cme->region)->entry), 0, -1);
 
2210
                converti = table_convert_char2int(table2, convertc, tcc2i_full_match_gettext);
 
2211
                g_free(convertc);*/
 
2212
                converti = gtk_option_menu_get_history(GTK_OPTION_MENU(cme->region));
 
2213
                newarray[3] = g_strdup_printf("%d", converti);
 
2214
 
 
2215
                /*convertc = gtk_editable_get_chars(GTK_EDITABLE(GTK_COMBO(cme->matching)->entry), 0, -1);
 
2216
                g_free(convertc);*/
 
2217
                converti = gtk_option_menu_get_history(GTK_OPTION_MENU(cme->matching));
 
2218
                newarray[4] = g_strdup_printf("%d", converti);
 
2219
                
 
2220
                newarray[5] = g_strdup_printf("%d", GTK_TOGGLE_BUTTON(cme->is_case_sens)->active);
1369
2221
        
1370
 
                newarray[7] = gtk_editable_get_chars(GTK_EDITABLE(cme->num), 0, -1);
1371
 
                DEBUG_MSG("cme_create_array, newarray[7]=%s\n", newarray[7]);
 
2222
                newarray[6] = gtk_editable_get_chars(GTK_EDITABLE(cme->num), 0, -1);
 
2223
                DEBUG_MSG("cme_create_array, newarray[6]=%s\n", newarray[6]);
1372
2224
                for (i = 0 ; i < num; i++) {
1373
 
                        DEBUG_MSG("cme_create_array, adding descriptions[%d] to newarray[%d]\n", i, i+8);
1374
 
                        newarray[8+i] = gtk_editable_get_chars(GTK_EDITABLE(cme->descriptions[i]), 0, -1);
 
2225
                        DEBUG_MSG("cme_create_array, adding descriptions[%d] to newarray[%d]\n", i, i+7);
 
2226
                        newarray[7+i] = gtk_editable_get_chars(GTK_EDITABLE(cme->descriptions[i]), 0, -1);
1375
2227
                }
1376
 
                DEBUG_MSG("cme_create_array, setting newarray[%d] to NULL\n",i+8);
1377
 
                newarray[8+i] = NULL;
1378
 
        }
1379
 
        newarray[2] = gtk_editable_get_chars(GTK_EDITABLE(cme->before), 0, -1);
1380
 
        newarray[3] = gtk_editable_get_chars(GTK_EDITABLE(cme->after), 0, -1);
1381
 
        
 
2228
                DEBUG_MSG("cme_create_array, setting newarray[%d] to NULL\n",i+7);
 
2229
                newarray[7+i] = NULL;
 
2230
        }
 
2231
        {
 
2232
                GtkTextIter itstart, itend;
 
2233
                gtk_text_buffer_get_bounds(cme->befb,&itstart,&itend);
 
2234
                newarray[1] = gtk_text_buffer_get_text(cme->befb,&itstart,&itend, FALSE);
 
2235
                gtk_text_buffer_get_bounds(cme->aftb,&itstart,&itend);
 
2236
                newarray[2] = gtk_text_buffer_get_text(cme->aftb,&itstart,&itend, FALSE);
 
2237
        }
 
2238
 
1382
2239
        return newarray;
1383
2240
}
1384
2241
 
1385
2242
static void cme_add_lcb(GtkWidget *widget, Tcmenu_editor *cme) {
1386
2243
        gchar **newarray;
1387
 
        gchar *tmplistentry[1]; 
1388
 
        gint row;
1389
 
 
1390
 
        newarray = cme_create_array(cme);
 
2244
        newarray = cme_create_array(cme, FALSE);
1391
2245
        if (newarray != NULL){
1392
 
             cme->worklist = g_list_append(cme->worklist, newarray);
1393
 
             tmplistentry[0] = newarray[0];
1394
 
             row = gtk_clist_append(GTK_CLIST(cme->clist), tmplistentry);
1395
 
                  cme->lastarray = newarray;
1396
 
                  DEBUG_MSG("cme_add_lcb, about to select row %d\n", row);
1397
 
                  gtk_clist_select_row(GTK_CLIST(cme->clist), row, 0);
 
2246
                GtkTreeIter iter;
 
2247
                GtkTreeSelection *gtsel;
 
2248
                gint type = GTK_TOGGLE_BUTTON(cme->type[1])->active;
 
2249
                DEBUG_MSG("cme_add_lcb, adding %p with type %d\n",newarray,type);
 
2250
                if (type == 0) {
 
2251
                        cme->worklist_insert = g_list_append(cme->worklist_insert, newarray);
 
2252
                } else {
 
2253
                        cme->worklist_replace = g_list_append(cme->worklist_replace, newarray);
 
2254
                }
 
2255
                gtk_list_store_append(GTK_LIST_STORE(cme->lstore),&iter);
 
2256
                gtk_list_store_set(GTK_LIST_STORE(cme->lstore),&iter,0,newarray[0],1,type,2,newarray,-1);
 
2257
                cme->lastarray = newarray;
 
2258
                gtsel = gtk_tree_view_get_selection(GTK_TREE_VIEW(cme->lview));
 
2259
                gtk_tree_selection_select_iter(gtsel,&iter);
1398
2260
        }
1399
2261
}
1400
2262
 
1401
2263
static void cme_update_lcb(GtkWidget *widget, Tcmenu_editor *cme) {
1402
 
        GList *tmplist;
1403
2264
        gchar **newarray;
1404
 
        gint row;
1405
 
 
1406
2265
        if (cme->lastarray == NULL) {
1407
2266
                cme_add_lcb(NULL, cme);
1408
2267
                return;
1409
2268
        }
1410
 
 
1411
 
        newarray = cme_create_array(cme);
 
2269
        newarray = cme_create_array(cme, TRUE);
1412
2270
        if (newarray) {
1413
 
 
1414
 
                row = g_list_index(cme->worklist, cme->lastarray);
1415
 
                tmplist = g_list_nth(cme->worklist, row);
 
2271
                GtkTreeIter iter;
 
2272
                if (cme_iter_at_pointer(&iter, cme->lastarray, cme)) {
 
2273
                        gint newtype, oldtype;
 
2274
                        gtk_tree_model_get(GTK_TREE_MODEL(cme->lstore),&iter,1,&oldtype,-1);
 
2275
                        newtype = GTK_TOGGLE_BUTTON(cme->type[1])->active;
 
2276
                        gtk_list_store_set(GTK_LIST_STORE(cme->lstore),&iter,0,newarray[0],1,newtype,2,newarray,-1);
 
2277
                        if (oldtype == 0) {
 
2278
                                if (newtype == 1) {
 
2279
                                        cme->worklist_insert = g_list_remove(cme->worklist_insert, cme->lastarray);
 
2280
                                        cme->worklist_replace = g_list_append(cme->worklist_replace, newarray);
 
2281
                                } else {
 
2282
                                        GList *tmplist = g_list_find(cme->worklist_insert,cme->lastarray);
 
2283
                                        tmplist->data = newarray;
 
2284
                                }
 
2285
                        } else if (oldtype == 1) {
 
2286
                                if (newtype == 0) {
 
2287
                                        cme->worklist_replace = g_list_remove(cme->worklist_replace, cme->lastarray);
 
2288
                                        cme->worklist_insert = g_list_append(cme->worklist_insert, newarray);
 
2289
                                } else {
 
2290
                                        GList *tmplist = g_list_find(cme->worklist_replace,cme->lastarray);
 
2291
                                        tmplist->data = newarray;
 
2292
                                }
 
2293
                        }
 
2294
                } else {
 
2295
                        DEBUG_MSG("cme_update_lcb, cannot find iter for pointer %p\n",cme->lastarray);
 
2296
                }
1416
2297
                g_strfreev(cme->lastarray);
1417
 
                DEBUG_MSG ("cme_update_lcb, row=%d\n", row);
1418
 
 
1419
 
                tmplist->data = newarray;
1420
 
                gtk_clist_set_text(GTK_CLIST(cme->clist), row, 0, newarray[0]);
1421
 
 
1422
 
                cme->lastarray = g_list_nth_data(cme->worklist, row);
 
2298
                cme->lastarray = newarray;
1423
2299
        } else {
1424
2300
                DEBUG_MSG ("cme_update_lcb, no new array, cancelled\n");
1425
2301
        }
1427
2303
}
1428
2304
 
1429
2305
static void cme_delete_lcb(GtkWidget *widget, Tcmenu_editor *cme) {
1430
 
        gint row;
1431
 
        gchar **array;
1432
 
        
1433
2306
        if (cme->lastarray) {
1434
 
                array = cme->lastarray;
1435
 
                DEBUG_MSG("cme_delete_lcb, delete lastarray %p\n", array);
1436
 
                row = g_list_index(cme->worklist, array);
1437
 
                DEBUG_MSG("cme_delete_lcb, g_list_length=%d\n", g_list_length(cme->worklist));
1438
 
                cme->worklist = g_list_remove(cme->worklist, array);
1439
 
                DEBUG_MSG("cme_delete_lcb, row=%d, g_list_length=%d\n", row, g_list_length(cme->worklist));
1440
 
                gtk_clist_remove(GTK_CLIST(cme->clist), row);
1441
 
                g_strfreev(array);
 
2307
                GtkTreeIter iter;
 
2308
                if (cme_iter_at_pointer(&iter, cme->lastarray, cme)) {
 
2309
                        gint type;
 
2310
                        DEBUG_MSG("cme_delete_lcb, removing from listmodel\n");
 
2311
                        gtk_tree_model_get(GTK_TREE_MODEL(cme->lstore),&iter,1,&type,-1);
 
2312
                        if (type == 0) {
 
2313
                                cme->worklist_insert = g_list_remove(cme->worklist_insert, cme->lastarray);
 
2314
                        } else if (type == 1) {
 
2315
                                cme->worklist_replace = g_list_remove(cme->worklist_replace, cme->lastarray);
 
2316
                        } else {
 
2317
                                DEBUG_MSG("NOT removed from lists, type=%d ???\n",type);
 
2318
                        }
 
2319
                        if (type == 1 || type == 0) {
 
2320
                                g_strfreev(cme->lastarray);
 
2321
                        }
 
2322
                        /* removing the iter will call cme_clist_unselect_lcb which will set the lastarray to NULL
 
2323
                        therefore we will do this as last action */
 
2324
                        gtk_list_store_remove(GTK_LIST_STORE(cme->lstore),&iter);
 
2325
                } else {
 
2326
                        DEBUG_MSG("NOT REMOVED, no iter can be found for pointer %p?!?\n",cme->lastarray);
 
2327
                }
 
2328
                DEBUG_MSG("cme_delete_lcb, setting lastarray NULL\n");
1442
2329
                cme->lastarray = NULL;
1443
2330
        } else {
1444
2331
                DEBUG_MSG("cme_delete_lcb, lastarray=NULL, nothing to delete\n");
1449
2336
        return strcmp(a[0],b[0]);
1450
2337
}
1451
2338
 
1452
 
void cmenu_editor(GtkWidget *widget, gpointer data) {
 
2339
void cmenu_editor(Tbfwin *bfwin,guint callback_action,GtkWidget *widget) {
1453
2340
        Tcmenu_editor *cme;
1454
 
        GtkWidget *hbox, *vbox,*frame, *vbox2, *but, *scrolwin, *hbox2;
1455
 
        GList *tmplist, *popuplist;
1456
 
        gchar *tmplistentry[1];
1457
 
        gchar **splittedstring;
 
2341
        GtkWidget *hbox, *vbox, *frame, *vbox2, *vbox3, *hbox2, *label, *toolbar;
 
2342
        GList *tmplist;
1458
2343
        gint i;
1459
2344
        gchar *tmpstr;
1460
2345
        
1461
2346
        cme = g_malloc0(sizeof(Tcmenu_editor));
1462
 
        cme->win = window_full(_("Bluefish config - custom menu"), GTK_WIN_POS_NONE
1463
 
                        , GTK_WINDOW_DIALOG, 5, cme_destroy_lcb, cme);
 
2347
        cme->bfwin = bfwin;
 
2348
        DEBUG_MSG("cmenu_editor, cme is at %p\n", cme);
 
2349
        cme->win = window_full2(_("Custom Menu Editor"), GTK_WIN_POS_CENTER, 
 
2350
                                                        0, G_CALLBACK(cme_destroy_lcb), cme, TRUE, bfwin->main_window);
1464
2351
 
1465
 
        vbox = gtk_vbox_new(FALSE, 2);
 
2352
        vbox = gtk_vbox_new(FALSE, 0);
1466
2353
        gtk_container_add(GTK_CONTAINER(cme->win), vbox);
 
2354
        
 
2355
        toolbar = gtk_toolbar_new();
 
2356
        gtk_toolbar_set_orientation(GTK_TOOLBAR(toolbar), GTK_ORIENTATION_HORIZONTAL);
 
2357
        gtk_toolbar_set_icon_size(GTK_TOOLBAR(toolbar), GTK_ICON_SIZE_SMALL_TOOLBAR);
 
2358
        gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
 
2359
        
 
2360
        gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_ADD, _("Add New Menu Entry"),
 
2361
                                                                NULL, G_CALLBACK(cme_add_lcb), cme, -1);
 
2362
        gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_APPLY, _("Apply Changes"),
 
2363
                                                                NULL, G_CALLBACK(cme_update_lcb), cme, -1);
 
2364
        gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_DELETE, _("Delete Menu Entry"),
 
2365
                                                                NULL, G_CALLBACK(cme_delete_lcb), cme, -1);
 
2366
        gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
 
2367
        gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_CLOSE, _("Close Discards Changes"),
 
2368
                                                                NULL, G_CALLBACK(cme_close_lcb), cme, -1);
 
2369
        gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_SAVE, _("Save Changes and Exit"),
 
2370
                                                                NULL, G_CALLBACK(cme_ok_lcb), cme, -1);
 
2371
        
 
2372
        vbox2 = gtk_vbox_new(FALSE, 12);
 
2373
        gtk_container_set_border_width(GTK_CONTAINER(vbox2), 6);
 
2374
        gtk_box_pack_start(GTK_BOX(vbox), vbox2, TRUE, TRUE, 0);                                                        
1467
2375
        /* upper area */
1468
 
        hbox = gtk_hbox_new(FALSE, 2);
1469
 
        gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
 
2376
        hbox = gtk_hbox_new(FALSE, 12);
 
2377
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, TRUE, 6);
1470
2378
 
1471
 
        gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new(_("Menu path")), FALSE, FALSE, 0);
 
2379
        label = gtk_label_new_with_mnemonic(_("_Menu Path:"));
 
2380
        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, TRUE, 0);
1472
2381
        cme->menupath = gtk_entry_new();
 
2382
        gtk_label_set_mnemonic_widget(GTK_LABEL(label), cme->menupath);
1473
2383
        gtk_box_pack_start(GTK_BOX(hbox),cme->menupath , TRUE, TRUE, 0);
1474
 
 
1475
 
        hbox = gtk_hbox_new(FALSE, 2);
1476
 
        gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
 
2384
        
 
2385
        hbox = gtk_hbox_new(FALSE, 12);
 
2386
        gtk_box_pack_start(GTK_BOX(vbox2), hbox, TRUE, TRUE, 6);
1477
2387
 
1478
2388
        /* clist & type area */
1479
 
        vbox2 = gtk_vbox_new(FALSE, 0); 
1480
 
        gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0);
1481
 
        scrolwin = gtk_scrolled_window_new(NULL, NULL);
1482
 
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolwin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1483
 
        cme->clist = gtk_clist_new(1);
1484
 
        gtk_signal_connect(GTK_OBJECT(cme->clist), "select_row", GTK_SIGNAL_FUNC(cme_clist_select_lcb), cme);
1485
 
        gtk_signal_connect(GTK_OBJECT(cme->clist), "unselect_row", GTK_SIGNAL_FUNC(cme_clist_unselect_lcb), cme);
1486
 
 
1487
 
        gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolwin), cme->clist);
1488
 
        gtk_widget_set_usize(scrolwin, 180, 250);
1489
 
        gtk_box_pack_start(GTK_BOX(vbox2), scrolwin, TRUE, TRUE, 0);
1490
 
 
1491
 
        cme->type[0] = gtk_radio_button_new_with_label(NULL, _("custom dialog"));
1492
 
        gtk_box_pack_start(GTK_BOX(vbox2), cme->type[0], TRUE, TRUE, 0);
1493
 
        cme->type[1] = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(cme->type[0]), _("custom search and replace"));
1494
 
        gtk_box_pack_start(GTK_BOX(vbox2), cme->type[1], TRUE, TRUE, 0);
1495
 
 
1496
 
        gtk_signal_connect(GTK_OBJECT(cme->type[0]), "toggled", cme_type_changed_lcb, cme);
 
2389
        vbox3 = gtk_vbox_new(FALSE, 12);        
 
2390
        gtk_box_pack_start(GTK_BOX(hbox), vbox3, TRUE, TRUE, 0);
 
2391
        {
 
2392
                GtkWidget *scrolwin;
 
2393
                GtkTreeViewColumn *column;
 
2394
                GtkTreeSelection *select;
 
2395
                GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
 
2396
 
 
2397
                cme->lstore = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_POINTER);
 
2398
                cme->lview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(cme->lstore));
 
2399
 
 
2400
                column = gtk_tree_view_column_new_with_attributes (_("Menu path"), renderer,"text", 0,NULL);
 
2401
                gtk_tree_view_append_column (GTK_TREE_VIEW(cme->lview), column);
 
2402
 
 
2403
                scrolwin = gtk_scrolled_window_new(NULL, NULL);
 
2404
                gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolwin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
 
2405
 
 
2406
                DEBUG_MSG("cmenu_editor, created lstore and lview\n");
 
2407
                gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolwin), cme->lview);
 
2408
                gtk_widget_set_size_request(scrolwin, 180, 250);
 
2409
                gtk_box_pack_start(GTK_BOX(vbox3), scrolwin, TRUE, TRUE, 0);
 
2410
                
 
2411
                select = gtk_tree_view_get_selection(GTK_TREE_VIEW(cme->lview));
 
2412
                g_signal_connect(G_OBJECT(select), "changed",G_CALLBACK(cme_lview_selection_changed),cme);
 
2413
        }
1497
2414
 
1498
2415
        /* dynamic entries area */
1499
 
        vbox2 = gtk_vbox_new(FALSE, 0); 
1500
 
        gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0);
 
2416
        vbox3 = gtk_vbox_new(FALSE, 0); 
 
2417
        gtk_box_pack_start(GTK_BOX(hbox), vbox3, TRUE, TRUE, 0);
1501
2418
 
1502
 
        gtk_box_pack_start(GTK_BOX(vbox2), gtk_label_new(_("Number of variables")), FALSE, FALSE, 0);           
 
2419
        hbox2 = gtk_hbox_new(FALSE, 12); 
 
2420
        label = gtk_label_new_with_mnemonic(_("Number of _Variables:"));
 
2421
        gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0);             
1503
2422
        cme->num = spinbut_with_value(NULL, 0, MAX_TEXT_ENTRY, 1,1);
1504
 
        gtk_signal_connect(GTK_OBJECT(cme->num), "changed", cme_spin_changed_lcb, cme);
1505
 
        gtk_box_pack_start(GTK_BOX(vbox2),cme->num , FALSE, FALSE, 0);
 
2423
        g_signal_connect(GTK_OBJECT(cme->num), "changed", G_CALLBACK(cme_spin_changed_lcb), cme);
 
2424
        gtk_label_set_mnemonic_widget(GTK_LABEL(label), cme->num);
 
2425
        gtk_box_pack_start(GTK_BOX(hbox2),cme->num , FALSE, FALSE, 0);
 
2426
        gtk_box_pack_start(GTK_BOX(vbox3), hbox2, FALSE, FALSE, 0);
1506
2427
        
1507
2428
        frame = gtk_frame_new(_("Variables"));
1508
 
        gtk_box_pack_end(GTK_BOX(vbox2), frame, TRUE, TRUE, 0);
1509
 
        cme->dynvbox = gtk_vbox_new(FALSE, 0);  
 
2429
        gtk_box_pack_end(GTK_BOX(vbox3), frame, TRUE, TRUE, 0);
 
2430
        cme->dynvbox = gtk_vbox_new(FALSE, 2);  
1510
2431
        gtk_container_add(GTK_CONTAINER(frame), cme->dynvbox);
1511
2432
        for (i = 0; i <  MAX_TEXT_ENTRY; i++) {
1512
2433
                cme->hboxes[i] = gtk_hbox_new(FALSE, 0);
1513
2434
                gtk_box_pack_start(GTK_BOX(cme->dynvbox), cme->hboxes[i], FALSE, FALSE, 0);
1514
 
                tmpstr = g_strdup_printf("%%%d", i);
 
2435
                tmpstr = g_strdup_printf("%%%d: ", i);
1515
2436
                gtk_box_pack_start(GTK_BOX(cme->hboxes[i]), gtk_label_new(tmpstr), FALSE, FALSE, 0);
1516
2437
                g_free(tmpstr);
1517
2438
                cme->descriptions[i] = gtk_entry_new();
1519
2440
        }
1520
2441
 
1521
2442
        /* lower area */
1522
 
        hbox = gtk_hbox_new(FALSE, 0);
1523
 
        gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
1524
 
 
1525
2443
        /* before and after text area */
1526
 
        vbox2 = gtk_vbox_new(FALSE, 0);
1527
 
        gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0);
 
2444
        vbox3 = gtk_vbox_new(FALSE, 6);
 
2445
        gtk_box_pack_start(GTK_BOX(hbox), vbox3, TRUE, TRUE, 0);
 
2446
        
 
2447
        cme->type[0] = gtk_radio_button_new_with_mnemonic(NULL, _("Custom Dialo_g"));
 
2448
        gtk_box_pack_start(GTK_BOX(vbox3), cme->type[0], FALSE, TRUE, 0);
 
2449
        cme->type[1] = gtk_radio_button_new_with_mnemonic_from_widget(GTK_RADIO_BUTTON(cme->type[0]), _("Custom Replace"));
 
2450
        gtk_box_pack_start(GTK_BOX(vbox3), cme->type[1], FALSE, TRUE, 0);
 
2451
 
 
2452
        g_signal_connect(GTK_OBJECT(cme->type[0]), "toggled", G_CALLBACK(cme_type_changed_lcb), cme);
1528
2453
        
1529
2454
        /* csnr area */
1530
 
        cme->csnr_box = gtk_vbox_new(FALSE, 0);
1531
 
        gtk_box_pack_start(GTK_BOX(vbox2), cme->csnr_box, TRUE, TRUE, 0);
1532
 
 
1533
 
        hbox2 = gtk_hbox_new(FALSE, 0);
1534
 
        gtk_box_pack_start(GTK_BOX(cme->csnr_box), hbox2, TRUE, TRUE, 0);
1535
 
        
1536
 
        gtk_box_pack_start(GTK_BOX(hbox2),gtk_label_new(_("Replace where")), FALSE, FALSE, 0);
1537
 
        popuplist = g_list_append(NULL, "current document");
1538
 
        popuplist = g_list_append(popuplist, "from cursor");
1539
 
        popuplist = g_list_append(popuplist, "in selection");
1540
 
        popuplist = g_list_append(popuplist, "in all open documents");
1541
 
        cme->region = combo_with_popdown(NULL, popuplist, 0);
1542
 
        g_list_free(popuplist);
1543
 
        gtk_box_pack_start(GTK_BOX(hbox2),cme->region , TRUE, TRUE, 0);
1544
 
 
1545
 
        hbox2 = gtk_hbox_new(FALSE, 0);
1546
 
        gtk_box_pack_start(GTK_BOX(cme->csnr_box), hbox2, TRUE, TRUE, 0);
1547
 
        cme->is_case_sens = boxed_checkbut_with_value(_("case sensitive"), 0, hbox2);
1548
 
        cme->is_regex = boxed_checkbut_with_value(_("regular expression"), 0, hbox2);
1549
 
        
1550
 
        cme->label1 = gtk_label_new("");
1551
 
        gtk_box_pack_start(GTK_BOX(vbox2), cme->label1, FALSE, FALSE, 0);
1552
 
        cme->before = gtk_text_new(NULL, NULL);
1553
 
        gtk_text_set_editable(GTK_TEXT(cme->before), TRUE);
1554
 
        gtk_widget_set_usize(cme->before, 280, 50);
1555
 
        gtk_box_pack_start(GTK_BOX(vbox2), cme->before, TRUE, TRUE, 0);
1556
 
        cme->label2 = gtk_label_new("");
1557
 
        gtk_box_pack_start(GTK_BOX(vbox2), cme->label2, FALSE, FALSE, 0);
1558
 
        cme->after = gtk_text_new(NULL, NULL);
1559
 
        gtk_text_set_editable(GTK_TEXT(cme->after), TRUE);
1560
 
        gtk_widget_set_usize(cme->after, 280, 50);
1561
 
        gtk_box_pack_start(GTK_BOX(vbox2), cme->after, TRUE, TRUE, 0);
1562
 
        
1563
 
        /* button area */
1564
 
        vbox2 = gtk_vbox_new(FALSE, 0); 
1565
 
        gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0);
1566
 
        but = bf_stock_button(_("Add"), cme_add_lcb, cme);
1567
 
        gtk_box_pack_start(GTK_BOX(vbox2), but, FALSE, FALSE, 5);
1568
 
        but = bf_stock_button(_("Update"), cme_update_lcb, cme);
1569
 
        gtk_box_pack_start(GTK_BOX(vbox2), but, FALSE, FALSE, 5);
1570
 
        but = bf_stock_button(_("Delete"), cme_delete_lcb, cme);
1571
 
        gtk_box_pack_start(GTK_BOX(vbox2), but, FALSE, FALSE, 5);
1572
 
 
1573
 
        /* frame for cancel/ok buttons */
1574
 
        frame = gtk_frame_new(NULL);
1575
 
        gtk_box_pack_end(GTK_BOX(vbox2), frame, FALSE, FALSE, 0);
1576
 
        hbox = gtk_hbox_new(TRUE, 1);
1577
 
        gtk_container_add(GTK_CONTAINER(frame), hbox);
1578
 
        but = bf_stock_ok_button(cme_ok_lcb, cme);
1579
 
        gtk_window_set_default(GTK_WINDOW(cme->win), but);
1580
 
        gtk_box_pack_start(GTK_BOX(hbox), but, TRUE, TRUE, 0);
1581
 
        
1582
 
        but = bf_stock_cancel_button(cme_close_lcb, cme);
1583
 
        gtk_box_pack_start(GTK_BOX(hbox), but, TRUE, TRUE, 0);
 
2455
        cme->csnr_box = gtk_vbox_new(FALSE, 6);
 
2456
        gtk_box_pack_start(GTK_BOX(vbox3), cme->csnr_box, FALSE, TRUE, 12);
 
2457
 
 
2458
        hbox2 = gtk_hbox_new(FALSE, 12);
 
2459
        gtk_box_pack_start(GTK_BOX(cme->csnr_box), hbox2, FALSE, TRUE, 0);
 
2460
        
 
2461
        label = gtk_label_new_with_mnemonic(_("_Replace:"));
 
2462
        gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0);
 
2463
        {
 
2464
                gchar *whereoptions[] = {N_("in current document"),N_("from cursor"),N_("in selection"),N_("in all open documents"), NULL};
 
2465
                cme->region = optionmenu_with_value(whereoptions, 0);
 
2466
        }
 
2467
        gtk_box_pack_start(GTK_BOX(hbox2),cme->region , TRUE, TRUE, 3);
 
2468
        gtk_label_set_mnemonic_widget(GTK_LABEL(label), cme->region);
 
2469
 
 
2470
        hbox2 = gtk_hbox_new(FALSE, 12);
 
2471
        gtk_box_pack_start(GTK_BOX(cme->csnr_box), hbox2, TRUE, TRUE, 0);
 
2472
        label = gtk_label_new_with_mnemonic(_("Matc_hing:"));
 
2473
        gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0);
 
2474
        {
 
2475
                gchar *matchactions[] = {N_("normal"), N_("posix regular expressions"), N_("perl regular expressions"), NULL};
 
2476
                cme->matching = optionmenu_with_value(matchactions, 0);
 
2477
        }
 
2478
        gtk_box_pack_start(GTK_BOX(hbox2),cme->matching , TRUE, TRUE, 3);
 
2479
        gtk_label_set_mnemonic_widget(GTK_LABEL(label), cme->matching);
 
2480
        
 
2481
        cme->is_case_sens = boxed_checkbut_with_value(_("Case Se_nsitive"), 0, cme->csnr_box);
 
2482
 
 
2483
        {
 
2484
                GtkWidget *scrolwin, *textview;
 
2485
                cme->label1 = gtk_label_new_with_mnemonic("");
 
2486
                gtk_box_pack_start(GTK_BOX(vbox3), cme->label1, FALSE, FALSE, 0);
 
2487
 
 
2488
                scrolwin = textview_buffer_in_scrolwin(&textview, -1, -1, NULL, GTK_WRAP_NONE);
 
2489
                cme->befb = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
 
2490
                gtk_box_pack_start(GTK_BOX(vbox3), scrolwin, TRUE, TRUE, 0);
 
2491
 
 
2492
                cme->label2 = gtk_label_new_with_mnemonic("");
 
2493
                gtk_box_pack_start(GTK_BOX(vbox3), cme->label2, FALSE, FALSE, 0);
 
2494
                
 
2495
                scrolwin = textview_buffer_in_scrolwin(&textview, -1, -1, NULL, GTK_WRAP_NONE);
 
2496
                cme->aftb = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
 
2497
                gtk_box_pack_start(GTK_BOX(vbox3), scrolwin, TRUE, TRUE, 0);
 
2498
        }
 
2499
        
1584
2500
        /* ready !! */
1585
 
        cme->worklist = duplicate_arraylist(main_v->props.cust_menu);
1586
 
        
1587
 
        tmplist = g_list_first(g_list_sort(cme->worklist, (GCompareFunc)menu_entry_sort));
1588
 
        while (tmplist) {
1589
 
                splittedstring = (gchar **) tmplist->data;
1590
 
                tmplistentry[0] = splittedstring[0];
1591
 
                gtk_clist_append(GTK_CLIST(cme->clist), tmplistentry);
1592
 
                tmplist = g_list_next(tmplist);
 
2501
        cme->worklist_insert = duplicate_arraylist(main_v->props.cmenu_insert);
 
2502
        cme->worklist_replace = duplicate_arraylist(main_v->props.cmenu_replace);
 
2503
        cme->worklist_insert = g_list_sort(cme->worklist_insert, (GCompareFunc)menu_entry_sort);
 
2504
        cme->worklist_replace = g_list_sort(cme->worklist_replace, (GCompareFunc)menu_entry_sort);
 
2505
        {
 
2506
                GtkTreeIter iter;
 
2507
                tmplist = g_list_first(cme->worklist_insert);
 
2508
                while (tmplist) {
 
2509
                        DEBUG_MSG("cmenu_editor, adding type 0 '%s'\n", *(gchar **)tmplist->data);
 
2510
                        gtk_list_store_append(GTK_LIST_STORE(cme->lstore), &iter);
 
2511
                        gtk_list_store_set(GTK_LIST_STORE(cme->lstore), &iter, 0, *(gchar **)tmplist->data, 1, 0, 2, tmplist->data, -1); /* the name , the type, the pointer */
 
2512
                        tmplist = g_list_next(tmplist);
 
2513
                }
 
2514
                tmplist = g_list_first(cme->worklist_replace);
 
2515
                while (tmplist) {
 
2516
                        DEBUG_MSG("cmenu_editor, adding type 1 '%s'\n", *(gchar **)tmplist->data);
 
2517
                        gtk_list_store_append(GTK_LIST_STORE(cme->lstore), &iter);
 
2518
                        gtk_list_store_set(GTK_LIST_STORE(cme->lstore), &iter, 0, *(gchar **)tmplist->data, 1, 1, 2, tmplist->data, -1); /* the name , the type, the pointer */
 
2519
                        tmplist = g_list_next(tmplist);
 
2520
                }
1593
2521
        }
1594
2522
        gtk_widget_show_all(cme->win);
1595
2523
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cme->type[0]), TRUE);
1597
2525
}
1598
2526
 
1599
2527
/*************************************************************************/
1600
 
 
1601
 
void make_cust_menubar(GtkWidget *cust_handle_box)
1602
 
{
1603
 
        static GtkItemFactoryEntry cust_menu[] = {
1604
 
                {N_("/_Custom menu"), NULL, NULL, 0, "<Branch>"},
1605
 
                {N_("/Custom menu/sep"), NULL, NULL, 0, "<Tearoff>"},
1606
 
                {N_("/Custom menu/Edit custom menu..."), NULL, cmenu_editor, 0, NULL},
1607
 
                {N_("/Custom menu/Reset custom menu"), NULL, reset_cust_menu_list_cb, 0, NULL}
1608
 
        };
1609
 
        GtkItemFactory *item_factory;
1610
 
        GtkAccelGroup *accel_group;
1611
 
        gint nmenu_items = sizeof(cust_menu) / sizeof(cust_menu[0]);
1612
 
 
1613
 
        DEBUG_MSG("make_cust_menubar, started\n");
1614
 
 
1615
 
        /* this should only happen once !!!!!!!!!! */
1616
 
        accel_group = gtk_accel_group_new();
1617
 
        item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group);
1618
 
#ifdef ENABLE_NLS
1619
 
        gtk_item_factory_set_translate_func(item_factory, menu_translate, "<main>", NULL);
1620
 
#endif
1621
 
        gtk_item_factory_create_items(item_factory, nmenu_items, cust_menu, NULL);
1622
 
        gtk_window_add_accel_group(GTK_WINDOW(main_v->main_window), accel_group);
1623
 
 
1624
 
        main_v->cmenu = gtk_item_factory_get_widget(item_factory, "<main>");
1625
 
        gtk_container_add(GTK_CONTAINER(cust_handle_box), main_v->cmenu);
1626
 
        gtk_widget_show(main_v->cmenu);
1627
 
 
1628
 
        fill_cust_menubar();
1629
 
 
1630
 
        DEBUG_MSG("make_cust_menubar, finished\n");
1631
 
}
1632
 
 
1633
 
/*******************************************************************/
1634
 
/*               Open Recent menu handling                         */
1635
 
/*******************************************************************/
1636
 
 
1637
 
/* the only required header */
1638
 
static GtkWidget *create_recent_entry(char *filename);
1639
 
/*******************************************************************/
1640
 
 
1641
 
/* save_recent_list
1642
 
 * Saves the items of main_v->recent_files to the .bluefish/recentlist file
1643
 
 * so that they can be restored in the next Bluefish session */
1644
 
/* this function is removed, append_to_file() is used instead */
1645
 
/*
1646
 
static void save_recent_list() {
1647
 
        gchar *recentfile;
1648
 
        GList *putlist=NULL, *list;
1649
 
 
1650
 
        DEBUG_MSG("save_recent_list, started\n");
1651
 
#ifndef WIN32
1652
 
        recentfile = g_strconcat(getenv("HOME"), "/.bluefish/recentlist", NULL);
1653
 
#else
1654
 
        recentfile = g_strconcat("C:\\", "recentlist", NULL);
1655
 
#endif
1656
 
        list = g_list_first(main_v->recent_files);      
1657
 
        while (list) {
1658
 
                putlist = add_to_stringlist(putlist, g_strdup(GTK_LABEL(GTK_BIN(list->data)->child)->label));
1659
 
                list = g_list_next(list);
1660
 
        }
1661
 
        
1662
 
        put_stringlist(recentfile, putlist);
1663
 
        free_stringlist(putlist);
1664
 
        g_free(recentfile);
1665
 
}
1666
 
*/
1667
 
 
1668
 
/* This function was nessecary I'm afraid, if you find a way
1669
 
 * that it is not needed for open_recent_file_cb, please
1670
 
 * send the patch. This also removes the last entry if
1671
 
 * filename == 'last' */
1672
 
static GtkWidget *remove_recent_entry(gchar *filename) {
1673
 
        GList *list;
1674
 
        gpointer tmp;
1675
 
 
1676
 
        if(strcmp(filename, "last") ==0) {
1677
 
                list = g_list_first(main_v->recent_files);
1678
 
                tmp = list->data;
1679
 
                DEBUG_MSG("remove_recent_entry, remove last entry\n");
1680
 
                main_v->recent_files = g_list_remove(main_v->recent_files, list->data);
1681
 
                return tmp;
1682
 
        }       else {
1683
 
                list = g_list_first(main_v->recent_files);
1684
 
                while (list) {
1685
 
                        DEBUG_MSG("remove_recent_entry, list=%p, data=%p\n", list, list->data);
1686
 
                        DEBUG_MSG("remove_recent_entry, list->data=%s\n",GTK_LABEL(GTK_BIN(list->data)->child)->label);
1687
 
                        if(!strcmp(GTK_LABEL(GTK_BIN(list->data)->child)->label, filename)) {
1688
 
                                tmp = list->data;
1689
 
                                main_v->recent_files = g_list_remove(main_v->recent_files, list->data);
1690
 
                                DEBUG_MSG("remove_recent_entry, returning %p\n", tmp);
1691
 
                                return tmp;
1692
 
                        }
1693
 
                        list = g_list_next(list);
1694
 
                }
1695
 
        }
1696
 
        return NULL;
1697
 
}
1698
 
 
1699
 
/* open_recent_file
1700
 
 * This function should be called when a menu from the Open Recent list
1701
 
 * has been selected. */
1702
 
 
1703
 
static void open_recent_file_cb(gchar *data) {
1704
 
        gchar *filename=data;
1705
 
 
1706
 
        DEBUG_MSG("open_recent_file_cb, started, filename is %s\n", filename);
1707
 
 
1708
 
        /* Now, let's check if that file still exists and is readable, before loading it */
1709
 
        if (!file_exists_and_readable(filename)) {
1710
 
                return;
1711
 
        }
1712
 
 
1713
 
        /* Open the file that was asked */
1714
 
        doc_new_with_file(filename);
1715
 
        DEBUG_MSG("open_recent_file_cb, document %s opened\n", filename);
1716
 
 
1717
 
/*
1718
 
        tmp = remove_recent_entry(filename);
1719
 
        gtk_widget_hide(tmp);
1720
 
 
1721
 
        main_v->recent_files = g_list_prepend(main_v->recent_files,
1722
 
                                                                create_recent_entry(GTK_LABEL(GTK_BIN(tmp)->child)->label, 0));
1723
 
        gtk_widget_destroy(tmp);*/
1724
 
 
1725
 
        /* save the new list */
1726
 
/*      save_recent_list();*/
1727
 
        add_to_recent_list(filename, 0);
1728
 
        return;
1729
 
}
1730
 
 
1731
 
/* create_recent_entry
1732
 
 * This function builds the gtkitemfactoryentry and inserts it at the
1733
 
 * main_v->menubar. Furthermore, it returns a pointer to it, so that
1734
 
 * this pointer can be added in the main_v->recent_files list */
1735
 
static GtkWidget *create_recent_entry(char *filename) {
1736
 
        GtkWidget *tmp, *menu;
1737
 
        GtkItemFactory *factory;
1738
 
 
1739
 
        tmp = remove_recent_entry(filename);
1740
 
        if (tmp) {
1741
 
                gtk_widget_hide(tmp);
1742
 
                gtk_widget_destroy(tmp);
1743
 
        }
1744
 
 
1745
 
        /* add it to main_v->menubar */
1746
 
        factory = gtk_item_factory_from_widget(main_v->menubar);
1747
 
        menu = gtk_item_factory_get_widget(factory, N_("<main>/File/Open recent"));
1748
 
 
1749
 
        tmp = gtk_menu_item_new_with_label(filename);
1750
 
        gtk_signal_connect_object(GTK_OBJECT(tmp), "activate",
1751
 
                                        GTK_SIGNAL_FUNC(open_recent_file_cb), (gpointer) GTK_LABEL(GTK_BIN(tmp)->child)->label);
1752
 
/*      gtk_signal_connect_object(GTK_OBJECT(tmp), "activate",
1753
 
                                        GTK_SIGNAL_FUNC(open_recent_file_cb), (gpointer) g_strdup("Hello World")); */
1754
 
 
1755
 
        gtk_widget_show(tmp);
1756
 
        gtk_menu_insert(GTK_MENU(menu), tmp, 1);
1757
 
 
1758
 
        flush_queue();
1759
 
 
1760
 
        /* return it */
1761
 
        return tmp;
1762
 
}
1763
 
 
1764
 
 
1765
 
/* open_recent_list()
1766
 
 * Gets the list of documents from .bluefish/recentlist and inserts
1767
 
 * it at the File-->Open Recent menu. If the file doesn't exist (probably
1768
 
 * because this is the first time Bluefish is running) then a menu
1769
 
 * item telling that no recent files exist will appear */
1770
 
 
1771
 
void open_recent_list() {
1772
 
        gchar *recentfile;
1773
 
        GList *filenames=NULL, *tmp, *tmp2, *newlist=NULL;
1774
 
        gint recent_file_count=0;
1775
 
 
1776
 
        DEBUG_MSG("open_recent_list, started\n");
1777
 
        recentfile = g_strconcat(getenv("HOME"), "/.bluefish/recentlist", NULL);
1778
 
        filenames = get_stringlist(recentfile, filenames);
1779
 
        if (!filenames) {
1780
 
                filenames = add_to_stringlist(main_v->recent_files, _("(none)"));
1781
 
        }
1782
 
 
1783
 
        tmp = g_list_last(filenames);
1784
 
        while (tmp && recent_file_count <= main_v->props.max_recent_files) {
1785
 
                gint already_found=0;
1786
 
                tmp2 = g_list_first(newlist);
1787
 
                while (tmp2) {
1788
 
                        if (strcmp(tmp->data, tmp2->data)==0) {
1789
 
                                already_found=1;
1790
 
                        }
1791
 
                        tmp2 = g_list_next(tmp2);
1792
 
                }
1793
 
                if (!already_found) {
1794
 
                        recent_file_count++;
1795
 
                        DEBUG_MSG("open_recent_list, added %s to top of list\n", (gchar *)tmp->data);
1796
 
                        newlist = g_list_prepend(newlist, tmp->data);
1797
 
                }
1798
 
                already_found = 0;
1799
 
                tmp = g_list_previous(tmp);
1800
 
        }
1801
 
 
1802
 
        tmp2 = g_list_first(newlist);
1803
 
        while (tmp2) {
1804
 
                main_v->recent_files  = g_list_append(main_v->recent_files, create_recent_entry(tmp2->data));
1805
 
                tmp2 = g_list_next(tmp2);
1806
 
        }
1807
 
 
1808
 
        put_stringlist(recentfile, newlist);
1809
 
        g_list_free(newlist);
1810
 
        free_stringlist(filenames);
1811
 
 
1812
 
        g_free(recentfile);
1813
 
}
1814
 
 
1815
 
/* Add_to_recent_list
1816
 
 * This should be called when a new file is opened, i.e. from
1817
 
 * file_open_cb, it adds a new entry which also appears in the
1818
 
 * menu bar, and (if nessecary) deletes the last entry */
1819
 
void add_to_recent_list(gchar *filename, gint closed_file) {
1820
 
        DEBUG_MSG("add_to_recent_list, started for %s\n", filename);
1821
 
        if (closed_file) {
1822
 
                GtkWidget *tmp;
1823
 
 
1824
 
                /* First of all, create the entry and insert it at the list*/
1825
 
                main_v->recent_files = g_list_append(main_v->recent_files,
1826
 
                                                                create_recent_entry(filename));
1827
 
 
1828
 
                DEBUG_MSG("add_to_recent_list, inserted item in menu\n");
1829
 
                if(g_list_length(main_v->recent_files) > main_v->props.max_recent_files) {
1830
 
                        tmp = remove_recent_entry("last");
1831
 
                        DEBUG_MSG("add_to_recent_list, list too long, entry %s to be deleted\n", GTK_LABEL(GTK_BIN(tmp)->child)->label);
1832
 
                        gtk_widget_hide(tmp);
1833
 
                        gtk_widget_destroy(tmp);
1834
 
                }
1835
 
                flush_queue();
1836
 
 
1837
 
        } else {
1838
 
                gchar *tmpfilename, *recentfile;
1839
 
                recentfile = g_strconcat(getenv("HOME"), "/.bluefish/recentlist", NULL);
1840
 
                /* save the new list */
1841
 
                tmpfilename = g_strconcat(filename, "\n", NULL);
1842
 
                DEBUG_MSG("add_to_recent_list, trying to append to %s\n", recentfile);
1843
 
                append_to_file(recentfile, tmpfilename);
1844
 
                g_free(recentfile);
1845
 
                g_free(tmpfilename);
1846
 
        }
1847
 
}
1848
 
 
1849
 
/*******************************************************************/
1850
 
/*           End of Open Recent menu handling                      */
1851
 
/*******************************************************************/
1852
 
 
1853
 
 
1854
 
#ifdef ENABLE_NLS
1855
 
 
1856
 
gchar *menu_translate(const gchar * path, gpointer data)
1857
 
{
1858
 
        static gchar *menupath = NULL;
1859
 
 
1860
 
        gchar *retval;
1861
 
        gchar *factory;
1862
 
 
1863
 
        factory = (gchar *) data;
1864
 
 
1865
 
        if (menupath)
1866
 
                g_free(menupath);
1867
 
 
1868
 
        menupath = g_strdup(path);
1869
 
 
1870
 
        if ((strstr(path, "/tearoff1") != NULL) || (strstr(path, "/---") != NULL) || (strstr(path, "/MRU") != NULL))
1871
 
                return menupath;
1872
 
 
1873
 
        retval = gettext(menupath);
1874
 
 
1875
 
        return retval;
1876
 
}
1877
 
 
1878
 
#endif                                                  /*  ENABLE_NLS  */