gnome-commander r2312 - in branches/gcmd-1-3: . src



Author: epiotr
Date: Mon Nov 24 23:07:36 2008
New Revision: 2312
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=2312&view=rev

Log:
Do not allocate dynamically SearchConfig in GnomeCmdData

Modified:
   branches/gcmd-1-3/ChangeLog
   branches/gcmd-1-3/src/gnome-cmd-data.cc
   branches/gcmd-1-3/src/gnome-cmd-data.h
   branches/gcmd-1-3/src/gnome-cmd-patternsel-dialog.cc
   branches/gcmd-1-3/src/gnome-cmd-search-dialog.cc

Modified: branches/gcmd-1-3/src/gnome-cmd-data.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-data.cc	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-data.cc	Mon Nov 24 23:07:36 2008
@@ -65,7 +65,6 @@
     gboolean             honor_expect_uris;
     gboolean             use_internal_viewer;
     gboolean             skip_mounting;
-    SearchDefaults       *search_defaults;
     gchar                *start_dirs[2];
     gchar                *last_pattern;
     GList                *auto_load_plugins;
@@ -811,15 +810,15 @@
 
 inline void GnomeCmdData::save_search_defaults()
 {
-    gnome_cmd_data_set_int ("/search-history/width", priv->search_defaults->width);
-    gnome_cmd_data_set_int ("/search-history/height", priv->search_defaults->height);
+    gnome_cmd_data_set_int ("/search-history/width", search_defaults.width);
+    gnome_cmd_data_set_int ("/search-history/height", search_defaults.height);
 
-    gnome_cmd_data_set_string_history ("/search-history/name_pattern%d", priv->search_defaults->name_patterns);
-    gnome_cmd_data_set_string_history ("/search-history/content_pattern%d", priv->search_defaults->content_patterns);
-    gnome_cmd_data_set_string_history ("/search-history/directory%d", priv->search_defaults->directories);
+    gnome_cmd_data_set_string_history ("/search-history/name_pattern%d", search_defaults.name_patterns.ents);
+    gnome_cmd_data_set_string_history ("/search-history/content_pattern%d", search_defaults.content_patterns.ents);
+    gnome_cmd_data_set_string_history ("/search-history/directory%d", search_defaults.directories.ents);
 
-    gnome_cmd_data_set_bool ("/search-history/recursive", priv->search_defaults->recursive);
-    gnome_cmd_data_set_bool ("/search-history/case_sens", priv->search_defaults->case_sens);
+    gnome_cmd_data_set_bool ("/search-history/recursive", search_defaults.recursive);
+    gnome_cmd_data_set_bool ("/search-history/case_sens", search_defaults.case_sens);
 }
 
 
@@ -958,16 +957,22 @@
 
 inline void GnomeCmdData::load_search_defaults()
 {
-    priv->search_defaults = g_new0 (SearchDefaults, 1);
-
-    priv->search_defaults->width = gnome_cmd_data_get_int ("/search-history/width", 450);
-    priv->search_defaults->height = gnome_cmd_data_get_int ("/search-history/height", 400);
+    GList *list = NULL;
 
-    priv->search_defaults->name_patterns = load_string_history ("/search-history/name_pattern%d", -1);
-    priv->search_defaults->content_patterns = load_string_history ("/search-history/content_pattern%d", -1);
-    priv->search_defaults->directories = load_string_history ("/search-history/directory%d", -1);
-    priv->search_defaults->recursive = gnome_cmd_data_get_bool ("/search-history/recursive", TRUE);
-    priv->search_defaults->case_sens = gnome_cmd_data_get_bool ("/search-history/case_sens", FALSE);
+    list = load_string_history ("/search-history/name_pattern%d", -1);
+    search_defaults.name_patterns.ents = list;
+    search_defaults.name_patterns.pos = list;
+    list = load_string_history ("/search-history/directory%d", -1);
+    search_defaults.directories.ents = list;
+    search_defaults.directories.pos = list;
+    list = load_string_history ("/search-history/content_pattern%d", -1);
+    search_defaults.content_patterns.ents = list;
+    search_defaults.content_patterns.pos = list;
+
+    search_defaults.width = gnome_cmd_data_get_int ("/search-history/width", 640);
+    search_defaults.height = gnome_cmd_data_get_int ("/search-history/height", 400);
+    search_defaults.recursive = gnome_cmd_data_get_bool ("/search-history/recursive", TRUE);
+    search_defaults.case_sens = gnome_cmd_data_get_bool ("/search-history/case_sens", FALSE);
 }
 
 
@@ -2000,12 +2005,6 @@
 }
 
 
-GnomeCmdData::SearchDefaults *gnome_cmd_data_get_search_defaults ()
-{
-    return gnome_cmd_data.priv->search_defaults;
-}
-
-
 GnomeCmdBookmarkGroup *gnome_cmd_data_get_local_bookmarks ()
 {
     return gnome_cmd_con_get_bookmarks (gnome_cmd_con_list_get_home (gnome_cmd_data.priv->con_list));

Modified: branches/gcmd-1-3/src/gnome-cmd-data.h
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-data.h	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-data.h	Mon Nov 24 23:07:36 2008
@@ -38,14 +38,22 @@
         RIGHT_BUTTON_SELECTS
     };
 
-    struct SearchDefaults
+    enum {PATTERN_HISTORY_SIZE=10};
+
+    struct SearchConfig
     {
-        GList *name_patterns;
-        GList *content_patterns;
-        GList *directories;
+        History name_patterns;
+        History directories;
+        History content_patterns;
         gboolean recursive;
         gboolean case_sens;
         gint width, height;
+
+        SearchConfig(): name_patterns(PATTERN_HISTORY_SIZE),
+                        directories(PATTERN_HISTORY_SIZE),
+                        content_patterns(PATTERN_HISTORY_SIZE),
+                        recursive(TRUE), case_sens(FALSE),
+                        width(600), height(400)                 {}
     };
 
     struct AdvrenameConfig
@@ -107,6 +115,7 @@
     Filter::Type                 filter_type;
     FilterSettings               filter_settings;
 
+    SearchConfig                 search_defaults;
     AdvrenameConfig              advrename_defaults;
 
     gboolean                     case_sens_sort;
@@ -150,8 +159,6 @@
     GnomeCmdConFtp *get_quick_connect()           {  return quick_connect;                     }
 };
 
-#define PATTERN_HISTORY_SIZE 10
-
 gpointer gnome_cmd_data_get_con_list ();
 
 void gnome_cmd_data_add_fav_app (GnomeCmdApp *app);
@@ -215,8 +222,6 @@
 gboolean gnome_cmd_data_get_use_ls_colors ();
 void gnome_cmd_data_set_use_ls_colors (gboolean value);
 
-GnomeCmdData::SearchDefaults *gnome_cmd_data_get_search_defaults ();
-
 GnomeCmdBookmarkGroup *gnome_cmd_data_get_local_bookmarks ();
 GList *gnome_cmd_data_get_bookmark_groups ();
 

Modified: branches/gcmd-1-3/src/gnome-cmd-patternsel-dialog.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-patternsel-dialog.cc	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-patternsel-dialog.cc	Mon Nov 24 23:07:36 2008
@@ -47,7 +47,7 @@
 {
     g_return_if_fail (GNOME_CMD_IS_PATTERNSEL_DIALOG (dialog));
 
-    GnomeCmdData::SearchDefaults *defaults = gnome_cmd_data_get_search_defaults ();
+    GnomeCmdData::SearchConfig &defaults = gnome_cmd_data.search_defaults;
 
     const gchar *s = gtk_entry_get_text (GTK_ENTRY (dialog->priv->pattern_entry));
     gboolean case_sens = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->case_check));
@@ -57,7 +57,7 @@
     else
         dialog->priv->fl->unselect_pattern(s, case_sens);
 
-    defaults->name_patterns = string_history_add (defaults->name_patterns, s, PATTERN_HISTORY_SIZE);
+    defaults.name_patterns.add(s);
 
     gtk_widget_hide (GTK_WIDGET (dialog));
 }
@@ -115,7 +115,7 @@
 GtkWidget *gnome_cmd_patternsel_dialog_new (GnomeCmdFileList *fl, gboolean mode)
 {
     GtkWidget *hbox, *vbox, *label;
-    GnomeCmdData::SearchDefaults *defaults = gnome_cmd_data_get_search_defaults ();
+    GnomeCmdData::SearchConfig &defaults = gnome_cmd_data.search_defaults;
     GnomeCmdPatternselDialog *dialog = (GnomeCmdPatternselDialog *) gtk_type_new (gnome_cmd_patternsel_dialog_get_type ());
     dialog->priv->mode = mode;
     dialog->priv->fl = fl;
@@ -131,8 +131,8 @@
 
     dialog->priv->pattern_combo = create_combo (GTK_WIDGET (dialog));
     gtk_combo_disable_activate (GTK_COMBO (dialog->priv->pattern_combo));
-    if (defaults->name_patterns)
-        gtk_combo_set_popdown_strings (GTK_COMBO (dialog->priv->pattern_combo), defaults->name_patterns);
+    if (!defaults.name_patterns.empty())
+        gtk_combo_set_popdown_strings (GTK_COMBO (dialog->priv->pattern_combo), defaults.name_patterns.ents);
     dialog->priv->pattern_entry = GTK_COMBO (dialog->priv->pattern_combo)->entry;
     gnome_cmd_dialog_editable_enters (GNOME_CMD_DIALOG (dialog), GTK_EDITABLE (dialog->priv->pattern_entry));
     gtk_entry_select_region (GTK_ENTRY (dialog->priv->pattern_entry), 0, -1);

Modified: branches/gcmd-1-3/src/gnome-cmd-search-dialog.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-search-dialog.cc	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-search-dialog.cc	Mon Nov 24 23:07:36 2008
@@ -495,9 +495,8 @@
 
 static void on_dialog_size_allocate (GtkWidget *widget, GtkAllocation *allocation, GnomeCmdSearchDialog *dialog)
 {
-    GnomeCmdData::SearchDefaults *defaults = gnome_cmd_data_get_search_defaults ();
-    defaults->width  = allocation->width;
-    defaults->height = allocation->height;
+    gnome_cmd_data.search_defaults.width = allocation->width;
+    gnome_cmd_data.search_defaults.height = allocation->height;
 }
 
 
@@ -526,14 +525,12 @@
     data->case_sens = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->case_check));
 
     // Save default settings
-    GnomeCmdData::SearchDefaults *defaults = gnome_cmd_data_get_search_defaults ();
-
-    defaults->case_sens = data->case_sens;
-    defaults->recursive = data->recurse;
-    defaults->name_patterns = string_history_add (defaults->name_patterns, data->name_pattern, PATTERN_HISTORY_SIZE);
-    defaults->directories = string_history_add (defaults->directories, data->dir, PATTERN_HISTORY_SIZE);
+    gnome_cmd_data.search_defaults.case_sens = data->case_sens;
+    gnome_cmd_data.search_defaults.recursive = data->recurse;
+    gnome_cmd_data.search_defaults.name_patterns.add(data->name_pattern);
+    gnome_cmd_data.search_defaults.directories.add(data->dir);
     if (data->content_search)
-        defaults->content_patterns = string_history_add (defaults->content_patterns, data->content_pattern, PATTERN_HISTORY_SIZE);
+        gnome_cmd_data.search_defaults.content_patterns.add(data->content_pattern);
 
     dialog->priv->result_list->remove_all_files();
 
@@ -803,7 +800,7 @@
 
 static void init (GnomeCmdSearchDialog *dialog)
 {
-    GnomeCmdData::SearchDefaults *defaults = gnome_cmd_data_get_search_defaults ();
+    GnomeCmdData::SearchConfig &defaults = gnome_cmd_data.search_defaults;
 
     GtkWidget *window;
     GtkWidget *vbox;
@@ -821,7 +818,7 @@
     gtk_object_set_data (GTK_OBJECT (window), "window", window);
     gtk_window_set_title (GTK_WINDOW (window), _("Search..."));
     gnome_cmd_dialog_set_resizable (GNOME_CMD_DIALOG (dialog), TRUE);
-    gtk_window_set_default_size (GTK_WINDOW (window), defaults->width, defaults->height);
+    gtk_window_set_default_size (GTK_WINDOW (window), defaults.width, defaults.height);
 
     vbox = create_vbox (window, FALSE, 0);
     gnome_cmd_dialog_add_expanding_category (GNOME_CMD_DIALOG (dialog), vbox);
@@ -837,8 +834,8 @@
     table_add (table, label, 0, 0, GTK_FILL);
 
     table_add (table, dialog->priv->pattern_combo, 1, 0, (GtkAttachOptions) (GTK_EXPAND|GTK_FILL));
-    if (defaults->name_patterns)
-        g_list_foreach (defaults->name_patterns, combo_box_insert_text, dialog->priv->pattern_combo);
+    if (!defaults.name_patterns.empty())
+        g_list_foreach (defaults.name_patterns.ents, combo_box_insert_text, dialog->priv->pattern_combo);
 
     gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->pattern_combo), 0);
     gnome_cmd_dialog_editable_enters (GNOME_CMD_DIALOG (dialog), GTK_EDITABLE (gtk_bin_get_child (GTK_BIN (dialog->priv->pattern_combo))));
@@ -849,10 +846,10 @@
     table_add (table, label, 0, 1, GTK_FILL);
 
     table_add (table, dialog->priv->dir_browser, 1, 1, (GtkAttachOptions) (GTK_EXPAND|GTK_FILL));
-    if (defaults->directories)
+    if (!defaults.directories.empty())
         gtk_combo_set_popdown_strings (
             GTK_COMBO (gnome_file_entry_gnome_entry (GNOME_FILE_ENTRY (dialog->priv->dir_browser))),
-            defaults->directories);
+            defaults.directories.ents);
 
     dialog->priv->dir_entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (dialog->priv->dir_browser));
 
@@ -861,7 +858,7 @@
 
     // Recurse check
     dialog->priv->recurse_check = create_check_with_mnemonic (window, _("Search _recursively"), "recurse_check");
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->recurse_check), defaults->recursive);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->recurse_check), defaults.recursive);
     gtk_box_pack_start (GTK_BOX (hbox), dialog->priv->recurse_check, FALSE, FALSE, 0);
 
 
@@ -885,8 +882,8 @@
     dialog->priv->find_text_combo = create_combo_box_entry (window);
     table_add (table, dialog->priv->find_text_combo, 1, 3, (GtkAttachOptions) (GTK_EXPAND|GTK_FILL));
     gtk_widget_set_sensitive (dialog->priv->find_text_combo, FALSE);
-    if (defaults->content_patterns)
-        g_list_foreach (defaults->content_patterns, combo_box_insert_text, dialog->priv->find_text_combo);
+    if (!defaults.content_patterns.empty())
+        g_list_foreach (defaults.content_patterns.ents, combo_box_insert_text, dialog->priv->find_text_combo);
 
     gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->priv->find_text_combo), 0);
     gnome_cmd_dialog_editable_enters (GNOME_CMD_DIALOG (dialog), GTK_EDITABLE (gtk_bin_get_child (GTK_BIN (dialog->priv->find_text_combo))));
@@ -896,7 +893,7 @@
     gtk_table_attach (GTK_TABLE (table), dialog->priv->case_check, 1, 2, 4, 5,
                       (GtkAttachOptions) (GTK_FILL),
                       (GtkAttachOptions) (0), 0, 0);
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->case_check), defaults->case_sens);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->priv->case_check), defaults.case_sens);
 
     dialog->priv->help_button = gnome_cmd_dialog_add_button (GNOME_CMD_DIALOG (dialog), GTK_STOCK_HELP, GTK_SIGNAL_FUNC (on_help), dialog);
     dialog->priv->close_button = gnome_cmd_dialog_add_button (GNOME_CMD_DIALOG (dialog), GTK_STOCK_CLOSE, GTK_SIGNAL_FUNC (on_close), dialog);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]