Thread: [Gpredict-svn] SF.net SVN: gpredict:[250] trunk/src (Page 3)
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
From: <cs...@us...> - 2009-04-12 14:05:13
|
Revision: 250 http://gpredict.svn.sourceforge.net/gpredict/?rev=250&view=rev Author: csete Date: 2009-04-12 14:05:11 +0000 (Sun, 12 Apr 2009) Log Message: ----------- Added checks for transponder data in user conf directory. Modified Paths: -------------- trunk/src/first-time.c trunk/src/first-time.h Modified: trunk/src/first-time.c =================================================================== --- trunk/src/first-time.c 2009-04-12 13:34:52 UTC (rev 249) +++ trunk/src/first-time.c 2009-04-12 14:05:11 UTC (rev 250) @@ -38,9 +38,7 @@ #include "first-time.h" -/**** FIXME: clean up / rewrite: check_dir, checkfile and driver */ - /* private function prototypes */ static void first_time_check_step_01 (guint *error); static void first_time_check_step_02 (guint *error); @@ -49,13 +47,15 @@ static void first_time_check_step_05 (guint *error); static void first_time_check_step_06 (guint *error); static void first_time_check_step_07 (guint *error); +static void first_time_check_step_08 (guint *error); +static void first_time_check_step_09 (guint *error); /** \brief Perform first time checks. * * This function is called by the main function very early during program - * startup. It's purpose is to check the user configuration to see weather + * startup. It's purpose is to check the user configuration to see whether * this is the first time gpredict is executed. If it is, a new default * configuration is set up so that the user has some sort of setup to get * started with. @@ -79,6 +79,10 @@ * network. * 7. Check for the existence of $HOME/.gpredict2/hwconf directory. This * directory contains radio and rotator configurations (.rig and .rot files). + * 8. Check for the existence of $HOME/.gpredict2/trsp directory. This + * directory contains transponder data for satellites. + * 9. Check the .trsp files in $HOME/.gpredict2/trsp/ and compare to the ones + * available in PACKAGE_DATA_DIR/data/xxx.trsp, and update if necessary. * * Send both error, warning and verbose debug messages to sat-log during this * process. @@ -92,17 +96,19 @@ guint first_time_check_run () { - guint error = 0; - - first_time_check_step_01 (&error); - first_time_check_step_02 (&error); - first_time_check_step_03 (&error); - first_time_check_step_04 (&error); - first_time_check_step_05 (&error); - first_time_check_step_06 (&error); + guint error = 0; + + first_time_check_step_01 (&error); + first_time_check_step_02 (&error); + first_time_check_step_03 (&error); + first_time_check_step_04 (&error); + first_time_check_step_05 (&error); + first_time_check_step_06 (&error); first_time_check_step_07 (&error); + first_time_check_step_08 (&error); + first_time_check_step_09 (&error); - return error; + return error; } @@ -115,41 +121,41 @@ static void first_time_check_step_01 (guint *error) { - gchar *dir; - int status; + gchar *dir; + int status; - dir = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", NULL); + dir = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, + ".gpredict2", NULL); - if (g_file_test (dir, G_FILE_TEST_IS_DIR)) { - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Check successful."), __FUNCTION__); - } - else { - /* try to create directory */ - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Check failed. Creating %s"), - __FUNCTION__, - dir); + if (g_file_test (dir, G_FILE_TEST_IS_DIR)) { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Check successful."), __FUNCTION__); + } + else { + /* try to create directory */ + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Check failed. Creating %s"), + __FUNCTION__, + dir); - status = g_mkdir (dir, 0755); + status = g_mkdir (dir, 0755); - if (status) { - /* set error flag */ - *error |= FTC_ERROR_STEP_01; + if (status) { + /* set error flag */ + *error |= FTC_ERROR_STEP_01; - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Failed to create %s"), - __FUNCTION__, dir ); - } - else { - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Created %s."), - __FUNCTION__, dir); - } - } + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Failed to create %s"), + __FUNCTION__, dir ); + } + else { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Created %s."), + __FUNCTION__, dir); + } + } - g_free (dir); + g_free (dir); } @@ -164,75 +170,75 @@ static void first_time_check_step_02 (guint *error) { - GDir *dir; - gchar *dirname; - gchar *filename; - const gchar *datafile; - gchar *target; - gboolean foundqth = FALSE; + GDir *dir; + gchar *dirname; + gchar *filename; + const gchar *datafile; + gchar *target; + gboolean foundqth = FALSE; - dirname = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", NULL); + dirname = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, + ".gpredict2", NULL); - dir = g_dir_open (dirname, 0, NULL); + dir = g_dir_open (dirname, 0, NULL); - /* directory does not exist, something went wrong in step 1 */ - if (!dir) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Could not open %s."), - __FUNCTION__, dirname); - - /* no reason to continue */ - *error |= FTC_ERROR_STEP_02; - } - else { - /* read files, if any; count number of .qth files */ - while ((datafile = g_dir_read_name (dir))) { + /* directory does not exist, something went wrong in step 1 */ + if (!dir) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Could not open %s."), + __FUNCTION__, dirname); + + /* no reason to continue */ + *error |= FTC_ERROR_STEP_02; + } + else { + /* read files, if any; count number of .qth files */ + while ((datafile = g_dir_read_name (dir))) { - /* note: filename is not a newly allocated gchar *, - so we must not free it - */ + /* note: filename is not a newly allocated gchar *, + so we must not free it + */ - if (g_strrstr (datafile, ".qth")) { - foundqth = TRUE; - } + if (g_strrstr (datafile, ".qth")) { + foundqth = TRUE; + } - } + } - g_dir_close (dir); + g_dir_close (dir); - if (foundqth) { - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Found at least one .qth file."), - __FUNCTION__); - } - else { - /* try to copy sample.qth */ - filename = data_file_name ("sample.qth"); - target = g_strconcat (dirname, G_DIR_SEPARATOR_S, - "sample.qth", NULL); + if (foundqth) { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Found at least one .qth file."), + __FUNCTION__); + } + else { + /* try to copy sample.qth */ + filename = data_file_name ("sample.qth"); + target = g_strconcat (dirname, G_DIR_SEPARATOR_S, + "sample.qth", NULL); - if (gpredict_file_copy (filename, target)) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Failed to copy sample.qth"), - __FUNCTION__); + if (gpredict_file_copy (filename, target)) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Failed to copy sample.qth"), + __FUNCTION__); - *error |= FTC_ERROR_STEP_02; - } - else { - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Copied sample.qth to %s/"), - __FUNCTION__, dirname); - } + *error |= FTC_ERROR_STEP_02; + } + else { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Copied sample.qth to %s/"), + __FUNCTION__, dirname); + } - g_free (target); - g_free (filename); + g_free (target); + g_free (filename); - } - } + } + } - g_free (dirname); + g_free (dirname); } @@ -246,67 +252,67 @@ static void first_time_check_step_03 (guint *error) { - gchar *dir; - int status; - gchar *target; - gchar *filename; + gchar *dir; + int status; + gchar *target; + gchar *filename; - dir = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "modules", NULL); + dir = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, + ".gpredict2", G_DIR_SEPARATOR_S, + "modules", NULL); - if (g_file_test (dir, G_FILE_TEST_IS_DIR)) { - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Check successful."), - __FUNCTION__); - } - else { - /* try to create directory */ - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Check failed. Creating %s"), - __FUNCTION__, - dir); + if (g_file_test (dir, G_FILE_TEST_IS_DIR)) { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Check successful."), + __FUNCTION__); + } + else { + /* try to create directory */ + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Check failed. Creating %s"), + __FUNCTION__, + dir); - status = g_mkdir (dir, 0755); + status = g_mkdir (dir, 0755); - if (status) { - /* set error flag */ - *error |= FTC_ERROR_STEP_03; + if (status) { + /* set error flag */ + *error |= FTC_ERROR_STEP_03; - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Failed to create %s"), - __FUNCTION__, dir); - } - else { - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Created %s."), - __FUNCTION__, dir); + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Failed to create %s"), + __FUNCTION__, dir); + } + else { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Created %s."), + __FUNCTION__, dir); - /* copy Amateur.mod to this directory */ - filename = data_file_name ("Amateur.mod"); - target = g_strconcat (dir, G_DIR_SEPARATOR_S, - "Amateur.mod", NULL); + /* copy Amateur.mod to this directory */ + filename = data_file_name ("Amateur.mod"); + target = g_strconcat (dir, G_DIR_SEPARATOR_S, + "Amateur.mod", NULL); - if (gpredict_file_copy (filename, target)) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Failed to copy Amateur.mod"), - __FUNCTION__); + if (gpredict_file_copy (filename, target)) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Failed to copy Amateur.mod"), + __FUNCTION__); - *error |= FTC_ERROR_STEP_02; - } - else { - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Copied amateur.mod to %s/"), - __FUNCTION__, dir); - } + *error |= FTC_ERROR_STEP_02; + } + else { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Copied amateur.mod to %s/"), + __FUNCTION__, dir); + } - g_free (target); - g_free (filename); - } - } + g_free (target); + g_free (filename); + } + } - g_free (dir); + g_free (dir); } @@ -320,40 +326,40 @@ static void first_time_check_step_04 (guint *error) { - gchar *dir; - int status; + gchar *dir; + int status; - dir = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "tle", NULL); + dir = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, + ".gpredict2", G_DIR_SEPARATOR_S, + "tle", NULL); - if (g_file_test (dir, G_FILE_TEST_IS_DIR)) { - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Check successful."), __FUNCTION__); - } - else { - /* try to create directory */ - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Check failed. Creating %s"), - __FUNCTION__, dir); + if (g_file_test (dir, G_FILE_TEST_IS_DIR)) { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Check successful."), __FUNCTION__); + } + else { + /* try to create directory */ + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Check failed. Creating %s"), + __FUNCTION__, dir); - status = g_mkdir (dir, 0755); + status = g_mkdir (dir, 0755); - if (status) { - /* set error flag */ - *error |= FTC_ERROR_STEP_04; + if (status) { + /* set error flag */ + *error |= FTC_ERROR_STEP_04; - sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Failed to create %s"), - __FUNCTION__, dir); - } - else { - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Created %s."), - __FUNCTION__, dir); - } - } + sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Failed to create %s"), + __FUNCTION__, dir); + } + else { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Created %s."), + __FUNCTION__, dir); + } + } - g_free (dir); + g_free (dir); } @@ -368,97 +374,97 @@ static void first_time_check_step_05 (guint *error) { - GDir *dir; - gchar *dirname; - gchar *datadir; - const gchar *filename; - gchar *target; - gchar *tlefile; - gboolean foundtle = FALSE; + GDir *dir; + gchar *dirname; + gchar *datadir; + const gchar *filename; + gchar *target; + gchar *tlefile; + gboolean foundtle = FALSE; - dirname = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "tle", NULL); + dirname = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, + ".gpredict2", G_DIR_SEPARATOR_S, + "tle", NULL); - dir = g_dir_open (dirname, 0, NULL); + dir = g_dir_open (dirname, 0, NULL); - /* directory does not exist, something went wrong in step 1 */ - if (!dir) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Could not open %s."), - __FUNCTION__, dirname); - - /* no reason to continue */ - *error |= FTC_ERROR_STEP_05; - } - else { - /* read files, if any; count number of .tle files */ - while ((filename = g_dir_read_name (dir))) { + /* directory does not exist, something went wrong in step 1 */ + if (!dir) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Could not open %s."), + __FUNCTION__, dirname); + + /* no reason to continue */ + *error |= FTC_ERROR_STEP_05; + } + else { + /* read files, if any; count number of .tle files */ + while ((filename = g_dir_read_name (dir))) { - /* note: filename is not a newly allocated gchar *, - so we must not free it - */ + /* note: filename is not a newly allocated gchar *, + so we must not free it + */ - if (g_strrstr (filename, ".tle")) { - foundtle = TRUE; - } + if (g_strrstr (filename, ".tle")) { + foundtle = TRUE; + } - } + } - g_dir_close (dir); + g_dir_close (dir); - if (foundtle) { - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Found at least one .tle file."), - __FUNCTION__); - } - else { + if (foundtle) { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Found at least one .tle file."), + __FUNCTION__); + } + else { - /* try to copy each tle file from instalation dir */ - datadir = get_data_dir (); - dir = g_dir_open (datadir, 0, NULL); + /* try to copy each tle file from instalation dir */ + datadir = get_data_dir (); + dir = g_dir_open (datadir, 0, NULL); - /* g_print ("====> %s\n", datadir); */ + /* g_print ("====> %s\n", datadir); */ - while ((filename = g_dir_read_name (dir))) { + while ((filename = g_dir_read_name (dir))) { - /* note: filename is not a newly allocated gchar *, - so we must not free it - */ + /* note: filename is not a newly allocated gchar *, + so we must not free it + */ - if (g_strrstr (filename, ".tle")) { + if (g_strrstr (filename, ".tle")) { - tlefile = data_file_name (filename); + tlefile = data_file_name (filename); - target = g_strconcat (dirname, - G_DIR_SEPARATOR_S, - filename, - NULL); + target = g_strconcat (dirname, + G_DIR_SEPARATOR_S, + filename, + NULL); - if (gpredict_file_copy (tlefile, target)) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Failed to copy %s"), - __FUNCTION__, filename); + if (gpredict_file_copy (tlefile, target)) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Failed to copy %s"), + __FUNCTION__, filename); - *error |= FTC_ERROR_STEP_05; - } - else { - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Successfully copied %s"), - __FUNCTION__, filename); - } - g_free (tlefile); - g_free (target); - } + *error |= FTC_ERROR_STEP_05; + } + else { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Successfully copied %s"), + __FUNCTION__, filename); + } + g_free (tlefile); + g_free (target); + } - } - g_free (datadir); - g_dir_close (dir); - } + } + g_free (datadir); + g_dir_close (dir); + } - } - g_free (dirname); + } + g_free (dirname); } @@ -473,41 +479,41 @@ static void first_time_check_step_06 (guint *error) { - gchar *dir; - int status; + gchar *dir; + int status; - dir = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "tle", G_DIR_SEPARATOR_S, - "cache", NULL); + dir = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, + ".gpredict2", G_DIR_SEPARATOR_S, + "tle", G_DIR_SEPARATOR_S, + "cache", NULL); - if (g_file_test (dir, G_FILE_TEST_IS_DIR)) { - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Check successful."), __FUNCTION__); - } - else { - /* try to create directory */ - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Check failed. Creating %s"), - __FUNCTION__, dir); + if (g_file_test (dir, G_FILE_TEST_IS_DIR)) { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Check successful."), __FUNCTION__); + } + else { + /* try to create directory */ + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Check failed. Creating %s"), + __FUNCTION__, dir); - status = g_mkdir (dir, 0755); + status = g_mkdir (dir, 0755); - if (status) { - /* set error flag */ - *error |= FTC_ERROR_STEP_06; + if (status) { + /* set error flag */ + *error |= FTC_ERROR_STEP_06; - sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Failed to create %s"), - __FUNCTION__, dir); - } - else { - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Created %s."), - __FUNCTION__, dir); - } - } + sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Failed to create %s"), + __FUNCTION__, dir); + } + else { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Created %s."), + __FUNCTION__, dir); + } + } - g_free (dir); + g_free (dir); } @@ -556,3 +562,125 @@ g_free (dir); } +/** \brief Execute step 8 of the first time checks. + * + * 8. Check for the existence of $HOME/.gpredict2/trsp directory. This + * directory contains transponder data for satellites. + * + */ +static void first_time_check_step_08 (guint *error) +{ + gchar *cfg; + gchar *dir; + int status; + + cfg = get_conf_dir (); + dir = g_strconcat (cfg, G_DIR_SEPARATOR_S, "trsp", NULL); + g_free (cfg); + + if (g_file_test (dir, G_FILE_TEST_IS_DIR)) { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Check successful."), __FUNCTION__); + } + else { + /* try to create directory */ + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Check failed. Creating %s"), + __FUNCTION__, dir); + + status = g_mkdir (dir, 0755); + + if (status) { + /* set error flag */ + *error |= FTC_ERROR_STEP_08; + + sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Failed to create %s"), + __FUNCTION__, dir); + } + else { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Created %s."), + __FUNCTION__, dir); + } + } + + g_free (dir); +} + +/** \brief Execute step 9 of the first time checks. + * + * 9. Check the .trsp files in $HOME/.gpredict2/trsp/ and compare to the ones + * available in PACKAGE_DATA_DIR/data/xxx.trsp, and update if necessary. + * + */ +static void first_time_check_step_09 (guint *error) +{ + GDir *targetdir,*dir; + gchar *targetdirname; + gchar *datadirname; + const gchar *filename; + gchar *srcfile,*destfile; + + + /* open data directory */ + targetdirname = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, + ".gpredict2", G_DIR_SEPARATOR_S, + "trsp", NULL); + + targetdir = g_dir_open (targetdirname, 0, NULL); + + /* directory does not exist, something went wrong in step 1 */ + if (!targetdir) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Could not open %s."), + __FUNCTION__, targetdirname); + + /* no reason to continue */ + *error |= FTC_ERROR_STEP_09; + } + else { + /* no need to keep this dir open */ + g_dir_close (targetdir); + + /* open data dir */ + datadirname = get_data_dir (); + dir = g_dir_open (datadirname, 0, NULL); + + /* for each .trsp file found in data dir */ + while ((filename = g_dir_read_name (dir))) { + if (g_strrstr (filename, ".trsp")) { + /* check if .trsp file already in user dir */ + destfile = g_strconcat (targetdirname, G_DIR_SEPARATOR_S, filename, NULL); + + /* check if .trsp file already in user dir */ + if (!g_file_test (destfile, G_FILE_TEST_EXISTS)) { + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: %s does not appear to be in user conf dir; adding."), + __FUNCTION__, filename); + + /* copy new .trsp file to user dir */ + srcfile = g_strconcat (datadirname, G_DIR_SEPARATOR_S, filename,NULL); + if (gpredict_file_copy (srcfile, destfile)) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Failed to copy %s"), + __FUNCTION__, filename); + + *error |= FTC_ERROR_STEP_09; + } + g_free (srcfile); + } + else { + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: %s already in user conf dir."), + __FUNCTION__, filename); + } + + g_free (destfile); + + } + } + g_dir_close (dir); + g_free (datadirname); + } + g_free (targetdirname); +} Modified: trunk/src/first-time.h =================================================================== --- trunk/src/first-time.h 2009-04-12 13:34:52 UTC (rev 249) +++ trunk/src/first-time.h 2009-04-12 14:05:11 UTC (rev 250) @@ -31,13 +31,15 @@ /** \brief Bit fields in the returned error code */ enum { - FTC_ERROR_STEP_01 = 1 << 1, - FTC_ERROR_STEP_02 = 1 << 2, - FTC_ERROR_STEP_03 = 1 << 3, - FTC_ERROR_STEP_04 = 1 << 4, - FTC_ERROR_STEP_05 = 1 << 5, - FTC_ERROR_STEP_06 = 1 << 6, - FTC_ERROR_STEP_07 = 1 << 7 + FTC_ERROR_STEP_01 = 1 << 1, + FTC_ERROR_STEP_02 = 1 << 2, + FTC_ERROR_STEP_03 = 1 << 3, + FTC_ERROR_STEP_04 = 1 << 4, + FTC_ERROR_STEP_05 = 1 << 5, + FTC_ERROR_STEP_06 = 1 << 6, + FTC_ERROR_STEP_07 = 1 << 7, + FTC_ERROR_STEP_08 = 1 << 8, + FTC_ERROR_STEP_09 = 1 << 9 }; guint first_time_check_run (void); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-04-12 18:32:15
|
Revision: 253 http://gpredict.svn.sourceforge.net/gpredict/?rev=253&view=rev Author: csete Date: 2009-04-12 18:32:11 +0000 (Sun, 12 Apr 2009) Log Message: ----------- Added mode string. Modified Paths: -------------- trunk/src/trsp-conf.c trunk/src/trsp-conf.h Modified: trunk/src/trsp-conf.c =================================================================== --- trunk/src/trsp-conf.c 2009-04-12 16:27:13 UTC (rev 252) +++ trunk/src/trsp-conf.c 2009-04-12 18:32:11 UTC (rev 253) @@ -39,6 +39,7 @@ #define KEY_DOWN_LOW "DOWN_LOW" #define KEY_DOWN_HIGH "DOWN_HIGH" #define KEY_INVERT "INVERT" +#define KEY_MODE "MODE" /** \brief Read transponder data file. * \param catnum The catalog number of the satellite to read transponders for. @@ -138,6 +139,14 @@ g_clear_error (&error); trsp->invert = FALSE; } + + trsp->mode = g_key_file_get_string (cfg, groups[i], KEY_MODE, &error); + if (error != NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Error reading %s:%s from %s"), + __FUNCTION__, groups[i], KEY_MODE, name); + g_clear_error (&error); + } /* add transponder to list */ trsplist = g_slist_append (trsplist, trsp); @@ -182,6 +191,8 @@ trsp = (trsp_t *) g_slist_nth_data (trsplist, i); g_free (trsp->name); g_free (trsp); + if (trsp->mode) + g_free (trsp->mode); } g_slist_free (trsplist); trsplist = NULL; Modified: trunk/src/trsp-conf.h =================================================================== --- trunk/src/trsp-conf.h 2009-04-12 16:27:13 UTC (rev 252) +++ trunk/src/trsp-conf.h 2009-04-12 18:32:11 UTC (rev 253) @@ -40,6 +40,7 @@ gdouble downlow; /*!< Lower limit of downlink. */ gdouble downhigh; /*!< Upper limit of donlink. */ gboolean invert; /*!< Flag indicating whether transponder is inverting. */ + gchar *mode; /*!< Mode descriptor. */ } trsp_t; /* The actual data would then be a singly linked list with pointers to transponder_t structures */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-04-13 10:53:39
|
Revision: 266 http://gpredict.svn.sourceforge.net/gpredict/?rev=266&view=rev Author: csete Date: 2009-04-13 10:53:28 +0000 (Mon, 13 Apr 2009) Log Message: ----------- Fixed indent. Modified Paths: -------------- trunk/src/gtk-sky-glance.c trunk/src/gtk-sky-glance.h trunk/src/predict-tools.c trunk/src/predict-tools.h Modified: trunk/src/gtk-sky-glance.c =================================================================== --- trunk/src/gtk-sky-glance.c 2009-04-13 10:38:53 UTC (rev 265) +++ trunk/src/gtk-sky-glance.c 2009-04-13 10:53:28 UTC (rev 266) @@ -67,25 +67,25 @@ static void gtk_sky_glance_init (GtkSkyGlance *skg); static void gtk_sky_glance_destroy (GtkObject *object); static void size_allocate_cb (GtkWidget *widget, - GtkAllocation *allocation, - gpointer data); + GtkAllocation *allocation, + gpointer data); static gboolean on_motion_notify (GooCanvasItem *item, - GooCanvasItem *target, - GdkEventMotion *event, - gpointer data); + GooCanvasItem *target, + GdkEventMotion *event, + gpointer data); static void on_item_created (GooCanvas *canvas, - GooCanvasItem *item, - GooCanvasItemModel *model, - gpointer data); + GooCanvasItem *item, + GooCanvasItemModel *model, + gpointer data); static void on_canvas_realized (GtkWidget *canvas, gpointer data); static gboolean on_button_press (GooCanvasItem *item, - GooCanvasItem *target, - GdkEventButton *event, - gpointer data); + GooCanvasItem *target, + GdkEventButton *event, + gpointer data); static gboolean on_button_release (GooCanvasItem *item, - GooCanvasItem *target, - GdkEventButton *event, - gpointer data); + GooCanvasItem *target, + GdkEventButton *event, + gpointer data); static GooCanvasItemModel* create_canvas_model (GtkSkyGlance *skg); @@ -103,67 +103,67 @@ GtkType gtk_sky_glance_get_type () { - static GType gtk_sky_glance_type = 0; + static GType gtk_sky_glance_type = 0; - if (!gtk_sky_glance_type) { - static const GTypeInfo gtk_sky_glance_info = { - sizeof (GtkSkyGlanceClass), - NULL, /* base init */ - NULL, /* base finalise */ - (GClassInitFunc) gtk_sky_glance_class_init, - NULL, /* class finalise */ - NULL, /* class data */ - sizeof (GtkSkyGlance), - 1, /* n_preallocs */ - (GInstanceInitFunc) gtk_sky_glance_init, - }; + if (!gtk_sky_glance_type) { + static const GTypeInfo gtk_sky_glance_info = { + sizeof (GtkSkyGlanceClass), + NULL, /* base init */ + NULL, /* base finalise */ + (GClassInitFunc) gtk_sky_glance_class_init, + NULL, /* class finalise */ + NULL, /* class data */ + sizeof (GtkSkyGlance), + 1, /* n_preallocs */ + (GInstanceInitFunc) gtk_sky_glance_init, + }; - gtk_sky_glance_type = g_type_register_static (GTK_TYPE_VBOX, - "GtkSkyGlance", - >k_sky_glance_info, - 0); - } + gtk_sky_glance_type = g_type_register_static (GTK_TYPE_VBOX, + "GtkSkyGlance", + >k_sky_glance_info, + 0); + } - return gtk_sky_glance_type; + return gtk_sky_glance_type; } static void gtk_sky_glance_class_init (GtkSkyGlanceClass *class) { - GObjectClass *gobject_class; - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; + GObjectClass *gobject_class; + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + GtkContainerClass *container_class; - gobject_class = G_OBJECT_CLASS (class); - object_class = (GtkObjectClass*) class; - widget_class = (GtkWidgetClass*) class; - container_class = (GtkContainerClass*) class; + gobject_class = G_OBJECT_CLASS (class); + object_class = (GtkObjectClass*) class; + widget_class = (GtkWidgetClass*) class; + container_class = (GtkContainerClass*) class; - parent_class = g_type_class_peek_parent (class); + parent_class = g_type_class_peek_parent (class); - object_class->destroy = gtk_sky_glance_destroy; - //widget_class->size_allocate = gtk_sky_glance_size_allocate; + object_class->destroy = gtk_sky_glance_destroy; + //widget_class->size_allocate = gtk_sky_glance_size_allocate; } static void gtk_sky_glance_init (GtkSkyGlance *skg) { - skg->sats = NULL; - skg->qth = NULL; - skg->passes = NULL; - skg->satlab = NULL; - skg->x0 = 0; - skg->y0 = 0; - skg->w = 0; - skg->h = 0; - skg->pps = 0; - skg->numsat = 0; - skg->satcnt = 0; - skg->ts = 0.0; - skg->te = 0.0; + skg->sats = NULL; + skg->qth = NULL; + skg->passes = NULL; + skg->satlab = NULL; + skg->x0 = 0; + skg->y0 = 0; + skg->w = 0; + skg->h = 0; + skg->pps = 0; + skg->numsat = 0; + skg->satcnt = 0; + skg->ts = 0.0; + skg->te = 0.0; } @@ -173,46 +173,46 @@ static void gtk_sky_glance_destroy (GtkObject *object) { - sky_pass_t *skypass; - guint i, n; + sky_pass_t *skypass; + guint i, n; - /* free passes */ - /* FIXME: TBC whether this is enough */ - if (GTK_SKY_GLANCE (object)->passes != NULL) { + /* free passes */ + /* FIXME: TBC whether this is enough */ + if (GTK_SKY_GLANCE (object)->passes != NULL) { - n = g_slist_length (GTK_SKY_GLANCE (object)->passes); - for (i = 0; i < n; i++) { - skypass = (sky_pass_t *) g_slist_nth_data (GTK_SKY_GLANCE (object)->passes, i); - free_pass (skypass->pass); - g_free (skypass); - } + n = g_slist_length (GTK_SKY_GLANCE (object)->passes); + for (i = 0; i < n; i++) { + skypass = (sky_pass_t *) g_slist_nth_data (GTK_SKY_GLANCE (object)->passes, i); + free_pass (skypass->pass); + g_free (skypass); + } - g_slist_free (GTK_SKY_GLANCE (object)->passes); - GTK_SKY_GLANCE (object)->passes = NULL; - } + g_slist_free (GTK_SKY_GLANCE (object)->passes); + GTK_SKY_GLANCE (object)->passes = NULL; + } - /* for the rest we only need to free the GSList because the - canvas items will be freed when removed from canvas. - */ - if (GTK_SKY_GLANCE (object)->satlab != NULL) { - g_slist_free (GTK_SKY_GLANCE (object)->satlab); - GTK_SKY_GLANCE (object)->satlab = NULL; - } - if (GTK_SKY_GLANCE (object)->majors != NULL) { - g_slist_free (GTK_SKY_GLANCE (object)->majors); - GTK_SKY_GLANCE (object)->majors = NULL; - } - if (GTK_SKY_GLANCE (object)->minors != NULL) { - g_slist_free (GTK_SKY_GLANCE (object)->minors); - GTK_SKY_GLANCE (object)->minors = NULL; - } - if (GTK_SKY_GLANCE (object)->labels != NULL) { - g_slist_free (GTK_SKY_GLANCE (object)->labels); - GTK_SKY_GLANCE (object)->labels = NULL; - } + /* for the rest we only need to free the GSList because the + canvas items will be freed when removed from canvas. + */ + if (GTK_SKY_GLANCE (object)->satlab != NULL) { + g_slist_free (GTK_SKY_GLANCE (object)->satlab); + GTK_SKY_GLANCE (object)->satlab = NULL; + } + if (GTK_SKY_GLANCE (object)->majors != NULL) { + g_slist_free (GTK_SKY_GLANCE (object)->majors); + GTK_SKY_GLANCE (object)->majors = NULL; + } + if (GTK_SKY_GLANCE (object)->minors != NULL) { + g_slist_free (GTK_SKY_GLANCE (object)->minors); + GTK_SKY_GLANCE (object)->minors = NULL; + } + if (GTK_SKY_GLANCE (object)->labels != NULL) { + g_slist_free (GTK_SKY_GLANCE (object)->labels); + GTK_SKY_GLANCE (object)->labels = NULL; + } - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } @@ -225,20 +225,20 @@ GtkWidget* gtk_sky_glance_new (GHashTable *sats, qth_t *qth, gdouble ts) { - GtkWidget *skg; - GooCanvasItemModel *root; - GdkColor bg_color = {0, 0xFFFF, 0xFFFF, 0xFFFF}; + GtkWidget *skg; + GooCanvasItemModel *root; + GdkColor bg_color = {0, 0xFFFF, 0xFFFF, 0xFFFF}; - skg = g_object_new (GTK_TYPE_SKY_GLANCE, NULL); + skg = g_object_new (GTK_TYPE_SKY_GLANCE, NULL); - /* FIXME? */ - GTK_SKY_GLANCE (skg)->sats = sats; - GTK_SKY_GLANCE (skg)->qth = qth; + /* FIXME? */ + GTK_SKY_GLANCE (skg)->sats = sats; + GTK_SKY_GLANCE (skg)->qth = qth; - /* get settings */ - GTK_SKY_GLANCE (skg)->numsat = g_hash_table_size (sats); - + /* get settings */ + GTK_SKY_GLANCE (skg)->numsat = g_hash_table_size (sats); + /* if ts = 0 use current time */ if (ts > 0.0) { GTK_SKY_GLANCE (skg)->ts = ts; @@ -246,159 +246,159 @@ else { GTK_SKY_GLANCE (skg)->ts = get_current_daynum (); } - - GTK_SKY_GLANCE (skg)->te = GTK_SKY_GLANCE (skg)->ts + - sat_cfg_get_int (SAT_CFG_INT_SKYATGL_TIME)*(1.0/24.0); - /* calculate preferred sizes */ - GTK_SKY_GLANCE (skg)->w = SKG_DEFAULT_WIDTH; - GTK_SKY_GLANCE (skg)->h = GTK_SKY_GLANCE (skg)->numsat * SKG_PIX_PER_SAT + - (GTK_SKY_GLANCE (skg)->numsat + 1) * SKG_MARGIN; - GTK_SKY_GLANCE (skg)->pps = SKG_PIX_PER_SAT; + GTK_SKY_GLANCE (skg)->te = GTK_SKY_GLANCE (skg)->ts + + sat_cfg_get_int (SAT_CFG_INT_SKYATGL_TIME)*(1.0/24.0); - /* create the canvas */ - GTK_SKY_GLANCE (skg)->canvas = goo_canvas_new (); - gtk_widget_modify_base (GTK_SKY_GLANCE (skg)->canvas, GTK_STATE_NORMAL, &bg_color); - gtk_widget_set_size_request (GTK_SKY_GLANCE (skg)->canvas, - GTK_SKY_GLANCE (skg)->w, - GTK_SKY_GLANCE (skg)->h + SKG_FOOTER); - goo_canvas_set_bounds (GOO_CANVAS (GTK_SKY_GLANCE (skg)->canvas), 0, 0, - GTK_SKY_GLANCE (skg)->w, - GTK_SKY_GLANCE (skg)->h + SKG_FOOTER); + /* calculate preferred sizes */ + GTK_SKY_GLANCE (skg)->w = SKG_DEFAULT_WIDTH; + GTK_SKY_GLANCE (skg)->h = GTK_SKY_GLANCE (skg)->numsat * SKG_PIX_PER_SAT + + (GTK_SKY_GLANCE (skg)->numsat + 1) * SKG_MARGIN; + GTK_SKY_GLANCE (skg)->pps = SKG_PIX_PER_SAT; - /* connect size-request signal */ - g_signal_connect (GTK_SKY_GLANCE (skg)->canvas, "size-allocate", - G_CALLBACK (size_allocate_cb), skg); - g_signal_connect (GTK_SKY_GLANCE (skg)->canvas, "item_created", - (GtkSignalFunc) on_item_created, skg); - g_signal_connect_after (GTK_SKY_GLANCE (skg)->canvas, "realize", - (GtkSignalFunc) on_canvas_realized, skg); + /* create the canvas */ + GTK_SKY_GLANCE (skg)->canvas = goo_canvas_new (); + gtk_widget_modify_base (GTK_SKY_GLANCE (skg)->canvas, GTK_STATE_NORMAL, &bg_color); + gtk_widget_set_size_request (GTK_SKY_GLANCE (skg)->canvas, + GTK_SKY_GLANCE (skg)->w, + GTK_SKY_GLANCE (skg)->h + SKG_FOOTER); + goo_canvas_set_bounds (GOO_CANVAS (GTK_SKY_GLANCE (skg)->canvas), 0, 0, + GTK_SKY_GLANCE (skg)->w, + GTK_SKY_GLANCE (skg)->h + SKG_FOOTER); - gtk_widget_show (GTK_SKY_GLANCE (skg)->canvas); + /* connect size-request signal */ + g_signal_connect (GTK_SKY_GLANCE (skg)->canvas, "size-allocate", + G_CALLBACK (size_allocate_cb), skg); + g_signal_connect (GTK_SKY_GLANCE (skg)->canvas, "item_created", + (GtkSignalFunc) on_item_created, skg); + g_signal_connect_after (GTK_SKY_GLANCE (skg)->canvas, "realize", + (GtkSignalFunc) on_canvas_realized, skg); + gtk_widget_show (GTK_SKY_GLANCE (skg)->canvas); - /* Create the canvas model */ - root = create_canvas_model (GTK_SKY_GLANCE (skg)); - goo_canvas_set_root_item_model (GOO_CANVAS (GTK_SKY_GLANCE (skg)->canvas), root); - g_object_unref (root); + /* Create the canvas model */ + root = create_canvas_model (GTK_SKY_GLANCE (skg)); + goo_canvas_set_root_item_model (GOO_CANVAS (GTK_SKY_GLANCE (skg)->canvas), root); - /* add satellite passes */ - g_hash_table_foreach (GTK_SKY_GLANCE (skg)->sats, create_sat, skg); + g_object_unref (root); - gtk_container_add (GTK_CONTAINER (skg), GTK_SKY_GLANCE (skg)->canvas); + /* add satellite passes */ + g_hash_table_foreach (GTK_SKY_GLANCE (skg)->sats, create_sat, skg); - return skg; + gtk_container_add (GTK_CONTAINER (skg), GTK_SKY_GLANCE (skg)->canvas); + + return skg; } static GooCanvasItemModel * create_canvas_model (GtkSkyGlance *skg) { - GooCanvasItemModel *root; - GooCanvasItemModel *hrt,*hrl,*hrm; - guint i,n; - gdouble th,tm; - time_t tt; - gdouble xh,xm; - gchar buff[3]; + GooCanvasItemModel *root; + GooCanvasItemModel *hrt,*hrl,*hrm; + guint i,n; + gdouble th,tm; + time_t tt; + gdouble xh,xm; + gchar buff[3]; - root = goo_canvas_group_model_new (NULL, NULL); + root = goo_canvas_group_model_new (NULL, NULL); - /* cursor tracking line */ - skg->cursor = goo_canvas_polyline_model_new_line (root, - skg->x0, skg->y0, skg->x0, skg->h, - "stroke-color-rgba", 0x000000AF, - "line-width", 0.5, - NULL); + /* cursor tracking line */ + skg->cursor = goo_canvas_polyline_model_new_line (root, + skg->x0, skg->y0, skg->x0, skg->h, + "stroke-color-rgba", 0x000000AF, + "line-width", 0.5, + NULL); - /* time label */ - skg->timel = goo_canvas_text_model_new (root, "--:--", skg->x0 + 5, skg->y0, -1, GTK_ANCHOR_NW, - "font", "Sans 8", - "fill-color-rgba", 0x000000AF, - NULL); + /* time label */ + skg->timel = goo_canvas_text_model_new (root, "--:--", skg->x0 + 5, skg->y0, -1, GTK_ANCHOR_NW, + "font", "Sans 8", + "fill-color-rgba", 0x000000AF, + NULL); - /* footer */ - skg->footer = goo_canvas_rect_model_new (root, - skg->x0, skg->h, - skg->w, SKG_FOOTER, - "fill-color-rgba", 0x00003FFF, - "stroke-color-rgba", 0xFFFFFFFF, - NULL); + /* footer */ + skg->footer = goo_canvas_rect_model_new (root, + skg->x0, skg->h, + skg->w, SKG_FOOTER, + "fill-color-rgba", 0x00003FFF, + "stroke-color-rgba", 0xFFFFFFFF, + NULL); - /* time ticks and labels */ - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - skg->axisl = goo_canvas_text_model_new (root, _("TIME"), - skg->w / 2, skg->h + SKG_FOOTER - 5, - -1, GTK_ANCHOR_S, - "font", "Sans 9", - "fill-color-rgba", 0xFFFFFFFF, - NULL); - else - skg->axisl = goo_canvas_text_model_new (root, _("UTC"), - skg->w / 2, skg->h + SKG_FOOTER - 5, - -1, GTK_ANCHOR_S, - "font", "Sans 9", - "fill-color-rgba", 0xFFFFFFFF, - NULL); + /* time ticks and labels */ + if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) + skg->axisl = goo_canvas_text_model_new (root, _("TIME"), + skg->w / 2, skg->h + SKG_FOOTER - 5, + -1, GTK_ANCHOR_S, + "font", "Sans 9", + "fill-color-rgba", 0xFFFFFFFF, + NULL); + else + skg->axisl = goo_canvas_text_model_new (root, _("UTC"), + skg->w / 2, skg->h + SKG_FOOTER - 5, + -1, GTK_ANCHOR_S, + "font", "Sans 9", + "fill-color-rgba", 0xFFFFFFFF, + NULL); - /* get the first hour and first 30 min slot */ - th = ceil (skg->ts * 24.0) / 24.0; + /* get the first hour and first 30 min slot */ + th = ceil (skg->ts * 24.0) / 24.0; - /* workaround for bug 1839140 (first hour incorrexct) */ - th += 0.00069; - - /* the first 30 min tick can be either before - or after the first hour tick - */ - if ((th - skg->ts) > 0.0208333) { - tm = th - 0.0208333; - } - else { - tm = th + 0.0208333; - } + /* workaround for bug 1839140 (first hour incorrexct) */ + th += 0.00069; - /* the number of steps equals the number of hours */ - n = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_TIME); - for (i = 0; i < n; i++) { + /* the first 30 min tick can be either before + or after the first hour tick + */ + if ((th - skg->ts) > 0.0208333) { + tm = th - 0.0208333; + } + else { + tm = th + 0.0208333; + } - /* hour tick */ - xh = t2x (skg, th); - hrt = goo_canvas_polyline_model_new_line (root, xh, skg->h, xh, skg->h + 10, - "stroke-color-rgba", 0xFFFFFFFF, - NULL); + /* the number of steps equals the number of hours */ + n = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_TIME); + for (i = 0; i < n; i++) { - /* hour tick label */ - tt = (th - 2440587.5)*86400.0; - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - strftime (buff, 3, "%H", localtime (&tt)); - else - strftime (buff, 3, "%H", gmtime (&tt)); - - buff[2] = '\0'; - hrl = goo_canvas_text_model_new (root, buff, xh, skg->h + 12, - -1, GTK_ANCHOR_N, - "font", "Sans 8", - "fill-color-rgba", 0xFFFFFFFF, - NULL); + /* hour tick */ + xh = t2x (skg, th); + hrt = goo_canvas_polyline_model_new_line (root, xh, skg->h, xh, skg->h + 10, + "stroke-color-rgba", 0xFFFFFFFF, + NULL); - /* 30 min tick */ - xm = t2x (skg, tm); - hrm = goo_canvas_polyline_model_new_line (root, xm, skg->h, xm, skg->h + 5, - "stroke-color-rgba", 0xFFFFFFFF, - NULL); + /* hour tick label */ + tt = (th - 2440587.5)*86400.0; + if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) + strftime (buff, 3, "%H", localtime (&tt)); + else + strftime (buff, 3, "%H", gmtime (&tt)); + + buff[2] = '\0'; + hrl = goo_canvas_text_model_new (root, buff, xh, skg->h + 12, + -1, GTK_ANCHOR_N, + "font", "Sans 8", + "fill-color-rgba", 0xFFFFFFFF, + NULL); - /* store canvas items */ - skg->majors = g_slist_append (skg->majors, hrt); - skg->labels = g_slist_append (skg->labels, hrl); - skg->minors = g_slist_append (skg->minors, hrm); + /* 30 min tick */ + xm = t2x (skg, tm); + hrm = goo_canvas_polyline_model_new_line (root, xm, skg->h, xm, skg->h + 5, + "stroke-color-rgba", 0xFFFFFFFF, + NULL); - th += 0.0416667; - tm += 0.0416667; - } + /* store canvas items */ + skg->majors = g_slist_append (skg->majors, hrt); + skg->labels = g_slist_append (skg->labels, hrl); + skg->minors = g_slist_append (skg->minors, hrm); - return root; + th += 0.0416667; + tm += 0.0416667; + } + + return root; } @@ -413,154 +413,154 @@ static void size_allocate_cb (GtkWidget *widget, GtkAllocation *allocation, gpointer data) { - GtkSkyGlance *skg; - GooCanvasPoints *pts; - GooCanvasItem *obj; - gint i,j,n; - guint curcat; - gdouble th,tm; - gdouble xh,xm; - sky_pass_t *skp; - gdouble x,y,w,h; + GtkSkyGlance *skg; + GooCanvasPoints *pts; + GooCanvasItem *obj; + gint i,j,n; + guint curcat; + gdouble th,tm; + gdouble xh,xm; + sky_pass_t *skp; + gdouble x,y,w,h; - if (GTK_WIDGET_REALIZED (widget)) { + if (GTK_WIDGET_REALIZED (widget)) { - /* get graph dimensions */ - skg = GTK_SKY_GLANCE (data); + /* get graph dimensions */ + skg = GTK_SKY_GLANCE (data); - skg->w = allocation->width; - skg->h = allocation->height - SKG_FOOTER; - skg->x0 = 0; - skg->y0 = 0; + skg->w = allocation->width; + skg->h = allocation->height - SKG_FOOTER; + skg->x0 = 0; + skg->y0 = 0; - skg->pps = (skg->h - SKG_MARGIN) / skg->numsat - SKG_MARGIN; + skg->pps = (skg->h - SKG_MARGIN) / skg->numsat - SKG_MARGIN; goo_canvas_set_bounds (GOO_CANVAS (GTK_SKY_GLANCE (skg)->canvas), 0, 0, allocation->width, allocation->height); - /* update cursor tracking line */ - pts = goo_canvas_points_new (2); - pts->coords[0] = skg->x0; - pts->coords[1] = skg->y0; - pts->coords[2] = skg->x0; - pts->coords[3] = skg->h; - g_object_set (skg->cursor, "points", pts, NULL); - goo_canvas_points_unref (pts); + /* update cursor tracking line */ + pts = goo_canvas_points_new (2); + pts->coords[0] = skg->x0; + pts->coords[1] = skg->y0; + pts->coords[2] = skg->x0; + pts->coords[3] = skg->h; + g_object_set (skg->cursor, "points", pts, NULL); + goo_canvas_points_unref (pts); - /* time label */ - g_object_set (skg->timel, - "x", (gdouble) skg->x0 + 5, - NULL); + /* time label */ + g_object_set (skg->timel, + "x", (gdouble) skg->x0 + 5, + NULL); - - /* update footer */ - g_object_set (skg->footer, - "x", (gdouble) skg->x0, - "y", (gdouble) skg->h, - "width", (gdouble) skg->w, - "height", (gdouble) SKG_FOOTER, - NULL); + + /* update footer */ + g_object_set (skg->footer, + "x", (gdouble) skg->x0, + "y", (gdouble) skg->h, + "width", (gdouble) skg->w, + "height", (gdouble) SKG_FOOTER, + NULL); - g_object_set (skg->axisl, - "x", (gdouble) (skg->w / 2), - "y", (gdouble) (skg->h + SKG_FOOTER - 5), - NULL); + g_object_set (skg->axisl, + "x", (gdouble) (skg->w / 2), + "y", (gdouble) (skg->h + SKG_FOOTER - 5), + NULL); - /* get the first hour and first 30 min slot */ - th = ceil (skg->ts * 24.0) / 24.0; + /* get the first hour and first 30 min slot */ + th = ceil (skg->ts * 24.0) / 24.0; - /* workaround for bug 1839140 (first hour incorrexct) */ - th += 0.00069; - - if ((th - skg->ts) > 0.0208333) { - tm = th - 0.0208333; - } - else { - tm = th + 0.0208333; - } + /* workaround for bug 1839140 (first hour incorrexct) */ + th += 0.00069; + + if ((th - skg->ts) > 0.0208333) { + tm = th - 0.0208333; + } + else { + tm = th + 0.0208333; + } - /* the number of steps equals the number of hours */ - n = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_TIME); - for (i = 0; i < n; i++) { - xh = t2x (skg, th); + /* the number of steps equals the number of hours */ + n = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_TIME); + for (i = 0; i < n; i++) { + xh = t2x (skg, th); - pts = goo_canvas_points_new (2); - pts->coords[0] = xh; - pts->coords[1] = skg->h; - pts->coords[2] = xh; - pts->coords[3] = skg->h + 10; + pts = goo_canvas_points_new (2); + pts->coords[0] = xh; + pts->coords[1] = skg->h; + pts->coords[2] = xh; + pts->coords[3] = skg->h + 10; - obj = g_slist_nth_data (skg->majors, i); - g_object_set (obj, "points", pts, NULL); + obj = g_slist_nth_data (skg->majors, i); + g_object_set (obj, "points", pts, NULL); - goo_canvas_points_unref (pts); + goo_canvas_points_unref (pts); - obj = g_slist_nth_data (skg->labels, i); - g_object_set (obj, - "x", (gdouble) xh, - "y", (gdouble) (skg->h + 12), - NULL); + obj = g_slist_nth_data (skg->labels, i); + g_object_set (obj, + "x", (gdouble) xh, + "y", (gdouble) (skg->h + 12), + NULL); - /* 30 min tick */ - xm = t2x (skg, tm); + /* 30 min tick */ + xm = t2x (skg, tm); - pts = goo_canvas_points_new (2); - pts->coords[0] = xm; - pts->coords[1] = skg->h; - pts->coords[2] = xm; - pts->coords[3] = skg->h + 5; + pts = goo_canvas_points_new (2); + pts->coords[0] = xm; + pts->coords[1] = skg->h; + pts->coords[2] = xm; + pts->coords[3] = skg->h + 5; - obj = g_slist_nth_data (skg->minors, i); - g_object_set (obj, "points", pts, NULL); + obj = g_slist_nth_data (skg->minors, i); + g_object_set (obj, "points", pts, NULL); - goo_canvas_points_unref (pts); + goo_canvas_points_unref (pts); - th += 0.04167; - tm += 0.04167; - } + th += 0.04167; + tm += 0.04167; + } - /* update pass items */ - n = g_slist_length (skg->passes); - j = -1; - curcat = 0; - y = 10.0; - h = 10.0; - for (i = 0; i < n; i++) { + /* update pass items */ + n = g_slist_length (skg->passes); + j = -1; + curcat = 0; + y = 10.0; + h = 10.0; + for (i = 0; i < n; i++) { - /* get pass */ - skp = (sky_pass_t *) g_slist_nth_data (skg->passes, i); + /* get pass */ + skp = (sky_pass_t *) g_slist_nth_data (skg->passes, i); - x = t2x (skg, skp->pass->aos); - w = t2x (skg, skp->pass->los) - x; + x = t2x (skg, skp->pass->aos); + w = t2x (skg, skp->pass->los) - x; - /* new satellite? */ - if (skp->catnum != curcat) { - j++; - curcat = skp->catnum; - y = j * (skg->pps + SKG_MARGIN) + SKG_MARGIN; - h = skg->pps; + /* new satellite? */ + if (skp->catnum != curcat) { + j++; + curcat = skp->catnum; + y = j * (skg->pps + SKG_MARGIN) + SKG_MARGIN; + h = skg->pps; - /* update label */ - obj = g_slist_nth_data (skg->satlab, j); - if (x > (skg->x0 + 100)) - g_object_set (obj, "x", x-5, "y", y+h/2.0, - "anchor", GTK_ANCHOR_E, NULL); - else - g_object_set (obj, "x", x+w+5, "y", y+h/2.0, - "anchor", GTK_ANCHOR_W, NULL); - } + /* update label */ + obj = g_slist_nth_data (skg->satlab, j); + if (x > (skg->x0 + 100)) + g_object_set (obj, "x", x-5, "y", y+h/2.0, + "anchor", GTK_ANCHOR_E, NULL); + else + g_object_set (obj, "x", x+w+5, "y", y+h/2.0, + "anchor", GTK_ANCHOR_W, NULL); + } - g_object_set (skp->box, - "x", x, - "y", y, - "width", w, - "height", h, - NULL); - } + g_object_set (skp->box, + "x", x, + "y", y, + "width", w, + "height", h, + NULL); + } - } + } } @@ -574,11 +574,11 @@ static void on_canvas_realized (GtkWidget *canvas, gpointer data) { - GtkAllocation aloc; + GtkAllocation aloc; - aloc.width = canvas->allocation.width; - aloc.height = canvas->allocation.height; - size_allocate_cb (canvas, &aloc, data); + aloc.width = canvas->allocation.width; + aloc.height = canvas->allocation.height; + size_allocate_cb (canvas, &aloc, data); } @@ -586,59 +586,59 @@ /** \brief Manage mouse motion events. */ static gboolean on_motion_notify (GooCanvasItem *item, - GooCanvasItem *target, - GdkEventMotion *event, - gpointer data) + GooCanvasItem *target, + GdkEventMotion *event, + gpointer data) { - GtkSkyGlance *skg = GTK_SKY_GLANCE (data); - GooCanvasPoints *pts; - gdouble t; - time_t tt; - gchar buff[6]; + GtkSkyGlance *skg = GTK_SKY_GLANCE (data); + GooCanvasPoints *pts; + gdouble t; + time_t tt; + gchar buff[6]; - /* update cursor tracking line and time label */ - pts = goo_canvas_points_new (2); - pts->coords[0] = event->x; - pts->coords[1] = skg->y0; - pts->coords[2] = event->x; - pts->coords[3] = skg->h; - g_object_set (skg->cursor, "points", pts, NULL); - goo_canvas_points_unref (pts); + /* update cursor tracking line and time label */ + pts = goo_canvas_points_new (2); + pts->coords[0] = event->x; + pts->coords[1] = skg->y0; + pts->coords[2] = event->x; + pts->coords[3] = skg->h; + g_object_set (skg->cursor, "points", pts, NULL); + goo_canvas_points_unref (pts); - /* get time corresponding to x */ - t = x2t (skg, event->x); + /* get time corresponding to x */ + t = x2t (skg, event->x); - /* convert julian date to struct tm */ - tt = (t - 2440587.5)*86400.; + /* convert julian date to struct tm */ + tt = (t - 2440587.5)*86400.; - /* format either local time or UTC depending on check box */ - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) - strftime (buff, 6, "%H:%M", localtime (&tt)); - else - strftime (buff, 6, "%H:%M", gmtime (&tt)); + /* format either local time or UTC depending on check box */ + if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_LOCAL_TIME)) + strftime (buff, 6, "%H:%M", localtime (&tt)); + else + strftime (buff, 6, "%H:%M", gmtime (&tt)); - buff[5] = '\0'; - - /* in order to avoid label clipping close to the edges of - the chart, the label is placed left/right of the cursor - tracking line depending on which half we are in. - */ - if (event->x > (skg->w / 2)) { - g_object_set (skg->timel, - "text", buff, - "x", (gdouble) event->x - 5, - "anchor", GTK_ANCHOR_NE, - NULL); - } - else { - g_object_set (skg->timel, - "text", buff, - "x", (gdouble) event->x + 5, - "anchor", GTK_ANCHOR_NW, - NULL); - } + buff[5] = '\0'; - return TRUE; + /* in order to avoid label clipping close to the edges of + the chart, the label is placed left/right of the cursor + tracking line depending on which half we are in. + */ + if (event->x > (skg->w / 2)) { + g_object_set (skg->timel, + "text", buff, + "x", (gdouble) event->x - 5, + "anchor", GTK_ANCHOR_NE, + NULL); + } + else { + g_object_set (skg->timel, + "text", buff, + "x", (gdouble) event->x + 5, + "anchor", GTK_ANCHOR_NW, + NULL); + } + + return TRUE; } @@ -653,22 +653,22 @@ */ static void on_item_created (GooCanvas *canvas, - GooCanvasItem *item, - GooCanvasItemModel *model, - gpointer data) + GooCanvasItem *item, + GooCanvasItemModel *model, + gpointer data) { - if (!goo_canvas_item_model_get_parent (model)) { - /* root item / canvas */ - g_signal_connect (item, "motion_notify_event", - (GtkSignalFunc) on_motion_notify, data); - } + if (!goo_canvas_item_model_get_parent (model)) { + /* root item / canvas */ + g_signal_connect (item, "motion_notify_event", + (GtkSignalFunc) on_motion_notify, data); + } - else if (!g_object_get_data (G_OBJECT (item), "skip-signal-connection")) { - g_signal_connect (item, "button_press_event", - (GtkSignalFunc) on_button_press, data); - g_signal_connect (item, "button_release_event", - (GtkSignalFunc) on_button_release, data); - } + else if (!g_object_get_data (G_OBJECT (item), "skip-signal-connection")) { + g_signal_connect (item, "button_press_event", + (GtkSignalFunc) on_button_press, data); + g_signal_connect (item, "button_release_event", + (GtkSignalFunc) on_button_release, data); + } } @@ -680,24 +680,24 @@ */ static gboolean on_button_press (GooCanvasItem *item, - GooCanvasItem *target, - GdkEventButton *event, - gpointer data) + GooCanvasItem *target, + GdkEventButton *event, + gpointer data) { /* GooCanvasItemModel *model = goo_canvas_item_get_model (item); */ /* GtkSkyGlance *skg = GTK_SKY_GLANCE (data); */ - switch (event->button) { + switch (event->button) { - /* pop-up menu */ - case 3: + /* pop-up menu */ + case 3: - break; + break; - default: - break; - } + default: + break; + } @@ -714,26 +714,26 @@ */ static gboolean on_button_release (GooCanvasItem *item, - GooCanvasItem *target, - GdkEventButton *event, - gpointer data) + GooCanvasItem *target, + GdkEventButton *event, + gpointer data) { /* GooCanvasItemModel *model = goo_canvas_item_get_model (item); */ /* GtkSkyGlance *skg = GTK_SKY_GLANCE (data); */ - switch (event->button) { + switch (event->button) { - /* Select / de-select satellite */ - case 1: + /* Select / de-select satellite */ + case 1: - break; + break; - default: - break; - } + default: + break; + } - - return TRUE; + + return TRUE; } @@ -747,11 +747,11 @@ */ static gdouble t2x (GtkSkyGlance *skg, gdouble t) { - gdouble frac; + gdouble frac; - frac = (t - skg->ts) / (skg->te - skg->ts); + frac = (t - skg->ts) / (skg->te - skg->ts); - return (skg->x0 + frac * skg->w); + return (skg->x0 + frac * skg->w); } @@ -766,77 +766,77 @@ */ static gdouble x2t (GtkSkyGlance *skg, gdouble x) { - gdouble frac; + gdouble frac; - frac = (x - skg->x0) / skg->w; + frac = (x - skg->x0) / skg->w; - return (skg->ts + frac * (skg->te - skg->ts)); + return (skg->ts + frac * (skg->te - skg->ts)); } /* fetch the basic colour and add alpha channel */ static void get_colours (guint i, guint *bcol, guint *fcol) { - guint tmp; + guint tmp; - /* ensure that we are within 1..10 */ - i = i % 10; + /* ensure that we are within 1..10 */ + i = i % 10; - switch (i) { + switch (i) { - case 0: - tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_01); - break; + case 0: + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_01); + break; - case 1: - tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_02); - break; + case 1: + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_02); + break; - case 2: - tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_03); - break; + case 2: + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_03); + break; - case 3: - tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_04); - break; + case 3: + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_04); + break; - case 4: - tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_05); - break; + case 4: + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_05); + break; - case 5: - tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_06); - break; + case 5: + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_06); + break; - case 6: - tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_07); - break; + case 6: + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_07); + break; - case 7: - tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_08); - break; + case 7: + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_08); + break; - case 8: - tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_09); - break; + case 8: + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_09); + break; - case 9: - tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_10); - break; + case 9: + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_10); + break; - default: - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s:%d: Colour index out of valid range (%d)"), - __FILE__, __LINE__, i); - tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_01); - break; - } + default: + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s:%d: Colour index out of valid range (%d)"), + __FILE__, __LINE__, i); + tmp = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_01); + break; + } - /* border colour is solid with no tranparency */ - *bcol = (tmp * 0x100) | 0xFF; + /* border colour is solid with no tranparency */ + *bcol = (tmp * 0x100) | 0xFF; - /* fill colour is slightly transparent */ - *fcol = (tmp * 0x100) | 0xF0; + /* fill colour is slightly transparent */ + *fcol = (tmp * 0x100) | 0xF0; } @@ -852,79 +852,79 @@ static void create_sat (gpointer key, gpointer value, gpointer data) { - sat_t *sat = SAT(value); - GtkSkyGlance *skg = GTK_SKY_GLANCE(data); - GSList *passes = NULL; - gdouble maxdt; - guint i,n; - pass_t *tmppass = NULL; - sky_pass_t *skypass; - guint bcol,fcol; /* colours */ - GooCanvasItemModel *root; - GooCanvasItemModel *lab; + sat_t *sat = SAT(value); + GtkSkyGlance *skg = GTK_SKY_GLANCE(data); + GSList *passes = NULL; + gdouble maxdt; + guint i,n; + pass_t *tmppass = NULL; + sky_pass_t *skypass; + guint bcol,fcol; /* colours */ + GooCanvasItemModel *root; + GooCanvasItemModel *lab; - /* FIXME: - Include current pass if sat is up now - */ + /* FIXME: + Include current pass if sat is up now + */ - /* check that we didn't exceed 10 sats */ -/* if (++skg->satcnt > 10) { */ -/* return; */ -/* } */ + /* check that we didn't exceed 10 sats */ + /* if (++skg->satcnt > 10) { */ + /* return; */ + /* } */ - /* get canvas root */ - root = goo_canvas_get_root_item_model (GOO_CANVAS (skg->canvas)); + /* get canvas root */ + root = goo_canvas_get_root_item_model (GOO_CANVAS (skg->canvas)); - get_colours (skg->satcnt++, &bcol, &fcol); + get_colours (skg->satcnt++, &bcol, &fcol); - maxdt = skg->te - skg->ts; + maxdt = skg->te - skg->ts; - /* get passes for satellite */ - passes = get_passes (sat, skg->qth, skg->ts, maxdt, 10); - n = g_slist_length (passes); - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s:%d: %s has %d passes within %.4f days\n"), - __FILE__, __LINE__, sat->tle.sat_name, n, maxdt); + /* get passes for satellite */ + passes = get_passes (sat, skg->qth, skg->ts, maxdt, 10); + n = g_slist_length (passes); + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s:%d: %s has %d passes within %.4f days\n"), + __FILE__, __LINE__, sat->tle.sat_name, n, maxdt); - /* add sky_pass_t items to skg->passes */ - if (passes != NULL) { + /* add sky_pass_t items to skg->passes */ + if (passes != NULL) { - /* add pass items */ - for (i = 0; i < n; i++) { - - skypass = g_try_new (sky_pass_t, 1); + /* add pass items */ + for (i = 0; i < n; i++) { + + skypass = g_try_new (sky_pass_t, 1); - if (skypass != NULL) { + if (skypass != NULL) { - /* create pass structure items */ - skypass->catnum = sat->tle.catnr; - tmppass = (pass_t *) g_slist_nth_data (passes, i); - skypass->pass = copy_pass (tmppass); - skypass->box = goo_canvas_rect_model_new (root, 10, 10, 20, 20, /* dummy coordinates */ - "stroke-color-rgba", bcol, - "fill-color-rgba", fcol, - NULL); - - /* store pass data */ - skg->passes = g_slist_append (skg->passes, skypass); - } - else { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%d: Could not allocate memory for pass object"), - __FILE__, __LINE__); - } + /* create pass structure items */ + skypass->catnum = sat->tle.catnr; + tmppass = (pass_t *) g_slist_nth_data (passes, i); + skypass->pass = copy_pass (tmppass); + skypass->box = goo_canvas_rect_model_new (root, 10, 10, 20, 20, /* dummy coordinates */ + "stroke-color-rgba", bcol, + "fill-color-rgba", fcol, + NULL); + + /* store pass data */ + skg->passes = g_slist_append (skg->passes, skypass); + } + else { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%d: Could not allocate memory for pass object"), + __FILE__, __LINE__); + } - } + } - free_passes (passes); + free_passes (passes); - /* add satellite label */ - lab = goo_canvas_text_model_new (root, sat->tle.sat_name, - 5, 0, -1, GTK_ANCHOR_W, - "font", "Sans 8", - "fill-color-rgba", bcol, - NULL); - skg->satlab = g_slist_append (skg->satlab, lab); - } + /* add satellite label */ + lab = goo_canvas_text_model_new (root, sat->tle.sat_name, + 5, 0, -1, GTK_ANCHOR_W, + "font", "Sans 8", + "fill-color-rgba", bcol, + NULL); + skg->satlab = g_slist_append (skg->satlab, lab); + } } Modified: trunk/src/gtk-sky-glance.h =================================================================== --- trunk/src/gtk-sky-glance.h 2009-04-13 10:38:53 UTC (rev 265) +++ trunk/src/gtk-sky-glance.h 2009-04-13 10:53:28 UTC (rev 266) @@ -56,9 +56,9 @@ /** \brief Satellite object on graph. */ typedef struct { - guint catnum; /*!< Catalogue number of satellite */ - pass_t *pass; /*!< Details of the corresponding pass. */ - GooCanvasItemModel *box; /*!< Canvas item showing the pass */ + guint catnum; /*!< Catalogue number of satellite */ + pass_t *pass; /*!< Details of the corresponding pass. */ + GooCanvasItemModel *box; /*!< Canvas item showing the pass */ } sky_pass_t; @@ -68,48 +68,48 @@ struct _GtkSkyGlance { - GtkVBox vbox; + GtkVBox vbox; - GtkWidget *canvas; /*!< The canvas widget */ + GtkWidget *canvas; /*!< The canvas widget */ - GHashTable *sats; /*!< Copy of satellites. */ - qth_t *qth; /*!< Pointer to current location. */ + GHashTable *sats; /*!< Copy of satellites. */ + qth_t *qth; /*!< Pointer to current location. */ - GSList *passes; /*!< Canvas items representing each pass. - Each element in the list is of type sky_pass_t. - */ - GSList *satlab; /*!< Canvas items showing satellite names. */ + GSList *passes; /*!< Canvas items representing each pass. + Each element in the list is of type sky_pass_t. + */ + GSList *satlab; /*!< Canvas items showing satellite names. */ - guint x0; /*!< X0 */ - guint y0; /*!< Y0 */ - guint w; /*!< width of the plot */ - guint h; /*!< height of the plot */ - guint pps; /*!< pixels per satellite */ + guint x0; /*!< X0 */ + guint y0; /*!< Y0 */ + guint w; /*!< width of the plot */ + guint h; /*!< height of the plot */ + guint pps; /*!< pixels per satellite */ - guint numsat; /*!< Number of satellites */ - guint satcnt; /*!< Counter to keep track of how many satellites we have - plotted so far when creating the boxes. - This is needed to ensure that we do not plot more - than 10 satellites and to know which colour to fetch - from sat-cfg. - */ - gdouble ts,te; /*!< Start and end times (Julian date) */ + guint numsat; /*!< Number of satellites */ + guint satcnt; /*!< Counter to keep track of how many satellites we have + plotted so far when creating the boxes. + This is needed to ensure that we do not plot more + than 10 satellites and to know which colour to fetch + from sat-cfg. + */ + gdouble ts,te; /*!< Start and end times (Julian date) */ - GSList *majors; /*!< Major ticks for every hour */ - GSList *minors; /*!< Minor ticks for every 30 min */ - GSList *labels; /*!< Tick labels for every hour */ - - GooCanvasItemModel *footer; /*!< Footer area with time ticks and labels */ - GooCanvasItemModel *axisl; /*!< Axis label */ - GooCanvasItemModel *cursor; /*!< Vertical line tracking the cursor */ - GooCanvasItemModel *timel; /*!< Label showing time under cursor */ + GSList *majors; /*!< Major ticks for every hour */ + GSList *minors; /*!< Minor ticks for every 30 min */ + GSList *labels; /*!< Tick labels for every hour */ + GooCanvasItemModel *footer; /*!< Footer area with time ticks and labels */ + GooCanvasItemModel *axisl; /*!< Axis label */ + GooCanvasItemModel *cursor; /*!< Vertical line tracking the cursor */ + GooCanvasItemModel *timel; /*!< Label showing time under cursor */ + }; struct _GtkSkyGlanceClass { - GtkVBoxClass parent_class; + GtkVBoxClass parent_class; }; Modified: trunk/src/predict-tools.c =================================================================== --- trunk/src/predict-tools.c 2009-04-13 10:38:53 UTC (rev 265) +++ trunk/src/predict-tools.c 2009-04-13 10:53:28 UTC (rev 266) @@ -51,58 +51,58 @@ void predict_calc (sat_t *sat, qth_t *qth, gdouble t) { - obs_set_t obs_set; - geodetic_t sat_geodetic; - geodetic_t obs_geodetic; - double age; + obs_set_t obs_set; + geodetic_t sat_geodetic; + geodetic_t obs_geodetic; + double age; - obs_geodetic.lon = qth->lon * de2ra; - obs_geodetic.lat = qth->lat * de2ra; - obs_geodetic.alt = qth->alt / 1000.0; - obs_geodetic.theta = 0; + obs_geodetic.lon = qth->lon * de2ra; + obs_geodetic.lat = qth->lat * de2ra; + obs_geodetic.alt = qth->alt / 1000.0; + obs_geodetic.theta = 0; - sat->jul_utc = t; - sat->tsince = (sat->jul_utc - sat->jul_epoch) * xmnpda; + sat->jul_utc = t; + sat->tsince = (sat->jul_utc - sat->jul_epoch) * xmnpda; - /* call the norad routines according to the deep-space flag */ - if (sat->flags & DEEP_SPACE_EPHEM_FLAG) - SDP4 (sat, sat->tsince); - else - SGP4 (sat, sat->tsince); + /* call the norad routines according to the deep-space flag */ + if (sat->flags & DEEP_SPACE_EPHEM_FLAG) + SDP4 (sat, sat->tsince); + else + SGP4 (sat, sat->tsince); - Convert_Sat_State (&sat->pos, &sat->vel); + Convert_Sat_State (&sat->pos, &sat->vel); - /* get the velocity of the satellite */ - Magnitude (&sat->vel); - sat->velo = sat->vel.w; - Calculate_Obs (sat->jul_utc, &sat->pos, &sat->vel, &obs_geodetic, &obs_set); - Calculate_LatLonAlt (sat->jul_utc, &sat->pos, &sat_geodetic); + /* get the velocity of the satellite */ + Magnitude (&sat->vel); + sat->velo = sat->vel.w; + Calculate_Obs (sat->jul_utc, &sat->pos, &sat->vel, &obs_geodetic, &obs_set); + Calculate_LatLonAlt (sat->jul_utc, &sat->pos, &sat_geodetic); - while (sat_geodetic.lon < -pi) - sat_geodetic.lon += twopi; - - while (sat_geodetic.lon > (pi)) - sat_geodetic.lon -= twopi; + while (sat_geodetic.lon < -pi) + sat_geodetic.lon += twopi; - sat->az = Degrees (obs_set.az); - sat->el = Degrees (obs_set.el); - sat->range = obs_set.range; - sat->range_rate = obs_set.range_rate; - sat->ssplat = Degrees (sat_geodetic.lat); - sat->ssplon = Degrees (sat_geodetic.lon); - sat->alt = sat_geodetic.alt; - sat->ma = Degrees (sat->phase); - sat->ma *= 256.0/360.0; - sat->phase = Degrees (sat->phase); + while (sat_geodetic.lon > (pi)) + sat_geodetic.lon -= twopi; - /* same formulas, but the one from predict is nicer */ - //sat->footprint = 2.0 * xkmper * acos (xkmper/sat->pos.w); - sat->footprint = 12756.33 * acos (xkmper / (xkmper+sat->alt)); - age = sat->jul_utc - sat->jul_epoch; - sat->orbit = (long) floor((sat->tle.xno * xmnpda/twopi + - age * sat->tle.bstar * ae) * age + - sat->tle.xmo/twopi) + sat->tle.revnum - 1; + sat->az = Degrees (obs_set.az); + sat->el = Degrees (obs_set.el); + sat->range = obs_set.range; + sat->range_rate = obs_set.range_rate; + sat->ssplat = Degrees (sat_geodetic.lat); + sat->ssplon = Degrees (sat_geodetic.lon); + sat->alt = sat_geodetic.alt; + sat->ma = Degrees (sat->phase); + sat->ma *= 256.0/360.0; + sat->phase = Degrees (sat->phase); + + /* same formulas, but the one from predict is nicer */ + //sat->footprint = 2.0 * xkmper * acos (xkmper/sat->pos.w); + sat->footprint = 12756.33 * acos (xkmper / (xkmper+sat->alt)); + age = sat->jul_utc - sat->jul_epoch; + sat->orbit = (long) floor((sat->tle.xno * xmnpda/twopi + + age * sat->tle.bstar * ae) * age + + sat->tle.xmo/twopi) + sat->tle.revnum - 1; } @@ -125,84 +125,84 @@ gdouble find_aos (sat_t *sat, qth_t *qth, gdouble start, gdouble maxdt) { - gdouble t = start; - gdouble aostime = 0.0; + gdouble t = start; + gdouble aostime = 0.0; - /* make sure current sat values are - in sync with the time - */ - predict_calc (sat, qth, start); + /* make sure current sat values are + in sync with the time + */ + predict_calc (sat, qth, start); - /* check whether satellite has aos */ - if ((sat->otype == ORBIT_TYPE_GEO) || - (sat->otype == ORBIT_TYPE_DECAYED) || - !has_aos (sat, qth)) { + /* check whether satellite has aos */ + if ((sat->otype == ORBIT_TYPE_GEO) || + (sat->otype == ORBIT_TYPE_DECAYED) || + !has_aos (sat, qth)) { - return 0.0; + return 0.0; - } + } - if (sat->el > 0.0) - t = find_los (sat, qth, start, maxdt) + 0.014; // +20 min + if (sat->el > 0.0) + t = find_los (sat, qth, start, maxdt) + 0.014; // +20 min - /* invalid time (potentially returned by find_los) */ - if (t < 0.1) - return 0.0; + /* invalid time (potentially returned by find_los) */ + if (t < 0.1) + return 0.0; - /* update satellite data */ - predict_calc (sat, qth, t); + /* update satellite data */ + predict_calc (sat, qth, t); - /* use upper time limit */ - if (maxdt > 0.0) { + /* use upper time limit */ + if (maxdt > 0.0) { - /* coarse time steps */ - while ((sat->el < -1.0) && (t <= (start + maxdt))) { - t -= 0.00035 * (sat->el * ((sat->alt / 8400.0) + 0.46) - 2.0); - predict_calc (sat, qth, t); - } + /* coarse time steps */ + while ((sat->el < -1.0) && (t <= (start + maxdt))) { + t -= 0.00035 * (sat->el * ((sat->alt / 8400.0) + 0.46) - 2.0); + predict_calc (sat, qth, t); + } - /* fine steps */ - while ((aostime == 0.0) && (t <= (start + maxdt))) { + /* fine steps */ + while ((aostime == 0.0) && (t <= (start + maxdt))) { - if (fabs (sat->el) < 0.005) { - aostime = t; - } - else { - t -= sat->el * sqrt (sat->alt) / 530000.0; - predict_calc (sat, qth, t); - } + if (fabs (sat->el) < 0.005) { + aostime = t; + } + else { + t -= sat->el * sqrt (sat->alt) / 530000.0; + predict_calc (sat, qth, t); + } - } + } - } - /* don't use upper time limit */ - else { + } + /* don't use upper time limit */ + else { - /* coarse time steps */ - while (sat->el < -1.0) { + /* coarse time steps */ + while (sat->el < -1.0) { - t -= 0.00035 * (sat->el * ((sat->alt / 8400.0) + 0.46) - 2.0); - predict_calc (sat, qth, t); - } + t -= 0.00035 * (sat->el * ((sat->alt / 8400.0) + 0.46) - 2.0); + predict_calc (sat, qth, t); + } - /* fine steps */ - while (aostime == 0.0) { + /* fine steps */ + while (aostime == 0.0) { - if (fabs (sat->el) < 0.005) { - aostime = t; - } - else { - t -= sat->el * sqrt (sat->alt) / 530000.0; - predict_calc (sat, qth, t); - } + if (fabs (sat->el) < 0.005) { + aostime = t; + } + else { + t -= sat->el * sqrt (sat->alt) / 530000.0; + predict_calc (sat, qth, t); + } - } - } + } + } - return aostime; + return aostime; } @@ -227,75 +227,75 @@ gdouble find_los (sat_t *sat, qth_t *qth, gdouble start, gdouble maxdt) { - gdouble t = start; - gdouble lostime = 0.0; + gdouble t = start; + gdouble lostime = 0.0; - - predict_calc (sat, qth, start); - /* check whether satellite has aos */ - if ((sat->otype == ORBIT_TYPE_GEO) || - (sat->otype == ORBIT_TYPE_DECAYED) || - !has_aos (sat, qth)) { + predict_calc (sat, qth, start); - return 0.0; + /* check whether satellite has aos */ + if ((sat->otype == ORBIT_TYPE_GEO) || + (sat->otype == ORBIT_TYPE_DECAYED) || + !has_aos (sat, qth)) { - } + return 0.0; + } - if (sat->el < 0.0) - t = find_aos (sat, qth, start, maxdt) + 0.001; // +1.5 min - /* invalid time (potentially returned by find_aos) */ - if (t < 0.01) - return 0.0; + if (sat->el < 0.0) + t = find_aos (sat, qth, start, maxdt) + 0.001; // +1.5 min - /* update satellite data */ - predict_calc (sat, qth, t); + /* invalid time (potentially returned by find_aos) */ + if (t < 0.01) + return 0.0; + /* update satellite data */ + predict_calc (sat, qth, t); - /* use upper time limit */ - if (maxdt > 0.0) { - /* coarse steps */ - while ((sat->el >= 1.0) && (t <= (start + maxdt))) { - t += cos((sat->el - 1.0) * de2ra) * sqrt(sat->alt) / 25000.0; - predict_calc (sat, qth, t); - } + /* use upper time limit */ + if (maxdt > 0.0) { - /* fine steps */ - while ((lostime == 0.0) && (t <= (start + maxdt))) { - - t += sat->el * sqrt(sat->alt)/502500.0; - predict_calc (sat, qth, t); - - if (fabs(sat->el) < 0.005) - lostime = t; - } - } + /* coarse steps */ + while ((sat->el >= 1.0) && (t <= (start + maxdt))) { + t += cos((sat->el - 1.0) * de2ra) * sqrt(sat->alt) / 25000.0; + predict_calc (sat, qth, t); + } - /* don't use upper limit */ - else { + /* fine steps */ + while ((lostime == 0.0) && (t <= (start + maxdt))) { + + t += sat->el * sqrt(sat->alt)/502500.0; + predict_calc (sat, qth, t); + + if (fabs(sat->el) < 0.005) + lostime = t; + } + } - /* coarse steps */ - while (sat->el >= 1.0) { - t += cos((sat->el - 1.0) * de2ra) * sqrt(sat->alt) / 25000.0; - predict_calc (sat, qth, t); - } + /* don't use upper limit */ + else { - /* fine steps */ - while (lostime == 0.0) { - - t += sat->el * sqrt(sat->alt)/502500.0; - predict_calc (sat, qth, t); - - if (fabs(sat->el) < 0.005) - lostime = t; - } - } - + /* coarse steps */ + while (sat->el >= 1.0) { + t += cos((sat->el - 1.0) * de2ra) * sqrt(sat->alt) / 25000.0; + predict_calc (sat, qth, t); + } - return lostime; + /* fine steps */ + while (lostime == 0.0) { + + t += sat->el * sqrt(sat->alt)/502500.0; + predict_calc (sat, qth, t); + + if (fabs(sat->el) < 0.005) + lostime = t; + } + } + + + return lostime; } @@ -311,29 +311,29 @@ gdouble find_prev_aos (sat_t *sat, qth_t *qth, gdouble start) { - gdouble aostime = start; + gdouble aostime = start; - /* make sure current sat values are - in sync with the time - */ - predict_calc (sat, qth, start); + /* make sure current sat values are + in sync with the time + */ + predict_calc (sat, qth, start); - /* check whether satellite has aos */ - if ((sat->otype == ORBIT_TYPE_GEO) || - (sat->otype == ORBIT_TYPE_DECAYED) || - !has_aos (sat, qth)) { + /* check whether satellite has aos */ + if ((sat->otype == ORBIT_TYPE_GEO) || + (sat->otype == ORBIT_TYPE_DECAYED) || + !has_aos (sat, qth)) { - return 0.0; + return 0.0; - } + } - while (sat->el >= 0.0) { - aostime -= 0.0005; // 0.75 min - predict_calc (sat, qth, aostime); - } + while (sat->el >= 0.0) { + aostime -= 0.0005; // 0.75 min + predict_calc (sat, qth, aostime); + } - return aostime; + return aostime; } /** \brief Predict the next pass. @@ -355,14 +355,14 @@ pass_t * get_next_pass (sat_t *sat, qth_t *qth, gdouble maxdt) { - gdouble now; + gdouble now; - /* get the current time and call - the get_pass function */ - now = get_current_daynum (); + /* get the current time and call + the get_pass function */ + now = get_current_daynum (); - return get_pass (sat, qth, now, maxdt); + return get_pass (sat, qth, now, maxdt); } @@ -385,14 +385,14 @@ GSList * get_next_passes (sat_t *sat, qth_t *qth, gdouble maxdt, guint num) { - gdouble now; + gdouble now; - /* get the current time and call - the get_pass function */ - now = get_current_daynum (); + /* get the current time and call + the get_pass function */ + now = get_current_daynum (); - return get_passes (sat, qth, now, maxdt, num); + return get_passes (sat, qth, now, maxdt, num); } @@ -420,165 +420,165 @@ pass_t * get_pass (sat_t *sat, qth_t *qth, gdouble start, gdouble maxdt) { - gdouble aos = 0.0; /* time of AOS */ - gdouble tca = 0.0; /* time of TCA */ - gdouble los = 0.0; /* time of LOS */ - gdouble dt = 0.0; /* time diff */ - gdouble step = 0.0; /* time step */ - gdouble t0 = start; - gdouble t; /* current time counter */ - gdouble tres = 0.0; /* required time resolution */ - gdouble max_el = 0.0; /* maximum elevation */ - pass_t *pass = NULL; - pass_detail_t *detail = NULL; - gboolean done = FALSE; - guint iter = 0; /* number of iterations */ + gdouble aos = 0.0; /* time of AOS */ + gdouble tca = 0.0; /* time of TCA */ + gdouble los = 0.0; /* time of LOS */ + gdouble dt = 0.0; /* time diff */ + gdouble step = 0.0; /* time step */ + gdou... [truncated message content] |
From: <cs...@us...> - 2009-05-01 20:06:19
|
Revision: 282 http://gpredict.svn.sourceforge.net/gpredict/?rev=282&view=rev Author: csete Date: 2009-05-01 20:06:18 +0000 (Fri, 01 May 2009) Log Message: ----------- Updated. Modified Paths: -------------- trunk/src/gtk-sat-module.c trunk/src/mod-mgr.c Modified: trunk/src/gtk-sat-module.c =================================================================== --- trunk/src/gtk-sat-module.c 2009-05-01 17:55:29 UTC (rev 281) +++ trunk/src/gtk-sat-module.c 2009-05-01 20:06:18 UTC (rev 282) @@ -1237,7 +1237,10 @@ if (retcode != MOD_CFG_OK) { - /**** FIXME: error message + dialog */ + /**** FIXME: dialog */ + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Module configuration failed for some reason."), + __FUNCTION__); /* don't try to reload config since it may be invalid; keep original Modified: trunk/src/mod-mgr.c =================================================================== --- trunk/src/mod-mgr.c 2009-05-01 17:55:29 UTC (rev 281) +++ trunk/src/mod-mgr.c 2009-05-01 20:06:18 UTC (rev 282) @@ -207,9 +207,7 @@ module, gtk_label_new (GTK_SAT_MODULE (module)->name)); - sat_log_log (SAT_LOG_LEVEL_MSG, - _("%s: Entered 3."), - __FUNCTION__); + sat_log_log (SAT_LOG_LEVEL_MSG, _("%s: Entered 3."), __FUNCTION__); gtk_notebook_set_current_page (GTK_NOTEBOOK (nbook), page); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-05-01 23:04:17
|
Revision: 283 http://gpredict.svn.sourceforge.net/gpredict/?rev=283&view=rev Author: csete Date: 2009-05-01 23:04:14 +0000 (Fri, 01 May 2009) Log Message: ----------- Changed resizing scheme to be the same as for GtkSatMap. This fixed the long delay (many seconds) problem when a module containing a polar view is opened or reconfigured. Modified Paths: -------------- trunk/src/gtk-polar-view.c trunk/src/gtk-polar-view.h Modified: trunk/src/gtk-polar-view.c =================================================================== --- trunk/src/gtk-polar-view.c 2009-05-01 20:06:18 UTC (rev 282) +++ trunk/src/gtk-polar-view.c 2009-05-01 23:04:14 UTC (rev 283) @@ -60,29 +60,29 @@ static void gtk_polar_view_init (GtkPolarView *polview); static void gtk_polar_view_destroy (GtkObject *object); static void size_allocate_cb (GtkWidget *widget, - GtkAllocation *allocation, - gpointer data); + GtkAllocation *allocation, + gpointer data); static void update_sat (gpointer key, gpointer value, gpointer data); static void update_track (gpointer key, gpointer value, gpointer data); static void correct_pole_coor (GtkPolarView *polv, polar_view_pole_t pole, - gfloat *x, gfloat *y, GtkAnchorType *anch); + gfloat *x, gfloat *y, GtkAnchorType *anch); static gboolean on_motion_notify (GooCanvasItem *item, - GooCanvasItem *target, - GdkEventMotion *event, - gpointer data); + GooCanvasItem *target, + GdkEventMotion *event, + gpointer data); static void on_item_created (GooCanvas *canvas, - GooCanvasItem *item, - GooCanvasItemModel *model, - gpointer data); + GooCanvasItem *item, + GooCanvasItemModel *model, + gpointer data); static void on_canvas_realized (GtkWidget *canvas, gpointer data); static gboolean on_button_press (GooCanvasItem *item, - GooCanvasItem *target, - GdkEventButton *event, - gpointer data); + GooCanvasItem *target, + GdkEventButton *event, + gpointer data); static gboolean on_button_release (GooCanvasItem *item, - GooCanvasItem *target, - GdkEventButton *event, - gpointer data); + GooCanvasItem *target, + GdkEventButton *event, + gpointer data); static void clear_selection (gpointer key, gpointer val, gpointer data); static GooCanvasItemModel* create_canvas_model (GtkPolarView *polv); static void get_canvas_bg_color (GtkPolarView *polv, GdkColor *color); @@ -94,70 +94,71 @@ GtkType gtk_polar_view_get_type () { - static GType gtk_polar_view_type = 0; + static GType gtk_polar_view_type = 0; - if (!gtk_polar_view_type) { - static const GTypeInfo gtk_polar_view_info = { - sizeof (GtkPolarViewClass), - NULL, /* base init */ - NULL, /* base finalise */ - (GClassInitFunc) gtk_polar_view_class_init, - NULL, /* class finalise */ - NULL, /* class data */ - sizeof (GtkPolarView), - 5, /* n_preallocs */ - (GInstanceInitFunc) gtk_polar_view_init, - }; + if (!gtk_polar_view_type) { + static const GTypeInfo gtk_polar_view_info = { + sizeof (GtkPolarViewClass), + NULL, /* base init */ + NULL, /* base finalise */ + (GClassInitFunc) gtk_polar_view_class_init, + NULL, /* class finalise */ + NULL, /* class data */ + sizeof (GtkPolarView), + 5, /* n_preallocs */ + (GInstanceInitFunc) gtk_polar_view_init, + }; - gtk_polar_view_type = g_type_register_static (GTK_TYPE_VBOX, - "GtkPolarView", - >k_polar_view_info, - 0); - } + gtk_polar_view_type = g_type_register_static (GTK_TYPE_VBOX, + "GtkPolarView", + >k_polar_view_info, + 0); + } - return gtk_polar_view_type; + return gtk_polar_view_type; } static void gtk_polar_view_class_init (GtkPolarViewClass *class) { - GObjectClass *gobject_class; - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; + GObjectClass *gobject_class; + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + GtkContainerClass *container_class; - gobject_class = G_OBJECT_CLASS (class); - object_class = (GtkObjectClass*) class; - widget_class = (GtkWidgetClass*) class; - container_class = (GtkContainerClass*) class; + gobject_class = G_OBJECT_CLASS (class); + object_class = (GtkObjectClass*) class; + widget_class = (GtkWidgetClass*) class; + container_class = (GtkContainerClass*) class; - parent_class = g_type_class_peek_parent (class); + parent_class = g_type_class_peek_parent (class); - object_class->destroy = gtk_polar_view_destroy; - //widget_class->size_allocate = gtk_polar_view_size_allocate; + object_class->destroy = gtk_polar_view_destroy; + //widget_class->size_allocate = gtk_polar_view_size_allocate; } static void gtk_polar_view_init (GtkPolarView *polview) { - polview->sats = NULL; - polview->qth = NULL; - polview->obj = NULL; - polview->naos = 2458849.5; - polview->ncat = 0; - polview->size = 0; - polview->r = 0; - polview->cx = 0; - polview->cy = 0; - polview->refresh = 0; - polview->counter = 0; - polview->swap = 0; - polview->qthinfo = FALSE; - polview->eventinfo = FALSE; - polview->cursinfo = FALSE; - polview->extratick = FALSE; + polview->sats = NULL; + polview->qth = NULL; + polview->obj = NULL; + polview->naos = 2458849.5; + polview->ncat = 0; + polview->size = 0; + polview->r = 0; + polview->cx = 0; + polview->cy = 0; + polview->refresh = 0; + polview->counter = 0; + polview->swap = 0; + polview->qthinfo = FALSE; + polview->eventinfo = FALSE; + polview->cursinfo = FALSE; + polview->extratick = FALSE; + polview->resize = FALSE; } @@ -165,7 +166,7 @@ gtk_polar_view_destroy (GtkObject *object) { - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } @@ -177,246 +178,246 @@ GtkWidget * gtk_polar_view_new (GKeyFile *cfgdata, GHashTable *sats, qth_t *qth) { - GtkWidget *polv; - GooCanvasItemModel *root; - GdkColor bg_color = {0, 0xFFFF, 0xFFFF, 0xFFFF}; + GtkWidget *polv; + GooCanvasItemModel *root; + GdkColor bg_color = {0, 0xFFFF, 0xFFFF, 0xFFFF}; - polv = g_object_new (GTK_TYPE_POLAR_VIEW, NULL); + polv = g_object_new (GTK_TYPE_POLAR_VIEW, NULL); - GTK_POLAR_VIEW (polv)->cfgdata = cfgdata; - GTK_POLAR_VIEW (polv)->sats = sats; - GTK_POLAR_VIEW (polv)->qth = qth; + GTK_POLAR_VIEW (polv)->cfgdata = cfgdata; + GTK_POLAR_VIEW (polv)->sats = sats; + GTK_POLAR_VIEW (polv)->qth = qth; - GTK_POLAR_VIEW (polv)->obj = g_hash_table_new_full (g_int_hash, - g_int_equal, - g_free, - NULL); + GTK_POLAR_VIEW (polv)->obj = g_hash_table_new_full (g_int_hash, + g_int_equal, + g_free, + NULL); - /* get settings */ - GTK_POLAR_VIEW (polv)->refresh = mod_cfg_get_int (cfgdata, - MOD_CFG_POLAR_SECTION, - MOD_CFG_POLAR_REFRESH, - SAT_CFG_INT_POLAR_REFRESH); + /* get settings */ + GTK_POLAR_VIEW (polv)->refresh = mod_cfg_get_int (cfgdata, + MOD_CFG_POLAR_SECTION, + MOD_CFG_POLAR_REFRESH, + SAT_CFG_INT_POLAR_REFRESH); - GTK_POLAR_VIEW (polv)->counter = 1; + GTK_POLAR_VIEW (polv)->counter = 1; - GTK_POLAR_VIEW (polv)->swap = mod_cfg_get_int (cfgdata, - MOD_CFG_POLAR_SECTION, - MOD_CFG_POLAR_ORIENTATION, - SAT_CFG_INT_POLAR_ORIENTATION); + GTK_POLAR_VIEW (polv)->swap = mod_cfg_get_int (cfgdata, + MOD_CFG_POLAR_SECTION, + MOD_CFG_POLAR_ORIENTATION, + SAT_CFG_INT_POLAR_ORIENTATION); - GTK_POLAR_VIEW (polv)->qthinfo = mod_cfg_get_bool (cfgdata, - MOD_CFG_POLAR_SECTION, - MOD_CFG_POLAR_SHOW_QTH_INFO, - SAT_CFG_BOOL_POL_SHOW_QTH_INFO); + GTK_POLAR_VIEW (polv)->qthinfo = mod_cfg_get_bool (cfgdata, + MOD_CFG_POLAR_SECTION, + MOD_CFG_POLAR_SHOW_QTH_INFO, + SAT_CFG_BOOL_POL_SHOW_QTH_INFO); - GTK_POLAR_VIEW (polv)->eventinfo = mod_cfg_get_bool (cfgdata, - MOD_CFG_POLAR_SECTION, - MOD_CFG_POLAR_SHOW_NEXT_EVENT, - SAT_CFG_BOOL_POL_SHOW_NEXT_EV); + GTK_POLAR_VIEW (polv)->eventinfo = mod_cfg_get_bool (cfgdata, + MOD_CFG_POLAR_SECTION, + MOD_CFG_POLAR_SHOW_NEXT_EVENT, + SAT_CFG_BOOL_POL_SHOW_NEXT_EV); - GTK_POLAR_VIEW (polv)->cursinfo = mod_cfg_get_bool (cfgdata, - MOD_CFG_POLAR_SECTION, - MOD_CFG_POLAR_SHOW_CURS_TRACK, - SAT_CFG_BOOL_POL_SHOW_CURS_TRACK); + GTK_POLAR_VIEW (polv)->cursinfo = mod_cfg_get_bool (cfgdata, + MOD_CFG_POLAR_SECTION, + MOD_CFG_POLAR_SHOW_CURS_TRACK, + SAT_CFG_BOOL_POL_SHOW_CURS_TRACK); - GTK_POLAR_VIEW (polv)->extratick = mod_cfg_get_bool (cfgdata, - MOD_CFG_POLAR_SECTION, - MOD_CFG_POLAR_SHOW_EXTRA_AZ_TICKS, - SAT_CFG_BOOL_POL_SHOW_EXTRA_AZ_TICKS); + GTK_POLAR_VIEW (polv)->extratick = mod_cfg_get_bool (cfgdata, + MOD_CFG_POLAR_SECTION, + MOD_CFG_POLAR_SHOW_EXTRA_AZ_TICKS, + SAT_CFG_BOOL_POL_SHOW_EXTRA_AZ_TICKS); - /* create the canvas */ - GTK_POLAR_VIEW (polv)->canvas = goo_canvas_new (); - get_canvas_bg_color (GTK_POLAR_VIEW (polv), &bg_color); - gtk_widget_modify_base (GTK_POLAR_VIEW (polv)->canvas, GTK_STATE_NORMAL, &bg_color); - gtk_widget_set_size_request (GTK_POLAR_VIEW (polv)->canvas, - POLV_DEFAULT_SIZE, POLV_DEFAULT_SIZE); - goo_canvas_set_bounds (GOO_CANVAS (GTK_POLAR_VIEW (polv)->canvas), 0, 0, - POLV_DEFAULT_SIZE, POLV_DEFAULT_SIZE); + /* create the canvas */ + GTK_POLAR_VIEW (polv)->canvas = goo_canvas_new (); + get_canvas_bg_color (GTK_POLAR_VIEW (polv), &bg_color); + gtk_widget_modify_base (GTK_POLAR_VIEW (polv)->canvas, GTK_STATE_NORMAL, &bg_color); + gtk_widget_set_size_request (GTK_POLAR_VIEW (polv)->canvas, + POLV_DEFAULT_SIZE, POLV_DEFAULT_SIZE); + goo_canvas_set_bounds (GOO_CANVAS (GTK_POLAR_VIEW (polv)->canvas), 0, 0, + POLV_DEFAULT_SIZE, POLV_DEFAULT_SIZE); - /* connect size-request signal */ - g_signal_connect (GTK_POLAR_VIEW (polv)->canvas, "size-allocate", - G_CALLBACK (size_allocate_cb), polv); - g_signal_connect (GTK_POLAR_VIEW (polv)->canvas, "item_created", - (GtkSignalFunc) on_item_created, polv); - g_signal_connect_after (GTK_POLAR_VIEW (polv)->canvas, "realize", - (GtkSignalFunc) on_canvas_realized, polv); + /* connect size-request signal */ + g_signal_connect (GTK_POLAR_VIEW (polv)->canvas, "size-allocate", + G_CALLBACK (size_allocate_cb), polv); + g_signal_connect (GTK_POLAR_VIEW (polv)->canvas, "item_created", + (GtkSignalFunc) on_item_created, polv); + g_signal_connect_after (GTK_POLAR_VIEW (polv)->canvas, "realize", + (GtkSignalFunc) on_canvas_realized, polv); - gtk_widget_show (GTK_POLAR_VIEW (polv)->canvas); + gtk_widget_show (GTK_POLAR_VIEW (polv)->canvas); - /* Create the canvas model */ - root = create_canvas_model (GTK_POLAR_VIEW (polv)); - goo_canvas_set_root_item_model (GOO_CANVAS (GTK_POLAR_VIEW (polv)->canvas), root); + /* Create the canvas model */ + root = create_canvas_model (GTK_POLAR_VIEW (polv)); + goo_canvas_set_root_item_model (GOO_CANVAS (GTK_POLAR_VIEW (polv)->canvas), root); - g_object_unref (root); + g_object_unref (root); - //gtk_box_pack_start (GTK_BOX (polv), GTK_POLAR_VIEW (polv)->swin, TRUE, TRUE, 0); - gtk_container_add (GTK_CONTAINER (polv), GTK_POLAR_VIEW (polv)->canvas); + //gtk_box_pack_start (GTK_BOX (polv), GTK_POLAR_VIEW (polv)->swin, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (polv), GTK_POLAR_VIEW (polv)->canvas); - return polv; + return polv; } static GooCanvasItemModel * create_canvas_model (GtkPolarView *polv) { - GooCanvasItemModel *root; - gfloat x,y; - guint32 col; - GtkAnchorType anch = GTK_ANCHOR_CENTER; + GooCanvasItemModel *root; + gfloat x,y; + guint32 col; + GtkAnchorType anch = GTK_ANCHOR_CENTER; - root = goo_canvas_group_model_new (NULL, NULL); + root = goo_canvas_group_model_new (NULL, NULL); - /* graph dimensions */ - polv->size = POLV_DEFAULT_SIZE; - polv->r = (polv->size / 2) - POLV_DEFAULT_MARGIN; - polv->cx = POLV_DEFAULT_SIZE / 2; - polv->cy = POLV_DEFAULT_SIZE / 2; + /* graph dimensions */ + polv->size = POLV_DEFAULT_SIZE; + polv->r = (polv->size / 2) - POLV_DEFAULT_MARGIN; + polv->cx = POLV_DEFAULT_SIZE / 2; + polv->cy = POLV_DEFAULT_SIZE / 2; - col = mod_cfg_get_int (polv->cfgdata, - MOD_CFG_POLAR_SECTION, - MOD_CFG_POLAR_AXIS_COL, - SAT_CFG_INT_POLAR_AXIS_COL); + col = mod_cfg_get_int (polv->cfgdata, + MOD_CFG_POLAR_SECTION, + MOD_CFG_POLAR_AXIS_COL, + SAT_CFG_INT_POLAR_AXIS_COL); - /* Add elevation circles at 0, 30 and 60 deg */ - polv->C00 = goo_canvas_ellipse_model_new (root, - polv->cx, polv->cy, - polv->r, polv->r, - "line-width", 1.0, - "stroke-color-rgba", col, - NULL); + /* Add elevation circles at 0, 30 and 60 deg */ + polv->C00 = goo_canvas_ellipse_model_new (root, + polv->cx, polv->cy, + polv->r, polv->r, + "line-width", 1.0, + "stroke-color-rgba", col, + NULL); - polv->C30 = goo_canvas_ellipse_model_new (root, - polv->cx, polv->cy, - 0.6667 * polv->r, 0.6667 * polv->r, - "line-width", 1.0, - "stroke-color-rgba", col, - NULL); + polv->C30 = goo_canvas_ellipse_model_new (root, + polv->cx, polv->cy, + 0.6667 * polv->r, 0.6667 * polv->r, + "line-width", 1.0, + "stroke-color-rgba", col, + NULL); - polv->C60 = goo_canvas_ellipse_model_new (root, - polv->cx, polv->cy, - 0.333 * polv->r, 0.3333 * polv->r, - "line-width", 1.0, - "stroke-color-rgba", col, - NULL); + polv->C60 = goo_canvas_ellipse_model_new (root, + polv->cx, polv->cy, + 0.333 * polv->r, 0.3333 * polv->r, + "line-width", 1.0, + "stroke-color-rgba", col, + NULL); - /* add horixontal and vertical guidance lines */ - polv->hl = goo_canvas_polyline_model_new_line (root, - polv->cx - polv->r - POLV_LINE_EXTRA, - polv->cy, - polv->cx + polv->r + POLV_LINE_EXTRA, - polv->cy, - "stroke-color-rgba", col, - "line-width", 1.0, - NULL); + /* add horixontal and vertical guidance lines */ + polv->hl = goo_canvas_polyline_model_new_line (root, + polv->cx - polv->r - POLV_LINE_EXTRA, + polv->cy, + polv->cx + polv->r + POLV_LINE_EXTRA, + polv->cy, + "stroke-color-rgba", col, + "line-width", 1.0, + NULL); - polv->vl = goo_canvas_polyline_model_new_line (root, - polv->cx, - polv->cy - polv->r - POLV_LINE_EXTRA, - polv->cx, - polv->cy + polv->r + POLV_LINE_EXTRA, - "stroke-color-rgba", col, - "line-width", 1.0, - NULL); + polv->vl = goo_canvas_polyline_model_new_line (root, + polv->cx, + polv->cy - polv->r - POLV_LINE_EXTRA, + polv->cx, + polv->cy + polv->r + POLV_LINE_EXTRA, + "stroke-color-rgba", col, + "line-width", 1.0, + NULL); - /* N, S, E and W labels. */ - col = mod_cfg_get_int (polv->cfgdata, - MOD_CFG_POLAR_SECTION, - MOD_CFG_POLAR_TICK_COL, - SAT_CFG_INT_POLAR_TICK_COL); - azel_to_xy (polv, 0.0, 0.0, &x, &y); - correct_pole_coor (polv, POLAR_VIEW_POLE_N, &x, &y, &anch); - polv->N = goo_canvas_text_model_new (root, _("N"), - x, - y, - -1, - anch, - "font", "Sans 10", - "fill-color-rgba", col, - NULL); + /* N, S, E and W labels. */ + col = mod_cfg_get_int (polv->cfgdata, + MOD_CFG_POLAR_SECTION, + MOD_CFG_POLAR_TICK_COL, + SAT_CFG_INT_POLAR_TICK_COL); + azel_to_xy (polv, 0.0, 0.0, &x, &y); + correct_pole_coor (polv, POLAR_VIEW_POLE_N, &x, &y, &anch); + polv->N = goo_canvas_text_model_new (root, _("N"), + x, + y, + -1, + anch, + "font", "Sans 10", + "fill-color-rgba", col, + NULL); - azel_to_xy (polv, 180.0, 0.0, &x, &y); - correct_pole_coor (polv, POLAR_VIEW_POLE_S, &x, &y, &anch); - polv->S = goo_canvas_text_model_new (root, _("S"), - x, - y, - -1, - anch, - "font", "Sans 10", - "fill-color-rgba", col, - NULL); + azel_to_xy (polv, 180.0, 0.0, &x, &y); + correct_pole_coor (polv, POLAR_VIEW_POLE_S, &x, &y, &anch); + polv->S = goo_canvas_text_model_new (root, _("S"), + x, + y, + -1, + anch, + "font", "Sans 10", + "fill-color-rgba", col, + NULL); - azel_to_xy (polv, 90.0, 0.0, &x, &y); - correct_pole_coor (polv, POLAR_VIEW_POLE_E, &x, &y, &anch); - polv->E = goo_canvas_text_model_new (root, _("E"), - x, - y, - -1, - anch, - "font", "Sans 10", - "fill-color-rgba", col, - NULL); + azel_to_xy (polv, 90.0, 0.0, &x, &y); + correct_pole_coor (polv, POLAR_VIEW_POLE_E, &x, &y, &anch); + polv->E = goo_canvas_text_model_new (root, _("E"), + x, + y, + -1, + anch, + "font", "Sans 10", + "fill-color-rgba", col, + NULL); - azel_to_xy (polv, 270.0, 0.0, &x, &y); - correct_pole_coor (polv, POLAR_VIEW_POLE_W, &x, &y, &anch); - polv->W = goo_canvas_text_model_new (root, _("W"), - x, - y, - -1, - anch, - "font", "Sans 10", - "fill-color-rgba", col, - NULL); + azel_to_xy (polv, 270.0, 0.0, &x, &y); + correct_pole_coor (polv, POLAR_VIEW_POLE_W, &x, &y, &anch); + polv->W = goo_canvas_text_model_new (root, _("W"), + x, + y, + -1, + anch, + "font", "Sans 10", + "fill-color-rgba", col, + NULL); - /* cursor text */ - col = mod_cfg_get_int (polv->cfgdata, - MOD_CFG_POLAR_SECTION, - MOD_CFG_POLAR_INFO_COL, - SAT_CFG_INT_POLAR_INFO_COL); - polv->curs = goo_canvas_text_model_new (root, "", - polv->cx - polv->r - 2*POLV_LINE_EXTRA, - polv->cy + polv->r + POLV_LINE_EXTRA, - -1, - GTK_ANCHOR_W, - "font", "Sans 8", - "fill-color-rgba", col, - NULL); + /* cursor text */ + col = mod_cfg_get_int (polv->cfgdata, + MOD_CFG_POLAR_SECTION, + MOD_CFG_POLAR_INFO_COL, + SAT_CFG_INT_POLAR_INFO_COL); + polv->curs = goo_canvas_text_model_new (root, "", + polv->cx - polv->r - 2*POLV_LINE_EXTRA, + polv->cy + polv->r + POLV_LINE_EXTRA, + -1, + GTK_ANCHOR_W, + "font", "Sans 8", + "fill-color-rgba", col, + NULL); - /* location info */ - polv->locnam = goo_canvas_text_model_new (root, polv->qth->name, - polv->cx - polv->r - 2*POLV_LINE_EXTRA, - polv->cy - polv->r - POLV_LINE_EXTRA, - -1, - GTK_ANCHOR_SW, - "font", "Sans 8", - "fill-color-rgba", col, - NULL); + /* location info */ + polv->locnam = goo_canvas_text_model_new (root, polv->qth->name, + polv->cx - polv->r - 2*POLV_LINE_EXTRA, + polv->cy - polv->r - POLV_LINE_EXTRA, + -1, + GTK_ANCHOR_SW, + "font", "Sans 8", + "fill-color-rgba", col, + NULL); - /* next event */ - polv->next = goo_canvas_text_model_new (root, "", - polv->cx + polv->r + 2*POLV_LINE_EXTRA, - polv->cy - polv->r - POLV_LINE_EXTRA, - -1, - GTK_ANCHOR_E, - "font", "Sans 8", - "fill-color-rgba", col, - "alignment", PANGO_ALIGN_RIGHT, - NULL); + /* next event */ + polv->next = goo_canvas_text_model_new (root, "", + polv->cx + polv->r + 2*POLV_LINE_EXTRA, + polv->cy - polv->r - POLV_LINE_EXTRA, + -1, + GTK_ANCHOR_E, + "font", "Sans 8", + "fill-color-rgba", col, + "alignment", PANGO_ALIGN_RIGHT, + NULL); - /* selected satellite text */ - polv->sel = goo_canvas_text_model_new (root, "", - polv->cx + polv->r + 2*POLV_LINE_EXTRA, - polv->cy + polv->r + POLV_LINE_EXTRA, - -1, - GTK_ANCHOR_E, - "font", "Sans 8", - "fill-color-rgba", col, - "alignment", PANGO_ALIGN_RIGHT, - NULL); + /* selected satellite text */ + polv->sel = goo_canvas_text_model_new (root, "", + polv->cx + polv->r + 2*POLV_LINE_EXTRA, + polv->cy + polv->r + POLV_LINE_EXTRA, + -1, + GTK_ANCHOR_E, + "font", "Sans 8", + "fill-color-rgba", col, + "alignment", PANGO_ALIGN_RIGHT, + NULL); - return root; + return root; } @@ -427,70 +428,70 @@ */ static void correct_pole_coor (GtkPolarView *polv, - polar_view_pole_t pole, - gfloat *x, gfloat *y, - GtkAnchorType *anch) + polar_view_pole_t pole, + gfloat *x, gfloat *y, + GtkAnchorType *anch) { - switch (pole) { + switch (pole) { - case POLAR_VIEW_POLE_N: - if ((polv->swap == POLAR_VIEW_SENW) || - (polv->swap == POLAR_VIEW_SWNE)) { - /* North and South are swapped */ - *y = *y + POLV_LINE_EXTRA; - *anch = GTK_ANCHOR_NORTH; - } - else { - *y = *y - POLV_LINE_EXTRA; - *anch = GTK_ANCHOR_SOUTH; - } + case POLAR_VIEW_POLE_N: + if ((polv->swap == POLAR_VIEW_SENW) || + (polv->swap == POLAR_VIEW_SWNE)) { + /* North and South are swapped */ + *y = *y + POLV_LINE_EXTRA; + *anch = GTK_ANCHOR_NORTH; + } + else { + *y = *y - POLV_LINE_EXTRA; + *anch = GTK_ANCHOR_SOUTH; + } - break; + break; - case POLAR_VIEW_POLE_E: - if ((polv->swap == POLAR_VIEW_NWSE) || - (polv->swap == POLAR_VIEW_SWNE)) { - /* East and West are swapped */ - *x = *x - POLV_LINE_EXTRA; - *anch = GTK_ANCHOR_EAST; - } - else { - *x = *x + POLV_LINE_EXTRA; - *anch = GTK_ANCHOR_WEST; - } - break; + case POLAR_VIEW_POLE_E: + if ((polv->swap == POLAR_VIEW_NWSE) || + (polv->swap == POLAR_VIEW_SWNE)) { + /* East and West are swapped */ + *x = *x - POLV_LINE_EXTRA; + *anch = GTK_ANCHOR_EAST; + } + else { + *x = *x + POLV_LINE_EXTRA; + *anch = GTK_ANCHOR_WEST; + } + break; - case POLAR_VIEW_POLE_S: - if ((polv->swap == POLAR_VIEW_SENW) || - (polv->swap == POLAR_VIEW_SWNE)) { - /* North and South are swapped */ - *y = *y - POLV_LINE_EXTRA; - *anch = GTK_ANCHOR_SOUTH; - } - else { - *y = *y + POLV_LINE_EXTRA; - *anch = GTK_ANCHOR_NORTH; - } - break; + case POLAR_VIEW_POLE_S: + if ((polv->swap == POLAR_VIEW_SENW) || + (polv->swap == POLAR_VIEW_SWNE)) { + /* North and South are swapped */ + *y = *y - POLV_LINE_EXTRA; + *anch = GTK_ANCHOR_SOUTH; + } + else { + *y = *y + POLV_LINE_EXTRA; + *anch = GTK_ANCHOR_NORTH; + } + break; - case POLAR_VIEW_POLE_W: - if ((polv->swap == POLAR_VIEW_NWSE) || - (polv->swap == POLAR_VIEW_SWNE)) { - /* East and West are swapped */ - *x = *x + POLV_LINE_EXTRA; - *anch = GTK_ANCHOR_WEST; - } - else { - *x = *x - POLV_LINE_EXTRA; - *anch = GTK_ANCHOR_EAST; - } - break; + case POLAR_VIEW_POLE_W: + if ((polv->swap == POLAR_VIEW_NWSE) || + (polv->swap == POLAR_VIEW_SWNE)) { + /* East and West are swapped */ + *x = *x + POLV_LINE_EXTRA; + *anch = GTK_ANCHOR_WEST; + } + else { + *x = *x - POLV_LINE_EXTRA; + *anch = GTK_ANCHOR_EAST; + } + break; - default: - /* FIXME: bug */ - break; - } + default: + /* FIXME: bug */ + break; + } } @@ -503,128 +504,137 @@ static void size_allocate_cb (GtkWidget *widget, GtkAllocation *allocation, gpointer data) { - GtkPolarView *polv; - GooCanvasPoints *prec; - gfloat x,y; - GtkAnchorType anch = GTK_ANCHOR_CENTER; + GTK_POLAR_VIEW (data)->resize = TRUE; +} - if (GTK_WIDGET_REALIZED (widget)) { +static void +update_polv_size (GtkPolarView *polv) +{ + //GtkPolarView *polv; + GtkAllocation allocation; + GooCanvasPoints *prec; + gfloat x,y; + GtkAnchorType anch = GTK_ANCHOR_CENTER; - /* get graph dimensions */ - polv = GTK_POLAR_VIEW (data); - polv->size = MIN(allocation->width, allocation->height); - polv->r = (polv->size / 2) - POLV_DEFAULT_MARGIN; - polv->cx = allocation->width / 2; - polv->cy = allocation->height / 2; + if (GTK_WIDGET_REALIZED (polv)) { + + /* get graph dimensions */ + allocation.width = GTK_WIDGET (polv)->allocation.width; + allocation.height = GTK_WIDGET (polv)->allocation.height; + polv->size = MIN(allocation.width, allocation.height); + polv->r = (polv->size / 2) - POLV_DEFAULT_MARGIN; + polv->cx = allocation.width / 2; + polv->cy = allocation.height / 2; + /* update canvas bounds to match new size */ goo_canvas_set_bounds (GOO_CANVAS (GTK_POLAR_VIEW (polv)->canvas), 0, 0, - allocation->width, allocation->height); + allocation.width, allocation.height); - /* update coordinate system */ - g_object_set (polv->C00, - "center-x", (gdouble) polv->cx, - "center-y", (gdouble) polv->cy, - "radius-x", (gdouble) polv->r, - "radius-y", (gdouble) polv->r, - NULL); - g_object_set (polv->C30, - "center-x", (gdouble) polv->cx, - "center-y", (gdouble) polv->cy, - "radius-x", (gdouble) 0.6667*polv->r, - "radius-y", (gdouble) 0.6667*polv->r, - NULL); - g_object_set (polv->C60, - "center-x", (gdouble) polv->cx, - "center-y", (gdouble) polv->cy, - "radius-x", (gdouble) 0.333*polv->r, - "radius-y", (gdouble) 0.333*polv->r, - NULL); + /* update coordinate system */ + g_object_set (polv->C00, + "center-x", (gdouble) polv->cx, + "center-y", (gdouble) polv->cy, + "radius-x", (gdouble) polv->r, + "radius-y", (gdouble) polv->r, + NULL); + g_object_set (polv->C30, + "center-x", (gdouble) polv->cx, + "center-y", (gdouble) polv->cy, + "radius-x", (gdouble) 0.6667*polv->r, + "radius-y", (gdouble) 0.6667*polv->r, + NULL); + g_object_set (polv->C60, + "center-x", (gdouble) polv->cx, + "center-y", (gdouble) polv->cy, + "radius-x", (gdouble) 0.333*polv->r, + "radius-y", (gdouble) 0.333*polv->r, + NULL); - /* horizontal line */ - prec = goo_canvas_points_new (2); - prec->coords[0] = polv->cx - polv->r - POLV_LINE_EXTRA; - prec->coords[1] = polv->cy; - prec->coords[2] = polv->cx + polv->r + POLV_LINE_EXTRA; - prec->coords[3] = polv->cy; - g_object_set (polv->hl, - "points", prec, - NULL); + /* horizontal line */ + prec = goo_canvas_points_new (2); + prec->coords[0] = polv->cx - polv->r - POLV_LINE_EXTRA; + prec->coords[1] = polv->cy; + prec->coords[2] = polv->cx + polv->r + POLV_LINE_EXTRA; + prec->coords[3] = polv->cy; + g_object_set (polv->hl, + "points", prec, + NULL); - /* vertical line */ - prec->coords[0] = polv->cx; - prec->coords[1] = polv->cy - polv->r - POLV_LINE_EXTRA; - prec->coords[2] = polv->cx; - prec->coords[3] = polv->cy + polv->r + POLV_LINE_EXTRA; - g_object_set (polv->vl, - "points", prec, - NULL); + /* vertical line */ + prec->coords[0] = polv->cx; + prec->coords[1] = polv->cy - polv->r - POLV_LINE_EXTRA; + prec->coords[2] = polv->cx; + prec->coords[3] = polv->cy + polv->r + POLV_LINE_EXTRA; + g_object_set (polv->vl, + "points", prec, + NULL); - /* free memory */ - goo_canvas_points_unref (prec); - - /* N/E/S/W */ - azel_to_xy (polv, 0.0, 0.0, &x, &y); - correct_pole_coor (polv, POLAR_VIEW_POLE_N, &x, &y, &anch); - g_object_set (polv->N, - "x", x, - "y", y, - NULL); + /* free memory */ + goo_canvas_points_unref (prec); + + /* N/E/S/W */ + azel_to_xy (polv, 0.0, 0.0, &x, &y); + correct_pole_coor (polv, POLAR_VIEW_POLE_N, &x, &y, &anch); + g_object_set (polv->N, + "x", x, + "y", y, + NULL); - azel_to_xy (polv, 90.0, 0.0, &x, &y); - correct_pole_coor (polv, POLAR_VIEW_POLE_E, &x, &y, &anch); - g_object_set (polv->E, - "x", x, - "y", y, - NULL); + azel_to_xy (polv, 90.0, 0.0, &x, &y); + correct_pole_coor (polv, POLAR_VIEW_POLE_E, &x, &y, &anch); + g_object_set (polv->E, + "x", x, + "y", y, + NULL); - azel_to_xy (polv, 180.0, 0.0, &x, &y); - correct_pole_coor (polv, POLAR_VIEW_POLE_S, &x, &y, &anch); - g_object_set (polv->S, - "x", x, - "y", y, - NULL); + azel_to_xy (polv, 180.0, 0.0, &x, &y); + correct_pole_coor (polv, POLAR_VIEW_POLE_S, &x, &y, &anch); + g_object_set (polv->S, + "x", x, + "y", y, + NULL); - azel_to_xy (polv, 270.0, 0.0, &x, &y); - correct_pole_coor (polv, POLAR_VIEW_POLE_W, &x, &y, &anch); - g_object_set (polv->W, - "x", x, - "y", y, - NULL); + azel_to_xy (polv, 270.0, 0.0, &x, &y); + correct_pole_coor (polv, POLAR_VIEW_POLE_W, &x, &y, &anch); + g_object_set (polv->W, + "x", x, + "y", y, + NULL); - /* cursor track */ - g_object_set (polv->curs, - "x", (gfloat) (polv->cx - polv->r - 2*POLV_LINE_EXTRA), - "y", (gfloat) (polv->cy + polv->r + POLV_LINE_EXTRA), - NULL); + /* cursor track */ + g_object_set (polv->curs, + "x", (gfloat) (polv->cx - polv->r - 2*POLV_LINE_EXTRA), + "y", (gfloat) (polv->cy + polv->r + POLV_LINE_EXTRA), + NULL); - /* location name */ - g_object_set (polv->locnam, - "x", (gfloat) (polv->cx - polv->r - 2*POLV_LINE_EXTRA), - "y", (gfloat) (polv->cy - polv->r - POLV_LINE_EXTRA), - NULL); + /* location name */ + g_object_set (polv->locnam, + "x", (gfloat) (polv->cx - polv->r - 2*POLV_LINE_EXTRA), + "y", (gfloat) (polv->cy - polv->r - POLV_LINE_EXTRA), + NULL); - /* next event */ - g_object_set (polv->next, - "x", (gfloat) (polv->cx + polv->r + 2*POLV_LINE_EXTRA), - "y", (gfloat) (polv->cy - polv->r - POLV_LINE_EXTRA), - NULL); + /* next event */ + g_object_set (polv->next, + "x", (gfloat) (polv->cx + polv->r + 2*POLV_LINE_EXTRA), + "y", (gfloat) (polv->cy - polv->r - POLV_LINE_EXTRA), + NULL); - /* selection info */ - g_object_set (polv->sel, - "x", (gfloat) polv->cx + polv->r + 2*POLV_LINE_EXTRA, - "y", (gfloat) polv->cy + polv->r + POLV_LINE_EXTRA, - NULL); + /* selection info */ + g_object_set (polv->sel, + "x", (gfloat) polv->cx + polv->r + 2*POLV_LINE_EXTRA, + "y", (gfloat) polv->cy + polv->r + POLV_LINE_EXTRA, + NULL); - g_hash_table_foreach (polv->sats, update_sat, polv); + g_hash_table_foreach (polv->sats, update_sat, polv); - /* sky tracks */ - g_hash_table_foreach (polv->obj, update_track, polv); + /* sky tracks */ + g_hash_table_foreach (polv->obj, update_track, polv); - } + } } @@ -638,11 +648,11 @@ static void on_canvas_realized (GtkWidget *canvas, gpointer data) { - GtkAllocation aloc; + GtkAllocation aloc; - aloc.width = canvas->allocation.width; - aloc.height = canvas->allocation.height; - size_allocate_cb (canvas, &aloc, data); + aloc.width = canvas->allocation.width; + aloc.height = canvas->allocation.height; + size_allocate_cb (canvas, &aloc, data); } @@ -650,321 +660,325 @@ void gtk_polar_view_update (GtkWidget *widget) { - GtkPolarView *polv = GTK_POLAR_VIEW (widget); - gdouble number, now; - gchar *buff; - guint h,m,s; - gchar *ch,*cm,*cs; - sat_t *sat = NULL; - gint *catnr; + GtkPolarView *polv = GTK_POLAR_VIEW (widget); + gdouble number, now; + gchar *buff; + guint h,m,s; + gchar *ch,*cm,*cs; + sat_t *sat = NULL; + gint *catnr; + if (polv->resize) { + update_polv_size (polv); + polv->resize = FALSE; + } + + /* check refresh rate and refresh sats if time */ + if (polv->counter < polv->refresh) { + polv->counter++; + } + else { + /* reset data */ + polv->counter = 1; + polv->naos = 2458849.5; - /* check refresh rate and refresh sats if time */ - if (polv->counter < polv->refresh) { - polv->counter++; - } - else { - /* reset data */ - polv->counter = 1; - polv->naos = 2458849.5; + /* update sats */ + g_hash_table_foreach (polv->sats, update_sat, polv); - /* update sats */ - g_hash_table_foreach (polv->sats, update_sat, polv); + /* update countdown to NEXT AOS label */ + if (polv->eventinfo) { - /* update countdown to NEXT AOS label */ - if (polv->eventinfo) { + if (polv->ncat > 0) { + catnr = g_try_new0 (gint, 1); + *catnr = polv->ncat; + sat = SAT(g_hash_table_lookup (polv->sats, catnr)); + g_free (catnr); - if (polv->ncat > 0) { - catnr = g_try_new0 (gint, 1); - *catnr = polv->ncat; - sat = SAT(g_hash_table_lookup (polv->sats, catnr)); - g_free (catnr); + /* last desperate sanity check */ + if (sat != NULL) { - /* last desperate sanity check */ - if (sat != NULL) { + now = polv->tstamp; //get_current_daynum (); + number = polv->naos - now; - now = polv->tstamp; //get_current_daynum (); - number = polv->naos - now; + /* convert julian date to seconds */ + s = (guint) (number * 86400); + + /* extract hours */ + h = (guint) floor (s/3600); + s -= 3600*h; - /* convert julian date to seconds */ - s = (guint) (number * 86400); - - /* extract hours */ - h = (guint) floor (s/3600); - s -= 3600*h; + /* leading zero */ + if ((h > 0) && (h < 10)) + ch = g_strdup ("0"); + else + ch = g_strdup (""); - /* leading zero */ - if ((h > 0) && (h < 10)) - ch = g_strdup ("0"); - else - ch = g_strdup (""); + /* extract minutes */ + m = (guint) floor (s/60); + s -= 60*m; + + /* leading zero */ + if (m < 10) + cm = g_strdup ("0"); + else + cm = g_strdup (""); + + /* leading zero */ + if (s < 10) + cs = g_strdup (":0"); + else + cs = g_strdup (":"); + + if (h > 0) + buff = g_strdup_printf (_("Next: %s\nin %s%d:%s%d%s%d"), + sat->tle.sat_name, ch, h, cm, m, cs, s); + else + buff = g_strdup_printf (_("Next: %s\nin %s%d%s%d"), + sat->tle.sat_name, cm, m, cs, s); + + + g_object_set (polv->next, + "text", buff, + NULL); - /* extract minutes */ - m = (guint) floor (s/60); - s -= 60*m; - - /* leading zero */ - if (m < 10) - cm = g_strdup ("0"); - else - cm = g_strdup (""); - - /* leading zero */ - if (s < 10) - cs = g_strdup (":0"); - else - cs = g_strdup (":"); - - if (h > 0) - buff = g_strdup_printf (_("Next: %s\nin %s%d:%s%d%s%d"), - sat->tle.sat_name, ch, h, cm, m, cs, s); - else - buff = g_strdup_printf (_("Next: %s\nin %s%d%s%d"), - sat->tle.sat_name, cm, m, cs, s); - - - g_object_set (polv->next, - "text", buff, - NULL); + g_free (buff); + g_free (ch); + g_free (cm); + g_free (cs); + } + else { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Can not find NEXT satellite."), + __FUNCTION__); + g_object_set (polv->next, + "text", _("Next: ERR"), + NULL); + } + } + else { + g_object_set (polv->next, + "text", _("Next: N/A"), + NULL); + } + } + else { + g_object_set (polv->next, + "text", "", + NULL); + } - g_free (buff); - g_free (ch); - g_free (cm); - g_free (cs); - } - else { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Can not find NEXT satellite."), - __FUNCTION__); - g_object_set (polv->next, - "text", _("Next: ERR"), - NULL); - } - } - else { - g_object_set (polv->next, - "text", _("Next: N/A"), - NULL); - } - } - else { - g_object_set (polv->next, - "text", "", - NULL); - } - - } + } } static void update_sat (gpointer key, gpointer value, gpointer data) { - gint *catnum; - sat_t *sat = SAT(value); - GtkPolarView *polv = GTK_POLAR_VIEW (data); - sat_obj_t *obj = NULL; - gfloat x,y; - GooCanvasItemModel *root; - gint idx,i; - gdouble now;// = get_current_daynum (); - gchar *text; - guint32 colour; + gint *catnum; + sat_t *sat = SAT(value); + GtkPolarView *polv = GTK_POLAR_VIEW (data); + sat_obj_t *obj = NULL; + gfloat x,y; + GooCanvasItemModel *root; + gint idx,i; + gdouble now;// = get_current_daynum (); + gchar *text; + guint32 colour; - catnum = g_new0 (gint, 1); - *catnum = sat->tle.catnr; + catnum = g_new0 (gint, 1); + *catnum = sat->tle.catnr; - now = polv->tstamp; + now = polv->tstamp; - /* update next AOS */ - if ((sat->aos > now) && (sat->aos < polv->naos)) { - polv->naos = sat->aos; - polv->ncat = sat->tle.catnr; - } + /* update next AOS */ + if ((sat->aos > now) && (sat->aos < polv->naos)) { + polv->naos = sat->aos; + polv->ncat = sat->tle.catnr; + } - /* if sat is out of range */ - if (sat->el < 0.00) { + /* if sat is out of range */ + if (sat->el < 0.00) { - obj = SAT_OBJ(g_hash_table_lookup (polv->obj, catnum)); + obj = SAT_OBJ(g_hash_table_lookup (polv->obj, catnum)); - /* if sat is on canvas */ - if (obj != NULL) { + /* if sat is on canvas */ + if (obj != NULL) { - /* remove sat from canvas */ - root = goo_canvas_get_root_item_model (GOO_CANVAS (polv->canvas)); + /* remove sat from canvas */ + root = goo_canvas_get_root_item_model (GOO_CANVAS (polv->canvas)); - idx = goo_canvas_item_model_find_child (root, obj->marker); - if (idx != -1) { - goo_canvas_item_model_remove_child (root, idx); - } + idx = goo_canvas_item_model_find_child (root, obj->marker); + if (idx != -1) { + goo_canvas_item_model_remove_child (root, idx); + } - idx = goo_canvas_item_model_find_child (root, obj->label); - if (idx != -1) { - goo_canvas_item_model_remove_child (root, idx); - } + idx = goo_canvas_item_model_find_child (root, obj->label); + if (idx != -1) { + goo_canvas_item_model_remove_child (root, idx); + } - /* remove sky track */ - if (obj->showtrack) { - idx = goo_canvas_item_model_find_child (root, obj->track); - if (idx != -1) - goo_canvas_item_model_remove_child (root, idx); + /* remove sky track */ + if (obj->showtrack) { + idx = goo_canvas_item_model_find_child (root, obj->track); + if (idx != -1) + goo_canvas_item_model_remove_child (root, idx); - for (i = 0; i < TRACK_TICK_NUM; i++) { - idx = goo_canvas_item_model_find_child (root, obj->trtick[i]); - if (idx != -1) - goo_canvas_item_model_remove_child (root, idx); - } - } - - /* free pass info */ - free_pass (obj->pass); + for (i = 0; i < TRACK_TICK_NUM; i++) { + idx = goo_canvas_item_model_find_child (root, obj->trtick[i]); + if (idx != -1) + goo_canvas_item_model_remove_child (root, idx); + } + } + + /* free pass info */ + free_pass (obj->pass); - /* if this was the selected satellite we need to - clear the info text - */ - if (obj->selected) { - g_object_set (polv->sel, "text", "", NULL); - } + /* if this was the selected satellite we need to + clear the info text + */ + if (obj->selected) { + g_object_set (polv->sel, "text", "", NULL); + } - g_free (obj); + g_free (obj); - /* remove sat object from hash table */ - g_hash_table_remove (polv->obj, catnum); + /* remove sat object from hash table */ + g_hash_table_remove (polv->obj, catnum); - /* FIXME: remove track from chart */ + /* FIXME: remove track from chart */ - } + } - g_free (catnum); - } + g_free (catnum); + } - /* sat is within range */ - else { + /* sat is within range */ + else { - obj = SAT_OBJ (g_hash_table_lookup (polv->obj, catnum)); - azel_to_xy (polv, sat->az, sat->el, &x, &y); + obj = SAT_OBJ (g_hash_table_lookup (polv->obj, catnum)); + azel_to_xy (polv, sat->az, sat->el, &x, &y); - /* if sat is already on canvas */ - if (obj != NULL) { - /* update sat */ - g_object_set (obj->marker, - "x", x - MARKER_SIZE_HALF, - "y", y - MARKER_SIZE_HALF, - NULL); - g_object_set (obj->label, - "x", x, - "y", y+2, - NULL); + /* if sat is already on canvas */ + if (obj != NULL) { + /* update sat */ + g_object_set (obj->marker, + "x", x - MARKER_SIZE_HALF, + "y", y - MARKER_SIZE_HALF, + NULL); + g_object_set (obj->label, + "x", x, + "y", y+2, + NULL); - /* update selection info if satellite is - selected - */ - if (obj->selected) { - guint h,m,s; - gchar *ch,*cm,*cs; - gdouble number, now; + /* update selection info if satellite is + selected + */ + if (obj->selected) { + guint h,m,s; + gchar *ch,*cm,*cs; + gdouble number, now; - if (sat->los > 0.0) { - now = polv->tstamp;//get_current_daynum (); - number = sat->los - now; + if (sat->los > 0.0) { + now = polv->tstamp;//get_current_daynum (); + number = sat->los - now; - /* convert julian date to seconds */ - s = (guint) (number * 86400); + /* convert julian date to seconds */ + s = (guint) (number * 86400); - /* extract hours */ - h = (guint) floor (s/3600); - s -= 3600*h; + /* extract hours */ + h = (guint) floor (s/3600); + s -= 3600*h; - /* leading zero */ - if ((h > 0) && (h < 10)) - ch = g_strdup ("0"); - else - ch = g_strdup (""); + /* leading zero */ + if ((h > 0) && (h < 10)) + ch = g_strdup ("0"); + else + ch = g_strdup (""); - /* extract minutes */ - m = (guint) floor (s/60); - s -= 60*m; + /* extract minutes */ + m = (guint) floor (s/60); + s -= 60*m; - /* leading zero */ - if (m < 10) - cm = g_strdup ("0"); - else - cm = g_strdup (""); + /* leading zero */ + if (m < 10) + cm = g_strdup ("0"); + else + cm = g_strdup (""); - /* leading zero */ - if (s < 10) - cs = g_strdup (":0"); - else - cs = g_strdup (":"); + /* leading zero */ + if (s < 10) + cs = g_strdup (":0"); + else + cs = g_strdup (":"); - if (h > 0) { - text = g_strdup_printf (_("%s\nLOS in %s%d:%s%d%s%d"), - sat->tle.sat_name, ch, h, cm, m, cs, s); - } - else { - text = g_strdup_printf (_("%s\nLOS in %s%d%s%d"), - sat->tle.sat_name, cm, m, cs, s); - } - g_free (ch); - g_free (cm); - g_free (cs); - } - else { - text = g_strdup_printf (_("%s\nAlways in range"), sat->tle.sat_name); - } - g_object_set (polv->sel, "text", text, NULL); + if (h > 0) { + text = g_strdup_printf (_("%s\nLOS in %s%d:%s%d%s%d"), + sat->tle.sat_name, ch, h, cm, m, cs, s); + } + else { + text = g_strdup_printf (_("%s\nLOS in %s%d%s%d"), + sat->tle.sat_name, cm, m, cs, s); + } + g_free (ch); + g_free (cm); + g_free (cs); + } + else { + text = g_strdup_printf (_("%s\nAlways in range"), sat->tle.sat_name); + } + g_object_set (polv->sel, "text", text, NULL); - g_free (text); - } + g_free (text); + } - g_free (catnum); - } - else { - /* add sat to canvas */ - obj = g_try_new (sat_obj_t, 1); - obj->selected = FALSE; - obj->showtrack = FALSE; - obj->istarget = FALSE; + g_free (catnum); + } + else { + /* add sat to canvas */ + obj = g_try_new (sat_obj_t, 1); + obj->selected = FALSE; + obj->showtrack = FALSE; + obj->istarget = FALSE; - root = goo_canvas_get_root_item_model (GOO_CANVAS (polv->canvas)); + root = goo_canvas_get_root_item_model (GOO_CANVAS (polv->canvas)); - colour = mod_cfg_get_int (polv->cfgdata, - MOD_CFG_POLAR_SECTION, - MOD_CFG_POLAR_SAT_COL, - SAT_CFG_INT_POLAR_SAT_COL); + colour = mod_cfg_get_int (polv->cfgdata, + MOD_CFG_POLAR_SECTION, + MOD_CFG_POLAR_SAT_COL, + SAT_CFG_INT_POLAR_SAT_COL); - obj->marker = goo_canvas_rect_model_new (root, - x - MARKER_SIZE_HALF, - y - MARKER_SIZE_HALF, - 2*MARKER_SIZE_HALF, - 2*MARKER_SIZE_HALF, - "fill-color-rgba", colour, - "stroke-color-rgba", colour, - NULL); - obj->label = goo_canvas_text_model_new (root, sat->tle.sat_name, - x, - y+2, - -1, - GTK_ANCHOR_NORTH, - "font", "Sans 8", - "fill-color-rgba", colour, - NULL); - - goo_canvas_item_model_raise (obj->marker, NULL); - goo_canvas_item_model_raise (obj->label, NULL); + obj->marker = goo_canvas_rect_model_new (root, + x - MARKER_SIZE_HALF, + y - MARKER_SIZE_HALF, + 2*MARKER_SIZE_HALF, + 2*MARKER_SIZE_HALF, + "fill-color-rgba", colour, + "stroke-color-rgba", colour, + NULL); + obj->label = goo_canvas_text_model_new (root, sat->tle.sat_name, + x, + y+2, + -1, + GTK_ANCHOR_NORTH, + "font", "Sans 8", + "fill-color-rgba", colour, + NULL); + + goo_canvas_item_model_raise (obj->marker, NULL); + goo_canvas_item_model_raise (obj->label, NULL); - g_object_set_data (G_OBJECT (obj->marker), "catnum", GINT_TO_POINTER(*catnum)); - g_object_set_data (G_OBJECT (obj->label), "catnum", GINT_TO_POINTER(*catnum)); + g_object_set_data (G_OBJECT (obj->marker), "catnum", GINT_TO_POINTER(*catnum)); + g_object_set_data (G_OBJECT (obj->label), "catnum", GINT_TO_POINTER(*catnum)); - /* get info about the current pass */ - obj->pass = get_current_pass (sat, polv->qth, now); + /* get info about the current pass */ + obj->pass = get_current_pass (sat, polv->qth, now); - /* add sat to hash table */ - g_hash_table_insert (polv->obj, catnum, obj); - } + /* add sat to hash table */ + g_hash_table_insert (polv->obj, catnum, obj); + } - } + } } @@ -973,62 +987,62 @@ static void update_track (gpointer key, gpointer value, gpointer data) { - sat_obj_t *obj = SAT_OBJ(value);; - GtkPolarView *pv = GTK_POLAR_VIEW (data); - guint num,i; - GooCanvasPoints *points; - gfloat x,y; - pass_detail_t *detail; - guint tres,ttidx; + sat_obj_t *obj = SAT_OBJ(value);; + GtkPolarView *pv = GTK_POLAR_VIEW (data); + guint num,i; + GooCanvasPoints *points; + gfloat x,y; + pass_detail_t *detail; + guint tres,ttidx; - if (obj->showtrack) { + if (obj->showtrack) { - /* create points */ - num = g_slist_length (obj->pass->details); + /* create points */ + num = g_slist_length (obj->pass->details); - points = goo_canvas_points_new (num); + points = goo_canvas_points_new (num); - /* first point should be (aos_az,0.0) */ - azel_to_xy (pv, obj->pass->aos_az, 0.0, &x, &y); - points->coords[0] = (double) x; - points->coords[1] = (double) y; + /* first point should be (aos_az,0.0) */ + azel_to_xy (pv, obj->pass->aos_az, 0.0, &x, &y); + points->coords[0] = (double) x; + points->coords[1] = (double) y; - /* time tick 0 */ - g_object_set (obj->trtick[0], "x", (gdouble) x, "y", (gdouble) y, NULL); + /* time tick 0 */ + g_object_set (obj->trtick[0], "x", (gdouble) x, "y", (gdouble) y, NULL); - /* time resolution for time ticks; we need - 3 additional points to AOS and LOS ticks. - */ - tres = (num-2) / (TRACK_TICK_NUM-1); - ttidx = 1; + /* time resolution for time ticks; we need + 3 additional points to AOS and LOS ticks. + */ + tres = (num-2) / (TRACK_TICK_NUM-1); + ttidx = 1; - for (i = 1; i < num-1; i++) { - detail = PASS_DETAIL(g_slist_nth_data (obj->pass->details, i)); - azel_to_xy (pv, detail->az, detail->el, &x, &y); - points->coords[2*i] = (double) x; - points->coords[2*i+1] = (double) y; + for (i = 1; i < num-1; i++) { + detail = PASS_DETAIL(g_slist_nth_data (obj->pass->details, i)); + azel_to_xy (pv, detail->az, detail->el, &x, &y); + points->coords[2*i] = (double) x; + points->coords[2*i+1] = (double) y; - if (!(i % tres)) { - /* update time tick */ - g_object_set (obj->trtick[ttidx], - "x", (gdouble) x, "y", (gdouble) y, - NULL); - ttidx++; - } - } + if (!(i % tres)) { + /* update time tick */ + g_object_set (obj->trtick[ttidx], + "x", (gdouble) x, "y", (gdouble) y, + NULL); + ttidx++; + } + } - /* last point should be (los_az, 0.0) */ - azel_to_xy (pv, obj->pass->los_az, 0.0, &x, &y); - points->coords[2*(num-1)] = (double) x; - points->coords[2*(num-1)+1] = (double) y; + /* last point should be (los_az, 0.0) */ + azel_to_xy (pv, obj->pass->los_az, 0.0, &x, &y); + points->coords[2*(num-1)] = (double) x; + points->coords[2*(num-1)+1] = (double) y; - g_object_set (obj->track, "points", points, NULL); + g_object_set (obj->track, "points", points, NULL); - goo_canvas_points_unref (points); + goo_canvas_po... [truncated message content] |
From: <cs...@us...> - 2009-05-01 23:06:58
|
Revision: 284 http://gpredict.svn.sourceforge.net/gpredict/?rev=284&view=rev Author: csete Date: 2009-05-01 23:06:55 +0000 (Fri, 01 May 2009) Log Message: ----------- Fixed indent. Modified Paths: -------------- trunk/src/gtk-sat-map.c trunk/src/gtk-sat-map.h Modified: trunk/src/gtk-sat-map.c =================================================================== --- trunk/src/gtk-sat-map.c 2009-05-01 23:04:14 UTC (rev 283) +++ trunk/src/gtk-sat-map.c 2009-05-01 23:06:55 UTC (rev 284) @@ -58,7 +58,7 @@ #endif #include <goocanvas.h> -#define MARKER_SIZE_HALF 1 +#define MARKER_SIZE_HALF 1 static void gtk_sat_map_class_init (GtkSatMapClass *class); static void gtk_sat_map_init (GtkSatMap *polview); @@ -70,22 +70,22 @@ static void lonlat_to_xy (GtkSatMap *m, gdouble lon, gdouble lat, gfloat *x, gfloat *y); static void xy_to_lonlat (GtkSatMap *m, gfloat x, gfloat y, gfloat *lon, gfloat *lat); static gboolean on_motion_notify (GooCanvasItem *item, - GooCanvasItem *target, - GdkEventMotion *event, - gpointer data); + GooCanvasItem *target, + GdkEventMotion *event, + gpointer data); static void on_item_created (GooCanvas *canvas, - GooCanvasItem *item, - GooCanvasItemModel *model, - gpointer data); + GooCanvasItem *item, + GooCanvasItemModel *model, + gpointer data); static void on_canvas_realized (GtkWidget *canvas, gpointer data); static gboolean on_button_press (GooCanvasItem *item, - GooCanvasItem *target, - GdkEventButton *event, - gpointer data); + GooCanvasItem *target, + GdkEventButton *event, + gpointer data); static gboolean on_button_release (GooCanvasItem *item, - GooCanvasItem *target, - GdkEventButton *event, - gpointer data); + GooCanvasItem *target, + GdkEventButton *event, + gpointer data); static void clear_selection (gpointer key, gpointer val, gpointer data); static void load_map_file (GtkSatMap *satmap); static GooCanvasItemModel* create_canvas_model (GtkSatMap *satmap); @@ -111,28 +111,28 @@ GtkType gtk_sat_map_get_type () { - static GType gtk_sat_map_type = 0; + static GType gtk_sat_map_type = 0; - if (!gtk_sat_map_type) { - static const GTypeInfo gtk_sat_map_info = { - sizeof (GtkSatMapClass), - NULL, /* base init */ - NULL, /* base finalize */ - (GClassInitFunc) gtk_sat_map_class_init, - NULL, /* class finalize */ - NULL, /* class data */ - sizeof (GtkSatMap), - 5, /* n_preallocs */ - (GInstanceInitFunc) gtk_sat_map_init, - }; + if (!gtk_sat_map_type) { + static const GTypeInfo gtk_sat_map_info = { + sizeof (GtkSatMapClass), + NULL, /* base init */ + NULL, /* base finalize */ + (GClassInitFunc) gtk_sat_map_class_init, + NULL, /* class finalize */ + NULL, /* class data */ + sizeof (GtkSatMap), + 5, /* n_preallocs */ + (GInstanceInitFunc) gtk_sat_map_init, + }; - gtk_sat_map_type = g_type_register_static (GTK_TYPE_VBOX, - "GtkSatMap", - >k_sat_map_info, - 0); - } + gtk_sat_map_type = g_type_register_static (GTK_TYPE_VBOX, + "GtkSatMap", + >k_sat_map_info, + 0); + } - return gtk_sat_map_type; + return gtk_sat_map_type; } @@ -140,20 +140,20 @@ static void gtk_sat_map_class_init (GtkSatMapClass *class) { - GObjectClass *gobject_class; - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; + GObjectClass *gobject_class; + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + GtkContainerClass *container_class; - gobject_class = G_OBJECT_CLASS (class); - object_class = (GtkObjectClass*) class; - widget_class = (GtkWidgetClass*) class; - container_class = (GtkContainerClass*) class; + gobject_class = G_OBJECT_CLASS (class); + object_class = (GtkObjectClass*) class; + widget_class = (GtkWidgetClass*) class; + container_class = (GtkContainerClass*) class; - parent_class = g_type_class_peek_parent (class); + parent_class = g_type_class_peek_parent (class); - object_class->destroy = gtk_sat_map_destroy; - /* widget_class->size_allocate = gtk_sat_map_size_allocate; */ + object_class->destroy = gtk_sat_map_destroy; + /* widget_class->size_allocate = gtk_sat_map_size_allocate; */ } @@ -161,24 +161,24 @@ static void gtk_sat_map_init (GtkSatMap *satmap) { - satmap->sats = NULL; - satmap->qth = NULL; - satmap->obj = NULL; - satmap->naos = 2458849.5; - satmap->ncat = 0; - satmap->tstamp = 2458849.5; - satmap->x0 = 0; - satmap->y0 = 0; - satmap->width = 0; - satmap->height = 0; - satmap->refresh = 0; - satmap->counter = 0; - satmap->qthinfo = FALSE; - satmap->eventinfo = FALSE; - satmap->cursinfo = FALSE; - satmap->showgrid = FALSE; - satmap->keepratio = FALSE; - satmap->resize = FALSE; + satmap->sats = NULL; + satmap->qth = NULL; + satmap->obj = NULL; + satmap->naos = 2458849.5; + satmap->ncat = 0; + satmap->tstamp = 2458849.5; + satmap->x0 = 0; + satmap->y0 = 0; + satmap->width = 0; + satmap->height = 0; + satmap->refresh = 0; + satmap->counter = 0; + satmap->qthinfo = FALSE; + satmap->eventinfo = FALSE; + satmap->cursinfo = FALSE; + satmap->showgrid = FALSE; + satmap->keepratio = FALSE; + satmap->resize = FALSE; } @@ -186,7 +186,7 @@ static void gtk_sat_map_destroy (GtkObject *object) { - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } @@ -199,99 +199,99 @@ GtkWidget* gtk_sat_map_new (GKeyFile *cfgdata, GHashTable *sats, qth_t *qth) { - GtkWidget *satmap; - GooCanvasItemModel *root; - guint32 col; + GtkWidget *satmap; + GooCanvasItemModel *root; + guint32 col; - satmap = g_object_new (GTK_TYPE_SAT_MAP, NULL); + satmap = g_object_new (GTK_TYPE_SAT_MAP, NULL); - GTK_SAT_MAP (satmap)->cfgdata = cfgdata; - GTK_SAT_MAP (satmap)->sats = sats; - GTK_SAT_MAP (satmap)->qth = qth; + GTK_SAT_MAP (satmap)->cfgdata = cfgdata; + GTK_SAT_MAP (satmap)->sats = sats; + GTK_SAT_MAP (satmap)->qth = qth; - GTK_SAT_MAP (satmap)->obj = g_hash_table_new_full (g_int_hash, g_int_equal, g_free, NULL); + GTK_SAT_MAP (satmap)->obj = g_hash_table_new_full (g_int_hash, g_int_equal, g_free, NULL); - /* get settings */ - GTK_SAT_MAP (satmap)->refresh = mod_cfg_get_int (cfgdata, - MOD_CFG_MAP_SECTION, - MOD_CFG_MAP_REFRESH, - SAT_CFG_INT_MAP_REFRESH); - GTK_SAT_MAP (satmap)->counter = 1; + /* get settings */ + GTK_SAT_MAP (satmap)->refresh = mod_cfg_get_int (cfgdata, + MOD_CFG_MAP_SECTION, + MOD_CFG_MAP_REFRESH, + SAT_CFG_INT_MAP_REFRESH); + GTK_SAT_MAP (satmap)->counter = 1; - GTK_SAT_MAP (satmap)->qthinfo = mod_cfg_get_bool (cfgdata, - MOD_CFG_MAP_SECTION, - MOD_CFG_MAP_SHOW_QTH_INFO, - SAT_CFG_BOOL_MAP_SHOW_QTH_INFO); + GTK_SAT_MAP (satmap)->qthinfo = mod_cfg_get_bool (cfgdata, + MOD_CFG_MAP_SECTION, + MOD_CFG_MAP_SHOW_QTH_INFO, + SAT_CFG_BOOL_MAP_SHOW_QTH_INFO); - GTK_SAT_MAP (satmap)->eventinfo = mod_cfg_get_bool (cfgdata, - MOD_CFG_MAP_SECTION, - MOD_CFG_MAP_SHOW_NEXT_EVENT, - SAT_CFG_BOOL_MAP_SHOW_NEXT_EV); + GTK_SAT_MAP (satmap)->eventinfo = mod_cfg_get_bool (cfgdata, + MOD_CFG_MAP_SECTION, + MOD_CFG_MAP_SHOW_NEXT_EVENT, + SAT_CFG_BOOL_MAP_SHOW_NEXT_EV); - GTK_SAT_MAP (satmap)->cursinfo = mod_cfg_get_bool (cfgdata, - MOD_CFG_MAP_SECTION, - MOD_CFG_MAP_SHOW_CURS_TRACK, - SAT_CFG_BOOL_MAP_SHOW_CURS_TRACK); + GTK_SAT_MAP (satmap)->cursinfo = mod_cfg_get_bool (cfgdata, + MOD_CFG_MAP_SECTION, + MOD_CFG_MAP_SHOW_CURS_TRACK, + SAT_CFG_BOOL_MAP_SHOW_CURS_TRACK); - GTK_SAT_MAP (satmap)->showgrid = mod_cfg_get_bool (cfgdata, - MOD_CFG_MAP_SECTION, - MOD_CFG_MAP_SHOW_GRID, - SAT_CFG_BOOL_MAP_SHOW_GRID); + GTK_SAT_MAP (satmap)->showgrid = mod_cfg_get_bool (cfgdata, + MOD_CFG_MAP_SECTION, + MOD_CFG_MAP_SHOW_GRID, + SAT_CFG_BOOL_MAP_SHOW_GRID); - GTK_SAT_MAP (satmap)->keepratio = mod_cfg_get_bool (cfgdata, - MOD_CFG_MAP_SECTION, - MOD_CFG_MAP_KEEP_RATIO, - SAT_CFG_BOOL_MAP_KEEP_RATIO); - col = mod_cfg_get_int (cfgdata, - MOD_CFG_MAP_SECTION, - MOD_CFG_MAP_INFO_BGD_COL, - SAT_CFG_INT_MAP_INFO_BGD_COL); + GTK_SAT_MAP (satmap)->keepratio = mod_cfg_get_bool (cfgdata, + MOD_CFG_MAP_SECTION, + MOD_CFG_MAP_KEEP_RATIO, + SAT_CFG_BOOL_MAP_KEEP_RATIO); + col = mod_cfg_get_int (cfgdata, + MOD_CFG_MAP_SECTION, + MOD_CFG_MAP_INFO_BGD_COL, + SAT_CFG_INT_MAP_INFO_BGD_COL); - GTK_SAT_MAP (satmap)->infobgd = rgba2html (col); + GTK_SAT_MAP (satmap)->infobgd = rgba2html (col); - /* create the canvas */ - GTK_SAT_MAP (satmap)->canvas = goo_canvas_new (); + /* create the canvas */ + GTK_SAT_MAP (satmap)->canvas = goo_canvas_new (); - /* safely load a background map */ - load_map_file (GTK_SAT_MAP (satmap)); + /* safely load a background map */ + load_map_file (GTK_SAT_MAP (satmap)); - /* Initial size request should be based on map size - but if we do this we can not shrink the canvas below this size - even though the map shrinks => better to set default size of - main container window. - */ - /* gtk_widget_set_size_request (GTK_SAT_MAP (satmap)->canvas, */ - /* gdk_pixbuf_get_width (GTK_SAT_MAP (satmap)->origmap), */ - /* gdk_pixbuf_get_height (GTK_SAT_MAP (satmap)->origmap)); */ + /* Initial size request should be based on map size + but if we do this we can not shrink the canvas below this size + even though the map shrinks => better to set default size of + main container window. + */ + /* gtk_widget_set_size_request (GTK_SAT_MAP (satmap)->canvas, */ + /* gdk_pixbuf_get_width (GTK_SAT_MAP (satmap)->origmap), */ + /* gdk_pixbuf_get_height (GTK_SAT_MAP (satmap)->origmap)); */ - goo_canvas_set_bounds (GOO_CANVAS (GTK_SAT_MAP (satmap)->canvas), 0, 0, - gdk_pixbuf_get_width (GTK_SAT_MAP (satmap)->origmap), - gdk_pixbuf_get_height (GTK_SAT_MAP (satmap)->origmap)); + goo_canvas_set_bounds (GOO_CANVAS (GTK_SAT_MAP (satmap)->canvas), 0, 0, + gdk_pixbuf_get_width (GTK_SAT_MAP (satmap)->origmap), + gdk_pixbuf_get_height (GTK_SAT_MAP (satmap)->origmap)); - /* connect size-request signal */ - g_signal_connect (GTK_SAT_MAP (satmap)->canvas, "size-allocate", - G_CALLBACK (size_allocate_cb), satmap); - g_signal_connect (GTK_SAT_MAP (satmap)->canvas, "item_created", - (GtkSignalFunc) on_item_created, satmap); - g_signal_connect_after (GTK_SAT_MAP (satmap)->canvas, "realize", - (GtkSignalFunc) on_canvas_realized, satmap); + /* connect size-request signal */ + g_signal_connect (GTK_SAT_MAP (satmap)->canvas, "size-allocate", + G_CALLBACK (size_allocate_cb), satmap); + g_signal_connect (GTK_SAT_MAP (satmap)->canvas, "item_created", + (GtkSignalFunc) on_item_created, satmap); + g_signal_connect_after (GTK_SAT_MAP (satmap)->canvas, "realize", + (GtkSignalFunc) on_canvas_realized, satmap); - gtk_widget_show (GTK_SAT_MAP (satmap)->canvas); + gtk_widget_show (GTK_SAT_MAP (satmap)->canvas); - /* create the canvas model */ - root = create_canvas_model (GTK_SAT_MAP (satmap)); - goo_canvas_set_root_item_model (GOO_CANVAS (GTK_SAT_MAP (satmap)->canvas), root); + /* create the canvas model */ + root = create_canvas_model (GTK_SAT_MAP (satmap)); + goo_canvas_set_root_item_model (GOO_CANVAS (GTK_SAT_MAP (satmap)->canvas), root); - g_object_unref (root); + g_object_unref (root); - /* plot each sat on the canvas */ - g_hash_table_foreach (GTK_SAT_MAP (satmap)->sats, plot_sat, GTK_SAT_MAP (satmap)); + /* plot each sat on the canvas */ + g_hash_table_foreach (GTK_SAT_MAP (satmap)->sats, plot_sat, GTK_SAT_MAP (satmap)); - /* gtk_box_pack_start (GTK_BOX (satmap), GTK_SAT_MAP (satmap)->swin, TRUE, TRUE, 0); */ - gtk_container_add (GTK_CONTAINER (satmap), GTK_SAT_MAP (satmap)->canvas); + /* gtk_box_pack_start (GTK_BOX (satmap), GTK_SAT_MAP (satmap)->swin, TRUE, TRUE, 0); */ + gtk_container_add (GTK_CONTAINER (satmap), GTK_SAT_MAP (satmap)->canvas); - return satmap; + return satmap; } @@ -305,127 +305,127 @@ static GooCanvasItemModel * create_canvas_model (GtkSatMap *satmap) { - GooCanvasItemModel *root; - gchar *buff; - gfloat x,y; - guint32 col; + GooCanvasItemModel *root; + gchar *buff; + gfloat x,y; + guint32 col; - root = goo_canvas_group_model_new (NULL, NULL); + root = goo_canvas_group_model_new (NULL, NULL); - /* map dimensions */ - satmap->width = gdk_pixbuf_get_width (satmap->origmap); - satmap->height = gdk_pixbuf_get_height (satmap->origmap); - satmap->x0 = 0; - satmap->y0 = 0; + /* map dimensions */ + satmap->width = gdk_pixbuf_get_width (satmap->origmap); + satmap->height = gdk_pixbuf_get_height (satmap->origmap); + satmap->x0 = 0; + satmap->y0 = 0; - /* background map */ - satmap->map = goo_canvas_image_model_new (root, - satmap->origmap, - satmap->x0, - satmap->y0, - NULL); + /* background map */ + satmap->map = goo_canvas_image_model_new (root, + satmap->origmap, + satmap->x0, + satmap->y0, + NULL); - goo_canvas_item_model_lower (satmap->map, NULL); + goo_canvas_item_model_lower (satmap->map, NULL); - /* grid lines */ - draw_grid_lines (satmap, root); + /* grid lines */ + draw_grid_lines (satmap, root); - /* QTH mark */ - col = mod_cfg_get_int (satmap->cfgdata, - MOD_CFG_MAP_SECTION, - MOD_CFG_MAP_QTH_COL, - SAT_CFG_INT_MAP_QTH_COL); + /* QTH mark */ + col = mod_cfg_get_int (satmap->cfgdata, + MOD_CFG_MAP_SECTION, + MOD_CFG_MAP_QTH_COL, + SAT_CFG_INT_MAP_QTH_COL); - lonlat_to_xy (satmap, satmap->qth->lon, satmap->qth->lat, &x, &y); - - satmap->qthmark = goo_canvas_rect_model_new (root, - x - MARKER_SIZE_HALF, - y - MARKER_SIZE_HALF, - 2 * MARKER_SIZE_HALF, - 2 * MARKER_SIZE_HALF, - "fill-color-rgba", col, - "stroke-color-rgba", col, - NULL); + lonlat_to_xy (satmap, satmap->qth->lon, satmap->qth->lat, &x, &y); + + satmap->qthmark = goo_canvas_rect_model_new (root, + x - MARKER_SIZE_HALF, + y - MARKER_SIZE_HALF, + 2 * MARKER_SIZE_HALF, + 2 * MARKER_SIZE_HALF, + "fill-color-rgba", col, + "stroke-color-rgba", col, + NULL); - satmap->qthlabel = goo_canvas_text_model_new (root, satmap->qth->name, - x, y+2, -1, - GTK_ANCHOR_NORTH, - "font", "Sans 8", - "fill-color-rgba", col, - NULL); + satmap->qthlabel = goo_canvas_text_model_new (root, satmap->qth->name, + x, y+2, -1, + GTK_ANCHOR_NORTH, + "font", "Sans 8", + "fill-color-rgba", col, + NULL); - /* QTH info */ - col = mod_cfg_get_int (satmap->cfgdata, - MOD_CFG_MAP_SECTION, - MOD_CFG_MAP_INFO_COL, - SAT_CFG_INT_MAP_INFO_COL); + /* QTH info */ + col = mod_cfg_get_int (satmap->cfgdata, + MOD_CFG_MAP_SECTION, + MOD_CFG_MAP_INFO_COL, + SAT_CFG_INT_MAP_INFO_COL); - satmap->locnam = goo_canvas_text_model_new (root, "", - satmap->x0 + 2, satmap->y0 + 1, -1, - GTK_ANCHOR_NORTH_WEST, - "font", "Sans 8", - "fill-color-rgba", col, - "use-markup", TRUE, - NULL); + satmap->locnam = goo_canvas_text_model_new (root, "", + satmap->x0 + 2, satmap->y0 + 1, -1, + GTK_ANCHOR_NORTH_WEST, + "font", "Sans 8", + "fill-color-rgba", col, + "use-markup", TRUE, + NULL); - /* set text only if QTH info is enabled */ - if (satmap->qthinfo) { - /* For now only QTH name and location. - It would be nice with coordinates (remember NWSE setting) - and Maidenhead locator, when using hamlib. - - Note: I used pango markup to set the background color, I didn't find any - other obvious ways to get the text height in pixels to draw rectangle. - */ - buff = g_strdup_printf ("<span background=\"#%s\"> %s \302\267 %s </span>", - satmap->infobgd, - satmap->qth->name, - satmap->qth->loc); - g_object_set (satmap->locnam, "text", buff, NULL); - g_free (buff); - } + /* set text only if QTH info is enabled */ + if (satmap->qthinfo) { + /* For now only QTH name and location. + It would be nice with coordinates (remember NWSE setting) + and Maidenhead locator, when using hamlib. + + Note: I used pango markup to set the background color, I didn't find any + other obvious ways to get the text height in pixels to draw rectangle. + */ + buff = g_strdup_printf ("<span background=\"#%s\"> %s \302\267 %s </span>", + satmap->infobgd, + satmap->qth->name, + satmap->qth->loc); + g_object_set (satmap->locnam, "text", buff, NULL); + g_free (buff); + } - /* next event */ - satmap->next = goo_canvas_text_model_new (root, "", - satmap->x0+satmap->width - 2, - satmap->y0 + 1, -1, - GTK_ANCHOR_NORTH_EAST, - "font", "Sans 8", - "fill-color-rgba", col, - "use-markup", TRUE, - NULL); + /* next event */ + satmap->next = goo_canvas_text_model_new (root, "", + satmap->x0+satmap->width - 2, + satmap->y0 + 1, -1, + GTK_ANCHOR_NORTH_EAST, + "font", "Sans 8", + "fill-color-rgba", col, + "use-markup", TRUE, + NULL); - /* set text only if QTH info is enabled */ - if (satmap->eventinfo) { - buff = g_strdup_printf ("<span background=\"#%s\"> ... </span>", - satmap->infobgd); - g_object_set (satmap->next, "text", buff, NULL); - g_free (buff); - } + /* set text only if QTH info is enabled */ + if (satmap->eventinfo) { + buff = g_strdup_printf ("<span background=\"#%s\"> ... </span>", + satmap->infobgd); + g_object_set (satmap->next, "text", buff, NULL); + g_free (buff); + } - /* cursor track */ - satmap->curs = goo_canvas_text_model_new (root, "", - satmap->x0 + 2, - satmap->y0 + satmap->height - 1, - -1, - GTK_ANCHOR_SOUTH_WEST, - "font", "Sans 8", - "fill-color-rgba", col, - "use-markup", TRUE, - NULL); + /* cursor track */ + satmap->curs = goo_canvas_text_model_new (root, "", + satmap->x0 + 2, + satmap->y0 + satmap->height - 1, + -1, + GTK_ANCHOR_SOUTH_WEST, + "font", "Sans 8", + "fill-color-rgba", col, + "use-markup", TRUE, + NULL); - /* info about a selected satellite */ - satmap->sel = goo_canvas_text_model_new (root, "", - satmap->x0 + satmap->width - 2, - satmap->y0 + satmap->height - 1, - -1, - GTK_ANCHOR_SOUTH_EAST, - "font", "Sans 8", - "fill-color-rgba", col, - "use-markup", TRUE, - NULL); + /* info about a selected satellite */ + satmap->sel = goo_canvas_text_model_new (root, "", + satmap->x0 + satmap->width - 2, + satmap->y0 + satmap->height - 1, + -1, + GTK_ANCHOR_SOUTH_EAST, + "font", "Sans 8", + "fill-color-rgba", col, + "use-markup", TRUE, + NULL); - return root; + return root; } @@ -443,7 +443,7 @@ static void size_allocate_cb (GtkWidget *widget, GtkAllocation *allocation, gpointer data) { - GTK_SAT_MAP (data)->resize = TRUE; + GTK_SAT_MAP (data)->resize = TRUE; } @@ -468,108 +468,108 @@ static void update_map_size (GtkSatMap *satmap) { - GtkAllocation allocation; - GdkPixbuf *pbuf; - gfloat x, y; - gfloat ratio; /* ratio between map width and height */ - gfloat size; /* size = min (alloc.w, ratio*alloc.h) */ + GtkAllocation allocation; + GdkPixbuf *pbuf; + gfloat x, y; + gfloat ratio; /* ratio between map width and height */ + gfloat size; /* size = min (alloc.w, ratio*alloc.h) */ - if (GTK_WIDGET_REALIZED (satmap)) { - /* get graph dimensions */ - allocation.width = GTK_WIDGET (satmap)->allocation.width; - allocation.height = GTK_WIDGET (satmap)->allocation.height; + if (GTK_WIDGET_REALIZED (satmap)) { + /* get graph dimensions */ + allocation.width = GTK_WIDGET (satmap)->allocation.width; + allocation.height = GTK_WIDGET (satmap)->allocation.height; - if (satmap->keepratio) { - /* Use allocation->width and allocation->height to calculate - * new X0 Y0 width and height. Map proportions must be kept. - */ - ratio = gdk_pixbuf_get_width (satmap->origmap) / - gdk_pixbuf_get_height (satmap->origmap); + if (satmap->keepratio) { + /* Use allocation->width and allocation->height to calculate + * new X0 Y0 width and height. Map proportions must be kept. + */ + ratio = gdk_pixbuf_get_width (satmap->origmap) / + gdk_pixbuf_get_height (satmap->origmap); - size = MIN(allocation.width, ratio*allocation.height); + size = MIN(allocation.width, ratio*allocation.height); - satmap->width = (guint) size; - satmap->height = (guint) (size / ratio); - - satmap->x0 = (allocation.width - satmap->width) / 2; - satmap->y0 = (allocation.height - satmap->height) / 2; + satmap->width = (guint) size; + satmap->height = (guint) (size / ratio); + + satmap->x0 = (allocation.width - satmap->width) / 2; + satmap->y0 = (allocation.height - satmap->height) / 2; - /* rescale pixbuf */ - pbuf = gdk_pixbuf_scale_simple (satmap->origmap, - satmap->width, - satmap->height, - GDK_INTERP_BILINEAR); - } - else { - satmap->x0 = 0; - satmap->y0 = 0; - satmap->width = allocation.width; - satmap->height =allocation.height; + /* rescale pixbuf */ + pbuf = gdk_pixbuf_scale_simple (satmap->origmap, + satmap->width, + satmap->height, + GDK_INTERP_BILINEAR); + } + else { + satmap->x0 = 0; + satmap->y0 = 0; + satmap->width = allocation.width; + satmap->height =allocation.height; - /* rescale pixbuf */ - pbuf = gdk_pixbuf_scale_simple (satmap->origmap, - satmap->width, - satmap->height, - GDK_INTERP_BILINEAR); - } + /* rescale pixbuf */ + pbuf = gdk_pixbuf_scale_simple (satmap->origmap, + satmap->width, + satmap->height, + GDK_INTERP_BILINEAR); + } /* set canvas bounds to match new size */ goo_canvas_set_bounds (GOO_CANVAS (GTK_SAT_MAP (satmap)->canvas), 0, 0, satmap->width, satmap->height); - /* redraw static elements */ - g_object_set (satmap->map, - "pixbuf", pbuf, - "x", (gdouble) satmap->x0, - "y", (gdouble) satmap->y0, - NULL); - g_object_unref (pbuf); + /* redraw static elements */ + g_object_set (satmap->map, + "pixbuf", pbuf, + "x", (gdouble) satmap->x0, + "y", (gdouble) satmap->y0, + NULL); + g_object_unref (pbuf); - /* grid lines */ - redraw_grid_lines (satmap); - - /* QTH */ - lonlat_to_xy (satmap, satmap->qth->lon, satmap->qth->lat, &x, &y); - g_object_set (satmap->qthmark, - "x", x - MARKER_SIZE_HALF, - "y", y - MARKER_SIZE_HALF, - NULL); - g_object_set (satmap->qthlabel, - "x", x, - "y", y+2, - NULL); + /* grid lines */ + redraw_grid_lines (satmap); + + /* QTH */ + lonlat_to_xy (satmap, satmap->qth->lon, satmap->qth->lat, &x, &y); + g_object_set (satmap->qthmark, + "x", x - MARKER_SIZE_HALF, + "y", y - MARKER_SIZE_HALF, + NULL); + g_object_set (satmap->qthlabel, + "x", x, + "y", y+2, + NULL); - /* QTH info */ - g_object_set (satmap->locnam, - "x", (gdouble) satmap->x0 + 2, - "y", (gdouble) satmap->y0 + 1, - NULL); + /* QTH info */ + g_object_set (satmap->locnam, + "x", (gdouble) satmap->x0 + 2, + "y", (gdouble) satmap->y0 + 1, + NULL); - /* next event */ - g_object_set (satmap->next, - "x", (gdouble) satmap->x0 + satmap->width - 2, - "y", (gdouble) satmap->y0 + 1, - NULL); + /* next event */ + g_object_set (satmap->next, + "x", (gdouble) satmap->x0 + satmap->width - 2, + "y", (gdouble) satmap->y0 + 1, + NULL); - /* cursor info */ - g_object_set (satmap->curs, - "x", (gdouble) satmap->x0 + 2, - "y", (gdouble) satmap->y0 + satmap->height - 1, - NULL); + /* cursor info */ + g_object_set (satmap->curs, + "x", (gdouble) satmap->x0 + 2, + "y", (gdouble) satmap->y0 + satmap->height - 1, + NULL); - /* selected sat info */ - g_object_set (satmap->sel, - "x", (gdouble) satmap->x0 + satmap->width - 2, - "y", (gdouble) satmap->y0 + satmap->height - 1, - NULL); + /* selected sat info */ + g_object_set (satmap->sel, + "x", (gdouble) satmap->x0 + satmap->width - 2, + "y", (gdouble) satmap->y0 + satmap->height - 1, + NULL); - /* update satellites */ - g_hash_table_foreach (satmap->sats, update_sat, satmap); + /* update satellites */ + g_hash_table_foreach (satmap->sats, update_sat, satmap); - satmap->resize = FALSE; - } + satmap->resize = FALSE; + } } @@ -581,13 +581,13 @@ static void on_canvas_realized (GtkWidget *canvas, gpointer data) { - GtkSatMap *satmap = GTK_SAT_MAP(data); + GtkSatMap *satmap = GTK_SAT_MAP(data); - /* raise info items */ - goo_canvas_item_model_raise (satmap->sel, NULL); - goo_canvas_item_model_raise (satmap->locnam, NULL); - goo_canvas_item_model_raise (satmap->next, NULL); - goo_canvas_item_model_raise (satmap->curs, NULL); + /* raise info items */ + goo_canvas_item_model_raise (satmap->sel, NULL); + goo_canvas_item_model_raise (satmap->locnam, NULL); + goo_canvas_item_model_raise (satmap->next, NULL); + goo_canvas_item_model_raise (satmap->curs, NULL); } @@ -598,118 +598,118 @@ void gtk_sat_map_update (GtkWidget *widget) { - GtkSatMap *satmap = GTK_SAT_MAP (widget); - sat_t *sat = NULL; - gdouble number, now; - gchar *buff; - gint *catnr; - guint h, m, s; - gchar *ch, *cm, *cs; + GtkSatMap *satmap = GTK_SAT_MAP (widget); + sat_t *sat = NULL; + gdouble number, now; + gchar *buff; + gint *catnr; + guint h, m, s; + gchar *ch, *cm, *cs; - /* check whether there are any pending resize requests */ - if (satmap->resize) - update_map_size (satmap); + /* check whether there are any pending resize requests */ + if (satmap->resize) + update_map_size (satmap); - /* check refresh rate and refresh sats if time */ - if (satmap->counter < satmap->refresh) { - satmap->counter++; - } - else { - /* reset data */ - satmap->counter = 1; - satmap->naos = 2458849.5; + /* check refresh rate and refresh sats if time */ + if (satmap->counter < satmap->refresh) { + satmap->counter++; + } + else { + /* reset data */ + satmap->counter = 1; + satmap->naos = 2458849.5; - /* update sats */ - g_hash_table_foreach (satmap->sats, update_sat, satmap); + /* update sats */ + g_hash_table_foreach (satmap->sats, update_sat, satmap); - /* update countdown to NEXT AOS label */ - if (satmap->eventinfo) { + /* update countdown to NEXT AOS label */ + if (satmap->eventinfo) { - if (satmap->ncat > 0) { + if (satmap->ncat > 0) { - catnr = g_try_new0 (gint, 1); - *catnr = satmap->ncat; - sat = SAT(g_hash_table_lookup (satmap->sats, catnr)); - g_free (catnr); + catnr = g_try_new0 (gint, 1); + *catnr = satmap->ncat; + sat = SAT(g_hash_table_lookup (satmap->sats, catnr)); + g_free (catnr); - /* last desperate sanity check */ - if (sat != NULL) { + /* last desperate sanity check */ + if (sat != NULL) { - now = satmap->tstamp;//get_current_daynum (); - number = satmap->naos - now; + now = satmap->tstamp;//get_current_daynum (); + number = satmap->naos - now; - /* convert julian date to seconds */ - s = (guint) (number * 86400); + /* convert julian date to seconds */ + s = (guint) (number * 86400); - /* extract hours */ - h = (guint) floor (s/3600); - s -= 3600*h; + /* extract hours */ + h = (guint) floor (s/3600); + s -= 3600*h; - /* leading zero */ - if ((h > 0) && (h < 10)) - ch = g_strdup ("0"); - else - ch = g_strdup (""); + /* leading zero */ + if ((h > 0) && (h < 10)) + ch = g_strdup ("0"); + else + ch = g_strdup (""); - /* extract minutes */ - m = (guint) floor (s/60); - s -= 60*m; + /* extract minutes */ + m = (guint) floor (s/60); + s -= 60*m; - /* leading zero */ - if (m < 10) - cm = g_strdup ("0"); - else - cm = g_strdup (""); + /* leading zero */ + if (m < 10) + cm = g_strdup ("0"); + else + cm = g_strdup (""); - /* leading zero */ - if (s < 10) - cs = g_strdup (":0"); - else - cs = g_strdup (":"); + /* leading zero */ + if (s < 10) + cs = g_strdup (":0"); + else + cs = g_strdup (":"); - if (h > 0) - buff = g_strdup_printf (_("<span background=\"#%s\"> "\ - "Next: %s in %s%d:%s%d%s%d </span>"), - satmap->infobgd, - sat->tle.sat_name, - ch, h, cm, m, cs, s); - else - buff = g_strdup_printf (_("<span background=\"#%s\"> " \ - "Next: %s in %s%d%s%d </span>"), - satmap->infobgd, - sat->tle.sat_name, - cm, m, cs, s); + if (h > 0) + buff = g_strdup_printf (_("<span background=\"#%s\"> "\ + "Next: %s in %s%d:%s%d%s%d </span>"), + satmap->infobgd, + sat->tle.sat_name, + ch, h, cm, m, cs, s); + else + buff = g_strdup_printf (_("<span background=\"#%s\"> " \ + "Next: %s in %s%d%s%d </span>"), + satmap->infobgd, + sat->tle.sat_name, + cm, m, cs, s); - g_object_set (satmap->next, - "text", buff, - NULL); + g_object_set (satmap->next, + "text", buff, + NULL); - g_free (buff); - g_free (ch); - g_free (cm); - g_free (cs); - } - else { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Can not find NEXT satellite."), - __FUNCTION__); - g_object_set (satmap->next, - "text", _("Next: ERR"), - NULL); - } - } - else { - g_object_set (satmap->next, - "text", _("Next: N/A"), - NULL); - } - } - else { - g_object_set (satmap->next, - "text", "", - NULL); - } - } + g_free (buff); + g_free (ch); + g_free (cm); + g_free (cs); + } + else { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Can not find NEXT satellite."), + __FUNCTION__); + g_object_set (satmap->next, + "text", _("Next: ERR"), + NULL); + } + } + else { + g_object_set (satmap->next, + "text", _("Next: N/A"), + NULL); + } + } + else { + g_object_set (satmap->next, + "text", "", + NULL); + } + } } @@ -724,13 +724,13 @@ static void lonlat_to_xy (GtkSatMap *p, gdouble lon, gdouble lat, gfloat *x, gfloat *y) { - *x = p->x0 + (180.0 - lon) * p->width / 360.0; - if (*x < 0.0) /* west longitude */ - *x *= -1; - else /* east longitude */ - *x = p->x0 + (180.0 + lon) * p->width / 360.0; + *x = p->x0 + (180.0 - lon) * p->width / 360.0; + if (*x < 0.0) /* west longitude */ + *x *= -1; + else /* east longitude */ + *x = p->x0 + (180.0 + lon) * p->width / 360.0; - *y = p->y0 + (90.0 - lat) * p->height / 180.0;; + *y = p->y0 + (90.0 - lat) * p->height / 180.0;; } @@ -748,8 +748,8 @@ static void xy_to_lonlat (GtkSatMap *p, gfloat x, gfloat y, gfloat *lon, gfloat *lat) { - *lat = 90.0 - (180.0 / p->height) * (y - p->y0); - *lon = (360.0 / p->width) * (x - p->x0) - 180.0; + *lat = 90.0 - (180.0 / p->height) * (y - p->y0); + *lon = (360.0 / p->width) * (x - p->x0) - 180.0; } @@ -760,32 +760,32 @@ */ static gboolean on_motion_notify (GooCanvasItem *item, - GooCanvasItem *target, - GdkEventMotion *event, - gpointer data) + GooCanvasItem *target, + GdkEventMotion *event, + gpointer data) { - GtkSatMap *satmap = GTK_SAT_MAP (data); - gfloat lat,lon; - gchar *text; + GtkSatMap *satmap = GTK_SAT_MAP (data); + gfloat lat,lon; + gchar *text; - /* set text only if QTH info is enabled */ - if (satmap->cursinfo) { + /* set text only if QTH info is enabled */ + if (satmap->cursinfo) { - xy_to_lonlat (satmap, event->x, event->y, &lon, &lat); + xy_to_lonlat (satmap, event->x, event->y, &lon, &lat); - /*** FIXME: - - Add QRA? - */ - /* cursor track */ - text = g_strdup_printf ("<span background=\"#%s\"> "\ - "LON:%.0f\302\260 LAT:%.0f\302\260 </span>", - satmap->infobgd, lon, lat); + /*** FIXME: + - Add QRA? + */ + /* cursor track */ + text = g_strdup_printf ("<span background=\"#%s\"> "\ + "LON:%.0f\302\260 LAT:%.0f\302\260 </span>", + satmap->infobgd, lon, lat); - g_object_set (satmap->curs, "text", text, NULL); - g_free (text); - } + g_object_set (satmap->curs, "text", text, NULL); + g_free (text); + } - return TRUE; + return TRUE; } @@ -805,22 +805,22 @@ */ static void on_item_created (GooCanvas *canvas, - GooCanvasItem *item, - GooCanvasItemModel *model, - gpointer data) + GooCanvasItem *item, + GooCanvasItemModel *model, + gpointer data) { - if (!goo_canvas_item_model_get_parent (model)) { - /* root item / canvas */ - g_signal_connect (item, "motion_notify_event", - (GtkSignalFunc) on_motion_notify, data); - } + if (!goo_canvas_item_model_get_parent (model)) { + /* root item / canvas */ + g_signal_connect (item, "motion_notify_event", + (GtkSignalFunc) on_motion_notify, data); + } - else if (!g_object_get_data (G_OBJECT (item), "skip-signal-connection")) { - g_signal_connect (item, "button_press_event", - (GtkSignalFunc) on_button_press, data); - g_signal_connect (item, "button_release_event", - (GtkSignalFunc) on_button_release, data); - } + else if (!g_object_get_data (G_OBJECT (item), "skip-signal-connection")) { + g_signal_connect (item, "button_press_event", + (GtkSignalFunc) on_button_press, data); + g_signal_connect (item, "button_release_event", + (GtkSignalFunc) on_button_release, data); + } } @@ -832,42 +832,42 @@ */ static gboolean on_button_press (GooCanvasItem *item, - GooCanvasItem *target, - GdkEventButton *event, - gpointer data) + GooCanvasItem *target, + GdkEventButton *event, + gpointer data) { - GooCanvasItemModel *model = goo_canvas_item_get_model (item); - GtkSatMap *satmap = GTK_SAT_MAP (data); - gint catnum = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (model), "catnum")); - gint *catpoint = NULL; - sat_t *sat = NULL; + GooCanvasItemModel *model = goo_canvas_item_get_model (item); + GtkSatMap *satmap = GTK_SAT_MAP (data); + gint catnum = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (model), "catnum")); + gint *catpoint = NULL; + sat_t *sat = NULL; - switch (event->button) { + switch (event->button) { - /* pop-up menu */ - case 3: - catpoint = g_try_new0 (gint, 1); - *catpoint = catnum; + /* pop-up menu */ + case 3: + catpoint = g_try_new0 (gint, 1); + *catpoint = catnum; - sat = SAT (g_hash_table_lookup (satmap->sats, catpoint)); + sat = SAT (g_hash_table_lookup (satmap->sats, catpoint)); - if (sat != NULL) { - gtk_sat_map_popup_exec (sat, satmap->qth, satmap, event, - gtk_widget_get_toplevel (GTK_WIDGET (satmap))); - } - else { - /* clicked on map -> map pop-up in the future */ - } + if (sat != NULL) { + gtk_sat_map_popup_exec (sat, satmap->qth, satmap, event, + gtk_widget_get_toplevel (GTK_WIDGET (satmap))); + } + else { + /* clicked on map -> map pop-up in the future */ + } - g_free (catpoint); + g_free (catpoint); - break; + break; - default: - break; - } + default: + break; + } - return TRUE; + return TRUE; } @@ -880,76 +880,76 @@ */ static gboolean on_button_release (GooCanvasItem *item, - GooCanvasItem *target, - GdkEventButton *event, - gpointer data) + GooCanvasItem *target, + GdkEventButton *event, + gpointer data) { - GooCanvasItemModel *model = goo_canvas_item_get_model (item); - GtkSatMap *satmap = GTK_SAT_MAP (data); - gint catnum = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (model), "catnum")); - gint *catpoint = NULL; - sat_map_obj_t *obj = NULL; - guint32 col; + GooCanvasItemModel *model = goo_canvas_item_get_model (item); + GtkSatMap *satmap = GTK_SAT_MAP (data); + gint catnum = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (model), "catnum")); + gint *catpoint = NULL; + sat_map_obj_t *obj = NULL; + guint32 col; - catpoint = g_try_new0 (gint, 1); - *catpoint = catnum; + catpoint = g_try_new0 (gint, 1); + *catpoint = catnum; - switch (event->button) { - /* Select / de-select satellite */ - case 1: - obj = SAT_MAP_OBJ (g_hash_table_lookup (satmap->obj, catpoint)); - if (obj == NULL) { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s:%d: Can not find clicked object (%d) in hash table"), - __FILE__, __LINE__, catnum); - } - else { - obj->selected = !obj->selected; + switch (event->button) { + /* Select / de-select satellite */ + case 1: + obj = SAT_MAP_OBJ (g_hash_table_lookup (satmap->obj, catpoint)); + if (obj == NULL) { + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s:%d: Can not find clicked object (%d) in hash table"), + __FILE__, __LINE__, catnum); + } + else { + obj->selected = !obj->selected; - if (obj->selected) { - col = mod_cfg_get_int (satmap->cfgdata, - MOD_CFG_MAP_SECTION, - MOD_CFG_MAP_SAT_SEL_COL, - SAT_CFG_INT_MAP_SAT_SEL_COL); - } - else { - col = mod_cfg_get_int (satmap->cfgdata, - MOD_CFG_MAP_SECTION, - MOD_CFG_MAP_SAT_COL, - SAT_CFG_INT_MAP_SAT_COL); - *catpoint = 0; + if (obj->selected) { + col = mod_cfg_get_int (satmap->cfgdata, + MOD_CFG_MAP_SECTION, + MOD_CFG_MAP_SAT_SEL_COL, + SAT_CFG_INT_MAP_SAT_SEL_COL); + } + else { + col = mod_cfg_get_int (satmap->cfgdata, + MOD_CFG_MAP_SECTION, + MOD_CFG_MAP_SAT_COL, + SAT_CFG_INT_MAP_SAT_COL); + *catpoint = 0; - g_object_set (satmap->sel, "text", "", NULL); - } + g_object_set (satmap->sel, "text", "", NULL); + } - g_object_set (obj->marker, - "fill-color-rgba", col, - "stroke-color-rgba", col, - NULL); - g_object_set (obj->label, - "fill-color-rgba", col, - "stroke-color-rgba", col, - NULL); - g_object_set (obj->range1, - "stroke-color-rgba", col, - NULL); + g_object_set (obj->marker, + "fill-color-rgba", col, + "stroke-color-rgba", col, + NULL); + g_object_set (obj->label, + "fill-color-rgba", col, + "stroke-color-rgba", col, + NULL); + g_object_set (obj->range1, + "stroke-color-rgba", col, + NULL); - if (obj->oldrcnum == 2) - g_object_set (obj->range2, - "stroke-color-rgba", col, - NULL); + if (obj->oldrcnum == 2) + g_object_set (obj->range2, + "stroke-color-rgba", col, + NULL); - /* clear other selections */ - g_hash_table_foreach (satmap->obj, clear_selection, catpoint); - } - break; - default: - break; - } + /* clear other selections */ + g_hash_table_foreach (satmap->obj, clear_selection, catpoint); + } + break; + default: + break; + } - g_free (catpoint); - - return TRUE; + g_free (catpoint); + + return TRUE; } @@ -961,34 +961,34 @@ static void clear_selection (gpointer key, gpointer val, gpointer data) { - gint *old = key; - gint *new = data; - sat_map_obj_t *obj = SAT_MAP_OBJ (val); - guint32 col; + gint *old = key; + gint *new = data; + sat_map_obj_t *obj = SAT_MAP_OBJ (val); + guint32 col; - if ((*old != *new) && (obj->selected)) { - obj->selected = FALSE; + if ((*old != *new) && (obj->selected)) { + obj->selected = FALSE; - /** FIXME: this is only global default; need the satmap here! */ - col = sat_cfg_get_int (SAT_CFG_INT_MAP_SAT_COL); + /** FIXME: this is only global default; need the satmap here! */ + col = sat_cfg_get_int (SAT_CFG_INT_MAP_SAT_COL); - g_object_set (obj->marker, - "fill-color-rgba", col, - "stroke-color-rgba", col, - NULL); - g_object_set (obj->label, - "fill-color-rgba", col, - "stroke-color-rgba", col, - NULL); - g_object_set (obj->range1, - "stroke-color-rgba", col, - NULL); + g_object_set (obj->marker, + "fill-color-rgba", col, + "stroke-color-rgba", col, + NULL); + g_object_set (obj->label, + "fill-color-rgba", col, + "stroke-color-rgba", col, + NULL); + g_object_set (obj->range1, + "stroke-color-rgba", col, + NULL); - if (obj->oldrcnum == 2) - g_object_set (obj->range2, - "stroke-color-rgba", col, - NULL); - } + if (obj->oldrcnum == 2) + g_object_set (obj->range2, + "stroke-color-rgba", col, + NULL); + } } @@ -1024,67 +1024,67 @@ static void load_map_file (GtkSatMap *satmap) { - gchar *buff; - gchar *mapfile; - GError *error = NULL; + gchar *buff; + gchar *mapfile; + GError *error = NULL; - /* get local, global or default map file */ - buff = mod_cfg_get_str (satmap->cfgdata, - MOD_CFG_MAP_SECTION, - MOD_CFG_MAP_FILE, - SAT_CFG_STR_MAP_FILE); + /* get local, global or default map file */ + buff = mod_cfg_get_str (satmap->cfgdata, + MOD_CFG_MAP_SECTION, + MOD_CFG_MAP_FILE, + SAT_CFG_STR_MAP_FILE); - if (g_path_is_absolute (buff)) { - /* map is user specific, ie. in $HOME/.gpredict2/maps/ */ - mapfile = g_strdup (buff); - } - else { - /* build complete path */ - mapfile = map_file_name (buff); - } - g_free (buff); + if (g_path_is_absolute (buff)) { + /* map is user specific, ie. in $HOME/.gpredict2/maps/ */ + mapfile = g_strdup (buff); + } + else { + /* build complete path */ + mapfile = map_file_name (buff); + } + g_free (buff); - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s:%d: Loading map file %s"), - __FILE__, __LINE__, mapfile); + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s:%d: Loading map file %s"), + __FILE__, __LINE__, mapfile); - /* check that file exists, if not get the default */ - if (g_file_test (mapfile, G_FILE_TEST_EXISTS)) { - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s:%d: Map file found"), - __FILE__, __LINE__); - } - else { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%d: Could not find map file %s"), - __FILE__, __LINE__, mapfile); + /* check that file exists, if not get the default */ + if (g_file_test (mapfile, G_FILE_TEST_EXISTS)) { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s:%d: Map file found"), + __FILE__, __LINE__); + } + else { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%d: Could not find map file %s"), + __FILE__, __LINE__, mapfile); - /* get default map file */ - g_free (mapfile); - mapfile = sat_cfg_get_str_def (SAT_CFG_STR_MAP_FILE); + /* get default map file */ + g_free (mapfile); + mapfile = sat_cfg_get_str_def (SAT_CFG_STR_MAP_FILE); - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%d: Using default map: %s"), - __FILE__, __LINE__, mapfile); - } + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%d: Using default map: %s"), + __FILE__, __LINE__, mapfile); + } - /* try to load the map file */ - satmap->origmap = gdk_pixbuf_new_from_file (mapfile, &error); + /* try to load the map file */ + satmap->origmap = gdk_pixbuf_new_from_file (mapfile, &error); - if (error != NULL) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%d: Error loading map file (%s)"), - __FILE__, __LINE__, error->message); - g_clear_error (&error); + if (error != NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%d: Error loading map file (%s)"), + __FILE__, __LINE__, error->message); + g_clear_error (&error); - /* create a dummy GdkPixbuf to avoid crash */ - satmap->origmap = gdk_pixbuf_new (GDK_COLORSPACE_RGB, - FALSE, - 8, 400, 200); - gdk_pixbuf_fill (satmap->origmap, 0x0F0F0F0F); - } - - g_free (mapfile); + /* create a dummy GdkPixbuf to avoid crash */ + satmap->origmap = gdk_pixbuf_new (GDK_COLORSPACE_RGB, + FALSE, + 8, 400, 200); + gdk_pixbuf_fill (satmap->origmap, 0x0F0F0F0F); + } + + g_free (mapfile); } @@ -1097,14 +1097,14 @@ static gdouble arccos (gdouble x, gdouble y) { - if (x && y) { - if (y > 0.0) - return acos (x/y); - else if (y < 0.0) - return pi + acos (x/y); - } + if (x && y) { + if (y > 0.0) + return acos (x/y); + else if (y < 0.0) + return pi + acos (x/y); + } - return 0.0; + return 0.0; } @@ -1112,16 +1112,16 @@ static gboolean pole_is_covered (sat_t *sat) { - int ret1,ret2; - gdouble qrb1, qrb2, az1, az2; + int ret1,ret2; + gdouble qrb1, qrb2, az1, az2; - ret1 = qrb (sat->ssplon, sat->ssplat, 0.0, 90.0, &qrb1, &az1); - ret2 = qrb (sat->ssplon, sat->ssplat, 0.0, -90.0, &qrb2, &az2); + ret1 = qrb (sat->ssplon, sat->ssplat, 0.0, 90.0, &qrb1, &az1); + ret2 = qrb (sat->ssplon, sat->ssplat, 0.0, -90.0, &qrb2, &az2); - if ((qrb1 <= 0.5*sat->footprint) || (qrb2 <= 0.5*sat->footprint)) - return TRUE; - - return FALSE; + if ((qrb1 <= 0.5*sat->footprint) || (qrb2 <= 0.5*sat->footprint)) + return TRUE; + + return FALSE; } @@ -1129,33 +1129,33 @@ static gboolean mirror_lon (sat_t *sat, gdouble rangelon, gdouble *mlon) { - gdouble diff; - gboolean warped = FALSE; + gdouble diff; + gboolean warped = FALSE; - if (sat->ssplon < 0.0) { - /* western longitude */ - if (rangelon < 0.0) { - /* rangelon has not been warped over */ - *mlon = sat->ssplon + fabs (rangelon - sat->ssplon); - } - else { - /* rangelon has been warped over */ - diff = 360.0 + sat->ssplon - rangelon; - *mlon = sat->ssplon + diff; - warped = TRUE; - } - } - else { - /* eastern longitude */ - *mlon = sat->ssplon + fabs (rangelon - sat->ssplon); - - if (*mlon > 180.0) { - *mlon -= 360; - warped = TRUE; - } - } + if (sat->ssplon < 0.0) { + /* western longitude */ + if (rangelon < 0.0) { + /* rangelon has not been warped over */ + *mlon = sat->ssplon + fabs (rangelon - sat->ssplon); + } + else { + /* rangelon has been warped over */ + diff = 360.0 + sat->ssplon - rangelon; + *mlon = sat->ssplon + diff; + warped = TRUE; + } + } + else { + /* eastern longitude */ + *mlon = sat->ssplon + fabs (rangelon - sat->ssplon); + + if (*mlon > 180.0) { + *mlon -= 360; + warped = TRUE; + } + } - return warped; + return warped; } @@ -1194,99 +1194,99 @@ static guint calculate_footprint (GtkSatMap *satmap, sat_t *sat) { - guint azi; - gfloat sx, sy, msx, msy, ssx, ssy; - gdouble ssplat, ssplon, beta, azimuth, num, dem; - gdouble rangelon, rangelat, mlon; - gboolean warped = FALSE; - guint numrc = 1; + guint azi; + gfloat sx, sy, msx, msy, ssx, ssy; + gdouble ssplat, ssplon, beta, azimuth, num, dem; + gdouble rangelon, rangelat, mlon; + gboolean warped = FALSE; + guint numrc = 1; - /* Range circle calculations. - * Borrowed from gsat 0.9.0 by Xavier Crehueras, EB3CZS - * who borrowed from John Magliacane, KD2BD. - * Optimized by Alexandru Csete and William J Beksi. - */ - ssplat = sat->ssplat * de2ra; - ssplon = sat->ssplon * de2ra; - beta = (0.5 * sat->footprint) / xkmper; + /* Range circle calculations. + * Borrowed from gsat 0.9.0 by Xavier Crehueras, EB3CZS + * who borrowed from John Magliacane, KD2BD. + * Optimized by Alexandru Csete and William J Beksi. + */ + ssplat = sat->ssplat * de2ra; + ssplon = sat->ssplon * de2ra; + beta = (0.5 * sat->footprint) / xkmper; - for (azi = 0; azi < 180; azi++) { - azimuth = de2ra * (double)azi; - rangelat = asin (sin (ssplat) * cos (beta) + cos (azimuth) * - sin (beta) * cos (ssplat)); - num = cos (beta) - (sin (ssplat) * sin (rangelat)); - dem = cos (ssplat) * cos (rangelat); - - if (azi == 0 && (beta > pio2 - ssplat)) - rangelon = ssplon + pi; - - else if (azi == 180 && (beta > pio2 + ssplat)) - rangelon = ssplon + pi; - - else if (fabs (num / dem) > 1.0) - rangelon = ssplon; - - else { - if ((180 - azi) >= 0) - rangelon = ssplon - arccos (num, dem); - else - rangelon = ssplon + arccos (num, dem); - } - - while (rangelon < -pi) - rangelon += twopi; - - while (rangelon > (pi)) - rangelon -= twopi; - - rangelat = rangelat / de2ra; - rangelon = rangelon / de2ra; + for (azi = 0; azi < 180; azi++) { + azimuth = de2ra * (double)azi; + rangelat = asin (sin (ssplat) * cos (beta) + cos (azimuth) * + sin (beta) * cos (ssplat)); + num = cos (beta) - (sin (ssplat) * sin (rangelat)); + dem = cos (ssplat) * cos (rangelat); + + if (azi == 0 && (beta > pio2 - ssplat)) + rangelon = ssplon + pi; + + else if (azi == 180 && (beta > pio2 + ssplat)) + rangelon = ssplon + pi; + + else if (fabs (num / dem) > 1.0) + rangelon = ssplon; + + else { + if ((180 - azi) >= 0) + rangelon = ssplon - arccos (num, dem); + else + rangelon = ssplon + arccos (num, dem); + } + + while (rangelon < -pi) + rangelon += twopi; + + while (rangelon > (pi)) + rangelon -= twopi; + + rangelat = rangelat / de2ra; + rangelon = rangelon / de2ra; - /* mirror longitude */ - if (mirror_lon (sat, rangelon, &mlon)) - warped = TRUE; + /* mirror longitude */ + if (mirror_lon (sat, rangelon, &mlon)) + warped = TRUE; - lonlat_to_xy (satmap, rangelon, rangelat, &sx, &sy); - lonlat_to_xy (satmap, mlon, rangelat, &msx, &msy); + lonlat_to_xy (satmap, rangelon, rangelat, &sx, &sy); + lonlat_to_xy (satmap, mlon, rangelat, &msx, &msy); - points1->coords[2*azi] = sx; - points1->coords[2*azi+1] = sy; - - /* Add mirrored point */ - points1->coords[718-2*azi] = msx; - points1->coords[719-2*azi] = msy; - } + points1->coords[2*azi] = sx; + points1->coords[2*azi+1] = sy; + + /* Add mirrored point */ + points1->coords[718-2*azi] = msx; + points1->coords[719-2*azi] = msy; + } - /* points1 ow contains 360 pairs of map-based XY coordinates. - Check whether actions 1, 2 or 3 have to be performed. - */ + /* points1 ow contains 360 pairs of map-based XY coordinates. + Check whether actions 1, 2 or 3 have to be performed. + */ - /* pole is covered => sort points1 and add additional points */ - if (pole_is_covered (sat)) { + /* pole is covered => sort points1 and add additional points */ + if (pole_is_covered (sat)) { - sort_points_x (satmap, sat, points1, 360); - numrc = 1; + sort_points_x (satmap, sat, points1, 360); + numrc = 1; - } + } - /* pole not covered but range circle has been warped - => split points */ - else if (warped == TRUE) { + /* pole not covered but range circle has been warped + => split points */ + else if (warped == TRUE) { - lonlat_to_xy (satmap, sat->ssplon, sat->ssplat, &ssx, &ssy); - split_points (satmap, sat, ssx); - numrc = 2; + lonlat_to_xy (satmap, sat->ssplon, sat->ssplat, &ssx, &ssy); + split_points (satmap, sat, ssx); + numrc = 2; - } + } - /* the nominal condition => points1 is adequate */ - else { + /* the nominal condition => points1 is adequate */ + else { - numrc = 1; + ... [truncated message content] |
From: <cs...@us...> - 2009-05-09 23:53:33
|
Revision: 288 http://gpredict.svn.sourceforge.net/gpredict/?rev=288&view=rev Author: csete Date: 2009-05-09 23:53:19 +0000 (Sat, 09 May 2009) Log Message: ----------- Added parameter to store uplink and downlink VFOs for full-duplex capable radios. Modified Paths: -------------- trunk/src/radio-conf.c trunk/src/radio-conf.h Modified: trunk/src/radio-conf.c =================================================================== --- trunk/src/radio-conf.c 2009-05-09 14:57:34 UTC (rev 287) +++ trunk/src/radio-conf.c 2009-05-09 23:53:19 UTC (rev 288) @@ -41,6 +41,8 @@ #define KEY_LOUP "LO_UP" #define KEY_TYPE "Type" #define KEY_PTT "PTT" +#define KEY_VFO_DOWN "VFO_DOWN" +#define KEY_VFO_UP "VFO_UP" /** \brief Read radio configuration. @@ -142,6 +144,7 @@ conf->loup = 0.0; } + /* Radio type */ conf->type = g_key_file_get_integer (cfg, GROUP, KEY_TYPE, &error); if (error != NULL) { sat_log_log (SAT_LOG_LEVEL_ERROR, @@ -152,6 +155,7 @@ return FALSE; } + /* PTT Type */ conf->ptt = g_key_file_get_integer (cfg, GROUP, KEY_PTT, &error); if (error != NULL) { sat_log_log (SAT_LOG_LEVEL_ERROR, @@ -161,6 +165,35 @@ g_key_file_free (cfg); return FALSE; } + + /* VFO up and down, only if radio is full-duplex */ + if (conf->type == RIG_TYPE_DUPLEX) { + + /* downlink */ + if (g_key_file_has_key (cfg, GROUP, KEY_VFO_DOWN, NULL)) { + conf->vfoDown = g_key_file_get_integer (cfg, GROUP, KEY_VFO_DOWN, &error); + if (error != NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Error reading radio conf from %s (%s)."), + __FUNCTION__, conf->name, error->message); + g_clear_error (&error); + conf->vfoDown = VFO_SUB; + } + } + + /* uplink */ + if (g_key_file_has_key (cfg, GROUP, KEY_VFO_UP, NULL)) { + conf->vfoUp = g_key_file_get_integer (cfg, GROUP, KEY_VFO_UP, &error); + if (error != NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Error reading radio conf from %s (%s)."), + __FUNCTION__, conf->name, error->message); + g_clear_error (&error); + conf->vfoUp = VFO_MAIN; + } + } + + } g_key_file_free (cfg); @@ -204,6 +237,11 @@ g_key_file_set_integer (cfg, GROUP, KEY_TYPE, conf->type); g_key_file_set_integer (cfg, GROUP, KEY_PTT, conf->ptt); + if (conf->type == RIG_TYPE_DUPLEX) { + g_key_file_set_integer (cfg, GROUP, KEY_VFO_UP, conf->vfoUp); + g_key_file_set_integer (cfg, GROUP, KEY_VFO_DOWN, conf->vfoDown); + } + /* convert to text sdata */ data = g_key_file_to_data (cfg, &len, NULL); Modified: trunk/src/radio-conf.h =================================================================== --- trunk/src/radio-conf.h 2009-05-09 14:57:34 UTC (rev 287) +++ trunk/src/radio-conf.h 2009-05-09 23:53:19 UTC (rev 288) @@ -47,6 +47,13 @@ PTT_TYPE_DCD /*!< Read PTT using get_dcd */ } ptt_type_t; +typedef enum { + VFO_A = 0, + VFO_B, + VFO_MAIN, + VFO_SUB +} vfo_t; + /** \brief Radio configuration. */ typedef struct { gchar *name; /*!< Configuration file name, without .rig. */ @@ -57,6 +64,8 @@ gdouble loup; /*!< local oscillator freq in Hz for uplink. */ rig_type_t type; /*!< Radio type */ ptt_type_t ptt; /*!< PTT type (needed for RX, TX, and TRX) */ + vfo_t vfoDown; /*!< Downlink VFO for full-duplex radios */ + vfo_t vfoUp; /*!< Uplink VFO for full-duplex radios */ } radio_conf_t; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-05-10 11:17:24
|
Revision: 292 http://gpredict.svn.sourceforge.net/gpredict/?rev=292&view=rev Author: csete Date: 2009-05-10 11:17:17 +0000 (Sun, 10 May 2009) Log Message: ----------- Added VFO UP/DOWN columns. Modified Paths: -------------- trunk/src/sat-pref-rig-data.h trunk/src/sat-pref-rig.c Modified: trunk/src/sat-pref-rig-data.h =================================================================== --- trunk/src/sat-pref-rig-data.h 2009-05-10 11:10:48 UTC (rev 291) +++ trunk/src/sat-pref-rig-data.h 2009-05-10 11:17:17 UTC (rev 292) @@ -35,6 +35,8 @@ RIG_LIST_COL_PORT, /*!< Port number */ RIG_LIST_COL_TYPE, /*!< Radio type */ RIG_LIST_COL_PTT, /*!< PTT */ + RIG_LIST_COL_VFOUP, /*!< VFO Up */ + RIG_LIST_COL_VFODOWN, /*!< VFO down */ RIG_LIST_COL_LO, /*!< Local oscillator freq (downlink) */ RIG_LIST_COL_LOUP, /*!< Local oscillato freq (uplink) */ RIG_LIST_COL_NUM /*!< The number of fields in the list. */ Modified: trunk/src/sat-pref-rig.c =================================================================== --- trunk/src/sat-pref-rig.c 2009-05-10 11:10:48 UTC (rev 291) +++ trunk/src/sat-pref-rig.c 2009-05-10 11:17:17 UTC (rev 292) @@ -73,6 +73,11 @@ GtkTreeModel *model, GtkTreeIter *iter, gpointer column); +static void render_vfo (GtkTreeViewColumn *col, + GtkCellRenderer *renderer, + GtkTreeModel *model, + GtkTreeIter *iter, + gpointer column); /* global objects */ @@ -168,6 +173,28 @@ NULL); gtk_tree_view_insert_column (GTK_TREE_VIEW (riglist), column, -1); + /* VFO Up */ + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes (_("VFO Up"), renderer, + "text", RIG_LIST_COL_VFOUP, + NULL); + gtk_tree_view_column_set_cell_data_func (column, renderer, + render_vfo, + GUINT_TO_POINTER(RIG_LIST_COL_VFOUP), + NULL); + gtk_tree_view_insert_column (GTK_TREE_VIEW (riglist), column, -1); + + /* VFO Down */ + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes (_("VFO Down"), renderer, + "text", RIG_LIST_COL_VFODOWN, + NULL); + gtk_tree_view_column_set_cell_data_func (column, renderer, + render_vfo, + GUINT_TO_POINTER(RIG_LIST_COL_VFODOWN), + NULL); + gtk_tree_view_insert_column (GTK_TREE_VIEW (riglist), column, -1); + /* transverter down */ renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes (_("Downconverter LO"), renderer, @@ -213,6 +240,8 @@ G_TYPE_INT, // port G_TYPE_INT, // type G_TYPE_INT, // PTT + G_TYPE_INT, // VFO Up + G_TYPE_INT, // VFO Down G_TYPE_DOUBLE, // LO DOWN G_TYPE_DOUBLE // LO UO ); @@ -242,6 +271,8 @@ RIG_LIST_COL_PORT, conf.port, RIG_LIST_COL_TYPE, conf.type, RIG_LIST_COL_PTT, conf.ptt, + RIG_LIST_COL_VFOUP, conf.vfoUp, + RIG_LIST_COL_VFODOWN, conf.vfoDown, RIG_LIST_COL_LO, conf.lo, RIG_LIST_COL_LOUP, conf.loup, -1); @@ -354,6 +385,8 @@ .port = 4532, .type = RIG_TYPE_RX, .ptt = 0, + .vfoUp = 0, + .vfoDown = 0, .lo = 0.0, .loup = 0.0, }; @@ -397,6 +430,8 @@ RIG_LIST_COL_PORT, &conf.port, RIG_LIST_COL_TYPE, &conf.type, RIG_LIST_COL_PTT, &conf.ptt, + RIG_LIST_COL_VFOUP, &conf.vfoUp, + RIG_LIST_COL_VFODOWN, &conf.vfoDown, RIG_LIST_COL_LO, &conf.lo, RIG_LIST_COL_LOUP, &conf.loup, -1); @@ -438,6 +473,8 @@ .port = 4532, .type = RIG_TYPE_RX, .ptt = 0, + .vfoUp = 0, + .vfoDown = 0, .lo = 0.0, .loup = 0.0, }; @@ -455,6 +492,8 @@ RIG_LIST_COL_PORT, conf.port, RIG_LIST_COL_TYPE, conf.type, RIG_LIST_COL_PTT, conf.ptt, + RIG_LIST_COL_VFOUP, conf.vfoUp, + RIG_LIST_COL_VFODOWN, conf.vfoDown, RIG_LIST_COL_LO, conf.lo, RIG_LIST_COL_LOUP, conf.loup, -1); @@ -488,6 +527,8 @@ .port = 4532, .type = RIG_TYPE_RX, .ptt = 0, + .vfoUp = 0, + .vfoDown = 0, .lo = 0.0, .loup = 0.0, }; @@ -516,6 +557,8 @@ RIG_LIST_COL_PORT, &conf.port, RIG_LIST_COL_TYPE, &conf.type, RIG_LIST_COL_PTT, &conf.ptt, + RIG_LIST_COL_VFOUP, &conf.vfoUp, + RIG_LIST_COL_VFODOWN, &conf.vfoDown, RIG_LIST_COL_LO, &conf.lo, RIG_LIST_COL_LOUP, &conf.loup, -1); @@ -547,6 +590,8 @@ RIG_LIST_COL_PORT, conf.port, RIG_LIST_COL_TYPE, conf.type, RIG_LIST_COL_PTT, conf.ptt, + RIG_LIST_COL_VFOUP, conf.vfoUp, + RIG_LIST_COL_VFODOWN, conf.vfoDown, RIG_LIST_COL_LO, conf.lo, RIG_LIST_COL_LOUP, conf.loup, -1); @@ -751,7 +796,55 @@ g_free (buff); } +/** \brief Render VFO selection. + * \param col Pointer to the tree view column. + * \param renderer Pointer to the renderer. + * \param model Pointer to the tree model. + * \param iter Pointer to the tree iterator. + * \param column The column number in the model. + * + * This function is used to render the VFO up/down selections for + * full duplex radios. + */ +static void render_vfo (GtkTreeViewColumn *col, + GtkCellRenderer *renderer, + GtkTreeModel *model, + GtkTreeIter *iter, + gpointer column) +{ + gint number; + gchar *buff; + guint coli = GPOINTER_TO_UINT (column); + + gtk_tree_model_get (model, iter, coli, &number, -1); + switch (number) { + + case VFO_A: + buff = g_strdup_printf ("VFO A"); + break; + + case VFO_B: + buff = g_strdup_printf ("VFO B"); + break; + + case VFO_MAIN: + buff = g_strdup_printf ("Main"); + break; + + case VFO_SUB: + buff = g_strdup_printf ("Sub"); + break; + + default: + buff = g_strdup_printf ("-"); + break; + } + g_object_set (renderer, "text", buff, NULL); + g_free (buff); +} + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fi...@us...> - 2009-05-19 21:03:46
|
Revision: 317 http://gpredict.svn.sourceforge.net/gpredict/?rev=317&view=rev Author: fillods Date: 2009-05-19 21:03:38 +0000 (Tue, 19 May 2009) Log Message: ----------- i18n Modified Paths: -------------- trunk/src/sat-info.c trunk/src/tle-update.c Modified: trunk/src/sat-info.c =================================================================== --- trunk/src/sat-info.c 2009-05-15 09:40:22 UTC (rev 316) +++ trunk/src/sat-info.c 2009-05-19 21:03:38 UTC (rev 317) @@ -424,7 +424,7 @@ trsplist = read_transponders (catnum); if (trsplist == NULL) { - vbox = gtk_label_new ("No transponders"); + vbox = gtk_label_new (_("No transponders")); } else { vbox = gtk_vbox_new (FALSE, 0); Modified: trunk/src/tle-update.c =================================================================== --- trunk/src/tle-update.c 2009-05-15 09:40:22 UTC (rev 316) +++ trunk/src/tle-update.c 2009-05-19 21:03:38 UTC (rev 317) @@ -1011,5 +1011,5 @@ } - return freq_to_str[freq]; + return _(freq_to_str[freq]); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-05-21 19:08:39
|
Revision: 322 http://gpredict.svn.sourceforge.net/gpredict/?rev=322&view=rev Author: csete Date: 2009-05-21 19:08:24 +0000 (Thu, 21 May 2009) Log Message: ----------- Added function to copy satellite data from one sat_t structure to another. Modified Paths: -------------- trunk/src/gtk-sat-data.c trunk/src/gtk-sat-data.h Modified: trunk/src/gtk-sat-data.c =================================================================== --- trunk/src/gtk-sat-data.c 2009-05-20 20:51:15 UTC (rev 321) +++ trunk/src/gtk-sat-data.c 2009-05-21 19:08:24 UTC (rev 322) @@ -612,3 +612,48 @@ /* orbit type */ sat->otype = get_orbit_type (sat); } + +/** \brief Copy satellite data. + * \param source Pointer to the source satellite to copy data from. + * \param dest Pointer to the destination satellite to copy data into. + * \param qth Pointer to the observer data (needed to initialize sat) + * + * This function copies the satellite data from a source sat_t structure into + * the destination. The function copies the tle_t data and calls gtk_sat_data_inti_sat() + * function for initializing the other fields. + * + */ +void gtk_sat_data_copy_sat (sat_t *source, sat_t *dest, qth_t *qth) +{ + guint i; + + g_return_if_fail ((source != NULL) && (dest != NULL)); + + dest->tle.epoch = source->tle.epoch; + dest->tle.epoch_year = source->tle.epoch_year; + dest->tle.epoch_day = source->tle.epoch_day; + dest->tle.epoch_fod = source->tle.epoch_fod; + dest->tle.xndt2o = source->tle.xndt2o; + dest->tle.xndd6o = source->tle.xndd6o; + dest->tle.bstar = source->tle.bstar; + dest->tle.xincl = source->tle.xincl; + dest->tle.xnodeo = source->tle.xnodeo; + dest->tle.eo = source->tle.eo; + dest->tle.omegao = source->tle.omegao; + dest->tle.xmo = source->tle.xmo; + dest->tle.xno = source->tle.xno; + dest->tle.catnr = source->tle.catnr; + dest->tle.elset = source->tle.elset; + dest->tle.revnum = source->tle.revnum; + + for (i = 0; i < 25; i++) + dest->tle.sat_name[i] = source->tle.sat_name[i]; + for (i = 0; i < 9; i++) + dest->tle.idesg[i] = source->tle.idesg[i]; + + dest->tle.status = source->tle.status; + dest->tle.xincl1 = source->tle.xincl1; + dest->tle.omegao1 = source->tle.omegao1; + + gtk_sat_data_init_sat (dest, qth); +} Modified: trunk/src/gtk-sat-data.h =================================================================== --- trunk/src/gtk-sat-data.h 2009-05-20 20:51:15 UTC (rev 321) +++ trunk/src/gtk-sat-data.h 2009-05-21 19:08:24 UTC (rev 322) @@ -53,5 +53,6 @@ void gtk_sat_data_free_qth (qth_t *qth); gint gtk_sat_data_read_sat (gint catnum, sat_t *sat); void gtk_sat_data_init_sat (sat_t *sat, qth_t *qth); +void gtk_sat_data_copy_sat (sat_t *source, sat_t *dest, qth_t *qth); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-03 18:39:24
|
Revision: 340 http://gpredict.svn.sourceforge.net/gpredict/?rev=340&view=rev Author: csete Date: 2009-08-03 18:39:16 +0000 (Mon, 03 Aug 2009) Log Message: ----------- Separate QTH data I/O from SAt data I/O. Modified Paths: -------------- trunk/src/Makefile.am Added Paths: ----------- trunk/src/qth-data.c trunk/src/qth-data.h Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-08-02 11:18:06 UTC (rev 339) +++ trunk/src/Makefile.am 2009-08-03 18:39:16 UTC (rev 340) @@ -68,6 +68,7 @@ pass-popup-menu.c pass-popup-menu.h \ pass-to-txt.c pass-to-txt.h \ predict-tools.c predict-tools.h \ + qth-data.c qth-data.h \ qth-editor.c qth-editor.h \ radio-conf.c radio-conf.h \ rotor-conf.c rotor-conf.h \ Added: trunk/src/qth-data.c =================================================================== --- trunk/src/qth-data.c (rev 0) +++ trunk/src/qth-data.c 2009-08-03 18:39:16 UTC (rev 340) @@ -0,0 +1,401 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + Gpredict: Real-time satellite tracking and orbit prediction program + + Copyright (C) 2001-2008 Alexandru Csete, OZ9AEC. + + Authors: Alexandru Csete <oz...@gm...> + + Comments, questions and bugreports should be submitted via + http://sourceforge.net/projects/gpredict/ + More details can be found at the project home page: + + http://gpredict.oz9aec.net/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, visit http://www.fsf.org/ +*/ + +#include <glib.h> +#include <glib/gi18n.h> +#include "sgpsdp/sgp4sdp4.h" +#include "qth-data.h" +#include "sat-log.h" +#include "config-keys.h" +#include "tle-lookup.h" +#ifdef HAVE_CONFIG_H +# include <build-config.h> +#endif +#include "orbit-tools.h" +#include "time-tools.h" + + +/** \brief Read QTH data from file. + * \param filename The file to read from. + * \param qth Pointer to a qth_t data structure where the data will be stored. + * \return FALSE if an error occurred, TRUE otherwise. + * + * \note The function uses the new key=value file parser from glib. + */ +gint +qth_data_read (const gchar *filename, qth_t *qth) +{ + GError *error = NULL; + gchar *buff; + gchar **buffv; + + qth->data = g_key_file_new (); + g_key_file_set_list_separator (qth->data, ';'); + + /* bail out with error message if data can not be read */ + if (!g_key_file_load_from_file (qth->data, filename, + G_KEY_FILE_KEEP_COMMENTS, &error)) { + + g_key_file_free (qth->data); + + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Could not load data from %s (%s)"), + __FUNCTION__, filename, error->message); + + return FALSE; + } + + /* send a debug message, then read data */ + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: QTH data: %s"), + __FUNCTION__, filename); + + /*** FIXME: should check that strings are UTF-8? */ + /* QTH Name */ + buff = g_path_get_basename (filename); + buffv = g_strsplit (buff, ".qth", 0); + qth->name = g_strdup (buffv[0]); + + g_free (buff); + g_strfreev (buffv); + /* g_key_file_get_string (qth->data, */ + /* QTH_CFG_MAIN_SECTION, */ + /* QTH_CFG_NAME_KEY, */ + /* &error); */ + if (error != NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Error reading QTH name (%s)."), + __FUNCTION__, error->message); + + qth->name = g_strdup (_("ERROR")); + g_clear_error (&error); + } + + /* QTH location */ + qth->loc = g_key_file_get_string (qth->data, + QTH_CFG_MAIN_SECTION, + QTH_CFG_LOC_KEY, + &error); + if (error != NULL) { + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: QTH has no location (%s)."), + __FUNCTION__, error->message); + + qth->loc = g_strdup (""); + g_clear_error (&error); + } + + /* QTH description */ + qth->desc = g_key_file_get_string (qth->data, + QTH_CFG_MAIN_SECTION, + QTH_CFG_DESC_KEY, + &error); + if ((qth->desc == NULL) || (error != NULL)) { + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: QTH has no description."), + __FUNCTION__); + + qth->desc = g_strdup (""); + g_clear_error (&error); + } + + /* Weather station */ + qth->wx = g_key_file_get_string (qth->data, + QTH_CFG_MAIN_SECTION, + QTH_CFG_WX_KEY, + &error); + if ((qth->wx == NULL) || (error != NULL)) { + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: QTH has no weather station."), + __FUNCTION__); + + qth->wx = g_strdup (""); + g_clear_error (&error); + } + + /* QTH Latitude */ + buff = g_key_file_get_string (qth->data, + QTH_CFG_MAIN_SECTION, + QTH_CFG_LAT_KEY, + &error); + if (error != NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Error reading QTH latitude (%s)."), + __FUNCTION__, error->message); + + g_clear_error (&error); + + if (buff != NULL) + g_free (buff); + + qth->lat = 0.0; + } + else { + qth->lat = g_ascii_strtod (buff, NULL); + g_free (buff); + } + + /* QTH Longitude */ + buff = g_key_file_get_string (qth->data, + QTH_CFG_MAIN_SECTION, + QTH_CFG_LON_KEY, + &error); + if (error != NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Error reading QTH longitude (%s)."), + __FUNCTION__, error->message); + + g_clear_error (&error); + + if (buff != NULL) + g_free (buff); + + qth->lon = 0.0; + } + else { + qth->lon = g_ascii_strtod (buff, NULL); + g_free (buff); + } + + /* QTH Altitude */ + qth->alt = g_key_file_get_integer (qth->data, + QTH_CFG_MAIN_SECTION, + QTH_CFG_ALT_KEY, + &error); + if (error != NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Error reading QTH altitude (%s)."), + __FUNCTION__, error->message); + + g_clear_error (&error); + + if (buff != NULL) + g_free (buff); + + qth->alt = 0; + } + else { + } + + /* Now, send debug message and return */ + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: QTH data: %s, %.4f, %.4f, %d"), + __FUNCTION__, + qth->name, + qth->lat, + qth->lon, + qth->alt); + + return TRUE; +} + + +/** \brief Save the QTH data to a file. + * \param filename The file to save to. + * \param qth Pointer to a qth_t data structure from which the data will be read. + */ +gint +qth_data_save (const gchar *filename, qth_t *qth) +{ + GError *error = NULL; + gchar *buff; + GIOChannel *cfgfile; + gsize length; + gsize written; + gchar *cfgstr; + gint ok = 1; + + qth->data = g_key_file_new (); + g_key_file_set_list_separator (qth->data, ';'); + + /* name */ + /* if (qth->name) { */ + /* g_key_file_set_string (qth->data, */ + /* QTH_CFG_MAIN_SECTION, */ + /* QTH_CFG_NAME_KEY, */ + /* qth->name); */ + /* } */ + + /* description */ + if (qth->desc && (g_utf8_strlen (qth->desc, -1) > 0)) { + g_key_file_set_string (qth->data, + QTH_CFG_MAIN_SECTION, + QTH_CFG_DESC_KEY, + qth->desc); + } + + /* location */ + if (qth->loc && (g_utf8_strlen (qth->loc, -1) > 0)) { + g_key_file_set_string (qth->data, + QTH_CFG_MAIN_SECTION, + QTH_CFG_LOC_KEY, + qth->loc); + } + + /* latitude */ + /* buff = g_strdup_printf ("%.4f", qth->lat);*/ + buff = g_malloc (10); + buff = g_ascii_dtostr (buff, 9, qth->lat); + g_key_file_set_string (qth->data, + QTH_CFG_MAIN_SECTION, + QTH_CFG_LAT_KEY, + buff); + g_free (buff); + + /* longitude */ + /* buff = g_strdup_printf ("%.4f", qth->lon); */ + buff = g_malloc (10); + buff = g_ascii_dtostr (buff, 9, qth->lon); + g_key_file_set_string (qth->data, + QTH_CFG_MAIN_SECTION, + QTH_CFG_LON_KEY, + buff); + g_free (buff); + + /* altitude */ + g_key_file_set_integer (qth->data, + QTH_CFG_MAIN_SECTION, + QTH_CFG_ALT_KEY, + qth->alt); + + /* weather station */ + if (qth->wx && (g_utf8_strlen (qth->wx, -1) > 0)) { + g_key_file_set_string (qth->data, + QTH_CFG_MAIN_SECTION, + QTH_CFG_WX_KEY, + qth->wx); + } + + /* saving code */ + + /* convert configuration data struct to charachter string */ + cfgstr = g_key_file_to_data (qth->data, &length, &error); + + if (error != NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Could not create QTH data (%s)."), + __FUNCTION__, error->message); + + g_clear_error (&error); + + ok = 0; + } + else { + + cfgfile = g_io_channel_new_file (filename, "w", &error); + + if (error != NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Could not create QTH file %s\n%s."), + __FUNCTION__, filename, error->message); + + g_clear_error (&error); + + ok = 0; + } + else { + g_io_channel_write_chars (cfgfile, + cfgstr, + length, + &written, + &error); + + g_io_channel_shutdown (cfgfile, TRUE, NULL); + g_io_channel_unref (cfgfile); + + if (error != NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Error writing QTH data (%s)."), + __FUNCTION__, error->message); + + g_clear_error (&error); + + ok = 0; + } + else if (length != written) { + sat_log_log (SAT_LOG_LEVEL_WARN, + _("%s: Wrote only %d out of %d chars."), + __FUNCTION__, written, length); + + ok = 0; + } + else { + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: QTH data saved."), + __FUNCTION__); + + ok = 1; + } + } + + g_free (cfgstr); + } + + return ok; +} + + +/** \brief Free QTH resources. + * \param qth The qth data structure to free. + */ +void +qth_data_free (qth_t *qth) +{ + if (qth->name) { + g_free (qth->name); + qth->name = NULL; + } + + if (qth->loc) { + g_free (qth->loc); + qth->loc = NULL; + } + + if (qth->desc) { + g_free (qth->desc); + qth->desc = NULL; + } + + if (qth->qra) { + g_free (qth->qra); + qth->qra = NULL; + } + + if (qth->wx) { + g_free (qth->wx); + qth->wx = NULL; + } + + if (qth->data) { + g_key_file_free (qth->data); + qth->data = NULL; + } + + g_free (qth); +} + Added: trunk/src/qth-data.h =================================================================== --- trunk/src/qth-data.h (rev 0) +++ trunk/src/qth-data.h 2009-08-03 18:39:16 UTC (rev 340) @@ -0,0 +1,56 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + Gpredict: Real-time satellite tracking and orbit prediction program + + Copyright (C) 2001-2009 Alexandru Csete, OZ9AEC. + + Authors: Alexandru Csete <oz...@gm...> + + Comments, questions and bugreports should be submitted via + http://sourceforge.net/projects/gpredict/ + More details can be found at the project home page: + + http://gpredict.oz9aec.net/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, visit http://www.fsf.org/ +*/ +#ifndef __QTH_DATA_H__ +#define __QTH_DATA_H__ 1 + +#include <glib.h> +#include "sgpsdp/sgp4sdp4.h" + + + +/** \brief QTH data structure in human readable form. */ +typedef struct { + gchar *name; /*!< Name, eg. callsign. */ + gchar *loc; /*!< Location, eg City, Country. */ + gchar *desc; /*!< Short description. */ + gdouble lat; /*!< Latitude in dec. deg. North. */ + gdouble lon; /*!< Longitude in dec. deg. East. */ + gint alt; /*!< Altitude above sea level in meters. */ + gchar *qra; /*!< QRA locator */ + gchar *wx; /*!< Weather station code (4 chars). */ + + GKeyFile *data; /*!< Raw data from cfg file. */ +} qth_t; + + +gint qth_data_read (const gchar *filename, qth_t *qth); +gint qth_data_save (const gchar *filename, qth_t *qth); +void qth_data_free (qth_t *qth); + + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-03 19:17:36
|
Revision: 341 http://gpredict.svn.sourceforge.net/gpredict/?rev=341&view=rev Author: csete Date: 2009-08-03 19:17:28 +0000 (Mon, 03 Aug 2009) Log Message: ----------- Separate QTH data I/O from SAT data I/O. Modified Paths: -------------- trunk/src/gtk-sat-data.c trunk/src/gtk-sat-data.h trunk/src/gtk-sat-module.c trunk/src/gtk-sat-module.h trunk/src/qth-editor.c trunk/src/qth-editor.h trunk/src/sat-pref-qth.c Modified: trunk/src/gtk-sat-data.c =================================================================== --- trunk/src/gtk-sat-data.c 2009-08-03 18:39:16 UTC (rev 340) +++ trunk/src/gtk-sat-data.c 2009-08-03 19:17:28 UTC (rev 341) @@ -40,366 +40,8 @@ #include "time-tools.h" -/** \brief Read QTH data from file. - * \param filename The file to read from. - * \param qth Pointer to a qth_t data structure where the data will be stored. - * \return FALSE if an error occurred, TRUE otherwise. - * - * \note The function uses the new key=value file parser from glib. - */ -gint -gtk_sat_data_read_qth (const gchar *filename, qth_t *qth) -{ - GError *error = NULL; - gchar *buff; - gchar **buffv; - qth->data = g_key_file_new (); - g_key_file_set_list_separator (qth->data, ';'); - /* bail out with error message if data can not be read */ - if (!g_key_file_load_from_file (qth->data, filename, - G_KEY_FILE_KEEP_COMMENTS, &error)) { - - g_key_file_free (qth->data); - - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Could not load data from %s (%s)"), - __FUNCTION__, filename, error->message); - - return FALSE; - } - - /* send a debug message, then read data */ - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: QTH data: %s"), - __FUNCTION__, filename); - - /*** FIXME: should check that strings are UTF-8? */ - /* QTH Name */ - buff = g_path_get_basename (filename); - buffv = g_strsplit (buff, ".qth", 0); - qth->name = g_strdup (buffv[0]); - - g_free (buff); - g_strfreev (buffv); - /* g_key_file_get_string (qth->data, */ - /* QTH_CFG_MAIN_SECTION, */ - /* QTH_CFG_NAME_KEY, */ - /* &error); */ - if (error != NULL) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Error reading QTH name (%s)."), - __FUNCTION__, error->message); - - qth->name = g_strdup (_("ERROR")); - g_clear_error (&error); - } - - /* QTH location */ - qth->loc = g_key_file_get_string (qth->data, - QTH_CFG_MAIN_SECTION, - QTH_CFG_LOC_KEY, - &error); - if (error != NULL) { - sat_log_log (SAT_LOG_LEVEL_MSG, - _("%s: QTH has no location (%s)."), - __FUNCTION__, error->message); - - qth->loc = g_strdup (""); - g_clear_error (&error); - } - - /* QTH description */ - qth->desc = g_key_file_get_string (qth->data, - QTH_CFG_MAIN_SECTION, - QTH_CFG_DESC_KEY, - &error); - if ((qth->desc == NULL) || (error != NULL)) { - sat_log_log (SAT_LOG_LEVEL_MSG, - _("%s: QTH has no description."), - __FUNCTION__); - - qth->desc = g_strdup (""); - g_clear_error (&error); - } - - /* Weather station */ - qth->wx = g_key_file_get_string (qth->data, - QTH_CFG_MAIN_SECTION, - QTH_CFG_WX_KEY, - &error); - if ((qth->wx == NULL) || (error != NULL)) { - sat_log_log (SAT_LOG_LEVEL_MSG, - _("%s: QTH has no weather station."), - __FUNCTION__); - - qth->wx = g_strdup (""); - g_clear_error (&error); - } - - /* QTH Latitude */ - buff = g_key_file_get_string (qth->data, - QTH_CFG_MAIN_SECTION, - QTH_CFG_LAT_KEY, - &error); - if (error != NULL) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Error reading QTH latitude (%s)."), - __FUNCTION__, error->message); - - g_clear_error (&error); - - if (buff != NULL) - g_free (buff); - - qth->lat = 0.0; - } - else { - qth->lat = g_ascii_strtod (buff, NULL); - g_free (buff); - } - - /* QTH Longitude */ - buff = g_key_file_get_string (qth->data, - QTH_CFG_MAIN_SECTION, - QTH_CFG_LON_KEY, - &error); - if (error != NULL) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Error reading QTH longitude (%s)."), - __FUNCTION__, error->message); - - g_clear_error (&error); - - if (buff != NULL) - g_free (buff); - - qth->lon = 0.0; - } - else { - qth->lon = g_ascii_strtod (buff, NULL); - g_free (buff); - } - - /* QTH Altitude */ - qth->alt = g_key_file_get_integer (qth->data, - QTH_CFG_MAIN_SECTION, - QTH_CFG_ALT_KEY, - &error); - if (error != NULL) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Error reading QTH altitude (%s)."), - __FUNCTION__, error->message); - - g_clear_error (&error); - - if (buff != NULL) - g_free (buff); - - qth->alt = 0; - } - else { - } - - /* Now, send debug message and return */ - sat_log_log (SAT_LOG_LEVEL_MSG, - _("%s: QTH data: %s, %.4f, %.4f, %d"), - __FUNCTION__, - qth->name, - qth->lat, - qth->lon, - qth->alt); - - return TRUE; -} - - -/** \brief Save the QTH data to a file. - * \param filename The file to save to. - * \param qth Pointer to a qth_t data structure from which the data will be read. - */ -gint -gtk_sat_data_save_qth (const gchar *filename, qth_t *qth) -{ - GError *error = NULL; - gchar *buff; - GIOChannel *cfgfile; - gsize length; - gsize written; - gchar *cfgstr; - gint ok = 1; - - qth->data = g_key_file_new (); - g_key_file_set_list_separator (qth->data, ';'); - - /* name */ - /* if (qth->name) { */ - /* g_key_file_set_string (qth->data, */ - /* QTH_CFG_MAIN_SECTION, */ - /* QTH_CFG_NAME_KEY, */ - /* qth->name); */ - /* } */ - - /* description */ - if (qth->desc && (g_utf8_strlen (qth->desc, -1) > 0)) { - g_key_file_set_string (qth->data, - QTH_CFG_MAIN_SECTION, - QTH_CFG_DESC_KEY, - qth->desc); - } - - /* location */ - if (qth->loc && (g_utf8_strlen (qth->loc, -1) > 0)) { - g_key_file_set_string (qth->data, - QTH_CFG_MAIN_SECTION, - QTH_CFG_LOC_KEY, - qth->loc); - } - - /* latitude */ - /* buff = g_strdup_printf ("%.4f", qth->lat);*/ - buff = g_malloc (10); - buff = g_ascii_dtostr (buff, 9, qth->lat); - g_key_file_set_string (qth->data, - QTH_CFG_MAIN_SECTION, - QTH_CFG_LAT_KEY, - buff); - g_free (buff); - - /* longitude */ - /* buff = g_strdup_printf ("%.4f", qth->lon); */ - buff = g_malloc (10); - buff = g_ascii_dtostr (buff, 9, qth->lon); - g_key_file_set_string (qth->data, - QTH_CFG_MAIN_SECTION, - QTH_CFG_LON_KEY, - buff); - g_free (buff); - - /* altitude */ - g_key_file_set_integer (qth->data, - QTH_CFG_MAIN_SECTION, - QTH_CFG_ALT_KEY, - qth->alt); - - /* weather station */ - if (qth->wx && (g_utf8_strlen (qth->wx, -1) > 0)) { - g_key_file_set_string (qth->data, - QTH_CFG_MAIN_SECTION, - QTH_CFG_WX_KEY, - qth->wx); - } - - /* saving code */ - - /* convert configuration data struct to charachter string */ - cfgstr = g_key_file_to_data (qth->data, &length, &error); - - if (error != NULL) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Could not create QTH data (%s)."), - __FUNCTION__, error->message); - - g_clear_error (&error); - - ok = 0; - } - else { - - cfgfile = g_io_channel_new_file (filename, "w", &error); - - if (error != NULL) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Could not create QTH file %s\n%s."), - __FUNCTION__, filename, error->message); - - g_clear_error (&error); - - ok = 0; - } - else { - g_io_channel_write_chars (cfgfile, - cfgstr, - length, - &written, - &error); - - g_io_channel_shutdown (cfgfile, TRUE, NULL); - g_io_channel_unref (cfgfile); - - if (error != NULL) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Error writing QTH data (%s)."), - __FUNCTION__, error->message); - - g_clear_error (&error); - - ok = 0; - } - else if (length != written) { - sat_log_log (SAT_LOG_LEVEL_WARN, - _("%s: Wrote only %d out of %d chars."), - __FUNCTION__, written, length); - - ok = 0; - } - else { - sat_log_log (SAT_LOG_LEVEL_MSG, - _("%s: QTH data saved."), - __FUNCTION__); - - ok = 1; - } - } - - g_free (cfgstr); - } - - return ok; -} - - -/** \brief Free QTH resources. - * \param qth The qth data structure to free. - */ -void -gtk_sat_data_free_qth (qth_t *qth) -{ - if (qth->name) { - g_free (qth->name); - qth->name = NULL; - } - - if (qth->loc) { - g_free (qth->loc); - qth->loc = NULL; - } - - if (qth->desc) { - g_free (qth->desc); - qth->desc = NULL; - } - - if (qth->qra) { - g_free (qth->qra); - qth->qra = NULL; - } - - if (qth->wx) { - g_free (qth->wx); - qth->wx = NULL; - } - - if (qth->data) { - g_key_file_free (qth->data); - qth->data = NULL; - } - - g_free (qth); -} - - /** \brief Read TLE data for a given satellite into memory. * \param catnum The catalog number of the satellite. * \param sat Pointerto a valid sat_t structure. Modified: trunk/src/gtk-sat-data.h =================================================================== --- trunk/src/gtk-sat-data.h 2009-08-03 18:39:16 UTC (rev 340) +++ trunk/src/gtk-sat-data.h 2009-08-03 19:17:28 UTC (rev 341) @@ -30,27 +30,9 @@ #include <glib.h> #include "sgpsdp/sgp4sdp4.h" +#include "qth-data.h" - -/** \brief QTH data structure in human readable form. */ -typedef struct { - gchar *name; /*!< Name, eg. callsign. */ - gchar *loc; /*!< Location, eg City, Country. */ - gchar *desc; /*!< Short description. */ - gdouble lat; /*!< Latitude in dec. deg. North. */ - gdouble lon; /*!< Longitude in dec. deg. East. */ - gint alt; /*!< Altitude above sea level in meters. */ - gchar *qra; /*!< QRA locator */ - gchar *wx; /*!< Weather station code (4 chars). */ - - GKeyFile *data; /*!< Raw data from cfg file. */ -} qth_t; - - -gint gtk_sat_data_read_qth (const gchar *filename, qth_t *qth); -gint gtk_sat_data_save_qth (const gchar *filename, qth_t *qth); -void gtk_sat_data_free_qth (qth_t *qth); gint gtk_sat_data_read_sat (gint catnum, sat_t *sat); void gtk_sat_data_init_sat (sat_t *sat, qth_t *qth); void gtk_sat_data_copy_sat (const sat_t *source, sat_t *dest, qth_t *qth); Modified: trunk/src/gtk-sat-module.c =================================================================== --- trunk/src/gtk-sat-module.c 2009-08-03 18:39:16 UTC (rev 340) +++ trunk/src/gtk-sat-module.c 2009-08-03 19:17:28 UTC (rev 341) @@ -222,7 +222,7 @@ /* clean up QTH */ if (module->qth) { - gtk_sat_data_free_qth (module->qth); + qth_data_free (module->qth); module->qth = NULL; } @@ -580,7 +580,7 @@ ".gpredict2", G_DIR_SEPARATOR_S, buffer, NULL); /* load QTH data */ - if (!gtk_sat_data_read_qth (qthfile, module->qth)) { + if (!qth_data_read (qthfile, module->qth)) { /* QTH file was not found for some reason */ g_free (buffer); @@ -601,7 +601,7 @@ ".gpredict2", G_DIR_SEPARATOR_S, buffer, NULL); - if (!gtk_sat_data_read_qth (qthfile, module->qth)) { + if (!qth_data_read (qthfile, module->qth)) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Can not load default QTH file %s; using built-in defaults"), Modified: trunk/src/gtk-sat-module.h =================================================================== --- trunk/src/gtk-sat-module.h 2009-08-03 18:39:16 UTC (rev 340) +++ trunk/src/gtk-sat-module.h 2009-08-03 19:17:28 UTC (rev 341) @@ -32,6 +32,7 @@ #include <gdk/gdk.h> #include <gtk/gtkvbox.h> #include "gtk-sat-data.h" +#include "qth-data.h" #ifdef __cplusplus Modified: trunk/src/qth-editor.c =================================================================== --- trunk/src/qth-editor.c 2009-08-03 18:39:16 UTC (rev 340) +++ trunk/src/qth-editor.c 2009-08-03 19:17:28 UTC (rev 341) @@ -533,7 +533,7 @@ ".qth", NULL); - retcode = gtk_sat_data_save_qth (fname, qth); + retcode = qth_data_save (fname, qth); g_free (fname); return retcode; Modified: trunk/src/qth-editor.h =================================================================== --- trunk/src/qth-editor.h 2009-08-03 18:39:16 UTC (rev 340) +++ trunk/src/qth-editor.h 2009-08-03 19:17:28 UTC (rev 341) @@ -30,6 +30,7 @@ #include <gtk/gtk.h> #include "gtk-sat-data.h" +#include "qth-data.h" GtkResponseType qth_editor_run (qth_t *qth, GtkWindow *parent); Modified: trunk/src/sat-pref-qth.c =================================================================== --- trunk/src/sat-pref-qth.c 2009-08-03 18:39:16 UTC (rev 340) +++ trunk/src/sat-pref-qth.c 2009-08-03 19:17:28 UTC (rev 341) @@ -34,7 +34,7 @@ #include "gpredict-utils.h" #include "sat-cfg.h" #include "sat-log.h" -#include "gtk-sat-data.h" +#include "qth-data.h" #include "sat-pref-qth.h" #include "sat-pref-qth-data.h" #include "sat-pref-qth-editor.h" @@ -380,7 +380,7 @@ } /* read data from file */ - if (!gtk_sat_data_read_qth (filename, qth)) { + if (!qth_data_read (filename, qth)) { g_free (qth); return FALSE; } @@ -454,7 +454,7 @@ g_free (fname); /* we are finished with this qth, free it */ - gtk_sat_data_free_qth (qth); + qth_data_free (qth); return TRUE; } @@ -856,7 +856,7 @@ qth.alt = (guint) FT_TO_M(qth.alt); } - if (gtk_sat_data_save_qth (filename, &qth)) { + if (qth_data_save (filename, &qth)) { /* saved ok, go on check whether qth is default */ if (def) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-03 19:38:47
|
Revision: 343 http://gpredict.svn.sourceforge.net/gpredict/?rev=343&view=rev Author: csete Date: 2009-08-03 19:38:36 +0000 (Mon, 03 Aug 2009) Log Message: ----------- New SAT daat I/O. Modified Paths: -------------- trunk/src/Makefile.am Added Paths: ----------- trunk/src/sat-data.c trunk/src/sat-data.h Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-08-03 19:26:35 UTC (rev 342) +++ trunk/src/Makefile.am 2009-08-03 19:38:36 UTC (rev 343) @@ -74,6 +74,7 @@ rotor-conf.c rotor-conf.h \ trsp-conf.c trsp-conf.h \ sat-cfg.c sat-cfg.h \ + sat-data.c sat-data.h \ sat-info.c sat-info.h \ sat-log.c sat-log.h \ sat-log-browser.c sat-log-browser.h \ Added: trunk/src/sat-data.c =================================================================== --- trunk/src/sat-data.c (rev 0) +++ trunk/src/sat-data.c 2009-08-03 19:38:36 UTC (rev 343) @@ -0,0 +1,328 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + Gpredict: Real-time satellite tracking and orbit prediction program + + Copyright (C) 2001-2008 Alexandru Csete, OZ9AEC. + + Authors: Alexandru Csete <oz...@gm...> + + Comments, questions and bugreports should be submitted via + http://sourceforge.net/projects/gpredict/ + More details can be found at the project home page: + + http://gpredict.oz9aec.net/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, visit http://www.fsf.org/ +*/ + +#include <glib.h> +#include <glib/gi18n.h> +#include "sgpsdp/sgp4sdp4.h" +#include "sat-data.h" +#include "sat-log.h" +#include "config-keys.h" +#include "tle-lookup.h" +#ifdef HAVE_CONFIG_H +# include <build-config.h> +#endif +#include "orbit-tools.h" +#include "time-tools.h" + + + + +/** \brief Read data for a given satellite into memory. + * \param catnum The catalog number of the satellite. + * \param sat Pointer to a valid sat_t structure. + * \return 0 if successfull, 1 if the satellite could not + * be found in any of the data files, 2 if the tle + * data has wrong checksum and finally 3 if the tle file + * in which the satellite should be, could not be read or opened. + * + * \bug We should use g_io_channel + */ +gint +sat_data_read (gint catnum, sat_t *sat) +{ + FILE *fp; + gchar tle_str[3][80]; + gchar *filename = NULL, *path = NULL; + gchar *b; + gchar catstr[6]; + guint i; + guint catnr; + gboolean found = FALSE; + guint errorcode = 0; + + filename = tle_lookup (catnum); + + if (!filename) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Can not find #%d in any .tle file."), + __FUNCTION__, catnum); + + return 1; + } + + /* create full file path */ + path = g_strdup_printf ("%s%s.gpredict2%stle%s%s", + g_get_home_dir (), + G_DIR_SEPARATOR_S, + G_DIR_SEPARATOR_S, + G_DIR_SEPARATOR_S, + filename); + + fp = fopen (path, "r"); + + if (fp != NULL) { + + while (fgets (tle_str[0], 80, fp) && !found) { + + /* read second and third lines */ + b = fgets (tle_str[1], 80, fp); + b = fgets (tle_str[2], 80, fp); + + /* copy catnum and convert to integer */ + for (i = 2; i < 7; i++) { + catstr[i-2] = tle_str[1][i]; + } + catstr[5] = '\0'; + catnr = (guint) g_ascii_strtod (catstr, NULL); + + if (catnr == catnum) { + + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Found #%d in %s"), + __FUNCTION__, + catnum, + path); + + found = TRUE; + + if (Get_Next_Tle_Set (tle_str, &sat->tle) != 1) { + /* TLE data not good */ + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Invalid data for #%d"), + __FUNCTION__, + catnum); + + errorcode = 2; + } + else { + /* DATA OK, phew... */ + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Good data for #%d"), + __FUNCTION__, + catnum); + + /* VERY, VERY important! If not done, some sats + will not get initialised, the first time SGP4/SDP4 + is called. Consequently, the resulting data will + be NAN, INF or similar nonsense. + For some reason, not even using g_new0 seems to + be enough. + */ + sat->flags = 0; + + select_ephemeris (sat); + + /* initialise variable fields */ + sat->jul_utc = 0.0; + sat->tsince = 0.0; + sat->az = 0.0; + sat->el = 0.0; + sat->range = 0.0; + sat->range_rate = 0.0; + sat->ra = 0.0; + sat->dec = 0.0; + sat->ssplat = 0.0; + sat->ssplon = 0.0; + sat->alt = 0.0; + sat->velo = 0.0; + sat->ma = 0.0; + sat->footprint = 0.0; + sat->phase = 0.0; + sat->aos = 0.0; + sat->los = 0.0; + + /* calculate satellite data at epoch */ + sat_data_init (sat, NULL); + + } + } + + } + + fclose (fp); + } + else { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Failed to open %s"), + __FUNCTION__, path); + + errorcode = 3; + } + + g_free (path); + g_free (filename); + + return errorcode; +} + + +/** \brief Initialise satellite data. + * \param sat The satellite to initialise. + * \param qth Optional QTH info, use (0,0) if NULL. + * + * This function calculates the satellite data at t = 0, ie. epoch time + * The function is called automatically by gtk_sat_data_read_sat. + */ +void +sat_data_init (sat_t *sat, qth_t *qth) +{ + geodetic_t obs_geodetic; + obs_set_t obs_set; + geodetic_t sat_geodetic; + double jul_utc, age; + + g_return_if_fail (sat != NULL); + + jul_utc = Julian_Date_of_Epoch (sat->tle.epoch); // => tsince = 0.0 + sat->jul_epoch = jul_utc; + + /* initialise observer location */ + if (qth != NULL) { + obs_geodetic.lon = qth->lon * de2ra; + obs_geodetic.lat = qth->lat * de2ra; + obs_geodetic.alt = qth->alt / 1000.0; + obs_geodetic.theta = 0; + } + else { + obs_geodetic.lon = 0.0; + obs_geodetic.lat = 0.0; + obs_geodetic.alt = 0.0; + obs_geodetic.theta = 0; + } + + /* execute computations */ + if (sat->flags & DEEP_SPACE_EPHEM_FLAG) + SDP4 (sat, 0.0); + else + SGP4 (sat, 0.0); + + /* scale position and velocity to km and km/sec */ + Convert_Sat_State (&sat->pos, &sat->vel); + + /* get the velocity of the satellite */ + Magnitude (&sat->vel); + sat->velo = sat->vel.w; + Calculate_Obs (jul_utc, &sat->pos, &sat->vel, &obs_geodetic, &obs_set); + Calculate_LatLonAlt (jul_utc, &sat->pos, &sat_geodetic); + + while (sat_geodetic.lon < -pi) + sat_geodetic.lon += twopi; + + while (sat_geodetic.lon > (pi)) + sat_geodetic.lon -= twopi; + + sat->az = Degrees (obs_set.az); + sat->el = Degrees (obs_set.el); + sat->range = obs_set.range; + sat->range_rate = obs_set.range_rate; + sat->ssplat = Degrees (sat_geodetic.lat); + sat->ssplon = Degrees (sat_geodetic.lon); + sat->alt = sat_geodetic.alt; + sat->ma = Degrees (sat->phase); + sat->ma *= 256.0/360.0; + sat->footprint = 2.0 * xkmper * acos (xkmper/sat->pos.w); + age = 0.0; + sat->orbit = (long) floor((sat->tle.xno * xmnpda/twopi + + age * sat->tle.bstar * ae) * age + + sat->tle.xmo/twopi) + sat->tle.revnum - 1; + + /* orbit type */ + sat->otype = get_orbit_type (sat); +} + +#if 0 +/** \brief Copy satellite data. + * \param source Pointer to the source satellite to copy data from. + * \param dest Pointer to the destination satellite to copy data into. + * \param qth Pointer to the observer data (needed to initialize sat) + * + * This function copies the satellite data from a source sat_t structure into + * the destination. The function copies the tle_t data and calls gtk_sat_data_inti_sat() + * function for initializing the other fields. + * + */ +void sat_data_copy (const sat_t *source, sat_t *dest, qth_t *qth) +{ + guint i; + + g_return_if_fail ((source != NULL) && (dest != NULL)); + + dest->tle.epoch = source->tle.epoch; + dest->tle.epoch_year = source->tle.epoch_year; + dest->tle.epoch_day = source->tle.epoch_day; + dest->tle.epoch_fod = source->tle.epoch_fod; + dest->tle.xndt2o = source->tle.xndt2o; + dest->tle.xndd6o = source->tle.xndd6o; + dest->tle.bstar = source->tle.bstar; + dest->tle.xincl = source->tle.xincl; + dest->tle.xnodeo = source->tle.xnodeo; + dest->tle.eo = source->tle.eo; + dest->tle.omegao = source->tle.omegao; + dest->tle.xmo = source->tle.xmo; + dest->tle.xno = source->tle.xno; + dest->tle.catnr = source->tle.catnr; + dest->tle.elset = source->tle.elset; + dest->tle.revnum = source->tle.revnum; + + for (i = 0; i < 25; i++) + dest->tle.sat_name[i] = source->tle.sat_name[i]; + for (i = 0; i < 9; i++) + dest->tle.idesg[i] = source->tle.idesg[i]; + + dest->tle.status = source->tle.status; + dest->tle.xincl1 = source->tle.xincl1; + dest->tle.omegao1 = source->tle.omegao1; + + dest->otype = source->otype; + + /* very important */ + dest->flags = 0; + select_ephemeris (dest); + + /* initialise variable fields */ + dest->jul_utc = 0.0; + dest->tsince = 0.0; + dest->az = 0.0; + dest->el = 0.0; + dest->range = 0.0; + dest->range_rate = 0.0; + dest->ra = 0.0; + dest->dec = 0.0; + dest->ssplat = 0.0; + dest->ssplon = 0.0; + dest->alt = 0.0; + dest->velo = 0.0; + dest->ma = 0.0; + dest->footprint = 0.0; + dest->phase = 0.0; + dest->aos = 0.0; + dest->los = 0.0; + + sat_data_init (dest, qth); +} +#endif Added: trunk/src/sat-data.h =================================================================== --- trunk/src/sat-data.h (rev 0) +++ trunk/src/sat-data.h 2009-08-03 19:38:36 UTC (rev 343) @@ -0,0 +1,42 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ +/* + Gpredict: Real-time satellite tracking and orbit prediction program + + Copyright (C) 2001-2008 Alexandru Csete, OZ9AEC. + + Authors: Alexandru Csete <oz...@gm...> + + Comments, questions and bugreports should be submitted via + http://sourceforge.net/projects/gpredict/ + More details can be found at the project home page: + + http://gpredict.oz9aec.net/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, visit http://www.fsf.org/ +*/ +#ifndef __SAT_DATA_H__ +#define __SAT_DATA_H__ 1 + +#include <glib.h> +#include "sgpsdp/sgp4sdp4.h" +#include "qth-data.h" + + +gint sat_data_read (gint catnum, sat_t *sat); +void sat_data_init (sat_t *sat, qth_t *qth); +#if 0 +void sat_data_copy (const sat_t *source, sat_t *dest, qth_t *qth); +#endif + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-04 22:14:31
|
Revision: 354 http://gpredict.svn.sourceforge.net/gpredict/?rev=354&view=rev Author: csete Date: 2009-08-04 22:14:20 +0000 (Tue, 04 Aug 2009) Log Message: ----------- Changed functions to transition to new configuration files. Modified Paths: -------------- trunk/src/compat.c trunk/src/compat.h Modified: trunk/src/compat.c =================================================================== --- trunk/src/compat.c 2009-08-04 20:32:35 UTC (rev 353) +++ trunk/src/compat.c 2009-08-04 22:14:20 UTC (rev 354) @@ -190,16 +190,106 @@ } -/** \brief Get user configuration directory. +/** \brief Get the old user configuration directory. * * On linux it corresponds to $HOME/.gpredict2 * The function returns a newly allocated gchar * which must be free when * it is no longer needed. */ -gchar *get_conf_dir (void) +gchar *get_old_conf_dir (void) { gchar *dir; dir = g_strconcat (g_get_home_dir(), G_DIR_SEPARATOR_S, ".gpredict2", NULL); return dir; } + + +/** \brief Get user configuration directory. + * + * Linux: $HOME/.config/Gpredict + * Windows: C:\Documents and Settings\username\Gpredict + * Mac OS X: /home/username/Library/Application Support/Gpredict + * + * The function returns a newly allocated gchar * which must be free when + * it is no longer needed. + */ +gchar *get_user_conf_dir (void) +{ + gchar *dir = NULL; + +#ifdef G_OS_UNIX + dir = g_strconcat (g_get_home_dir(), G_DIR_SEPARATOR_S, + ".config", G_DIR_SEPARATOR_S, + "Gpredict", NULL); + "icons", NULL); +#endif +#ifdef G_OS_WIN32 + // FIXME: does this work? + dir = g_strconcat (g_get_home_dir(), G_DIR_SEPARATOR_S, + "Gpredict", NULL); +#endif +/* see gtk-osx.sourceforge.net -> Integration */ +#ifdef MAC_INTEGRATION + dir = g_strconcat (g_get_home_dir(), G_DIR_SEPARATOR_S, + "Library", G_DIR_SEPARATOR_S, + "Application Support", G_DIR_SEPARATOR_S, + "Gpredict", NULL); +#endif + + return dir; + +} + + +/** \brief Get full path of a .sat or .cat file + * \param satfile The file name for the satellite + * \return A newly allocated gchar * that should be freed when no longer needed + */ +gchar *sat_file_name (const gchar *satfile) +{ + gchar *filename = NULL; + gchar *buff; + + buff = get_user_conf_dir (); + filename = g_strconcat (buff, G_DIR_SEPARATOR_S, satdata, G_DIR_SEPARATOR_S, satfile, NULL); + g_free (buff); + + return filename; + +} + +/** \brief Get full path of a .trsp file + * \param trspfile The file name for the satellite + * \return A newly allocated gchar * that should be freed when no longer needed + */ +gchar *trsp_file_name (const gchar *trspfile) +{ + gchar *filename = NULL; + gchar *buff; + + buff = get_user_conf_dir (); + filename = g_strconcat (buff, G_DIR_SEPARATOR_S, trsp, G_DIR_SEPARATOR_S, trspfile, NULL); + g_free (buff); + + return filename; + +} + + +/** \brief Get full path of a .rig or .rot file + * \param hwfile The file name for the configuration + * \return A newly allocated gchar * that should be freed when no longer needed + */ +gchar *hw_file_name (const gchar *hwfile) +{ + gchar *filename = NULL; + gchar *buff; + + buff = get_user_conf_dir (); + filename = g_strconcat (buff, G_DIR_SEPARATOR_S, hwconf, G_DIR_SEPARATOR_S, hwfile, NULL); + g_free (buff); + + return filename; + +} Modified: trunk/src/compat.h =================================================================== --- trunk/src/compat.h 2009-08-04 20:32:35 UTC (rev 353) +++ trunk/src/compat.h 2009-08-04 22:14:20 UTC (rev 354) @@ -32,10 +32,13 @@ gchar *get_data_dir (void); gchar *get_maps_dir (void); gchar *get_icon_dir (void); -gchar *get_conf_dir (void); +gchar *get_user_conf_dir (void); +gchar *get_old_conf_dir (void); gchar *map_file_name (const gchar *map); gchar *icon_file_name (const gchar *icon); gchar *data_file_name (const gchar *data); +gchar *sat_file_name (const gchar *satfile); +gchar *trsp_file_name (const gchar *trspfile); +gchar *hw_file_name (const gchar *hwfile); - #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-05 23:32:04
|
Revision: 363 http://gpredict.svn.sourceforge.net/gpredict/?rev=363&view=rev Author: csete Date: 2009-08-05 23:31:57 +0000 (Wed, 05 Aug 2009) Log Message: ----------- Added more configuration related utility functions. Modified Paths: -------------- trunk/src/compat.c trunk/src/compat.h Modified: trunk/src/compat.c =================================================================== --- trunk/src/compat.c 2009-08-05 12:02:13 UTC (rev 362) +++ trunk/src/compat.c 2009-08-05 23:31:57 UTC (rev 363) @@ -240,7 +240,62 @@ } +/** \brief Get USER_CONF_DIR/modules */ +gchar *get_modules_dir (void) +{ + gchar *confdir; + gchar *dir; + confdir = get_user_conf_dir (); + dir = g_strconcat (confdir, G_DIR_SEPARATOR_S, "modules", NULL); + g_free (confdir); + + return dir; +} + +/** \brief Get USER_CONF_DIR/satdata */ +gchar *get_satdata_dir (void) +{ + gchar *confdir; + gchar *dir; + + confdir = get_user_conf_dir (); + dir = g_strconcat (confdir, G_DIR_SEPARATOR_S, "satdata", NULL); + g_free (confdir); + + return dir; +} + + +/** \brief Get USER_CONF_DIR/trsp */ +gchar *get_trsp_dir (void) +{ + gchar *confdir; + gchar *dir; + + confdir = get_user_conf_dir (); + dir = g_strconcat (confdir, G_DIR_SEPARATOR_S, "trsp", NULL); + g_free (confdir); + + return dir; +} + + +/** \brief Get USER_CONF_DIR/hwconf */ +gchar *get_hwconf_dir (void) +{ + gchar *confdir; + gchar *dir; + + confdir = get_user_conf_dir (); + dir = g_strconcat (confdir, G_DIR_SEPARATOR_S, "hwconf", NULL); + g_free (confdir); + + return dir; +} + + + /** \brief Get full path of a .sat or .cat file * \param satfile The file name for the satellite * \return A newly allocated gchar * that should be freed when no longer needed @@ -250,8 +305,8 @@ gchar *filename = NULL; gchar *buff; - buff = get_user_conf_dir (); - filename = g_strconcat (buff, G_DIR_SEPARATOR_S, "satdata", G_DIR_SEPARATOR_S, satfile, NULL); + buff = get_satdata_dir (); + filename = g_strconcat (buff, G_DIR_SEPARATOR_S, satfile, NULL); g_free (buff); return filename; @@ -267,8 +322,8 @@ gchar *filename = NULL; gchar *buff; - buff = get_user_conf_dir (); - filename = g_strconcat (buff, G_DIR_SEPARATOR_S, "trsp", G_DIR_SEPARATOR_S, trspfile, NULL); + buff = get_trsp_dir (); + filename = g_strconcat (buff, G_DIR_SEPARATOR_S, trspfile, NULL); g_free (buff); return filename; @@ -285,8 +340,8 @@ gchar *filename = NULL; gchar *buff; - buff = get_user_conf_dir (); - filename = g_strconcat (buff, G_DIR_SEPARATOR_S, "hwconf", G_DIR_SEPARATOR_S, hwfile, NULL); + buff = get_hwconf_dir (); + filename = g_strconcat (buff, G_DIR_SEPARATOR_S, hwfile, NULL); g_free (buff); return filename; Modified: trunk/src/compat.h =================================================================== --- trunk/src/compat.h 2009-08-05 12:02:13 UTC (rev 362) +++ trunk/src/compat.h 2009-08-05 23:31:57 UTC (rev 363) @@ -32,7 +32,11 @@ gchar *get_data_dir (void); gchar *get_maps_dir (void); gchar *get_icon_dir (void); -gchar *get_user_conf_dir (void); +gchar *get_user_conf_dir (void); +gchar *get_modules_dir (void); +gchar *get_satdata_dir (void); +gchar *get_trsp_dir (void); +gchar *get_hwconf_dir (void); gchar *get_old_conf_dir (void); gchar *map_file_name (const gchar *map); gchar *icon_file_name (const gchar *icon); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-06 09:44:55
|
Revision: 366 http://gpredict.svn.sourceforge.net/gpredict/?rev=366&view=rev Author: csete Date: 2009-08-06 09:44:45 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Migrated to new user configuration. Modified Paths: -------------- trunk/src/gtk-rig-ctrl.c trunk/src/gtk-rot-ctrl.c trunk/src/radio-conf.c trunk/src/rotor-conf.c trunk/src/sat-pref-rig.c trunk/src/sat-pref-rot.c trunk/src/trsp-conf.c Modified: trunk/src/gtk-rig-ctrl.c =================================================================== --- trunk/src/gtk-rig-ctrl.c 2009-08-05 23:33:52 UTC (rev 365) +++ trunk/src/gtk-rig-ctrl.c 2009-08-06 09:44:45 UTC (rev 366) @@ -639,7 +639,6 @@ GtkWidget *frame,*table,*label,*timer; GDir *dir = NULL; /* directory handle */ GError *error = NULL; /* error flag and info */ - gchar *cfgdir; gchar *dirname; /* directory name */ gchar **vbuff; const gchar *filename; /* file name */ @@ -662,10 +661,7 @@ "unless you select a secondary device for uplink")); /* open configuration directory */ - cfgdir = get_conf_dir (); - dirname = g_strconcat (cfgdir, G_DIR_SEPARATOR_S, - "hwconf", NULL); - g_free (cfgdir); + dirname = get_hwconf_dir (); dir = g_dir_open (dirname, 0, &error); if (dir) { @@ -2341,17 +2337,13 @@ { GDir *dir = NULL; /* directory handle */ GError *error = NULL; /* error flag and info */ - gchar *cfgdir; gchar *dirname; /* directory name */ const gchar *filename; /* file name */ gint i = 0; /* open configuration directory */ - cfgdir = get_conf_dir (); - dirname = g_strconcat (cfgdir, G_DIR_SEPARATOR_S, - "hwconf", NULL); - g_free (cfgdir); + dirname = get_hwconf_dir (); dir = g_dir_open (dirname, 0, &error); if (dir) { Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2009-08-05 23:33:52 UTC (rev 365) +++ trunk/src/gtk-rot-ctrl.c 2009-08-06 09:44:45 UTC (rev 366) @@ -469,7 +469,6 @@ GtkWidget *frame,*table,*label,*timer,*toler; GDir *dir = NULL; /* directory handle */ GError *error = NULL; /* error flag and info */ - gchar *cfgdir; gchar *dirname; /* directory name */ gchar **vbuff; const gchar *filename; /* file name */ @@ -490,10 +489,7 @@ gtk_widget_set_tooltip_text (ctrl->DevSel, _("Select antenna rotator device")); /* open configuration directory */ - cfgdir = get_conf_dir (); - dirname = g_strconcat (cfgdir, G_DIR_SEPARATOR_S, - "hwconf", NULL); - g_free (cfgdir); + dirname = get_hwconf_dir (); dir = g_dir_open (dirname, 0, &error); if (dir) { @@ -1202,17 +1198,13 @@ { GDir *dir = NULL; /* directory handle */ GError *error = NULL; /* error flag and info */ - gchar *cfgdir; gchar *dirname; /* directory name */ const gchar *filename; /* file name */ gint i = 0; /* open configuration directory */ - cfgdir = get_conf_dir (); - dirname = g_strconcat (cfgdir, G_DIR_SEPARATOR_S, - "hwconf", NULL); - g_free (cfgdir); + dirname = get_hwconf_dir (); dir = g_dir_open (dirname, 0, &error); if (dir) { Modified: trunk/src/radio-conf.c =================================================================== --- trunk/src/radio-conf.c 2009-08-05 23:33:52 UTC (rev 365) +++ trunk/src/radio-conf.c 2009-08-06 09:44:45 UTC (rev 366) @@ -70,9 +70,8 @@ return FALSE; } - confdir = get_conf_dir(); + confdir = get_hwconf_dir(); fname = g_strconcat (confdir, G_DIR_SEPARATOR_S, - "hwconf", G_DIR_SEPARATOR_S, conf->name, ".rig", NULL); g_free (confdir); @@ -245,9 +244,8 @@ /* convert to text sdata */ data = g_key_file_to_data (cfg, &len, NULL); - confdir = get_conf_dir(); + confdir = get_hwconf_dir(); fname = g_strconcat (confdir, G_DIR_SEPARATOR_S, - "hwconf", G_DIR_SEPARATOR_S, conf->name, ".rig", NULL); g_free (confdir); Modified: trunk/src/rotor-conf.c =================================================================== --- trunk/src/rotor-conf.c 2009-08-05 23:33:52 UTC (rev 365) +++ trunk/src/rotor-conf.c 2009-08-06 09:44:45 UTC (rev 366) @@ -67,9 +67,8 @@ return FALSE; } - confdir = get_conf_dir(); + confdir = get_hwconf_dir(); fname = g_strconcat (confdir, G_DIR_SEPARATOR_S, - "hwconf", G_DIR_SEPARATOR_S, conf->name, ".rot", NULL); g_free (confdir); @@ -193,9 +192,8 @@ /* convert to text sdata */ data = g_key_file_to_data (cfg, &len, NULL); - confdir = get_conf_dir(); + confdir = get_hwconf_dir(); fname = g_strconcat (confdir, G_DIR_SEPARATOR_S, - "hwconf", G_DIR_SEPARATOR_S, conf->name, ".rot", NULL); g_free (confdir); Modified: trunk/src/sat-pref-rig.c =================================================================== --- trunk/src/sat-pref-rig.c 2009-08-05 23:33:52 UTC (rev 365) +++ trunk/src/sat-pref-rig.c 2009-08-06 09:44:45 UTC (rev 366) @@ -227,7 +227,6 @@ GtkTreeIter item; /* new item added to the list store */ GDir *dir = NULL; /* directory handle */ GError *error = NULL; /* error flag and info */ - gchar *cfgdir; gchar *dirname; /* directory name */ gchar **vbuff; const gchar *filename; /* file name */ @@ -247,10 +246,7 @@ ); /* open configuration directory */ - cfgdir = get_conf_dir (); - dirname = g_strconcat (cfgdir, G_DIR_SEPARATOR_S, - "hwconf", NULL); - g_free (cfgdir); + dirname = get_hwconf_dir (); dir = g_dir_open (dirname, 0, &error); if (dir) { @@ -393,10 +389,7 @@ /* delete all .rig files */ - buff = get_conf_dir (); - dirname = g_strconcat (buff, G_DIR_SEPARATOR_S, - "hwconf", NULL); - g_free (buff); + dirname = get_hwconf_dir (); dir = g_dir_open (dirname, 0, &error); if (dir) { Modified: trunk/src/sat-pref-rot.c =================================================================== --- trunk/src/sat-pref-rot.c 2009-08-05 23:33:52 UTC (rev 365) +++ trunk/src/sat-pref-rot.c 2009-08-06 09:44:45 UTC (rev 366) @@ -195,7 +195,6 @@ GtkTreeIter item; /* new item added to the list store */ GDir *dir = NULL; /* directory handle */ GError *error = NULL; /* error flag and info */ - gchar *cfgdir; gchar *dirname; /* directory name */ gchar **vbuff; const gchar *filename; /* file name */ @@ -214,10 +213,7 @@ ); /* open configuration directory */ - cfgdir = get_conf_dir (); - dirname = g_strconcat (cfgdir, G_DIR_SEPARATOR_S, - "hwconf", NULL); - g_free (cfgdir); + dirname = get_hwconf_dir (); dir = g_dir_open (dirname, 0, &error); if (dir) { @@ -357,10 +353,7 @@ /* delete all .rot files */ - buff = get_conf_dir (); - dirname = g_strconcat (buff, G_DIR_SEPARATOR_S, - "hwconf", NULL); - g_free (buff); + dirname = get_hwconf_dir (); dir = g_dir_open (dirname, 0, &error); if (dir) { Modified: trunk/src/trsp-conf.c =================================================================== --- trunk/src/trsp-conf.c 2009-08-05 23:33:52 UTC (rev 365) +++ trunk/src/trsp-conf.c 2009-08-06 09:44:45 UTC (rev 366) @@ -51,16 +51,13 @@ trsp_t *trsp; GKeyFile *cfg = NULL; GError *error = NULL; - gchar *name,*fname,*confdir; + gchar *name,*fname; gchar **groups; gsize numgrp,i; name = g_strdup_printf ("%d.trsp", catnum); - confdir = get_conf_dir(); - fname = g_strconcat (confdir, G_DIR_SEPARATOR_S, - "trsp", G_DIR_SEPARATOR_S, - name, NULL); + fname = trsp_file_name (name); cfg = g_key_file_new (); if (!g_key_file_load_from_file (cfg, fname, G_KEY_FILE_KEEP_COMMENTS, &error)) { @@ -158,7 +155,6 @@ g_strfreev (groups); g_key_file_free (cfg); g_free (name); - g_free (confdir); g_free (fname); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-06 10:32:36
|
Revision: 368 http://gpredict.svn.sourceforge.net/gpredict/?rev=368&view=rev Author: csete Date: 2009-08-06 10:32:24 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Added utility function to build satellite data file path from catalog number. Modified Paths: -------------- trunk/src/compat.c trunk/src/compat.h Modified: trunk/src/compat.c =================================================================== --- trunk/src/compat.c 2009-08-06 10:11:33 UTC (rev 367) +++ trunk/src/compat.c 2009-08-06 10:32:24 UTC (rev 368) @@ -313,6 +313,27 @@ } + +/** \brief Build satellite file path from catnum */ +gchar *sat_file_name_from_catnum (guint catnum) +{ + gchar *filename; + gchar *buff; + gchar *dir; + + buff = g_strdup_printf ("%d.sat", catnum); + dir = get_satdata_dir (); + + filename = g_strconcat (dir, G_DIR_SEPARATOR_S, buff, NULL); + + g_free (buff); + g_free (dir); + + return filename; +} + + + /** \brief Get full path of a .trsp file * \param trspfile The file name for the satellite * \return A newly allocated gchar * that should be freed when no longer needed Modified: trunk/src/compat.h =================================================================== --- trunk/src/compat.h 2009-08-06 10:11:33 UTC (rev 367) +++ trunk/src/compat.h 2009-08-06 10:32:24 UTC (rev 368) @@ -45,4 +45,6 @@ gchar *trsp_file_name (const gchar *trspfile); gchar *hw_file_name (const gchar *hwfile); +gchar *sat_file_name_from_catnum (guint catnum); + #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-06 16:08:50
|
Revision: 379 http://gpredict.svn.sourceforge.net/gpredict/?rev=379&view=rev Author: csete Date: 2009-08-06 16:08:42 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Delete obsolete object. Modified Paths: -------------- trunk/src/Makefile.am Removed Paths: ------------- trunk/src/sat-data.c trunk/src/sat-data.h Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-08-06 14:12:56 UTC (rev 378) +++ trunk/src/Makefile.am 2009-08-06 16:08:42 UTC (rev 379) @@ -74,7 +74,6 @@ rotor-conf.c rotor-conf.h \ trsp-conf.c trsp-conf.h \ sat-cfg.c sat-cfg.h \ - sat-data.c sat-data.h \ sat-info.c sat-info.h \ sat-log.c sat-log.h \ sat-log-browser.c sat-log-browser.h \ Deleted: trunk/src/sat-data.c =================================================================== --- trunk/src/sat-data.c 2009-08-06 14:12:56 UTC (rev 378) +++ trunk/src/sat-data.c 2009-08-06 16:08:42 UTC (rev 379) @@ -1,328 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - Gpredict: Real-time satellite tracking and orbit prediction program - - Copyright (C) 2001-2008 Alexandru Csete, OZ9AEC. - - Authors: Alexandru Csete <oz...@gm...> - - Comments, questions and bugreports should be submitted via - http://sourceforge.net/projects/gpredict/ - More details can be found at the project home page: - - http://gpredict.oz9aec.net/ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, visit http://www.fsf.org/ -*/ - -#include <glib.h> -#include <glib/gi18n.h> -#include "sgpsdp/sgp4sdp4.h" -#include "sat-data.h" -#include "sat-log.h" -#include "config-keys.h" -#include "tle-lookup.h" -#ifdef HAVE_CONFIG_H -# include <build-config.h> -#endif -#include "orbit-tools.h" -#include "time-tools.h" - - - - -/** \brief Read data for a given satellite into memory. - * \param catnum The catalog number of the satellite. - * \param sat Pointer to a valid sat_t structure. - * \return 0 if successfull, 1 if the satellite could not - * be found in any of the data files, 2 if the tle - * data has wrong checksum and finally 3 if the tle file - * in which the satellite should be, could not be read or opened. - * - * \bug We should use g_io_channel - */ -gint -sat_data_read (gint catnum, sat_t *sat) -{ - FILE *fp; - gchar tle_str[3][80]; - gchar *filename = NULL, *path = NULL; - gchar *b; - gchar catstr[6]; - guint i; - guint catnr; - gboolean found = FALSE; - guint errorcode = 0; - - filename = tle_lookup (catnum); - - if (!filename) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Can not find #%d in any .tle file."), - __FUNCTION__, catnum); - - return 1; - } - - /* create full file path */ - path = g_strdup_printf ("%s%s.gpredict2%stle%s%s", - g_get_home_dir (), - G_DIR_SEPARATOR_S, - G_DIR_SEPARATOR_S, - G_DIR_SEPARATOR_S, - filename); - - fp = fopen (path, "r"); - - if (fp != NULL) { - - while (fgets (tle_str[0], 80, fp) && !found) { - - /* read second and third lines */ - b = fgets (tle_str[1], 80, fp); - b = fgets (tle_str[2], 80, fp); - - /* copy catnum and convert to integer */ - for (i = 2; i < 7; i++) { - catstr[i-2] = tle_str[1][i]; - } - catstr[5] = '\0'; - catnr = (guint) g_ascii_strtod (catstr, NULL); - - if (catnr == catnum) { - - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Found #%d in %s"), - __FUNCTION__, - catnum, - path); - - found = TRUE; - - if (Get_Next_Tle_Set (tle_str, &sat->tle) != 1) { - /* TLE data not good */ - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Invalid data for #%d"), - __FUNCTION__, - catnum); - - errorcode = 2; - } - else { - /* DATA OK, phew... */ - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Good data for #%d"), - __FUNCTION__, - catnum); - - /* VERY, VERY important! If not done, some sats - will not get initialised, the first time SGP4/SDP4 - is called. Consequently, the resulting data will - be NAN, INF or similar nonsense. - For some reason, not even using g_new0 seems to - be enough. - */ - sat->flags = 0; - - select_ephemeris (sat); - - /* initialise variable fields */ - sat->jul_utc = 0.0; - sat->tsince = 0.0; - sat->az = 0.0; - sat->el = 0.0; - sat->range = 0.0; - sat->range_rate = 0.0; - sat->ra = 0.0; - sat->dec = 0.0; - sat->ssplat = 0.0; - sat->ssplon = 0.0; - sat->alt = 0.0; - sat->velo = 0.0; - sat->ma = 0.0; - sat->footprint = 0.0; - sat->phase = 0.0; - sat->aos = 0.0; - sat->los = 0.0; - - /* calculate satellite data at epoch */ - sat_data_init (sat, NULL); - - } - } - - } - - fclose (fp); - } - else { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Failed to open %s"), - __FUNCTION__, path); - - errorcode = 3; - } - - g_free (path); - g_free (filename); - - return errorcode; -} - - -/** \brief Initialise satellite data. - * \param sat The satellite to initialise. - * \param qth Optional QTH info, use (0,0) if NULL. - * - * This function calculates the satellite data at t = 0, ie. epoch time - * The function is called automatically by gtk_sat_data_read_sat. - */ -void -sat_data_init (sat_t *sat, qth_t *qth) -{ - geodetic_t obs_geodetic; - obs_set_t obs_set; - geodetic_t sat_geodetic; - double jul_utc, age; - - g_return_if_fail (sat != NULL); - - jul_utc = Julian_Date_of_Epoch (sat->tle.epoch); // => tsince = 0.0 - sat->jul_epoch = jul_utc; - - /* initialise observer location */ - if (qth != NULL) { - obs_geodetic.lon = qth->lon * de2ra; - obs_geodetic.lat = qth->lat * de2ra; - obs_geodetic.alt = qth->alt / 1000.0; - obs_geodetic.theta = 0; - } - else { - obs_geodetic.lon = 0.0; - obs_geodetic.lat = 0.0; - obs_geodetic.alt = 0.0; - obs_geodetic.theta = 0; - } - - /* execute computations */ - if (sat->flags & DEEP_SPACE_EPHEM_FLAG) - SDP4 (sat, 0.0); - else - SGP4 (sat, 0.0); - - /* scale position and velocity to km and km/sec */ - Convert_Sat_State (&sat->pos, &sat->vel); - - /* get the velocity of the satellite */ - Magnitude (&sat->vel); - sat->velo = sat->vel.w; - Calculate_Obs (jul_utc, &sat->pos, &sat->vel, &obs_geodetic, &obs_set); - Calculate_LatLonAlt (jul_utc, &sat->pos, &sat_geodetic); - - while (sat_geodetic.lon < -pi) - sat_geodetic.lon += twopi; - - while (sat_geodetic.lon > (pi)) - sat_geodetic.lon -= twopi; - - sat->az = Degrees (obs_set.az); - sat->el = Degrees (obs_set.el); - sat->range = obs_set.range; - sat->range_rate = obs_set.range_rate; - sat->ssplat = Degrees (sat_geodetic.lat); - sat->ssplon = Degrees (sat_geodetic.lon); - sat->alt = sat_geodetic.alt; - sat->ma = Degrees (sat->phase); - sat->ma *= 256.0/360.0; - sat->footprint = 2.0 * xkmper * acos (xkmper/sat->pos.w); - age = 0.0; - sat->orbit = (long) floor((sat->tle.xno * xmnpda/twopi + - age * sat->tle.bstar * ae) * age + - sat->tle.xmo/twopi) + sat->tle.revnum - 1; - - /* orbit type */ - sat->otype = get_orbit_type (sat); -} - -#if 0 -/** \brief Copy satellite data. - * \param source Pointer to the source satellite to copy data from. - * \param dest Pointer to the destination satellite to copy data into. - * \param qth Pointer to the observer data (needed to initialize sat) - * - * This function copies the satellite data from a source sat_t structure into - * the destination. The function copies the tle_t data and calls gtk_sat_data_inti_sat() - * function for initializing the other fields. - * - */ -void sat_data_copy (const sat_t *source, sat_t *dest, qth_t *qth) -{ - guint i; - - g_return_if_fail ((source != NULL) && (dest != NULL)); - - dest->tle.epoch = source->tle.epoch; - dest->tle.epoch_year = source->tle.epoch_year; - dest->tle.epoch_day = source->tle.epoch_day; - dest->tle.epoch_fod = source->tle.epoch_fod; - dest->tle.xndt2o = source->tle.xndt2o; - dest->tle.xndd6o = source->tle.xndd6o; - dest->tle.bstar = source->tle.bstar; - dest->tle.xincl = source->tle.xincl; - dest->tle.xnodeo = source->tle.xnodeo; - dest->tle.eo = source->tle.eo; - dest->tle.omegao = source->tle.omegao; - dest->tle.xmo = source->tle.xmo; - dest->tle.xno = source->tle.xno; - dest->tle.catnr = source->tle.catnr; - dest->tle.elset = source->tle.elset; - dest->tle.revnum = source->tle.revnum; - - for (i = 0; i < 25; i++) - dest->tle.sat_name[i] = source->tle.sat_name[i]; - for (i = 0; i < 9; i++) - dest->tle.idesg[i] = source->tle.idesg[i]; - - dest->tle.status = source->tle.status; - dest->tle.xincl1 = source->tle.xincl1; - dest->tle.omegao1 = source->tle.omegao1; - - dest->otype = source->otype; - - /* very important */ - dest->flags = 0; - select_ephemeris (dest); - - /* initialise variable fields */ - dest->jul_utc = 0.0; - dest->tsince = 0.0; - dest->az = 0.0; - dest->el = 0.0; - dest->range = 0.0; - dest->range_rate = 0.0; - dest->ra = 0.0; - dest->dec = 0.0; - dest->ssplat = 0.0; - dest->ssplon = 0.0; - dest->alt = 0.0; - dest->velo = 0.0; - dest->ma = 0.0; - dest->footprint = 0.0; - dest->phase = 0.0; - dest->aos = 0.0; - dest->los = 0.0; - - sat_data_init (dest, qth); -} -#endif Deleted: trunk/src/sat-data.h =================================================================== --- trunk/src/sat-data.h 2009-08-06 14:12:56 UTC (rev 378) +++ trunk/src/sat-data.h 2009-08-06 16:08:42 UTC (rev 379) @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - Gpredict: Real-time satellite tracking and orbit prediction program - - Copyright (C) 2001-2008 Alexandru Csete, OZ9AEC. - - Authors: Alexandru Csete <oz...@gm...> - - Comments, questions and bugreports should be submitted via - http://sourceforge.net/projects/gpredict/ - More details can be found at the project home page: - - http://gpredict.oz9aec.net/ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, visit http://www.fsf.org/ -*/ -#ifndef __SAT_DATA_H__ -#define __SAT_DATA_H__ 1 - -#include <glib.h> -#include "sgpsdp/sgp4sdp4.h" -#include "qth-data.h" - - -gint sat_data_read (gint catnum, sat_t *sat); -void sat_data_init (sat_t *sat, qth_t *qth); -#if 0 -void sat_data_copy (const sat_t *source, sat_t *dest, qth_t *qth); -#endif - -#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-06 18:55:59
|
Revision: 382 http://gpredict.svn.sourceforge.net/gpredict/?rev=382&view=rev Author: csete Date: 2009-08-06 18:55:50 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Migrated to new user configuration. Modified Paths: -------------- trunk/src/sat-log-browser.c trunk/src/sat-log.c Modified: trunk/src/sat-log-browser.c =================================================================== --- trunk/src/sat-log-browser.c 2009-08-06 18:35:11 UTC (rev 381) +++ trunk/src/sat-log-browser.c 2009-08-06 18:55:50 UTC (rev 382) @@ -11,17 +11,17 @@ More details can be found at the project home page: http://gpredict.oz9aec.net/ - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, visit http://www.fsf.org/ */ @@ -29,49 +29,50 @@ #include <glib/gi18n.h> #include "sat-log.h" #include "sat-log-browser.h" +#include "compat.h" /* columns in the message list */ typedef enum { - MSG_LIST_COL_TIME = 0, - MSG_LIST_COL_SOURCE, - MSG_LIST_COL_LEVEL, - MSG_LIST_COL_MSG, - MSG_LIST_COL_NUMBER + MSG_LIST_COL_TIME = 0, + MSG_LIST_COL_SOURCE, + MSG_LIST_COL_LEVEL, + MSG_LIST_COL_MSG, + MSG_LIST_COL_NUMBER } msg_list_col_t; /* data structure to hold one message */ typedef struct { - time_t time; /* time stamp */ - sat_log_level_t level; /* debug level */ - gchar *message; /* the message itself */ + time_t time; /* time stamp */ + sat_log_level_t level; /* debug level */ + gchar *message; /* the message itself */ } message_t; /* Easy access to column titles */ const gchar *MSG_LIST_COL_TITLE[MSG_LIST_COL_NUMBER] = { - N_("Time"), - N_("Source"), - N_("Level"), - N_("Message") + N_("Time"), + N_("Source"), + N_("Level"), + N_("Message") }; const gfloat MSG_LIST_COL_TITLE_ALIGN[MSG_LIST_COL_NUMBER] = { - 0.5, 0.0, 0.5, 0.0 -}; + 0.5, 0.0, 0.5, 0.0 + }; const gchar *DEBUG_STR[6] = { - N_("NONE"), - N_("BUG"), - N_("ERROR"), - N_("WARNING"), - N_("DEBUG"), - N_("TRACE") + N_("NONE"), + N_("BUG"), + N_("ERROR"), + N_("WARNING"), + N_("DEBUG"), + N_("TRACE") }; @@ -117,9 +118,9 @@ static void clear_message_list (void); static void add_debug_message (const gchar *datetime, - const gchar *source, - sat_log_level_t debug_level, - const char *message); + const gchar *source, + sat_log_level_t debug_level, + const char *message); /* Initialise message window. * @@ -128,67 +129,70 @@ * is initialised. */ void -sat_log_browser_open () + sat_log_browser_open () { - GtkWidget *hbox; - gchar *fname; + GtkWidget *hbox; + gchar *fname; + gchar *confdir; - if (!initialised) { + if (!initialised) { - /* do some init stuff */ + /* do some init stuff */ - hbox = gtk_hbox_new (FALSE, 10); - gtk_box_pack_start_defaults (GTK_BOX (hbox), - create_message_list ()); + hbox = gtk_hbox_new (FALSE, 10); + gtk_box_pack_start_defaults (GTK_BOX (hbox), + create_message_list ()); - gtk_box_pack_start (GTK_BOX (hbox), - create_message_summary (), - FALSE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (hbox), + create_message_summary (), + FALSE, TRUE, 0); - /* create dialog window; we use "fake" stock responses to catch user - button clicks (save_as and pause) - */ - window = gtk_dialog_new_with_buttons (_("Log Browser"), - GTK_WINDOW (app), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_OPEN, - GTK_RESPONSE_YES, /* cheating */ - GTK_STOCK_CLEAR, - GTK_RESPONSE_NO, /* cheating */ - GTK_STOCK_CLOSE, - GTK_RESPONSE_CLOSE, - NULL); - - gtk_window_set_default_size (GTK_WINDOW (window), 850, 400); + /* create dialog window; we use "fake" stock responses to catch user + button clicks (save_as and pause) + */ + window = gtk_dialog_new_with_buttons (_("Log Browser"), + GTK_WINDOW (app), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_OPEN, + GTK_RESPONSE_YES, /* cheating */ + GTK_STOCK_CLEAR, + GTK_RESPONSE_NO, /* cheating */ + GTK_STOCK_CLOSE, + GTK_RESPONSE_CLOSE, + NULL); - gtk_container_add (GTK_CONTAINER (GTK_DIALOG(window)->vbox), hbox); + gtk_window_set_default_size (GTK_WINDOW (window), 850, 400); - /* connect response signal */ - g_signal_connect (G_OBJECT (window), "response", - G_CALLBACK (message_window_response), - NULL); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG(window)->vbox), hbox); - /* connect delete and destroy signals */ - g_signal_connect (G_OBJECT (window), "delete_event", - G_CALLBACK (message_window_delete), NULL); - g_signal_connect (G_OBJECT (window), "destroy", - G_CALLBACK (message_window_destroy), NULL); + /* connect response signal */ + g_signal_connect (G_OBJECT (window), "response", + G_CALLBACK (message_window_response), + NULL); - gtk_widget_show_all (window); + /* connect delete and destroy signals */ + g_signal_connect (G_OBJECT (window), "delete_event", + G_CALLBACK (message_window_delete), NULL); + g_signal_connect (G_OBJECT (window), "destroy", + G_CALLBACK (message_window_destroy), NULL); - /* read gpredict.log by default */ - fname = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "logs", G_DIR_SEPARATOR_S, - "gpredict.log", NULL); - read_debug_file (fname); - g_free (fname); - - /*** FIXME: add currently shown file name in title; chech read_debug_file status */ + gtk_widget_show_all (window); - initialised = TRUE; - } + /* read gpredict.log by default */ + confdir = get_user_conf_dir (); + fname = g_strconcat (confdir, G_DIR_SEPARATOR_S, + "logs", G_DIR_SEPARATOR_S, + "gpredict.log", NULL); + + read_debug_file (fname); + g_free (fname); + g_free (confdir); + + /*** FIXME: add currently shown file name in title; chech read_debug_file status */ + + initialised = TRUE; + } } @@ -196,102 +200,102 @@ /** \brief Add a message to message list */ static void -add_debug_message (const gchar *datetime, - const gchar *source, - sat_log_level_t debug_level, - const char *message) + add_debug_message (const gchar *datetime, + const gchar *source, + sat_log_level_t debug_level, + const char *message) { - guint total; /* totalt number of messages */ - gchar *str; /* string to show message count */ - GtkTreeIter item; /* new item added to the list store */ + guint total; /* totalt number of messages */ + gchar *str; /* string to show message count */ + GtkTreeIter item; /* new item added to the list store */ - /* increment source counter and convert to string */ - if (!g_ascii_strcasecmp (source, "1")) { - hamlibs++; - str = g_strdup_printf ("%d", hamlibs); - gtk_label_set_text (GTK_LABEL (hamliblabel), str); - g_free (str); - str = g_strdup ("HAMLIB"); - } - else if (!g_ascii_strcasecmp (source, "2")) { - gpredicts++; - str = g_strdup_printf ("%d", gpredicts); - gtk_label_set_text (GTK_LABEL (gpredictlabel), str); - g_free (str); - str = g_strdup ("GPREDICT"); - } - else { - others++; - str = g_strdup_printf ("%d", others); - gtk_label_set_text (GTK_LABEL (otherlabel), str); - g_free (str); - str = g_strdup ("OTHER"); - } + /* increment source counter and convert to string */ + if (!g_ascii_strcasecmp (source, "1")) { + hamlibs++; + str = g_strdup_printf ("%d", hamlibs); + gtk_label_set_text (GTK_LABEL (hamliblabel), str); + g_free (str); + str = g_strdup ("HAMLIB"); + } + else if (!g_ascii_strcasecmp (source, "2")) { + gpredicts++; + str = g_strdup_printf ("%d", gpredicts); + gtk_label_set_text (GTK_LABEL (gpredictlabel), str); + g_free (str); + str = g_strdup ("GPREDICT"); + } + else { + others++; + str = g_strdup_printf ("%d", others); + gtk_label_set_text (GTK_LABEL (otherlabel), str); + g_free (str); + str = g_strdup ("OTHER"); + } - gtk_list_store_append (GTK_LIST_STORE (model), &item); - gtk_list_store_set (GTK_LIST_STORE (model), &item, - MSG_LIST_COL_TIME, datetime, - MSG_LIST_COL_SOURCE, str, - MSG_LIST_COL_LEVEL, _(DEBUG_STR[debug_level]), - MSG_LIST_COL_MSG, message, - -1); + gtk_list_store_append (GTK_LIST_STORE (model), &item); + gtk_list_store_set (GTK_LIST_STORE (model), &item, + MSG_LIST_COL_TIME, datetime, + MSG_LIST_COL_SOURCE, str, + MSG_LIST_COL_LEVEL, _(DEBUG_STR[debug_level]), + MSG_LIST_COL_MSG, message, + -1); - g_free (str); + g_free (str); - /* increment severity counter */ - switch (debug_level) { - - /* internal bugs */ - case SAT_LOG_LEVEL_BUG: - bugs++; - str = g_strdup_printf ("%d", bugs); - gtk_label_set_text (GTK_LABEL (buglabel), str); - g_free (str); - break; + /* increment severity counter */ + switch (debug_level) { - /* runtime error */ - case SAT_LOG_LEVEL_ERROR: - errors++; - str = g_strdup_printf ("%d", errors); - gtk_label_set_text (GTK_LABEL (errlabel), str); - g_free (str); - break; + /* internal bugs */ + case SAT_LOG_LEVEL_BUG: + bugs++; + str = g_strdup_printf ("%d", bugs); + gtk_label_set_text (GTK_LABEL (buglabel), str); + g_free (str); + break; - /* warning */ - case SAT_LOG_LEVEL_WARN: - warnings++; - str = g_strdup_printf ("%d", warnings); - gtk_label_set_text (GTK_LABEL (warnlabel), str); - g_free (str); - break; + /* runtime error */ + case SAT_LOG_LEVEL_ERROR: + errors++; + str = g_strdup_printf ("%d", errors); + gtk_label_set_text (GTK_LABEL (errlabel), str); + g_free (str); + break; - /* verbose info */ - case SAT_LOG_LEVEL_MSG: - verboses++; - str = g_strdup_printf ("%d", verboses); - gtk_label_set_text (GTK_LABEL (verblabel), str); - g_free (str); - break; + /* warning */ + case SAT_LOG_LEVEL_WARN: + warnings++; + str = g_strdup_printf ("%d", warnings); + gtk_label_set_text (GTK_LABEL (warnlabel), str); + g_free (str); + break; - /* trace */ - case SAT_LOG_LEVEL_DEBUG: - traces++; - str = g_strdup_printf ("%d", traces); - gtk_label_set_text (GTK_LABEL (tracelabel), str); - g_free (str); - break; + /* verbose info */ + case SAT_LOG_LEVEL_MSG: + verboses++; + str = g_strdup_printf ("%d", verboses); + gtk_label_set_text (GTK_LABEL (verblabel), str); + g_free (str); + break; - default: - break; - } + /* trace */ + case SAT_LOG_LEVEL_DEBUG: + traces++; + str = g_strdup_printf ("%d", traces); + gtk_label_set_text (GTK_LABEL (tracelabel), str); + g_free (str); + break; - /* the sum does not have to be updated for each line */ - total = bugs+errors+warnings+verboses+traces; - str = g_strdup_printf ("<b>%d</b>", total); - gtk_label_set_markup (GTK_LABEL (sumlabel), str); - g_free (str); + default: + break; + } + /* the sum does not have to be updated for each line */ + total = bugs+errors+warnings+verboses+traces; + str = g_strdup_printf ("<b>%d</b>", total); + gtk_label_set_markup (GTK_LABEL (sumlabel), str); + g_free (str); + } @@ -299,55 +303,55 @@ /*** FIXME: does not seem to be necessary */ static gint -message_window_delete (GtkWidget *widget, - GdkEvent *event, - gpointer data) + message_window_delete (GtkWidget *widget, + GdkEvent *event, + gpointer data) { - /* return FALSE to indicate that message window - should be destroyed */ - return FALSE; + /* return FALSE to indicate that message window + should be destroyed */ + return FALSE; } /* callback function called when the dialog window is destroyed */ static void -message_window_destroy (GtkWidget *widget, - gpointer data) + message_window_destroy (GtkWidget *widget, + gpointer data) { - /* clean up memory */ - /* GSList, ... */ + /* clean up memory */ + /* GSList, ... */ - initialised = FALSE; + initialised = FALSE; } /* callback function called when a dialog button is clicked */ static void -message_window_response (GtkWidget *widget, - gint response, - gpointer data) + message_window_response (GtkWidget *widget, + gint response, + gpointer data) { - switch (response) { + switch (response) { - /* close button */ - case GTK_RESPONSE_CLOSE: - gtk_widget_destroy (widget); - break; + /* close button */ + case GTK_RESPONSE_CLOSE: + gtk_widget_destroy (widget); + break; - /* OPEN button */ - case GTK_RESPONSE_YES: - load_debug_file (widget); - break; + /* OPEN button */ + case GTK_RESPONSE_YES: + load_debug_file (widget); + break; - /* CLEAR button */ - case GTK_RESPONSE_NO: - clear_message_list (); - break; + /* CLEAR button */ + case GTK_RESPONSE_NO: + clear_message_list (); + break; - default: - break; - } + default: + break; + } } @@ -358,138 +362,139 @@ * file is checked and, if the file exists, is read line by line. */ static void -load_debug_file (GtkWidget *parent) + load_debug_file (GtkWidget *parent) { + gchar *confdir; + gchar *filename; + gint error; /* error code returned by by read_debug_file */ - gchar *filename; - gint error; /* error code returned by by read_debug_file */ + GtkWidget *dialog; - GtkWidget *dialog; + /* create file chooser dialog */ + dialog = gtk_file_chooser_dialog_new (_("Select Log File"), + GTK_WINDOW (parent), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); - /* create file chooser dialog */ - dialog = gtk_file_chooser_dialog_new (_("Select Log File"), - GTK_WINDOW (parent), - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, - NULL); - filename = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "logs", NULL); - gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), filename); - g_free (filename); + confdir = get_user_conf_dir (); + filename = g_strconcat (confdir, G_DIR_SEPARATOR_S, "logs", NULL); + gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), filename); + g_free (filename); + g_free (confdir); - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { - clear_message_list (); + clear_message_list (); - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); + filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); - /* sanity check of filename will be performed - in read_debug_file */ - error = read_debug_file (filename); - - /*** FIXME: add currently shown file name in title; chech read_debug_file status */ + /* sanity check of filename will be performed + in read_debug_file */ + error = read_debug_file (filename); - g_free (filename); - } + /*** FIXME: add currently shown file name in title; chech read_debug_file status */ - gtk_widget_destroy (dialog); + g_free (filename); + } + gtk_widget_destroy (dialog); + } /** \brief Read contents of debug file. */ static int -read_debug_file (const gchar *filename) + read_debug_file (const gchar *filename) { - GIOChannel *logfile = NULL; /* the log file */ - GError *error = NULL; /* error structure */ - gint errorcode = 0; /* error code returned by function */ - gchar *line; /* line read from file */ - gsize length; /* length of line read from file */ - gchar **buff; + GIOChannel *logfile = NULL; /* the log file */ + GError *error = NULL; /* error structure */ + gint errorcode = 0; /* error code returned by function */ + gchar *line; /* line read from file */ + gsize length; /* length of line read from file */ + gchar **buff; - /* check file and read contents */ - if (g_file_test (filename, G_FILE_TEST_EXISTS)) { + /* check file and read contents */ + if (g_file_test (filename, G_FILE_TEST_EXISTS)) { - /* open file */ - logfile = g_io_channel_new_file (filename, "r", &error); + /* open file */ + logfile = g_io_channel_new_file (filename, "r", &error); - if (logfile) { - /* read the file line by line */ - while (g_io_channel_read_line (logfile, - &line, - &length, - NULL, - NULL) != G_IO_STATUS_EOF) { + if (logfile) { + /* read the file line by line */ + while (g_io_channel_read_line (logfile, + &line, + &length, + NULL, + NULL) != G_IO_STATUS_EOF) { - /* trim line and split it */ - line = g_strdelimit (line, "\n", '\0'); + /* trim line and split it */ + line = g_strdelimit (line, "\n", '\0'); - buff = g_strsplit (line, - SAT_LOG_MSG_SEPARATOR, - MSG_LIST_COL_NUMBER); + buff = g_strsplit (line, + SAT_LOG_MSG_SEPARATOR, + MSG_LIST_COL_NUMBER); - /* buff[0] = date and time - buff[1] = source - buff[2] = level - buff[3] = message - unless it comes from Gtk+/Glib, in which case - buff[0] contains the message and it is the - only element - */ - switch (g_strv_length (buff)) { + /* buff[0] = date and time + buff[1] = source + buff[2] = level + buff[3] = message + unless it comes from Gtk+/Glib, in which case + buff[0] contains the message and it is the + only element + */ + switch (g_strv_length (buff)) { - case 1: - add_debug_message ("", _("SYS"), - SAT_LOG_LEVEL_ERROR, buff[0]); - break; + case 1: + add_debug_message ("", _("SYS"), + SAT_LOG_LEVEL_ERROR, buff[0]); + break; - case 4: - add_debug_message (buff[0], buff[1], - (guint) g_ascii_strtod (buff[2], NULL), - buff[3]); - break; - default: - add_debug_message ("", _("GPREDICT"), SAT_LOG_LEVEL_ERROR, - _("Log file seems corrupt")); - break; - } + case 4: + add_debug_message (buff[0], buff[1], + (guint) g_ascii_strtod (buff[2], NULL), + buff[3]); + break; + default: + add_debug_message ("", _("GPREDICT"), SAT_LOG_LEVEL_ERROR, + _("Log file seems corrupt")); + break; + } - /* clean up */ - g_free (line); - g_strfreev (buff); - } + /* clean up */ + g_free (line); + g_strfreev (buff); + } - errorcode = 0; + errorcode = 0; - /* Close IO chanel; don't care about status. - Shutdown will flush the stream and close the channel - as soon as the reference count is dropped. Order matters! - */ - g_io_channel_shutdown (logfile, TRUE, NULL); - g_io_channel_unref (logfile); + /* Close IO chanel; don't care about status. + Shutdown will flush the stream and close the channel + as soon as the reference count is dropped. Order matters! + */ + g_io_channel_shutdown (logfile, TRUE, NULL); + g_io_channel_unref (logfile); - } - else { - /* an error occured */ - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%d: Error open debug log (%s)"), - __FILE__, __LINE__, error->message); + } + else { + /* an error occured */ + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%d: Error open debug log (%s)"), + __FILE__, __LINE__, error->message); - g_clear_error (&error); + g_clear_error (&error); - errorcode = 1; - } - } - else { - errorcode = 1; - } + errorcode = 1; + } + } + else { + errorcode = 1; + } - return errorcode; + return errorcode; } @@ -500,87 +505,87 @@ * to zero. */ static void -clear_message_list () + clear_message_list () { - /* clear the meaase list */ - gtk_list_store_clear (GTK_LIST_STORE (model)); + /* clear the meaase list */ + gtk_list_store_clear (GTK_LIST_STORE (model)); - /* reset the counters and text widgets */ - bugs = 0; - errors = 0; - warnings = 0; - verboses = 0; - traces = 0; - gpredicts = 0; - hamlibs = 0; - others = 0; + /* reset the counters and text widgets */ + bugs = 0; + errors = 0; + warnings = 0; + verboses = 0; + traces = 0; + gpredicts = 0; + hamlibs = 0; + others = 0; - gtk_label_set_text (GTK_LABEL (buglabel), "0"); - gtk_label_set_text (GTK_LABEL (errlabel), "0"); - gtk_label_set_text (GTK_LABEL (warnlabel), "0"); - gtk_label_set_text (GTK_LABEL (verblabel), "0"); - gtk_label_set_text (GTK_LABEL (tracelabel), "0"); - gtk_label_set_text (GTK_LABEL (hamliblabel), "0"); - gtk_label_set_text (GTK_LABEL (gpredictlabel), "0"); - gtk_label_set_text (GTK_LABEL (otherlabel), "0"); - gtk_label_set_markup (GTK_LABEL (sumlabel), "<b>0</b>"); + gtk_label_set_text (GTK_LABEL (buglabel), "0"); + gtk_label_set_text (GTK_LABEL (errlabel), "0"); + gtk_label_set_text (GTK_LABEL (warnlabel), "0"); + gtk_label_set_text (GTK_LABEL (verblabel), "0"); + gtk_label_set_text (GTK_LABEL (tracelabel), "0"); + gtk_label_set_text (GTK_LABEL (hamliblabel), "0"); + gtk_label_set_text (GTK_LABEL (gpredictlabel), "0"); + gtk_label_set_text (GTK_LABEL (otherlabel), "0"); + gtk_label_set_markup (GTK_LABEL (sumlabel), "<b>0</b>"); } /* Create list view */ static GtkWidget * -create_message_list () + create_message_list () { - /* high level treev iew widget */ - GtkWidget *treeview; + /* high level treev iew widget */ + GtkWidget *treeview; - /* scrolled window containing the tree view */ - GtkWidget *swin; + /* scrolled window containing the tree view */ + GtkWidget *swin; - /* cell renderer used to create a column */ - GtkCellRenderer *renderer; + /* cell renderer used to create a column */ + GtkCellRenderer *renderer; - /* place holder for a tree view column */ - GtkTreeViewColumn *column; + /* place holder for a tree view column */ + GtkTreeViewColumn *column; - guint i; + guint i; - treeview = gtk_tree_view_new (); - gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (treeview), TRUE); + treeview = gtk_tree_view_new (); + gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (treeview), TRUE); - for (i = 0; i < MSG_LIST_COL_NUMBER; i++) { + for (i = 0; i < MSG_LIST_COL_NUMBER; i++) { - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_(MSG_LIST_COL_TITLE[i]), - renderer, - "text", i, - NULL); - gtk_tree_view_insert_column (GTK_TREE_VIEW (treeview), - column, - -1); + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes (_(MSG_LIST_COL_TITLE[i]), + renderer, + "text", i, + NULL); + gtk_tree_view_insert_column (GTK_TREE_VIEW (treeview), + column, + -1); - /* only aligns the headers? */ - gtk_tree_view_column_set_alignment (column, MSG_LIST_COL_TITLE_ALIGN[i]); + /* only aligns the headers? */ + gtk_tree_view_column_set_alignment (column, MSG_LIST_COL_TITLE_ALIGN[i]); - } + } - /* create tree view model and finalise tree view */ - model = create_list_model (); - gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), model); - g_object_unref (model); + /* create tree view model and finalise tree view */ + model = create_list_model (); + gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), model); + g_object_unref (model); - /* treeview is packed into a scroleld window */ - swin = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_container_add (GTK_CONTAINER (swin), treeview); + /* treeview is packed into a scroleld window */ + swin = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + gtk_container_add (GTK_CONTAINER (swin), treeview); - return swin; + return swin; } @@ -589,160 +594,160 @@ without any problems. */ static GtkTreeModel * -create_list_model () + create_list_model () { - GtkListStore *liststore; + GtkListStore *liststore; - liststore = gtk_list_store_new (MSG_LIST_COL_NUMBER, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING); + liststore = gtk_list_store_new (MSG_LIST_COL_NUMBER, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING); - /*** Fill existing data into the list here ***/ + /*** Fill existing data into the list here ***/ - return GTK_TREE_MODEL (liststore); + return GTK_TREE_MODEL (liststore); } /* create summary */ static GtkWidget * -create_message_summary () + create_message_summary () { - GtkWidget *vbox; - GtkWidget *table; /* table containing everything */ - GtkWidget *frame; /* surrounding frame */ - GtkWidget *label; /* dummy label */ + GtkWidget *vbox; + GtkWidget *table; /* table containing everything */ + GtkWidget *frame; /* surrounding frame */ + GtkWidget *label; /* dummy label */ - /* create labels */ - hamliblabel = gtk_label_new ("0"); - gtk_misc_set_alignment (GTK_MISC (hamliblabel), 1.0, 0.5); + /* create labels */ + hamliblabel = gtk_label_new ("0"); + gtk_misc_set_alignment (GTK_MISC (hamliblabel), 1.0, 0.5); - gpredictlabel = gtk_label_new ("0"); - gtk_misc_set_alignment (GTK_MISC (gpredictlabel), 1.0, 0.5); + gpredictlabel = gtk_label_new ("0"); + gtk_misc_set_alignment (GTK_MISC (gpredictlabel), 1.0, 0.5); - otherlabel = gtk_label_new ("0"); - gtk_misc_set_alignment (GTK_MISC (otherlabel), 1.0, 0.5); + otherlabel = gtk_label_new ("0"); + gtk_misc_set_alignment (GTK_MISC (otherlabel), 1.0, 0.5); - buglabel = gtk_label_new ("0"); - gtk_misc_set_alignment (GTK_MISC (buglabel), 1.0, 0.5); + buglabel = gtk_label_new ("0"); + gtk_misc_set_alignment (GTK_MISC (buglabel), 1.0, 0.5); - errlabel = gtk_label_new ("0"); - gtk_misc_set_alignment (GTK_MISC (errlabel), 1.0, 0.5); + errlabel = gtk_label_new ("0"); + gtk_misc_set_alignment (GTK_MISC (errlabel), 1.0, 0.5); - warnlabel = gtk_label_new ("0"); - gtk_misc_set_alignment (GTK_MISC (warnlabel), 1.0, 0.5); + warnlabel = gtk_label_new ("0"); + gtk_misc_set_alignment (GTK_MISC (warnlabel), 1.0, 0.5); - verblabel = gtk_label_new ("0"); - gtk_misc_set_alignment (GTK_MISC (verblabel), 1.0, 0.5); + verblabel = gtk_label_new ("0"); + gtk_misc_set_alignment (GTK_MISC (verblabel), 1.0, 0.5); - tracelabel = gtk_label_new ("0"); - gtk_misc_set_alignment (GTK_MISC (tracelabel), 1.0, 0.5); + tracelabel = gtk_label_new ("0"); + gtk_misc_set_alignment (GTK_MISC (tracelabel), 1.0, 0.5); - sumlabel = gtk_label_new (NULL); - gtk_label_set_use_markup (GTK_LABEL (sumlabel), TRUE); - gtk_label_set_markup (GTK_LABEL (sumlabel), "<b>0</b>"); - gtk_misc_set_alignment (GTK_MISC (sumlabel), 1.0, 0.5); + sumlabel = gtk_label_new (NULL); + gtk_label_set_use_markup (GTK_LABEL (sumlabel), TRUE); + gtk_label_set_markup (GTK_LABEL (sumlabel), "<b>0</b>"); + gtk_misc_set_alignment (GTK_MISC (sumlabel), 1.0, 0.5); - /* create table and add widgets */ - table = gtk_table_new (10, 2, TRUE); - gtk_table_set_col_spacings (GTK_TABLE (table), 5); - gtk_container_set_border_width (GTK_CONTAINER (table), 10); + /* create table and add widgets */ + table = gtk_table_new (10, 2, TRUE); + gtk_table_set_col_spacings (GTK_TABLE (table), 5); + gtk_container_set_border_width (GTK_CONTAINER (table), 10); - label = gtk_label_new (_("Hamlib")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), - label, - 0, 1, 0, 1); + label = gtk_label_new (_("Hamlib")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach_defaults (GTK_TABLE (table), + label, + 0, 1, 0, 1); - label = gtk_label_new (_("Gpredict")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), - label, - 0, 1, 1, 2); + label = gtk_label_new (_("Gpredict")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach_defaults (GTK_TABLE (table), + label, + 0, 1, 1, 2); - label = gtk_label_new (_("Other")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), - label, - 0, 1, 2, 3); + label = gtk_label_new (_("Other")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach_defaults (GTK_TABLE (table), + label, + 0, 1, 2, 3); - gtk_table_attach_defaults (GTK_TABLE (table), - gtk_hseparator_new (), - 0, 2, 3, 4); + gtk_table_attach_defaults (GTK_TABLE (table), + gtk_hseparator_new (), + 0, 2, 3, 4); - label = gtk_label_new (_("Bugs")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), - label, - 0, 1, 4, 5); + label = gtk_label_new (_("Bugs")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach_defaults (GTK_TABLE (table), + label, + 0, 1, 4, 5); - label = gtk_label_new (_("Errors")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), - label, - 0, 1, 5, 6); + label = gtk_label_new (_("Errors")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach_defaults (GTK_TABLE (table), + label, + 0, 1, 5, 6); - label = gtk_label_new (_("Warnings")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), - label, - 0, 1, 6, 7); + label = gtk_label_new (_("Warnings")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach_defaults (GTK_TABLE (table), + label, + 0, 1, 6, 7); - label = gtk_label_new (_("Messages")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), - label, - 0, 1, 7, 8); + label = gtk_label_new (_("Messages")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach_defaults (GTK_TABLE (table), + label, + 0, 1, 7, 8); - label = gtk_label_new (_("Debug")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), - label, - 0, 1, 8, 9); + label = gtk_label_new (_("Debug")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach_defaults (GTK_TABLE (table), + label, + 0, 1, 8, 9); - gtk_table_attach_defaults (GTK_TABLE (table), - gtk_hseparator_new (), - 0, 2, 9, 10); + gtk_table_attach_defaults (GTK_TABLE (table), + gtk_hseparator_new (), + 0, 2, 9, 10); - label = gtk_label_new (NULL); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_label_set_use_markup (GTK_LABEL (label), TRUE); - gtk_label_set_markup (GTK_LABEL (label), _("<b>Total</b>")); - gtk_table_attach_defaults (GTK_TABLE (table), - label, - 0, 1, 10, 11); + label = gtk_label_new (NULL); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + gtk_label_set_markup (GTK_LABEL (label), _("<b>Total</b>")); + gtk_table_attach_defaults (GTK_TABLE (table), + label, + 0, 1, 10, 11); - gtk_table_attach_defaults (GTK_TABLE (table), hamliblabel, - 1, 2, 0, 1); - gtk_table_attach_defaults (GTK_TABLE (table), gpredictlabel, - 1, 2, 1, 2); - gtk_table_attach_defaults (GTK_TABLE (table), otherlabel, - 1, 2, 2, 3); - gtk_table_attach_defaults (GTK_TABLE (table), buglabel, - 1, 2, 4, 5); - gtk_table_attach_defaults (GTK_TABLE (table), errlabel, - 1, 2, 5, 6); - gtk_table_attach_defaults (GTK_TABLE (table), warnlabel, - 1, 2, 6, 7); - gtk_table_attach_defaults (GTK_TABLE (table), verblabel, - 1, 2, 7, 8); - gtk_table_attach_defaults (GTK_TABLE (table), tracelabel, - 1, 2, 8, 9); - gtk_table_attach_defaults (GTK_TABLE (table), sumlabel, - 1, 2, 10, 11); + gtk_table_attach_defaults (GTK_TABLE (table), hamliblabel, + 1, 2, 0, 1); + gtk_table_attach_defaults (GTK_TABLE (table), gpredictlabel, + 1, 2, 1, 2); + gtk_table_attach_defaults (GTK_TABLE (table), otherlabel, + 1, 2, 2, 3); + gtk_table_attach_defaults (GTK_TABLE (table), buglabel, + 1, 2, 4, 5); + gtk_table_attach_defaults (GTK_TABLE (table), errlabel, + 1, 2, 5, 6); + gtk_table_attach_defaults (GTK_TABLE (table), warnlabel, + 1, 2, 6, 7); + gtk_table_attach_defaults (GTK_TABLE (table), verblabel, + 1, 2, 7, 8); + gtk_table_attach_defaults (GTK_TABLE (table), tracelabel, + 1, 2, 8, 9); + gtk_table_attach_defaults (GTK_TABLE (table), sumlabel, + 1, 2, 10, 11); - /* frame around the table */ - frame = gtk_frame_new (_(" Summary ")); - gtk_frame_set_label_align (GTK_FRAME (frame), 0.5, 0.5); - gtk_container_add (GTK_CONTAINER (frame), table); + /* frame around the table */ + frame = gtk_frame_new (_(" Summary ")); + gtk_frame_set_label_align (GTK_FRAME (frame), 0.5, 0.5); + gtk_container_add (GTK_CONTAINER (frame), table); - /* pack frame into vbox so that it doesn't gets streched vertically */ - vbox = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); + /* pack frame into vbox so that it doesn't gets streched vertically */ + vbox = gtk_vbox_new (FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); - return vbox; + return vbox; } Modified: trunk/src/sat-log.c =================================================================== --- trunk/src/sat-log.c 2009-08-06 18:35:11 UTC (rev 381) +++ trunk/src/sat-log.c 2009-08-06 18:55:50 UTC (rev 382) @@ -30,7 +30,7 @@ * * This component is responsible for logging the debug messages * coming from gpredict and hamlib. Debug messages are stored - * in $HOME/.gpredict2/logs/gpredict.log during runtime. + * in USER_CONF_DIR/logs/gpredict.log during runtime. * * During initialisation, gpredict removes the previous gpredict.log * file to allow the creation of the new one. However, the user can @@ -48,6 +48,7 @@ #ifdef HAVE_CONFIG_H # include <build-config.h> #endif +#include "compat.h" #include "sat-cfg.h" #include "sat-log.h" @@ -75,7 +76,7 @@ /** \brief Initialise message logger. * * This function initialises the debug message logger. First, it - * checks that the directory $HOME/.gpredict2/logs/ exists, if not it + * checks that the directory USER_CONF_DIR/logs/ exists, if not it * creates it. * Then, if there is a gpredict.log file it is either deleted or * renamed, depending on the sat-cfg settings. @@ -84,16 +85,16 @@ void sat_log_init () { - gchar *dirname,*filename; + gchar *dirname,*filename,*confdir; gboolean err = FALSE; GError *error = NULL; /* Check whether log directory exists, if not, create it */ - dirname = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "logs", NULL); + confdir = get_user_conf_dir (); + dirname = g_strconcat (confdir, G_DIR_SEPARATOR_S, "logs", NULL); + g_free (confdir); if (!g_file_test (dirname, G_FILE_TEST_IS_DIR)) { if (g_mkdir_with_parents (dirname, 0755)) { @@ -287,14 +288,14 @@ GTimeVal now; /* current time */ glong age; /* age for cleaning */ glong then; /* time in sec corresponding to age */ - gchar *dirname,*fname1,*fname2; + gchar *confdir,*dirname,*fname1,*fname2; /* initialise some vars */ g_get_current_time (&now); - dirname = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "logs", NULL); + confdir = get_user_conf_dir (); + dirname = g_strconcat (confdir, G_DIR_SEPARATOR_S, "logs", NULL); + fname1 = g_strconcat (dirname, G_DIR_SEPARATOR_S, "gpredict.log", NULL); fname2 = g_strdup_printf ("%s%sgpredict-%ld.log", dirname, G_DIR_SEPARATOR_S, now.tv_sec); @@ -315,7 +316,7 @@ g_free (dirname); g_free (fname1); g_free (fname2); - + g_free (confdir); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-06 19:31:47
|
Revision: 383 http://gpredict.svn.sourceforge.net/gpredict/?rev=383&view=rev Author: csete Date: 2009-08-06 19:31:38 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Migrated to new user configuration. Modified Paths: -------------- trunk/src/sat-cfg.c trunk/src/sat-pref-map-view.c trunk/src/sat-pref-qth.c Modified: trunk/src/sat-cfg.c =================================================================== --- trunk/src/sat-cfg.c 2009-08-06 18:55:50 UTC (rev 382) +++ trunk/src/sat-cfg.c 2009-08-06 19:31:38 UTC (rev 383) @@ -11,7 +11,7 @@ More details can be found at the project home page: http://gpredict.oz9aec.net/ - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or @@ -43,48 +43,49 @@ #include "gtk-polar-view.h" #include "gtk-single-sat.h" #include "sat-pass-dialogs.h" +#include "compat.h" #include "sat-cfg.h" #define LIST_COLUMNS_DEFAULTS (SAT_LIST_FLAG_NAME |\ - SAT_LIST_FLAG_AZ |\ - SAT_LIST_FLAG_EL |\ - SAT_LIST_FLAG_RANGE |\ - SAT_LIST_FLAG_DIR |\ - SAT_LIST_FLAG_NEXT_EVENT |\ - SAT_LIST_FLAG_ALT |\ - SAT_LIST_FLAG_ORBIT) +SAT_LIST_FLAG_AZ |\ + SAT_LIST_FLAG_EL |\ + SAT_LIST_FLAG_RANGE |\ + SAT_LIST_FLAG_DIR |\ + SAT_LIST_FLAG_NEXT_EVENT |\ + SAT_LIST_FLAG_ALT |\ + SAT_LIST_FLAG_ORBIT) #define SINGLE_PASS_COL_DEFAULTS (SINGLE_PASS_FLAG_TIME |\ - SINGLE_PASS_FLAG_AZ |\ - SINGLE_PASS_FLAG_EL |\ - SINGLE_PASS_FLAG_RANGE |\ - SINGLE_PASS_FLAG_FOOTPRINT) +SINGLE_PASS_FLAG_AZ |\ +SINGLE_PASS_FLAG_EL |\ +SINGLE_PASS_FLAG_RANGE |\ +SINGLE_PASS_FLAG_FOOTPRINT) #define MULTI_PASS_COL_DEFAULTS (MULTI_PASS_FLAG_AOS_TIME |\ - MULTI_PASS_FLAG_LOS_TIME |\ - MULTI_PASS_FLAG_DURATION |\ - MULTI_PASS_FLAG_AOS_AZ |\ - MULTI_PASS_FLAG_MAX_EL |\ - MULTI_PASS_FLAG_LOS_AZ) +MULTI_PASS_FLAG_LOS_TIME |\ +MULTI_PASS_FLAG_DURATION |\ +MULTI_PASS_FLAG_AOS_AZ |\ +MULTI_PASS_FLAG_MAX_EL |\ +MULTI_PASS_FLAG_LOS_AZ) #define SINGLE_SAT_FIELD_DEF (SINGLE_SAT_FLAG_AZ |\ - SINGLE_SAT_FLAG_EL |\ - SINGLE_SAT_FLAG_RANGE |\ - SINGLE_SAT_FLAG_RANGE_RATE |\ - SINGLE_SAT_FLAG_NEXT_EVENT |\ - SINGLE_SAT_FLAG_SSP |\ - SINGLE_SAT_FLAG_FOOTPRINT |\ - SINGLE_SAT_FLAG_ALT |\ - SINGLE_SAT_FLAG_VEL |\ - SINGLE_SAT_FLAG_DOPPLER |\ - SINGLE_SAT_FLAG_LOSS |\ - SINGLE_SAT_FLAG_DELAY |\ - SINGLE_SAT_FLAG_MA |\ - SINGLE_SAT_FLAG_PHASE |\ - SINGLE_SAT_FLAG_ORBIT |\ - SINGLE_SAT_FLAG_VISIBILITY) +SINGLE_SAT_FLAG_EL |\ +SINGLE_SAT_FLAG_RANGE |\ +SINGLE_SAT_FLAG_RANGE_RATE |\ +SINGLE_SAT_FLAG_NEXT_EVENT |\ +SINGLE_SAT_FLAG_SSP |\ +SINGLE_SAT_FLAG_FOOTPRINT |\ +SINGLE_SAT_FLAG_ALT |\ +SINGLE_SAT_FLAG_VEL |\ +SINGLE_SAT_FLAG_DOPPLER |\ +SINGLE_SAT_FLAG_LOSS |\ +SINGLE_SAT_FLAG_DELAY |\ +SINGLE_SAT_FLAG_MA |\ +SINGLE_SAT_FLAG_PHASE |\ +SINGLE_SAT_FLAG_ORBIT |\ +SINGLE_SAT_FLAG_VISIBILITY) /** \brief Structure representing a boolean value */ typedef struct { @@ -180,26 +181,26 @@ { "PREDICT", "SAVE_CONTENTS", 0}, { "PREDICT", "TWILIGHT_THRESHOLD", -6}, { "SKY_AT_GLANCE", "TIME_SPAN_HOURS", 8}, - { "SKY_AT_GLANCE", "COLOUR_01", 0x3c46c8}, - { "SKY_AT_GLANCE", "COLOUR_02", 0x00500a}, - { "SKY_AT_GLANCE", "COLOUR_03", 0xd5472b}, - { "SKY_AT_GLANCE", "COLOUR_04", 0xd06b38}, - { "SKY_AT_GLANCE", "COLOUR_05", 0xcf477a}, - { "SKY_AT_GLANCE", "COLOUR_06", 0xbf041f}, - { "SKY_AT_GLANCE", "COLOUR_07", 0x04bf20}, - { "SKY_AT_GLANCE", "COLOUR_08", 0x0420bf}, - { "SKY_AT_GLANCE", "COLOUR_09", 0xa304bf}, - { "SKY_AT_GLANCE", "COLOUR_10", 0x04bdbf}, - { "GLOBAL", "WINDOW_POS_X", 0}, - { "GLOBAL", "WINDOW_POS_Y", 0}, - { "GLOBAL", "WINDOW_WIDTH", 700}, - { "GLOBAL", "WINDOW_HEIGHT", 700}, - { "GLOBAL", "HTML_BROWSER_TYPE", 0}, - { "TLE", "AUTO_UPDATE_FREQ", 2}, - { "TLE", "AUTO_UPDATE_ACTION", 1}, - { "TLE", "LAST_UPDATE", 0}, - { "LOG", "CLEAN_AGE", 0}, /* 0 = Never clean */ - { "LOG", "LEVEL", 4} +{ "SKY_AT_GLANCE", "COLOUR_01", 0x3c46c8}, +{ "SKY_AT_GLANCE", "COLOUR_02", 0x00500a}, +{ "SKY_AT_GLANCE", "COLOUR_03", 0xd5472b}, +{ "SKY_AT_GLANCE", "COLOUR_04", 0xd06b38}, +{ "SKY_AT_GLANCE", "COLOUR_05", 0xcf477a}, +{ "SKY_AT_GLANCE", "COLOUR_06", 0xbf041f}, +{ "SKY_AT_GLANCE", "COLOUR_07", 0x04bf20}, +{ "SKY_AT_GLANCE", "COLOUR_08", 0x0420bf}, +{ "SKY_AT_GLANCE", "COLOUR_09", 0xa304bf}, +{ "SKY_AT_GLANCE", "COLOUR_10", 0x04bdbf}, +{ "GLOBAL", "WINDOW_POS_X", 0}, +{ "GLOBAL", "WINDOW_POS_Y", 0}, +{ "GLOBAL", "WINDOW_WIDTH", 700}, +{ "GLOBAL", "WINDOW_HEIGHT", 700}, +{ "GLOBAL", "HTML_BROWSER_TYPE", 0}, +{ "TLE", "AUTO_UPDATE_FREQ", 2}, +{ "TLE", "AUTO_UPDATE_ACTION", 1}, +{ "TLE", "LAST_UPDATE", 0}, +{ "LOG", "CLEAN_AGE", 0}, /* 0 = Never clean */ +{ "LOG", "LEVEL", 4} }; @@ -214,16 +215,16 @@ { "MODULES", "POLAR_FONT", "Sans 10"}, { "TLE", "SERVER", "http://www.celestrak.com/NORAD/elements/"}, { "TLE", "FILES", "amateur.txt;cubesat.txt;galileo.txt;geo.txt;gps-ops.txt;"\ - "iridium.txt;military.txt;radar.txt;science.txt;weather.txt"}, - { "TLE", "PROXY", NULL}, - { "TLE", "FILE_DIR", NULL}, - { "TLE", "EXTENSION", "*.*"}, - { "PREDICT", "SAVE_DIR", NULL} + "iridium.txt;military.txt;radar.txt;science.txt;weather.txt"}, +{ "TLE", "PROXY", NULL}, +{ "TLE", "FILE_DIR", NULL}, +{ "TLE", "EXTENSION", "*.*"}, +{ "PREDICT", "SAVE_DIR", NULL} }; - + /* The configuration data buffer */ static GKeyFile *config = NULL; @@ -239,9 +240,9 @@ * be ereased first. */ guint -sat_cfg_load () + sat_cfg_load () { - gchar *keyfile; + gchar *keyfile,*confdir; GError *error = NULL; if (config != NULL) @@ -249,9 +250,9 @@ /* load the configuration file */ config = g_key_file_new (); - keyfile = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "gpredict.cfg", NULL); + confdir = get_user_conf_dir (); + keyfile = g_strconcat (confdir, G_DIR_SEPARATOR_S, "gpredict.cfg", NULL); + g_free (confdir); g_key_file_load_from_file (config, keyfile, G_KEY_FILE_KEEP_COMMENTS, &error); @@ -260,12 +261,12 @@ if (error != NULL) { sat_log_log (SAT_LOG_LEVEL_WARN, - _("%s: Error reading config file (%s)"), - __FUNCTION__, error->message); + _("%s: Error reading config file (%s)"), + __FUNCTION__, error->message); sat_log_log (SAT_LOG_LEVEL_WARN, - _("%s: Using built-in defaults"), - __FUNCTION__); + _("%s: Using built-in defaults"), + __FUNCTION__); g_clear_error (&error); @@ -273,7 +274,7 @@ } else { sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Everything OK."), __FUNCTION__); + _("%s: Everything OK."), __FUNCTION__); } return 0; @@ -287,13 +288,14 @@ * memory to the gpredict.cfg file. */ guint -sat_cfg_save () + sat_cfg_save () { gsize length; gsize written; GError *error = NULL; gchar *cfgstr; gchar *keyfile; + gchar *confdir; GIOChannel *cfgfile; guint err = 0; @@ -302,27 +304,25 @@ if (error != NULL) { sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Could not create config data (%s)."), - __FUNCTION__, error->message); + _("%s: Could not create config data (%s)."), + __FUNCTION__, error->message); g_clear_error (&error); err = 1; } else { - - /* create and open a file for writing */ - keyfile = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "gpredict.cfg", NULL); + confdir = get_user_conf_dir (); + keyfile = g_strconcat (confdir, G_DIR_SEPARATOR_S, "gpredict.cfg", NULL); + g_free (confdir); cfgfile = g_io_channel_new_file (keyfile, "w", &error); g_free (keyfile); if (error != NULL) { sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Could not create config file (%s)."), - __FUNCTION__, error->message); + _("%s: Could not create config file (%s)."), + __FUNCTION__, error->message); g_clear_error (&error); @@ -330,18 +330,18 @@ } else { g_io_channel_write_chars (cfgfile, - cfgstr, - length, - &written, - &error); + cfgstr, + length, + &written, + &error); g_io_channel_shutdown (cfgfile, TRUE, NULL); g_io_channel_unref (cfgfile); if (error != NULL) { sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Error writing config data (%s)."), - __FUNCTION__, error->message); + _("%s: Error writing config data (%s)."), + __FUNCTION__, error->message); g_clear_error (&error); @@ -349,15 +349,15 @@ } else if (length != written) { sat_log_log (SAT_LOG_LEVEL_WARN, - _("%s: Wrote only %d out of %d chars."), - __FUNCTION__, written, length); + _("%s: Wrote only %d out of %d chars."), + __FUNCTION__, written, length); err = 1; } else { sat_log_log (SAT_LOG_LEVEL_MSG, - _("%s: Configuration saved."), - __FUNCTION__); + _("%s: Configuration saved."), + __FUNCTION__); err = 0; } @@ -379,7 +379,7 @@ * program exits. */ void -sat_cfg_close () + sat_cfg_close () { if (config != NULL) { g_key_file_free (config); @@ -390,7 +390,7 @@ /** \brief Get boolean value */ gboolean -sat_cfg_get_bool (sat_cfg_bool_e param) + sat_cfg_get_bool (sat_cfg_bool_e param) { gboolean value = FALSE; GError *error = NULL; @@ -399,8 +399,8 @@ if (config == NULL) { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Module not initialised\n"), - __FUNCTION__); + _("%s: Module not initialised\n"), + __FUNCTION__); /* return default value */ value = sat_cfg_bool[param].defval; @@ -422,8 +422,8 @@ } else { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown BOOL param index (%d)\n"), - __FUNCTION__, param); + _("%s: Unknown BOOL param index (%d)\n"), + __FUNCTION__, param); } return value; @@ -431,7 +431,7 @@ /** \brief Get default value of boolean parameter */ gboolean -sat_cfg_get_bool_def (sat_cfg_bool_e param) + sat_cfg_get_bool_def (sat_cfg_bool_e param) { gboolean value = FALSE; @@ -440,8 +440,8 @@ } else { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown BOOL param index (%d)\n"), - __FUNCTION__, param); + _("%s: Unknown BOOL param index (%d)\n"), + __FUNCTION__, param); } return value; @@ -455,15 +455,15 @@ * table. */ void -sat_cfg_set_bool (sat_cfg_bool_e param, gboolean value) + sat_cfg_set_bool (sat_cfg_bool_e param, gboolean value) { if (param < SAT_CFG_BOOL_NUM) { if (config == NULL) { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Module not initialised\n"), - __FUNCTION__); + _("%s: Module not initialised\n"), + __FUNCTION__); } else { g_key_file_set_boolean (config, @@ -475,34 +475,34 @@ } else { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown BOOL param index (%d)\n"), - __FUNCTION__, param); + _("%s: Unknown BOOL param index (%d)\n"), + __FUNCTION__, param); } } void -sat_cfg_reset_bool (sat_cfg_bool_e param) + sat_cfg_reset_bool (sat_cfg_bool_e param) { if (param < SAT_CFG_BOOL_NUM) { if (config == NULL) { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Module not initialised\n"), - __FUNCTION__); + _("%s: Module not initialised\n"), + __FUNCTION__); } else { g_key_file_remove_key (config, - sat_cfg_bool[param].group, - sat_cfg_bool[param].key, - NULL); + sat_cfg_bool[param].group, + sat_cfg_bool[param].key, + NULL); } } else { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown BOOL param index (%d)\n"), - __FUNCTION__, param); + _("%s: Unknown BOOL param index (%d)\n"), + __FUNCTION__, param); } } @@ -512,7 +512,7 @@ * Return a newly allocated gchar * which must be freed when no longer needed. */ gchar * -sat_cfg_get_str (sat_cfg_str_e param) + sat_cfg_get_str (sat_cfg_str_e param) { gchar *value; GError *error = NULL; @@ -521,8 +521,8 @@ if (config == NULL) { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Module not initialised\n"), - __FUNCTION__); + _("%s: Module not initialised\n"), + __FUNCTION__); /* return default value */ value = g_strdup (sat_cfg_str[param].defval); @@ -530,9 +530,9 @@ else { /* fetch value */ value = g_key_file_get_string (config, - sat_cfg_str[param].group, - sat_cfg_str[param].key, - &error); + sat_cfg_str[param].group, + sat_cfg_str[param].key, + &error); if (error != NULL) { g_clear_error (&error); @@ -544,8 +544,8 @@ } else { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown STR param index (%d)\n"), - __FUNCTION__, param); + _("%s: Unknown STR param index (%d)\n"), + __FUNCTION__, param); value = g_strdup ("ERROR"); } @@ -558,7 +558,7 @@ * Returns a newly allocated gchar * which must be freed when no longer needed. */ gchar * -sat_cfg_get_str_def (sat_cfg_str_e param) + sat_cfg_get_str_def (sat_cfg_str_e param) { gchar *value; @@ -567,8 +567,8 @@ } else { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown STR param index (%d)\n"), - __FUNCTION__, param); + _("%s: Unknown STR param index (%d)\n"), + __FUNCTION__, param); value = g_strdup ("ERROR"); } @@ -579,69 +579,69 @@ /** \brief Store a str configuration value. */ void -sat_cfg_set_str (sat_cfg_str_e param, const gchar *value) + sat_cfg_set_str (sat_cfg_str_e param, const gchar *value) { if (param < SAT_CFG_STR_NUM) { if (config == NULL) { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Module not initialised\n"), - __FUNCTION__); + _("%s: Module not initialised\n"), + __FUNCTION__); } else { if (value) { g_key_file_set_string (config, - sat_cfg_str[param].group, - sat_cfg_str[param].key, - value); + sat_cfg_str[param].group, + sat_cfg_str[param].key, + value); } else { /* remove key from config */ g_key_file_remove_key (config, - sat_cfg_str[param].group, - sat_cfg_str[param].key, - NULL); + sat_cfg_str[param].group, + sat_cfg_str[param].key, + NULL); } } } else { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown STR param index (%d)\n"), - __FUNCTION__, param); + _("%s: Unknown STR param index (%d)\n"), + __FUNCTION__, param); } } void -sat_cfg_reset_str (sat_cfg_str_e param) + sat_cfg_reset_str (sat_cfg_str_e param) { if (param < SAT_CFG_STR_NUM) { if (config == NULL) { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Module not initialised\n"), - __FUNCTION__); + _("%s: Module not initialised\n"), + __FUNCTION__); } else { g_key_file_remove_key (config, - sat_cfg_str[param].group, - sat_cfg_str[param].key, - NULL); + sat_cfg_str[param].group, + sat_cfg_str[param].key, + NULL); } } else { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown STR param index (%d)\n"), - __FUNCTION__, param); + _("%s: Unknown STR param index (%d)\n"), + __FUNCTION__, param); } } gint -sat_cfg_get_int (sat_cfg_int_e param) + sat_cfg_get_int (sat_cfg_int_e param) { gint value = 0; GError *error = NULL; @@ -650,8 +650,8 @@ if (config == NULL) { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Module not initialised\n"), - __FUNCTION__); + _("%s: Module not initialised\n"), + __FUNCTION__); /* return default value */ value = sat_cfg_int[param].defval; @@ -673,8 +673,8 @@ } else { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown INT param index (%d)\n"), - __FUNCTION__, param); + _("%s: Unknown INT param index (%d)\n"), + __FUNCTION__, param); } return value; @@ -682,7 +682,7 @@ gint -sat_cfg_get_int_def (sat_cfg_int_e param) + sat_cfg_get_int_def (sat_cfg_int_e param) { gint value = 0; @@ -691,8 +691,8 @@ } else { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown INT param index (%d)\n"), - __FUNCTION__, param); + _("%s: Unknown INT param index (%d)\n"), + __FUNCTION__, param); } return value; @@ -700,14 +700,14 @@ void -sat_cfg_set_int (sat_cfg_int_e param, gint value) + sat_cfg_set_int (sat_cfg_int_e param, gint value) { if (param < SAT_CFG_INT_NUM) { if (config == NULL) { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Module not initialised\n"), - __FUNCTION__); + _("%s: Module not initialised\n"), + __FUNCTION__); } else { g_key_file_set_integer (config, @@ -719,34 +719,34 @@ } else { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown INT param index (%d)\n"), - __FUNCTION__, param); + _("%s: Unknown INT param index (%d)\n"), + __FUNCTION__, param); } } void -sat_cfg_reset_int (sat_cfg_int_e param) + sat_cfg_reset_int (sat_cfg_int_e param) { if (param < SAT_CFG_INT_NUM) { if (config == NULL) { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Module not initialised\n"), - __FUNCTION__); + _("%s: Module not initialised\n"), + __FUNCTION__); } else { g_key_file_remove_key (config, - sat_cfg_int[param].group, - sat_cfg_int[param].key, - NULL); + sat_cfg_int[param].group, + sat_cfg_int[param].key, + NULL); } } else { sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Unknown INT param index (%d)\n"), - __FUNCTION__, param); + _("%s: Unknown INT param index (%d)\n"), + __FUNCTION__, param); } } Modified: trunk/src/sat-pref-map-view.c =================================================================== --- trunk/src/sat-pref-map-view.c 2009-08-06 18:55:50 UTC (rev 382) +++ trunk/src/sat-pref-map-view.c 2009-08-06 19:31:38 UTC (rev 383) @@ -146,7 +146,7 @@ mapf = sat_cfg_get_str (SAT_CFG_STR_MAP_FILE); } if (g_path_is_absolute (mapf)) { - /* map is user specific, ie. in $HOME/.gpredict2/maps/ */ + /* map is user specific, ie. in USER_CONF_DIR/maps/ */ mapfile = g_strdup (mapf); } else { @@ -1177,7 +1177,7 @@ if (g_path_is_absolute (mapf)) { - /* map is user specific, ie. in $HOME/.gpredict2/maps/ */ + /* map is user specific, ie. in USER_CONF_DIR/maps/ */ mapfile = g_strdup (mapf); } else { Modified: trunk/src/sat-pref-qth.c =================================================================== --- trunk/src/sat-pref-qth.c 2009-08-06 18:55:50 UTC (rev 382) +++ trunk/src/sat-pref-qth.c 2009-08-06 19:31:38 UTC (rev 383) @@ -39,6 +39,7 @@ #include "sat-pref-qth-data.h" #include "sat-pref-qth-editor.h" #include "locator.h" +#include "compat.h" @@ -100,7 +101,7 @@ /** \brief Create and initialise widgets for the locations prefs tab. * * The QTH tab consists of two main parts: A list showing the configured - * locations (.qth files in $HOME/.gpredict2/ and three buttons beside the list: + * locations (.qth files in USER_CONF_DIR/ and three buttons beside the list: * Add Add a new location to the list * Edit Edit selected location * Delete Delete selected location @@ -298,8 +299,7 @@ /* scan for .qth files in the user config directory and add the contents of each .qth file to the list store */ - dirname = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", NULL); + dirname = get_user_conf_dir (); dir = g_dir_open (dirname, 0, &error); @@ -824,8 +824,8 @@ gpointer data) { qth_t qth; - gboolean def = FALSE; - gchar *filename; + gboolean def = FALSE; + gchar *filename,*confdir; gchar *buff; @@ -840,13 +840,9 @@ QTH_LIST_COL_WX, &qth.wx, -1); - filename = g_strconcat (g_get_home_dir (), - G_DIR_SEPARATOR_S, - ".gpredict2", - G_DIR_SEPARATOR_S, - qth.name, - ".qth", - NULL); + confdir = get_user_conf_dir (); + filename = g_strconcat (confdir, G_DIR_SEPARATOR_S, qth.name, ".qth", NULL); + g_free (confdir); /* check wehter we are using imperial or metric system; in case of imperial we have to convert altitude from @@ -900,8 +896,7 @@ /* scan for .qth files in the user config directory and add the contents of each .qth file to the list store */ - dirname = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", NULL); + dirname = get_user_conf_dir (); dir = g_dir_open (dirname, 0, &error); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-06 21:08:39
|
Revision: 387 http://gpredict.svn.sourceforge.net/gpredict/?rev=387&view=rev Author: csete Date: 2009-08-06 21:08:29 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Uset sat->nickname instead of sat->tle.sat_name. Modified Paths: -------------- trunk/src/gtk-polar-view-popup.c trunk/src/gtk-polar-view.c trunk/src/gtk-rig-ctrl.c trunk/src/gtk-rot-ctrl.c trunk/src/gtk-sat-data.c trunk/src/gtk-sat-list-popup.c trunk/src/gtk-sat-list.c trunk/src/gtk-sat-map-ground-track.c trunk/src/gtk-sat-map-popup.c trunk/src/gtk-sat-map.c trunk/src/gtk-sat-module.c trunk/src/gtk-single-sat.c trunk/src/gtk-sky-glance.c trunk/src/main.c trunk/src/predict-tools.c trunk/src/sat-info.c Modified: trunk/src/gtk-polar-view-popup.c =================================================================== --- trunk/src/gtk-polar-view-popup.c 2009-08-06 20:44:36 UTC (rev 386) +++ trunk/src/gtk-polar-view-popup.c 2009-08-06 21:08:29 UTC (rev 387) @@ -85,7 +85,7 @@ menuitem = gtk_image_menu_item_new (); label = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5); - buff = g_strdup_printf ("<b>%s</b>", sat->tle.sat_name); + buff = g_strdup_printf ("<b>%s</b>", sat->nickname); gtk_label_set_markup (GTK_LABEL (label), buff); g_free (buff); gtk_container_add (GTK_CONTAINER (menuitem), label); @@ -392,7 +392,7 @@ } if (pass != NULL) { - show_pass (sat->tle.sat_name, qth, pass, GTK_WIDGET (toplevel)); + show_pass (sat->nickname, qth, pass, GTK_WIDGET (toplevel)); } else { /* show dialog that there are no passes within time frame */ @@ -403,7 +403,7 @@ GTK_BUTTONS_OK, _("Satellite %s has no passes\n"\ "within the next %d days"), - sat->tle.sat_name, + sat->nickname, sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); gtk_dialog_run (GTK_DIALOG (dialog)); @@ -422,7 +422,7 @@ "This can be because the satellite\n"\ "is geostationary, decayed or simply\n"\ "never comes above the horizon"), - sat->tle.sat_name); + sat->nickname); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); @@ -462,7 +462,7 @@ if (passes != NULL) { - show_passes (sat->tle.sat_name, qth, passes, GTK_WIDGET (toplevel)); + show_passes (sat->nickname, qth, passes, GTK_WIDGET (toplevel)); } else { /* show dialog that there are no passes within time frame */ @@ -473,7 +473,7 @@ GTK_BUTTONS_OK, _("Satellite %s has no passes\n"\ "within the next %d days"), - sat->tle.sat_name, + sat->nickname, sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); gtk_dialog_run (GTK_DIALOG (dialog)); @@ -492,7 +492,7 @@ GTK_BUTTONS_OK, _("Satellite %s has no passes for\n"\ "the current ground station!"), - sat->tle.sat_name); + sat->nickname); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); Modified: trunk/src/gtk-polar-view.c =================================================================== --- trunk/src/gtk-polar-view.c 2009-08-06 20:44:36 UTC (rev 386) +++ trunk/src/gtk-polar-view.c 2009-08-06 21:08:29 UTC (rev 387) @@ -731,10 +731,10 @@ if (h > 0) buff = g_strdup_printf (_("Next: %s\nin %s%d:%s%d%s%d"), - sat->tle.sat_name, ch, h, cm, m, cs, s); + sat->nickname, ch, h, cm, m, cs, s); else buff = g_strdup_printf (_("Next: %s\nin %s%d%s%d"), - sat->tle.sat_name, cm, m, cs, s); + sat->nickname, cm, m, cs, s); g_object_set (polv->next, @@ -914,18 +914,18 @@ if (h > 0) { text = g_strdup_printf (_("%s\nLOS in %s%d:%s%d%s%d"), - sat->tle.sat_name, ch, h, cm, m, cs, s); + sat->nickname, ch, h, cm, m, cs, s); } else { text = g_strdup_printf (_("%s\nLOS in %s%d%s%d"), - sat->tle.sat_name, cm, m, cs, s); + sat->nickname, cm, m, cs, s); } g_free (ch); g_free (cm); g_free (cs); } else { - text = g_strdup_printf (_("%s\nAlways in range"), sat->tle.sat_name); + text = g_strdup_printf (_("%s\nAlways in range"), sat->nickname); } g_object_set (polv->sel, "text", text, NULL); @@ -956,7 +956,7 @@ "fill-color-rgba", colour, "stroke-color-rgba", colour, NULL); - obj->label = goo_canvas_text_model_new (root, sat->tle.sat_name, + obj->label = goo_canvas_text_model_new (root, sat->nickname, x, y+2, -1, Modified: trunk/src/gtk-rig-ctrl.c =================================================================== --- trunk/src/gtk-rig-ctrl.c 2009-08-06 20:44:36 UTC (rev 386) +++ trunk/src/gtk-rig-ctrl.c 2009-08-06 21:08:29 UTC (rev 387) @@ -524,7 +524,7 @@ for (i = 0; i < n; i++) { sat = SAT (g_slist_nth_data (ctrl->sats, i)); if (sat) { - gtk_combo_box_append_text (GTK_COMBO_BOX (satsel), sat->tle.sat_name); + gtk_combo_box_append_text (GTK_COMBO_BOX (satsel), sat->nickname); } } gtk_combo_box_set_active (GTK_COMBO_BOX (satsel), 0); Modified: trunk/src/gtk-rot-ctrl.c =================================================================== --- trunk/src/gtk-rot-ctrl.c 2009-08-06 20:44:36 UTC (rev 386) +++ trunk/src/gtk-rot-ctrl.c 2009-08-06 21:08:29 UTC (rev 387) @@ -413,7 +413,7 @@ for (i = 0; i < n; i++) { sat = SAT (g_slist_nth_data (ctrl->sats, i)); if (sat) { - gtk_combo_box_append_text (GTK_COMBO_BOX (satsel), sat->tle.sat_name); + gtk_combo_box_append_text (GTK_COMBO_BOX (satsel), sat->nickname); } } gtk_combo_box_set_active (GTK_COMBO_BOX (satsel), 0); Modified: trunk/src/gtk-sat-data.c =================================================================== --- trunk/src/gtk-sat-data.c 2009-08-06 20:44:36 UTC (rev 386) +++ trunk/src/gtk-sat-data.c 2009-08-06 21:08:29 UTC (rev 387) @@ -265,8 +265,8 @@ dest->tle.elset = source->tle.elset; dest->tle.revnum = source->tle.revnum; - for (i = 0; i < 25; i++) - dest->tle.sat_name[i] = source->tle.sat_name[i]; + dest->name = g_strdup (source->name); + dest->nickname = g_strdup (source->nickname); for (i = 0; i < 9; i++) dest->tle.idesg[i] = source->tle.idesg[i]; Modified: trunk/src/gtk-sat-list-popup.c =================================================================== --- trunk/src/gtk-sat-list-popup.c 2009-08-06 20:44:36 UTC (rev 386) +++ trunk/src/gtk-sat-list-popup.c 2009-08-06 21:08:29 UTC (rev 387) @@ -72,7 +72,7 @@ menuitem = gtk_image_menu_item_new (); label = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5); - buff = g_strdup_printf ("<b>%s</b>", sat->tle.sat_name); + buff = g_strdup_printf ("<b>%s</b>", sat->nickname); gtk_label_set_markup (GTK_LABEL (label), buff); g_free (buff); gtk_container_add (GTK_CONTAINER (menuitem), label); @@ -164,7 +164,7 @@ } if (pass != NULL) { - show_pass (sat->tle.sat_name, qth, pass, GTK_WIDGET (toplevel)); + show_pass (sat->nickname, qth, pass, GTK_WIDGET (toplevel)); } else { /* show dialog that there are no passes within time frame */ @@ -175,7 +175,7 @@ GTK_BUTTONS_OK, _("Satellite %s has no passes\n"\ "within the next %d days"), - sat->tle.sat_name, + sat->nickname, sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); gtk_dialog_run (GTK_DIALOG (dialog)); @@ -194,7 +194,7 @@ "This can be because the satellite\n"\ "is geostationary, decayed or simply\n"\ "never comes above the horizon"), - sat->tle.sat_name); + sat->nickname); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); @@ -234,7 +234,7 @@ } if (passes != NULL) { - show_passes (sat->tle.sat_name, qth, passes, GTK_WIDGET (toplevel)); + show_passes (sat->nickname, qth, passes, GTK_WIDGET (toplevel)); } else { /* show dialog that there are no passes within time frame */ @@ -245,7 +245,7 @@ GTK_BUTTONS_OK, _("Satellite %s has no passes\n"\ "within the next %d days"), - sat->tle.sat_name, + sat->nickname, sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); gtk_dialog_run (GTK_DIALOG (dialog)); @@ -264,7 +264,7 @@ GTK_BUTTONS_OK, _("Satellite %s has no passes for\n"\ "the current ground station!"), - sat->tle.sat_name); + sat->nickname); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); Modified: trunk/src/gtk-sat-list.c =================================================================== --- trunk/src/gtk-sat-list.c 2009-08-06 20:44:36 UTC (rev 386) +++ trunk/src/gtk-sat-list.c 2009-08-06 21:08:29 UTC (rev 387) @@ -483,7 +483,7 @@ gtk_list_store_append (store, &item); gtk_list_store_set (store, &item, - SAT_LIST_COL_NAME, sat->tle.sat_name, + SAT_LIST_COL_NAME, sat->nickname, SAT_LIST_COL_CATNUM, sat->tle.catnr, SAT_LIST_COL_AZ, sat->az, SAT_LIST_COL_EL, sat->el, Modified: trunk/src/gtk-sat-map-ground-track.c =================================================================== --- trunk/src/gtk-sat-map-ground-track.c 2009-08-06 20:44:36 UTC (rev 386) +++ trunk/src/gtk-sat-map-ground-track.c 2009-08-06 21:08:29 UTC (rev 387) @@ -80,7 +80,7 @@ sat_log_log (SAT_LOG_LEVEL_DEBUG, _("%s: Creating ground track for %s"), - __FUNCTION__, sat->tle.sat_name); + __FUNCTION__, sat->nickname); /* just to be safe... if empty GSList is not NULL => segfault */ obj->track_data.latlon = NULL; @@ -189,7 +189,7 @@ { sat_log_log (SAT_LOG_LEVEL_DEBUG, _("%s: Updating ground track for %s"), - __FUNCTION__, sat->tle.sat_name); + __FUNCTION__, sat->nickname); if (recalc == TRUE) { ground_track_delete (satmap, sat, qth, obj, TRUE); @@ -219,7 +219,7 @@ sat_log_log (SAT_LOG_LEVEL_DEBUG, _("%s: Deleting ground track for %s"), - __FUNCTION__, sat->tle.sat_name); + __FUNCTION__, sat->nickname); root = goo_canvas_get_root_item_model (GOO_CANVAS (satmap->canvas)); Modified: trunk/src/gtk-sat-map-popup.c =================================================================== --- trunk/src/gtk-sat-map-popup.c 2009-08-06 20:44:36 UTC (rev 386) +++ trunk/src/gtk-sat-map-popup.c 2009-08-06 21:08:29 UTC (rev 387) @@ -84,7 +84,7 @@ menuitem = gtk_image_menu_item_new (); label = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5); - buff = g_strdup_printf ("<b>%s</b>", sat->tle.sat_name); + buff = g_strdup_printf ("<b>%s</b>", sat->nickname); gtk_label_set_markup (GTK_LABEL (label), buff); g_free (buff); gtk_container_add (GTK_CONTAINER (menuitem), label); @@ -294,7 +294,7 @@ } if (pass != NULL) { - show_pass (sat->tle.sat_name, qth, pass, GTK_WIDGET (toplevel)); + show_pass (sat->nickname, qth, pass, GTK_WIDGET (toplevel)); } else { /* show dialog that there are no passes within time frame */ @@ -305,7 +305,7 @@ GTK_BUTTONS_OK, _("Satellite %s has no passes\n"\ "within the next %d days"), - sat->tle.sat_name, + sat->nickname, sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); gtk_dialog_run (GTK_DIALOG (dialog)); @@ -324,7 +324,7 @@ "This can be because the satellite\n"\ "is geostationary, decayed or simply\n"\ "never comes above the horizon"), - sat->tle.sat_name); + sat->nickname); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); @@ -364,7 +364,7 @@ if (passes != NULL) { - show_passes (sat->tle.sat_name, qth, passes, GTK_WIDGET (toplevel)); + show_passes (sat->nickname, qth, passes, GTK_WIDGET (toplevel)); } else { /* show dialog that there are no passes within time frame */ @@ -375,7 +375,7 @@ GTK_BUTTONS_OK, _("Satellite %s has no passes\n"\ "within the next %d days"), - sat->tle.sat_name, + sat->nickname, sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); gtk_dialog_run (GTK_DIALOG (dialog)); @@ -394,7 +394,7 @@ GTK_BUTTONS_OK, _("Satellite %s has no passes for\n"\ "the current ground station!"), - sat->tle.sat_name); + sat->nickname); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); Modified: trunk/src/gtk-sat-map.c =================================================================== --- trunk/src/gtk-sat-map.c 2009-08-06 20:44:36 UTC (rev 386) +++ trunk/src/gtk-sat-map.c 2009-08-06 21:08:29 UTC (rev 387) @@ -671,13 +671,13 @@ buff = g_strdup_printf (_("<span background=\"#%s\"> "\ "Next: %s in %s%d:%s%d%s%d </span>"), satmap->infobgd, - sat->tle.sat_name, + sat->nickname, ch, h, cm, m, cs, s); else buff = g_strdup_printf (_("<span background=\"#%s\"> " \ "Next: %s in %s%d%s%d </span>"), satmap->infobgd, - sat->tle.sat_name, + sat->nickname, cm, m, cs, s); g_object_set (satmap->next, @@ -1683,7 +1683,7 @@ "stroke-color-rgba", col, NULL); - obj->label = goo_canvas_text_model_new (root, sat->tle.sat_name, + obj->label = goo_canvas_text_model_new (root, sat->nickname, x, y+2, -1, @@ -1960,11 +1960,11 @@ if (isgeo) { if (sat->el > 0.0) { text = g_strdup_printf ("<span background=\"#%s\"> %s: Always in range </span>", - satmap->infobgd, sat->tle.sat_name); + satmap->infobgd, sat->nickname); } else { text = g_strdup_printf ("<span background=\"#%s\"> %s: Always out of range </span>", - satmap->infobgd, sat->tle.sat_name); + satmap->infobgd, sat->nickname); } } else { @@ -2000,13 +2000,13 @@ if (h > 0) { text = g_strdup_printf ("<span background=\"#%s\"> "\ "%s %s in %s%d:%s%d%s%d </span>", - satmap->infobgd, sat->tle.sat_name, + satmap->infobgd, sat->nickname, alsstr, ch, h, cm, m, cs, s); } else { text = g_strdup_printf ("<span background=\"#%s\"> "\ "%s %s in %s%d%s%d </span>", - satmap->infobgd, sat->tle.sat_name, + satmap->infobgd, sat->nickname, alsstr, cm, m, cs, s); } Modified: trunk/src/gtk-sat-module.c =================================================================== --- trunk/src/gtk-sat-module.c 2009-08-06 20:44:36 UTC (rev 386) +++ trunk/src/gtk-sat-module.c 2009-08-06 21:08:29 UTC (rev 387) @@ -237,18 +237,6 @@ } -/* static void dump_data(gpointer key, */ -/* gpointer value, */ -/* gpointer user_data) */ -/* { */ -/* gint *catnum = key; */ - -/* g_print ("SATELLITE: %5d\t%s\t%d\n", */ -/* *catnum, */ -/* SAT(value)->tle.sat_name, */ -/* SAT(value)->flags); */ -/* } */ - /**** FIXME: Program goes into infinite loop when there is something wrong with cfg file. */ GtkWidget * Modified: trunk/src/gtk-single-sat.c =================================================================== --- trunk/src/gtk-single-sat.c 2009-08-06 20:44:36 UTC (rev 386) +++ trunk/src/gtk-single-sat.c 2009-08-06 21:08:29 UTC (rev 387) @@ -258,7 +258,7 @@ /* create header */ sat = SAT (g_slist_nth_data (GTK_SINGLE_SAT (widget)->sats, 0)); - title = g_strdup_printf ("<b>%s</b>", sat ? sat->tle.sat_name : "noname"); + title = g_strdup_printf ("<b>%s</b>", sat ? sat->nickname : "noname"); GTK_SINGLE_SAT (widget)->header = gtk_label_new (NULL); gtk_label_set_markup (GTK_LABEL (GTK_SINGLE_SAT (widget)->header), title); @@ -812,7 +812,7 @@ menuitem = gtk_image_menu_item_new (); label = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5); - buff = g_strdup_printf ("<b>%s</b>", sat->tle.sat_name); + buff = g_strdup_printf ("<b>%s</b>", sat->nickname); gtk_label_set_markup (GTK_LABEL (label), buff); g_free (buff); gtk_container_add (GTK_CONTAINER (menuitem), label); @@ -938,7 +938,7 @@ sat = SAT (g_slist_nth_data (ssat->sats, i)); - title = g_strdup_printf ("<b>%s</b>", sat->tle.sat_name); + title = g_strdup_printf ("<b>%s</b>", sat->nickname); gtk_label_set_markup (GTK_LABEL (ssat->header), title); g_free (title); @@ -1042,7 +1042,7 @@ } if (pass != NULL) { - show_pass (sat->tle.sat_name, qth, pass, GTK_WIDGET (toplevel)); + show_pass (sat->nickname, qth, pass, GTK_WIDGET (toplevel)); } else { /* show dialog that there are no passes within time frame */ @@ -1053,7 +1053,7 @@ GTK_BUTTONS_OK, _("Satellite %s has no passes\n"\ "within the next %d days"), - sat->tle.sat_name, + sat->nickname, sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); gtk_dialog_run (GTK_DIALOG (dialog)); @@ -1072,7 +1072,7 @@ "This can be because the satellite\n"\ "is geostationary, decayed or simply\n"\ "never comes above the horizon"), - sat->tle.sat_name); + sat->nickname); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); @@ -1113,7 +1113,7 @@ if (passes != NULL) { - show_passes (sat->tle.sat_name, qth, passes, GTK_WIDGET (toplevel)); + show_passes (sat->nickname, qth, passes, GTK_WIDGET (toplevel)); } else { /* show dialog that there are no passes within time frame */ @@ -1124,7 +1124,7 @@ GTK_BUTTONS_OK, _("Satellite %s has no passes\n"\ "within the next %d days"), - sat->tle.sat_name, + sat->nickname, sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); gtk_dialog_run (GTK_DIALOG (dialog)); @@ -1143,7 +1143,7 @@ GTK_BUTTONS_OK, _("Satellite %s has no passes for\n"\ "the current ground station!"), - sat->tle.sat_name); + sat->nickname); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); Modified: trunk/src/gtk-sky-glance.c =================================================================== --- trunk/src/gtk-sky-glance.c 2009-08-06 20:44:36 UTC (rev 386) +++ trunk/src/gtk-sky-glance.c 2009-08-06 21:08:29 UTC (rev 387) @@ -885,7 +885,7 @@ n = g_slist_length (passes); sat_log_log (SAT_LOG_LEVEL_DEBUG, _("%s:%d: %s has %d passes within %.4f days\n"), - __FILE__, __LINE__, sat->tle.sat_name, n, maxdt); + __FILE__, __LINE__, sat->nickname, n, maxdt); /* add sky_pass_t items to skg->passes */ if (passes != NULL) { @@ -920,7 +920,7 @@ free_passes (passes); /* add satellite label */ - lab = goo_canvas_text_model_new (root, sat->tle.sat_name, + lab = goo_canvas_text_model_new (root, sat->nickname, 5, 0, -1, GTK_ANCHOR_W, "font", "Sans 8", "fill-color-rgba", bcol, Modified: trunk/src/main.c =================================================================== --- trunk/src/main.c 2009-08-06 20:44:36 UTC (rev 386) +++ trunk/src/main.c 2009-08-06 21:08:29 UTC (rev 387) @@ -84,8 +84,7 @@ static void test_ui (void); -int - main (int argc, char *argv[]) +int main (int argc, char *argv[]) { guint error = 0; @@ -108,6 +107,7 @@ /* check that user settings are ok */ error = first_time_check_run (); + if (error) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: User config check failed (code %d). This is fatal.\n"\ @@ -118,15 +118,6 @@ return 1; } - /* initialise sub-systems */ - if (tle_lookup_init (NULL) != TLE_LOOKUP_INIT_OK) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: TLE check failed! This is fatal."), - __FUNCTION__); - - return -1; - } - sat_cfg_load (); /* get logging level */ @@ -141,7 +132,7 @@ /* launch TLE monitoring task; 10 min interval */ tle_mon_id = g_timeout_add (600000, tle_mon_task, NULL); - test_ui (); + //test_ui (); gtk_main (); @@ -236,7 +227,7 @@ * to make a clean exit. */ static void - gpredict_sig_handler (int sig) +gpredict_sig_handler (int sig) { /* satlog_log (SAT_LOG_ERROR, "Received signal: %d\n", sig); */ /* satlog_log (SAT_LOG_ERROR, "Trying clean exit...\n"); */ @@ -258,9 +249,9 @@ * */ static gint - gpredict_app_delete (GtkWidget *widget, - GdkEvent *event, - gpointer data) +gpredict_app_delete (GtkWidget *widget, + GdkEvent *event, + gpointer data) { return FALSE; } @@ -277,8 +268,8 @@ * */ static void - gpredict_app_destroy (GtkWidget *widget, - gpointer data) +gpredict_app_destroy (GtkWidget *widget, + gpointer data) { /* stop TLE monitoring task */ @@ -325,7 +316,7 @@ * */ static gboolean - gpredict_app_config (GtkWidget *widget, GdkEventConfigure *event, gpointer data) +gpredict_app_config (GtkWidget *widget, GdkEventConfigure *event, gpointer data) { gint x, y; @@ -375,7 +366,7 @@ * avoid a new notification the next time the taks would be run. */ static gboolean - tle_mon_task (gpointer data) +tle_mon_task (gpointer data) { glong last,now,thrld; GTimeVal tval; @@ -474,7 +465,7 @@ /** \brief Stop TLE monitoring and any pending updates. */ static void - tle_mon_stop () +tle_mon_stop () { gboolean retcode; @@ -498,7 +489,7 @@ /** \brief Thread function which invokes TLE update */ static gpointer - update_tle_thread (gpointer data) +update_tle_thread (gpointer data) { tle_upd_running = TRUE; Modified: trunk/src/predict-tools.c =================================================================== --- trunk/src/predict-tools.c 2009-08-06 20:44:36 UTC (rev 386) +++ trunk/src/predict-tools.c 2009-08-06 21:08:29 UTC (rev 387) @@ -484,7 +484,7 @@ pass->vis[1] = '-'; pass->vis[2] = '-'; pass->vis[3] = 0; - pass->satname = g_strdup (sat->tle.sat_name); + pass->satname = g_strdup (sat->nickname); pass->details = NULL; /* iterate over each time step */ @@ -901,7 +901,7 @@ pass->vis[1] = '-'; pass->vis[2] = '-'; pass->vis[3] = 0; - pass->satname = g_strdup (sat->tle.sat_name); + pass->satname = g_strdup (sat->nickname); pass->details = NULL; /* iterate over each time step */ Modified: trunk/src/sat-info.c =================================================================== --- trunk/src/sat-info.c 2009-08-06 20:44:36 UTC (rev 386) +++ trunk/src/sat-info.c 2009-08-06 21:08:29 UTC (rev 387) @@ -86,7 +86,7 @@ gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1); label = gtk_label_new (NULL); - str = g_strdup_printf (_("<b>%s</b>"), sat->tle.sat_name); + str = g_strdup_printf (_("<b>%s</b>"), sat->nickname); gtk_label_set_markup (GTK_LABEL (label), str); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 0, 1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-08 12:52:33
|
Revision: 399 http://gpredict.svn.sourceforge.net/gpredict/?rev=399&view=rev Author: csete Date: 2009-08-08 12:52:24 +0000 (Sat, 08 Aug 2009) Log Message: ----------- Added sat_file_name_from_catnum_s (gchar *catnum). Modified Paths: -------------- trunk/src/compat.c trunk/src/compat.h Modified: trunk/src/compat.c =================================================================== --- trunk/src/compat.c 2009-08-07 23:40:48 UTC (rev 398) +++ trunk/src/compat.c 2009-08-08 12:52:24 UTC (rev 399) @@ -314,7 +314,7 @@ } -/** \brief Build satellite file path from catnum */ +/** \brief Build satellite file path from catnum (integer) */ gchar *sat_file_name_from_catnum (guint catnum) { gchar *filename; @@ -333,7 +333,27 @@ } +/** \brief Build satellite file path from catnum (string) */ +gchar *sat_file_name_from_catnum (gchar *catnum) +{ + gchar *filename; + gchar *buff; + gchar *dir; + buff = g_strdup_printf ("%s.sat", catnum); + dir = get_satdata_dir (); + + filename = g_strconcat (dir, G_DIR_SEPARATOR_S, buff, NULL); + + g_free (buff); + g_free (dir); + + return filename; +} + + + + /** \brief Get full path of a .trsp file * \param trspfile The file name for the satellite * \return A newly allocated gchar * that should be freed when no longer needed Modified: trunk/src/compat.h =================================================================== --- trunk/src/compat.h 2009-08-07 23:40:48 UTC (rev 398) +++ trunk/src/compat.h 2009-08-08 12:52:24 UTC (rev 399) @@ -46,5 +46,6 @@ gchar *hw_file_name (const gchar *hwfile); gchar *sat_file_name_from_catnum (guint catnum); +gchar *sat_file_name_from_catnum_s (gchar *catnum); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-08 23:41:32
|
Revision: 406 http://gpredict.svn.sourceforge.net/gpredict/?rev=406&view=rev Author: csete Date: 2009-08-08 23:41:24 +0000 (Sat, 08 Aug 2009) Log Message: ----------- Don't use tle-lookup. Modified Paths: -------------- trunk/src/Makefile.am trunk/src/main.c trunk/src/qth-data.c Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2009-08-08 21:30:15 UTC (rev 405) +++ trunk/src/Makefile.am 2009-08-08 23:41:24 UTC (rev 406) @@ -68,11 +68,11 @@ pass-popup-menu.c pass-popup-menu.h \ pass-to-txt.c pass-to-txt.h \ predict-tools.c predict-tools.h \ - qth-data.c qth-data.h \ + qth-data.c qth-data.h \ qth-editor.c qth-editor.h \ radio-conf.c radio-conf.h \ rotor-conf.c rotor-conf.h \ - trsp-conf.c trsp-conf.h \ + trsp-conf.c trsp-conf.h \ sat-cfg.c sat-cfg.h \ sat-info.c sat-info.h \ sat-log.c sat-log.h \ @@ -107,7 +107,6 @@ sat-vis.c sat-vis.h \ save-pass.c save-pass.h \ time-tools.c time-tools.h \ - tle-lookup.c tle-lookup.h \ tle-tools.c tle-tools.h \ tle-update.c tle-update.h \ sat-debugger.c sat-debugger.h Modified: trunk/src/main.c =================================================================== --- trunk/src/main.c 2009-08-08 21:30:15 UTC (rev 405) +++ trunk/src/main.c 2009-08-08 23:41:24 UTC (rev 406) @@ -49,7 +49,6 @@ #include "compat.h" #include "gui.h" #include "mod-mgr.h" -#include "tle-lookup.h" #include "tle-update.h" #include "sat-cfg.h" #include "sat-debugger.h" @@ -158,8 +157,7 @@ * gpredict_gui package. * */ -static void - gpredict_app_create () +static void gpredict_app_create () { gchar *title; /* window title */ gchar *icon; /* icon file name */ @@ -279,9 +277,6 @@ /* stop timeouts */ - /* stop other sub-systems */ - tle_lookup_close (); - /* configuration data */ mod_mgr_save_state (); Modified: trunk/src/qth-data.c =================================================================== --- trunk/src/qth-data.c 2009-08-08 21:30:15 UTC (rev 405) +++ trunk/src/qth-data.c 2009-08-08 23:41:24 UTC (rev 406) @@ -32,7 +32,6 @@ #include "qth-data.h" #include "sat-log.h" #include "config-keys.h" -#include "tle-lookup.h" #ifdef HAVE_CONFIG_H # include <build-config.h> #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-08 23:42:16
|
Revision: 407 http://gpredict.svn.sourceforge.net/gpredict/?rev=407&view=rev Author: csete Date: 2009-08-08 23:42:09 +0000 (Sat, 08 Aug 2009) Log Message: ----------- Removed obsolete files. Removed Paths: ------------- trunk/src/tle-lookup.c trunk/src/tle-lookup.h Deleted: trunk/src/tle-lookup.c =================================================================== --- trunk/src/tle-lookup.c 2009-08-08 23:41:24 UTC (rev 406) +++ trunk/src/tle-lookup.c 2009-08-08 23:42:09 UTC (rev 407) @@ -1,304 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - Gpredict: Real-time satellite tracking and orbit prediction program - - Copyright (C) 2001-2008 Alexandru Csete, OZ9AEC. - - Authors: Alexandru Csete <oz...@gm...> - - Comments, questions and bugreports should be submitted via - http://sourceforge.net/projects/gpredict/ - More details can be found at the project home page: - - http://gpredict.oz9aec.net/ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, visit http://www.fsf.org/ -*/ -/** \defgroup tle_lookup TLE Link Manager - * \ingroup utils - * - * The TLE link manager maintains a mapping between satellite catalog numbers - * and the .tle files found in the user's data directory, usually - * $HOME/.gpredict/tle/ - */ -/** \defgroup tle_lookup_if Interface - * \ingroup tle_lookup - */ -/** \defgroup tle_lookup_priv Private - * \ingroup tle_lookup - */ -#include <glib.h> -#include <glib/gi18n.h> -#ifdef HAVE_CONFIG_H -# include <build-config.h> -#endif -#include "sat-log.h" -#include "tle-lookup.h" - - -/** \brief The has tanle containing the links. - * \ingroup tle_lookup_priv - */ -GHashTable *linktable = NULL; - -/** \brief Key used when accessing the hash table. - * \ingroup tle_lookup_priv - */ -guint *key = NULL; - - -/* private function prototypes */ -static guint tle_lookup_scan_file (const gchar *name); - - - -/** \brief Create and initialise hash table. - * \param tledir Directory to scan (optional). - * \return Error code indicating whether the process has been successful - * (TLE_LOOKUP_INIT_OK) or not. - * \ingroup tle_lookup_if - * - * The function creates and initialises the lookup hash table. It then scans - * the specified directory for tle files and adds each sattelite (catnum,file) - * to the hash table. If the specified directory is NULL, $HOME/.gpredict/tle/ - * is used. - * - * \note The error TLE_LOOKUP_NO_MEM is fatal and the main program should exit - * immediately in such case. - */ -gint -tle_lookup_init (const gchar *tledir) -{ - GDir *dir; - gchar *dirname; - const gchar *name; - gchar *msg; - guint num; - - /* create hash table */ - linktable = g_hash_table_new_full (g_int_hash, - g_int_equal, - g_free, - g_free); - - if (!linktable) { - return TLE_LOOKUP_NO_MEM; - } - - /* open directory */ - if (tledir != NULL) { - dirname = g_strdup (tledir); - } - else { - dirname = g_strdup_printf ("%s%s.gpredict2%stle", - g_get_home_dir (), - G_DIR_SEPARATOR_S, - G_DIR_SEPARATOR_S); - } - - /* debug message */ - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Directory is: %s"), - __FUNCTION__, dirname); - - dir = g_dir_open (dirname, 0, NULL); - - /* no tle files */ - if (!dir) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: No .tle files found in %s."), - __FUNCTION__, dirname); - - return TLE_LOOKUP_EMPTY_DIR; - } - - /* Scan data directory for .tle files. - For each file scan through the file and - add entry to the hash table. - */ - while ((name = g_dir_read_name (dir))) { - - if (g_strrstr (name, ".tle")) { - - msg = g_strconcat (dirname, G_DIR_SEPARATOR_S, - name, NULL); - num = tle_lookup_scan_file (msg); - g_free (msg); - - sat_log_log (SAT_LOG_LEVEL_MSG, - _("%s: Read %d sats from %s "), - __FUNCTION__, num, name); - } - - } - - g_dir_close (dir); - g_free (dirname); - - return TLE_LOOKUP_INIT_OK; -} - - -/** \brief Close link table and free resources. - * \ingroup tle_lookup_if - * - * This function destroys the link table freeing any memory that has been - * allocated to it. - */ -void -tle_lookup_close () -{ - - g_hash_table_destroy (linktable); - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Hash table destroyed, resources freed."), - __FUNCTION__); -} - - -/** \brief Get number of satellites in link table */ -guint -tle_lookup_count () -{ - if (!linktable) { - - return 0; - } - - return g_hash_table_size (linktable); -} - - -/** \brief Look up satellite - * \return copy of the file name in which the satellite can be found or - * NULL if the satellite can not be found. - * - * \note The returned string should be freed when no onger needed, unless - * it is already NULL :-P - */ -gchar * -tle_lookup (gint catnum) -{ - gchar *filename = NULL; - guint *key; - - if (!linktable) { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Link table is NULL!"), - __FUNCTION__); - - return NULL; - } - - key = g_new0 (guint, 1); - *key = (guint) catnum; - - /* GUINT_TO_POINTER(catnum) does not work */ - filename = (gchar *) g_hash_table_lookup (linktable, key); - - g_free (key); - - if (filename) { - return g_strdup (filename); - } - else { - return NULL; - } -} - - -/** \brief Scan TLE file for satellites. - * \param name The TLE file to scan. - * \return The number of satellites found. - * \ingroup tle_lookup_priv - * - * This function scans the specified TLE file and adds each satellite - * to the hash table. It returns the number of satellites found in the - * file. - * - * FIXME: USE GError - */ -static guint -tle_lookup_scan_file (const gchar *name) -{ - guint i = 0; - guint j; - GIOChannel *tlefile; - gchar *line; - gsize length; - gchar catstr[6]; - - /* open IO channel and read 3 lines at a time */ - tlefile = g_io_channel_new_file (name, "r", NULL); - - if (tlefile) { - - /*** FIXME: add error handling */ - - while (g_io_channel_read_line (tlefile, &line, &length, NULL, NULL) != G_IO_STATUS_EOF) { - - /* free line */ - g_free (line); - - /* extract catnum from second line; index 2..6 */ - g_io_channel_read_line (tlefile, &line, &length, - NULL, NULL); - - for (j = 2; j < 7; j++) { - catstr[j-2] = line[j]; - } - catstr[5] = '\0'; - - key = g_try_malloc (sizeof (guint)); - if (key) { - *key = (guint) g_ascii_strtod (catstr, NULL); - } - else { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Could not allocate memory for KEY"), - __FUNCTION__); - - /* FIXME: What to do now? We should try to bail out! */ - } - - /* add (catnum,name) to hash table; - warn if key already exists... - */ - if (g_hash_table_lookup (linktable, key)) { - sat_log_log (SAT_LOG_LEVEL_WARN, - _("%s: Catnum %d found more than once."), - __FUNCTION__, *key); - } - - g_hash_table_insert (linktable, key, g_path_get_basename (name)); - - /* free line */ - g_free (line); - - /* read the third line */ - g_io_channel_read_line (tlefile, &line, &length, NULL, NULL); - - /* free line */ - g_free (line); - - i++; - } - - /* close IO chanel; don't care about status */ - g_io_channel_shutdown (tlefile, TRUE, NULL); - g_io_channel_unref (tlefile); - } - - return i; -} Deleted: trunk/src/tle-lookup.h =================================================================== --- trunk/src/tle-lookup.h 2009-08-08 23:41:24 UTC (rev 406) +++ trunk/src/tle-lookup.h 2009-08-08 23:42:09 UTC (rev 407) @@ -1,49 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/* - Gpredict: Real-time satellite tracking and orbit prediction program - - Copyright (C) 2001-2008 Alexandru Csete, OZ9AEC. - - Authors: Alexandru Csete <oz...@gm...> - - Comments, questions and bugreports should be submitted via - http://sourceforge.net/projects/gpredict/ - More details can be found at the project home page: - - http://gpredict.oz9aec.net/ - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, visit http://www.fsf.org/ -*/ -#ifndef TLE_LOOKUP_H -#define TLE_LOOKUP_H 1 - -#include <glib.h> - - -/** \brief TLE lookup error codes - \ingroup tle_lookup_if - */ -typedef enum { - TLE_LOOKUP_INIT_OK = 0, /*!< No errors. */ - TLE_LOOKUP_EMPTY_DIR = 1, /*!< TLE directory empty, nothing loaded. */ - TLE_LOOKUP_NO_MEM = 2 /*!< Insufficient memory (fatal). */ -} tle_lookup_err_t; - -gint tle_lookup_init (const gchar *tledir); -void tle_lookup_close (void); -gchar *tle_lookup (gint catnum); -guint tle_lookup_count (void); - - -#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-09 00:33:16
|
Revision: 408 http://gpredict.svn.sourceforge.net/gpredict/?rev=408&view=rev Author: csete Date: 2009-08-09 00:33:08 +0000 (Sun, 09 Aug 2009) Log Message: ----------- Include new TLE files in default. Introduced configuration version number. Modified Paths: -------------- trunk/src/sat-cfg.c trunk/src/sat-cfg.h Modified: trunk/src/sat-cfg.c =================================================================== --- trunk/src/sat-cfg.c 2009-08-08 23:42:09 UTC (rev 407) +++ trunk/src/sat-cfg.c 2009-08-09 00:33:08 UTC (rev 408) @@ -140,6 +140,8 @@ /** \brief Array containing the integer configuration parameters */ sat_cfg_int_t sat_cfg_int[SAT_CFG_INT_NUM] = { + { "VERSION", "MAJOR", 0}, + { "VERSION", "MINOR", 0}, { "MODULES", "DATA_TIMEOUT", 300}, { "MODULES", "LAYOUT", GTK_SAT_MOD_LAYOUT_3}, { "MODULES", "VIEW_1", GTK_SAT_MOD_VIEW_MAP}, @@ -214,12 +216,16 @@ { "MODULES", "MAP_FONT", "Sans 10"}, { "MODULES", "POLAR_FONT", "Sans 10"}, { "TLE", "SERVER", "http://www.celestrak.com/NORAD/elements/"}, - { "TLE", "FILES", "amateur.txt;cubesat.txt;galileo.txt;geo.txt;gps-ops.txt;"\ - "iridium.txt;military.txt;radar.txt;science.txt;weather.txt"}, -{ "TLE", "PROXY", NULL}, -{ "TLE", "FILE_DIR", NULL}, -{ "TLE", "EXTENSION", "*.*"}, -{ "PREDICT", "SAVE_DIR", NULL} + { "TLE", "FILES", "amateur.txt;cubesat.txt;dmc.txt;education.txt;"\ + "engineering.txt;galileo.txt;geo.txt;geodetic.txt;globalstar.txt;"\ + "glo-ops.txt;goes.txt;gorizont.txt;gps-ops.txt;intelsat.txt;"\ + "iridium.txt;military.txt;molniya.txt;musson.txt;nnss.txt;noaa.txt;"\ + "orbcomm.txt;other.txt;other-comm.txt;radar.txt;raduga.txt;resource.txt;"\ + "sarsat.txt;sbas.txt;science.txt;tle-new.txt;visual.txt;weather.txt;x-comm.txt"}, + { "TLE", "PROXY", NULL}, + { "TLE", "FILE_DIR", NULL}, + { "TLE", "EXTENSION", "*.*"}, + { "PREDICT", "SAVE_DIR", NULL} }; @@ -239,8 +245,7 @@ * The the configuration data in memory is already "loaded" the data will * be ereased first. */ -guint - sat_cfg_load () +guint sat_cfg_load () { gchar *keyfile,*confdir; GError *error = NULL; @@ -277,6 +282,16 @@ _("%s: Everything OK."), __FUNCTION__); } + /* if config version is < 1.1; reset SAT_CFG_STR_TLE_FILES */ + guint ver; + ver = 10*sat_cfg_get_int (SAT_CFG_INT_VERSION_MAJOR) + sat_cfg_get_int (SAT_CFG_INT_VERSION_MINOR); + if (ver < 11) { + sat_cfg_reset_str (SAT_CFG_STR_TLE_FILES); + sat_cfg_set_int (SAT_CFG_INT_VERSION_MAJOR, 1); + sat_cfg_set_int (SAT_CFG_INT_VERSION_MINOR, 1); + } + + return 0; } Modified: trunk/src/sat-cfg.h =================================================================== --- trunk/src/sat-cfg.h 2009-08-08 23:42:09 UTC (rev 407) +++ trunk/src/sat-cfg.h 2009-08-09 00:33:08 UTC (rev 408) @@ -62,7 +62,9 @@ /** \brief Symbolic references for integer config values. */ typedef enum { - SAT_CFG_INT_MODULE_TIMEOUT = 0, /*!< Module refresh rate */ + SAT_CFG_INT_VERSION_MAJOR = 0, /*!< Configuration version number (major) */ + SAT_CFG_INT_VERSION_MINOR, /*!< Configuration version number (minor) */ + SAT_CFG_INT_MODULE_TIMEOUT, /*!< Module refresh rate */ SAT_CFG_INT_MODULE_LAYOUT, /*!< Module layout */ SAT_CFG_INT_MODULE_VIEW_1, /*!< Type of view 1 */ SAT_CFG_INT_MODULE_VIEW_2, /*!< Type of view 2 */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |