Added new preference to unfold all children of a fold point if the fold point is unfolded.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1044 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2006-12-03 22:33:46 +00:00
parent 4469c37c42
commit 956e5ad179
7 changed files with 75 additions and 5 deletions

View File

@ -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 <enrico.troeger@uvena.de>

View File

@ -5130,6 +5130,26 @@ Bottom
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="check_unfold_children">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Unfold all children of a fold point when unfolding it.</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Unfold all children of a fold point</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">False</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="check_indicators">
<property name="visible">True</property>

View File

@ -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;

View File

@ -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");

View File

@ -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);

View File

@ -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();

View File

@ -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. <p>
return FALSE; // Smallest tag is 3 characters e.g. <p>
sci_get_text_range(sci, min, pos, sel);
sel[sizeof(sel) - 1] = '\0';