[gnome-commander] Added function for testing a favourite apps name beeing a duplicate



commit 1fc0b8b4ee4ae5783aefec1518fbe1a8f6b39cac
Author: Uwe Scholz <uwescholz src gnome org>
Date:   Sat Jul 4 18:30:03 2015 +0200

    Added function for testing a favourite apps name beeing a duplicate

 src/gnome-cmd-data.cc |   24 ++++++++++++++++++++++++
 src/gnome-cmd-data.h  |    1 +
 2 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 18c8645..cddf998 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -180,6 +180,30 @@ GnomeCmdData::Options &GnomeCmdData::Options::operator = (const Options &cfg)
     return *this;
 }
 
+/**
+ * This function takes a char array and compares it against each app
+ * name in the list of gnome_cmd_data.options.fav_apps.
+ *
+ * @returns A TRUE if the given name is already existing in the list of
+ * apps, else FALSE.
+ */
+gboolean GnomeCmdData::Options::is_name_double(const gchar *name_to_test)
+{
+    GList *app_pointer;
+    gboolean foundstate = FALSE;
+    for (app_pointer = gnome_cmd_data.options.fav_apps; app_pointer; app_pointer = app_pointer->next)
+    {
+       GnomeCmdApp *app = (GnomeCmdApp *) app_pointer->data;
+       if (app)
+       {
+           gchar *app_name = g_strdup(gnome_cmd_app_get_name(app));
+           if (!strcmp(app_name, name_to_test))
+               foundstate = TRUE;
+           g_free (app_name);
+       }
+    }
+    return foundstate;
+}
 
 void GnomeCmdData::Selection::reset()
 {
diff --git a/src/gnome-cmd-data.h b/src/gnome-cmd-data.h
index 12f3b20..211993c 100644
--- a/src/gnome-cmd-data.h
+++ b/src/gnome-cmd-data.h
@@ -311,6 +311,7 @@ struct GnomeCmdData
             // FIXME:   free fav_apps
             fav_apps = apps;
         }
+        gboolean is_name_double(const gchar *name);
     };
 
     struct Selection


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