gpredict-svn Mailing List for Gpredict (Page 24)
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
You can subscribe to this list here.
2008 |
Jan
(24) |
Feb
|
Mar
(6) |
Apr
(14) |
May
(9) |
Jun
|
Jul
|
Aug
(25) |
Sep
(60) |
Oct
(26) |
Nov
|
Dec
(20) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
|
Feb
(2) |
Mar
(22) |
Apr
(61) |
May
(57) |
Jun
|
Jul
(3) |
Aug
(83) |
Sep
(35) |
Oct
(50) |
Nov
(28) |
Dec
(34) |
2010 |
Jan
(29) |
Feb
(15) |
Mar
(2) |
Apr
|
May
(6) |
Jun
(2) |
Jul
(24) |
Aug
(2) |
Sep
(9) |
Oct
(43) |
Nov
(22) |
Dec
(6) |
2011 |
Jan
(24) |
Feb
(22) |
Mar
(31) |
Apr
(13) |
May
(10) |
Jun
(10) |
Jul
(43) |
Aug
(12) |
Sep
(18) |
Oct
(33) |
Nov
(18) |
Dec
(4) |
From: <cs...@us...> - 2009-08-06 23:25:51
|
Revision: 391 http://gpredict.svn.sourceforge.net/gpredict/?rev=391&view=rev Author: csete Date: 2009-08-06 23:25:43 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Updated. Modified Paths: -------------- trunk/ChangeLog Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-08-06 23:23:46 UTC (rev 390) +++ trunk/ChangeLog 2009-08-06 23:25:43 UTC (rev 391) @@ -13,6 +13,12 @@ * src/menubar.c: * src/mod-mgr.c: * src/qth-editor.c: + * src/sat-pref-debug.c: + * src/sat-log-browser.c: + * src/sat-log.c: + * src/sat-cfg.c: + * src/sat-pref-qth.c: + * src/mod-cfg.c: Migrated to new user configuration. * src/sgpsdp/sgp4sdp4.h: @@ -25,7 +31,23 @@ * stc/gtk-sat-data.c: Migrated to new satdata config. + * src/gtk-polar-view.c: + * src/gtk-polar-view-popup.c: + * src/gtk-sat-list-popup.c: + * src/gtk-sat-map-popup.c: + * src/gtk-sat-map.c: + * src/gtk-sat-map-ground-track.c: + * src/gtk-single-sat.c: + * src/gtk-rig-ctrl.c: + * gtk/gtk-rot-ctrl.c: + * src/gtk-sat-data.c: + * src/gtk-sat-list.c: + * src/gtk-sky-glance.c: + * src/predict-tools.c: + * src/sat-info.c: + Uset sat->nickname instead of sat->tle.sat_name. + 2009-08-05 Alexandru Csete <oz9aec at gmail.com> * src/compat.[ch]: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-06 23:23:52
|
Revision: 390 http://gpredict.svn.sourceforge.net/gpredict/?rev=390&view=rev Author: csete Date: 2009-08-06 23:23:46 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Updated. Modified Paths: -------------- trunk/src/gtk-sat-data.c Modified: trunk/src/gtk-sat-data.c =================================================================== --- trunk/src/gtk-sat-data.c 2009-08-06 23:22:16 UTC (rev 389) +++ trunk/src/gtk-sat-data.c 2009-08-06 23:23:46 UTC (rev 390) @@ -79,7 +79,7 @@ } else { /* read name, nickname, and website */ - sat->name = g_key_file_get_string (data, NULL, "NAME", &error); + sat->name = g_key_file_get_string (data, "Satellite", "NAME", &error); if (error != NULL) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Error reading NAME from %s (%s)"), @@ -87,7 +87,7 @@ g_clear_error (&error); sat->name = g_strdup ("Error"); } - sat->nickname = g_key_file_get_string (data, NULL, "NICKNAME", &error); + sat->nickname = g_key_file_get_string (data, "Satellite", "NICKNAME", &error); if (error != NULL) { sat_log_log (SAT_LOG_LEVEL_MSG, _("%s: Satellite %d has no NICKNAME"), @@ -95,11 +95,11 @@ g_clear_error (&error); sat->nickname = g_strdup (sat->name); } - sat->website = g_key_file_get_string (data, NULL, "WEBSITE", NULL); /* website may be NULL */ + sat->website = g_key_file_get_string (data, "Satellite", "WEBSITE", NULL); /* website may be NULL */ /* get TLE data */ - tlestr1 = g_key_file_get_string (data, NULL, "TLE1", NULL); - tlestr2 = g_key_file_get_string (data, NULL, "TLE2", NULL); + tlestr1 = g_key_file_get_string (data, "Satellite", "TLE1", NULL); + tlestr2 = g_key_file_get_string (data, "Satellite", "TLE2", NULL); rawtle = g_strconcat (tlestr1, tlestr2, NULL); if (!Good_Elements (rawtle)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-06 23:22:24
|
Revision: 389 http://gpredict.svn.sourceforge.net/gpredict/?rev=389&view=rev Author: csete Date: 2009-08-06 23:22:16 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Updated. Modified Paths: -------------- trunk/data/satdata/convert.py Modified: trunk/data/satdata/convert.py =================================================================== --- trunk/data/satdata/convert.py 2009-08-06 21:14:19 UTC (rev 388) +++ trunk/data/satdata/convert.py 2009-08-06 23:22:16 UTC (rev 389) @@ -34,7 +34,7 @@ # satellite file satfile = open('./out/'+catnum+'.sat','w') - + satfile.write('[Satellite]\n') satfile.write('VERSION=1.1\n') satfile.write('NAME='+line1+'\n') satfile.write('NICKNAME='+line1+'\n') 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:14:27
|
Revision: 388 http://gpredict.svn.sourceforge.net/gpredict/?rev=388&view=rev Author: csete Date: 2009-08-06 21:14:19 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Missed one tle->sat_name. Modified Paths: -------------- trunk/src/gtk-single-sat.c Modified: trunk/src/gtk-single-sat.c =================================================================== --- trunk/src/gtk-single-sat.c 2009-08-06 21:08:29 UTC (rev 387) +++ trunk/src/gtk-single-sat.c 2009-08-06 21:14:19 UTC (rev 388) @@ -885,7 +885,7 @@ sati = SAT (g_slist_nth_data (single_sat->sats, i)); - menuitem = gtk_radio_menu_item_new_with_label (group, sati->tle.sat_name); + menuitem = gtk_radio_menu_item_new_with_label (group, sati->nickname); group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menuitem)); if (i == single_sat->selected) { 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-06 20:44:42
|
Revision: 386 http://gpredict.svn.sourceforge.net/gpredict/?rev=386&view=rev Author: csete Date: 2009-08-06 20:44:36 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Updated. Modified Paths: -------------- trunk/src/map-selector.c Modified: trunk/src/map-selector.c =================================================================== --- trunk/src/map-selector.c 2009-08-06 20:41:45 UTC (rev 385) +++ trunk/src/map-selector.c 2009-08-06 20:44:36 UTC (rev 386) @@ -95,7 +95,7 @@ /* select current map file */ if (g_path_is_absolute (curmap)) { - /* map is user specific, ie. in $HOME/.gpredict2/maps/ */ + /* map is user specific, ie. in USER_CONF_DIR/maps/ */ selection = g_strdup (curmap); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-06 20:41:54
|
Revision: 385 http://gpredict.svn.sourceforge.net/gpredict/?rev=385&view=rev Author: csete Date: 2009-08-06 20:41:45 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Fix various errors introduced by config migration. Modified Paths: -------------- trunk/src/first-time.c Modified: trunk/src/first-time.c =================================================================== --- trunk/src/first-time.c 2009-08-06 19:43:30 UTC (rev 384) +++ trunk/src/first-time.c 2009-08-06 20:41:45 UTC (rev 385) @@ -62,9 +62,10 @@ * * Check logic: * - * 1. Check for USER_CONF_DIR (use get_user_conf_dir()) and create dir if it - * does not exist. If we create the directory, check if there is a - * gpredict.cfg in the old configuration directory. + * 0. USER_CONF_DIR already exists because sat_log_init() initializes it. + * + * 1. Check for USER_CONF_DIR/gpredict.cfg - if not found, check if there is a + * gpredict.cfg in the old configuration directory and copy it to the new location. * 2. Check for the existence of at least one .qth file in USER_CONF_DIR * If no such file found, check if there are any in the pre-1.1 configuration. * If still none, copy PACKAGE_DATA_DIR/data/sample.qth to this @@ -121,60 +122,40 @@ /** \brief Execute step 1 of the first time checks. * - * 1. Check for USER_CONF_DIR (use get_user_conf_dir()) and create dir if it - * does not exist. If we create the directory, check if there is a - * gpredict.cfg in the old configuration directory. + * 1. Check for USER_CONF_DIR/gpredict.cfg - if not found, check if there is a + * gpredict.cfg in the old configuration directory and copy it to the new location. * */ static void first_time_check_step_01 (guint *error) { - gchar *dir; - gchar *cfgfile; - int status; + gchar *newdir,*olddir; + gchar *source,*target; - dir = get_user_conf_dir (); + newdir = get_user_conf_dir (); + target = g_strconcat (newdir, G_DIR_SEPARATOR_S, "gpredict.cfg", NULL); + g_free (newdir); - if (g_file_test (dir, G_FILE_TEST_IS_DIR)) { - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Check successful."), __FUNCTION__); + if (g_file_test (target, G_FILE_TEST_EXISTS)) { + /* already have config file => return */ + g_free (target); + + return; } - else { - /* try to create directory */ - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Check failed. Creating %s"), - __FUNCTION__, - dir); - status = g_mkdir_with_parents (dir, 0755); + /* check if we have old configuration */ + olddir = get_old_conf_dir (); + source = g_strconcat (olddir, G_DIR_SEPARATOR_S, "gpredict.cfg", NULL); + g_free (olddir); - if (status) { - /* set error flag */ - *error |= FTC_ERROR_STEP_01; + if (g_file_test (source, G_FILE_TEST_EXISTS)) { + /* copy old config file to new location */ + gpredict_file_copy (source, target); - 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); - - /* now check if there is a gpredict.cfg in the pre-1.1 config - folder. */ - cfgfile = g_strconcat (dir, G_DIR_SEPARATOR_S, "gpredict.cfg", NULL); - if (g_file_test (cfgfile, G_FILE_TEST_EXISTS)) { - /* copy cfg file to USER_CONF_DIR */ - gchar *target = g_strconcat (dir, G_DIR_SEPARATOR_S, "gpredict.cfg", NULL); - gpredict_file_copy (cfgfile, target); /* FIXME: Error ignored */ - g_free (target); - } - g_free (cfgfile); - } } - g_free (dir); + g_free (source); + g_free (target); } @@ -247,18 +228,22 @@ */ if (g_strrstr (datafile, ".qth")) { + gchar *source = g_strconcat (olddir, G_DIR_SEPARATOR_S, datafile, NULL); + /* copy .qth file to USER_CONF_DIR */ target = g_strconcat (dirname, G_DIR_SEPARATOR_S, datafile, NULL); - if (!gpredict_file_copy (datafile, target)) { + if (!gpredict_file_copy (source, target)) { /* success */ foundqth = TRUE; } g_free (target); + g_free (source); } } g_dir_close (dir); + } else if (!foundqth) { /* try to copy sample.qth */ @@ -281,7 +266,7 @@ g_free (target); g_free (filename); } - + g_free (olddir); } } @@ -348,7 +333,6 @@ dir = g_dir_open (olddir, 0, NULL); g_free (buff); - g_free (olddir); if (dir) { /* read files, if any; count number of .qth files */ @@ -358,19 +342,22 @@ so we must not free it */ if (g_strrstr (datafile, ".mod")) { + gchar *source = g_strconcat (olddir, G_DIR_SEPARATOR_S, datafile, NULL); /* copy .qth file to USER_CONF_DIR */ target = g_strconcat (confdir, G_DIR_SEPARATOR_S, datafile, NULL); - if (!gpredict_file_copy (datafile, target)) { + if (!gpredict_file_copy (source, target)) { /* success */ foundmod = TRUE; } g_free (target); + g_free (source); } } g_dir_close (dir); + } else if (!foundmod) { /* copy Amateur.mod to this directory */ @@ -393,6 +380,7 @@ g_free (target); g_free (filename); } + g_free (olddir); } } @@ -625,24 +613,27 @@ dir = g_dir_open (olddir, 0, NULL); g_free (buff); - g_free (olddir); if (dir) { /* read files, if any; count number of .qth files */ while ((datafile = g_dir_read_name (dir))) { + gchar *source = g_strconcat (olddir, G_DIR_SEPARATOR_S, datafile, NULL); + /* note: filename is not a newly allocated gchar *, so we must not free it */ /* copy file to USER_CONF_DIR */ target = g_strconcat (confdir, G_DIR_SEPARATOR_S, datafile, NULL); - gpredict_file_copy (datafile, target); + gpredict_file_copy (source, target); g_free (target); + g_free (source); } - + g_dir_close (dir); } + g_free (olddir); } } 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:43:38
|
Revision: 384 http://gpredict.svn.sourceforge.net/gpredict/?rev=384&view=rev Author: csete Date: 2009-08-06 19:43:30 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Migrated to new user configuration. Modified Paths: -------------- trunk/src/mod-cfg.c Modified: trunk/src/mod-cfg.c =================================================================== --- trunk/src/mod-cfg.c 2009-08-06 19:31:38 UTC (rev 383) +++ trunk/src/mod-cfg.c 2009-08-06 19:43:30 UTC (rev 384) @@ -131,15 +131,15 @@ if (num > 0) { /* we have at least one sat selected */ - gchar *filename; + gchar *filename,*confdir; gboolean save = TRUE; /* check if there is already a module with this name */ - filename = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "modules", G_DIR_SEPARATOR_S, + confdir = get_modules_dir (); + filename = g_strconcat (confdir, G_DIR_SEPARATOR_S, gtk_entry_get_text (GTK_ENTRY (namew)), ".mod", NULL); + g_free (confdir); if (g_file_test (filename, G_FILE_TEST_EXISTS)) { GtkWidget *warn; @@ -325,7 +325,7 @@ * * This function saves the module configuration data from cfgdata * into a module configuration file called modname.mod placed in - * the /home/username/.gpredict2/modules/ directory. + * the USER_CONF_DIR/modules/ directory. */ mod_cfg_status_t mod_cfg_save (gchar *modname, GKeyFile *cfgdata) @@ -334,6 +334,7 @@ gchar *datastream; /* cfgdata string */ GIOChannel *cfgfile; /* .mod file */ gchar *filename; /* file name */ + gchar *confdir; gsize length; /* length of the data stream */ gsize written; /* number of bytes actually written */ gboolean err; @@ -368,10 +369,9 @@ } /* create file and write data stream */ - filename = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "modules", G_DIR_SEPARATOR_S, - modname, ".mod", NULL); + confdir = get_modules_dir (); + filename = g_strconcat (confdir, G_DIR_SEPARATOR_S, modname, ".mod", NULL); + g_free (confdir); cfgfile = g_io_channel_new_file (filename, "w", &error); @@ -434,7 +434,7 @@ * \param needcfm Flag indicating whether the user should confirm th eoperation. * * This function deletes the module configuration file - * /home/username/.gpredict2/modules/modname.mod from the disk. If needcfm is + * USER_CONF_DIR/modules/modname.mod from the disk. If needcfm is * TRUE the user will be asked for confirmation first. The function returns * MOD_CFG_CANCEL if the user has cancelled the operation. */ @@ -705,8 +705,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); if (dir) { 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 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 18:35:18
|
Revision: 381 http://gpredict.svn.sourceforge.net/gpredict/?rev=381&view=rev Author: csete Date: 2009-08-06 18:35:11 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Migrated to new user configuration. Modified Paths: -------------- trunk/src/sat-pref-debug.c Modified: trunk/src/sat-pref-debug.c =================================================================== --- trunk/src/sat-pref-debug.c 2009-08-06 16:14:56 UTC (rev 380) +++ trunk/src/sat-pref-debug.c 2009-08-06 18:35:11 UTC (rev 381) @@ -33,6 +33,7 @@ #include "sat-cfg.h" #include "gpredict-utils.h" #include "sat-pref-debug.h" +#include "compat.h" #define SEC_PER_DAY 86400 @@ -65,6 +66,7 @@ GtkWidget *label; GtkWidget *butbox; gchar *msg; + gchar *confdir; vbox = gtk_vbox_new (FALSE, 10); @@ -121,17 +123,15 @@ gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, 0); /* info label */ + confdir = get_user_conf_dir (); msg = g_strdup_printf (_("Gpredict stores all run-time messages " - "in the %s%s.gpredict2%slogs%s folder. The " + "in the %s%slogs%s folder. The " "current log file is called gpredict.log and the " "file is always kept until the next execution so " "that you can examine it in case of a failure. " "If old log files are kept, they are called " "gpredict-XYZ.log where XYZ is a uniques timestamp."), - g_get_home_dir (), - G_DIR_SEPARATOR_S, - G_DIR_SEPARATOR_S, - G_DIR_SEPARATOR_S); + confdir, G_DIR_SEPARATOR_S, G_DIR_SEPARATOR_S); label = gtk_label_new (msg); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); 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:15:03
|
Revision: 380 http://gpredict.svn.sourceforge.net/gpredict/?rev=380&view=rev Author: csete Date: 2009-08-06 16:14:56 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Added missing NULL terminator. Modified Paths: -------------- trunk/src/first-time.c Modified: trunk/src/first-time.c =================================================================== --- trunk/src/first-time.c 2009-08-06 16:08:42 UTC (rev 379) +++ trunk/src/first-time.c 2009-08-06 16:14:56 UTC (rev 380) @@ -492,7 +492,7 @@ if (!g_file_test (target, G_FILE_TEST_EXISTS)) { /* copy file to target dir */ - gchar *source = g_strconcat (srcdirname, G_DIR_SEPARATOR_S, filename); + gchar *source = g_strconcat (srcdirname, G_DIR_SEPARATOR_S, filename, NULL); if (gpredict_file_copy (source, target)) { sat_log_log (SAT_LOG_LEVEL_ERROR, _("%s: Failed to copy %s"), 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 14:13:03
|
Revision: 378 http://gpredict.svn.sourceforge.net/gpredict/?rev=378&view=rev Author: csete Date: 2009-08-06 14:12:56 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Updated. Modified Paths: -------------- trunk/ChangeLog Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-08-06 14:12:01 UTC (rev 377) +++ trunk/ChangeLog 2009-08-06 14:12:56 UTC (rev 378) @@ -1,6 +1,34 @@ -2009-08-05 alexandru Csete <oz9aec at gmail.com> +2009-08-06 Alexandru Csete <oz9aec at gmail.com> + * src/gtk-rig-ctrl.c: + * src/gtk-rot-ctrl.c: + * src/radio-conf.c: + * src/rotor-conf.c: + * src/trsp-conf.c: + * src/sat-pref-rig.c: + * src/sat-pref-rot.c: + * src/gtk-sat-module.c: + * src/gtk-sat-module-popup.c: + * src/main.c: + * src/menubar.c: + * src/mod-mgr.c: + * src/qth-editor.c: + Migrated to new user configuration. + + * src/sgpsdp/sgp4sdp4.h: + Add new name fields to sat_t structure. + * src/compat.[ch]: + Added utility function to build satellite data file path from catalog + number. + + * stc/gtk-sat-data.c: + Migrated to new satdata config. + + +2009-08-05 Alexandru Csete <oz9aec at gmail.com> + + * src/compat.[ch]: Added more configuration related utility functions. * src/first-time.c: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-06 14:12:15
|
Revision: 377 http://gpredict.svn.sourceforge.net/gpredict/?rev=377&view=rev Author: csete Date: 2009-08-06 14:12:01 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Migrated to new user configuration. Modified Paths: -------------- trunk/src/qth-editor.c Modified: trunk/src/qth-editor.c =================================================================== --- trunk/src/qth-editor.c 2009-08-06 13:54:55 UTC (rev 376) +++ trunk/src/qth-editor.c 2009-08-06 14:12:01 UTC (rev 377) @@ -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 @@ -37,6 +37,7 @@ #include "sat-cfg.h" #include "sat-log.h" #include "locator.h" +#include "compat.h" #include "gtk-sat-data.h" #include "qth-editor.h" @@ -47,9 +48,9 @@ * select location or select weather station. */ enum { - SELECTION_MODE_LOC = 1, - SELECTION_MODE_WX = 2 -}; + SELECTION_MODE_LOC = 1, + SELECTION_MODE_WX = 2 + }; extern GtkWidget *window; /* dialog window defined in sat-pref.c */ @@ -101,331 +102,331 @@ */ GtkResponseType qth_editor_run (qth_t *qth, GtkWindow *parent) { - gint response; - gboolean finished = FALSE; + gint response; + gboolean finished = FALSE; - /* crate dialog and add contents */ - dialog = gtk_dialog_new_with_buttons (_("Edit ground station data"), - parent, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CLEAR, - GTK_RESPONSE_REJECT, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, - GTK_RESPONSE_OK, - NULL); + /* crate dialog and add contents */ + dialog = gtk_dialog_new_with_buttons (_("Edit ground station data"), + parent, + GTK_DIALOG_MODAL | + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_CLEAR, + GTK_RESPONSE_REJECT, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + GTK_STOCK_OK, + GTK_RESPONSE_OK, + NULL); - /* disable OK button to begin with */ - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), - GTK_RESPONSE_OK, - FALSE); + /* disable OK button to begin with */ + gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), + GTK_RESPONSE_OK, + FALSE); - gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), - create_editor_widgets (qth)); + gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), + create_editor_widgets (qth)); - /* this hacky-thing is to keep the dialog running in case the - CLEAR button is plressed. OK and CANCEL will exit the loop - */ - while (!finished) { + /* this hacky-thing is to keep the dialog running in case the + CLEAR button is plressed. OK and CANCEL will exit the loop + */ + while (!finished) { - response = gtk_dialog_run (GTK_DIALOG (dialog)); + response = gtk_dialog_run (GTK_DIALOG (dialog)); - switch (response) { + switch (response) { - /* OK */ - case GTK_RESPONSE_OK: - if (apply_changes (qth)) { - finished = TRUE; - } - else { - /* and error occured; try again */ - GtkWidget *errd; + /* OK */ + case GTK_RESPONSE_OK: + if (apply_changes (qth)) { + finished = TRUE; + } + else { + /* and error occured; try again */ + GtkWidget *errd; - errd = gtk_message_dialog_new (parent, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("An error occurred while trying to save\n"\ - "ground station data to %s.qth!\n"\ - "Please try again using a different name."), - qth->name); + errd = gtk_message_dialog_new (parent, + GTK_DIALOG_MODAL | + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + _("An error occurred while trying to save\n"\ + "ground station data to %s.qth!\n"\ + "Please try again using a different name."), + qth->name); - gtk_dialog_run (GTK_DIALOG (errd)); - gtk_widget_destroy (errd); + gtk_dialog_run (GTK_DIALOG (errd)); + gtk_widget_destroy (errd); - finished = FALSE; - } - break; + finished = FALSE; + } + break; - /* CLEAR */ - case GTK_RESPONSE_REJECT: - clear_widgets (); - break; + /* CLEAR */ + case GTK_RESPONSE_REJECT: + clear_widgets (); + break; - /* Everything else is considered CANCEL */ - default: - finished = TRUE; - break; - } - } + /* Everything else is considered CANCEL */ + default: + finished = TRUE; + break; + } + } - gtk_widget_destroy (dialog); + gtk_widget_destroy (dialog); - return response; + return response; } /** \brief Create and initialise widgets */ static GtkWidget * -create_editor_widgets (qth_t *qth) + create_editor_widgets (qth_t *qth) { - GtkWidget *table; - GtkWidget *label; - GtkTooltips *tooltips; - GtkWidget *locbut; - GtkWidget *wxbut; + GtkWidget *table; + GtkWidget *label; + GtkTooltips *tooltips; + GtkWidget *locbut; + GtkWidget *wxbut; - table = gtk_table_new (9, 4, FALSE); - gtk_container_set_border_width (GTK_CONTAINER (table), 5); - gtk_table_set_col_spacings (GTK_TABLE (table), 5); - gtk_table_set_row_spacings (GTK_TABLE (table), 5); + table = gtk_table_new (9, 4, FALSE); + gtk_container_set_border_width (GTK_CONTAINER (table), 5); + gtk_table_set_col_spacings (GTK_TABLE (table), 5); + gtk_table_set_row_spacings (GTK_TABLE (table), 5); - /* QTH name */ - label = gtk_label_new (_("Name")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1); - - name = gtk_entry_new (); - gtk_entry_set_max_length (GTK_ENTRY (name), 25); - tooltips = gtk_tooltips_new (); - gtk_tooltips_set_tip (tooltips, name, - _("Enter a short name for this ground station, e.g. callsign.\n"\ - "Allowed characters: 0..9, a..z, A..Z, - and _"), - _("The name will be used to identify the ground station "\ - "when it is presented to the user. Maximum allowed length "\ - "is 25 characters.")); - gtk_table_attach_defaults (GTK_TABLE (table), name, 1, 4, 0, 1); + /* QTH name */ + label = gtk_label_new (_("Name")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1); - /* attach changed signal so that we can enable OK button when - a proper name has been entered - */ - g_signal_connect (name, "changed", G_CALLBACK (name_changed), NULL); + name = gtk_entry_new (); + gtk_entry_set_max_length (GTK_ENTRY (name), 25); + tooltips = gtk_tooltips_new (); + gtk_tooltips_set_tip (tooltips, name, + _("Enter a short name for this ground station, e.g. callsign.\n"\ + "Allowed characters: 0..9, a..z, A..Z, - and _"), + _("The name will be used to identify the ground station "\ + "when it is presented to the user. Maximum allowed length "\ + "is 25 characters.")); + gtk_table_attach_defaults (GTK_TABLE (table), name, 1, 4, 0, 1); - /* QTH description */ - label = gtk_label_new (_("Description")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2); - - desc = gtk_entry_new (); - gtk_entry_set_max_length (GTK_ENTRY (desc), 256); - tooltips = gtk_tooltips_new (); - gtk_tooltips_set_tip (tooltips, desc, - _("Enter an optional description for this ground station."), - _("The description for the ground station can be used as additional "\ - "information. It may be included when generating reports. "\ - "The maximum length for the description is 256 characters.")); - gtk_table_attach_defaults (GTK_TABLE (table), desc, 1, 4, 1, 2); + /* attach changed signal so that we can enable OK button when + a proper name has been entered + */ + g_signal_connect (name, "changed", G_CALLBACK (name_changed), NULL); - /* location */ - label = gtk_label_new (_("Location")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 2, 3); - - location = gtk_entry_new (); - gtk_entry_set_max_length (GTK_ENTRY (location), 50); - tooltips = gtk_tooltips_new (); - gtk_tooltips_set_tip (tooltips, location, - _("Optional location of the ground station, fx. Copenhagen, Denmark."), - NULL); - gtk_table_attach_defaults (GTK_TABLE (table), location, 1, 3, 2, 3); + /* QTH description */ + label = gtk_label_new (_("Description")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2); - locbut = gpredict_hstock_button (GTK_STOCK_INDEX, _("Select"), - _("Select a predefined location from a list.")); - g_signal_connect (locbut, "clicked", - G_CALLBACK (select_location), - GUINT_TO_POINTER (SELECTION_MODE_LOC)); - gtk_table_attach_defaults (GTK_TABLE (table), locbut, 3, 4, 2, 3); - + desc = gtk_entry_new (); + gtk_entry_set_max_length (GTK_ENTRY (desc), 256); + tooltips = gtk_tooltips_new (); + gtk_tooltips_set_tip (tooltips, desc, + _("Enter an optional description for this ground station."), + _("The description for the ground station can be used as additional "\ + "information. It may be included when generating reports. "\ + "The maximum length for the description is 256 characters.")); + gtk_table_attach_defaults (GTK_TABLE (table), desc, 1, 4, 1, 2); - /* latitude */ - label = gtk_label_new (_("Latitude (\302\260)")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 3, 4); + /* location */ + label = gtk_label_new (_("Location")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 2, 3); - lat = gtk_spin_button_new_with_range (0.00, 90.00, 0.0001); - gtk_spin_button_set_increments (GTK_SPIN_BUTTON (lat), 0.01, 1.0); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (lat), TRUE); - gtk_spin_button_set_digits (GTK_SPIN_BUTTON (lat), 4); - tooltips = gtk_tooltips_new (); - gtk_tooltips_set_tip (tooltips, lat, - _("Select the latitude of the ground station in decimal degrees."), - NULL); - gtk_table_attach_defaults (GTK_TABLE (table), lat, 1, 2, 3, 4); + location = gtk_entry_new (); + gtk_entry_set_max_length (GTK_ENTRY (location), 50); + tooltips = gtk_tooltips_new (); + gtk_tooltips_set_tip (tooltips, location, + _("Optional location of the ground station, fx. Copenhagen, Denmark."), + NULL); + gtk_table_attach_defaults (GTK_TABLE (table), location, 1, 3, 2, 3); - ns = gtk_combo_box_new_text (); - gtk_combo_box_append_text (GTK_COMBO_BOX (ns), _("North")); - gtk_combo_box_append_text (GTK_COMBO_BOX (ns), _("South")); - gtk_combo_box_set_active (GTK_COMBO_BOX (ns), 0); - /*** FIXME tooltips */ - gtk_table_attach_defaults (GTK_TABLE (table), ns, 2, 3, 3, 4); + locbut = gpredict_hstock_button (GTK_STOCK_INDEX, _("Select"), + _("Select a predefined location from a list.")); + g_signal_connect (locbut, "clicked", + G_CALLBACK (select_location), + GUINT_TO_POINTER (SELECTION_MODE_LOC)); + gtk_table_attach_defaults (GTK_TABLE (table), locbut, 3, 4, 2, 3); - /* longitude */ - label = gtk_label_new (_("Longitude (\302\260)")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 4, 5); - lon = gtk_spin_button_new_with_range (0.00, 180.00, 0.0001); - gtk_spin_button_set_increments (GTK_SPIN_BUTTON (lon), 0.01, 1.0); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (lon), TRUE); - gtk_spin_button_set_digits (GTK_SPIN_BUTTON (lon), 4); - gtk_tooltips_set_tip (tooltips, lon, - _("Select the longitude of the ground station in decimal degrees."), - NULL); - gtk_table_attach_defaults (GTK_TABLE (table), lon, 1, 2, 4, 5); + /* latitude */ + label = gtk_label_new (_("Latitude (\302\260)")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 3, 4); - ew = gtk_combo_box_new_text (); - gtk_combo_box_append_text (GTK_COMBO_BOX (ew), _("East")); - gtk_combo_box_append_text (GTK_COMBO_BOX (ew), _("West")); - gtk_combo_box_set_active (GTK_COMBO_BOX (ew), 0); - /*** FIXME tooltips */ - gtk_table_attach_defaults (GTK_TABLE (table), ew, 2, 3, 4, 5); + lat = gtk_spin_button_new_with_range (0.00, 90.00, 0.0001); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON (lat), 0.01, 1.0); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (lat), TRUE); + gtk_spin_button_set_digits (GTK_SPIN_BUTTON (lat), 4); + tooltips = gtk_tooltips_new (); + gtk_tooltips_set_tip (tooltips, lat, + _("Select the latitude of the ground station in decimal degrees."), + NULL); + gtk_table_attach_defaults (GTK_TABLE (table), lat, 1, 2, 3, 4); + ns = gtk_combo_box_new_text (); + gtk_combo_box_append_text (GTK_COMBO_BOX (ns), _("North")); + gtk_combo_box_append_text (GTK_COMBO_BOX (ns), _("South")); + gtk_combo_box_set_active (GTK_COMBO_BOX (ns), 0); + /*** FIXME tooltips */ + gtk_table_attach_defaults (GTK_TABLE (table), ns, 2, 3, 3, 4); - /* connect lat/lon spinners and combos to callback - remember signal id so that we can block signals - while doing automatic cross-updates - */ - latsigid = g_signal_connect (lat, "value-changed", - G_CALLBACK (latlon_changed), - NULL); - lonsigid = g_signal_connect (lon, "value-changed", - G_CALLBACK (latlon_changed), - NULL); - nssigid = g_signal_connect (ns, "changed", - G_CALLBACK (latlon_changed), - NULL); - ewsigid = g_signal_connect (ew, "changed", - G_CALLBACK (latlon_changed), - NULL); - - /* QRA locator */ - label = gtk_label_new (_("Locator")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 5, 6); + /* longitude */ + label = gtk_label_new (_("Longitude (\302\260)")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 4, 5); - qra = gtk_entry_new (); - gtk_entry_set_max_length (GTK_ENTRY (qra), 6); - tooltips = gtk_tooltips_new (); - gtk_tooltips_set_tip (tooltips, qra, - _("Maidenhead locator grid."), - NULL); - gtk_table_attach_defaults (GTK_TABLE (table), qra, 1, 2, 5, 6); - qrasigid = g_signal_connect (qra, "changed", - G_CALLBACK (qra_changed), - NULL); + lon = gtk_spin_button_new_with_range (0.00, 180.00, 0.0001); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON (lon), 0.01, 1.0); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (lon), TRUE); + gtk_spin_button_set_digits (GTK_SPIN_BUTTON (lon), 4); + gtk_tooltips_set_tip (tooltips, lon, + _("Select the longitude of the ground station in decimal degrees."), + NULL); + gtk_table_attach_defaults (GTK_TABLE (table), lon, 1, 2, 4, 5); - /* altitude */ - label = gtk_label_new (_("Altitude")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 6, 7); + ew = gtk_combo_box_new_text (); + gtk_combo_box_append_text (GTK_COMBO_BOX (ew), _("East")); + gtk_combo_box_append_text (GTK_COMBO_BOX (ew), _("West")); + gtk_combo_box_set_active (GTK_COMBO_BOX (ew), 0); + /*** FIXME tooltips */ + gtk_table_attach_defaults (GTK_TABLE (table), ew, 2, 3, 4, 5); - alt = gtk_spin_button_new_with_range (0, 5000, 1); - gtk_spin_button_set_increments (GTK_SPIN_BUTTON (alt), 1, 100); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (alt), TRUE); - gtk_tooltips_set_tip (tooltips, alt, - _("Select the altitude of the ground station in meters or feet "\ - "depending on your settings"), - NULL); - gtk_table_attach_defaults (GTK_TABLE (table), alt, 1, 2, 6, 7); - if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_IMPERIAL)) { - label = gtk_label_new (_("ft asl")); - } - else { - label = gtk_label_new (_("m asl")); - } - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), label, 2, 3, 6, 7); + /* connect lat/lon spinners and combos to callback + remember signal id so that we can block signals + while doing automatic cross-updates + */ + latsigid = g_signal_connect (lat, "value-changed", + G_CALLBACK (latlon_changed), + NULL); + lonsigid = g_signal_connect (lon, "value-changed", + G_CALLBACK (latlon_changed), + NULL); + nssigid = g_signal_connect (ns, "changed", + G_CALLBACK (latlon_changed), + NULL); + ewsigid = g_signal_connect (ew, "changed", + G_CALLBACK (latlon_changed), + NULL); - /* weather station */ - label = gtk_label_new (_("Weather St")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 7, 8); + /* QRA locator */ + label = gtk_label_new (_("Locator")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 5, 6); - wx = gtk_entry_new (); - gtk_entry_set_max_length (GTK_ENTRY (wx), 4); - tooltips = gtk_tooltips_new (); - gtk_tooltips_set_tip (tooltips, wx, - _("Four letter code for weather station"), - NULL); - gtk_table_attach_defaults (GTK_TABLE (table), wx, 1, 3, 7, 8); + qra = gtk_entry_new (); + gtk_entry_set_max_length (GTK_ENTRY (qra), 6); + tooltips = gtk_tooltips_new (); + gtk_tooltips_set_tip (tooltips, qra, + _("Maidenhead locator grid."), + NULL); + gtk_table_attach_defaults (GTK_TABLE (table), qra, 1, 2, 5, 6); + qrasigid = g_signal_connect (qra, "changed", + G_CALLBACK (qra_changed), + NULL); - wxbut = gpredict_hstock_button (GTK_STOCK_INDEX, _("Select"), - _("Select a predefined weather station from a list.")); - g_signal_connect (wxbut, "clicked", - G_CALLBACK (select_location), - GUINT_TO_POINTER (SELECTION_MODE_WX)); - gtk_table_attach_defaults (GTK_TABLE (table), wxbut, 3, 4, 7, 8); - + /* altitude */ + label = gtk_label_new (_("Altitude")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 6, 7); - if (qth->name != NULL) - update_widgets (qth); + alt = gtk_spin_button_new_with_range (0, 5000, 1); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON (alt), 1, 100); + gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (alt), TRUE); + gtk_tooltips_set_tip (tooltips, alt, + _("Select the altitude of the ground station in meters or feet "\ + "depending on your settings"), + NULL); + gtk_table_attach_defaults (GTK_TABLE (table), alt, 1, 2, 6, 7); - gtk_widget_show_all (table); + if (sat_cfg_get_bool (SAT_CFG_BOOL_USE_IMPERIAL)) { + label = gtk_label_new (_("ft asl")); + } + else { + label = gtk_label_new (_("m asl")); + } + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach_defaults (GTK_TABLE (table), label, 2, 3, 6, 7); - return table; + /* weather station */ + label = gtk_label_new (_("Weather St")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 7, 8); + + wx = gtk_entry_new (); + gtk_entry_set_max_length (GTK_ENTRY (wx), 4); + tooltips = gtk_tooltips_new (); + gtk_tooltips_set_tip (tooltips, wx, + _("Four letter code for weather station"), + NULL); + gtk_table_attach_defaults (GTK_TABLE (table), wx, 1, 3, 7, 8); + + wxbut = gpredict_hstock_button (GTK_STOCK_INDEX, _("Select"), + _("Select a predefined weather station from a list.")); + g_signal_connect (wxbut, "clicked", + G_CALLBACK (select_location), + GUINT_TO_POINTER (SELECTION_MODE_WX)); + gtk_table_attach_defaults (GTK_TABLE (table), wxbut, 3, 4, 7, 8); + + + if (qth->name != NULL) + update_widgets (qth); + + gtk_widget_show_all (table); + + return table; } /** \brief Update widgets from the currently selected row in the treeview */ static void -update_widgets (qth_t *qth) + update_widgets (qth_t *qth) { - if (qth->name != NULL) - gtk_entry_set_text (GTK_ENTRY (name), qth->name); + if (qth->name != NULL) + gtk_entry_set_text (GTK_ENTRY (name), qth->name); - if (qth->loc != NULL) { - gtk_entry_set_text (GTK_ENTRY (location), qth->loc); - } + if (qth->loc != NULL) { + gtk_entry_set_text (GTK_ENTRY (location), qth->loc); + } - if (qth->desc != NULL) { - gtk_entry_set_text (GTK_ENTRY (desc), qth->desc); - } + if (qth->desc != NULL) { + gtk_entry_set_text (GTK_ENTRY (desc), qth->desc); + } - if (qth->wx != NULL) { - gtk_entry_set_text (GTK_ENTRY (wx), qth->wx); - } + if (qth->wx != NULL) { + gtk_entry_set_text (GTK_ENTRY (wx), qth->wx); + } - if (qth->lat < 0.00) - gtk_combo_box_set_active (GTK_COMBO_BOX (ns), 1); - else - gtk_combo_box_set_active (GTK_COMBO_BOX (ns), 0); - - gtk_spin_button_set_value (GTK_SPIN_BUTTON (lat), fabs (qth->lat)); + if (qth->lat < 0.00) + gtk_combo_box_set_active (GTK_COMBO_BOX (ns), 1); + else + gtk_combo_box_set_active (GTK_COMBO_BOX (ns), 0); - if (qth->lon < 0.00) - gtk_combo_box_set_active (GTK_COMBO_BOX (ew), 1); - else - gtk_combo_box_set_active (GTK_COMBO_BOX (ew), 0); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (lat), fabs (qth->lat)); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (lon), fabs (qth->lon)); + if (qth->lon < 0.00) + gtk_combo_box_set_active (GTK_COMBO_BOX (ew), 1); + else + gtk_combo_box_set_active (GTK_COMBO_BOX (ew), 0); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (alt), qth->alt); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (lon), fabs (qth->lon)); - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s:%d: Loaded %s for editing:\n"\ - "LAT:%.2f LON:%.2f ALT:%d"), - __FILE__, __LINE__, - (qth->name != NULL) ? qth->name : "???", - qth->lat, qth->lon, qth->alt); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (alt), qth->alt); + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s:%d: Loaded %s for editing:\n"\ + "LAT:%.2f LON:%.2f ALT:%d"), + __FILE__, __LINE__, + (qth->name != NULL) ? qth->name : "???", + qth->lat, qth->lon, qth->alt); + } @@ -436,16 +437,16 @@ * */ static void -clear_widgets () + clear_widgets () { - gtk_entry_set_text (GTK_ENTRY (name), ""); - gtk_entry_set_text (GTK_ENTRY (location), ""); - gtk_entry_set_text (GTK_ENTRY (desc), ""); - gtk_entry_set_text (GTK_ENTRY (wx), ""); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (lat), 0.0); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (lon), 0.0); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (alt), 0); - gtk_entry_set_text (GTK_ENTRY (qra), ""); + gtk_entry_set_text (GTK_ENTRY (name), ""); + gtk_entry_set_text (GTK_ENTRY (location), ""); + gtk_entry_set_text (GTK_ENTRY (desc), ""); + gtk_entry_set_text (GTK_ENTRY (wx), ""); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (lat), 0.0); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (lon), 0.0); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (alt), 0); + gtk_entry_set_text (GTK_ENTRY (qra), ""); } @@ -455,88 +456,85 @@ * This function is usually called when the user clicks the OK button. */ static gboolean -apply_changes (qth_t *qth) + apply_changes (qth_t *qth) { - const gchar *qthname = NULL; - const gchar *qthloc = NULL; - const gchar *qthdesc = NULL; - const gchar *qthwx = NULL; - const gchar *qthqra= NULL; - gdouble qthlat; - gdouble qthlon; - guint qthalt; - gchar *fname; - gboolean retcode; + const gchar *qthname = NULL; + const gchar *qthloc = NULL; + const gchar *qthdesc = NULL; + const gchar *qthwx = NULL; + const gchar *qthqra= NULL; + gdouble qthlat; + gdouble qthlon; + guint qthalt; + gchar *fname,*confdir; + gboolean retcode; - /* get values from widgets */ - qthname = gtk_entry_get_text (GTK_ENTRY (name)); - qthloc = gtk_entry_get_text (GTK_ENTRY (location)); - qthdesc = gtk_entry_get_text (GTK_ENTRY (desc)); - qthwx = gtk_entry_get_text (GTK_ENTRY (wx)); + /* get values from widgets */ + qthname = gtk_entry_get_text (GTK_ENTRY (name)); + qthloc = gtk_entry_get_text (GTK_ENTRY (location)); + qthdesc = gtk_entry_get_text (GTK_ENTRY (desc)); + qthwx = gtk_entry_get_text (GTK_ENTRY (wx)); - qthlat = gtk_spin_button_get_value (GTK_SPIN_BUTTON (lat)); - if (gtk_combo_box_get_active (GTK_COMBO_BOX (ns))) - qthlat = -qthlat; + qthlat = gtk_spin_button_get_value (GTK_SPIN_BUTTON (lat)); + if (gtk_combo_box_get_active (GTK_COMBO_BOX (ns))) + qthlat = -qthlat; - qthlon = gtk_spin_button_get_value (GTK_SPIN_BUTTON (lon)); - if (gtk_combo_box_get_active (GTK_COMBO_BOX (ew))) - qthlon = -qthlon; + qthlon = gtk_spin_button_get_value (GTK_SPIN_BUTTON (lon)); + if (gtk_combo_box_get_active (GTK_COMBO_BOX (ew))) + qthlon = -qthlon; - qthalt = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (alt)); - qthqra = gtk_entry_get_text (GTK_ENTRY (qra)); + qthalt = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (alt)); + qthqra = gtk_entry_get_text (GTK_ENTRY (qra)); - /* clear qth struct if not empty */ - /* if (qth->name != NULL) */ - /* g_free (qth->name); */ + /* clear qth struct if not empty */ + /* if (qth->name != NULL) */ + /* g_free (qth->name); */ - /* if (qth->loc != NULL) */ - /* g_free (qth->loc); */ + /* if (qth->loc != NULL) */ + /* g_free (qth->loc); */ - /* if (qth->desc != NULL) */ - /* g_free (qth->desc); */ + /* if (qth->desc != NULL) */ + /* g_free (qth->desc); */ - /* if (qth->wx != NULL) */ - /* g_free (qth->wx); */ + /* if (qth->wx != NULL) */ + /* g_free (qth->wx); */ - /* if (qth->qra != NULL) */ - /* g_free (qth->qra); */ + /* if (qth->qra != NULL) */ + /* g_free (qth->qra); */ - /* if (qth->data != NULL) */ - /* g_key_file_free (qth->data); */ + /* if (qth->data != NULL) */ + /* g_key_file_free (qth->data); */ - /* copy new values to qth struct */ - qth->name = g_strdup (qthname); + /* copy new values to qth struct */ + qth->name = g_strdup (qthname); - if (qthloc != NULL) - qth->loc = g_strdup (qthloc); + if (qthloc != NULL) + qth->loc = g_strdup (qthloc); - if (qthdesc != NULL) - qth->desc = g_strdup (qthdesc); + if (qthdesc != NULL) + qth->desc = g_strdup (qthdesc); - if (qthwx != NULL) - qth->wx = g_strdup (qthwx); + if (qthwx != NULL) + qth->wx = g_strdup (qthwx); - if (qthqra != NULL) - qth->qra = g_strdup (qthqra); + if (qthqra != NULL) + qth->qra = g_strdup (qthqra); - qth->lat = qthlat; - qth->lon = qthlon; - qth->alt = qthalt; + qth->lat = qthlat; + qth->lon = qthlon; + qth->alt = qthalt; - /* store values to disc */ - fname = g_strconcat (g_get_home_dir (), - G_DIR_SEPARATOR_S, - ".gpredict2", - G_DIR_SEPARATOR_S, - qth->name, - ".qth", - NULL); + /* store values */ + confdir = get_user_conf_dir (); + fname = g_strconcat (confdir, G_DIR_SEPARATOR_S, + qth->name, ".qth", NULL); retcode = qth_data_save (fname, qth); - g_free (fname); + g_free (fname); + g_free (confdir); - return retcode; + return retcode; } @@ -548,54 +546,54 @@ * of the name is greater than zero, if yes enable the OK button of the dialog. */ static void -name_changed (GtkWidget *widget, gpointer data) + name_changed (GtkWidget *widget, gpointer data) { - const gchar *text; - gchar *entry, *end, *j; - gint len, pos; + const gchar *text; + gchar *entry, *end, *j; + gint len, pos; - /* step 1: ensure that only valid characters are entered - (stolen from xlog, tnx pg4i) - */ - entry = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1); - if ((len = g_utf8_strlen (entry, -1)) > 0) - { - end = entry + g_utf8_strlen (entry, -1); - for (j = entry; j < end; ++j) - { - switch (*j) - { - case '0' ... '9': - case 'a' ... 'z': - case 'A' ... 'Z': - case '-': - case '_': - break; - default: - gdk_beep (); - pos = gtk_editable_get_position (GTK_EDITABLE (widget)); - gtk_editable_delete_text (GTK_EDITABLE (widget), - pos, pos+1); - break; - } - } - } + /* step 1: ensure that only valid characters are entered + (stolen from xlog, tnx pg4i) + */ + entry = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1); + if ((len = g_utf8_strlen (entry, -1)) > 0) + { + end = entry + g_utf8_strlen (entry, -1); + for (j = entry; j < end; ++j) + { + switch (*j) + { + case '0' ... '9': + case 'a' ... 'z': + case 'A' ... 'Z': + case '-': + case '_': + break; + default: + gdk_beep (); + pos = gtk_editable_get_position (GTK_EDITABLE (widget)); + gtk_editable_delete_text (GTK_EDITABLE (widget), + pos, pos+1); + break; + } + } + } - /* step 2: if name seems all right, enable OK button */ - text = gtk_entry_get_text (GTK_ENTRY (widget)); + /* step 2: if name seems all right, enable OK button */ + text = gtk_entry_get_text (GTK_ENTRY (widget)); - if (g_utf8_strlen (text, -1) > 0) { - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), - GTK_RESPONSE_OK, - TRUE); - } - else { - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), - GTK_RESPONSE_OK, - FALSE); - } + if (g_utf8_strlen (text, -1) > 0) { + gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), + GTK_RESPONSE_OK, + TRUE); + } + else { + gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), + GTK_RESPONSE_OK, + FALSE); + } } @@ -606,80 +604,80 @@ * the data parameter contains information about which button has been clicked. */ static void -select_location (GtkWidget *widget, gpointer data) + select_location (GtkWidget *widget, gpointer data) { - guint mode = GPOINTER_TO_UINT (data); - guint flags; - gchar *qthloc; - gchar *qthwx; - gfloat qthlat; - gfloat qthlon; - guint qthalt; - gboolean selected = FALSE; + guint mode = GPOINTER_TO_UINT (data); + guint flags; + gchar *qthloc; + gchar *qthwx; + gfloat qthlat; + gfloat qthlon; + guint qthalt; + gboolean selected = FALSE; - switch (mode) { + switch (mode) { - /* We distinguish only between WX mode and "everything else". - Although a value != 1 or 2 is definitely a bug, we need to - have some sensible fall-back. - */ - case SELECTION_MODE_WX: - flags = TREE_COL_FLAG_NAME | TREE_COL_FLAG_WX; - break; + /* We distinguish only between WX mode and "everything else". + Although a value != 1 or 2 is definitely a bug, we need to + have some sensible fall-back. + */ + case SELECTION_MODE_WX: + flags = TREE_COL_FLAG_NAME | TREE_COL_FLAG_WX; + break; - default: - flags = TREE_COL_FLAG_NAME | - TREE_COL_FLAG_LAT | - TREE_COL_FLAG_LON | - TREE_COL_FLAG_ALT | - TREE_COL_FLAG_WX; + default: + flags = TREE_COL_FLAG_NAME | + TREE_COL_FLAG_LAT | + TREE_COL_FLAG_LON | + TREE_COL_FLAG_ALT | + TREE_COL_FLAG_WX; - mode = SELECTION_MODE_LOC; - break; - } + mode = SELECTION_MODE_LOC; + break; + } - selected = loc_tree_create (NULL, flags, &qthloc, &qthlat, &qthlon, &qthalt, &qthwx); + selected = loc_tree_create (NULL, flags, &qthloc, &qthlat, &qthlon, &qthalt, &qthwx); - if (selected) { - /* update widgets */ - switch (mode) { + if (selected) { + /* update widgets */ + switch (mode) { - case SELECTION_MODE_WX: - gtk_entry_set_text (GTK_ENTRY (wx), qthwx); - break; + case SELECTION_MODE_WX: + gtk_entry_set_text (GTK_ENTRY (wx), qthwx); + break; - case SELECTION_MODE_LOC: - gtk_entry_set_text (GTK_ENTRY (location), qthloc); - gtk_entry_set_text (GTK_ENTRY (wx), qthwx); + case SELECTION_MODE_LOC: + gtk_entry_set_text (GTK_ENTRY (location), qthloc); + gtk_entry_set_text (GTK_ENTRY (wx), qthwx); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (lat), fabs (qthlat)); - if (qthlat < 0.00) - gtk_combo_box_set_active (GTK_COMBO_BOX (ns), 1); - else - gtk_combo_box_set_active (GTK_COMBO_BOX (ns), 0); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (lat), fabs (qthlat)); + if (qthlat < 0.00) + gtk_combo_box_set_active (GTK_COMBO_BOX (ns), 1); + else + gtk_combo_box_set_active (GTK_COMBO_BOX (ns), 0); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (lon), fabs (qthlon)); - if (qthlon < 0.00) - gtk_combo_box_set_active (GTK_COMBO_BOX (ew), 1); - else - gtk_combo_box_set_active (GTK_COMBO_BOX (ew), 0); - - gtk_spin_button_set_value (GTK_SPIN_BUTTON (alt), qthalt); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (lon), fabs (qthlon)); + if (qthlon < 0.00) + gtk_combo_box_set_active (GTK_COMBO_BOX (ew), 1); + else + gtk_combo_box_set_active (GTK_COMBO_BOX (ew), 0); - break; + gtk_spin_button_set_value (GTK_SPIN_BUTTON (alt), qthalt); - default: - /*** FIXME: add some error reporting */ - break; - } + break; - /* free some memory */ - g_free (qthloc); - g_free (qthwx); - } + default: + /*** FIXME: add some error reporting */ + break; + } - /* else do nothing; we are finished */ + /* free some memory */ + g_free (qthloc); + g_free (qthwx); + } + + /* else do nothing; we are finished */ } @@ -693,58 +691,58 @@ * coordinates and the calculates the new Maidenhead locator square. */ static void -latlon_changed (GtkWidget *widget, gpointer data) + latlon_changed (GtkWidget *widget, gpointer data) { - gchar *locator; - gint retcode; - gdouble latf,lonf; + gchar *locator; + gint retcode; + gdouble latf,lonf; - locator = g_try_malloc (7); - - /* no need to check locator != NULL, since hamlib func will do it for us - and return RIGEINVAL - */ - lonf = gtk_spin_button_get_value (GTK_SPIN_BUTTON (lon)); - latf = gtk_spin_button_get_value (GTK_SPIN_BUTTON (lat)); + locator = g_try_malloc (7); - /* set the correct sign */ - if (gtk_combo_box_get_active (GTK_COMBO_BOX (ns))) { - /* index 1 => South */ - latf = -latf; - } + /* no need to check locator != NULL, since hamlib func will do it for us + and return RIGEINVAL + */ + lonf = gtk_spin_button_get_value (GTK_SPIN_BUTTON (lon)); + latf = gtk_spin_button_get_value (GTK_SPIN_BUTTON (lat)); - if (gtk_combo_box_get_active (GTK_COMBO_BOX (ew))) { - /* index 1 => Wesr */ - lonf = -lonf; - } + /* set the correct sign */ + if (gtk_combo_box_get_active (GTK_COMBO_BOX (ns))) { + /* index 1 => South */ + latf = -latf; + } - retcode = longlat2locator (lonf, latf, locator, 3); + if (gtk_combo_box_get_active (GTK_COMBO_BOX (ew))) { + /* index 1 => Wesr */ + lonf = -lonf; + } - if (retcode == RIG_OK) { - /* debug message */ - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s:%s: %.2f %.2f => %s"), - __FILE__, __FUNCTION__, - gtk_spin_button_get_value (GTK_SPIN_BUTTON (lon)), - gtk_spin_button_get_value (GTK_SPIN_BUTTON (lat)), - locator); + retcode = longlat2locator (lonf, latf, locator, 3); - g_signal_handler_block (qra, qrasigid); + if (retcode == RIG_OK) { + /* debug message */ + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s:%s: %.2f %.2f => %s"), + __FILE__, __FUNCTION__, + gtk_spin_button_get_value (GTK_SPIN_BUTTON (lon)), + gtk_spin_button_get_value (GTK_SPIN_BUTTON (lat)), + locator); - gtk_entry_set_text (GTK_ENTRY (qra), locator); + g_signal_handler_block (qra, qrasigid); - g_signal_handler_unblock (qra, qrasigid); - } - else { - /* send an error message and don't update */ - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%d: Error converting lon/lat to locator"), - __FILE__, __LINE__); - } + gtk_entry_set_text (GTK_ENTRY (qra), locator); + g_signal_handler_unblock (qra, qrasigid); + } + else { + /* send an error message and don't update */ + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%d: Error converting lon/lat to locator"), + __FILE__, __LINE__); + } - if (locator) - g_free (locator); + + if (locator) + g_free (locator); } /** \brief Manage locator changes. @@ -754,64 +752,64 @@ * the combo boxes. */ static void -qra_changed (GtkEntry *entry, gpointer data) + qra_changed (GtkEntry *entry, gpointer data) { - gint retcode; - gdouble latf,lonf; - gchar *msg; + gint retcode; + gdouble latf,lonf; + gchar *msg; - retcode = locator2longlat (&lonf, &latf, gtk_entry_get_text (GTK_ENTRY (qra))); + retcode = locator2longlat (&lonf, &latf, gtk_entry_get_text (GTK_ENTRY (qra))); - if (retcode == RIG_OK) { + if (retcode == RIG_OK) { - /* debug message */ - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s:%s: %s => %.2f %.2f"), - __FILE__, __FUNCTION__, - gtk_entry_get_text (GTK_ENTRY (qra)), - lonf, latf); + /* debug message */ + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s:%s: %s => %.2f %.2f"), + __FILE__, __FUNCTION__, + gtk_entry_get_text (GTK_ENTRY (qra)), + lonf, latf); - /* block signal emissions for lat/lon widgets */ - g_signal_handler_block (lat, latsigid); - g_signal_handler_block (lon, lonsigid); - g_signal_handler_block (ns, nssigid); - g_signal_handler_block (ew, ewsigid); - g_signal_handler_block (qra, qrasigid); + /* block signal emissions for lat/lon widgets */ + g_signal_handler_block (lat, latsigid); + g_signal_handler_block (lon, lonsigid); + g_signal_handler_block (ns, nssigid); + g_signal_handler_block (ew, ewsigid); + g_signal_handler_block (qra, qrasigid); - /* update widgets */ - if (latf < 0.00) - gtk_combo_box_set_active (GTK_COMBO_BOX (ns), 1); - else - gtk_combo_box_set_active (GTK_COMBO_BOX (ns), 0); + /* update widgets */ + if (latf < 0.00) + gtk_combo_box_set_active (GTK_COMBO_BOX (ns), 1); + else + gtk_combo_box_set_active (GTK_COMBO_BOX (ns), 0); - if (lonf < 0.00) - gtk_combo_box_set_active (GTK_COMBO_BOX (ew), 1); - else - gtk_combo_box_set_active (GTK_COMBO_BOX (ew), 0); + if (lonf < 0.00) + gtk_combo_box_set_active (GTK_COMBO_BOX (ew), 1); + else + gtk_combo_box_set_active (GTK_COMBO_BOX (ew), 0); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (lat), fabs (latf)); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (lon), fabs (lonf)); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (lat), fabs (latf)); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (lon), fabs (lonf)); - /* make sure text is upper case */ - msg = g_ascii_strup (gtk_entry_get_text (GTK_ENTRY (qra)), -1); - gtk_entry_set_text (GTK_ENTRY (qra), msg); - g_free (msg); + /* make sure text is upper case */ + msg = g_ascii_strup (gtk_entry_get_text (GTK_ENTRY (qra)), -1); + gtk_entry_set_text (GTK_ENTRY (qra), msg); + g_free (msg); - /* unblock signal emissions */ - g_signal_handler_unblock (lat, latsigid); - g_signal_handler_unblock (lon, lonsigid); - g_signal_handler_unblock (ns, nssigid); - g_signal_handler_unblock (ew, ewsigid); - g_signal_handler_unblock (qra, qrasigid); + /* unblock signal emissions */ + g_signal_handler_unblock (lat, latsigid); + g_signal_handler_unblock (lon, lonsigid); + g_signal_handler_unblock (ns, nssigid); + g_signal_handler_unblock (ew, ewsigid); + g_signal_handler_unblock (qra, qrasigid); - } - else { - /* send an error message and don't update */ - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%d: Invalid locator: %s"), - __FILE__, __LINE__, - gtk_entry_get_text (GTK_ENTRY (qra))); - } + } + else { + /* send an error message and don't update */ + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%d: Invalid locator: %s"), + __FILE__, __LINE__, + gtk_entry_get_text (GTK_ENTRY (qra))); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-06 13:55:29
|
Revision: 372 http://gpredict.svn.sourceforge.net/gpredict/?rev=372&view=rev Author: csete Date: 2009-08-06 13:38:16 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Migrated to new user configuration. Modified Paths: -------------- trunk/src/gtk-sat-module-popup.c Modified: trunk/src/gtk-sat-module-popup.c =================================================================== --- trunk/src/gtk-sat-module-popup.c 2009-08-06 13:29:37 UTC (rev 371) +++ trunk/src/gtk-sat-module-popup.c 2009-08-06 13:38:16 UTC (rev 372) @@ -360,15 +360,12 @@ gtk_entry_get_text (GTK_ENTRY (entry))); /* build full file names */ - source = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "modules", G_DIR_SEPARATOR_S, - module->name, ".mod", NULL); - target = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "modules", G_DIR_SEPARATOR_S, - gtk_entry_get_text (GTK_ENTRY (entry)), - ".mod", NULL); + gchar *moddir = get_modules_dir (); + source = g_strconcat (moddir, G_DIR_SEPARATOR_S, + module->name, ".mod", NULL); + target = g_strconcat (moddir, G_DIR_SEPARATOR_S, + gtk_entry_get_text (GTK_ENTRY (entry)), ".mod", NULL); + g_free (moddir); /* copy file */ if (gpredict_file_copy (source, target)) { @@ -377,9 +374,9 @@ __FILE__, __LINE__, module->name); } else { - sat_log_log (SAT_LOG_LEVEL_MSG, - _("%s:%d: Successfully cloned %s."), - __FILE__, __LINE__, module->name); + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s:%d: Successfully cloned %s."), + __FILE__, __LINE__, module->name); /* open module if requested */ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (toggle))) { @@ -1046,14 +1043,13 @@ { gchar *file; GtkWidget *dialog; - //GtkWidget *parent = gtk_widget_get_toplevel (GTK_WIDGET (data)); + gchar *moddir; + moddir = get_modules_dir (); + file = g_strconcat (moddir, G_DIR_SEPARATOR_S, + GTK_SAT_MODULE (data)->name, ".mod", NULL); + g_free (moddir); - file = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "modules", G_DIR_SEPARATOR_S, - GTK_SAT_MODULE (data)->name, ".mod", NULL); - gtk_sat_module_close_cb (menuitem, data); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-06 13:55:19
|
Revision: 373 http://gpredict.svn.sourceforge.net/gpredict/?rev=373&view=rev Author: csete Date: 2009-08-06 13:41:11 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Fixed indent. Modified Paths: -------------- trunk/src/gtk-sat-tree.c Modified: trunk/src/gtk-sat-tree.c =================================================================== --- trunk/src/gtk-sat-tree.c 2009-08-06 13:38:16 UTC (rev 372) +++ trunk/src/gtk-sat-tree.c 2009-08-06 13:41:11 UTC (rev 373) @@ -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 @@ -36,6 +36,7 @@ # include <build-config.h> #endif #include "sat-log.h" +#include "compat.h" #include "gtk-sat-tree.h" @@ -50,27 +51,27 @@ static GtkTreeModel *create_and_fill_model (guint flags); static void column_toggled (GtkCellRendererToggle *cell, - gchar *path_str, - gpointer data); + gchar *path_str, + gpointer data); static gint scan_tle_file (const gchar *path, - GtkTreeStore *store, - GtkTreeIter *node); + GtkTreeStore *store, + GtkTreeIter *node); static gboolean check_and_select_sat (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data); + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data); static gboolean uncheck_sat (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data); + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data); static gint compare_func (GtkTreeModel *model, - GtkTreeIter *a, - GtkTreeIter *b, - gpointer userdata); + GtkTreeIter *a, + GtkTreeIter *b, + gpointer userdata); static void expand_cb (GtkWidget *button, gpointer tree); static void collapse_cb (GtkWidget *button, gpointer tree); @@ -82,82 +83,82 @@ GType -gtk_sat_tree_get_type () + gtk_sat_tree_get_type () { - static GType gtk_sat_tree_type = 0; + static GType gtk_sat_tree_type = 0; - if (!gtk_sat_tree_type) - { - static const GTypeInfo gtk_sat_tree_info = - { - sizeof (GtkSatTreeClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_sat_tree_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkSatTree), - 1, /* n_preallocs */ - (GInstanceInitFunc) gtk_sat_tree_init, - }; + if (!gtk_sat_tree_type) + { + static const GTypeInfo gtk_sat_tree_info = + { + sizeof (GtkSatTreeClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) gtk_sat_tree_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (GtkSatTree), + 1, /* n_preallocs */ + (GInstanceInitFunc) gtk_sat_tree_init, + }; - gtk_sat_tree_type = g_type_register_static (GTK_TYPE_VBOX, - "GtkSatTree", - >k_sat_tree_info, - 0); - } + gtk_sat_tree_type = g_type_register_static (GTK_TYPE_VBOX, + "GtkSatTree", + >k_sat_tree_info, + 0); + } - return gtk_sat_tree_type; + return gtk_sat_tree_type; } static void -gtk_sat_tree_class_init (GtkSatTreeClass *class) + gtk_sat_tree_class_init (GtkSatTreeClass *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_tree_destroy; - + object_class->destroy = gtk_sat_tree_destroy; + } static void -gtk_sat_tree_init (GtkSatTree *sat_tree) + gtk_sat_tree_init (GtkSatTree *sat_tree) { } static void -gtk_sat_tree_destroy (GtkObject *object) + gtk_sat_tree_destroy (GtkObject *object) { - GtkSatTree *sat_tree = GTK_SAT_TREE (object); + GtkSatTree *sat_tree = GTK_SAT_TREE (object); - /* clear list of selected satellites */ - /* crashes on 2. instance: g_slist_free (sat_tree->selection); */ - guint n,i; - gpointer data; + /* clear list of selected satellites */ + /* crashes on 2. instance: g_slist_free (sat_tree->selection); */ + guint n,i; + gpointer data; - n = g_slist_length (sat_tree->selection); + n = g_slist_length (sat_tree->selection); - for (i = 0; i < n; i++) { - /* get the first element and delete it */ - data = g_slist_nth_data (sat_tree->selection, 0); - sat_tree->selection = g_slist_remove (sat_tree->selection, data); - } + for (i = 0; i < n; i++) { + /* get the first element and delete it */ + data = g_slist_nth_data (sat_tree->selection, 0); + sat_tree->selection = g_slist_remove (sat_tree->selection, data); + } - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); + (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } @@ -168,224 +169,224 @@ * \return A GtkSatTree widget. */ GtkWidget * -gtk_sat_tree_new (guint flags) + gtk_sat_tree_new (guint flags) { - GtkWidget *widget; - GtkSatTree *sat_tree; - GtkTreeModel *model; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; - GtkWidget *hbox; - GtkTooltips *tips; - GtkWidget *expbut; - GtkWidget *colbut; + GtkWidget *widget; + GtkSatTree *sat_tree; + GtkTreeModel *model; + GtkCellRenderer *renderer; + GtkTreeViewColumn *column; + GtkWidget *hbox; + GtkTooltips *tips; + GtkWidget *expbut; + GtkWidget *colbut; - if (!flags) - flags = GTK_SAT_TREE_DEFAULT_FLAGS; + if (!flags) + flags = GTK_SAT_TREE_DEFAULT_FLAGS; - widget = g_object_new (GTK_TYPE_SAT_TREE, NULL); - sat_tree = GTK_SAT_TREE (widget); + widget = g_object_new (GTK_TYPE_SAT_TREE, NULL); + sat_tree = GTK_SAT_TREE (widget); - sat_tree->flags = flags; + sat_tree->flags = flags; - /* create list and model */ - sat_tree->tree = gtk_tree_view_new (); - gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (sat_tree->tree), TRUE); - model = create_and_fill_model (flags); - gtk_tree_view_set_model (GTK_TREE_VIEW (sat_tree->tree), model); - g_object_unref (model); + /* create list and model */ + sat_tree->tree = gtk_tree_view_new (); + gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (sat_tree->tree), TRUE); + model = create_and_fill_model (flags); + gtk_tree_view_set_model (GTK_TREE_VIEW (sat_tree->tree), model); + g_object_unref (model); - /* sort the tree by name */ - gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (model), - GTK_SAT_TREE_COL_NAME, - compare_func, - NULL, - NULL); - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model), - GTK_SAT_TREE_COL_NAME, - GTK_SORT_ASCENDING); + /* sort the tree by name */ + gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (model), + GTK_SAT_TREE_COL_NAME, + compare_func, + NULL, + NULL); + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model), + GTK_SAT_TREE_COL_NAME, + GTK_SORT_ASCENDING); - /* create tree view columns */ - /* label column */ - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Satellite"), renderer, - "text", GTK_SAT_TREE_COL_NAME, - NULL); - gtk_tree_view_insert_column (GTK_TREE_VIEW (sat_tree->tree), column, -1); - if (!(flags & GTK_SAT_TREE_FLAG_NAME)) - gtk_tree_view_column_set_visible (column, FALSE); + /* create tree view columns */ + /* label column */ + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes (_("Satellite"), renderer, + "text", GTK_SAT_TREE_COL_NAME, + NULL); + gtk_tree_view_insert_column (GTK_TREE_VIEW (sat_tree->tree), column, -1); + if (!(flags & GTK_SAT_TREE_FLAG_NAME)) + gtk_tree_view_column_set_visible (column, FALSE); - /* catalogue number */ - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Catnum"), renderer, - "text", GTK_SAT_TREE_COL_CATNUM, - "visible", GTK_SAT_TREE_COL_VIS, - NULL); - gtk_tree_view_insert_column (GTK_TREE_VIEW (sat_tree->tree), column, -1); - if (!(flags & GTK_SAT_TREE_FLAG_CATNUM)) - gtk_tree_view_column_set_visible (column, FALSE); + /* catalogue number */ + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes (_("Catnum"), renderer, + "text", GTK_SAT_TREE_COL_CATNUM, + "visible", GTK_SAT_TREE_COL_VIS, + NULL); + gtk_tree_view_insert_column (GTK_TREE_VIEW (sat_tree->tree), column, -1); + if (!(flags & GTK_SAT_TREE_FLAG_CATNUM)) + gtk_tree_view_column_set_visible (column, FALSE); - /* epoch */ - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Epoch"), renderer, - "text", GTK_SAT_TREE_COL_EPOCH, - "visible", GTK_SAT_TREE_COL_VIS, - NULL); - gtk_tree_view_insert_column (GTK_TREE_VIEW (sat_tree->tree), column, -1); - if (!(flags & GTK_SAT_TREE_FLAG_EPOCH)) - gtk_tree_view_column_set_visible (column, FALSE); + /* epoch */ + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes (_("Epoch"), renderer, + "text", GTK_SAT_TREE_COL_EPOCH, + "visible", GTK_SAT_TREE_COL_VIS, + NULL); + gtk_tree_view_insert_column (GTK_TREE_VIEW (sat_tree->tree), column, -1); + if (!(flags & GTK_SAT_TREE_FLAG_EPOCH)) + gtk_tree_view_column_set_visible (column, FALSE); - /* checkbox column */ - renderer = gtk_cell_renderer_toggle_new (); - sat_tree->handler_id = g_signal_connect (renderer, "toggled", - G_CALLBACK (column_toggled), widget); + /* checkbox column */ + renderer = gtk_cell_renderer_toggle_new (); + sat_tree->handler_id = g_signal_connect (renderer, "toggled", + G_CALLBACK (column_toggled), widget); - column = gtk_tree_view_column_new_with_attributes (_("Selected"), renderer, - "active", GTK_SAT_TREE_COL_SEL, - "visible", GTK_SAT_TREE_COL_VIS, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (sat_tree->tree), column); - gtk_tree_view_column_set_alignment (column, 0.5); - if (!(flags & GTK_SAT_TREE_FLAG_SEL)) - gtk_tree_view_column_set_visible (column, FALSE); - + column = gtk_tree_view_column_new_with_attributes (_("Selected"), renderer, + "active", GTK_SAT_TREE_COL_SEL, + "visible", GTK_SAT_TREE_COL_VIS, + NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (sat_tree->tree), column); + gtk_tree_view_column_set_alignment (column, 0.5); + if (!(flags & GTK_SAT_TREE_FLAG_SEL)) + gtk_tree_view_column_set_visible (column, FALSE); - /* scrolled window */ - GTK_SAT_TREE (widget)->swin = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (GTK_SAT_TREE (widget)->swin), - GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_container_add (GTK_CONTAINER (GTK_SAT_TREE (widget)->swin), - GTK_SAT_TREE (widget)->tree); + /* scrolled window */ + GTK_SAT_TREE (widget)->swin = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (GTK_SAT_TREE (widget)->swin), + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - //gtk_container_add (GTK_CONTAINER (widget), GTK_SAT_TREE (widget)->swin); - gtk_box_pack_start (GTK_BOX (widget), GTK_SAT_TREE (widget)->swin, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (GTK_SAT_TREE (widget)->swin), + GTK_SAT_TREE (widget)->tree); - /* expand and collabse buttons */ - expbut = gtk_button_new_with_label (_("Expand")); - tips = gtk_tooltips_new (); - gtk_tooltips_set_tip (tips, expbut, - _("Expand all nodes in the tree to make it searchable"), - NULL); - g_signal_connect (expbut, "clicked", G_CALLBACK (expand_cb), sat_tree); + //gtk_container_add (GTK_CONTAINER (widget), GTK_SAT_TREE (widget)->swin); + gtk_box_pack_start (GTK_BOX (widget), GTK_SAT_TREE (widget)->swin, TRUE, TRUE, 0); - colbut = gtk_button_new_with_label (_("Collapse")); - tips = gtk_tooltips_new (); - gtk_tooltips_set_tip (tips, colbut, - _("Collapse all nodes in the tree"), - NULL); - g_signal_connect (colbut, "clicked", G_CALLBACK (collapse_cb), sat_tree); + /* expand and collabse buttons */ + expbut = gtk_button_new_with_label (_("Expand")); + tips = gtk_tooltips_new (); + gtk_tooltips_set_tip (tips, expbut, + _("Expand all nodes in the tree to make it searchable"), + NULL); + g_signal_connect (expbut, "clicked", G_CALLBACK (expand_cb), sat_tree); - hbox = gtk_hbutton_box_new (); - gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_START); - gtk_box_pack_start (GTK_BOX (hbox), expbut, FALSE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (hbox), colbut, FALSE, TRUE, 0); + colbut = gtk_button_new_with_label (_("Collapse")); + tips = gtk_tooltips_new (); + gtk_tooltips_set_tip (tips, colbut, + _("Collapse all nodes in the tree"), + NULL); + g_signal_connect (colbut, "clicked", G_CALLBACK (collapse_cb), sat_tree); - gtk_box_pack_start (GTK_BOX (widget), hbox, FALSE, FALSE, 5); + hbox = gtk_hbutton_box_new (); + gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_START); + gtk_box_pack_start (GTK_BOX (hbox), expbut, FALSE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (hbox), colbut, FALSE, TRUE, 0); - gtk_widget_show_all (widget); + gtk_box_pack_start (GTK_BOX (widget), hbox, FALSE, FALSE, 5); + gtk_widget_show_all (widget); - /* initialise selection */ - GTK_SAT_TREE (widget)->selection = NULL; + /* initialise selection */ + GTK_SAT_TREE (widget)->selection = NULL; - return widget; + + return widget; } /** FIXME: flags not needed here */ static GtkTreeModel * -create_and_fill_model (guint flags) + create_and_fill_model (guint flags) { - GtkTreeStore *store; /* the list store data structure */ - GtkTreeIter node; /* new top level node added to the tree store */ - GDir *dir; - gchar *dirname; - gchar *path; - gchar *nodename; - gchar **buffv; - const gchar *fname; - guint num = 0; + GtkTreeStore *store; /* the list store data structure */ + GtkTreeIter node; /* new top level node added to the tree store */ + GDir *dir; + gchar *dirname; + gchar *path; + gchar *nodename; + gchar **buffv; + const gchar *fname; + guint num = 0; - /* create a new tree store */ - store = gtk_tree_store_new (GTK_SAT_TREE_COL_NUM, - G_TYPE_STRING, // name - G_TYPE_INT, // catnum - G_TYPE_STRING, // epoch - G_TYPE_BOOLEAN, // selected - G_TYPE_BOOLEAN // visible - ); + /* create a new tree store */ + store = gtk_tree_store_new (GTK_SAT_TREE_COL_NUM, + G_TYPE_STRING, // name + G_TYPE_INT, // catnum + G_TYPE_STRING, // epoch + G_TYPE_BOOLEAN, // selected + G_TYPE_BOOLEAN // visible + ); - 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); - /* debug message */ - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s:%d: Directory is: %s"), - __FILE__, __LINE__, dirname); + /* debug message */ + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s:%d: Directory is: %s"), + __FILE__, __LINE__, dirname); - dir = g_dir_open (dirname, 0, NULL); + dir = g_dir_open (dirname, 0, NULL); - /* no tle files */ - if (!dir) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%d: No .tle files found in %s."), - __FILE__, __LINE__, dirname); + /* no tle files */ + if (!dir) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%d: No .tle files found in %s."), + __FILE__, __LINE__, dirname); - g_free (dirname); - - return GTK_TREE_MODEL (store);; - } + g_free (dirname); - /* Scan data directory for .tle files. - For each file scan through the file and - add entry to the tree. - */ - while ((fname = g_dir_read_name (dir))) { + return GTK_TREE_MODEL (store);; + } - if (g_strrstr (fname, ".tle")) { + /* Scan data directory for .tle files. + For each file scan through the file and + add entry to the tree. + */ + while ((fname = g_dir_read_name (dir))) { - buffv = g_strsplit (fname, ".tle", 0); - nodename = g_strdup (buffv[0]); - nodename[0] = g_ascii_toupper (nodename[0]); + if (g_strrstr (fname, ".tle")) { - /* create a new top level node in the tree */ - gtk_tree_store_append (store, &node, NULL); - gtk_tree_store_set (store, &node, - GTK_SAT_TREE_COL_NAME, nodename, - GTK_SAT_TREE_COL_VIS, FALSE, - -1); + buffv = g_strsplit (fname, ".tle", 0); + nodename = g_strdup (buffv[0]); + nodename[0] = g_ascii_toupper (nodename[0]); - /* build full path til file and sweep it for sats */ - path = g_strconcat (dirname, G_DIR_SEPARATOR_S, - fname, NULL); - - num = scan_tle_file (path, store, &node); + /* create a new top level node in the tree */ + gtk_tree_store_append (store, &node, NULL); + gtk_tree_store_set (store, &node, + GTK_SAT_TREE_COL_NAME, nodename, + GTK_SAT_TREE_COL_VIS, FALSE, + -1); - g_free (path); - g_free (nodename); - g_strfreev (buffv); + /* build full path til file and sweep it for sats */ + path = g_strconcat (dirname, G_DIR_SEPARATOR_S, + fname, NULL); - sat_log_log (SAT_LOG_LEVEL_MSG, - _("%s:%d: Read %d sats from %s "), - __FILE__, __LINE__, num, fname); - } + num = scan_tle_file (path, store, &node); - } + g_free (path); + g_free (nodename); + g_strfreev (buffv); - g_dir_close (dir); - g_free (dirname); + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s:%d: Read %d sats from %s "), + __FILE__, __LINE__, num, fname); + } + } - return GTK_TREE_MODEL (store); + g_dir_close (dir); + g_free (dirname); + + + return GTK_TREE_MODEL (store); } @@ -396,87 +397,87 @@ * \return The number of satellites that have been read into the tree. */ static gint -scan_tle_file (const gchar *path, GtkTreeStore *store, GtkTreeIter *node) + scan_tle_file (const gchar *path, GtkTreeStore *store, GtkTreeIter *node) { - guint i = 0; - guint j; - GIOChannel *tlefile; - GError *error = NULL; - GtkTreeIter sat_iter; - gchar *line; - gsize length; - gchar catstr[6]; + guint i = 0; + guint j; + GIOChannel *tlefile; + GError *error = NULL; + GtkTreeIter sat_iter; + gchar *line; + gsize length; + gchar catstr[6]; - gchar *satnam; - guint catnum; + gchar *satnam; + guint catnum; - /* open IO channel and read 3 lines at a time */ - tlefile = g_io_channel_new_file (path, "r", &error); + /* open IO channel and read 3 lines at a time */ + tlefile = g_io_channel_new_file (path, "r", &error); - if (error != NULL) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s:%d: Failed to open %s (%s)"), - __FILE__, __LINE__, path, error->message); - g_clear_error (&error); - } - else if (tlefile) { + if (error != NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s:%d: Failed to open %s (%s)"), + __FILE__, __LINE__, path, error->message); + g_clear_error (&error); + } + else if (tlefile) { - /*** FIXME: More error handling please */ + /*** FIXME: More error handling please */ - while (g_io_channel_read_line (tlefile, &line, &length, NULL, NULL) != - G_IO_STATUS_EOF) { + while (g_io_channel_read_line (tlefile, &line, &length, NULL, NULL) != + G_IO_STATUS_EOF) { - /* satellite name can be found in the first line */ - satnam = g_strdup (line); - g_strchomp (satnam); + /* satellite name can be found in the first line */ + satnam = g_strdup (line); + g_strchomp (satnam); - /* free allocated line */ - g_free (line); + /* free allocated 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'; + /* extract catnum from second line; index 2..6 */ + g_io_channel_read_line (tlefile, &line, &length, + NULL, NULL); - catnum = (guint) g_ascii_strtod (catstr, NULL); + for (j = 2; j < 7; j++) { + catstr[j-2] = line[j]; + } + catstr[5] = '\0'; - /* insert satnam and catnum */ - gtk_tree_store_append (store, &sat_iter, node); - gtk_tree_store_set (store, &sat_iter, - GTK_SAT_TREE_COL_NAME, satnam, - GTK_SAT_TREE_COL_CATNUM, catnum, - GTK_SAT_TREE_COL_SEL, FALSE, - GTK_SAT_TREE_COL_VIS, TRUE, - -1); - + catnum = (guint) g_ascii_strtod (catstr, NULL); - /* free mem */ - g_free (satnam); + /* insert satnam and catnum */ + gtk_tree_store_append (store, &sat_iter, node); + gtk_tree_store_set (store, &sat_iter, + GTK_SAT_TREE_COL_NAME, satnam, + GTK_SAT_TREE_COL_CATNUM, catnum, + GTK_SAT_TREE_COL_SEL, FALSE, + GTK_SAT_TREE_COL_VIS, TRUE, + -1); - /* free allocated line */ - g_free (line); - /* read the third line */ - g_io_channel_read_line (tlefile, &line, &length, NULL, NULL); + /* free mem */ + g_free (satnam); - /* free allocated line */ - g_free (line); + /* free allocated line */ + g_free (line); - i++; - } + /* read the third line */ + g_io_channel_read_line (tlefile, &line, &length, NULL, NULL); - /* close IO chanel; don't care about status */ - g_io_channel_shutdown (tlefile, TRUE, NULL); - g_io_channel_unref (tlefile); - } + /* free allocated line */ + g_free (line); - return i; + i++; + } + + /* close IO chanel; don't care about status */ + g_io_channel_shutdown (tlefile, TRUE, NULL); + g_io_channel_unref (tlefile); + } + + return i; } @@ -489,80 +490,80 @@ * It will add or remove the toggled satellite from the list of selected sats. */ static void -column_toggled (GtkCellRendererToggle *cell, - gchar *path_str, - gpointer data) + column_toggled (GtkCellRendererToggle *cell, + gchar *path_str, + gpointer data) { - GtkSatTree *sat_tree = GTK_SAT_TREE (data); - GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (sat_tree->tree)); - GtkTreePath *path = gtk_tree_path_new_from_string (path_str); - GtkTreeIter iter; - gboolean toggle_item; - guint catnum; + GtkSatTree *sat_tree = GTK_SAT_TREE (data); + GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (sat_tree->tree)); + GtkTreePath *path = gtk_tree_path_new_from_string (path_str); + GtkTreeIter iter; + gboolean toggle_item; + guint catnum; - /* get toggled iter */ - gtk_tree_model_get_iter (model, &iter, path); - gtk_tree_model_get (model, &iter, - GTK_SAT_TREE_COL_CATNUM, &catnum, - GTK_SAT_TREE_COL_SEL, &toggle_item, - -1); + /* get toggled iter */ + gtk_tree_model_get_iter (model, &iter, path); + gtk_tree_model_get (model, &iter, + GTK_SAT_TREE_COL_CATNUM, &catnum, + GTK_SAT_TREE_COL_SEL, &toggle_item, + -1); - /* do something with the value */ - toggle_item ^= 1; + /* do something with the value */ + toggle_item ^= 1; - if (toggle_item) { + if (toggle_item) { - /* only append if sat not already in list */ - if (!g_slist_find (sat_tree->selection, GUINT_TO_POINTER (catnum))) { - sat_tree->selection = g_slist_append (sat_tree->selection, - GUINT_TO_POINTER (catnum)); - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s:%d: Satellite %d selected."), - __FILE__, __LINE__, catnum); + /* only append if sat not already in list */ + if (!g_slist_find (sat_tree->selection, GUINT_TO_POINTER (catnum))) { + sat_tree->selection = g_slist_append (sat_tree->selection, + GUINT_TO_POINTER (catnum)); + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s:%d: Satellite %d selected."), + __FILE__, __LINE__, catnum); - /* Scan the tree for other instances of this sat. For example is - CUTE-1.7 present in both AMATEUR and CUBESAT. - We will need access to both the sat_tree and the catnum in the - foreach callback, so we attach catnum as data to the sat_tree - */ - g_object_set_data (G_OBJECT (sat_tree), "tmp", GUINT_TO_POINTER (catnum)); - - /* find the satellite in the tree */ - gtk_tree_model_foreach (model, check_and_select_sat, sat_tree); + /* Scan the tree for other instances of this sat. For example is + CUTE-1.7 present in both AMATEUR and CUBESAT. + We will need access to both the sat_tree and the catnum in the + foreach callback, so we attach catnum as data to the sat_tree + */ + g_object_set_data (G_OBJECT (sat_tree), "tmp", GUINT_TO_POINTER (catnum)); - } - else { - sat_log_log (SAT_LOG_LEVEL_MSG, - _("%s:%d: Satellite %d already selected; skip..."), - __FILE__, __LINE__, catnum); - } - } - else { - sat_tree->selection = g_slist_remove (sat_tree->selection, - GUINT_TO_POINTER (catnum)); - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s:%d: Satellite %d de-selected."), - __FILE__, __LINE__, catnum); - - /* Scan the tree for other instances of this sat. For example is - CUTE-1.7 present in both AMATEUR and CUBESAT. - We will need access to both the sat_tree and the catnum in the - foreach callback, so we attach catnum as data to the sat_tree - */ - g_object_set_data (G_OBJECT (sat_tree), "tmp", GUINT_TO_POINTER (catnum)); - - /* find the satellite in the tree */ - gtk_tree_model_foreach (model, uncheck_sat, sat_tree); - } + /* find the satellite in the tree */ + gtk_tree_model_foreach (model, check_and_select_sat, sat_tree); - /* set new value */ - gtk_tree_store_set (GTK_TREE_STORE (model), &iter, - GTK_SAT_TREE_COL_SEL, toggle_item, - -1); + } + else { + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s:%d: Satellite %d already selected; skip..."), + __FILE__, __LINE__, catnum); + } + } + else { + sat_tree->selection = g_slist_remove (sat_tree->selection, + GUINT_TO_POINTER (catnum)); + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s:%d: Satellite %d de-selected."), + __FILE__, __LINE__, catnum); - /* clean up */ - gtk_tree_path_free (path); + /* Scan the tree for other instances of this sat. For example is + CUTE-1.7 present in both AMATEUR and CUBESAT. + We will need access to both the sat_tree and the catnum in the + foreach callback, so we attach catnum as data to the sat_tree + */ + g_object_set_data (G_OBJECT (sat_tree), "tmp", GUINT_TO_POINTER (catnum)); + + /* find the satellite in the tree */ + gtk_tree_model_foreach (model, uncheck_sat, sat_tree); + } + + /* set new value */ + gtk_tree_store_set (GTK_TREE_STORE (model), &iter, + GTK_SAT_TREE_COL_SEL, toggle_item, + -1); + + /* clean up */ + gtk_tree_path_free (path); } @@ -571,38 +572,38 @@ * \param catnum Catalogue number of satellite to be selected. */ void -gtk_sat_tree_select (GtkSatTree *sat_tree, guint catnum) + gtk_sat_tree_select (GtkSatTree *sat_tree, guint catnum) { - /* sanity check */ - if ((sat_tree == NULL) || !IS_GTK_SAT_TREE (sat_tree)) { + /* sanity check */ + if ((sat_tree == NULL) || !IS_GTK_SAT_TREE (sat_tree)) { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Invalid GtkSatTree!"), - __FUNCTION__); + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Invalid GtkSatTree!"), + __FUNCTION__); - return; - } + return; + } - if (!g_slist_find (sat_tree->selection, GUINT_TO_POINTER (catnum))) { + if (!g_slist_find (sat_tree->selection, GUINT_TO_POINTER (catnum))) { - GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (sat_tree->tree)); + GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (sat_tree->tree)); - /* we will need access to both the sat_tree and the catnum in the - foreach callback, so we attach catnum as data to the sat_tree - */ - g_object_set_data (G_OBJECT (sat_tree), "tmp", GUINT_TO_POINTER (catnum)); + /* we will need access to both the sat_tree and the catnum in the + foreach callback, so we attach catnum as data to the sat_tree + */ + g_object_set_data (G_OBJECT (sat_tree), "tmp", GUINT_TO_POINTER (catnum)); - /* find the satellite in the tree */ - gtk_tree_model_foreach (model, check_and_select_sat, sat_tree); + /* find the satellite in the tree */ + gtk_tree_model_foreach (model, check_and_select_sat, sat_tree); - } - else { - /* else do nothing since the sat is already selected */ - sat_log_log (SAT_LOG_LEVEL_MSG, - _("%s: Satellite %d already selected; skip..."), - __FUNCTION__, catnum); - } + } + else { + /* else do nothing since the sat is already selected */ + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: Satellite %d already selected; skip..."), + __FUNCTION__, catnum); + } } @@ -625,51 +626,51 @@ * TLE file and we want to chak them all, not just the clicked instance). */ static gboolean -check_and_select_sat (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data) + check_and_select_sat (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data) { - GtkSatTree *sat_tree = GTK_SAT_TREE (data); - guint cat1, cat2; + GtkSatTree *sat_tree = GTK_SAT_TREE (data); + guint cat1, cat2; - cat1 = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (data), "tmp")); + cat1 = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (data), "tmp")); - gtk_tree_model_get (model, iter, - GTK_SAT_TREE_COL_CATNUM, &cat2, - -1); + gtk_tree_model_get (model, iter, + GTK_SAT_TREE_COL_CATNUM, &cat2, + -1); - if (cat1 == cat2) { - /* we have a match */ - gtk_tree_store_set (GTK_TREE_STORE (model), iter, - GTK_SAT_TREE_COL_SEL, TRUE, - -1); + if (cat1 == cat2) { + /* we have a match */ + gtk_tree_store_set (GTK_TREE_STORE (model), iter, + GTK_SAT_TREE_COL_SEL, TRUE, + -1); - /* only append if sat not already in list */ - if (!g_slist_find (sat_tree->selection, GUINT_TO_POINTER (cat1))) { - sat_tree->selection = g_slist_append (sat_tree->selection, - GUINT_TO_POINTER (cat1)); - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s:%d: Satellite %d selected."), - __FILE__, __LINE__, cat1); - } - else { - sat_log_log (SAT_LOG_LEVEL_MSG, - _("%s:%d: Satellite %d already selected; skip..."), - __FILE__, __LINE__, cat1); - } + /* only append if sat not already in list */ + if (!g_slist_find (sat_tree->selection, GUINT_TO_POINTER (cat1))) { + sat_tree->selection = g_slist_append (sat_tree->selection, + GUINT_TO_POINTER (cat1)); + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s:%d: Satellite %d selected."), + __FILE__, __LINE__, cat1); + } + else { + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s:%d: Satellite %d already selected; skip..."), + __FILE__, __LINE__, cat1); + } - /* If we return TRUE here, the foreach would terminate. - We let it run to allow GtkSatTree to mark all instances - of sat the satellite (some sats may be present in two or - more .tle files. - */ - //return TRUE; - } + /* If we return TRUE here, the foreach would terminate. + We let it run to allow GtkSatTree to mark all instances + of sat the satellite (some sats may be present in two or + more .tle files. + */ + //return TRUE; + } - /* continue in order to catch ALL instances of sat */ - return FALSE; + /* continue in order to catch ALL instances of sat */ + return FALSE; } @@ -684,29 +685,29 @@ * is used only to uncheck a deselected satellite. */ static gboolean -uncheck_sat (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data) + uncheck_sat (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data) { - guint cat1, cat2; + guint cat1, cat2; - cat1 = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (data), "tmp")); + cat1 = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (data), "tmp")); - gtk_tree_model_get (model, iter, - GTK_SAT_TREE_COL_CATNUM, &cat2, - -1); + gtk_tree_model_get (model, iter, + GTK_SAT_TREE_COL_CATNUM, &cat2, + -1); - if (cat1 == cat2) { - /* we have a match */ - gtk_tree_store_set (GTK_TREE_STORE (model), iter, - GTK_SAT_TREE_COL_SEL, FALSE, - -1); - } + if (cat1 == cat2) { + /* we have a match */ + gtk_tree_store_set (GTK_TREE_STORE (model), iter, + GTK_SAT_TREE_COL_SEL, FALSE, + -1); + } - /* continue in order to catch ALL instances of sat */ - return FALSE; + /* continue in order to catch ALL instances of sat */ + return FALSE; } @@ -721,45 +722,45 @@ * The returned array should be g_freed when no longer needed. */ guint * -gtk_sat_tree_get_selected (GtkSatTree *sat_tree, gsize *size) + gtk_sat_tree_get_selected (GtkSatTree *sat_tree, gsize *size) { - guint i; - gsize s; - guint *ret; + guint i; + gsize s; + guint *ret; - /* sanity check */ - if ((sat_tree == NULL) || !IS_GTK_SAT_TREE (sat_tree)) { + /* sanity check */ + if ((sat_tree == NULL) || !IS_GTK_SAT_TREE (sat_tree)) { - sat_log_log (SAT_LOG_LEVEL_BUG, - _("%s: Invalid GtkSatTree!"), - __FUNCTION__); + sat_log_log (SAT_LOG_LEVEL_BUG, + _("%s: Invalid GtkSatTree!"), + __FUNCTION__); - return NULL; - } + return NULL; + } - /* parameter are ok */ - s = g_slist_length (sat_tree->selection); + /* parameter are ok */ + s = g_slist_length (sat_tree->selection); - if (s < 1) { - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: There are no satellites selected => NULL."), - __FUNCTION__); + if (s < 1) { + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: There are no satellites selected => NULL."), + __FUNCTION__); - *size = 0; + *size = 0; - return NULL; - } + return NULL; + } - ret = (guint *) g_try_malloc (s * sizeof (guint)); + ret = (guint *) g_try_malloc (s * sizeof (guint)); - for (i = 0; i < s; i++) { - ret[i] = GPOINTER_TO_UINT (g_slist_nth_data (sat_tree->selection, i)); - } + for (i = 0; i < s; i++) { + ret[i] = GPOINTER_TO_UINT (g_slist_nth_data (sat_tree->selection, i)); + } - if (size != NULL) - *size = s; + if (size != NULL) + *size = s; - return ret; + return ret; } @@ -775,24 +776,24 @@ * in the name column. */ static gint -compare_func (GtkTreeModel *model, - GtkTreeIter *a, - GtkTreeIter *b, - gpointer userdata) + compare_func (GtkTreeModel *model, + GtkTreeIter *a, + GtkTreeIter *b, + gpointer userdata) { - gchar *sat1,*sat2; - gint ret = 0; + gchar *sat1,*sat2; + gint ret = 0; - gtk_tree_model_get(model, a, GTK_SAT_TREE_COL_NAME, &sat1, -1); - gtk_tree_model_get(model, b, GTK_SAT_TREE_COL_NAME, &sat2, -1); + gtk_tree_model_get(model, a, GTK_SAT_TREE_COL_NAME, &sat1, -1); + gtk_tree_model_get(model, b, GTK_SAT_TREE_COL_NAME, &sat2, -1); - ret = g_ascii_strcasecmp (sat1, sat2); + ret = g_ascii_strcasecmp (sat1, sat2); - g_free (sat1); - g_free (sat2); + g_free (sat1); + g_free (sat2); - return ret; + return ret; } @@ -805,9 +806,9 @@ * searchable. */ static void -expand_cb (GtkWidget *button, gpointer tree) + expand_cb (GtkWidget *button, gpointer tree) { - gtk_tree_view_expand_all (GTK_TREE_VIEW (GTK_SAT_TREE (tree)->tree)); + gtk_tree_view_expand_all (GTK_TREE_VIEW (GTK_SAT_TREE (tree)->tree)); } @@ -818,8 +819,8 @@ * This function collapses all rows in the tree view. */ static void -collapse_cb (GtkWidget *button, gpointer tree) + collapse_cb (GtkWidget *button, gpointer tree) { - gtk_tree_view_collapse_all (GTK_TREE_VIEW (GTK_SAT_TREE (tree)->tree)); + gtk_tree_view_collapse_all (GTK_TREE_VIEW (GTK_SAT_TREE (tree)->tree)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-06 13:55:15
|
Revision: 374 http://gpredict.svn.sourceforge.net/gpredict/?rev=374&view=rev Author: csete Date: 2009-08-06 13:42:26 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Changed error message to reflect new configuration. Fixed indent. Modified Paths: -------------- trunk/src/main.c Modified: trunk/src/main.c =================================================================== --- trunk/src/main.c 2009-08-06 13:41:11 UTC (rev 373) +++ trunk/src/main.c 2009-08-06 13:42:26 UTC (rev 374) @@ -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 @@ -85,67 +85,67 @@ int -main (int argc, char *argv[]) + main (int argc, char *argv[]) { - guint error = 0; + guint error = 0; #ifdef G_OS_WIN32 - printf ("Starting gpredict. This may take some time...\n"); + printf ("Starting gpredict. This may take some time...\n"); #endif #ifdef ENABLE_NLS - bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR); - bind_textdomain_codeset (PACKAGE, "UTF-8"); - textdomain (PACKAGE); + bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR); + bind_textdomain_codeset (PACKAGE, "UTF-8"); + textdomain (PACKAGE); #endif - gtk_set_locale (); - gtk_init (&argc, &argv); + gtk_set_locale (); + gtk_init (&argc, &argv); - /* start logger first, so that we can catch error messages if any */ - sat_log_init (); + /* start logger first, so that we can catch error messages if any */ + sat_log_init (); - /* check that user settings are ok */ - error = first_time_check_run (); + /* 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"\ - "A possible solution would be to remove the .gpredict2 data dir\n"\ - "in your home directory"), - __FUNCTION__, error); + if (error) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: User config check failed (code %d). This is fatal.\n"\ + "A possible solution would be to remove the .config/Gpredict data dir\n"\ + "in your home directory"), + __FUNCTION__, error); - return 1; - } + 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__); + /* 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; - } + return -1; + } - sat_cfg_load (); + sat_cfg_load (); - /* get logging level */ - sat_log_set_level (sat_cfg_get_int (SAT_CFG_INT_LOG_LEVEL)); + /* get logging level */ + sat_log_set_level (sat_cfg_get_int (SAT_CFG_INT_LOG_LEVEL)); - /* create application */ - gpredict_app_create (); - gtk_widget_show_all (app); + /* create application */ + gpredict_app_create (); + gtk_widget_show_all (app); - //sat_debugger_run (); + //sat_debugger_run (); - /* launch TLE monitoring task; 10 min interval */ - tle_mon_id = g_timeout_add (600000, tle_mon_task, NULL); + /* launch TLE monitoring task; 10 min interval */ + tle_mon_id = g_timeout_add (600000, tle_mon_task, NULL); test_ui (); - gtk_main (); + gtk_main (); - return 0; + return 0; } static void test_ui (void) @@ -168,61 +168,61 @@ * */ static void -gpredict_app_create () + gpredict_app_create () { - gchar *title; /* window title */ - gchar *icon; /* icon file name */ - - /* create window title and file name for window icon */ - title = g_strdup (_("GPREDICT")); - icon = icon_file_name ("gpredict-icon.png"); + gchar *title; /* window title */ + gchar *icon; /* icon file name */ - /* ceate window, add title and icon, restore size and position */ - app = gtk_window_new (GTK_WINDOW_TOPLEVEL); + /* create window title and file name for window icon */ + title = g_strdup (_("GPREDICT")); + icon = icon_file_name ("gpredict-icon.png"); - gtk_window_set_title (GTK_WINDOW (app), title); + /* ceate window, add title and icon, restore size and position */ + app = gtk_window_new (GTK_WINDOW_TOPLEVEL); - /* restore window position and size if requested by config */ - /* trunk/gtk/gtkblist.c */ - /* size is always restored */ - gtk_window_set_default_size (GTK_WINDOW (app), - sat_cfg_get_int (SAT_CFG_INT_WINDOW_WIDTH), - sat_cfg_get_int (SAT_CFG_INT_WINDOW_HEIGHT)); + gtk_window_set_title (GTK_WINDOW (app), title); - /* position restored only if requested in config */ - if (sat_cfg_get_bool (SAT_CFG_BOOL_MAIN_WIN_POS)) { - gtk_window_move (GTK_WINDOW (app), - sat_cfg_get_int (SAT_CFG_INT_WINDOW_POS_X), - sat_cfg_get_int (SAT_CFG_INT_WINDOW_POS_Y)); - } + /* restore window position and size if requested by config */ + /* trunk/gtk/gtkblist.c */ + /* size is always restored */ + gtk_window_set_default_size (GTK_WINDOW (app), + sat_cfg_get_int (SAT_CFG_INT_WINDOW_WIDTH), + sat_cfg_get_int (SAT_CFG_INT_WINDOW_HEIGHT)); - gtk_container_add (GTK_CONTAINER (app), - gui_create (app)); + /* position restored only if requested in config */ + if (sat_cfg_get_bool (SAT_CFG_BOOL_MAIN_WIN_POS)) { + gtk_window_move (GTK_WINDOW (app), + sat_cfg_get_int (SAT_CFG_INT_WINDOW_POS_X), + sat_cfg_get_int (SAT_CFG_INT_WINDOW_POS_Y)); + } - if (g_file_test (icon, G_FILE_TEST_EXISTS)) { - gtk_window_set_icon_from_file (GTK_WINDOW (app), - icon, - NULL); - } + gtk_container_add (GTK_CONTAINER (app), + gui_create (app)); - g_free (title); - g_free (icon); + if (g_file_test (icon, G_FILE_TEST_EXISTS)) { + gtk_window_set_icon_from_file (GTK_WINDOW (app), + icon, + NULL); + } - /* connect delete and destroy signals */ - g_signal_connect (G_OBJECT (app), "delete_event", - G_CALLBACK (gpredict_app_delete), NULL); - g_signal_connect (G_OBJECT (app), "configure_event", - G_CALLBACK (gpredict_app_config), NULL); - g_signal_connect (G_OBJECT (app), "destroy", - G_CALLBACK (gpredict_app_destroy), NULL); + g_free (title); + g_free (icon); - /* register UNIX signals as well so that we - have a chance to clean up external resources. - */ - signal (SIGTERM, (void *) gpredict_sig_handler); - signal (SIGINT, (void *) gpredict_sig_handler); - signal (SIGABRT, (void *) gpredict_sig_handler); + /* connect delete and destroy signals */ + g_signal_connect (G_OBJECT (app), "delete_event", + G_CALLBACK (gpredict_app_delete), NULL); + g_signal_connect (G_OBJECT (app), "configure_event", + G_CALLBACK (gpredict_app_config), NULL); + g_signal_connect (G_OBJECT (app), "destroy", + G_CALLBACK (gpredict_app_destroy), NULL); + /* register UNIX signals as well so that we + have a chance to clean up external resources. + */ + signal (SIGTERM, (void *) gpredict_sig_handler); + signal (SIGINT, (void *) gpredict_sig_handler); + signal (SIGABRT, (void *) gpredict_sig_handler); + } @@ -236,12 +236,12 @@ * 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"); */ + /* satlog_log (SAT_LOG_ERROR, "Received signal: %d\n", sig); */ + /* satlog_log (SAT_LOG_ERROR, "Trying clean exit...\n"); */ - gtk_widget_destroy (app); + gtk_widget_destroy (app); } @@ -258,11 +258,11 @@ * */ static gint -gpredict_app_delete (GtkWidget *widget, - GdkEvent *event, - gpointer data) + gpredict_app_delete (GtkWidget *widget, + GdkEvent *event, + gpointer data) { - return FALSE; + return FALSE; } @@ -277,34 +277,34 @@ * */ static void -gpredict_app_destroy (GtkWidget *widget, - gpointer data) + gpredict_app_destroy (GtkWidget *widget, + gpointer data) { - /* stop TLE monitoring task */ - tle_mon_stop (); + /* stop TLE monitoring task */ + tle_mon_stop (); - /* GUI timers are stopped automatically */ + /* GUI timers are stopped automatically */ - /* stop timeouts */ + /* stop timeouts */ - /* stop other sub-systems */ - tle_lookup_close (); + /* stop other sub-systems */ + tle_lookup_close (); - /* configuration data */ - mod_mgr_save_state (); + /* configuration data */ + mod_mgr_save_state (); - /* not good, have to use configure event instead (see API doc) */ - /* gtk_window_get_size (GTK_WINDOW (app), &w, &h); - sat_cfg_set_int (SAT_CFG_INT_WINDOW_WIDTH, w); - sat_cfg_set_int (SAT_CFG_INT_WINDOW_HEIGHT, h); - */ - sat_cfg_save (); - sat_log_close (); - sat_cfg_close (); + /* not good, have to use configure event instead (see API doc) */ + /* gtk_window_get_size (GTK_WINDOW (app), &w, &h); + sat_cfg_set_int (SAT_CFG_INT_WINDOW_WIDTH, w); + sat_cfg_set_int (SAT_CFG_INT_WINDOW_HEIGHT, h); + */ + sat_cfg_save (); + sat_log_close (); + sat_cfg_close (); - /* exit Gtk+ */ - gtk_main_quit (); + /* exit Gtk+ */ + gtk_main_quit (); } @@ -325,40 +325,40 @@ * */ static gboolean -gpredict_app_config (GtkWidget *widget, GdkEventConfigure *event, gpointer data) + gpredict_app_config (GtkWidget *widget, GdkEventConfigure *event, gpointer data) { - gint x, y; + gint x, y; - /* data is only useful when window is visible */ - if (GTK_WIDGET_VISIBLE (widget)) - gtk_window_get_position (GTK_WINDOW (widget), &x, &y); - else - return FALSE; /* carry on normally */ - + /* data is only useful when window is visible */ + if (GTK_WIDGET_VISIBLE (widget)) + gtk_window_get_position (GTK_WINDOW (widget), &x, &y); + else + return FALSE; /* carry on normally */ + #ifdef G_OS_WIN32 - /* Workaround for GTK+ bug # 169811 - "configure_event" is fired - when the window is being maximized */ - if (gdk_window_get_state (widget->window) & GDK_WINDOW_STATE_MAXIMIZED) { - return FALSE; - } + /* Workaround for GTK+ bug # 169811 - "configure_event" is fired + when the window is being maximized */ + if (gdk_window_get_state (widget->window) & GDK_WINDOW_STATE_MAXIMIZED) { + return FALSE; + } #endif - /* don't save off-screen positioning */ - if (x + event->width < 0 || y + event->height < 0 || - x > gdk_screen_width() || y > gdk_screen_height()) { + /* don't save off-screen positioning */ + if (x + event->width < 0 || y + event->height < 0 || + x > gdk_screen_width() || y > gdk_screen_height()) { - return FALSE; /* carry on normally */ - } + return FALSE; /* carry on normally */ + } - /* store the position and size */ - sat_cfg_set_int (SAT_CFG_INT_WINDOW_POS_X, x); - sat_cfg_set_int (SAT_CFG_INT_WINDOW_POS_Y, y); - sat_cfg_set_int (SAT_CFG_INT_WINDOW_WIDTH, event->width); - sat_cfg_set_int (SAT_CFG_INT_WINDOW_HEIGHT, event->height); + /* store the position and size */ + sat_cfg_set_int (SAT_CFG_INT_WINDOW_POS_X, x); + sat_cfg_set_int (SAT_CFG_INT_WINDOW_POS_Y, y); + sat_cfg_set_int (SAT_CFG_INT_WINDOW_WIDTH, event->width); + sat_cfg_set_int (SAT_CFG_INT_WINDOW_HEIGHT, event->height); - /* continue to handle event normally */ - return FALSE; + /* continue to handle event normally */ + return FALSE; } @@ -375,136 +375,136 @@ * 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; - GtkWidget *dialog; - GError *err = NULL; + glong last,now,thrld; + GTimeVal tval; + GtkWidget *dialog; + GError *err = NULL; - /* sat_log_log (SAT_LOG_LEVEL_DEBUG, */ - /* _("%s: Checking whether TLE check should be executed..."), */ - /* __FUNCTION__); */ + /* sat_log_log (SAT_LOG_LEVEL_DEBUG, */ + /* _("%s: Checking whether TLE check should be executed..."), */ + /* __FUNCTION__); */ - /* get time of last update */ - last = sat_cfg_get_int (SAT_CFG_INT_TLE_LAST_UPDATE); - - /* get current time */ - g_get_current_time (&tval); - now = tval.tv_sec; - - /* threshold */ - switch (sat_cfg_get_int (SAT_CFG_INT_TLE_AUTO_UPD_FREQ)) { + /* get time of last update */ + last = sat_cfg_get_int (SAT_CFG_INT_TLE_LAST_UPDATE); - case TLE_AUTO_UPDATE_MONTHLY: - thrld = 2592000; - break; + /* get current time */ + g_get_current_time (&tval); + now = tval.tv_sec; - case TLE_AUTO_UPDATE_WEEKLY: - thrld = 604800; - break; + /* threshold */ + switch (sat_cfg_get_int (SAT_CFG_INT_TLE_AUTO_UPD_FREQ)) { - case TLE_AUTO_UPDATE_DAILY: - thrld = 86400; - break; + case TLE_AUTO_UPDATE_MONTHLY: + thrld = 2592000; + break; - /* set default to "infinite" */ - default: - thrld = G_MAXLONG; - break; - } + case TLE_AUTO_UPDATE_WEEKLY: + thrld = 604800; + break; - if ((now - last) < thrld) { - /* too early */ - /* sat_log_log (SAT_LOG_LEVEL_DEBUG, */ - /* _("%s: Threshold has not been passed yet."), */ - /* __FUNCTION__, last, now, thrld); */ - } - else { - /* time to update */ - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Time threshold has been passed."), - __FUNCTION__); + case TLE_AUTO_UPDATE_DAILY: + thrld = 86400; + break; - /* find out what to do */ - if (sat_cfg_get_int (SAT_CFG_INT_TLE_AUTO_UPD_ACTION) == TLE_AUTO_UPDATE_GOAHEAD) { + /* set default to "infinite" */ + default: + thrld = G_MAXLONG; + break; + } - /* start update process in separate thread */ - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Starting new update thread."), - __FUNCTION__); + if ((now - last) < thrld) { + /* too early */ + /* sat_log_log (SAT_LOG_LEVEL_DEBUG, */ + /* _("%s: Threshold has not been passed yet."), */ + /* __FUNCTION__, last, now, thrld); */ + } + else { + /* time to update */ + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Time threshold has been passed."), + __FUNCTION__); - if (!g_thread_supported ()) - g_thread_init (NULL); + /* find out what to do */ + if (sat_cfg_get_int (SAT_CFG_INT_TLE_AUTO_UPD_ACTION) == TLE_AUTO_UPDATE_GOAHEAD) { - g_thread_create (update_tle_thread, NULL, FALSE, &err); + /* start update process in separate thread */ + sat_log_log (SAT_LOG_LEVEL_DEBUG, + _("%s: Starting new update thread."), + __FUNCTION__); - if (err != NULL) - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Failed to create TLE update thread (%s)"), - __FUNCTION__, err->message); + if (!g_thread_supported ()) + g_thread_init (NULL); - } - else if (!tle_upd_note_sent) { - /* notify user */ - dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (app), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - _("Your TLE files are getting out of date.\n"\ - "You can update them by selecting\n"\ - "<b>Edit -> Update TLE</b>\n"\ - "in the menubar.")); + g_thread_create (update_tle_thread, NULL, FALSE, &err); - /* Destroy the dialog when the user responds to it (e.g. clicks a button) */ - g_signal_connect_swapped (dialog, "response", - G_CALLBACK (gtk_widget_destroy), - dialog); + if (err != NULL) + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Failed to create TLE update thread (%s)"), + __FUNCTION__, err->message); - gtk_widget_show_all (dialog); + } + else if (!tle_upd_note_sent) { + /* notify user */ + dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (app), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_OK, + _("Your TLE files are getting out of date.\n"\ + "You can update them by selecting\n"\ + "<b>Edit -> Update TLE</b>\n"\ + "in the menubar.")); - tle_upd_note_sent = TRUE; - } - } + /* Destroy the dialog when the user responds to it (e.g. clicks a button) */ + g_signal_connect_swapped (dialog, "response", + G_CALLBACK (gtk_widget_destroy), + dialog); - return TRUE; + gtk_widget_show_all (dialog); + + tle_upd_note_sent = TRUE; + } + } + + return TRUE; } /** \brief Stop TLE monitoring and any pending updates. */ static void -tle_mon_stop () + tle_mon_stop () { - gboolean retcode; + gboolean retcode; - if (tle_mon_id) { - retcode = g_source_remove (tle_mon_id); + if (tle_mon_id) { + retcode = g_source_remove (tle_mon_id); - if (!retcode) - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Could not find TLE monitoring task (ID = %d)"), - __FUNCTION__, tle_mon_id); + if (!retcode) + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Could not find TLE monitoring task (ID = %d)"), + __FUNCTION__, tle_mon_id); - } + } - /* if TLE update is running wait until it is finished */ - while (tle_upd_running) { - g_usleep (1000); - } + /* if TLE update is running wait until it is finished */ + while (tle_upd_running) { + g_usleep (1000); + } } /** \brief Thread function which invokes TLE update */ static gpointer -update_tle_thread (gpointer data) + update_tle_thread (gpointer data) { - tle_upd_running = TRUE; + tle_upd_running = TRUE; - tle_update_from_network (TRUE, NULL, NULL, NULL); + tle_update_from_network (TRUE, NULL, NULL, NULL); - tle_upd_running = FALSE; + tle_upd_running = FALSE; - return NULL; + return NULL; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-06 13:55:09
|
Revision: 375 http://gpredict.svn.sourceforge.net/gpredict/?rev=375&view=rev Author: csete Date: 2009-08-06 13:49:20 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Migrated to new user configuration. Modified Paths: -------------- trunk/src/menubar.c Modified: trunk/src/menubar.c =================================================================== --- trunk/src/menubar.c 2009-08-06 13:42:26 UTC (rev 374) +++ trunk/src/menubar.c 2009-08-06 13:49:20 UTC (rev 375) @@ -258,6 +258,7 @@ { gchar *modnam = NULL; gchar *modfile; + gchar *confdir; GtkWidget *module = NULL; GtkWidget *parent; @@ -274,11 +275,10 @@ _("%s: New module name is %s."), __FUNCTION__, modnam); - modfile = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "modules", G_DIR_SEPARATOR_S, - modnam, - ".mod", NULL); + confdir = get_modules_dir (); + modfile = g_strconcat (confdir, G_DIR_SEPARATOR_S, + modnam, ".mod", NULL); + g_free (confdir); /* create new module */ module = gtk_sat_module_new (modfile); @@ -327,6 +327,7 @@ { gchar *modnam = NULL; gchar *modfile; + gchar *confdir; GtkWidget *module = NULL; GtkWidget *parent; @@ -342,11 +343,10 @@ _("%s: Open module %s."), __FUNCTION__, modnam); - modfile = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "modules", G_DIR_SEPARATOR_S, - modnam, - ".mod", NULL); + confdir = get_modules_dir (); + modfile = g_strconcat (confdir, G_DIR_SEPARATOR_S, + modnam, ".mod", NULL); + g_free (confdir); /* create new module */ module = gtk_sat_module_new (modfile); @@ -805,7 +805,7 @@ /** \brief Select an existing module. * * This function creates a dialog with a list of existing modules - * from /homedir/.gpredict2/modules/ and lets the user select one + * from /homedir/.config/Gpredict/modules/ and lets the user select one * of them. The function will return the name of the selected module * without the .mod suffix. */ @@ -833,10 +833,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", - G_DIR_SEPARATOR_S, "modules", - NULL); + dirname = get_modules_dir (); dir = g_dir_open (dirname, 0, &error); if (dir) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-06 13:55:03
|
Revision: 376 http://gpredict.svn.sourceforge.net/gpredict/?rev=376&view=rev Author: csete Date: 2009-08-06 13:54:55 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Migrated to new user configuration. Modified Paths: -------------- trunk/src/mod-mgr.c Modified: trunk/src/mod-mgr.c =================================================================== --- trunk/src/mod-mgr.c 2009-08-06 13:49:20 UTC (rev 375) +++ trunk/src/mod-mgr.c 2009-08-06 13:54:55 UTC (rev 376) @@ -99,6 +99,7 @@ gint count,i; GtkWidget *module; gchar *modfile; + gchar *confdir; /* create notebook */ nbook = gtk_notebook_new (); @@ -118,11 +119,10 @@ for (i = 0; i < count; i++) { /* get data file name */ - modfile = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - "modules", G_DIR_SEPARATOR_S, - mods[i], - ".mod", NULL); + confdir = get_modules_dir (); + modfile = g_strconcat (confdir, G_DIR_SEPARATOR_S, + mods[i], ".mod", NULL); + g_free (confdir); /* create module */ module = gtk_sat_module_new (modfile); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-06 13:29:47
|
Revision: 371 http://gpredict.svn.sourceforge.net/gpredict/?rev=371&view=rev Author: csete Date: 2009-08-06 13:29:37 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Fix implicit declaration warning. Modified Paths: -------------- trunk/src/gtk-sat-module.c Modified: trunk/src/gtk-sat-module.c =================================================================== --- trunk/src/gtk-sat-module.c 2009-08-06 13:24:48 UTC (rev 370) +++ trunk/src/gtk-sat-module.c 2009-08-06 13:29:37 UTC (rev 371) @@ -65,6 +65,7 @@ #include "gtk-single-sat.h" #include "gtk-rig-ctrl.h" #include "gtk-rot-ctrl.h" +#include "compat.h" //#ifdef G_OS_WIN32 //# include "libc_internal.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-06 13:25:00
|
Revision: 370 http://gpredict.svn.sourceforge.net/gpredict/?rev=370&view=rev Author: csete Date: 2009-08-06 13:24:48 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Migrated to new user configuration. Modified Paths: -------------- trunk/src/gtk-sat-module.c Modified: trunk/src/gtk-sat-module.c =================================================================== --- trunk/src/gtk-sat-module.c 2009-08-06 12:32:31 UTC (rev 369) +++ trunk/src/gtk-sat-module.c 2009-08-06 13:24:48 UTC (rev 370) @@ -537,6 +537,7 @@ { gchar *buffer = NULL; gchar *qthfile; + gchar *confdir; gchar **buffv; GError *error = NULL; @@ -576,9 +577,9 @@ MOD_CFG_QTH_FILE_KEY, SAT_CFG_STR_DEF_QTH); - qthfile = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - buffer, NULL); + confdir = get_user_conf_dir (); + qthfile = g_strconcat (confdir, G_DIR_SEPARATOR_S, buffer, NULL); + /* load QTH data */ if (!qth_data_read (qthfile, module->qth)) { @@ -597,9 +598,7 @@ /* try SAT_CFG_STR_DEF_QTH */ buffer = sat_cfg_get_str (SAT_CFG_STR_DEF_QTH); - qthfile = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, - ".gpredict2", G_DIR_SEPARATOR_S, - buffer, NULL); + qthfile = g_strconcat (confdir, G_DIR_SEPARATOR_S, buffer, NULL); if (!qth_data_read (qthfile, module->qth)) { @@ -617,6 +616,7 @@ } g_free (buffer); + g_free (confdir); g_free (qthfile); @@ -1261,14 +1261,9 @@ gtk_sat_module_close_cb (NULL, module); - cfgfile = g_strconcat (g_get_home_dir (), - G_DIR_SEPARATOR_S, - ".gpredict2", - G_DIR_SEPARATOR_S, - "modules", - G_DIR_SEPARATOR_S, - name, ".mod", - NULL); + gchar *confdir = get_modules_dir (); + cfgfile = g_strconcat (confdir, G_DIR_SEPARATOR_S, name, ".mod", NULL); + g_free (confdir); module = GTK_SAT_MODULE (gtk_sat_module_new (cfgfile)); module->state = laststate; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cs...@us...> - 2009-08-06 12:32:38
|
Revision: 369 http://gpredict.svn.sourceforge.net/gpredict/?rev=369&view=rev Author: csete Date: 2009-08-06 12:32:31 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Migrated to new satdata config. Modified Paths: -------------- trunk/src/gtk-sat-data.c Modified: trunk/src/gtk-sat-data.c =================================================================== --- trunk/src/gtk-sat-data.c 2009-08-06 10:32:24 UTC (rev 368) +++ trunk/src/gtk-sat-data.c 2009-08-06 12:32:31 UTC (rev 369) @@ -31,156 +31,133 @@ #include "sgpsdp/sgp4sdp4.h" #include "gtk-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" +#include "compat.h" /** \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. - * \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. + * \param sat Pointer to a valid sat_t structure. + * \return 0 if successfull, 1 if an I/O error occurred, + * 2 if the TLE data appears to be bad. * - * \bug We should use g_io_channel */ gint gtk_sat_data_read_sat (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; + GError *error = NULL; + GKeyFile *data; + gchar *filename = NULL, *path = NULL; + gchar *tlestr1,*tlestr2,*rawtle; - filename = tle_lookup (catnum); - if (!filename) { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Can not find #%d in any .tle file."), - __FUNCTION__, catnum); + /* ensure that sat != NULL */ + g_return_val_if_fail (sat != NULL, 1); - return 1; - } + /* .sat file names */ + filename = g_strdup_printf ("%d.sat", catnum); + path = sat_file_name_from_catnum (catnum); - /* 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); + /* open .sat file */ + data = g_key_file_new (); + if (!g_key_file_load_from_file (data, path, G_KEY_FILE_KEEP_COMMENTS, &error)) { + /* an error occurred */ + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Failed to load data from %s (%s)"), + __FUNCTION__, path, error->message); - fp = fopen (path, "r"); + g_clear_error (&error); - 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); + errorcode = 1; + } + else { + /* read name, nickname, and website */ + sat->name = g_key_file_get_string (data, NULL, "NAME", &error); + if (error != NULL) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: Error reading NAME from %s (%s)"), + __FUNCTION__, path, error->message); + g_clear_error (&error); + sat->name = g_strdup ("Error"); + } + sat->nickname = g_key_file_get_string (data, NULL, "NICKNAME", &error); + if (error != NULL) { + sat_log_log (SAT_LOG_LEVEL_MSG, + _("%s: Satellite %d has no NICKNAME"), + __FUNCTION__, catnum); + g_clear_error (&error); + sat->nickname = g_strdup (sat->name); + } + sat->website = g_key_file_get_string (data, NULL, "WEBSITE", NULL); /* website may be NULL */ - /* 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); + /* get TLE data */ + tlestr1 = g_key_file_get_string (data, NULL, "TLE1", NULL); + tlestr2 = g_key_file_get_string (data, NULL, "TLE2", NULL); + rawtle = g_strconcat (tlestr1, tlestr2, NULL); - if (catnr == catnum) { + if (!Good_Elements (rawtle)) { + sat_log_log (SAT_LOG_LEVEL_ERROR, + _("%s: TLE data for %d appears to be bad"), + __FUNCTION__, catnum); + errorcode = 2; + } + Convert_Satellite_Data (rawtle, &sat->tle); - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Found #%d in %s"), - __FUNCTION__, - catnum, - path); + g_free (tlestr1); + g_free (tlestr2); + g_free (rawtle); - 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); + /* 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; - errorcode = 2; - } - else { - /* DATA OK, phew... */ - sat_log_log (SAT_LOG_LEVEL_DEBUG, - _("%s: Good data for #%d"), - __FUNCTION__, - catnum); + select_ephemeris (sat); - /* 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; + /* 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; - 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 */ - gtk_sat_data_init_sat (sat, NULL); - - } - } - - } - - fclose (fp); + /* calculate satellite data at epoch */ + gtk_sat_data_init_sat (sat, NULL); } - else { - sat_log_log (SAT_LOG_LEVEL_ERROR, - _("%s: Failed to open %s"), - __FUNCTION__, path); - errorcode = 3; - } - - g_free (path); g_free (filename); + g_free (path); + g_key_file_free (data); return errorcode; } + /** \brief Initialise satellite data. * \param sat The satellite to initialise. * \param qth Optional QTH info, use (0,0) if NULL. 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 10:11:41
|
Revision: 367 http://gpredict.svn.sourceforge.net/gpredict/?rev=367&view=rev Author: csete Date: 2009-08-06 10:11:33 +0000 (Thu, 06 Aug 2009) Log Message: ----------- Add new name fields to sat_t structure. Modified Paths: -------------- trunk/src/sgpsdp/sgp4sdp4.h Modified: trunk/src/sgpsdp/sgp4sdp4.h =================================================================== --- trunk/src/sgpsdp/sgp4sdp4.h 2009-08-06 09:44:45 UTC (rev 366) +++ trunk/src/sgpsdp/sgp4sdp4.h 2009-08-06 10:11:33 UTC (rev 367) @@ -67,7 +67,7 @@ int elset; /*!< Element Set number. */ int revnum; /*!< Revolution Number at epoch. */ - char sat_name[25]; /*!< Satellite name string. */ + char sat_name[25]; /*!< Satellite name string. */ char idesg[9]; /*!< International Designator. */ op_stat_t status; /*!< Operational status. */ @@ -154,6 +154,9 @@ * */ typedef struct { + char *name; + char *nickname; + char *website; tle_t tle; /*!< Keplerian elements */ int flags; /*!< Flags for algo ctrl */ sgpsdp_static_t sgps; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |