Revision: 2724 http://geany.svn.sourceforge.net/geany/?rev=2724&view=rev Author: ntrel Date: 2008-06-25 04:56:58 -0700 (Wed, 25 Jun 2008)
Log Message: ----------- Move 2 search prefs to new Search tab of Preferences dialog. Add new search pref: 'Use the current file's directory for Find in Files' (#1930435). Add PrefEntry struct which is used for an array containing widget names to lookup; currently only used for 3 search-related GtkToggleButton prefs. Add SettingEntry struct which is used for an array containing keyfile key and group information; currently only used for 3 search-related gboolean settings.
Modified Paths: -------------- trunk/ChangeLog trunk/geany.glade trunk/src/interface.c trunk/src/keyfile.c trunk/src/prefs.c trunk/src/search.c trunk/src/search.h
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2008-06-24 14:32:54 UTC (rev 2723) +++ trunk/ChangeLog 2008-06-25 11:56:58 UTC (rev 2724) @@ -1,3 +1,18 @@ +2008-06-25 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> + + * src/interface.c, src/prefs.c, src/keyfile.c, src/search.c, + src/search.h, geany.glade: + Move 2 search prefs to new Search tab of Preferences dialog. + Add new search pref: 'Use the current file's directory for Find in + Files' (#1930435). + Add PrefEntry struct which is used for an array containing widget + names to lookup; currently only used for 3 search-related + GtkToggleButton prefs. + Add SettingEntry struct which is used for an array containing keyfile + key and group information; currently only used for 3 search-related + gboolean settings. + + 2008-06-24 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/keybindings.c:
Modified: trunk/geany.glade =================================================================== --- trunk/geany.glade 2008-06-24 14:32:54 UTC (rev 2723) +++ trunk/geany.glade 2008-06-25 11:56:58 UTC (rev 2724) @@ -3548,44 +3548,6 @@ <property name="fill">False</property> </packing> </child> - - <child> - <widget class="GtkCheckButton" id="check_ask_suppress_search_dialogs"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">Always wrap search around the document and hide the Find dialog after clicking Find Next/Previous</property> - <property name="label" translatable="yes">Always wrap search and hide the Find dialog</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_search_use_current_word"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">Use current word under the cursor when opening the Find, Find in Files or Replace dialog and there is no selection.</property> - <property name="label" translatable="yes">Use the current word under the cursor for Find dialogs</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> </widget> </child> </widget> @@ -7167,6 +7129,144 @@ </child>
<child> + <widget class="GtkFrame" id="frame36"> + <property name="visible">True</property> + <property name="label_xalign">0</property> + <property name="label_yalign">0.5</property> + <property name="shadow_type">GTK_SHADOW_NONE</property> + + <child> + <widget class="GtkAlignment" id="alignment39"> + <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">12</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkVBox" id="vbox36"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child> + <widget class="GtkCheckButton" id="check_ask_suppress_search_dialogs"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Always wrap search around the document and hide the Find dialog after clicking Find Next/Previous</property> + <property name="label" translatable="yes">Always wrap search and hide the Find dialog</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_search_use_current_word"> + <property name="visible">True</property> + <property name="tooltip" translatable="yes">Use current word under the cursor when opening the Find, Find in Files or Replace dialog and there is no selection.</property> + <property name="label" translatable="yes">Use the current word under the cursor for Find dialogs</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_fif_current_dir"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Use the current file's directory for Find in Files</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="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + + <child> + <widget class="GtkLabel" id="label215"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Search</b></property> + <property name="use_underline">False</property> + <property name="use_markup">True</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">label_item</property> + </packing> + </child> + </widget> + <packing> + <property name="tab_expand">False</property> + <property name="tab_fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label214"> + <property name="visible">True</property> + <property name="label" translatable="yes">Search</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> + + <child> <widget class="GtkVBox" id="vbox23"> <property name="visible">True</property> <property name="homogeneous">False</property>
Modified: trunk/src/interface.c =================================================================== --- trunk/src/interface.c 2008-06-24 14:32:54 UTC (rev 2723) +++ trunk/src/interface.c 2008-06-25 11:56:58 UTC (rev 2724) @@ -2511,8 +2511,6 @@ GtkWidget *check_switch_pages; GtkWidget *check_suppress_status_msgs; GtkWidget *check_auto_focus; - GtkWidget *check_ask_suppress_search_dialogs; - GtkWidget *check_search_use_current_word; GtkWidget *label199; GtkWidget *frame25; GtkWidget *alignment28; @@ -2714,6 +2712,14 @@ GtkWidget *spin_disk_check; GtkWidget *label198; GtkWidget *label174; + GtkWidget *frame36; + GtkWidget *alignment39; + GtkWidget *vbox36; + GtkWidget *check_ask_suppress_search_dialogs; + GtkWidget *check_search_use_current_word; + GtkWidget *check_fif_current_dir; + GtkWidget *label215; + GtkWidget *label214; GtkWidget *vbox23; GtkWidget *frame20; GtkWidget *alignment23; @@ -2957,20 +2963,6 @@ gtk_tooltips_set_tip (tooltips, check_auto_focus, _("Gives the focus automatically to widgets below the mouse cursor. Works for the main editor widget, the scribble, the toolbar search and goto line fields and the VTE."), NULL); gtk_button_set_focus_on_click (GTK_BUTTON (check_auto_focus), FALSE);
- check_ask_suppress_search_dialogs = gtk_check_button_new_with_mnemonic (_("Always wrap search and hide the Find dialog")); - gtk_widget_show (check_ask_suppress_search_dialogs); - gtk_box_pack_start (GTK_BOX (vbox21), check_ask_suppress_search_dialogs, FALSE, FALSE, 0); - GTK_WIDGET_UNSET_FLAGS (check_ask_suppress_search_dialogs, GTK_CAN_FOCUS); - gtk_tooltips_set_tip (tooltips, check_ask_suppress_search_dialogs, _("Always wrap search around the document and hide the Find dialog after clicking Find Next/Previous"), NULL); - gtk_button_set_focus_on_click (GTK_BUTTON (check_ask_suppress_search_dialogs), FALSE); - - check_search_use_current_word = gtk_check_button_new_with_mnemonic (_("Use the current word under the cursor for Find dialogs")); - gtk_widget_show (check_search_use_current_word); - gtk_box_pack_start (GTK_BOX (vbox21), check_search_use_current_word, FALSE, FALSE, 0); - GTK_WIDGET_UNSET_FLAGS (check_search_use_current_word, GTK_CAN_FOCUS); - gtk_tooltips_set_tip (tooltips, check_search_use_current_word, _("Use current word under the cursor when opening the Find, Find in Files or Replace dialog and there is no selection."), NULL); - gtk_button_set_focus_on_click (GTK_BUTTON (check_search_use_current_word), FALSE); - label199 = gtk_label_new (_("<b>Miscellaneous</b>")); gtk_widget_show (label199); gtk_frame_set_label_widget (GTK_FRAME (frame19), label199); @@ -4091,6 +4083,47 @@ gtk_widget_show (label174); gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 4), label174);
+ frame36 = gtk_frame_new (NULL); + gtk_widget_show (frame36); + gtk_container_add (GTK_CONTAINER (notebook2), frame36); + gtk_frame_set_shadow_type (GTK_FRAME (frame36), GTK_SHADOW_NONE); + + alignment39 = gtk_alignment_new (0.5, 0.5, 1, 1); + gtk_widget_show (alignment39); + gtk_container_add (GTK_CONTAINER (frame36), alignment39); + gtk_alignment_set_padding (GTK_ALIGNMENT (alignment39), 0, 0, 12, 0); + + vbox36 = gtk_vbox_new (FALSE, 0); + gtk_widget_show (vbox36); + gtk_container_add (GTK_CONTAINER (alignment39), vbox36); + + check_ask_suppress_search_dialogs = gtk_check_button_new_with_mnemonic (_("Always wrap search and hide the Find dialog")); + gtk_widget_show (check_ask_suppress_search_dialogs); + gtk_box_pack_start (GTK_BOX (vbox36), check_ask_suppress_search_dialogs, FALSE, FALSE, 0); + GTK_WIDGET_UNSET_FLAGS (check_ask_suppress_search_dialogs, GTK_CAN_FOCUS); + gtk_tooltips_set_tip (tooltips, check_ask_suppress_search_dialogs, _("Always wrap search around the document and hide the Find dialog after clicking Find Next/Previous"), NULL); + gtk_button_set_focus_on_click (GTK_BUTTON (check_ask_suppress_search_dialogs), FALSE); + + check_search_use_current_word = gtk_check_button_new_with_mnemonic (_("Use the current word under the cursor for Find dialogs")); + gtk_widget_show (check_search_use_current_word); + gtk_box_pack_start (GTK_BOX (vbox36), check_search_use_current_word, FALSE, FALSE, 0); + GTK_WIDGET_UNSET_FLAGS (check_search_use_current_word, GTK_CAN_FOCUS); + gtk_tooltips_set_tip (tooltips, check_search_use_current_word, _("Use current word under the cursor when opening the Find, Find in Files or Replace dialog and there is no selection."), NULL); + gtk_button_set_focus_on_click (GTK_BUTTON (check_search_use_current_word), FALSE); + + check_fif_current_dir = gtk_check_button_new_with_mnemonic (_("Use the current file's directory for Find in Files")); + gtk_widget_show (check_fif_current_dir); + gtk_box_pack_start (GTK_BOX (vbox36), check_fif_current_dir, FALSE, FALSE, 0); + + label215 = gtk_label_new (_("<b>Search</b>")); + gtk_widget_show (label215); + gtk_frame_set_label_widget (GTK_FRAME (frame36), label215); + gtk_label_set_use_markup (GTK_LABEL (label215), TRUE); + + label214 = gtk_label_new (_("Search")); + gtk_widget_show (label214); + gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 5), label214); + vbox23 = gtk_vbox_new (FALSE, 10); gtk_widget_show (vbox23); gtk_container_add (GTK_CONTAINER (notebook2), vbox23); @@ -4266,7 +4299,7 @@
label96 = gtk_label_new (_("Tools")); gtk_widget_show (label96); - gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 5), label96); + gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 6), label96);
frame21 = gtk_frame_new (NULL); gtk_widget_show (frame21); @@ -4369,7 +4402,7 @@
label119 = gtk_label_new (_("Templates")); gtk_widget_show (label119); - gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 6), label119); + gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 7), label119);
frame22 = gtk_frame_new (NULL); gtk_widget_show (frame22); @@ -4416,7 +4449,7 @@
label151 = gtk_label_new (_("Keybindings")); gtk_widget_show (label151); - gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 7), label151); + gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 8), label151);
vbox27 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox27); @@ -4536,7 +4569,7 @@
label201 = gtk_label_new (_("Printing")); gtk_widget_show (label201); - gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 8), label201); + gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 9), label201);
dialog_action_area3 = GTK_DIALOG (prefs_dialog)->action_area; gtk_widget_show (dialog_action_area3); @@ -4587,8 +4620,6 @@ GLADE_HOOKUP_OBJECT (prefs_dialog, check_switch_pages, "check_switch_pages"); GLADE_HOOKUP_OBJECT (prefs_dialog, check_suppress_status_msgs, "check_suppress_status_msgs"); GLADE_HOOKUP_OBJECT (prefs_dialog, check_auto_focus, "check_auto_focus"); - GLADE_HOOKUP_OBJECT (prefs_dialog, check_ask_suppress_search_dialogs, "check_ask_suppress_search_dialogs"); - GLADE_HOOKUP_OBJECT (prefs_dialog, check_search_use_current_word, "check_search_use_current_word"); GLADE_HOOKUP_OBJECT (prefs_dialog, label199, "label199"); GLADE_HOOKUP_OBJECT (prefs_dialog, frame25, "frame25"); GLADE_HOOKUP_OBJECT (prefs_dialog, alignment28, "alignment28"); @@ -4778,6 +4809,14 @@ GLADE_HOOKUP_OBJECT (prefs_dialog, spin_disk_check, "spin_disk_check"); GLADE_HOOKUP_OBJECT (prefs_dialog, label198, "label198"); GLADE_HOOKUP_OBJECT (prefs_dialog, label174, "label174"); + GLADE_HOOKUP_OBJECT (prefs_dialog, frame36, "frame36"); + GLADE_HOOKUP_OBJECT (prefs_dialog, alignment39, "alignment39"); + GLADE_HOOKUP_OBJECT (prefs_dialog, vbox36, "vbox36"); + GLADE_HOOKUP_OBJECT (prefs_dialog, check_ask_suppress_search_dialogs, "check_ask_suppress_search_dialogs"); + GLADE_HOOKUP_OBJECT (prefs_dialog, check_search_use_current_word, "check_search_use_current_word"); + GLADE_HOOKUP_OBJECT (prefs_dialog, check_fif_current_dir, "check_fif_current_dir"); + GLADE_HOOKUP_OBJECT (prefs_dialog, label215, "label215"); + GLADE_HOOKUP_OBJECT (prefs_dialog, label214, "label214"); GLADE_HOOKUP_OBJECT (prefs_dialog, vbox23, "vbox23"); GLADE_HOOKUP_OBJECT (prefs_dialog, frame20, "frame20"); GLADE_HOOKUP_OBJECT (prefs_dialog, alignment23, "alignment23");
Modified: trunk/src/keyfile.c =================================================================== --- trunk/src/keyfile.c 2008-06-24 14:32:54 UTC (rev 2723) +++ trunk/src/keyfile.c 2008-06-25 11:56:58 UTC (rev 2724) @@ -89,6 +89,25 @@ static gint vpan_position;
+/* Used in e.g. save_bool_prefs(). */ +typedef struct SettingEntry +{ + const gchar *group; + const gchar *key_name; + gpointer setting; + gpointer default_value; +} +SettingEntry; + +static SettingEntry bool_prefs[] = +{ + {PACKAGE, "pref_main_suppress_search_dialogs", &search_prefs.suppress_dialogs, GINT_TO_POINTER(FALSE)}, + {PACKAGE, "pref_main_search_use_current_word", &search_prefs.use_current_word, GINT_TO_POINTER(TRUE)}, + {"search", "pref_search_current_file_dir", &search_prefs.use_current_file_dir, GINT_TO_POINTER(TRUE)}, + {NULL, NULL, NULL, NULL} /* must be terminated */ +}; + + static void save_recent_files(GKeyFile *config) { gchar **recent_files = g_new0(gchar*, file_prefs.mru_length + 1); @@ -184,8 +203,21 @@ }
+static void save_bool_prefs(GKeyFile *config) +{ + SettingEntry *pe; + + for (pe = bool_prefs; pe->group != NULL; pe++) + { + g_key_file_set_boolean(config, pe->group, pe->key_name, *(gboolean*)pe->setting); + } +} + + static void save_dialog_prefs(GKeyFile *config) { + save_bool_prefs(config); + /* Some of the key names are not consistent, but this is for backwards compatibility */
/* general */ @@ -193,8 +225,6 @@ g_key_file_set_boolean(config, PACKAGE, "pref_main_project_session", project_prefs.project_session); g_key_file_set_boolean(config, PACKAGE, "pref_main_save_winpos", prefs.save_winpos); g_key_file_set_boolean(config, PACKAGE, "pref_main_confirm_exit", prefs.confirm_exit); - g_key_file_set_boolean(config, PACKAGE, "pref_main_suppress_search_dialogs", search_prefs.suppress_dialogs); - g_key_file_set_boolean(config, PACKAGE, "pref_main_search_use_current_word", search_prefs.use_current_word); g_key_file_set_boolean(config, PACKAGE, "pref_main_suppress_status_messages", prefs.suppress_status_messages); g_key_file_set_boolean(config, PACKAGE, "switch_msgwin_pages", prefs.switch_to_status); g_key_file_set_boolean(config, PACKAGE, "beep_on_errors", prefs.beep_on_errors); @@ -476,6 +506,18 @@ }
+static void load_bool_prefs(GKeyFile *config) +{ + SettingEntry *pe; + + for (pe = bool_prefs; pe->group != NULL; pe++) + { + *(gboolean*)pe->setting = utils_get_setting_boolean(config, pe->group, pe->key_name, + GPOINTER_TO_INT(pe->default_value)); + } +} + + #define GEANY_GET_SETTING(propertyname, value, default_value) \ if (g_object_class_find_property( \ G_OBJECT_GET_CLASS(G_OBJECT(gtk_settings_get_default())), propertyname)) \ @@ -489,10 +531,10 @@ gchar *tmp_string, *tmp_string2; const gchar *default_charset = NULL;
+ load_bool_prefs(config); + /* general */ prefs.confirm_exit = utils_get_setting_boolean(config, PACKAGE, "pref_main_confirm_exit", FALSE); - search_prefs.suppress_dialogs = utils_get_setting_boolean(config, PACKAGE, "pref_main_suppress_search_dialogs", FALSE); - search_prefs.use_current_word = utils_get_setting_boolean(config, PACKAGE, "pref_main_search_use_current_word", TRUE); prefs.suppress_status_messages = utils_get_setting_boolean(config, PACKAGE, "pref_main_suppress_status_messages", FALSE); prefs.load_session = utils_get_setting_boolean(config, PACKAGE, "pref_main_load_session", TRUE); project_prefs.project_session = utils_get_setting_boolean(config, PACKAGE, "pref_main_project_session", TRUE);
Modified: trunk/src/prefs.c =================================================================== --- trunk/src/prefs.c 2008-06-24 14:32:54 UTC (rev 2723) +++ trunk/src/prefs.c 2008-06-25 11:56:58 UTC (rev 2724) @@ -89,6 +89,23 @@ static void on_prefs_print_page_header_toggled(GtkToggleButton *togglebutton, gpointer user_data);
+/* used in e.g. init_toggle_button_prefs(). */ +typedef struct PrefEntry +{ + const gchar *widget_name; + gpointer setting; +} +PrefEntry; + +static PrefEntry toggle_prefs[] = +{ + {"check_ask_suppress_search_dialogs", &search_prefs.suppress_dialogs}, + {"check_search_use_current_word", &search_prefs.use_current_word}, + {"check_fif_current_dir", &search_prefs.use_current_file_dir}, + {NULL, NULL} /* must be terminated */ +}; + + enum { KB_TREE_ACTION, @@ -162,11 +179,26 @@ }
+static void init_toggle_button_prefs() +{ + PrefEntry *pe; + + for (pe = toggle_prefs; pe->widget_name != NULL; pe++) + { + GtkWidget *widget = lookup_widget(ui_widgets.prefs_dialog, pe->widget_name); + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), *(gboolean*)pe->setting); + } +} + + void prefs_init_dialog(void) { GtkWidget *widget; GdkColor *color;
+ init_toggle_button_prefs(); + /* General settings */ /* startup */ widget = lookup_widget(ui_widgets.prefs_dialog, "check_load_session"); @@ -197,12 +229,6 @@ widget = lookup_widget(ui_widgets.prefs_dialog, "check_auto_focus"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), prefs.auto_focus);
- widget = lookup_widget(ui_widgets.prefs_dialog, "check_ask_suppress_search_dialogs"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), search_prefs.suppress_dialogs); - - widget = lookup_widget(ui_widgets.prefs_dialog, "check_search_use_current_word"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), search_prefs.use_current_word); - widget = lookup_widget(ui_widgets.prefs_dialog, "entry_contextaction"); gtk_entry_set_text(GTK_ENTRY(widget), tool_prefs.context_action_cmd);
@@ -578,6 +604,19 @@ }
+static void update_toggle_button_prefs() +{ + PrefEntry *pe; + + for (pe = toggle_prefs; pe->widget_name != NULL; pe++) + { + GtkWidget *widget = lookup_widget(ui_widgets.prefs_dialog, pe->widget_name); + + *(gboolean*)pe->setting = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + } +} + + /* * callbacks */ @@ -589,6 +628,8 @@ GtkWidget *widget; guint i;
+ update_toggle_button_prefs(); + /* General settings */ /* startup */ widget = lookup_widget(ui_widgets.prefs_dialog, "check_load_session"); @@ -610,18 +651,12 @@ widget = lookup_widget(ui_widgets.prefs_dialog, "check_beep"); prefs.beep_on_errors = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- widget = lookup_widget(ui_widgets.prefs_dialog, "check_ask_suppress_search_dialogs"); - search_prefs.suppress_dialogs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); - widget = lookup_widget(ui_widgets.prefs_dialog, "check_switch_pages"); prefs.switch_to_status = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = lookup_widget(ui_widgets.prefs_dialog, "check_suppress_status_msgs"); prefs.suppress_status_messages = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
- widget = lookup_widget(ui_widgets.prefs_dialog, "check_search_use_current_word"); - search_prefs.use_current_word = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); - widget = lookup_widget(ui_widgets.prefs_dialog, "check_auto_focus"); prefs.auto_focus = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
Modified: trunk/src/search.c =================================================================== --- trunk/src/search.c 2008-06-24 14:32:54 UTC (rev 2723) +++ trunk/src/search.c 2008-06-25 11:56:58 UTC (rev 2724) @@ -562,7 +562,7 @@ GtkWidget *entry; /* the child GtkEntry of combo (or dir_combo) */ GeanyDocument *doc = document_get_current(); gchar *sel = NULL; - gchar *cur_dir; + gchar *cur_dir = NULL;
if (widgets.find_in_files_dialog == NULL) { @@ -725,18 +725,26 @@
entry = GTK_BIN(dir_combo)->child; if (NZV(dir)) - cur_dir = g_strdup(dir); + cur_dir = g_strdup(dir); /* custom directory argument passed */ else - cur_dir = utils_get_current_file_dir_utf8(); + { + gboolean entry_empty = ! NZV(gtk_entry_get_text(GTK_ENTRY(entry))); + + if (search_prefs.use_current_file_dir || entry_empty) + { + cur_dir = utils_get_current_file_dir_utf8(); + + /* use default_open_path if no directory could be determined + * (e.g. when no files are open) */ + if (!cur_dir) + cur_dir = g_strdup(prefs.default_open_path); + } + } if (cur_dir) { gtk_entry_set_text(GTK_ENTRY(entry), cur_dir); g_free(cur_dir); } - else - { /* use default_open_path if no directory could be determined (e.g. when no files are open) */ - gtk_entry_set_text(GTK_ENTRY(entry), prefs.default_open_path); - }
/* put the focus to the directory entry if it is empty */ if (utils_str_equal(gtk_entry_get_text(GTK_ENTRY(entry)), ""))
Modified: trunk/src/search.h =================================================================== --- trunk/src/search.h 2008-06-24 14:32:54 UTC (rev 2723) +++ trunk/src/search.h 2008-06-25 11:56:58 UTC (rev 2724) @@ -45,6 +45,7 @@ gchar *fif_extra_options; gboolean suppress_dialogs; gboolean use_current_word; + gboolean use_current_file_dir; /* find in files directory to use on showing dialog */ } GeanySearchPrefs;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.