implemented folding

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@227 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2006-02-26 18:19:28 +00:00
parent 33aafb4899
commit 6409cf8926
13 changed files with 352 additions and 188 deletions

View File

@ -217,20 +217,24 @@ gint document_create_new_sci(const gchar *filename)
/* SCI - Code */
sci = SCINTILLA(scintilla_new());
scintilla_set_id(sci, new_idx);
// disable scintilla provided popup menu
#ifdef GEANY_WIN32
sci_set_codepage(sci, 0);
#else
sci_set_codepage(sci, SC_CP_UTF8);
#endif
//SSM(sci, SCI_SETWRAPSTARTINDENT, 4, 0);
// disable scintilla provided popup menu
sci_use_popup(sci, FALSE);
sci_set_codepage(sci, 1);
sci_assign_cmdkey(sci, SCK_HOME, SCI_VCHOMEWRAP);
sci_assign_cmdkey(sci, SCK_END, SCI_LINEENDWRAP);
sci_assign_cmdkey(sci, SCK_END, SCI_LINEENDWRAP);
sci_set_mark_long_lines(sci, app->long_line_column, app->long_line_color);
sci_set_symbol_margin(sci, app->show_markers_margin);
sci_set_folding_margin_visible(sci, app->pref_editor_folding);
sci_set_line_numbers(sci, app->show_linenumber_margin, 0);
sci_set_lines_wrapped(sci, app->pref_editor_line_breaking);
sci_set_indentionguides(sci, app->pref_editor_show_indent_guide);
sci_set_visible_white_spaces(sci, app->pref_editor_show_white_space);
sci_set_visible_eols(sci, app->pref_editor_show_line_endings);
//sci_set_folding_margin_visible(sci, TRUE);
pfd = pango_font_description_from_string(app->editor_font);
fname = g_strdup_printf("!%s", pango_font_description_get_family(pfd));
document_set_font(sci, fname, pango_font_description_get_size(pfd) / PANGO_SCALE);
@ -347,7 +351,7 @@ void document_new_file(filetype *ft)
sci_set_eol_mode(doc_list[idx].sci, SC_EOL_LF);
sci_set_line_numbers(doc_list[idx].sci, app->show_linenumber_margin, 0);
sci_empty_undo_buffer(doc_list[idx].sci);
sci_goto_pos(doc_list[idx].sci, 0);
sci_goto_pos(doc_list[idx].sci, 0, TRUE);
msgwin_status_add(_("New file opened."));
}
@ -496,13 +500,13 @@ void document_open_file(gint idx, const gchar *filename, gint pos, gboolean read
doc_list[idx].encoding = enc;
if (reload)
{
sci_goto_pos(doc_list[idx].sci, 0);
sci_goto_pos(doc_list[idx].sci, 0, FALSE);
msgwin_status_add(_("File %s reloaded."), utf8_filename);
}
else
{
filetype *use_ft = (ft != NULL) ? ft : filetypes_get_from_filename(utf8_filename);
sci_goto_pos(doc_list[idx].sci, pos);
sci_goto_pos(doc_list[idx].sci, pos, TRUE);
//if (app->main_window_realized) // avoids warnings, but doesn't scroll, so accept warning
sci_scroll_to_line(doc_list[idx].sci, sci_get_line_from_position(doc_list[idx].sci, pos) - 10);
doc_list[idx].readonly = readonly;
@ -634,7 +638,7 @@ void document_find_next(gint idx, const gchar *text, gint flags, gboolean find_b
selection_end = sci_get_selection_end(doc_list[idx].sci);
if (!inc && sci_can_copy(doc_list[idx].sci))
{ // there's a selection so go to the end
sci_goto_pos(doc_list[idx].sci, selection_end + 1);
sci_goto_pos(doc_list[idx].sci, selection_end + 1, TRUE);
}
sci_set_search_anchor(doc_list[idx].sci);
@ -649,14 +653,14 @@ void document_find_next(gint idx, const gchar *text, gint flags, gboolean find_b
{
if (dialogs_show_not_found(text))
{
sci_goto_pos(doc_list[idx].sci, 0);
sci_goto_pos(doc_list[idx].sci, 0, FALSE);
document_find_next(idx, text, flags, TRUE, inc);
}
}
else
{
utils_beep();
sci_goto_pos(doc_list[idx].sci, 0);
sci_goto_pos(doc_list[idx].sci, 0, FALSE);
}
}
}
@ -674,9 +678,9 @@ void document_find_text(gint idx, const gchar *text, gint flags, gboolean search
if ((selection_end - selection_start) > 0)
{ // there's a selection so go to the end
if (search_backwards)
sci_goto_pos(doc_list[idx].sci, selection_start - 1);
sci_goto_pos(doc_list[idx].sci, selection_start - 1, TRUE);
else
sci_goto_pos(doc_list[idx].sci, selection_end + 1);
sci_goto_pos(doc_list[idx].sci, selection_end + 1, TRUE);
}
sci_set_search_anchor(doc_list[idx].sci);
@ -693,7 +697,7 @@ void document_find_text(gint idx, const gchar *text, gint flags, gboolean search
{
if (dialogs_show_not_found(text))
{
sci_goto_pos(doc_list[idx].sci, (search_backwards) ? sci_get_length(doc_list[idx].sci) : 0);
sci_goto_pos(doc_list[idx].sci, (search_backwards) ? sci_get_length(doc_list[idx].sci) : 0, TRUE);
document_find_text(idx, text, flags, search_backwards);
}
}
@ -712,9 +716,9 @@ void document_replace_text(gint idx, const gchar *find_text, const gchar *replac
if ((selection_end - selection_start) > 0)
{ // there's a selection so go to the end
if (search_backwards)
sci_goto_pos(doc_list[idx].sci, selection_start - 1);
sci_goto_pos(doc_list[idx].sci, selection_start - 1, TRUE);
else
sci_goto_pos(doc_list[idx].sci, selection_end + 1);
sci_goto_pos(doc_list[idx].sci, selection_end + 1, TRUE);
}
sci_set_search_anchor(doc_list[idx].sci);
@ -755,9 +759,9 @@ void document_replace_sel(gint idx, const gchar *find_text, const gchar *replace
}
if (search_backwards)
sci_goto_pos(doc_list[idx].sci, selection_end);
sci_goto_pos(doc_list[idx].sci, selection_end, TRUE);
else
sci_goto_pos(doc_list[idx].sci, selection_start);
sci_goto_pos(doc_list[idx].sci, selection_start, TRUE);
sci_set_search_anchor(doc_list[idx].sci);
if (search_backwards)
@ -789,7 +793,7 @@ void document_replace_all(gint idx, const gchar *find_text, const gchar *replace
if (idx == -1 || ! find_text_len) return;
sci_goto_pos(doc_list[idx].sci, 0);
sci_goto_pos(doc_list[idx].sci, 0, FALSE);
sci_set_search_anchor(doc_list[idx].sci);
search_pos = sci_search_next(doc_list[idx].sci, flags, find_text);
@ -971,3 +975,40 @@ gchar *document_prepare_template(filetype *ft)
return templates_get_template_fileheader(GEANY_TEMPLATE_FILETYPE_NONE, NULL, -1);
}
}
void document_unfold_all(gint idx)
{
gint lines, pos, i;
if (idx == -1 || ! doc_list[idx].is_valid) return;
lines = sci_get_line_count(doc_list[idx].sci);
pos = sci_get_current_position(doc_list[idx].sci);
for (i = 0; i < lines; i++)
{
sci_ensure_line_is_visible(doc_list[idx].sci, i);
}
}
void document_fold_all(gint idx)
{
gint lines, pos, i;
if (idx == -1 || ! doc_list[idx].is_valid) return;
lines = sci_get_line_count(doc_list[idx].sci);
pos = sci_get_current_position(doc_list[idx].sci);
for (i = 0; i < lines; i++)
{
gint level = sci_get_fold_level(doc_list[idx].sci, i);
if (level & SC_FOLDLEVELHEADERFLAG)
{
if (sci_get_fold_expanded(doc_list[idx].sci, i))
sci_toggle_fold(doc_list[idx].sci, i);
}
}
}

View File

@ -109,4 +109,8 @@ gchar *document_get_eol_mode(gint);
gchar *document_prepare_template(filetype *ft);
void document_fold_all(gint idx);
void document_unfold_all(gint idx);
#endif

View File

@ -136,6 +136,7 @@ typedef struct MyApp
gboolean pref_editor_show_line_endings;
gboolean pref_editor_auto_close_xml_tags;
gboolean pref_editor_auto_complete_constructs;
gboolean pref_editor_folding;
gint pref_editor_tab_width;
gboolean pref_editor_new_line;
gboolean pref_editor_trail_space;
@ -143,6 +144,7 @@ typedef struct MyApp
gboolean pref_main_save_winpos;
gboolean pref_main_confirm_exit;
gboolean pref_main_show_search;
gboolean pref_main_show_goto;
gint mru_length;
gint long_line_column;
#ifdef HAVE_FIFO

View File

@ -151,6 +151,7 @@ void styleset_common(ScintillaObject *sci, gint style_bits)
// a darker grey for the line number margin
SSM(sci, SCI_STYLESETBACK, STYLE_LINENUMBER, 0xD0D0D0);
//SSM(sci, SCI_STYLESETBACK, STYLE_LINENUMBER, 0xD0D0D0);
// define marker symbols
// 0 -> line marker
@ -163,19 +164,46 @@ void styleset_common(ScintillaObject *sci, gint style_bits)
SSM(sci, SCI_MARKERSETFORE, 1, 0x000000);
SSM(sci, SCI_MARKERSETBACK, 1, 0xB8F4B8);
// 2 -> folding marker, other folding settings
SSM(sci, SCI_SETMARGINTYPEN, 2, SC_MARGIN_SYMBOL);
SSM(sci, SCI_SETMARGINMASKN, 2, SC_MASK_FOLDERS);
SSM(sci, SCI_SETFOLDFLAGS, 0, 0);
SSM (sci,SCI_MARKERDEFINE, SC_MARKNUM_FOLDEROPEN, SC_MARK_BOXMINUS);
SSM (sci,SCI_MARKERSETFORE, SC_MARKNUM_FOLDEROPEN, 0xffffff);
SSM (sci,SCI_MARKERSETBACK, SC_MARKNUM_FOLDEROPEN, 0x000000);
SSM (sci,SCI_MARKERDEFINE, SC_MARKNUM_FOLDER, SC_MARK_BOXPLUS);
SSM (sci,SCI_MARKERSETFORE, SC_MARKNUM_FOLDER, 0xffffff);
SSM (sci,SCI_MARKERSETBACK, SC_MARKNUM_FOLDER, 0x000000);
SSM (sci,SCI_MARKERDEFINE, SC_MARKNUM_FOLDERSUB, SC_MARK_VLINE);
SSM (sci,SCI_MARKERSETFORE, SC_MARKNUM_FOLDERSUB, 0xffffff);
SSM (sci,SCI_MARKERSETBACK, SC_MARKNUM_FOLDERSUB, 0x000000);
SSM (sci,SCI_MARKERDEFINE, SC_MARKNUM_FOLDERTAIL, SC_MARK_LCORNER);
SSM (sci,SCI_MARKERSETFORE, SC_MARKNUM_FOLDERTAIL, 0xffffff);
SSM (sci,SCI_MARKERSETBACK, SC_MARKNUM_FOLDERTAIL, 0x000000);
SSM (sci,SCI_MARKERDEFINE, SC_MARKNUM_FOLDEREND, SC_MARK_BOXPLUSCONNECTED);
SSM (sci,SCI_MARKERSETFORE, SC_MARKNUM_FOLDEREND, 0xffffff);
SSM (sci,SCI_MARKERSETBACK, SC_MARKNUM_FOLDEREND, 0x000000);
SSM (sci,SCI_MARKERDEFINE, SC_MARKNUM_FOLDEROPENMID, SC_MARK_BOXMINUSCONNECTED);
SSM (sci,SCI_MARKERSETFORE, SC_MARKNUM_FOLDEROPENMID, 0xffffff);
SSM (sci,SCI_MARKERSETBACK, SC_MARKNUM_FOLDEROPENMID, 0x000000);
SSM (sci,SCI_MARKERDEFINE, SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_TCORNER);
SSM (sci,SCI_MARKERSETFORE, SC_MARKNUM_FOLDERMIDTAIL, 0xffffff);
SSM (sci,SCI_MARKERSETBACK, SC_MARKNUM_FOLDERMIDTAIL, 0x000000);
SSM(sci, SCI_SETPROPERTY, (sptr_t) "fold", (sptr_t) "1");
SSM(sci, SCI_SETPROPERTY, (sptr_t) "fold.compact", (sptr_t) "1");
SSM(sci, SCI_SETPROPERTY, (sptr_t) "fold.comment", (sptr_t) "1");
SSM(sci, SCI_SETPROPERTY, (sptr_t) "fold.preprocessor", (sptr_t) "1");
SSM(sci, SCI_SETPROPERTY, (sptr_t) "fold.at.else", (sptr_t) "1");
SSM(sci, SCI_SETSELFORE, 1, types[GEANY_FILETYPES_ALL]->styling[1][0]);
SSM(sci, SCI_SETSELBACK, 1, types[GEANY_FILETYPES_ALL]->styling[1][1]);
SSM (sci, SCI_SETSTYLEBITS, style_bits, 0);
//SSM(sci, SCI_STYLESETFORE, STYLE_BRACELIGHT, types[GEANY_FILETYPES_ALL]->styling[2][0]);
//SSM(sci, SCI_STYLESETBACK, STYLE_BRACELIGHT, types[GEANY_FILETYPES_ALL]->styling[2][1]);
//SSM(sci, SCI_STYLESETBOLD, STYLE_BRACELIGHT, types[GEANY_FILETYPES_ALL]->styling[2][2]);
styleset_set_style(sci, STYLE_BRACELIGHT, GEANY_FILETYPES_ALL, 2);
//SSM(sci, SCI_STYLESETFORE, STYLE_BRACEBAD, types[GEANY_FILETYPES_ALL]->styling[3][0]);
//SSM(sci, SCI_STYLESETBACK, STYLE_BRACEBAD, types[GEANY_FILETYPES_ALL]->styling[3][1]);
//SSM(sci, SCI_STYLESETBOLD, STYLE_BRACEBAD, types[GEANY_FILETYPES_ALL]->styling[3][2]);
styleset_set_style(sci, STYLE_BRACEBAD, GEANY_FILETYPES_ALL, 2);
}
@ -294,22 +322,12 @@ void styleset_c(ScintillaObject *sci)
SSM(sci, SCI_SETWHITESPACEFORE, 1, 0xc0c0c0);
// I dont like/need folding
//SSM (sci, SCI_SETPROPERTY, (sptr_t) "fold.preprocessor", (sptr_t) "1");
//SSM (sci, SCI_SETPROPERTY, (sptr_t) "fold.at.else", (sptr_t) "1");
// enable folding for retrieval of current function (utils_get_current_tag)
SSM(sci, SCI_SETPROPERTY, (sptr_t) "fold", (sptr_t) "1");
SSM(sci, SCI_SETPROPERTY, (sptr_t) "styling.within.preprocessor", (sptr_t) "1");
SSM(sci, SCI_SETPROPERTY, (sptr_t) "file.patterns.cpp", (sptr_t) "*.cpp;*.cxx;*.cc");
SSM(sci, SCI_SETPROPERTY, (sptr_t) "preprocessor.symbol.$(file.patterns.cpp)", (sptr_t) "#");
SSM(sci, SCI_SETPROPERTY, (sptr_t) "preprocessor.start.$(file.patterns.cpp)", (sptr_t) "if ifdef ifndef");
SSM(sci, SCI_SETPROPERTY, (sptr_t) "preprocessor.middle.$(file.patterns.cpp)", (sptr_t) "else elif");
SSM(sci, SCI_SETPROPERTY, (sptr_t) "preprocessor.end.$(file.patterns.cpp)", (sptr_t) "endif");
//SSM(sci, SCI_SETPROPERTY, (sptr_t) "statement.indent.$(file.patterns.cpp)", (sptr_t) "5 case catch class default do else for if private protected public struct try union while switch");
//SSM(sci, SCI_SETPROPERTY, (sptr_t) "statement.indent.$(file.patterns.header)", (sptr_t) "5 case catch class default do else for if private protected public struct try union while switch");
//SSM(sci, SCI_SETPROPERTY, (sptr_t) "statement.indent.$(file.patterns.c)", (sptr_t) "5 case do else for if struct union while switch");
}
@ -349,9 +367,6 @@ void styleset_pascal(ScintillaObject *sci)
styleset_common(sci, 5);
// enable folding for retrieval of current function (utils_get_current_tag)
SSM (sci, SCI_SETPROPERTY, (sptr_t) "fold", (sptr_t) "1");
SSM (sci, SCI_SETWORDCHARS, 0, (sptr_t) GEANY_WORDCHARS);
SSM (sci, SCI_AUTOCSETMAXHEIGHT, 8, 0);
@ -462,9 +477,6 @@ void styleset_php(ScintillaObject *sci)
{
styleset_common(sci, 7);
// enable folding for retrieval of current function (utils_get_current_tag)
SSM (sci, SCI_SETPROPERTY, (sptr_t) "fold", (sptr_t) "1");
SSM (sci, SCI_SETPROPERTY, (sptr_t) "phpscript.mode", (sptr_t) "1");
SSM (sci, SCI_SETLEXER, SCLEX_HTML, 0);
@ -845,9 +857,6 @@ void styleset_java(ScintillaObject *sci)
styleset_common(sci, 5);
SSM (sci, SCI_SETLEXER, SCLEX_CPP, 0);
// enable folding for retrieval of current function (utils_get_current_tag)
SSM (sci, SCI_SETPROPERTY, (sptr_t) "fold", (sptr_t) "1");
SSM (sci, SCI_SETWORDCHARS, 0, (sptr_t) GEANY_WORDCHARS);
SSM (sci, SCI_AUTOCSETMAXHEIGHT, 8, 0);
@ -958,8 +967,6 @@ void styleset_perl(ScintillaObject *sci)
styleset_common(sci, 5);
SSM (sci, SCI_SETLEXER, SCLEX_PERL, 0);
// enable folding for retrieval of current function (utils_get_current_tag)
SSM (sci, SCI_SETPROPERTY, (sptr_t) "fold", (sptr_t) "1");
SSM(sci, SCI_SETPROPERTY, (sptr_t) "styling.within.preprocessor", (sptr_t) "1");
SSM (sci, SCI_SETWORDCHARS, 0, (sptr_t) GEANY_WORDCHARS);
@ -1028,9 +1035,6 @@ void styleset_python(ScintillaObject *sci)
styleset_common(sci, 5);
SSM (sci, SCI_SETLEXER, SCLEX_PYTHON, 0);
// enable folding for retrieval of current function (utils_get_current_tag)
SSM (sci, SCI_SETPROPERTY, (sptr_t) "fold", (sptr_t) "1");
SSM(sci, SCI_SETKEYWORDS, 0, (sptr_t) types[GEANY_FILETYPES_PYTHON]->keywords[0]);
styleset_set_style(sci, SCE_P_DEFAULT, GEANY_FILETYPES_PYTHON, 0);

View File

@ -37,7 +37,7 @@ create_window1 (void)
GtkWidget *menuitem1_menu;
GtkWidget *menu_new1;
GtkWidget *menu_new_with_template1;
GtkWidget *image578;
GtkWidget *image586;
GtkWidget *menu_new_with_template1_menu;
GtkWidget *invisible2;
GtkWidget *separator12;
@ -46,14 +46,14 @@ create_window1 (void)
GtkWidget *menu_save1;
GtkWidget *menu_save_as1;
GtkWidget *menu_save_all1;
GtkWidget *image579;
GtkWidget *image587;
GtkWidget *revert1;
GtkWidget *separator21;
GtkWidget *preferences2;
GtkWidget *separator14;
GtkWidget *menu_close1;
GtkWidget *menu_close_all1;
GtkWidget *image580;
GtkWidget *image588;
GtkWidget *menu_separatormenuitem1;
GtkWidget *recent_files1;
GtkWidget *recent_files1_menu;
@ -71,11 +71,11 @@ create_window1 (void)
GtkWidget *menu_delete1;
GtkWidget *menu_seperator2;
GtkWidget *insert_include2;
GtkWidget *image581;
GtkWidget *image589;
GtkWidget *insert_include2_menu;
GtkWidget *invisible4;
GtkWidget *add_comments1;
GtkWidget *image582;
GtkWidget *image590;
GtkWidget *add_comments1_menu;
GtkWidget *menu_add_changelog_entry1;
GtkWidget *insert_file_header1;
@ -91,17 +91,17 @@ create_window1 (void)
GtkWidget *separator9;
GtkWidget *find1;
GtkWidget *find_next1;
GtkWidget *image583;
GtkWidget *image591;
GtkWidget *replace1;
GtkWidget *image584;
GtkWidget *image592;
GtkWidget *separator11;
GtkWidget *preferences1;
GtkWidget *menuitem3;
GtkWidget *menuitem3_menu;
GtkWidget *menu_change_font1;
GtkWidget *image585;
GtkWidget *image593;
GtkWidget *menu_choose_color1;
GtkWidget *image586;
GtkWidget *image594;
GtkWidget *menu_separator4;
GtkWidget *menu_fullscreen1;
GtkWidget *menu_show_messages_window1;
@ -128,6 +128,9 @@ create_window1 (void)
GtkWidget *cr;
GtkWidget *separator8;
GtkWidget *menu_replace_tabs;
GtkWidget *separator22;
GtkWidget *menu_fold_all1;
GtkWidget *menu_unfold_all1;
GtkWidget *menu_build1;
GtkWidget *menu_item5;
GtkWidget *menu_item5_menu;
@ -155,6 +158,10 @@ create_window1 (void)
GtkWidget *toolitem11;
GtkWidget *entry1;
GtkWidget *toolbutton18;
GtkWidget *separatortoolitem5;
GtkWidget *toolitem15;
GtkWidget *entry_goto_line;
GtkWidget *toolbutton25;
GtkWidget *toolitem14;
GtkWidget *alignment1;
GtkWidget *label1;
@ -220,9 +227,9 @@ create_window1 (void)
gtk_widget_show (menu_new_with_template1);
gtk_container_add (GTK_CONTAINER (menuitem1_menu), menu_new_with_template1);
image578 = gtk_image_new_from_stock ("gtk-new", GTK_ICON_SIZE_MENU);
gtk_widget_show (image578);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_new_with_template1), image578);
image586 = gtk_image_new_from_stock ("gtk-new", GTK_ICON_SIZE_MENU);
gtk_widget_show (image586);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_new_with_template1), image586);
menu_new_with_template1_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_new_with_template1), menu_new_with_template1_menu);
@ -260,9 +267,9 @@ create_window1 (void)
GDK_s, (GdkModifierType) GDK_CONTROL_MASK | GDK_SHIFT_MASK,
GTK_ACCEL_VISIBLE);
image579 = gtk_image_new_from_stock ("gtk-save", GTK_ICON_SIZE_MENU);
gtk_widget_show (image579);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_save_all1), image579);
image587 = gtk_image_new_from_stock ("gtk-save", GTK_ICON_SIZE_MENU);
gtk_widget_show (image587);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_save_all1), image587);
revert1 = gtk_image_menu_item_new_from_stock ("gtk-revert-to-saved", accel_group);
gtk_widget_show (revert1);
@ -294,9 +301,9 @@ create_window1 (void)
GDK_d, (GdkModifierType) GDK_MOD1_MASK,
GTK_ACCEL_VISIBLE);
image580 = gtk_image_new_from_stock ("gtk-close", GTK_ICON_SIZE_MENU);
gtk_widget_show (image580);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_close_all1), image580);
image588 = gtk_image_new_from_stock ("gtk-close", GTK_ICON_SIZE_MENU);
gtk_widget_show (image588);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_close_all1), image588);
menu_separatormenuitem1 = gtk_separator_menu_item_new ();
gtk_widget_show (menu_separatormenuitem1);
@ -368,9 +375,9 @@ create_window1 (void)
gtk_widget_show (insert_include2);
gtk_container_add (GTK_CONTAINER (edit1_menu), insert_include2);
image581 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
gtk_widget_show (image581);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (insert_include2), image581);
image589 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
gtk_widget_show (image589);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (insert_include2), image589);
insert_include2_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (insert_include2), insert_include2_menu);
@ -382,9 +389,9 @@ create_window1 (void)
gtk_widget_show (add_comments1);
gtk_container_add (GTK_CONTAINER (edit1_menu), add_comments1);
image582 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
gtk_widget_show (image582);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (add_comments1), image582);
image590 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
gtk_widget_show (image590);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (add_comments1), image590);
add_comments1_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (add_comments1), add_comments1_menu);
@ -455,17 +462,17 @@ create_window1 (void)
GDK_F3, (GdkModifierType) 0,
GTK_ACCEL_VISIBLE);
image583 = gtk_image_new_from_stock ("gtk-find", GTK_ICON_SIZE_MENU);
gtk_widget_show (image583);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (find_next1), image583);
image591 = gtk_image_new_from_stock ("gtk-find", GTK_ICON_SIZE_MENU);
gtk_widget_show (image591);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (find_next1), image591);
replace1 = gtk_image_menu_item_new_with_mnemonic (_("_Replace"));
gtk_widget_show (replace1);
gtk_container_add (GTK_CONTAINER (edit1_menu), replace1);
image584 = gtk_image_new_from_stock ("gtk-find-and-replace", GTK_ICON_SIZE_MENU);
gtk_widget_show (image584);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (replace1), image584);
image592 = gtk_image_new_from_stock ("gtk-find-and-replace", GTK_ICON_SIZE_MENU);
gtk_widget_show (image592);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (replace1), image592);
separator11 = gtk_separator_menu_item_new ();
gtk_widget_show (separator11);
@ -488,18 +495,18 @@ create_window1 (void)
gtk_container_add (GTK_CONTAINER (menuitem3_menu), menu_change_font1);
gtk_tooltips_set_tip (tooltips, menu_change_font1, _("Change the default font"), NULL);
image585 = gtk_image_new_from_stock ("gtk-select-font", GTK_ICON_SIZE_MENU);
gtk_widget_show (image585);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_change_font1), image585);
image593 = gtk_image_new_from_stock ("gtk-select-font", GTK_ICON_SIZE_MENU);
gtk_widget_show (image593);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_change_font1), image593);
menu_choose_color1 = gtk_image_menu_item_new_with_mnemonic (_("Show Color Chooser"));
gtk_widget_show (menu_choose_color1);
gtk_container_add (GTK_CONTAINER (menuitem3_menu), menu_choose_color1);
gtk_tooltips_set_tip (tooltips, menu_choose_color1, _("Open a color chooser dialog, to interactively pick colors from a palette."), NULL);
image586 = gtk_image_new_from_stock ("gtk-select-color", GTK_ICON_SIZE_MENU);
gtk_widget_show (image586);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_choose_color1), image586);
image594 = gtk_image_new_from_stock ("gtk-select-color", GTK_ICON_SIZE_MENU);
gtk_widget_show (image594);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_choose_color1), image594);
menu_separator4 = gtk_separator_menu_item_new ();
gtk_widget_show (menu_separator4);
@ -621,6 +628,21 @@ create_window1 (void)
gtk_container_add (GTK_CONTAINER (menu_item4_menu), menu_replace_tabs);
gtk_tooltips_set_tip (tooltips, menu_replace_tabs, _("Replaces all tabs in document by spaces."), NULL);
separator22 = gtk_separator_menu_item_new ();
gtk_widget_show (separator22);
gtk_container_add (GTK_CONTAINER (menu_item4_menu), separator22);
gtk_widget_set_sensitive (separator22, FALSE);
menu_fold_all1 = gtk_menu_item_new_with_mnemonic (_("Fold all"));
gtk_widget_show (menu_fold_all1);
gtk_container_add (GTK_CONTAINER (menu_item4_menu), menu_fold_all1);
gtk_tooltips_set_tip (tooltips, menu_fold_all1, _("Folds all contractible code blocks"), NULL);
menu_unfold_all1 = gtk_menu_item_new_with_mnemonic (_("Unfold all"));
gtk_widget_show (menu_unfold_all1);
gtk_container_add (GTK_CONTAINER (menu_item4_menu), menu_unfold_all1);
gtk_tooltips_set_tip (tooltips, menu_unfold_all1, _("Unfolds all contracted code blocks"), NULL);
menu_build1 = gtk_menu_item_new_with_mnemonic (_("Build"));
gtk_widget_show (menu_build1);
gtk_container_add (GTK_CONTAINER (menubar1), menu_build1);
@ -698,7 +720,7 @@ create_window1 (void)
toolbutton13 = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-convert");
gtk_widget_show (toolbutton13);
gtk_container_add (GTK_CONTAINER (toolbar1), toolbutton13);
gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (toolbutton13), tooltips, _("Compiles the current file"), NULL);
gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (toolbutton13), tooltips, _("Compile the current file"), NULL);
tmp_image = gtk_image_new_from_stock ("gtk-select-color", tmp_toolbar_icon_size);
gtk_widget_show (tmp_image);
@ -739,6 +761,26 @@ create_window1 (void)
gtk_container_add (GTK_CONTAINER (toolbar1), toolbutton18);
gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (toolbutton18), tooltips, _("Find the entered text in the current file"), NULL);
separatortoolitem5 = (GtkWidget*) gtk_separator_tool_item_new ();
gtk_widget_show (separatortoolitem5);
gtk_container_add (GTK_CONTAINER (toolbar1), separatortoolitem5);
toolitem15 = (GtkWidget*) gtk_tool_item_new ();
gtk_widget_show (toolitem15);
gtk_container_add (GTK_CONTAINER (toolbar1), toolitem15);
entry_goto_line = gtk_entry_new ();
gtk_widget_show (entry_goto_line);
gtk_container_add (GTK_CONTAINER (toolitem15), entry_goto_line);
gtk_tooltips_set_tip (tooltips, entry_goto_line, _("Enter a line number and jump to it."), NULL);
gtk_entry_set_max_length (GTK_ENTRY (entry_goto_line), 5);
gtk_entry_set_width_chars (GTK_ENTRY (entry_goto_line), 8);
toolbutton25 = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-jump-to");
gtk_widget_show (toolbutton25);
gtk_container_add (GTK_CONTAINER (toolbar1), toolbutton25);
gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (toolbutton25), tooltips, _("Jump to the entered line number."), NULL);
toolitem14 = (GtkWidget*) gtk_tool_item_new ();
gtk_widget_show (toolitem14);
gtk_container_add (GTK_CONTAINER (toolbar1), toolitem14);
@ -1021,6 +1063,12 @@ create_window1 (void)
g_signal_connect ((gpointer) menu_replace_tabs, "activate",
G_CALLBACK (on_replace_tabs_activate),
NULL);
g_signal_connect ((gpointer) menu_fold_all1, "activate",
G_CALLBACK (on_menu_fold_all1_activate),
NULL);
g_signal_connect ((gpointer) menu_unfold_all1, "activate",
G_CALLBACK (on_menu_unfold_all1_activate),
NULL);
g_signal_connect ((gpointer) help1, "activate",
G_CALLBACK (on_help1_activate),
NULL);
@ -1072,6 +1120,12 @@ create_window1 (void)
g_signal_connect ((gpointer) toolbutton18, "clicked",
G_CALLBACK (on_toolbutton18_clicked),
NULL);
g_signal_connect ((gpointer) entry_goto_line, "activate",
G_CALLBACK (on_entry_goto_line_activate),
NULL);
g_signal_connect ((gpointer) toolbutton25, "clicked",
G_CALLBACK (on_toolbutton_goto_clicked),
NULL);
g_signal_connect ((gpointer) toolbutton19, "clicked",
G_CALLBACK (on_toolbutton19_clicked),
NULL);
@ -1094,7 +1148,7 @@ create_window1 (void)
GLADE_HOOKUP_OBJECT (window1, menuitem1_menu, "menuitem1_menu");
GLADE_HOOKUP_OBJECT (window1, menu_new1, "menu_new1");
GLADE_HOOKUP_OBJECT (window1, menu_new_with_template1, "menu_new_with_template1");
GLADE_HOOKUP_OBJECT (window1, image578, "image578");
GLADE_HOOKUP_OBJECT (window1, image586, "image586");
GLADE_HOOKUP_OBJECT (window1, menu_new_with_template1_menu, "menu_new_with_template1_menu");
GLADE_HOOKUP_OBJECT (window1, invisible2, "invisible2");
GLADE_HOOKUP_OBJECT (window1, separator12, "separator12");
@ -1103,14 +1157,14 @@ create_window1 (void)
GLADE_HOOKUP_OBJECT (window1, menu_save1, "menu_save1");
GLADE_HOOKUP_OBJECT (window1, menu_save_as1, "menu_save_as1");
GLADE_HOOKUP_OBJECT (window1, menu_save_all1, "menu_save_all1");
GLADE_HOOKUP_OBJECT (window1, image579, "image579");
GLADE_HOOKUP_OBJECT (window1, image587, "image587");
GLADE_HOOKUP_OBJECT (window1, revert1, "revert1");
GLADE_HOOKUP_OBJECT (window1, separator21, "separator21");
GLADE_HOOKUP_OBJECT (window1, preferences2, "preferences2");
GLADE_HOOKUP_OBJECT (window1, separator14, "separator14");
GLADE_HOOKUP_OBJECT (window1, menu_close1, "menu_close1");
GLADE_HOOKUP_OBJECT (window1, menu_close_all1, "menu_close_all1");
GLADE_HOOKUP_OBJECT (window1, image580, "image580");
GLADE_HOOKUP_OBJECT (window1, image588, "image588");
GLADE_HOOKUP_OBJECT (window1, menu_separatormenuitem1, "menu_separatormenuitem1");
GLADE_HOOKUP_OBJECT (window1, recent_files1, "recent_files1");
GLADE_HOOKUP_OBJECT (window1, recent_files1_menu, "recent_files1_menu");
@ -1128,11 +1182,11 @@ create_window1 (void)
GLADE_HOOKUP_OBJECT (window1, menu_delete1, "menu_delete1");
GLADE_HOOKUP_OBJECT (window1, menu_seperator2, "menu_seperator2");
GLADE_HOOKUP_OBJECT (window1, insert_include2, "insert_include2");
GLADE_HOOKUP_OBJECT (window1, image581, "image581");
GLADE_HOOKUP_OBJECT (window1, image589, "image589");
GLADE_HOOKUP_OBJECT (window1, insert_include2_menu, "insert_include2_menu");
GLADE_HOOKUP_OBJECT (window1, invisible4, "invisible4");
GLADE_HOOKUP_OBJECT (window1, add_comments1, "add_comments1");
GLADE_HOOKUP_OBJECT (window1, image582, "image582");
GLADE_HOOKUP_OBJECT (window1, image590, "image590");
GLADE_HOOKUP_OBJECT (window1, add_comments1_menu, "add_comments1_menu");
GLADE_HOOKUP_OBJECT (window1, menu_add_changelog_entry1, "menu_add_changelog_entry1");
GLADE_HOOKUP_OBJECT (window1, insert_file_header1, "insert_file_header1");
@ -1148,17 +1202,17 @@ create_window1 (void)
GLADE_HOOKUP_OBJECT (window1, separator9, "separator9");
GLADE_HOOKUP_OBJECT (window1, find1, "find1");
GLADE_HOOKUP_OBJECT (window1, find_next1, "find_next1");
GLADE_HOOKUP_OBJECT (window1, image583, "image583");
GLADE_HOOKUP_OBJECT (window1, image591, "image591");
GLADE_HOOKUP_OBJECT (window1, replace1, "replace1");
GLADE_HOOKUP_OBJECT (window1, image584, "image584");
GLADE_HOOKUP_OBJECT (window1, image592, "image592");
GLADE_HOOKUP_OBJECT (window1, separator11, "separator11");
GLADE_HOOKUP_OBJECT (window1, preferences1, "preferences1");
GLADE_HOOKUP_OBJECT (window1, menuitem3, "menuitem3");
GLADE_HOOKUP_OBJECT (window1, menuitem3_menu, "menuitem3_menu");
GLADE_HOOKUP_OBJECT (window1, menu_change_font1, "menu_change_font1");
GLADE_HOOKUP_OBJECT (window1, image585, "image585");
GLADE_HOOKUP_OBJECT (window1, image593, "image593");
GLADE_HOOKUP_OBJECT (window1, menu_choose_color1, "menu_choose_color1");
GLADE_HOOKUP_OBJECT (window1, image586, "image586");
GLADE_HOOKUP_OBJECT (window1, image594, "image594");
GLADE_HOOKUP_OBJECT (window1, menu_separator4, "menu_separator4");
GLADE_HOOKUP_OBJECT (window1, menu_fullscreen1, "menu_fullscreen1");
GLADE_HOOKUP_OBJECT (window1, menu_show_messages_window1, "menu_show_messages_window1");
@ -1185,6 +1239,9 @@ create_window1 (void)
GLADE_HOOKUP_OBJECT (window1, cr, "cr");
GLADE_HOOKUP_OBJECT (window1, separator8, "separator8");
GLADE_HOOKUP_OBJECT (window1, menu_replace_tabs, "menu_replace_tabs");
GLADE_HOOKUP_OBJECT (window1, separator22, "separator22");
GLADE_HOOKUP_OBJECT (window1, menu_fold_all1, "menu_fold_all1");
GLADE_HOOKUP_OBJECT (window1, menu_unfold_all1, "menu_unfold_all1");
GLADE_HOOKUP_OBJECT (window1, menu_build1, "menu_build1");
GLADE_HOOKUP_OBJECT (window1, menu_item5, "menu_item5");
GLADE_HOOKUP_OBJECT (window1, menu_item5_menu, "menu_item5_menu");
@ -1210,6 +1267,10 @@ create_window1 (void)
GLADE_HOOKUP_OBJECT (window1, toolitem11, "toolitem11");
GLADE_HOOKUP_OBJECT (window1, entry1, "entry1");
GLADE_HOOKUP_OBJECT (window1, toolbutton18, "toolbutton18");
GLADE_HOOKUP_OBJECT (window1, separatortoolitem5, "separatortoolitem5");
GLADE_HOOKUP_OBJECT (window1, toolitem15, "toolitem15");
GLADE_HOOKUP_OBJECT (window1, entry_goto_line, "entry_goto_line");
GLADE_HOOKUP_OBJECT (window1, toolbutton25, "toolbutton25");
GLADE_HOOKUP_OBJECT (window1, toolitem14, "toolitem14");
GLADE_HOOKUP_OBJECT (window1, alignment1, "alignment1");
GLADE_HOOKUP_OBJECT (window1, label1, "label1");
@ -1681,6 +1742,7 @@ create_prefs_dialog (void)
GtkWidget *alignment4;
GtkWidget *vbox7;
GtkWidget *check_toolbar_search;
GtkWidget *check_toolbar_goto;
GtkWidget *label98;
GtkWidget *label104;
GtkWidget *frame7;
@ -1722,6 +1784,7 @@ create_prefs_dialog (void)
GtkWidget *check_line_end;
GtkWidget *check_xmltag;
GtkWidget *check_auto_complete;
GtkWidget *check_folding;
GtkWidget *label148;
GtkWidget *table3;
GtkWidget *label103;
@ -1922,6 +1985,13 @@ create_prefs_dialog (void)
gtk_tooltips_set_tip (tooltips, check_toolbar_search, _("Display the search field and button in the toolbar"), NULL);
gtk_button_set_focus_on_click (GTK_BUTTON (check_toolbar_search), FALSE);
check_toolbar_goto = gtk_check_button_new_with_mnemonic (_("Show goto line field"));
gtk_widget_show (check_toolbar_goto);
gtk_box_pack_start (GTK_BOX (vbox7), check_toolbar_goto, FALSE, FALSE, 0);
GTK_WIDGET_UNSET_FLAGS (check_toolbar_goto, GTK_CAN_FOCUS);
gtk_tooltips_set_tip (tooltips, check_toolbar_goto, _("Display the line number field and button in the toolbar"), NULL);
gtk_button_set_focus_on_click (GTK_BUTTON (check_toolbar_goto), FALSE);
label98 = gtk_label_new (_("<b>Toolbar</b>"));
gtk_widget_show (label98);
gtk_frame_set_label_widget (GTK_FRAME (frame3), label98);
@ -2147,6 +2217,12 @@ create_prefs_dialog (void)
gtk_tooltips_set_tip (tooltips, check_auto_complete, _("Automatic completion of often used constructs like if and for"), NULL);
gtk_button_set_focus_on_click (GTK_BUTTON (check_auto_complete), FALSE);
check_folding = gtk_check_button_new_with_mnemonic (_("Enable folding"));
gtk_widget_show (check_folding);
gtk_box_pack_start (GTK_BOX (vbox12), check_folding, FALSE, FALSE, 0);
gtk_tooltips_set_tip (tooltips, check_folding, _("Whether to enable folding the code"), NULL);
gtk_button_set_focus_on_click (GTK_BUTTON (check_folding), FALSE);
label148 = gtk_label_new (_(" "));
gtk_widget_show (label148);
gtk_box_pack_start (GTK_BOX (vbox12), label148, FALSE, FALSE, 0);
@ -2677,6 +2753,7 @@ create_prefs_dialog (void)
GLADE_HOOKUP_OBJECT (prefs_dialog, alignment4, "alignment4");
GLADE_HOOKUP_OBJECT (prefs_dialog, vbox7, "vbox7");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_toolbar_search, "check_toolbar_search");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_toolbar_goto, "check_toolbar_goto");
GLADE_HOOKUP_OBJECT (prefs_dialog, label98, "label98");
GLADE_HOOKUP_OBJECT (prefs_dialog, label104, "label104");
GLADE_HOOKUP_OBJECT (prefs_dialog, frame7, "frame7");
@ -2717,6 +2794,7 @@ create_prefs_dialog (void)
GLADE_HOOKUP_OBJECT (prefs_dialog, check_line_end, "check_line_end");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_xmltag, "check_xmltag");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_auto_complete, "check_auto_complete");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_folding, "check_folding");
GLADE_HOOKUP_OBJECT (prefs_dialog, label148, "label148");
GLADE_HOOKUP_OBJECT (prefs_dialog, table3, "table3");
GLADE_HOOKUP_OBJECT (prefs_dialog, label103, "label103");

View File

@ -84,6 +84,7 @@ void configuration_save(void)
g_key_file_set_boolean(config, PACKAGE, "treeview_symbol_visible", app->treeview_symbol_visible);
g_key_file_set_boolean(config, PACKAGE, "treeview_openfiles_visible", app->treeview_openfiles_visible);
g_key_file_set_boolean(config, PACKAGE, "msgwindow_visible", app->msgwindow_visible);
g_key_file_set_boolean(config, PACKAGE, "use_folding", app->pref_editor_folding);
g_key_file_set_boolean(config, PACKAGE, "use_auto_indention", app->pref_editor_use_auto_indention);
g_key_file_set_boolean(config, PACKAGE, "show_indent_guide", app->pref_editor_show_indent_guide);
g_key_file_set_boolean(config, PACKAGE, "show_white_space", app->pref_editor_show_white_space);
@ -115,6 +116,7 @@ void configuration_save(void)
g_key_file_set_boolean(config, PACKAGE, "pref_main_load_session", app->pref_main_load_session);
g_key_file_set_boolean(config, PACKAGE, "pref_main_save_winpos", app->pref_main_save_winpos);
g_key_file_set_boolean(config, PACKAGE, "pref_main_show_search", app->pref_main_show_search);
g_key_file_set_boolean(config, PACKAGE, "pref_main_show_goto", app->pref_main_show_goto);
g_key_file_set_boolean(config, PACKAGE, "pref_editor_new_line", app->pref_editor_new_line);
g_key_file_set_boolean(config, PACKAGE, "pref_editor_trail_space", app->pref_editor_trail_space);
g_key_file_set_string(config, PACKAGE, "pref_template_developer", app->pref_template_developer);
@ -214,6 +216,7 @@ gboolean configuration_load(void)
app->treeview_symbol_visible = utils_get_setting_boolean(config, PACKAGE, "treeview_symbol_visible", TRUE);
app->treeview_openfiles_visible = utils_get_setting_boolean(config, PACKAGE, "treeview_openfiles_visible", TRUE);
app->msgwindow_visible = utils_get_setting_boolean(config, PACKAGE, "msgwindow_visible", TRUE);
app->pref_editor_folding = utils_get_setting_boolean(config, PACKAGE, "use_folding", TRUE);
app->pref_editor_use_auto_indention = utils_get_setting_boolean(config, PACKAGE, "use_auto_indention", TRUE);
app->pref_editor_show_indent_guide = utils_get_setting_boolean(config, PACKAGE, "show_indent_guide", FALSE);
app->pref_editor_show_white_space = utils_get_setting_boolean(config, PACKAGE, "show_white_space", FALSE);
@ -255,6 +258,7 @@ gboolean configuration_load(void)
app->pref_main_load_session = utils_get_setting_boolean(config, PACKAGE, "pref_main_load_session", TRUE);
app->pref_main_save_winpos = utils_get_setting_boolean(config, PACKAGE, "pref_main_save_winpos", TRUE);
app->pref_main_show_search = utils_get_setting_boolean(config, PACKAGE, "pref_main_show_search", TRUE);
app->pref_main_show_goto = utils_get_setting_boolean(config, PACKAGE, "pref_main_show_goto", TRUE);
app->pref_template_developer = utils_get_setting_string(config, PACKAGE, "pref_template_developer", g_get_real_name());
app->pref_template_company = utils_get_setting_string(config, PACKAGE, "pref_template_company", "");
#ifdef HAVE_VTE

View File

@ -100,6 +100,8 @@ void geany_debug(gchar const *format, ...)
* (all the following code is not perfect but it works for the moment) */
static void apply_settings(void)
{
utils_update_fold_items();
// toolbar, message window and tagbar are by default visible, so don't change it if it is true
if (! app->toolbar_visible)
{
@ -172,6 +174,13 @@ static void apply_settings(void)
gtk_window_set_default_size(GTK_WINDOW(app->window), app->geometry[2], app->geometry[3]);
}
if (! app->pref_main_show_goto)
{
gtk_widget_hide(lookup_widget(app->window, "entry_goto_line"));
gtk_widget_hide(lookup_widget(app->window, "toolbutton25"));
gtk_widget_hide(lookup_widget(app->window, "separatortoolitem5"));
}
if (! app->pref_main_show_search)
{
gtk_widget_hide(lookup_widget(app->window, "entry1"));
@ -189,10 +198,8 @@ static void apply_settings(void)
}
static gint main_init(void)
static void main_init(void)
{
gint mkdir_result;
// inits
app = g_new(MyApp, 1);
#ifdef GEANY_DEBUG
@ -248,9 +255,6 @@ static gint main_init(void)
dialogs_build_menus.menu_misc.item_compile = NULL;
dialogs_build_menus.menu_misc.item_exec = NULL;
dialogs_build_menus.menu_misc.item_link = NULL;
mkdir_result = utils_make_settings_dir();
if (mkdir_result != 0)
if (! dialogs_show_mkcfgdir_error(mkdir_result)) destroyapp_early();
app->window = create_window1();
app->new_file_menu = gtk_menu_new();
@ -318,8 +322,6 @@ static gint main_init(void)
msgwindow.tree_status = lookup_widget(app->window, "treeview3");
msgwindow.tree_msg = lookup_widget(app->window, "treeview4");
msgwindow.tree_compiler = lookup_widget(app->window, "treeview5");
return mkdir_result;
}
@ -367,17 +369,13 @@ static void write_fifo(gint argc, gchar **argv)
/* creates a named pipe in GEANY_FIFO_NAME, to communicate with new instances of Geany
* to submit filenames and possibly other things */
static void create_fifo(gint argc, gchar **argv)
static void create_fifo(gint argc, gchar **argv, const gchar *config_dir)
{
struct stat st;
gchar *tmp;
GIOChannel *ioc;
if (alternate_config)
tmp = g_strconcat(alternate_config, G_DIR_SEPARATOR_S, GEANY_FIFO_NAME, NULL);
else
tmp = g_strconcat(GEANY_HOME_DIR, G_DIR_SEPARATOR_S, ".", PACKAGE, G_DIR_SEPARATOR_S, GEANY_FIFO_NAME, NULL);
tmp = g_strconcat(config_dir, G_DIR_SEPARATOR_S, GEANY_FIFO_NAME, NULL);
strncpy(fifo_name, tmp, MAX(strlen(tmp), sizeof(fifo_name)));
g_free(tmp);
@ -408,7 +406,8 @@ static void create_fifo(gint argc, gchar **argv)
if ((mkfifo(fifo_name, S_IRUSR | S_IWUSR)) == -1)
{
if(errno != EEXIST) geany_debug("creating of a named pipe for IPC failed!");
if (errno != EEXIST) geany_debug("creating of a named pipe for IPC failed! (%s)", g_strerror(errno));
return;
}
ioc = g_io_channel_unix_new(open(fifo_name, O_RDONLY | O_NONBLOCK));
@ -421,12 +420,14 @@ gint main(gint argc, gchar **argv)
{
GError *error = NULL;
GOptionContext *context;
gint mkdir_result, idx;
gint mkdir_result = 0;
gint idx;
time_t seconds = time((time_t *) 0);
struct tm *tm = localtime(&seconds);
this_year = tm->tm_year + 1900;
this_month = tm->tm_mon + 1;
this_day = tm->tm_mday;
gchar *config_dir;
#ifdef ENABLE_NLS
bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
@ -453,15 +454,25 @@ gint main(gint argc, gchar **argv)
}
signal(SIGTERM, signal_cb);
//signal(SIGUSR1, signal_cb);
if (alternate_config) config_dir = g_strdup(alternate_config);
else config_dir = g_strconcat(GEANY_HOME_DIR, G_DIR_SEPARATOR_S, ".", PACKAGE, NULL);
mkdir_result = utils_make_settings_dir(config_dir);
if (mkdir_result != 0 && ! dialogs_show_mkcfgdir_error(mkdir_result))
{
g_free(config_dir);
return (0);
}
#ifdef HAVE_FIFO
if (! ignore_fifo) create_fifo(argc, argv);
if (! ignore_fifo) create_fifo(argc, argv, config_dir);
#endif
g_free(config_dir);
gtk_init(&argc, &argv);
mkdir_result = main_init();
main_init();
configuration_load();
templates_init();
encodings_init();
@ -500,9 +511,6 @@ gint main(gint argc, gchar **argv)
// apply all configuration options
apply_settings();
// this option is currently disabled, until the document menu item is reordered
//gtk_widget_hide(lookup_widget(app->window, "set_file_readonly1"));
// open files from command line
app->opening_session_files = TRUE;
if (argc > 1)

View File

@ -28,6 +28,7 @@
#include "utils.h"
#include "msgwindow.h"
#include "sciwrappers.h"
#include "document.h"
#include "keyfile.h"
#ifdef HAVE_VTE
# include "vte.h"
@ -66,6 +67,9 @@ void prefs_init_dialog(void)
widget = lookup_widget(app->prefs_dialog, "check_toolbar_search");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), app->pref_main_show_search);
widget = lookup_widget(app->prefs_dialog, "check_toolbar_goto");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), app->pref_main_show_goto);
widget = lookup_widget(app->prefs_dialog, "check_list_symbol");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), app->treeview_symbol_visible);
@ -105,6 +109,9 @@ void prefs_init_dialog(void)
widget = lookup_widget(app->prefs_dialog, "check_auto_complete");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), app->pref_editor_auto_complete_constructs);
widget = lookup_widget(app->prefs_dialog, "check_folding");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), app->pref_editor_folding);
widget = lookup_widget(app->prefs_dialog, "editor_font");
gtk_font_button_set_font_name(GTK_FONT_BUTTON(widget), app->editor_font);
@ -233,6 +240,9 @@ void on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_dat
widget = lookup_widget(app->prefs_dialog, "check_toolbar_search");
app->pref_main_show_search = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = lookup_widget(app->prefs_dialog, "check_toolbar_goto");
app->pref_main_show_goto = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = lookup_widget(app->prefs_dialog, "check_list_symbol");
app->treeview_symbol_visible = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
@ -253,6 +263,25 @@ void on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_dat
widget = lookup_widget(app->prefs_dialog, "spin_long_line");
app->long_line_column = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
widget = lookup_widget(app->prefs_dialog, "check_folding");
app->pref_editor_folding = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
utils_update_fold_items();
widget = lookup_widget(app->prefs_dialog, "check_indent");
app->pref_editor_show_indent_guide = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = lookup_widget(app->prefs_dialog, "check_white_space");
app->pref_editor_show_white_space = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = lookup_widget(app->prefs_dialog, "check_line_end");
app->pref_editor_show_line_endings = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = lookup_widget(app->prefs_dialog, "check_xmltag");
app->pref_editor_auto_close_xml_tags = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = lookup_widget(app->prefs_dialog, "check_auto_complete");
app->pref_editor_auto_complete_constructs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
// Tools Settings
widget = lookup_widget(app->prefs_dialog, "entry_com_c");
@ -346,6 +375,9 @@ void on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_dat
utils_widget_show_hide(lookup_widget(app->window, "entry1"), app->pref_main_show_search);
utils_widget_show_hide(lookup_widget(app->window, "toolbutton18"), app->pref_main_show_search);
utils_widget_show_hide(lookup_widget(app->window, "separatortoolitem4"), app->pref_main_show_search);
utils_widget_show_hide(lookup_widget(app->window, "entry_goto_line"), app->pref_main_show_goto);
utils_widget_show_hide(lookup_widget(app->window, "toolbutton25"), app->pref_main_show_goto);
utils_widget_show_hide(lookup_widget(app->window, "separatortoolitem5"), app->pref_main_show_goto);
utils_treeviews_showhide();
for (i = 0; i < GEANY_MAX_OPEN_FILES; i++)
{
@ -353,7 +385,7 @@ void on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_dat
gtk_widget_modify_font(doc_list[i].tag_tree, pango_font_description_from_string(app->tagbar_font));
}
if (GTK_IS_WIDGET(app->default_tag_tree))
gtk_widget_modify_font(app->default_tag_tree, pango_font_description_from_string(app->tagbar_font));
gtk_widget_modify_font(app->default_tag_tree, pango_font_description_from_string(app->tagbar_font));
gtk_widget_modify_font(lookup_widget(app->window, "entry1"), pango_font_description_from_string(app->tagbar_font));
gtk_widget_modify_font(msgwindow.tree_compiler, pango_font_description_from_string(app->msgwin_font));
gtk_widget_modify_font(msgwindow.tree_msg, pango_font_description_from_string(app->msgwin_font));
@ -376,6 +408,8 @@ void on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_dat
sci_set_visible_eols(doc_list[i].sci, app->pref_editor_show_line_endings);
sci_set_indentionguides(doc_list[i].sci, app->pref_editor_show_indent_guide);
sci_set_visible_white_spaces(doc_list[i].sci, app->pref_editor_show_white_space);
sci_set_folding_margin_visible(doc_list[i].sci, app->pref_editor_folding);
if (! app->pref_editor_folding) document_unfold_all(i);
}
// }
old_tab_width = app->pref_editor_tab_width;

View File

@ -76,6 +76,10 @@ void on_editor_notification(GtkWidget* editor, gint scn, gpointer lscn, gpointer
//sci_marker_delete_all(doc_list[idx].sci, 1);
sci_set_marker_at_line(sci, line, sci_is_marker_set_at_line(sci, line, 1), 1);
}
else if (nt->margin == 2 && app->pref_editor_folding)
{
SSM(sci, SCI_TOGGLEFOLD, SSM(sci, SCI_LINEFROMPOSITION, nt->position, 0), 0);
}
break;
}
case SCN_UPDATEUI:
@ -203,14 +207,15 @@ void on_editor_notification(GtkWidget* editor, gint scn, gpointer lscn, gpointer
SSM(sci, SCI_STARTSTYLING, end_of_styling, 31);
*/ break;
}
case SCN_STYLENEEDED:
/* case SCN_STYLENEEDED:
{
geany_debug("style");
break;
}
case SCN_URIDROPPED:
*/ case SCN_URIDROPPED:
{
geany_debug(nt->text);
break;
}
}
}
@ -455,7 +460,7 @@ void sci_cb_auto_forif(ScintillaObject *sci, gint idx)
construct = g_strdup_printf("()%s{%s\t%s}%s", eol, eol, eol, eol);
SSM(sci, SCI_INSERTTEXT, pos, (sptr_t) construct);
SSM(sci, SCI_GOTOPOS, pos + 1, 0);
sci_goto_pos(sci, pos + 1, TRUE);
g_free(construct);
}
else if (! strncmp("else", buf + 2, 4))
@ -463,7 +468,7 @@ void sci_cb_auto_forif(ScintillaObject *sci, gint idx)
construct = g_strdup_printf("%s{%s\t%s}%s", eol, eol, eol, eol);
SSM(sci, SCI_INSERTTEXT, pos, (sptr_t) construct);
SSM(sci, SCI_GOTOPOS, pos + 4 + (2 * strlen(indent)), 0);
sci_goto_pos(sci, pos + 4 + (2 * strlen(indent)), TRUE);
g_free(construct);
}
else if (! strncmp("for", buf + 3, 3))
@ -483,7 +488,7 @@ void sci_cb_auto_forif(ScintillaObject *sci, gint idx)
construct = g_strdup_printf("(%s = 0; %s < ; %s++)%s{%s\t%s}%s", var, var, var, eol, eol, eol, eol);
SSM(sci, SCI_INSERTTEXT, pos, (sptr_t) construct);
SSM(sci, SCI_GOTOPOS, pos + contruct_len, 0);
sci_goto_pos(sci, pos + contruct_len, TRUE);
g_free(var);
g_free(construct);
}
@ -492,7 +497,7 @@ void sci_cb_auto_forif(ScintillaObject *sci, gint idx)
construct = g_strdup_printf("()%s{%s\t%s}%s", eol, eol, eol, eol);
SSM(sci, SCI_INSERTTEXT, pos, (sptr_t) construct);
SSM(sci, SCI_GOTOPOS, pos + 1, 0);
sci_goto_pos(sci, pos + 1, TRUE);
g_free(construct);
}
else if (! strncmp("switch", buf, 5))
@ -500,7 +505,7 @@ void sci_cb_auto_forif(ScintillaObject *sci, gint idx)
construct = g_strdup_printf("()%s{%s\tcase : break;%s\tdefault: %s}%s", eol, eol, eol, eol, eol);
SSM(sci, SCI_INSERTTEXT, pos, (sptr_t) construct);
SSM(sci, SCI_GOTOPOS, pos + 1, 0);
sci_goto_pos(sci, pos + 1, TRUE);
g_free(construct);
}
g_free(eol);

View File

@ -89,19 +89,24 @@ void sci_set_symbol_margin(ScintillaObject * sci, gboolean set )
}
}
gboolean sci_get_symbol_margin(ScintillaObject * sci)
gboolean sci_get_symbol_margin(ScintillaObject *sci)
{
if (SSM(sci, SCI_GETMARGINWIDTHN, 1, 0) > 0 ) return TRUE;
else return FALSE;
}
/* folding margin visibility */
void sci_set_folding_margin_visible (ScintillaObject * sci, gboolean set )
void sci_set_folding_margin_visible(ScintillaObject *sci, gboolean set)
{
if( set ){
SSM (sci, SCI_SETMARGINWIDTHN, 2, 12 );
}else{
SSM (sci, SCI_SETMARGINWIDTHN, 2, 0 );
if (set)
{
SSM(sci, SCI_SETMARGINWIDTHN, 2, 12);
SSM(sci, SCI_SETMARGINSENSITIVEN, 2, TRUE);
}
else
{
SSM(sci, SCI_SETMARGINSENSITIVEN, 2, FALSE);
SSM(sci, SCI_SETMARGINWIDTHN, 2, 0);
}
}
@ -589,8 +594,9 @@ gboolean sci_can_copy(ScintillaObject *sci)
}
void sci_goto_pos(ScintillaObject *sci, gint pos)
void sci_goto_pos(ScintillaObject *sci, gint pos, gboolean ensure_visibility)
{
if (ensure_visibility) SSM(sci,SCI_ENSUREVISIBLE,SSM(sci, SCI_LINEFROMPOSITION, pos, 0),0);
SSM(sci, SCI_GOTOPOS, pos, 0);
}
@ -638,8 +644,9 @@ void sci_set_font(ScintillaObject *sci, gint style, const gchar* font, gint size
}
void sci_goto_line(ScintillaObject *sci, gint line)
void sci_goto_line(ScintillaObject *sci, gint line, gboolean ensure_visibility)
{
if (ensure_visibility) SSM(sci,SCI_ENSUREVISIBLE,line,0);
SSM(sci, SCI_GOTOLINE, line, 0);
}

View File

@ -111,7 +111,7 @@ gchar sci_get_char_at (ScintillaObject * sci, gint pos);
void sci_set_savepoint (ScintillaObject * sci);
void sci_set_indentionguides (ScintillaObject * sci, gboolean enable);
void sci_use_popup (ScintillaObject * sci, gboolean enable);
void sci_goto_pos (ScintillaObject * sci, gint pos);
void sci_goto_pos (ScintillaObject * sci, gint pos, gboolean ensure_visibility);
void sci_set_search_anchor (ScintillaObject * sci);
void sci_set_anchor (ScintillaObject * sci, gint pos);
void sci_scroll_caret (ScintillaObject * sci);
@ -119,7 +119,7 @@ gint sci_search_next (ScintillaObject * sci, gint flags, const gchar *text
gint sci_search_prev (ScintillaObject * sci, gint flags, const gchar *text);
gint sci_find_text (ScintillaObject * sci, gint flags, struct TextToFind *ttf);
void sci_set_font (ScintillaObject * sci, gint style, const gchar* font, gint size);
void sci_goto_line (ScintillaObject * sci, gint line);
void sci_goto_line (ScintillaObject * sci, gint line, gboolean ensure_visibility);
void sci_marker_delete_all (ScintillaObject * sci, gint marker);
gint sci_get_style_at (ScintillaObject * sci, gint position);
void sci_set_symbol_margin (ScintillaObject * sci, gboolean set);

View File

@ -473,9 +473,9 @@ gboolean utils_goto_line(gint idx, gint line)
}
// mark the tag and ensure that we have arround 5 lines visible around the mark
sci_goto_line(doc_list[idx].sci, line - 5);
sci_goto_line(doc_list[idx].sci, line + 5);
sci_goto_line(doc_list[idx].sci, line);
sci_goto_line(doc_list[idx].sci, line - 5, FALSE);
sci_goto_line(doc_list[idx].sci, line + 5, FALSE);
sci_goto_line(doc_list[idx].sci, line, TRUE);
sci_marker_delete_all(doc_list[idx].sci, 0);
sci_set_marker_at_line(doc_list[idx].sci, line, TRUE, 0);
@ -578,42 +578,6 @@ gint utils_write_file(const gchar *filename, const gchar *text)
}
void _utils_show_indention_guides(void)
{
gint i, idx, max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook));
for(i = 0; i < max; i++)
{
idx = document_get_n_idx(i);
sci_set_indentionguides(doc_list[idx].sci, app->pref_editor_show_indent_guide);
}
}
void _utils_show_white_space(void)
{
gint i, idx, max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook));
for(i = 0; i < max; i++)
{
idx = document_get_n_idx(i);
sci_set_visible_white_spaces(doc_list[idx].sci, app->pref_editor_show_white_space);
}
}
void _utils_show_line_endings(void)
{
gint i, idx, max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook));
for(i = 0; i < max; i++)
{
idx = document_get_n_idx(i);
sci_set_visible_eols(doc_list[idx].sci, app->pref_editor_show_line_endings);
}
}
void utils_show_markers_margin(void)
{
gint i, idx, max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook));
@ -1042,7 +1006,7 @@ gint utils_get_current_tag(gint idx, gchar **tagname)
gint pos;
gint line;
gint fold_level;
gint start, end;
gint start, end, last_pos;
gint tmp;
//const GList *tags;
@ -1070,14 +1034,17 @@ gint utils_get_current_tag(gint idx, gchar **tagname)
}
*/
start = sci_get_position_from_line(doc_list[idx].sci, line + 1);
last_pos = sci_get_length(doc_list[idx].sci);
tmp = 0;
while (sci_get_style_at(doc_list[idx].sci, start) != SCE_C_IDENTIFIER
&& sci_get_style_at(doc_list[idx].sci, start) != SCE_C_GLOBALCLASS) start++;
&& sci_get_style_at(doc_list[idx].sci, start) != SCE_C_GLOBALCLASS
&& start < last_pos) start++;
end = start;
// save the style from start, it is SCE_C_IDENTIFIER or SCE_C_GLOBALCLASS
tmp = sci_get_style_at(doc_list[idx].sci, start);
while (sci_get_style_at(doc_list[idx].sci, end) == tmp
|| sci_get_char_at(doc_list[idx].sci, end) == ':') end++;
while ((sci_get_style_at(doc_list[idx].sci, end) == tmp
|| sci_get_char_at(doc_list[idx].sci, end) == ':')
&& end < last_pos) end++;
*tagname = g_malloc(end - start + 1);
sci_get_text_range(doc_list[idx].sci, start, end, *tagname);
@ -1677,19 +1644,19 @@ gchar *utils_get_hostname(void)
}
gint utils_make_settings_dir(void)
gint utils_make_settings_dir(const gchar *dir)
{
gint error_nr = 0;
gchar *fileytpes_readme = g_strconcat(
app->configdir, G_DIR_SEPARATOR_S, "template.README", NULL);
dir, G_DIR_SEPARATOR_S, "template.README", NULL);
if (! g_file_test(app->configdir, G_FILE_TEST_EXISTS))
if (! g_file_test(dir, G_FILE_TEST_EXISTS))
{
geany_debug("creating config directory %s", app->configdir);
geany_debug("creating config directory %s", dir);
#ifdef GEANY_WIN32
if (mkdir(app->configdir) != 0) error_nr = errno;
if (mkdir(dir) != 0) error_nr = errno;
#else
if (mkdir(app->configdir, 0700) != 0) error_nr = errno;
if (mkdir(dir, 0700) != 0) error_nr = errno;
#endif
}
@ -1698,10 +1665,10 @@ gint utils_make_settings_dir(void)
error_nr = utils_write_file(fileytpes_readme,
"There are several template files in this directory. For these templates you can use wildcards.\n\
For more information read the documentation (in " DOCDIR " or visit " GEANY_HOMEPAGE ").");
{ // check whether write test was successful, otherwise directory is not writeable
/* { // check whether write test was successful, otherwise directory is not writeable
/// FIXME write the code
}
}
*/ }
g_free(fileytpes_readme);
return error_nr;
@ -1905,6 +1872,13 @@ void utils_free_ptr_array(gchar *array[], gint len)
}
void utils_update_fold_items(void)
{
gtk_widget_set_sensitive(lookup_widget(app->window, "menu_fold_all1"), app->pref_editor_folding);
gtk_widget_set_sensitive(lookup_widget(app->window, "menu_unfold_all1"), app->pref_editor_folding);
}
void utils_update_recent_menu(void)
{
GtkWidget *recent_menu = lookup_widget(app->window, "recent_files1_menu");
@ -2221,3 +2195,4 @@ gchar *utils_make_human_readable_str(unsigned long long size, unsigned long bloc
/* If f==fmt then 'frac' and 'u' are ignored. */
return g_strdup_printf(f, val, frac, *u, 'b');
}

View File

@ -161,7 +161,7 @@ void utils_glist_strings_free(GList * list);
gchar *utils_get_hostname(void);
gint utils_make_settings_dir(void);
gint utils_make_settings_dir(const gchar *dir);
gchar *utils_str_replace(gchar *haystack, const gchar *needle, const gchar *replacement);
@ -206,4 +206,6 @@ void utils_beep(void);
gchar *utils_make_human_readable_str(unsigned long long size, unsigned long block_size,
unsigned long display_unit);
void utils_update_fold_items(void);
#endif