[Gpredict-svn] SF.net SVN: gpredict:[934] trunk
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
From: <aa...@us...> - 2011-10-23 12:33:40
|
Revision: 934 http://gpredict.svn.sourceforge.net/gpredict/?rev=934&view=rev Author: aa1vs Date: 2011-10-23 12:33:34 +0000 (Sun, 23 Oct 2011) Log Message: ----------- Migrate satellite map and polar view to single mod-cfg functions for getting lists of integers. Modified Paths: -------------- trunk/ChangeLog trunk/src/gtk-polar-view.c trunk/src/gtk-sat-map.c trunk/src/mod-cfg-get-param.c trunk/src/mod-cfg-get-param.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-10-23 12:25:13 UTC (rev 933) +++ trunk/ChangeLog 2011-10-23 12:33:34 UTC (rev 934) @@ -11,7 +11,13 @@ * src/loc-tree.c Eliminate calls to deprecated gtk_box_pack_start_defaults. + * src/mod-cfg-get-param.c + * src/mod-cfg-get-param.h + * src/gtk-sat-map.c + * src/gtk-polar-view.c + Migrate satellite map and polar view to single mod-cfg functions for getting lists of integers. + 2011-10-13 Charles Suprin <hamaa1vs at gmail.com> * ChangeLog Modified: trunk/src/gtk-polar-view.c =================================================================== --- trunk/src/gtk-polar-view.c 2011-10-23 12:25:13 UTC (rev 933) +++ trunk/src/gtk-polar-view.c 2011-10-23 12:33:34 UTC (rev 934) @@ -94,8 +94,6 @@ static gchar *los_time_to_str (GtkPolarView *polv, sat_t *sat); static void gtk_polar_view_store_showtracks (GtkPolarView *pv); static void gtk_polar_view_load_showtracks (GtkPolarView *pv); -static void store_binary_hash_cfgdata (GKeyFile *cfgdata, GHashTable *hash, const gchar *cfgsection, const gchar *cfgkey) ; -static void load_integer_list_boolean (GKeyFile *cfgdata,const gchar* section,const gchar *key,GHashTable *dest); static GtkVBoxClass *parent_class = NULL; @@ -1766,11 +1764,11 @@ static void gtk_polar_view_store_showtracks (GtkPolarView *pv) { - store_binary_hash_cfgdata(pv->cfgdata, + mod_cfg_set_integer_list_boolean(pv->cfgdata, pv->showtracks_on, MOD_CFG_POLAR_SECTION, MOD_CFG_POLAR_SHOWTRACKS); - store_binary_hash_cfgdata(pv->cfgdata, + mod_cfg_set_integer_list_boolean(pv->cfgdata, pv->showtracks_off, MOD_CFG_POLAR_SECTION, MOD_CFG_POLAR_HIDETRACKS); @@ -1780,95 +1778,15 @@ static void gtk_polar_view_load_showtracks (GtkPolarView *pv) { - load_integer_list_boolean(pv->cfgdata, + mod_cfg_get_integer_list_boolean(pv->cfgdata, MOD_CFG_POLAR_SECTION, MOD_CFG_POLAR_HIDETRACKS, pv->showtracks_off); - load_integer_list_boolean(pv->cfgdata, + mod_cfg_get_integer_list_boolean(pv->cfgdata, MOD_CFG_POLAR_SECTION, MOD_CFG_POLAR_SHOWTRACKS, pv->showtracks_on); } -/** \brief Load an integer list into a hash table that uses the - existinence of datain the hash as a boolean. - It loads NULL's into the hash table. -*/ -static void load_integer_list_boolean (GKeyFile *cfgdata,const gchar* section,const gchar *key,GHashTable *dest) { - gint *sats = NULL; - gsize length; - GError *error = NULL; - guint i; - guint *tkey; - - sats = g_key_file_get_integer_list (cfgdata, - section, - key, - &length, - &error); - if (error != NULL) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Failed to get list of satellites (%s)"), - __FUNCTION__, error->message); - - g_clear_error (&error); - - /* GLib API says nothing about the contents in case of error */ - if (sats) { - g_free (sats); - } - - return; - } - - /* read each satellite into hash table */ - for (i = 0; i < length; i++) { - tkey = g_new0 (guint, 1); - *tkey = sats[i]; - //printf("loading sat %d\n",sats[i]); - if (!(g_hash_table_lookup_extended (dest, tkey, NULL, NULL))) { - /* just add a one to the value so there is presence indicator */ - g_hash_table_insert (dest, - tkey, - NULL); - } - } - g_free(sats); -} - -/** \brief Convert the "boolean" hash back into an integer list and - save it to the cfgdata. */ -static void -store_binary_hash_cfgdata (GKeyFile *cfgdata, GHashTable *hash, const gchar *cfgsection, const gchar *cfgkey) -{ - gint *showtrack; - gint *something; - gint i,length; - GList *keys = g_hash_table_get_keys(hash); - - length = g_list_length(keys); - if (g_list_length(keys)>0) { - - showtrack = g_try_new0(gint,g_list_length(keys)); - for (i=0;i<length;i++) { - something=g_list_nth_data(keys,i); - showtrack[i]=*something; - } - g_key_file_set_integer_list (cfgdata, - cfgsection, - cfgkey, - showtrack, - g_list_length(keys) - ); - - } else { - g_key_file_remove_key(cfgdata, - cfgsection, - cfgkey, - NULL); - } - - g_list_free (keys); -} Modified: trunk/src/gtk-sat-map.c =================================================================== --- trunk/src/gtk-sat-map.c 2011-10-23 12:25:13 UTC (rev 933) +++ trunk/src/gtk-sat-map.c 2011-10-23 12:33:34 UTC (rev 934) @@ -111,8 +111,6 @@ static void gtk_sat_map_store_showtracks (GtkSatMap *satmap); static void gtk_sat_map_load_hide_coverages (GtkSatMap *map); static void gtk_sat_map_store_hidecovs (GtkSatMap *satmap); -static void load_integer_list_boolean (GKeyFile *cfgdata,const gchar* section,const gchar *key,GHashTable *dest); -static void store_binary_hash_cfgdata (GKeyFile *cfgdata, GHashTable *hash, const gchar *cfgsection, const gchar *cfgkey); static GtkVBoxClass *parent_class = NULL; @@ -2603,115 +2601,34 @@ static void gtk_sat_map_load_showtracks (GtkSatMap *satmap) { - load_integer_list_boolean(satmap->cfgdata, - MOD_CFG_MAP_SECTION, - MOD_CFG_MAP_SHOWTRACKS, - satmap->showtracks); + mod_cfg_get_integer_list_boolean(satmap->cfgdata, + MOD_CFG_MAP_SECTION, + MOD_CFG_MAP_SHOWTRACKS, + satmap->showtracks); } static void gtk_sat_map_store_showtracks (GtkSatMap *satmap) { - store_binary_hash_cfgdata(satmap->cfgdata, - satmap->showtracks, - MOD_CFG_MAP_SECTION, - MOD_CFG_MAP_SHOWTRACKS); + mod_cfg_set_integer_list_boolean(satmap->cfgdata, + satmap->showtracks, + MOD_CFG_MAP_SECTION, + MOD_CFG_MAP_SHOWTRACKS); } static void gtk_sat_map_store_hidecovs (GtkSatMap *satmap) { - store_binary_hash_cfgdata(satmap->cfgdata, - satmap->hidecovs, - MOD_CFG_MAP_SECTION, - MOD_CFG_MAP_HIDECOVS); + mod_cfg_set_integer_list_boolean(satmap->cfgdata, + satmap->hidecovs, + MOD_CFG_MAP_SECTION, + MOD_CFG_MAP_HIDECOVS); } /** \brief Load the satellites that we should not highlight coverage */ static void gtk_sat_map_load_hide_coverages (GtkSatMap *satmap) { - load_integer_list_boolean(satmap->cfgdata, - MOD_CFG_MAP_SECTION, - MOD_CFG_MAP_HIDECOVS, - satmap->hidecovs); + mod_cfg_get_integer_list_boolean(satmap->cfgdata, + MOD_CFG_MAP_SECTION, + MOD_CFG_MAP_HIDECOVS, + satmap->hidecovs); } - -/** \brief Load an integer list into a hash table that uses the - existinence of datain the hash as a boolean. - It loads NULL's into the hash table. -*/ -static void load_integer_list_boolean (GKeyFile *cfgdata,const gchar* section,const gchar *key,GHashTable *dest) { - gint *sats = NULL; - gsize length; - GError *error = NULL; - guint i; - guint *tkey; - - sats = g_key_file_get_integer_list (cfgdata, - section, - key, - &length, - &error); - if (error != NULL) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Failed to get list of satellites (%s)"), - __FUNCTION__, error->message); - - g_clear_error (&error); - - /* GLib API says nothing about the contents in case of error */ - if (sats) { - g_free (sats); - } - - return; - } - - /* read each satellite into hash table */ - for (i = 0; i < length; i++) { - tkey = g_new0 (guint, 1); - *tkey = sats[i]; - //printf("loading sat %d\n",sats[i]); - if (!(g_hash_table_lookup_extended (dest, tkey, NULL, NULL))) { - /* just add a one to the value so there is presence indicator */ - g_hash_table_insert (dest, - tkey, - NULL); - } - } - g_free(sats); -} - -/** \brief Convert the "boolean" hash back into an integer list and - save it to the cfgdata. */ -static void -store_binary_hash_cfgdata (GKeyFile *cfgdata, GHashTable *hash, const gchar *cfgsection, const gchar *cfgkey) -{ - gint *showtrack; - gint *something; - gint i,length; - GList *keys = g_hash_table_get_keys(hash); - - length = g_list_length(keys); - if (g_list_length(keys)>0) { - - showtrack = g_try_new0(gint,g_list_length(keys)); - for (i=0;i<length;i++) { - something=g_list_nth_data(keys,i); - showtrack[i]=*something; - } - g_key_file_set_integer_list (cfgdata, - cfgsection, - cfgkey, - showtrack, - g_list_length(keys) - ); - - } else { - g_key_file_remove_key(cfgdata, - cfgsection, - cfgkey, - NULL); - } - - g_list_free (keys); -} Modified: trunk/src/mod-cfg-get-param.c =================================================================== --- trunk/src/mod-cfg-get-param.c 2011-10-23 12:25:13 UTC (rev 933) +++ trunk/src/mod-cfg-get-param.c 2011-10-23 12:33:34 UTC (rev 934) @@ -161,3 +161,83 @@ return param; } + +/** \brief Load an integer list into a hash table that uses the + existinence of datain the hash as a boolean. + It loads NULL's into the hash table. +*/ +void mod_cfg_get_integer_list_boolean (GKeyFile *cfgdata,const gchar* section,const gchar *key,GHashTable *dest) { + gint *sats = NULL; + gsize length; + GError *error = NULL; + guint i; + guint *tkey; + + sats = g_key_file_get_integer_list (cfgdata, + section, + key, + &length, + &error); + if (error != NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Failed to get list of satellites (%s)"), + __FUNCTION__, error->message); + + g_clear_error (&error); + + /* GLib API says nothing about the contents in case of error */ + if (sats) { + g_free (sats); + } + + return; + } + + /* read each satellite into hash table */ + for (i = 0; i < length; i++) { + tkey = g_new0 (guint, 1); + *tkey = sats[i]; + //printf("loading sat %d\n",sats[i]); + if (!(g_hash_table_lookup_extended (dest, tkey, NULL, NULL))) { + /* just add a one to the value so there is presence indicator */ + g_hash_table_insert (dest, + tkey, + NULL); + } + } + g_free(sats); +} + +/** \brief Convert the "boolean" hash back into an integer list and + save it to the cfgdata. */ +void mod_cfg_set_integer_list_boolean (GKeyFile *cfgdata, GHashTable *hash, const gchar *cfgsection, const gchar *cfgkey) +{ + gint *showtrack; + gint *something; + gint i,length; + GList *keys = g_hash_table_get_keys(hash); + + length = g_list_length(keys); + if (g_list_length(keys)>0) { + + showtrack = g_try_new0(gint,g_list_length(keys)); + for (i=0;i<length;i++) { + something=g_list_nth_data(keys,i); + showtrack[i]=*something; + } + g_key_file_set_integer_list (cfgdata, + cfgsection, + cfgkey, + showtrack, + g_list_length(keys) + ); + + } else { + g_key_file_remove_key(cfgdata, + cfgsection, + cfgkey, + NULL); + } + + g_list_free (keys); +} Modified: trunk/src/mod-cfg-get-param.h =================================================================== --- trunk/src/mod-cfg-get-param.h 2011-10-23 12:25:13 UTC (rev 933) +++ trunk/src/mod-cfg-get-param.h 2011-10-23 12:33:34 UTC (rev 934) @@ -33,6 +33,9 @@ gboolean mod_cfg_get_bool (GKeyFile *f, const gchar *sec, const gchar *key, sat_cfg_bool_e p); gint mod_cfg_get_int (GKeyFile *f, const gchar *sec, const gchar *key, sat_cfg_int_e p); gchar *mod_cfg_get_str (GKeyFile *f, const gchar *sec, const gchar *key, sat_cfg_str_e p); +void mod_cfg_get_integer_list_boolean (GKeyFile *cfgdata,const gchar* section,const gchar *key,GHashTable *dest); +void mod_cfg_set_integer_list_boolean (GKeyFile *cfgdata, GHashTable *hash, const gchar *cfgsection, const gchar *cfgkey); + #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |