[Gpredict-svn] SF.net SVN: gpredict:[939] trunk
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
From: <aa...@us...> - 2011-10-27 22:13:40
|
Revision: 939 http://gpredict.svn.sourceforge.net/gpredict/?rev=939&view=rev Author: aa1vs Date: 2011-10-27 22:13:31 +0000 (Thu, 27 Oct 2011) Log Message: ----------- Consolidate popup callback functions into single file. Modified Paths: -------------- trunk/ChangeLog trunk/src/Makefile.am trunk/src/gtk-event-list-popup.c trunk/src/gtk-polar-view-popup.c trunk/src/gtk-sat-list-popup.c trunk/src/gtk-sat-map-popup.c trunk/src/gtk-single-sat.c Added Paths: ----------- trunk/src/gtk-sat-popup-common.c trunk/src/gtk-sat-popup-common.h Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2011-10-26 18:30:16 UTC (rev 938) +++ trunk/ChangeLog 2011-10-27 22:13:31 UTC (rev 939) @@ -1,3 +1,16 @@ +2011-10-27 Charles Suprin <hamaa1vs at gmail.com> + + * src/gtk-event-list-popup.c + * src/gtk-sat-list-popup.c + * src/gtk-sat-map-popup.c + * src/gtk-polar-view-popup.c + * src/gtk-sat-popup-common.c + * src/gtk-sat-popup-common.h + * src/gtk-single-sat.c + * src/Makefile.am + Consolidate popup callback functions into single function and file. + + 2011-10-26 Charles Suprin <hamaa1vs at gmail.com> * src/tle-update.c Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2011-10-26 18:30:16 UTC (rev 938) +++ trunk/src/Makefile.am 2011-10-27 22:13:31 UTC (rev 939) @@ -52,6 +52,7 @@ gtk-sat-module.c gtk-sat-module.h \ gtk-sat-module-popup.c gtk-sat-module-popup.h \ gtk-sat-module-tmg.c gtk-sat-module-tmg.h \ + gtk-sat-popup-common.c gtk-sat-popup-common.h \ gtk-sat-selector.c gtk-sat-selector.h \ gtk-single-sat.c gtk-single-sat.h \ gtk-sky-glance.c gtk-sky-glance.h \ Modified: trunk/src/gtk-event-list-popup.c =================================================================== --- trunk/src/gtk-event-list-popup.c 2011-10-26 18:30:16 UTC (rev 938) +++ trunk/src/gtk-event-list-popup.c 2011-10-27 22:13:31 UTC (rev 939) @@ -41,14 +41,8 @@ #include "sat-pass-dialogs.h" #include "gtk-event-list-popup.h" #include "sat-info.h" +#include "gtk-sat-popup-common.h" - - - -static void show_next_pass_cb (GtkWidget *menuitem, gpointer data); -static void show_future_passes_cb (GtkWidget *menuitem, gpointer data); - - /** \brief Show satellite popup menu. * \param sat Pointer to the satellite data. * \param qth The current location. @@ -99,6 +93,7 @@ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); g_object_set_data (G_OBJECT (menuitem), "sat", sat); g_object_set_data (G_OBJECT (menuitem), "qth", qth); + g_object_set_data (G_OBJECT (menuitem), "tstamp", &(list->tstamp)); g_signal_connect (menuitem, "activate", G_CALLBACK (show_next_pass_cb), list); @@ -110,6 +105,7 @@ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); g_object_set_data (G_OBJECT (menuitem), "sat", sat); g_object_set_data (G_OBJECT (menuitem), "qth", qth); + g_object_set_data (G_OBJECT (menuitem), "tstamp", &(list->tstamp)); g_signal_connect (menuitem, "activate", G_CALLBACK (show_future_passes_cb), list); @@ -127,144 +123,3 @@ } - - - - -/** \brief Show details of the next pass. - * - */ -static void show_next_pass_cb (GtkWidget *menuitem, gpointer data) -{ - sat_t *sat; - qth_t *qth; - pass_t *pass; - GtkWidget *dialog; - GtkWindow *toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (data))); - GtkEventList *list = GTK_EVENT_LIST (data); - - - /* get next pass */ - sat = SAT(g_object_get_data (G_OBJECT (menuitem), "sat")); - qth = (qth_t *) (g_object_get_data (G_OBJECT (menuitem), "qth")); - - /* check wheather sat actially has AOS */ - if (has_aos (sat, qth)) { - - if (sat_cfg_get_bool (SAT_CFG_BOOL_PRED_USE_REAL_T0)) { - pass = get_next_pass (sat, qth, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); - } - else { - pass = get_pass (sat, qth, list->tstamp, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); - } - - if (pass != NULL) { - show_pass (sat->nickname, qth, pass, GTK_WIDGET (toplevel)); - } - else { - /* show dialog that there are no passes within time frame */ - dialog = gtk_message_dialog_new (toplevel, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - _("Satellite %s has no passes\n"\ - "within the next %d days"), - sat->nickname, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - } - else { - /* show dialog telling that this sat never reaches AOS*/ - dialog = gtk_message_dialog_new (toplevel, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Satellite %s has no passes for\n"\ - "the current ground station!\n\n"\ - "This can be because the satellite\n"\ - "is geostationary, decayed or simply\n"\ - "never comes above the horizon"), - sat->nickname); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - -} - - -static void show_future_passes_cb (GtkWidget *menuitem, gpointer data) -{ - GtkWidget *dialog; - GtkWindow *toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (data))); - GtkEventList *list = GTK_EVENT_LIST (data); - GSList *passes = NULL; - sat_t *sat; - qth_t *qth; - - - - sat = SAT(g_object_get_data (G_OBJECT (menuitem), "sat")); - qth = (qth_t *) (g_object_get_data (G_OBJECT (menuitem), "qth")); - - /* check wheather sat actially has AOS */ - if (has_aos (sat, qth)) { - - if (sat_cfg_get_bool (SAT_CFG_BOOL_PRED_USE_REAL_T0)) { - passes = get_next_passes (sat, qth, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD), - sat_cfg_get_int (SAT_CFG_INT_PRED_NUM_PASS)); - } - else { - passes = get_passes (sat, qth, list->tstamp, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD), - sat_cfg_get_int (SAT_CFG_INT_PRED_NUM_PASS)); - } - - if (passes != NULL) { - show_passes (sat->nickname, qth, passes, GTK_WIDGET (toplevel)); - } - else { - /* show dialog that there are no passes within time frame */ - dialog = gtk_message_dialog_new (toplevel, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - _("Satellite %s has no passes\n"\ - "within the next %d days"), - sat->nickname, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - - } - else { - /* show dialog */ - GtkWidget *dialog; - - dialog = gtk_message_dialog_new (toplevel, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Satellite %s has no passes for\n"\ - "the current ground station!"), - sat->nickname); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } -} - - - Modified: trunk/src/gtk-polar-view-popup.c =================================================================== --- trunk/src/gtk-polar-view-popup.c 2011-10-26 18:30:16 UTC (rev 938) +++ trunk/src/gtk-polar-view-popup.c 2011-10-27 22:13:31 UTC (rev 939) @@ -45,13 +45,11 @@ #include "sat-pass-dialogs.h" #include "sat-info.h" #include "gtk-polar-view-popup.h" +#include "gtk-sat-popup-common.h" - static void track_toggled (GtkCheckMenuItem *item, gpointer data); /* static void target_toggled (GtkCheckMenuItem *item, gpointer data); */ static GooCanvasItemModel *create_time_tick (GtkPolarView *pv, gdouble time, gfloat x, gfloat y); -static void show_next_pass_cb (GtkWidget *menuitem, gpointer data); -static void show_next_passes_cb (GtkWidget *menuitem, gpointer data); /** \brief Show satellite popup menu. @@ -109,6 +107,7 @@ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); g_object_set_data (G_OBJECT (menuitem), "sat", sat); g_object_set_data (G_OBJECT (menuitem), "qth", qth); + g_object_set_data (G_OBJECT (menuitem), "tstamp", &(pview->tstamp)); g_signal_connect (menuitem, "activate", G_CALLBACK (show_next_pass_cb), pview); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); @@ -117,7 +116,8 @@ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); g_object_set_data (G_OBJECT (menuitem), "sat", sat); g_object_set_data (G_OBJECT (menuitem), "qth", qth); - g_signal_connect (menuitem, "activate", G_CALLBACK (show_next_passes_cb), pview); + g_object_set_data (G_OBJECT (menuitem), "tstamp", &(pview->tstamp)); + g_signal_connect (menuitem, "activate", G_CALLBACK (show_future_passes_cb), pview); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); /* separator */ @@ -380,139 +380,3 @@ return item; } - - - -static void - show_next_pass_cb (GtkWidget *menuitem, gpointer data) -{ - GtkPolarView *pv = GTK_POLAR_VIEW (data); - sat_t *sat; - qth_t *qth; - pass_t *pass; - GtkWidget *dialog; - GtkWindow *toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (data))); - - - /* get next pass */ - sat = SAT(g_object_get_data (G_OBJECT (menuitem), "sat")); - qth = (qth_t *) (g_object_get_data (G_OBJECT (menuitem), "qth")); - - /* check wheather sat actially has AOS */ - if (has_aos (sat, qth)) { - if (sat_cfg_get_bool(SAT_CFG_BOOL_PRED_USE_REAL_T0)) { - pass = get_next_pass (sat, qth, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); - } - else { - pass = get_pass (sat, qth, pv->tstamp, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); - } - - if (pass != NULL) { - show_pass (sat->nickname, qth, pass, GTK_WIDGET (toplevel)); - } - else { - /* show dialog that there are no passes within time frame */ - dialog = gtk_message_dialog_new (toplevel, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - _("Satellite %s has no passes\n"\ - "within the next %d days"), - sat->nickname, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - } - else { - /* show dialog telling that this sat never reaches AOS*/ - dialog = gtk_message_dialog_new (toplevel, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Satellite %s has no passes for\n"\ - "the current ground station!\n\n"\ - "This can be because the satellite\n"\ - "is geostationary, decayed or simply\n"\ - "never comes above the horizon"), - sat->nickname); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - -} - - -static void show_next_passes_cb (GtkWidget *menuitem, gpointer data) -{ - GtkPolarView *pv = GTK_POLAR_VIEW (data); - GtkWidget *dialog; - GtkWindow *toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (data))); - GSList *passes = NULL; - sat_t *sat; - qth_t *qth; - - - sat = SAT(g_object_get_data (G_OBJECT (menuitem), "sat")); - qth = (qth_t *) (g_object_get_data (G_OBJECT (menuitem), "qth")); - - /* check wheather sat actially has AOS */ - if (has_aos (sat, qth)) { - - if (sat_cfg_get_bool(SAT_CFG_BOOL_PRED_USE_REAL_T0)) { - passes = get_next_passes (sat, qth, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD), - sat_cfg_get_int (SAT_CFG_INT_PRED_NUM_PASS)); - } - else { - passes = get_passes (sat, qth, pv->tstamp, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD), - sat_cfg_get_int (SAT_CFG_INT_PRED_NUM_PASS)); - - } - - - if (passes != NULL) { - show_passes (sat->nickname, qth, passes, GTK_WIDGET (toplevel)); - } - else { - /* show dialog that there are no passes within time frame */ - dialog = gtk_message_dialog_new (toplevel, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - _("Satellite %s has no passes\n"\ - "within the next %d days"), - sat->nickname, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - - } - else { - /* show dialog */ - GtkWidget *dialog; - - dialog = gtk_message_dialog_new (toplevel, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Satellite %s has no passes for\n"\ - "the current ground station!"), - sat->nickname); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - -} Modified: trunk/src/gtk-sat-list-popup.c =================================================================== --- trunk/src/gtk-sat-list-popup.c 2011-10-26 18:30:16 UTC (rev 938) +++ trunk/src/gtk-sat-list-popup.c 2011-10-27 22:13:31 UTC (rev 939) @@ -41,14 +41,8 @@ #include "sat-pass-dialogs.h" #include "gtk-sat-list-popup.h" #include "sat-info.h" +#include "gtk-sat-popup-common.h" - - - -void show_next_pass_cb (GtkWidget *menuitem, gpointer data); -void show_future_passes_cb (GtkWidget *menuitem, gpointer data); - - /** \brief Show satellite popup menu. * \param sat Pointer to the satellite data. * \param qth The current location. @@ -100,6 +94,7 @@ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); g_object_set_data (G_OBJECT (menuitem), "sat", sat); g_object_set_data (G_OBJECT (menuitem), "qth", qth); + g_object_set_data (G_OBJECT (menuitem), "tstamp", &(list->tstamp)); g_signal_connect (menuitem, "activate", G_CALLBACK (show_next_pass_cb), list); @@ -111,6 +106,7 @@ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); g_object_set_data (G_OBJECT (menuitem), "sat", sat); g_object_set_data (G_OBJECT (menuitem), "qth", qth); + g_object_set_data (G_OBJECT (menuitem), "tstamp", &(list->tstamp)); g_signal_connect (menuitem, "activate", G_CALLBACK (show_future_passes_cb), list); @@ -128,146 +124,3 @@ } - - - - -/** \brief Show details of the next pass. - * - */ -void -show_next_pass_cb (GtkWidget *menuitem, gpointer data) -{ - sat_t *sat; - qth_t *qth; - pass_t *pass; - GtkWidget *dialog; - GtkWindow *toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (data))); - GtkSatList *list = GTK_SAT_LIST (data); - - - /* get next pass */ - sat = SAT(g_object_get_data (G_OBJECT (menuitem), "sat")); - qth = (qth_t *) (g_object_get_data (G_OBJECT (menuitem), "qth")); - - /* check wheather sat actially has AOS */ - if (has_aos (sat, qth)) { - - if (sat_cfg_get_bool (SAT_CFG_BOOL_PRED_USE_REAL_T0)) { - pass = get_next_pass (sat, qth, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); - } - else { - pass = get_pass (sat, qth, list->tstamp, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); - } - - if (pass != NULL) { - show_pass (sat->nickname, qth, pass, GTK_WIDGET (toplevel)); - } - else { - /* show dialog that there are no passes within time frame */ - dialog = gtk_message_dialog_new (toplevel, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - _("Satellite %s has no passes\n"\ - "within the next %d days"), - sat->nickname, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - } - else { - /* show dialog telling that this sat never reaches AOS*/ - dialog = gtk_message_dialog_new (toplevel, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Satellite %s has no passes for\n"\ - "the current ground station!\n\n"\ - "This can be because the satellite\n"\ - "is geostationary, decayed or simply\n"\ - "never comes above the horizon"), - sat->nickname); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - -} - - -void -show_future_passes_cb (GtkWidget *menuitem, gpointer data) -{ - GtkWidget *dialog; - GtkWindow *toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (data))); - GtkSatList *list = GTK_SAT_LIST (data); - GSList *passes = NULL; - sat_t *sat; - qth_t *qth; - - - - sat = SAT(g_object_get_data (G_OBJECT (menuitem), "sat")); - qth = (qth_t *) (g_object_get_data (G_OBJECT (menuitem), "qth")); - - /* check wheather sat actially has AOS */ - if (has_aos (sat, qth)) { - - if (sat_cfg_get_bool (SAT_CFG_BOOL_PRED_USE_REAL_T0)) { - passes = get_next_passes (sat, qth, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD), - sat_cfg_get_int (SAT_CFG_INT_PRED_NUM_PASS)); - } - else { - passes = get_passes (sat, qth, list->tstamp, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD), - sat_cfg_get_int (SAT_CFG_INT_PRED_NUM_PASS)); - } - - if (passes != NULL) { - show_passes (sat->nickname, qth, passes, GTK_WIDGET (toplevel)); - } - else { - /* show dialog that there are no passes within time frame */ - dialog = gtk_message_dialog_new (toplevel, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - _("Satellite %s has no passes\n"\ - "within the next %d days"), - sat->nickname, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - - } - else { - /* show dialog */ - GtkWidget *dialog; - - dialog = gtk_message_dialog_new (toplevel, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Satellite %s has no passes for\n"\ - "the current ground station!"), - sat->nickname); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } -} - - - Modified: trunk/src/gtk-sat-map-popup.c =================================================================== --- trunk/src/gtk-sat-map-popup.c 2011-10-26 18:30:16 UTC (rev 938) +++ trunk/src/gtk-sat-map-popup.c 2011-10-27 22:13:31 UTC (rev 939) @@ -45,14 +45,12 @@ #include "gtk-sat-map-popup.h" #include "gtk-sat-data.h" #include "gtk-sat-map-ground-track.h" +#include "gtk-sat-popup-common.h" - static void coverage_toggled (GtkCheckMenuItem *item, gpointer data); static void track_toggled (GtkCheckMenuItem *item, gpointer data); /* static void target_toggled (GtkCheckMenuItem *item, gpointer data); */ -static void show_next_pass_cb (GtkWidget *menuitem, gpointer data); -static void show_next_passes_cb (GtkWidget *menuitem, gpointer data); /** \brief Show satellite popup menu. @@ -108,6 +106,7 @@ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); g_object_set_data (G_OBJECT (menuitem), "sat", sat); g_object_set_data (G_OBJECT (menuitem), "qth", qth); + g_object_set_data (G_OBJECT (menuitem), "tstamp", &(satmap->tstamp)); g_signal_connect (menuitem, "activate", G_CALLBACK (show_next_pass_cb), satmap); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); @@ -116,7 +115,8 @@ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); g_object_set_data (G_OBJECT (menuitem), "sat", sat); g_object_set_data (G_OBJECT (menuitem), "qth", qth); - g_signal_connect (menuitem, "activate", G_CALLBACK (show_next_passes_cb), satmap); + g_object_set_data (G_OBJECT (menuitem), "tstamp", &(satmap->tstamp)); + g_signal_connect (menuitem, "activate", G_CALLBACK (show_future_passes_cb), satmap); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); /* separator */ @@ -288,142 +288,6 @@ } - -static void show_next_pass_cb (GtkWidget *menuitem, gpointer data) -{ - GtkSatMap *satmap = GTK_SAT_MAP (data); - sat_t *sat; - qth_t *qth; - pass_t *pass; - GtkWidget *dialog; - GtkWindow *toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (data))); - - - /* get next pass */ - sat = SAT(g_object_get_data (G_OBJECT (menuitem), "sat")); - qth = (qth_t *) (g_object_get_data (G_OBJECT (menuitem), "qth")); - - /* check wheather sat actially has AOS */ - if (has_aos (sat, qth)) { - if (sat_cfg_get_bool(SAT_CFG_BOOL_PRED_USE_REAL_T0)) { - pass = get_next_pass (sat, qth, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); - } - else { - pass = get_pass (sat, qth, satmap->tstamp, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); - } - - if (pass != NULL) { - show_pass (sat->nickname, qth, pass, GTK_WIDGET (toplevel)); - } - else { - /* show dialog that there are no passes within time frame */ - dialog = gtk_message_dialog_new (toplevel, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - _("Satellite %s has no passes\n"\ - "within the next %d days"), - sat->nickname, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - } - else { - /* show dialog telling that this sat never reaches AOS*/ - dialog = gtk_message_dialog_new (toplevel, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Satellite %s has no passes for\n"\ - "the current ground station!\n\n"\ - "This can be because the satellite\n"\ - "is geostationary, decayed or simply\n"\ - "never comes above the horizon"), - sat->nickname); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - -} - - -static void show_next_passes_cb (GtkWidget *menuitem, gpointer data) -{ - GtkSatMap *satmap = GTK_SAT_MAP (data); - GtkWidget *dialog; - GtkWindow *toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (data))); - GSList *passes = NULL; - sat_t *sat; - qth_t *qth; - - - sat = SAT(g_object_get_data (G_OBJECT (menuitem), "sat")); - qth = (qth_t *) (g_object_get_data (G_OBJECT (menuitem), "qth")); - - /* check whether sat actually has AOS */ - if (has_aos (sat, qth)) { - - if (sat_cfg_get_bool(SAT_CFG_BOOL_PRED_USE_REAL_T0)) { - passes = get_next_passes (sat, qth, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD), - sat_cfg_get_int (SAT_CFG_INT_PRED_NUM_PASS)); - } - else { - passes = get_passes (sat, qth, satmap->tstamp, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD), - sat_cfg_get_int (SAT_CFG_INT_PRED_NUM_PASS)); - - } - - - if (passes != NULL) { - show_passes (sat->nickname, qth, passes, GTK_WIDGET (toplevel)); - } - else { - /* show dialog that there are no passes within time frame */ - dialog = gtk_message_dialog_new (toplevel, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - _("Satellite %s has no passes\n"\ - "within the next %d days"), - sat->nickname, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - - } - else { - /* show dialog */ - GtkWidget *dialog; - - dialog = gtk_message_dialog_new (toplevel, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Satellite %s has no passes for\n"\ - "the current ground station!"), - sat->nickname); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - -} - - - #if 0 /** \brief Manage toggling of Set Target. * \param item The menu item that was toggled. Added: trunk/src/gtk-sat-popup-common.c =================================================================== --- trunk/src/gtk-sat-popup-common.c (rev 0) +++ trunk/src/gtk-sat-popup-common.c 2011-10-27 22:13:31 UTC (rev 939) @@ -0,0 +1,186 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + Gpredict: Real-time satellite tracking and orbit prediction program + + Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC. + + Authors: Alexandru Csete <oz...@gm...> + Charles Suprin <ham...@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/ +*/ +/** \brief Functions common to popup menus of all modules. + * + * + */ +#include <gtk/gtk.h> +#include "sgpsdp/sgp4sdp4.h" +#include "qth-data.h" +#include "predict-tools.h" +#include "orbit-tools.h" +#include "sat-cfg.h" +#include "gtk-sat-popup-common.h" +#include "sat-pass-dialogs.h" + +void show_next_pass_cb (GtkWidget *menuitem, gpointer data) +{ + sat_t *sat; + qth_t *qth; + GtkWindow *toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (data))); + gdouble *tstamp; + + sat = SAT(g_object_get_data (G_OBJECT (menuitem), "sat")); + qth = (qth_t *) (g_object_get_data (G_OBJECT (menuitem), "qth")); + tstamp = (gdouble *) (g_object_get_data (G_OBJECT (menuitem), "tstamp")); + + show_next_pass_dialog (sat,qth,*tstamp,toplevel); +} + + +void show_future_passes_cb (GtkWidget *menuitem, gpointer data) +{ + GtkWindow *toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (data))); + sat_t *sat; + qth_t *qth; + gdouble *tstamp; + + sat = SAT(g_object_get_data (G_OBJECT (menuitem), "sat")); + qth = (qth_t *) (g_object_get_data (G_OBJECT (menuitem), "qth")); + tstamp = (gdouble *) (g_object_get_data (G_OBJECT (menuitem), "tstamp")); + + show_future_passes_dialog (sat,qth,*tstamp,toplevel); +} + + +void show_next_pass_dialog (sat_t *sat, qth_t *qth, gdouble tstamp, GtkWindow *toplevel){ + + GtkWidget *dialog; + pass_t *pass; + + /* check whether sat actually has AOS */ + if (has_aos (sat, qth)) { + if (sat_cfg_get_bool(SAT_CFG_BOOL_PRED_USE_REAL_T0)) { + pass = get_next_pass (sat, qth, + sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); + } + else { + pass = get_pass (sat, qth, tstamp, + sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); + } + + if (pass != NULL) { + show_pass (sat->nickname, qth, pass, GTK_WIDGET (toplevel)); + } + else { + /* show dialog that there are no passes within time frame */ + dialog = gtk_message_dialog_new (toplevel, + GTK_DIALOG_MODAL | + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_OK, + _("Satellite %s has no passes\n"\ + "within the next %d days"), + sat->nickname, + sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); + + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } + } + else { + /* show dialog telling that this sat never reaches AOS*/ + dialog = gtk_message_dialog_new (toplevel, + GTK_DIALOG_MODAL | + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + _("Satellite %s has no passes for\n"\ + "the current ground station!\n\n"\ + "This can be because the satellite\n"\ + "is geostationary, decayed or simply\n"\ + "never comes above the horizon"), + sat->nickname); + + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } + +} + + +void show_future_passes_dialog (sat_t *sat, qth_t *qth, gdouble tstamp, GtkWindow *toplevel){ + GSList *passes = NULL; + GtkWidget *dialog; + + /* check wheather sat actially has AOS */ + if (has_aos (sat, qth)) { + + if (sat_cfg_get_bool(SAT_CFG_BOOL_PRED_USE_REAL_T0)) { + passes = get_next_passes (sat, qth, + sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD), + sat_cfg_get_int (SAT_CFG_INT_PRED_NUM_PASS)); + } + else { + passes = get_passes (sat, qth, tstamp, + sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD), + sat_cfg_get_int (SAT_CFG_INT_PRED_NUM_PASS)); + + } + + + if (passes != NULL) { + show_passes (sat->nickname, qth, passes, GTK_WIDGET (toplevel)); + } + else { + /* show dialog that there are no passes within time frame */ + dialog = gtk_message_dialog_new (toplevel, + GTK_DIALOG_MODAL | + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_OK, + _("Satellite %s has no passes\n"\ + "within the next %d days"), + sat->nickname, + sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); + + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } + + } + else { + /* show dialog */ + GtkWidget *dialog; + + dialog = gtk_message_dialog_new (toplevel, + GTK_DIALOG_MODAL | + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, + _("Satellite %s has no passes for\n"\ + "the current ground station!"), + sat->nickname); + + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + } + + +} Added: trunk/src/gtk-sat-popup-common.h =================================================================== --- trunk/src/gtk-sat-popup-common.h (rev 0) +++ trunk/src/gtk-sat-popup-common.h 2011-10-27 22:13:31 UTC (rev 939) @@ -0,0 +1,45 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + Gpredict: Real-time satellite tracking and orbit prediction program + + Copyright (C) 2001-2011 Alexandru Csete, OZ9AEC. + + Authors: Alexandru Csete <oz...@gm...> + Charles Suprin <ham...@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 __GTK_SAT_POPUP_COMMON_H__ +#define __GTK_SAT_POPUP_COMMON_H__ 1 + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +void show_next_pass_cb (GtkWidget *menuitem, gpointer data); +void show_future_passes_cb (GtkWidget *menuitem, gpointer data); +void show_next_pass_dialog (sat_t *sat, qth_t *qth, gdouble tstamp, GtkWindow *toplevel); +void show_future_passes_dialog (sat_t *sat, qth_t *qth, gdouble tstamp, GtkWindow *toplevel); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __GTK_SAT_POPUP_COMMON_H__ */ Modified: trunk/src/gtk-single-sat.c =================================================================== --- trunk/src/gtk-single-sat.c 2011-10-26 18:30:16 UTC (rev 938) +++ trunk/src/gtk-single-sat.c 2011-10-27 22:13:31 UTC (rev 939) @@ -50,6 +50,7 @@ #include "predict-tools.h" #include "sat-pass-dialogs.h" #include "time-tools.h" +#include "gtk-sat-popup-common.h" /** \brief Column titles indexed with column symb. refs. */ const gchar *SINGLE_SAT_FIELD_TITLE[SINGLE_SAT_FIELD_NUMBER] = { @@ -116,8 +117,6 @@ static void Calculate_RADec (sat_t *sat, qth_t *qth, obs_astro_t *obs_set); static void gtk_single_sat_popup_cb (GtkWidget *button, gpointer data); static void select_satellite (GtkWidget *menuitem, gpointer data); -static void show_next_pass_cb (GtkWidget *menuitem, gpointer data); -static void show_next_passes_cb (GtkWidget *menuitem, gpointer data); static gint sat_name_compare (sat_t *a,sat_t *b); static GtkVBoxClass *parent_class = NULL; @@ -855,6 +854,7 @@ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); g_object_set_data (G_OBJECT (menuitem), "sat", sat); g_object_set_data (G_OBJECT (menuitem), "qth", single_sat->qth); + g_object_set_data (G_OBJECT (menuitem), "tstamp", &(single_sat->tstamp)); /* g_signal_connect (menuitem, "activate", G_CALLBACK (show_next_pass), gtk_widget_get_toplevel (button));*/ @@ -870,11 +870,12 @@ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); g_object_set_data (G_OBJECT (menuitem), "sat", sat); g_object_set_data (G_OBJECT (menuitem), "qth", single_sat->qth); + g_object_set_data (G_OBJECT (menuitem), "tstamp", &(single_sat->tstamp)); /* g_signal_connect (menuitem, "activate", G_CALLBACK (show_future_passes), gtk_widget_get_toplevel (button));*/ g_signal_connect (menuitem, "activate", - G_CALLBACK (show_next_passes_cb), data); + G_CALLBACK (show_future_passes_cb), data); gtk_menu_shell_append (GTK_MENU_SHELL(menu), menuitem); /* separator */ @@ -1023,143 +1024,6 @@ GTK_SINGLE_SAT (widget)->counter = 1; } - - -static void -show_next_pass_cb (GtkWidget *menuitem, gpointer data) -{ - GtkSingleSat *ssat = GTK_SINGLE_SAT (data); - sat_t *sat; - qth_t *qth; - pass_t *pass; - GtkWidget *dialog; - GtkWindow *toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (data))); - - - /* get next pass */ - sat = SAT(g_object_get_data (G_OBJECT (menuitem), "sat")); - qth = (qth_t *) (g_object_get_data (G_OBJECT (menuitem), "qth")); - - /* check wheather sat actially has AOS */ - if (has_aos (sat, qth)) { - if (sat_cfg_get_bool(SAT_CFG_BOOL_PRED_USE_REAL_T0)) { - pass = get_next_pass (sat, qth, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); - } - else { - pass = get_pass (sat, qth, ssat->tstamp, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); - } - - if (pass != NULL) { - show_pass (sat->nickname, qth, pass, GTK_WIDGET (toplevel)); - } - else { - /* show dialog that there are no passes within time frame */ - dialog = gtk_message_dialog_new (toplevel, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - _("Satellite %s has no passes\n"\ - "within the next %d days"), - sat->nickname, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - } - else { - /* show dialog telling that this sat never reaches AOS*/ - dialog = gtk_message_dialog_new (toplevel, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Satellite %s has no passes for\n"\ - "the current ground station!\n\n"\ - "This can be because the satellite\n"\ - "is geostationary, decayed or simply\n"\ - "never comes above the horizon"), - sat->nickname); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - -} - - -static void -show_next_passes_cb (GtkWidget *menuitem, gpointer data) -{ - GtkSingleSat *ssat = GTK_SINGLE_SAT (data); - GtkWidget *dialog; - GtkWindow *toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (data))); - GSList *passes = NULL; - sat_t *sat; - qth_t *qth; - - - sat = SAT(g_object_get_data (G_OBJECT (menuitem), "sat")); - qth = (qth_t *) (g_object_get_data (G_OBJECT (menuitem), "qth")); - - /* check wheather sat actially has AOS */ - if (has_aos (sat, qth)) { - - if (sat_cfg_get_bool(SAT_CFG_BOOL_PRED_USE_REAL_T0)) { - passes = get_next_passes (sat, qth, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD), - sat_cfg_get_int (SAT_CFG_INT_PRED_NUM_PASS)); - } - else { - passes = get_passes (sat, qth, ssat->tstamp, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD), - sat_cfg_get_int (SAT_CFG_INT_PRED_NUM_PASS)); - - } - - - if (passes != NULL) { - show_passes (sat->nickname, qth, passes, GTK_WIDGET (toplevel)); - } - else { - /* show dialog that there are no passes within time frame */ - dialog = gtk_message_dialog_new (toplevel, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - _("Satellite %s has no passes\n"\ - "within the next %d days"), - sat->nickname, - sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD)); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - - } - else { - /* show dialog */ - GtkWidget *dialog; - - dialog = gtk_message_dialog_new (toplevel, - GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Satellite %s has no passes for\n"\ - "the current ground station!"), - sat->nickname); - - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - } - -} - static gint sat_name_compare (sat_t *a,sat_t *b) { return gpredict_strcmp(a->nickname,b->nickname); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |