[gnome-commander] GnomeCmdData: more C++ rework



commit 15f192ec274309a73b7be2bc6a7649d0975b3297
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Sat Nov 12 15:31:05 2011 +0100

    GnomeCmdData: more C++ rework

 src/gnome-cmd-data.cc           |   28 ----------------------------
 src/gnome-cmd-data.h            |   23 ++++++++++++++++++-----
 src/gnome-cmd-file-popmenu.cc   |    2 +-
 src/gnome-cmd-options-dialog.cc |   10 +++++-----
 4 files changed, 24 insertions(+), 39 deletions(-)
---
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 47291f9..c3473d8 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -1661,34 +1661,6 @@ void gnome_cmd_data_set_ftp_anonymous_password (const gchar *pw)
 }
 
 
-void gnome_cmd_data_add_fav_app (GnomeCmdApp *app)
-{
-    g_return_if_fail (app != NULL);
-
-    gnome_cmd_data.options.fav_apps = g_list_append (gnome_cmd_data.options.fav_apps, app);
-}
-
-
-void gnome_cmd_data_remove_fav_app (GnomeCmdApp *app)
-{
-    g_return_if_fail (app != NULL);
-
-    gnome_cmd_data.options.fav_apps = g_list_remove (gnome_cmd_data.options.fav_apps, app);
-}
-
-
-GList *gnome_cmd_data_get_fav_apps ()
-{
-    return gnome_cmd_data.options.fav_apps;
-}
-
-
-void gnome_cmd_data_set_fav_apps (GList *apps)
-{
-    gnome_cmd_data.options.fav_apps = apps;
-}
-
-
 GnomeCmdColorTheme *gnome_cmd_data_get_current_color_theme ()
 {
     return &gnome_cmd_data.priv->color_themes[gnome_cmd_data.options.color_mode];
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index 4c644cb..40a3f44 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -244,6 +244,24 @@ struct GnomeCmdData
             g_free (term);
             term = g_strdup (command);
         }
+
+        void add_fav_app(GnomeCmdApp *app)
+        {
+            g_return_if_fail (app != NULL);
+            fav_apps = g_list_append (fav_apps, app);
+        }
+
+        void remove_fav_app(GnomeCmdApp *app)
+        {
+            g_return_if_fail (app != NULL);
+            fav_apps = g_list_remove (fav_apps, app);
+        }
+
+        void set_fav_apps(GList *apps)
+        {
+            // FIXME:   free fav_apps
+            fav_apps = apps;
+        }
     };
 
     struct Selection
@@ -418,11 +436,6 @@ struct GnomeCmdData
 
 gpointer gnome_cmd_data_get_con_list ();
 
-void gnome_cmd_data_add_fav_app (GnomeCmdApp *app);
-void gnome_cmd_data_remove_fav_app (GnomeCmdApp *app);
-GList *gnome_cmd_data_get_fav_apps ();
-void gnome_cmd_data_set_fav_apps (GList *apps);
-
 const gchar *gnome_cmd_data_get_ftp_anonymous_password ();
 void gnome_cmd_data_set_ftp_anonymous_password (const gchar *pw);
 
diff --git a/src/gnome-cmd-file-popmenu.cc b/src/gnome-cmd-file-popmenu.cc
index 6a581dd..2a4e091 100644
--- a/src/gnome-cmd-file-popmenu.cc
+++ b/src/gnome-cmd-file-popmenu.cc
@@ -539,7 +539,7 @@ GtkWidget *gnome_cmd_file_popmenu_new (GnomeCmdFileList *fl)
 
     // Add favorite applications
     match_count = 0;
-    for (GList *tmp=gnome_cmd_data_get_fav_apps (); tmp; tmp = tmp->next)
+    for (GList *tmp=gnome_cmd_data.options.fav_apps; tmp; tmp = tmp->next)
     {
         GnomeCmdApp *app = (GnomeCmdApp *) tmp->data;
         if (fav_app_matches_files (app, files))
diff --git a/src/gnome-cmd-options-dialog.cc b/src/gnome-cmd-options-dialog.cc
index 6069726..e359b5a 100644
--- a/src/gnome-cmd-options-dialog.cc
+++ b/src/gnome-cmd-options-dialog.cc
@@ -1250,7 +1250,7 @@ static void on_add_app_dialog_ok (GtkButton *button, GtkWidget *dialog)
                                                       (AppTarget) target,
                                                       pattern_string,
                                                       handles_uris, handles_multiple, requires_terminal);
-    gnome_cmd_data_add_fav_app (app);
+    gnome_cmd_data.options.add_fav_app(app);
     add_app_to_list (GTK_CLIST (clist), app);
     gtk_widget_destroy (dialog);
 
@@ -1430,7 +1430,7 @@ static void on_app_selected (GtkCList *clist, gint row, gint column, GdkEventBut
 
 static void on_app_moved (GtkCList *clist, gint arg1, gint arg2, GtkWidget *frame)
 {
-    GList *apps = gnome_cmd_data_get_fav_apps ();
+    GList *apps = gnome_cmd_data.options.fav_apps;
 
     if (!apps
         || MAX (arg1, arg2) >= g_list_length (apps)
@@ -1443,7 +1443,7 @@ static void on_app_moved (GtkCList *clist, gint arg1, gint arg2, GtkWidget *fram
 
     apps = g_list_insert (apps, data, arg2);
 
-    gnome_cmd_data_set_fav_apps (apps);
+    gnome_cmd_data.options.set_fav_apps(apps);
 }
 
 
@@ -1454,7 +1454,7 @@ static void on_app_remove (GtkWidget *button, GtkWidget *frame)
     if (clist->focus_row >= 0)
     {
         GnomeCmdApp *app = (GnomeCmdApp *) gtk_clist_get_row_data (clist, clist->focus_row);
-        gnome_cmd_data_remove_fav_app (app);
+        gnome_cmd_data.options.remove_fav_app(app);
         gtk_clist_remove (clist, clist->focus_row);
     }
 }
@@ -1564,7 +1564,7 @@ inline GtkWidget *create_programs_tab (GtkWidget *parent, GnomeCmdData &cfg)
     gtk_container_add (GTK_CONTAINER (bbox), button);
 
     clist = (GtkWidget *) g_object_get_data (G_OBJECT (parent), "app_clist");
-    for (GList *apps = gnome_cmd_data_get_fav_apps (); apps; apps = apps->next)
+    for (GList *apps = gnome_cmd_data.options.fav_apps; apps; apps = apps->next)
         add_app_to_list (GTK_CLIST (clist), (GnomeCmdApp *) apps->data);
 
     return frame;



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