[Gpredict-svn] SF.net SVN: gpredict:[755] trunk
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
From: <aa...@us...> - 2011-02-02 17:06:30
|
Revision: 755 http://gpredict.svn.sourceforge.net/gpredict/?rev=755&view=rev Author: aa1vs Date: 2011-02-02 17:06:24 +0000 (Wed, 02 Feb 2011) Log Message: ----------- Sort QTH list alphabetically when configuring module. Modified Paths: -------------- trunk/ChangeLog trunk/src/mod-cfg.c Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-02-01 16:05:11 UTC (rev 754) +++ trunk/ChangeLog 2011-02-02 17:06:24 UTC (rev 755) @@ -1,3 +1,8 @@ +2011-02-02 Charles Suprin <hamaa1vs at gmail.com> + + * src/mod-cfg.c + Sort QTH list alphabetically when configuring module. + 2011-02-01 Alexandru Csete <oz9aec at gmail.com> * src/gtk-rig-ctrl.c: Modified: trunk/src/mod-cfg.c =================================================================== --- trunk/src/mod-cfg.c 2011-02-01 16:05:11 UTC (rev 754) +++ trunk/src/mod-cfg.c 2011-02-02 17:06:24 UTC (rev 755) @@ -80,6 +80,7 @@ static void addbut_clicked_cb (GtkButton *button, GtkSatSelector *selector); static void delbut_clicked_cb (GtkButton *button, GtkSatSelector *selector); +static gint qth_name_compare (const gchar *a, const gchar *b); /** \brief Create a new module. * @@ -829,11 +830,14 @@ gchar *dirname; const gchar *filename; gchar *defqth = NULL; + gchar *defqthshort = NULL; gchar **buffv; gint idx = -1; gint count = 0; + GSList *qths=NULL; + gchar *qthname; + gint i,n; - combo = gtk_combo_box_new_text (); /* get qth file name from cfgdata; if cfg data has no QTH @@ -845,6 +849,10 @@ MOD_CFG_GLOBAL_SECTION, MOD_CFG_QTH_FILE_KEY, &error); + buffv = g_strsplit (defqth, ".qth", 0); + defqthshort = g_strdup(buffv[0]); + + g_strfreev(buffv); } else { sat_log_log (SAT_LOG_LEVEL_MSG, @@ -852,6 +860,7 @@ __FUNCTION__); defqth = g_strdup (_("** DEFAULT **")); + defqthshort = g_strdup(defqth); } @@ -863,23 +872,33 @@ if (dir) { while ((filename = g_dir_read_name (dir))) { - + /*create a sorted list then use it to load the combo box*/ if (g_str_has_suffix (filename, ".qth")) { buffv = g_strsplit (filename, ".qth", 0); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo), buffv[0]); + qths=g_slist_insert_sorted(qths,g_strdup(buffv[0]),(GCompareFunc) qth_name_compare); g_strfreev (buffv); + } + + } + n = g_slist_length (qths); + for (i = 0; i < n; i++) { + qthname = g_slist_nth_data (qths, i); + if (qthname) { + gtk_combo_box_append_text (GTK_COMBO_BOX (combo), qthname); + /* is this the QTH for this module? */ - if (!g_ascii_strcasecmp (defqth, filename)) { + /* comparison uses short name full filename*/ + if (!g_ascii_strcasecmp (defqthshort, qthname)) { idx = count; } - + g_free(qthname); count++; } - } - + g_slist_free(qths); + } else { sat_log_log (SAT_LOG_LEVEL_ERROR, @@ -907,6 +926,7 @@ } g_free (defqth); + g_free (defqthshort); g_free (dirname); g_dir_close (dir); @@ -1224,3 +1244,7 @@ } + +static gint qth_name_compare (const gchar* a,const gchar *b){ + return (g_ascii_strcasecmp(a,b)); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |