diff --git a/ChangeLog b/ChangeLog index 94dd3b72..f9eedcf1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,10 @@ data/filetypes.ferite, data/filetypes.java, src/highlighting.c: Added new style for doc keyword error and added some doc key words for Doxygen and Javadoc. + * geany.glade, src/geany.h, src/interface.c, src/keyfile.c, + src/prefs.c, src/sci_cb.c: + Added new preference to unfold all children of a fold point if the + fold point is unfolded. 2006-12-02 Enrico Tröger diff --git a/geany.glade b/geany.glade index af54efe7..76b5ea2e 100644 --- a/geany.glade +++ b/geany.glade @@ -5130,6 +5130,26 @@ Bottom + + + True + Unfold all children of a fold point when unfolding it. + True + Unfold all children of a fold point + True + GTK_RELIEF_NORMAL + False + False + False + True + + + 0 + False + False + + + True diff --git a/src/geany.h b/src/geany.h index 37c4d871..aefa428e 100644 --- a/src/geany.h +++ b/src/geany.h @@ -105,6 +105,7 @@ typedef struct MyApp gboolean pref_editor_auto_close_xml_tags; gboolean pref_editor_auto_complete_constructs; gboolean pref_editor_folding; + gboolean pref_editor_unfold_all_children; gint pref_editor_tab_width; gint pref_editor_default_encoding; gboolean pref_editor_new_line; diff --git a/src/interface.c b/src/interface.c index 72b42fca..b18aa5a4 100644 --- a/src/interface.c +++ b/src/interface.c @@ -2264,6 +2264,7 @@ create_prefs_dialog (void) GtkWidget *check_auto_indent; GtkWidget *check_line_wrapping; GtkWidget *check_folding; + GtkWidget *check_unfold_children; GtkWidget *check_indicators; GtkWidget *label172; GtkWidget *frame18; @@ -3141,6 +3142,12 @@ create_prefs_dialog (void) 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); + check_unfold_children = gtk_check_button_new_with_mnemonic (_("Unfold all children of a fold point")); + gtk_widget_show (check_unfold_children); + gtk_box_pack_start (GTK_BOX (vbox17), check_unfold_children, FALSE, FALSE, 0); + gtk_tooltips_set_tip (tooltips, check_unfold_children, _("Unfold all children of a fold point when unfolding it."), NULL); + gtk_button_set_focus_on_click (GTK_BUTTON (check_unfold_children), FALSE); + check_indicators = gtk_check_button_new_with_mnemonic (_("Use indicators to show compile errors")); gtk_widget_show (check_indicators); gtk_box_pack_start (GTK_BOX (vbox17), check_indicators, FALSE, FALSE, 0); @@ -3674,6 +3681,7 @@ create_prefs_dialog (void) GLADE_HOOKUP_OBJECT (prefs_dialog, check_auto_indent, "check_auto_indent"); GLADE_HOOKUP_OBJECT (prefs_dialog, check_line_wrapping, "check_line_wrapping"); GLADE_HOOKUP_OBJECT (prefs_dialog, check_folding, "check_folding"); + GLADE_HOOKUP_OBJECT (prefs_dialog, check_unfold_children, "check_unfold_children"); GLADE_HOOKUP_OBJECT (prefs_dialog, check_indicators, "check_indicators"); GLADE_HOOKUP_OBJECT (prefs_dialog, label172, "label172"); GLADE_HOOKUP_OBJECT (prefs_dialog, frame18, "frame18"); diff --git a/src/keyfile.c b/src/keyfile.c index b811c6f9..8364f1d7 100644 --- a/src/keyfile.c +++ b/src/keyfile.c @@ -100,6 +100,7 @@ void configuration_save() g_key_file_set_boolean(config, PACKAGE, "sidebar_visible", app->sidebar_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, "unfold_all_children", app->pref_editor_unfold_all_children); g_key_file_set_boolean(config, PACKAGE, "use_auto_indention", app->pref_editor_use_auto_indention); g_key_file_set_boolean(config, PACKAGE, "use_indicators", app->pref_editor_use_indicators); g_key_file_set_boolean(config, PACKAGE, "show_indent_guide", app->pref_editor_show_indent_guide); @@ -314,6 +315,7 @@ gboolean configuration_load() app->pref_editor_auto_close_xml_tags = utils_get_setting_boolean(config, PACKAGE, "auto_close_xml_tags", TRUE); app->pref_editor_auto_complete_constructs = utils_get_setting_boolean(config, PACKAGE, "auto_complete_constructs", TRUE); app->pref_editor_folding = utils_get_setting_boolean(config, PACKAGE, "use_folding", TRUE); + app->pref_editor_unfold_all_children = utils_get_setting_boolean(config, PACKAGE, "unfold_all_children", FALSE); app->show_markers_margin = utils_get_setting_boolean(config, PACKAGE, "show_markers_margin", TRUE); app->show_linenumber_margin = utils_get_setting_boolean(config, PACKAGE, "show_linenumber_margin", TRUE); app->fullscreen = utils_get_setting_boolean(config, PACKAGE, "fullscreen", FALSE); diff --git a/src/prefs.c b/src/prefs.c index 69e3470c..7aa3064f 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -62,6 +62,7 @@ static void on_dialog_response(GtkWidget *dialog, gint response, gpointer user_d static gboolean find_duplicate(guint idx, guint key, GdkModifierType mods, const gchar *action); static void on_pref_toolbar_show_toggled(GtkToggleButton *togglebutton, gpointer user_data); static void on_pref_show_notebook_tabs_toggled(GtkToggleButton *togglebutton, gpointer user_data); +static void on_pref_use_folding_toggled(GtkToggleButton *togglebutton, gpointer user_data); void prefs_init_dialog(void) @@ -241,6 +242,11 @@ void prefs_init_dialog(void) 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, "check_unfold_children"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), app->pref_editor_unfold_all_children); + on_pref_use_folding_toggled(GTK_TOGGLE_BUTTON( + lookup_widget(app->prefs_dialog, "check_folding")), NULL); + widget = lookup_widget(app->prefs_dialog, "check_indicators"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), app->pref_editor_use_indicators); @@ -514,6 +520,9 @@ void on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_dat app->pref_editor_folding = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); ui_update_fold_items(); + widget = lookup_widget(app->prefs_dialog, "check_unfold_children"); + app->pref_editor_unfold_all_children = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + widget = lookup_widget(app->prefs_dialog, "check_indent"); app->pref_editor_show_indent_guide = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); @@ -647,7 +656,7 @@ void on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_dat // store all settings configuration_save(); } - + if (response != GTK_RESPONSE_APPLY) { gtk_list_store_clear(store); @@ -930,6 +939,14 @@ static void on_pref_show_notebook_tabs_toggled(GtkToggleButton *togglebutton, gp } +static void on_pref_use_folding_toggled(GtkToggleButton *togglebutton, gpointer user_data) +{ + gboolean sens = gtk_toggle_button_get_active(togglebutton); + + gtk_widget_set_sensitive(lookup_widget(app->prefs_dialog, "check_unfold_children"), sens); +} + + void dialogs_show_prefs_dialog(void) { if (app->prefs_dialog == NULL) @@ -981,7 +998,8 @@ void dialogs_show_prefs_dialog(void) "toggled", G_CALLBACK(on_pref_toolbar_show_toggled), NULL); g_signal_connect((gpointer) lookup_widget(app->prefs_dialog, "check_show_notebook_tabs"), "toggled", G_CALLBACK(on_pref_show_notebook_tabs_toggled), NULL); - + g_signal_connect((gpointer) lookup_widget(app->prefs_dialog, "check_folding"), + "toggled", G_CALLBACK(on_pref_use_folding_toggled), NULL); } prefs_init_dialog(); diff --git a/src/sci_cb.c b/src/sci_cb.c index a1af15a2..7ac04f74 100644 --- a/src/sci_cb.c +++ b/src/sci_cb.c @@ -120,9 +120,26 @@ 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); } + // left click on the folding margin to toggle folding state of current line else if (nt->margin == 2 && app->pref_editor_folding) { - SSM(sci, SCI_TOGGLEFOLD, SSM(sci, SCI_LINEFROMPOSITION, nt->position, 0), 0); + gint line = SSM(sci, SCI_LINEFROMPOSITION, nt->position, 0); + + SSM(sci, SCI_TOGGLEFOLD, line, 0); + if (app->pref_editor_unfold_all_children && + SSM(sci, SCI_GETLINEVISIBLE, line + 1, 0)) + { // unfold all children of the current fold point + gint last_line = SSM(sci, SCI_GETLASTCHILD, line, -1); + gint i; + + for (i = line; i < last_line; i++) + { + if (! SSM(sci, SCI_GETLINEVISIBLE, i, 0)) + { + SSM(sci, SCI_TOGGLEFOLD, SSM(sci, SCI_GETFOLDPARENT, i, 0), 0); + } + } + } } break; } @@ -1016,7 +1033,7 @@ void sci_cb_show_macro_list(ScintillaObject *sci) /** * (stolen from anjuta and heavily modified) * This routine will auto complete XML or HTML tags that are still open by closing them - * @parm ch The character we are dealing with, currently only works with the '>' character + * @param ch The character we are dealing with, currently only works with the '>' character * @return True if handled, false otherwise */ @@ -1042,7 +1059,7 @@ gboolean sci_cb_handle_xml(ScintillaObject *sci, gchar ch) if (min < 0) min = 0; if (pos - min < 3) - return FALSE; // Smallest tag is 3 characters ex.

+ return FALSE; // Smallest tag is 3 characters e.g.

sci_get_text_range(sci, min, pos, sel); sel[sizeof(sel) - 1] = '\0';