[gnome-commander/gcmd-1-3] advrename profiles: added copy() method



commit 037ae7d588abc30db3c4435f99cdfec737ef6e4c
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Sun Apr 26 17:39:55 2009 +0200

    advrename profiles: added copy() method
---
 src/gnome-cmd-profile-component.cc |   34 ++++++++++++++++++++++++++++++++--
 src/gnome-cmd-profile-component.h  |    3 +++
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/src/gnome-cmd-profile-component.cc b/src/gnome-cmd-profile-component.cc
index 97412fc..96b041f 100644
--- a/src/gnome-cmd-profile-component.cc
+++ b/src/gnome-cmd-profile-component.cc
@@ -938,8 +938,7 @@ static void gnome_cmd_profile_component_finalize (GObject *object)
 {
     GnomeCmdProfileComponent *component = GNOME_CMD_PROFILE_COMPONENT (object);
 
-    component->profile.template_string = component->get_template_entry();
-    copy_regex_model(component->priv->regex_model, GnomeCmdProfileComponent::COL_REGEX, component->profile.regexes);
+    component->copy();
 
     delete component->priv;
 
@@ -1143,3 +1142,34 @@ void GnomeCmdProfileComponent::set_template_history(GList *history)
     for (GList *i=history; i; i=i->next)
         gtk_combo_box_append_text (GTK_COMBO_BOX (priv->template_combo), (const gchar *) i->data);
 }
+
+
+GtkTreeModel *GnomeCmdProfileComponent::get_regex_model() const
+{
+    return priv ? priv->regex_model : NULL;
+}
+
+
+void GnomeCmdProfileComponent::copy()
+{
+    profile.template_string = get_template_entry();
+    copy_regex_model(priv->regex_model, COL_REGEX, profile.regexes);
+}
+
+
+void GnomeCmdProfileComponent::copy(GnomeCmdData::AdvrenameConfig::Profile &p)
+{
+    p.template_string = get_template_entry();
+    copy_regex_model(priv->regex_model, COL_REGEX, p.regexes);
+
+    if (&p==&profile)
+        return;
+
+    p.name.clear();
+    p.template_string = profile.template_string;
+    p.counter_start = profile.counter_start;
+    p.counter_width = profile.counter_width;
+    p.counter_step = profile.counter_step;
+    p.case_conversion = profile.case_conversion;
+    p.trim_blanks = profile.trim_blanks;
+}
diff --git a/src/gnome-cmd-profile-component.h b/src/gnome-cmd-profile-component.h
index f4e0900..81716a7 100644
--- a/src/gnome-cmd-profile-component.h
+++ b/src/gnome-cmd-profile-component.h
@@ -51,9 +51,12 @@ struct GnomeCmdProfileComponent
     ~GnomeCmdProfileComponent()     {}
 
     void update();
+    void copy();                                                    //  copies component to associated profile
+    void copy(GnomeCmdData::AdvrenameConfig::Profile &profile);     //  copies component to specified profile
 
     const gchar *get_template_entry() const;
     void set_template_history(GList *history);
+    GtkTreeModel *get_regex_model() const;
 };
 
 #endif // __GNOME_CMD_PROFILE_COMPONENT_H__



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