gnome-commander r2300 - in trunk: . src
- From: epiotr svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-commander r2300 - in trunk: . src
- Date: Fri, 21 Nov 2008 23:33:08 +0000 (UTC)
Author: epiotr
Date: Fri Nov 21 23:33:08 2008
New Revision: 2300
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=2300&view=rev
Log:
Do not allocate dynamically AdvrenameConfig in GnomeCmdData
Modified:
trunk/ChangeLog
trunk/src/gnome-cmd-advrename-dialog.cc
trunk/src/gnome-cmd-data.cc
trunk/src/gnome-cmd-data.h
trunk/src/gnome-cmd-user-actions.cc
trunk/src/history.h
Modified: trunk/src/gnome-cmd-advrename-dialog.cc
==============================================================================
--- trunk/src/gnome-cmd-advrename-dialog.cc (original)
+++ trunk/src/gnome-cmd-advrename-dialog.cc Fri Nov 21 23:33:08 2008
@@ -938,7 +938,7 @@
g_free (new_name);
}
dialog->update_new_filenames();
- dialog->defaults.templates->add(gtk_entry_get_text (GTK_ENTRY (dialog->priv->template_entry)));
+ dialog->defaults.templates.add(gtk_entry_get_text (GTK_ENTRY (dialog->priv->template_entry)));
break;
@@ -946,7 +946,7 @@
case GTK_RESPONSE_DELETE_EVENT:
case GTK_RESPONSE_CANCEL:
case GTK_RESPONSE_CLOSE:
- dialog->defaults.templates->add(gtk_entry_get_text (GTK_ENTRY (dialog->priv->template_entry)));
+ dialog->defaults.templates.add(gtk_entry_get_text (GTK_ENTRY (dialog->priv->template_entry)));
gtk_widget_hide (*dialog);
dialog->unset();
g_signal_stop_emission_by_name (dialog, "response"); // FIXME: ???
@@ -1429,11 +1429,11 @@
gtk_window_set_default_size (*this, defaults.width, defaults.height);
// Template
- for (GList *i=defaults.templates->ents; i; i=i->next)
+ for (GList *i=defaults.templates.ents; i; i=i->next)
gtk_combo_box_append_text (GTK_COMBO_BOX (priv->template_combo), (const gchar *) i->data);
- if (defaults.templates->ents)
- gtk_entry_set_text (GTK_ENTRY (priv->template_entry), (const gchar *) defaults.templates->ents->data);
+ if (defaults.templates.ents)
+ gtk_entry_set_text (GTK_ENTRY (priv->template_entry), (const gchar *) defaults.templates.ents->data);
else
gtk_entry_set_text (GTK_ENTRY (priv->template_entry), "$N");
Modified: trunk/src/gnome-cmd-data.cc
==============================================================================
--- trunk/src/gnome-cmd-data.cc (original)
+++ trunk/src/gnome-cmd-data.cc Fri Nov 21 23:33:08 2008
@@ -830,11 +830,11 @@
GtkTreeIter i;
- for (gboolean valid_iter=gtk_tree_model_get_iter_first (advrename_defaults->regexes, &i); valid_iter; valid_iter=gtk_tree_model_iter_next (advrename_defaults->regexes, &i))
+ for (gboolean valid_iter=gtk_tree_model_get_iter_first (advrename_defaults.regexes, &i); valid_iter; valid_iter=gtk_tree_model_iter_next (advrename_defaults.regexes, &i))
{
GnomeCmdAdvrenameDialog::Regex *rx;
- gtk_tree_model_get (advrename_defaults->regexes, &i,
+ gtk_tree_model_get (advrename_defaults.regexes, &i,
GnomeCmdAdvrenameDialog::COL_REGEX, &rx,
-1);
if (!rx)
@@ -845,15 +845,15 @@
csens = g_list_append (csens, (gpointer) (rx->case_sensitive ? "T" : "F"));
}
- gnome_cmd_data_set_int ("/advrename/width", advrename_defaults->width);
- gnome_cmd_data_set_int ("/advrename/height", advrename_defaults->height);
+ gnome_cmd_data_set_int ("/advrename/width", advrename_defaults.width);
+ gnome_cmd_data_set_int ("/advrename/height", advrename_defaults.height);
- gnome_cmd_data_set_int ("/template-history/size", g_list_length (advrename_defaults->templates->ents));
- gnome_cmd_data_set_string_history ("/template-history/template%d", advrename_defaults->templates->ents);
+ gnome_cmd_data_set_int ("/template-history/size", advrename_defaults.templates.size());
+ gnome_cmd_data_set_string_history ("/template-history/template%d", advrename_defaults.templates.ents);
- gnome_cmd_data_set_int ("/advrename/counter_start", advrename_defaults->counter_start);
- gnome_cmd_data_set_int ("/advrename/counter_precision", advrename_defaults->counter_precision);
- gnome_cmd_data_set_int ("/advrename/counter_increment", advrename_defaults->counter_increment);
+ gnome_cmd_data_set_int ("/advrename/counter_start", advrename_defaults.counter_start);
+ gnome_cmd_data_set_int ("/advrename/counter_precision", advrename_defaults.counter_precision);
+ gnome_cmd_data_set_int ("/advrename/counter_increment", advrename_defaults.counter_increment);
gnome_cmd_data_set_int ("/rename-history/size", g_list_length (from));
gnome_cmd_data_set_string_history ("/rename-history/from%d", from);
@@ -975,21 +975,18 @@
gint size;
GList *from=NULL, *to=NULL, *csens=NULL;
- advrename_defaults = g_new0 (AdvrenameConfig, 1);
-
- advrename_defaults->width = gnome_cmd_data_get_int ("/advrename/width", 450);
- advrename_defaults->height = gnome_cmd_data_get_int ("/advrename/height", 400);
+ advrename_defaults.width = gnome_cmd_data_get_int ("/advrename/width", 640);
+ advrename_defaults.height = gnome_cmd_data_get_int ("/advrename/height", 400);
size = gnome_cmd_data_get_int ("/template-history/size", 0);
GList *templates = load_string_history ("/template-history/template%d", size);
- advrename_defaults->templates = new History(10);
- advrename_defaults->templates->ents = templates;
- advrename_defaults->templates->pos = templates;
-
- advrename_defaults->counter_start = gnome_cmd_data_get_int ("/advrename/counter_start", 1);
- advrename_defaults->counter_precision = gnome_cmd_data_get_int ("/advrename/counter_precision", 1);
- advrename_defaults->counter_increment = gnome_cmd_data_get_int ("/advrename/counter_increment", 1);
+ advrename_defaults.templates.ents = templates;
+ advrename_defaults.templates.pos = templates;
+
+ advrename_defaults.counter_start = gnome_cmd_data_get_int ("/advrename/counter_start", 1);
+ advrename_defaults.counter_precision = gnome_cmd_data_get_int ("/advrename/counter_precision", 1);
+ advrename_defaults.counter_increment = gnome_cmd_data_get_int ("/advrename/counter_increment", 1);
size = gnome_cmd_data_get_int ("/rename-history/size", 0);
@@ -997,7 +994,7 @@
GList *tmp_to = to = load_string_history ("/rename-history/to%d", size);
GList *tmp_csens = csens = load_string_history ("/rename-history/csens%d", size);
- advrename_defaults->regexes = GTK_TREE_MODEL (gtk_list_store_new (GnomeCmdAdvrenameDialog::NUM_REGEX_COLS,
+ advrename_defaults.regexes = GTK_TREE_MODEL (gtk_list_store_new (GnomeCmdAdvrenameDialog::NUM_REGEX_COLS,
G_TYPE_POINTER,
G_TYPE_BOOLEAN,
G_TYPE_STRING,
@@ -1009,8 +1006,8 @@
GnomeCmdAdvrenameDialog::Regex *rx = new GnomeCmdAdvrenameDialog::Regex((gchar *) tmp_from->data,
(gchar *) tmp_to->data,
*((gchar *) tmp_csens->data)=='T');
- gtk_list_store_append (GTK_LIST_STORE (advrename_defaults->regexes), &iter);
- gtk_list_store_set (GTK_LIST_STORE (advrename_defaults->regexes), &iter,
+ gtk_list_store_append (GTK_LIST_STORE (advrename_defaults.regexes), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (advrename_defaults.regexes), &iter,
GnomeCmdAdvrenameDialog::COL_REGEX, rx,
GnomeCmdAdvrenameDialog::COL_MALFORMED_REGEX, !*rx,
GnomeCmdAdvrenameDialog::COL_PATTERN, rx->from.c_str(),
@@ -1099,8 +1096,6 @@
filter_settings.hidden = TRUE;
filter_settings.backup = TRUE;
- advrename_defaults = NULL;
-
case_sens_sort = TRUE;
ext_disp_mode = GNOME_CMD_EXT_DISP_BOTH;
list_orientation = FALSE;
@@ -1162,8 +1157,6 @@
g_free (priv->differ);
g_free (priv->term);
- delete advrename_defaults->templates;
-
g_free (priv);
}
}
Modified: trunk/src/gnome-cmd-data.h
==============================================================================
--- trunk/src/gnome-cmd-data.h (original)
+++ trunk/src/gnome-cmd-data.h Fri Nov 21 23:33:08 2008
@@ -50,13 +50,18 @@
struct AdvrenameConfig
{
- History *templates;
+ History templates;
GtkTreeModel *regexes;
guint counter_start;
- guint counter_precision;
gint counter_increment;
+ guint counter_precision;
gint width, height;
+
+ AdvrenameConfig(): templates(10), regexes(NULL),
+ counter_start(1), counter_increment(1), counter_precision(1), // defaults for
+ width(600), height(400) {} // advrename settings
+ ~AdvrenameConfig() { if (regexes) g_object_unref (regexes); }
};
struct FilterSettings
@@ -102,7 +107,7 @@
Filter::Type filter_type;
FilterSettings filter_settings;
- AdvrenameConfig *advrename_defaults;
+ AdvrenameConfig advrename_defaults;
gboolean case_sens_sort;
GnomeCmdExtDispMode ext_disp_mode;
Modified: trunk/src/gnome-cmd-user-actions.cc
==============================================================================
--- trunk/src/gnome-cmd-user-actions.cc (original)
+++ trunk/src/gnome-cmd-user-actions.cc Fri Nov 21 23:33:08 2008
@@ -743,7 +743,7 @@
if (!main_win->advrename_dlg)
{
- main_win->advrename_dlg = new GnomeCmdAdvrenameDialog(*gnome_cmd_data.advrename_defaults);
+ main_win->advrename_dlg = new GnomeCmdAdvrenameDialog(gnome_cmd_data.advrename_defaults);
// gtk_widget_ref (*main_win->advrename_dlg); // FIXME: ???
main_win->advrename_dlg->set(files);
gtk_widget_show_all (*main_win->advrename_dlg);
Modified: trunk/src/history.h
==============================================================================
--- trunk/src/history.h (original)
+++ trunk/src/history.h Fri Nov 21 23:33:08 2008
@@ -31,6 +31,9 @@
History(gint max): ents(NULL), pos(NULL), is_locked(FALSE) { this->max = max; }
~History();
+ guint size() { return g_list_length (ents); }
+ gboolean empty() { return ents==NULL; }
+
void add(const gchar *text);
gboolean can_back() { return pos && pos->next; }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]