Revision: 3423 http://geany.svn.sourceforge.net/geany/?rev=3423&view=rev Author: ntrel Date: 2008-12-27 12:55:04 +0000 (Sat, 27 Dec 2008)
Log Message: ----------- Add Project Indentation prefs, which override the Editor Preferences dialog options. For new projects, these default to the editor indent prefs. - Plugins: For compatibility with this change, use editor_get_indent_prefs(). - Code changes: The Project Properties dialog is now created by Glade, but (for now) the existing options are added manually. Add GeanyProjectPrivate project field. Add stash_group_set_use_defaults().
Modified Paths: -------------- trunk/ChangeLog trunk/geany.glade trunk/src/Makefile.am trunk/src/editor.c trunk/src/interface.c trunk/src/interface.h trunk/src/main.c trunk/src/project.c trunk/src/project.h trunk/src/stash.c trunk/src/stash.h
Added Paths: ----------- trunk/src/projectprivate.h
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2008-12-25 17:02:56 UTC (rev 3422) +++ trunk/ChangeLog 2008-12-27 12:55:04 UTC (rev 3423) @@ -1,3 +1,20 @@ +2008-12-27 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> + + * src/interface.c, src/interface.h, src/project.c, src/project.h, + src/projectprivate.h, src/stash.c, src/stash.h, src/main.c, + src/editor.c, src/Makefile.am, geany.glade: + Add Project Indentation prefs, which override the Editor + Preferences dialog options. For new projects, these default to the + editor indent prefs. + - Plugins: + For compatibility with this change, use editor_get_indent_prefs(). + - Code changes: + The Project Properties dialog is now created by Glade, but (for + now) the existing options are added manually. + Add GeanyProjectPrivate project field. + Add stash_group_set_use_defaults(). + + 2008-12-22 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/stash.c, src/stash.h, src/keyfile.c:
Modified: trunk/geany.glade =================================================================== --- trunk/geany.glade 2008-12-25 17:02:56 UTC (rev 3422) +++ trunk/geany.glade 2008-12-27 12:55:04 UTC (rev 3423) @@ -8897,4 +8897,418 @@ </child> </widget>
+<widget class="GtkDialog" id="project_dialog"> + <property name="visible">True</property> + <property name="title" translatable="yes">Project Properties</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="has_separator">True</property> + + <child internal-child="vbox"> + <widget class="GtkVBox" id="dialog-vbox4"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child internal-child="action_area"> + <widget class="GtkHButtonBox" id="dialog-action_area4"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + + <child> + <widget class="GtkButton" id="cancelbutton1"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-cancel</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">-6</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="okbutton1"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-ok</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">-5</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">GTK_PACK_END</property> + </packing> + </child> + + <child> + <widget class="GtkNotebook" id="project_notebook"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="show_tabs">True</property> + <property name="show_border">True</property> + <property name="tab_pos">GTK_POS_TOP</property> + <property name="scrollable">False</property> + <property name="enable_popup">False</property> + + <child> + <widget class="GtkTable" id="table17"> + <property name="border_width">6</property> + <property name="visible">True</property> + <property name="n_rows">7</property> + <property name="n_columns">2</property> + <property name="homogeneous">False</property> + <property name="row_spacing">3</property> + <property name="column_spacing">24</property> + + <child> + <widget class="GtkLabel" id="label228"> + <property name="visible">True</property> + <property name="label" translatable="yes">Auto-indent mode:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">6</property> + <property name="bottom_attach">7</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkComboBox" id="combo_auto_indent_mode"> + <property name="visible">True</property> + <property name="items" translatable="yes">None +Basic +Current chars +Match braces</property> + <property name="add_tearoffs">False</property> + <property name="focus_on_click">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">6</property> + <property name="bottom_attach">7</property> + <property name="x_options">fill</property> + <property name="y_options">fill</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label229"> + <property name="visible">True</property> + <property name="label" translatable="yes">Type:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label230"> + <property name="visible">True</property> + <property name="label" translatable="yes">Width:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkSpinButton" id="spin_indent_width"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">The width in chars of a single indent</property> + <property name="can_focus">True</property> + <property name="climb_rate">1</property> + <property name="digits">0</property> + <property name="numeric">True</property> + <property name="update_policy">GTK_UPDATE_IF_VALID</property> + <property name="snap_to_ticks">False</property> + <property name="wrap">True</property> + <property name="adjustment">1 1 99 1 10 0</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">0</property> + <property name="bottom_attach">1</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkRadioButton" id="radio_indent_spaces"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Use spaces when inserting indentation</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">_Spaces</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkRadioButton" id="radio_indent_tabs"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Use one tab per indent</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">_Tabs</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + <property name="group">radio_indent_spaces</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkRadioButton" id="radio_indent_both"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Use spaces if the total indent is less than the tab width, otherwise use both</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">T_abs and Spaces</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + <property name="group">radio_indent_spaces</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + + <child> + <widget class="GtkAlignment" id="alignment44"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">1</property> + <property name="yscale">1</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">24</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkHBox" id="hbox14"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">12</property> + + <child> + <widget class="GtkLabel" id="label231"> + <property name="visible">True</property> + <property name="label" translatable="yes">Hard tab width:</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkSpinButton" id="spin_tab_width"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">The width of a tab when Tabs & Spaces is set for a document</property> + <property name="can_focus">True</property> + <property name="climb_rate">1</property> + <property name="digits">0</property> + <property name="numeric">True</property> + <property name="update_policy">GTK_UPDATE_IF_VALID</property> + <property name="snap_to_ticks">False</property> + <property name="wrap">True</property> + <property name="adjustment">8 1 99 1 10 0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + <property name="x_options">fill</property> + </packing> + </child> + + <child> + <widget class="GtkCheckButton" id="check_detect_indent"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Whether to detect the indentation type from file contents when a file is opened.</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Detect from file</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">5</property> + <property name="bottom_attach">6</property> + <property name="x_options">fill</property> + <property name="y_options"></property> + </packing> + </child> + </widget> + <packing> + <property name="tab_expand">False</property> + <property name="tab_fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label227"> + <property name="visible">True</property> + <property name="label" translatable="yes">Indentation</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="type">tab</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> +</widget> + </glade-interface>
Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2008-12-25 17:02:56 UTC (rev 3422) +++ trunk/src/Makefile.am 2008-12-27 12:55:04 UTC (rev 3423) @@ -3,7 +3,7 @@
EXTRA_DIST = images.c gb.c win32.c win32.h plugindata.h \ - documentprivate.h + documentprivate.h projectprivate.h
bin_PROGRAMS = geany
Modified: trunk/src/editor.c =================================================================== --- trunk/src/editor.c 2008-12-25 17:02:56 UTC (rev 3422) +++ trunk/src/editor.c 2008-12-27 12:55:04 UTC (rev 3423) @@ -57,6 +57,8 @@ #include "geanyobject.h" #include "templates.h" #include "keybindings.h" +#include "project.h" +#include "projectprivate.h"
/* Note: Avoid using SSM in files not related to scintilla, use sciwrappers.h instead. */ @@ -817,8 +819,10 @@ static const GeanyIndentPrefs * get_default_indent_prefs(void) { - /* In future this might depend on the current project. */ - return editor_prefs.indentation; + static GeanyIndentPrefs iprefs; + + iprefs = app->project ? *app->project->priv->indentation : *editor_prefs.indentation; + return &iprefs; }
Modified: trunk/src/interface.c =================================================================== --- trunk/src/interface.c 2008-12-25 17:02:56 UTC (rev 3422) +++ trunk/src/interface.c 2008-12-27 12:55:04 UTC (rev 3423) @@ -4848,3 +4848,197 @@ return prefs_dialog; }
+GtkWidget* +create_project_dialog (void) +{ + GtkWidget *project_dialog; + GtkWidget *dialog_vbox4; + GtkWidget *project_notebook; + GtkWidget *table17; + GtkWidget *label228; + GtkWidget *combo_auto_indent_mode; + GtkWidget *label229; + GtkWidget *label230; + GtkObject *spin_indent_width_adj; + GtkWidget *spin_indent_width; + GtkWidget *radio_indent_spaces; + GSList *radio_indent_spaces_group = NULL; + GtkWidget *radio_indent_tabs; + GtkWidget *radio_indent_both; + GtkWidget *alignment44; + GtkWidget *hbox14; + GtkWidget *label231; + GtkObject *spin_tab_width_adj; + GtkWidget *spin_tab_width; + GtkWidget *check_detect_indent; + GtkWidget *label227; + GtkWidget *dialog_action_area4; + GtkWidget *cancelbutton1; + GtkWidget *okbutton1; + GtkTooltips *tooltips; + + tooltips = gtk_tooltips_new (); + + project_dialog = gtk_dialog_new (); + gtk_window_set_title (GTK_WINDOW (project_dialog), _("Project Properties")); + gtk_window_set_type_hint (GTK_WINDOW (project_dialog), GDK_WINDOW_TYPE_HINT_DIALOG); + + dialog_vbox4 = GTK_DIALOG (project_dialog)->vbox; + gtk_widget_show (dialog_vbox4); + + project_notebook = gtk_notebook_new (); + gtk_widget_show (project_notebook); + gtk_box_pack_start (GTK_BOX (dialog_vbox4), project_notebook, TRUE, TRUE, 0); + + table17 = gtk_table_new (7, 2, FALSE); + gtk_widget_show (table17); + gtk_container_add (GTK_CONTAINER (project_notebook), table17); + gtk_container_set_border_width (GTK_CONTAINER (table17), 6); + gtk_table_set_row_spacings (GTK_TABLE (table17), 3); + gtk_table_set_col_spacings (GTK_TABLE (table17), 24); + + label228 = gtk_label_new (_("Auto-indent mode:")); + gtk_widget_show (label228); + gtk_table_attach (GTK_TABLE (table17), label228, 0, 1, 6, 7, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_misc_set_alignment (GTK_MISC (label228), 0, 0.5); + + combo_auto_indent_mode = gtk_combo_box_new_text (); + gtk_widget_show (combo_auto_indent_mode); + gtk_table_attach (GTK_TABLE (table17), combo_auto_indent_mode, 1, 2, 6, 7, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (GTK_FILL), 0, 0); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_auto_indent_mode), _("None")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_auto_indent_mode), _("Basic")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_auto_indent_mode), _("Current chars")); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_auto_indent_mode), _("Match braces")); + + label229 = gtk_label_new (_("Type:")); + gtk_widget_show (label229); + gtk_table_attach (GTK_TABLE (table17), label229, 0, 1, 1, 2, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_misc_set_alignment (GTK_MISC (label229), 0, 0.5); + + label230 = gtk_label_new (_("Width:")); + gtk_widget_show (label230); + gtk_table_attach (GTK_TABLE (table17), label230, 0, 1, 0, 1, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_misc_set_alignment (GTK_MISC (label230), 0, 0.5); + + spin_indent_width_adj = gtk_adjustment_new (1, 1, 99, 1, 10, 0); + spin_indent_width = gtk_spin_button_new (GTK_ADJUSTMENT (spin_indent_width_adj), 1, 0); + gtk_widget_show (spin_indent_width); + gtk_table_attach (GTK_TABLE (table17), spin_indent_width, 1, 2, 0, 1, + (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_tooltips_set_tip (tooltips, spin_indent_width, _("The width in chars of a single indent"), NULL); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spin_indent_width), TRUE); + gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (spin_indent_width), GTK_UPDATE_IF_VALID); + gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spin_indent_width), TRUE); + + radio_indent_spaces = gtk_radio_button_new_with_mnemonic (NULL, _("_Spaces")); + gtk_widget_show (radio_indent_spaces); + gtk_table_attach (GTK_TABLE (table17), radio_indent_spaces, 1, 2, 2, 3, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_tooltips_set_tip (tooltips, radio_indent_spaces, _("Use spaces when inserting indentation"), NULL); + gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_indent_spaces), radio_indent_spaces_group); + radio_indent_spaces_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_indent_spaces)); + + radio_indent_tabs = gtk_radio_button_new_with_mnemonic (NULL, _("_Tabs")); + gtk_widget_show (radio_indent_tabs); + gtk_table_attach (GTK_TABLE (table17), radio_indent_tabs, 1, 2, 1, 2, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_tooltips_set_tip (tooltips, radio_indent_tabs, _("Use one tab per indent"), NULL); + gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_indent_tabs), radio_indent_spaces_group); + radio_indent_spaces_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_indent_tabs)); + + radio_indent_both = gtk_radio_button_new_with_mnemonic (NULL, _("T_abs and Spaces")); + gtk_widget_show (radio_indent_both); + gtk_table_attach (GTK_TABLE (table17), radio_indent_both, 1, 2, 3, 4, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_tooltips_set_tip (tooltips, radio_indent_both, _("Use spaces if the total indent is less than the tab width, otherwise use both"), NULL); + gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_indent_both), radio_indent_spaces_group); + radio_indent_spaces_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_indent_both)); + + alignment44 = gtk_alignment_new (0.5, 0.5, 1, 1); + gtk_widget_show (alignment44); + gtk_table_attach (GTK_TABLE (table17), alignment44, 1, 2, 4, 5, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); + gtk_alignment_set_padding (GTK_ALIGNMENT (alignment44), 0, 0, 24, 0); + + hbox14 = gtk_hbox_new (FALSE, 12); + gtk_widget_show (hbox14); + gtk_container_add (GTK_CONTAINER (alignment44), hbox14); + + label231 = gtk_label_new (_("Hard tab width:")); + gtk_widget_show (label231); + gtk_box_pack_start (GTK_BOX (hbox14), label231, FALSE, FALSE, 0); + + spin_tab_width_adj = gtk_adjustment_new (8, 1, 99, 1, 10, 0); + spin_tab_width = gtk_spin_button_new (GTK_ADJUSTMENT (spin_tab_width_adj), 1, 0); + gtk_widget_show (spin_tab_width); + gtk_box_pack_start (GTK_BOX (hbox14), spin_tab_width, TRUE, TRUE, 0); + gtk_tooltips_set_tip (tooltips, spin_tab_width, _("The width of a tab when Tabs & Spaces is set for a document"), NULL); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spin_tab_width), TRUE); + gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (spin_tab_width), GTK_UPDATE_IF_VALID); + gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spin_tab_width), TRUE); + + check_detect_indent = gtk_check_button_new_with_mnemonic (_("Detect from file")); + gtk_widget_show (check_detect_indent); + gtk_table_attach (GTK_TABLE (table17), check_detect_indent, 1, 2, 5, 6, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + gtk_tooltips_set_tip (tooltips, check_detect_indent, _("Whether to detect the indentation type from file contents when a file is opened."), NULL); + + label227 = gtk_label_new (_("Indentation")); + gtk_widget_show (label227); + gtk_notebook_set_tab_label (GTK_NOTEBOOK (project_notebook), gtk_notebook_get_nth_page (GTK_NOTEBOOK (project_notebook), 0), label227); + + dialog_action_area4 = GTK_DIALOG (project_dialog)->action_area; + gtk_widget_show (dialog_action_area4); + gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area4), GTK_BUTTONBOX_END); + + cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel"); + gtk_widget_show (cancelbutton1); + gtk_dialog_add_action_widget (GTK_DIALOG (project_dialog), cancelbutton1, GTK_RESPONSE_CANCEL); + GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT); + + okbutton1 = gtk_button_new_from_stock ("gtk-ok"); + gtk_widget_show (okbutton1); + gtk_dialog_add_action_widget (GTK_DIALOG (project_dialog), okbutton1, GTK_RESPONSE_OK); + GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT); + + /* Store pointers to all widgets, for use by lookup_widget(). */ + GLADE_HOOKUP_OBJECT_NO_REF (project_dialog, project_dialog, "project_dialog"); + GLADE_HOOKUP_OBJECT_NO_REF (project_dialog, dialog_vbox4, "dialog_vbox4"); + GLADE_HOOKUP_OBJECT (project_dialog, project_notebook, "project_notebook"); + GLADE_HOOKUP_OBJECT (project_dialog, table17, "table17"); + GLADE_HOOKUP_OBJECT (project_dialog, label228, "label228"); + GLADE_HOOKUP_OBJECT (project_dialog, combo_auto_indent_mode, "combo_auto_indent_mode"); + GLADE_HOOKUP_OBJECT (project_dialog, label229, "label229"); + GLADE_HOOKUP_OBJECT (project_dialog, label230, "label230"); + GLADE_HOOKUP_OBJECT (project_dialog, spin_indent_width, "spin_indent_width"); + GLADE_HOOKUP_OBJECT (project_dialog, radio_indent_spaces, "radio_indent_spaces"); + GLADE_HOOKUP_OBJECT (project_dialog, radio_indent_tabs, "radio_indent_tabs"); + GLADE_HOOKUP_OBJECT (project_dialog, radio_indent_both, "radio_indent_both"); + GLADE_HOOKUP_OBJECT (project_dialog, alignment44, "alignment44"); + GLADE_HOOKUP_OBJECT (project_dialog, hbox14, "hbox14"); + GLADE_HOOKUP_OBJECT (project_dialog, label231, "label231"); + GLADE_HOOKUP_OBJECT (project_dialog, spin_tab_width, "spin_tab_width"); + GLADE_HOOKUP_OBJECT (project_dialog, check_detect_indent, "check_detect_indent"); + GLADE_HOOKUP_OBJECT (project_dialog, label227, "label227"); + GLADE_HOOKUP_OBJECT_NO_REF (project_dialog, dialog_action_area4, "dialog_action_area4"); + GLADE_HOOKUP_OBJECT (project_dialog, cancelbutton1, "cancelbutton1"); + GLADE_HOOKUP_OBJECT (project_dialog, okbutton1, "okbutton1"); + GLADE_HOOKUP_OBJECT_NO_REF (project_dialog, tooltips, "tooltips"); + + return project_dialog; +} +
Modified: trunk/src/interface.h =================================================================== --- trunk/src/interface.h 2008-12-25 17:02:56 UTC (rev 3422) +++ trunk/src/interface.h 2008-12-27 12:55:04 UTC (rev 3423) @@ -6,3 +6,4 @@ GtkWidget* create_toolbar_popup_menu1 (void); GtkWidget* create_edit_menu1 (void); GtkWidget* create_prefs_dialog (void); +GtkWidget* create_project_dialog (void);
Modified: trunk/src/main.c =================================================================== --- trunk/src/main.c 2008-12-25 17:02:56 UTC (rev 3422) +++ trunk/src/main.c 2008-12-27 12:55:04 UTC (rev 3423) @@ -919,6 +919,7 @@
encodings_init(); editor_init(); + project_init();
configuration_init(); search_init(); @@ -1051,6 +1052,7 @@ build_finalize(); document_finalize(); symbols_finalize(); + project_finalize(); editor_finalize(); editor_snippets_free(); encodings_finalize();
Modified: trunk/src/project.c =================================================================== --- trunk/src/project.c 2008-12-25 17:02:56 UTC (rev 3422) +++ trunk/src/project.c 2008-12-27 12:55:04 UTC (rev 3423) @@ -31,6 +31,8 @@ #include <unistd.h>
#include "project.h" +#include "projectprivate.h" + #include "dialogs.h" #include "support.h" #include "utils.h" @@ -44,10 +46,19 @@ #endif #include "build.h" #include "geanyobject.h" +#include "interface.h" +#include "editor.h" +#include "stash.h"
ProjectPrefs project_prefs = { NULL, FALSE, FALSE };
+ +static GeanyProjectPrivate priv; +static GeanyIndentPrefs indentation; + +static GeanyPrefGroup *indent_group = NULL; + static struct { gchar *project_file_path; /* in UTF-8 */ @@ -341,23 +352,20 @@
static void create_properties_dialog(PropertyDialogElements *e) { - GtkWidget *vbox; - GtkWidget *table; + GtkWidget *table, *notebook; GtkWidget *image; GtkWidget *button; GtkWidget *bbox; GtkWidget *label; GtkWidget *swin;
- e->dialog = gtk_dialog_new_with_buttons(_("Project Properties"), GTK_WINDOW(main_widgets.window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); - gtk_dialog_add_buttons(GTK_DIALOG(e->dialog), GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); + e->dialog = create_project_dialog(); + gtk_window_set_transient_for(GTK_WINDOW(e->dialog), GTK_WINDOW(main_widgets.window)); + gtk_window_set_destroy_with_parent(GTK_WINDOW(e->dialog), TRUE); gtk_widget_set_name(e->dialog, "GeanyDialogProject");
- vbox = ui_dialog_vbox_new(GTK_DIALOG(e->dialog)); - table = gtk_table_new(6, 2, FALSE); + gtk_container_set_border_width(GTK_CONTAINER(table), 6); gtk_table_set_row_spacings(GTK_TABLE(table), 5); gtk_table_set_col_spacings(GTK_TABLE(table), 10);
@@ -465,7 +473,11 @@ (GtkAttachOptions) (0), 0, 0); #endif
- gtk_container_add(GTK_CONTAINER(vbox), table); + notebook = ui_lookup_widget(e->dialog, "project_notebook"); + label = gtk_label_new(_("Project")); + gtk_widget_show(table); /* needed to switch current page */ + gtk_notebook_insert_page(GTK_NOTEBOOK(notebook), table, label, 0); + gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0); }
@@ -481,6 +493,8 @@
create_properties_dialog(e);
+ stash_group_display(indent_group, e->dialog); + /* fill the elements with the appropriate data */ gtk_entry_set_text(GTK_ENTRY(e->name), p->name);
@@ -526,6 +540,8 @@ { if (! update_config(e)) goto retry; + + stash_group_update(indent_group, e->dialog); }
gtk_widget_destroy(e->dialog); @@ -555,6 +571,20 @@ }
+static GeanyProject *create_project(void) +{ + GeanyProject *project = g_new0(GeanyProject, 1); + + memset(&priv, 0, sizeof priv); + indentation = *editor_get_indent_prefs(NULL); + priv.indentation = &indentation; + project->priv = &priv; + + app->project = project; + return project; +} + + /* Verifies data for New & Properties dialogs. * Returns: FALSE if the user needs to change any data. */ static gboolean update_config(const PropertyDialogElements *e) @@ -640,7 +670,7 @@
if (app->project == NULL) { - app->project = g_new0(GeanyProject, 1); + create_project(); new_project = TRUE; } p = app->project; @@ -887,8 +917,10 @@ return FALSE; }
- p = app->project = g_new0(GeanyProject, 1); + p = create_project();
+ stash_group_load_from_key_file(indent_group, config); + p->name = utils_get_setting_string(config, "project", "name", GEANY_STRING_UNTITLED); p->description = utils_get_setting_string(config, "project", "description", ""); p->file_name = utils_get_utf8_from_locale(filename); @@ -936,6 +968,8 @@ filename = utils_get_locale_from_utf8(p->file_name); g_key_file_load_from_file(config, filename, G_KEY_FILE_NONE, NULL);
+ stash_group_save_to_key_file(indent_group, config); + g_key_file_set_string(config, "project", "name", p->name); g_key_file_set_string(config, "project", "base_path", p->base_path);
@@ -1066,3 +1100,34 @@ }
+void project_init(void) +{ + GeanyPrefGroup *group; + + group = stash_group_new("indentation"); + /* defaults are copied from editor indent prefs */ + stash_group_set_use_defaults(group, FALSE); + indent_group = group; + + stash_group_add_spin_button_integer(group, &indentation.width, + "indent_width", 4, "spin_indent_width"); + stash_group_add_radio_buttons(group, (gint*)&indentation.type, + "indent_type", GEANY_INDENT_TYPE_TABS, + "radio_indent_spaces", GEANY_INDENT_TYPE_SPACES, + "radio_indent_tabs", GEANY_INDENT_TYPE_TABS, + "radio_indent_both", GEANY_INDENT_TYPE_BOTH, + NULL); + stash_group_add_spin_button_integer(group, &indentation.hard_tab_width, + "indent_hard_tab_width", 8, "spin_tab_width"); + stash_group_add_toggle_button(group, &indentation.detect_type, + "detect_indent", FALSE, "check_detect_indent"); + stash_group_add_combo_box(group, (gint*)&indentation.auto_indent_mode, + "indent_mode", GEANY_AUTOINDENT_CURRENTCHARS, "combo_auto_indent_mode"); +} + + +void project_finalize(void) +{ + stash_group_free(indent_group); +} +
Modified: trunk/src/project.h =================================================================== --- trunk/src/project.h 2008-12-25 17:02:56 UTC (rev 3422) +++ trunk/src/project.h 2008-12-27 12:55:04 UTC (rev 3423) @@ -41,6 +41,8 @@ gint type; gchar **file_patterns; /**< Array of filename extension patterns. */ gboolean make_in_base_path; + + struct GeanyProjectPrivate *priv; /* must be last, append fields before this item */ } GeanyProject;
@@ -55,6 +57,11 @@ extern ProjectPrefs project_prefs;
+void project_init(void); + +void project_finalize(void); + + void project_new(void);
void project_open(void);
Added: trunk/src/projectprivate.h =================================================================== --- trunk/src/projectprivate.h (rev 0) +++ trunk/src/projectprivate.h 2008-12-27 12:55:04 UTC (rev 3423) @@ -0,0 +1,37 @@ +/* + * projectprivate.h - this file is part of Geany, a fast and lightweight IDE + * + * Copyright 2008 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> + * Copyright 2008 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * $Id$ + */ + + +#ifndef GEANY_PROJECTPRIVATE_H +#define GEANY_PROJECTPRIVATE_H 1 + + +typedef struct GeanyProjectPrivate +{ + struct GeanyIndentPrefs *indentation; +} +GeanyProjectPrivate; + + +#endif
Property changes on: trunk/src/projectprivate.h ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native
Modified: trunk/src/stash.c =================================================================== --- trunk/src/stash.c 2008-12-25 17:02:56 UTC (rev 3422) +++ trunk/src/stash.c 2008-12-27 12:55:04 UTC (rev 3423) @@ -74,6 +74,7 @@ const gchar *name; /* group name to use in the keyfile */ GArray *entries; /* array of GeanyPrefEntry */ gboolean write_once; /* only write settings if they don't already exist */ + gboolean use_defaults; /* use default values if there's no keyfile entry */ };
typedef struct EnumWidget @@ -160,9 +161,14 @@
foreach_array(GeanyPrefEntry, entry, group->entries) { + /* don't overwrite write_once prefs */ if (group->write_once && action == SETTING_WRITE && g_key_file_has_key(keyfile, group->name, entry->key_name, NULL)) - continue; /* don't overwrite write_once prefs */ + continue; + /* don't override settings with default values */ + if (!group->use_defaults && action == SETTING_READ && + !g_key_file_has_key(keyfile, group->name, entry->key_name, NULL)) + continue;
switch (entry->setting_type) { @@ -198,6 +204,7 @@
group->name = name; group->entries = g_array_new(FALSE, FALSE, sizeof(GeanyPrefEntry)); + group->use_defaults = TRUE; return group; }
@@ -218,12 +225,24 @@ }
+/* Useful so the user can edit the keyfile manually while the program is running, + * and the setting won't be overridden. + * @c FALSE by default. */ void stash_group_set_write_once(GeanyPrefGroup *group, gboolean write_once) { group->write_once = write_once; }
+/* When @c FALSE, Stash doesn't change the setting if there is no keyfile entry, so it + * remains whatever it was initialized/set to by user code. + * @c TRUE by default. */ +void stash_group_set_use_defaults(GeanyPrefGroup *group, gboolean use_defaults) +{ + group->use_defaults = use_defaults; +} + + static GeanyPrefEntry * add_pref(GeanyPrefGroup *group, GType type, gpointer setting, const gchar *key_name, gpointer default_value)
Modified: trunk/src/stash.h =================================================================== --- trunk/src/stash.h 2008-12-25 17:02:56 UTC (rev 3422) +++ trunk/src/stash.h 2008-12-27 12:55:04 UTC (rev 3423) @@ -34,6 +34,8 @@
void stash_group_set_write_once(GeanyPrefGroup *group, gboolean write_once);
+void stash_group_set_use_defaults(GeanyPrefGroup *group, gboolean use_defaults); + void stash_group_add_boolean(GeanyPrefGroup *group, gboolean *setting, const gchar *key_name, gboolean default_value);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.