Exemplo n.º 1
0
gint
mod_cfg_get_int  (GKeyFile *f, const gchar *sec, const gchar *key, sat_cfg_int_e p)
{
     GError  *error = NULL;
     gint     param;

     /* check whether parameter is present in GKeyFile */
     if (g_key_file_has_key (f, sec, key, NULL)) {

          param = g_key_file_get_integer (f, sec, key, &error);

          if (error != NULL) {

               sat_log_log (SAT_LOG_LEVEL_ERROR,
                         _("%s: Failed to read integer (%s)"),
                         __FUNCTION__, error->message);

               g_clear_error (&error);

               /* get a timeout from global config */
               param = sat_cfg_get_int (p);
          }
     }
     /* get value from sat-cfg */
     else {
          param = sat_cfg_get_int (p);

/*           sat_log_log (SAT_LOG_LEVEL_DEBUG, */
/*                     _("%s: Integer value not found, using default (%d)"), */
/*                     __FUNCTION__, param); */
     }

     return param;
}
Exemplo n.º 2
0
/** \brief Load configuration data.
 *  \return 0 if everything OK, 1 otherwise.
 *
 * This function reads the configuration data from gpredict.cfg into
 * memory. This function must be called very early at program start.
 *
 * The the configuration data in memory is already "loaded" the data will
 * be ereased first.
 */
guint sat_cfg_load        ()
{
    gchar  *keyfile,*confdir;
    GError *error = NULL;

    if (config != NULL)
        sat_cfg_close ();

    /* load the configuration file */
    config = g_key_file_new ();
    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);

    g_free (keyfile);

    if (error != NULL) {

        sat_log_log (SAT_LOG_LEVEL_WARN,
                     _("%s: Error reading config file (%s)"),
                     __FUNCTION__, error->message);

        sat_log_log (SAT_LOG_LEVEL_WARN,
                     _("%s: Using built-in defaults"),
                     __FUNCTION__);

        g_clear_error (&error);

        return 1;
    }
    else {
        sat_log_log (SAT_LOG_LEVEL_DEBUG,
                     _("%s: Everything OK."), __FUNCTION__);
    }

    /* if config version is < 1.1; reset SAT_CFG_STR_TLE_FILES */
    guint ver;
    ver = 10*sat_cfg_get_int (SAT_CFG_INT_VERSION_MAJOR) + sat_cfg_get_int (SAT_CFG_INT_VERSION_MINOR);
    if (ver < 11) {
        sat_cfg_reset_str (SAT_CFG_STR_TLE_FILES);
        sat_cfg_set_int (SAT_CFG_INT_VERSION_MAJOR, 1);
        sat_cfg_set_int (SAT_CFG_INT_VERSION_MINOR, 1);
    }


    return 0;
}
/** \brief Reset settings.
 *  \param button The RESET button.
 *  \param cfg Pointer to the module config or NULL in global mode.
 *
 * This function is called when the user clicks on the RESET button. In global mode
 * (when cfg = NULL) the function will reset the settings to the efault values, while
 * in "local" mode (when cfg != NULL) the function will reset the module settings to
 * the global settings. This is done by removing the corresponding key from the GKeyFile.
 */
static void
reset_cb               (GtkWidget *button, gpointer cfg)
{
    guint i;


    if (cfg == NULL) {
        /* global mode, get defaults */
        flags = sat_cfg_get_int_def (SAT_CFG_INT_SINGLE_SAT_FIELDS);
    }
    else {
        /* local mode, get global value */
        flags = sat_cfg_get_int (SAT_CFG_INT_SINGLE_SAT_FIELDS);
    }

    for (i = 0; i < SINGLE_SAT_FIELD_NUMBER; i++) {

        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check[i]),
                          flags & (1 << i));

    }

    /* reset flags */
    dirty = FALSE;
    reset = TRUE;
}
/** \brief Create and initialise widgets for the single pass cfg tab.
 *
 * The widgets must be preloaded with values from config. If a config value
 * is NULL, sensible default values, eg. those from defaults.h should
 * be laoded.
 */
GtkWidget *sat_pref_single_pass_create ()
{
     GtkWidget *table;
     GtkWidget *label;
     GtkWidget *vbox;
     guint      i;


     /* create the table */
     table = gtk_table_new ((SINGLE_PASS_COL_NUMBER+1)/COLUMNS + 1, COLUMNS, TRUE);
     gtk_container_set_border_width (GTK_CONTAINER (table), 20);
     gtk_table_set_row_spacings (GTK_TABLE (table), 10);
     gtk_table_set_col_spacings (GTK_TABLE (table), 5);

     /* create header */
     label = gtk_label_new (NULL);
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_label_set_markup (GTK_LABEL (label), 
                     _("<b>Visible Columns:</b>"));

     gtk_table_attach (GTK_TABLE (table), label, 0, 2, 0, 1,
                 GTK_FILL,  GTK_SHRINK, 0, 0);

     /* get visible column flags */
     flags = sat_cfg_get_int (SAT_CFG_INT_PRED_SINGLE_COL);

     for (i = 0; i < SINGLE_PASS_COL_NUMBER; i++) {

          check[i] = gtk_check_button_new_with_label (SINGLE_PASS_COL_HINT[i]);

          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check[i]),
                               flags & (1 << i));

          gtk_table_attach (GTK_TABLE (table), check[i],
                      i % COLUMNS, (i % COLUMNS) + 1,
                      Y0 + i / COLUMNS, Y0 + i / COLUMNS + 1,
                      GTK_FILL,  GTK_SHRINK, 0, 0);

          g_signal_connect (check[i], "toggled",
                      G_CALLBACK (toggle_cb),
                      GUINT_TO_POINTER (i));

     }

     /* create vertical box */
     vbox = gtk_vbox_new (FALSE, 0);
     gtk_container_set_border_width (GTK_CONTAINER (vbox), 20);
     gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0);

     /* create RESET button */
     create_reset_button (GTK_BOX (vbox));


     startflags = flags;
     dirty = FALSE;
     reset = FALSE;

     return vbox;
}
Exemplo n.º 5
0
/** \brief Launch help system.
 *
 */
void
gpredict_help_launch (gpredict_help_type_t type)
{
     browser_type_t idx;
     gint           resp;

     (void) type; /* avoid unused parameter compiler warning */


     idx = sat_cfg_get_int (SAT_CFG_INT_WEB_BROWSER_TYPE);

     /* some sanity check before accessing the arrays ;-) */
     if ((idx <= BROWSER_TYPE_NONE) || (idx >= BROWSER_TYPE_NUM)) {
          idx = BROWSER_TYPE_NONE;
     }

     if (idx == BROWSER_TYPE_NONE) {
          sat_log_log (SAT_LOG_LEVEL_INFO,
                    _("%s: Help browser is not set up yet."),
                    __FUNCTION__);

          resp = config_help ();

          if (resp == GTK_RESPONSE_CANCEL) {
               sat_log_log (SAT_LOG_LEVEL_INFO,
                         _("%s: Configure help browser cancelled."),
                         __FUNCTION__);

               return;
          }

          /* else try again */
          idx = sat_cfg_get_int (SAT_CFG_INT_WEB_BROWSER_TYPE);          
     }

     if ((idx <= BROWSER_TYPE_NONE) || (idx >= BROWSER_TYPE_NUM)) {
          return;
     }

     /* launch help browser */
     sat_log_log (SAT_LOG_LEVEL_DEBUG,
               _("%s: Launching help browser %s."),
               __FUNCTION__, sat_help[idx].type);

     g_print ("FIXME: FINSH IMPELMTATION\n");
}
Exemplo n.º 6
0
/** \brief Reset settings.
 *  \param button The RESET button.
 *  \param cfg Pointer to the module config or NULL in global mode.
 *
 * This function is called when the user clicks on the RESET button. In global mode
 * (when cfg = NULL) the function will reset the settings to the efault values, while
 * in "local" mode (when cfg != NULL) the function will reset the module settings to
 * the global settings. This is done by removing the corresponding key from the GKeyFile.
 */
static void
reset_cb               (GtkWidget *button, gpointer cfg)
{
     gint val;

     (void) button; /* avoid unused parameter compiler warning */

     /* views */
     if (cfg == NULL) {
          /* global mode, get defaults */
          val = sat_cfg_get_int_def (SAT_CFG_INT_MODULE_TIMEOUT);
          gtk_spin_button_set_value (GTK_SPIN_BUTTON (dataspin), val);
          val = sat_cfg_get_int_def (SAT_CFG_INT_LIST_REFRESH);
          gtk_spin_button_set_value (GTK_SPIN_BUTTON (listspin), val);
          val = sat_cfg_get_int_def (SAT_CFG_INT_MAP_REFRESH);
          gtk_spin_button_set_value (GTK_SPIN_BUTTON (mapspin), val);
          val = sat_cfg_get_int_def (SAT_CFG_INT_POLAR_REFRESH);
          gtk_spin_button_set_value (GTK_SPIN_BUTTON (polarspin), val);
          val = sat_cfg_get_int_def (SAT_CFG_INT_SINGLE_SAT_REFRESH);
          gtk_spin_button_set_value (GTK_SPIN_BUTTON (singlespin), val);
     }
     else {
          /* local mode, get global value */
          val = sat_cfg_get_int (SAT_CFG_INT_MODULE_TIMEOUT);
          gtk_spin_button_set_value (GTK_SPIN_BUTTON (dataspin), val);
          val = sat_cfg_get_int (SAT_CFG_INT_LIST_REFRESH);
          gtk_spin_button_set_value (GTK_SPIN_BUTTON (listspin), val);
          val = sat_cfg_get_int (SAT_CFG_INT_MAP_REFRESH);
          gtk_spin_button_set_value (GTK_SPIN_BUTTON (mapspin), val);
          val = sat_cfg_get_int (SAT_CFG_INT_POLAR_REFRESH);
          gtk_spin_button_set_value (GTK_SPIN_BUTTON (polarspin), val);
          val = sat_cfg_get_int (SAT_CFG_INT_SINGLE_SAT_REFRESH);
          gtk_spin_button_set_value (GTK_SPIN_BUTTON (singlespin), val);
     }


     /* reset flags */
     reset = TRUE;
     dirty = FALSE;
}
Exemplo n.º 7
0
/** \brief Calculate satellite visibility.
 *  \param sat The satellite structure.
 *  \param qth The QTH
 *  \param jul_utc The time at which the visibility should be calculated.
 *  \return The visiblity code.
 *
 */
sat_vis_t
get_sat_vis (sat_t *sat, qth_t *qth, gdouble jul_utc)
{
    gboolean sat_sun_status;
    gdouble  sun_el;
    gdouble  threshold;
    gdouble  eclipse_depth;
    sat_vis_t vis = SAT_VIS_NONE;
    vector_t zero_vector = {0,0,0,0};
    geodetic_t obs_geodetic;

    /* Solar ECI position vector  */
    vector_t solar_vector=zero_vector;

    /* Solar observed az and el vector  */
    obs_set_t solar_set;

    /* FIXME: could be passed as parameter */
    obs_geodetic.lon = qth->lon * de2ra;
    obs_geodetic.lat = qth->lat * de2ra;
    obs_geodetic.alt = qth->alt / 1000.0;
    obs_geodetic.theta = 0;


    Calculate_Solar_Position (jul_utc, &solar_vector);
    Calculate_Obs (jul_utc, &solar_vector, &zero_vector, &obs_geodetic, &solar_set);

    if (Sat_Eclipsed (&sat->pos, &solar_vector, &eclipse_depth)) {
        /* satellite is eclipsed */
        sat_sun_status = FALSE;
    }
    else {
        /* satellite in sunlight => may be visible */
        sat_sun_status = TRUE;
    }


    if (sat_sun_status) {
        sun_el = Degrees (solar_set.el);
        threshold = (gdouble) sat_cfg_get_int (SAT_CFG_INT_PRED_TWILIGHT_THLD);
        
        if (sun_el <= threshold && sat->el >= 0.0)
            vis = SAT_VIS_VISIBLE;
        else
            vis = SAT_VIS_DAYLIGHT;
    }
    else
        vis = SAT_VIS_ECLIPSED;


    return vis;
}
Exemplo n.º 8
0
/* Select proper log file age in combo box. */
static void select_age(void)
{
    gint            num = sat_cfg_get_int(SAT_CFG_INT_LOG_CLEAN_AGE);

    switch (num)
    {
    case SEC_PER_DAY:
        gtk_combo_box_set_active(GTK_COMBO_BOX(age), 1);
        break;

    case SEC_PER_WEEK:
        gtk_combo_box_set_active(GTK_COMBO_BOX(age), 2);
        break;

    case SEC_PER_MONTH:
        gtk_combo_box_set_active(GTK_COMBO_BOX(age), 3);
        break;

    default:
        gtk_combo_box_set_active(GTK_COMBO_BOX(age), 0);
    }
}
Exemplo n.º 9
0
/** \brief Print a satellite pass.
  * \param pass Pointer to the pass_t data
  * \param qth Pointer to the qth_t structure
  * \param parent Transient parent of the dialog, or NULL
  *
  * This function prints a satellite pass to the printer (or a file) using the
  * Gtk+ printing API. The function takes the user configuration into account
  * and only prints the selected columns. The font size will be adjusted so that
  * one row can fit on one line. The function will also try to reduce the number
  * of rows so that the whole pass can fit on one page:
  *
  *    +-------------------------+
  *    |         header          |
  *    |------------+------------|
  *    |            |            |
  *    |            |            |
  *    |  polar     |   az/el    |
  *    |            |            |
  *    |------------+------------|
  *    |                         |
  *    |    Table with data      |
  *    |                         |
  *    |  - - - - - - - - - - -  |
  *    |  - - - - - - - - - - -  |
  *    |  - - - - - - - - - - -  |
  *    |  - - - - - - - - - - -  |
  *    |  - - - - - - - - - - -  |
  *    |  - - - - - - - - - - -  |
  *    |  - - - - - - - - - - -  |
  *    |                         |
  *    +-------------------------+
  *
  */
void print_pass   (pass_t *pass, qth_t *qth, GtkWindow *parent)
{
    gchar *text,*header,*buff;

    GtkPrintOperation *operation;
    PrintData *data;
    GError *error = NULL;


    /* TODO check pass and qth */


    operation = gtk_print_operation_new ();
    data = g_new0 (PrintData, 1);
    data->font_size = 12.0;  // FIXME

    /* page header */
    data->pgheader = g_strdup_printf (_("Pass details for %s (orbit %d)"), pass->satname, pass->orbit);

    /* convert data to printable strings; we use existing pass_to_txt functions */
    data->fields = sat_cfg_get_int (SAT_CFG_INT_PRED_SINGLE_COL);
    header = pass_to_txt_tblheader (pass, qth, data->fields);
    text = pass_to_txt_tblcontents (pass, qth, data->fields);
    buff = g_strconcat (header, text, NULL);
    data->lines = g_strsplit (buff, "\n", 0);
    g_free (text);
    g_free (header);
    g_free (buff);

    g_signal_connect (G_OBJECT (operation), "begin-print", G_CALLBACK (begin_print), data);
    g_signal_connect (G_OBJECT (operation), "draw-page", G_CALLBACK (draw_page), data);
    g_signal_connect (G_OBJECT (operation), "end-print", G_CALLBACK (end_print), data);

    gtk_print_operation_set_use_full_page (operation, FALSE);
    gtk_print_operation_set_unit (operation, GTK_UNIT_POINTS);

    gtk_print_operation_run (operation, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
                             parent, &error);

    g_object_unref (operation);


    if (error) {
        sat_log_log (SAT_LOG_LEVEL_ERROR,
                     "%s: %s", __func__, error->message);

        GtkWidget *dialog;

        dialog = gtk_message_dialog_new (parent,
                                         GTK_DIALOG_DESTROY_WITH_PARENT,
                                         GTK_MESSAGE_ERROR,
                                         GTK_BUTTONS_CLOSE,
                                         "%s", error->message);
        g_error_free (error);

        g_signal_connect (dialog, "response",
                          G_CALLBACK (gtk_widget_destroy), NULL);

        gtk_widget_show (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 ((sat->otype != ORBIT_TYPE_GEO) && (sat->otype != ORBIT_TYPE_DECAYED) &&
        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);
    }
}
Exemplo n.º 11
0
/** \brief Create and initialise widgets for the radios tab.
 *
 * The widgets must be preloaded with values from config. If a config value
 * is NULL, sensible default values, eg. those from defaults.h should
 * be laoded.
 */
GtkWidget *sat_pref_conditions_create ()
{
     GtkWidget   *table;
     GtkWidget   *label;
     GtkWidget   *vbox;


     dirty = FALSE;
     reset = FALSE;

     table = gtk_table_new (14, 3, FALSE);
     gtk_table_set_row_spacings (GTK_TABLE (table), 10);
     gtk_table_set_col_spacings (GTK_TABLE (table), 5);

     /* minimum elevation */
     label = gtk_label_new (_("Minimum elevation"));
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_table_attach (GTK_TABLE (table), label,
                           0, 1, 0, 1,
                           GTK_FILL,
                           GTK_SHRINK,
                           0, 0);
     minel = gtk_spin_button_new_with_range (1, 90, 1);
     gtk_widget_set_tooltip_text (minel,
                                _("Elevation threshold for passes.\n"\
                                   "Passes with maximum elevation below this limit "\
                                  "will be omitted"));
     gtk_spin_button_set_digits (GTK_SPIN_BUTTON (minel), 0);
     gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (minel), TRUE);
     gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (minel), FALSE);
     gtk_spin_button_set_value (GTK_SPIN_BUTTON (minel),
                                      sat_cfg_get_int (SAT_CFG_INT_PRED_MIN_EL));
     g_signal_connect (G_OBJECT (minel), "value-changed",
                           G_CALLBACK (spin_changed_cb), NULL);
     gtk_table_attach (GTK_TABLE (table), minel,
                           1, 2, 0, 1,
                           GTK_FILL,
                           GTK_SHRINK,
                           0, 0);
     label = gtk_label_new (_("[deg]"));
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_table_attach (GTK_TABLE (table), label,
                           2, 3, 0, 1,
                           GTK_FILL | GTK_EXPAND,
                           GTK_SHRINK,
                           0, 0);
     
     /* separator */
     gtk_table_attach (GTK_TABLE (table),
                           gtk_hseparator_new (),
                           0, 3, 1, 2,
                           GTK_FILL | GTK_EXPAND,
                           GTK_SHRINK,
                           0, 0);

     label = gtk_label_new (NULL);
     gtk_label_set_markup (GTK_LABEL (label), _("<b>Multiple Passes:</b>"));
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_table_attach (GTK_TABLE (table), label,
                           0, 1, 2, 3,
                           GTK_FILL,
                           GTK_SHRINK,
                           0, 0);

     /* number of passes */
     label = gtk_label_new (_("Number of passes to predict"));
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_table_attach (GTK_TABLE (table), label,
                           0, 1, 3, 4,
                           GTK_FILL,
                           GTK_SHRINK,
                           0, 0);
     numpass = gtk_spin_button_new_with_range (5, 50, 1);
     gtk_widget_set_tooltip_text (numpass,
                                  _("The maximum number of passes to predict."));
     gtk_spin_button_set_digits (GTK_SPIN_BUTTON (numpass), 0);
     gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (numpass), TRUE);
     gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (numpass), FALSE);
     gtk_spin_button_set_value (GTK_SPIN_BUTTON (numpass),
                                      sat_cfg_get_int (SAT_CFG_INT_PRED_NUM_PASS));
     g_signal_connect (G_OBJECT (numpass), "value-changed",
                           G_CALLBACK (spin_changed_cb), NULL);
     gtk_table_attach (GTK_TABLE (table), numpass,
                           1, 2, 3, 4,
                           GTK_FILL,
                           GTK_SHRINK,
                           0, 0);

     /* lookahead */
     label = gtk_label_new (_("Passes should occur within"));
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_table_attach (GTK_TABLE (table), label,
                           0, 1, 4, 5,
                           GTK_FILL,
                           GTK_SHRINK,
                           0, 0);
     lookahead = gtk_spin_button_new_with_range (1, 14, 1);
     gtk_widget_set_tooltip_text (lookahead,
                                _("Only passes that occur within the specified "\
                                  "number of days will be shown."));
     gtk_spin_button_set_digits (GTK_SPIN_BUTTON (lookahead), 0);
     gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (lookahead), TRUE);
     gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (lookahead), FALSE);
     gtk_spin_button_set_value (GTK_SPIN_BUTTON (lookahead),
                                      sat_cfg_get_int (SAT_CFG_INT_PRED_LOOK_AHEAD));
     g_signal_connect (G_OBJECT (lookahead), "value-changed",
                           G_CALLBACK (spin_changed_cb), NULL);
     gtk_table_attach (GTK_TABLE (table), lookahead,
                           1, 2, 4, 5,
                           GTK_FILL,
                           GTK_SHRINK,
                           0, 0);
     label = gtk_label_new (_("[days]"));
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_table_attach (GTK_TABLE (table), label,
                           2, 3, 4, 5,
                           GTK_FILL | GTK_EXPAND,
                           GTK_SHRINK,
                           0, 0);
     
     /* separator */
     gtk_table_attach (GTK_TABLE (table),
                           gtk_hseparator_new (),
                           0, 3, 5, 6,
                           GTK_FILL | GTK_EXPAND,
                           GTK_SHRINK,
                           0, 0);


     label = gtk_label_new (NULL);
     gtk_label_set_markup (GTK_LABEL (label), _("<b>Pass Details:</b>"));
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_table_attach (GTK_TABLE (table), label,
                           0, 1, 6, 7,
                           GTK_FILL,
                           GTK_SHRINK,
                           0, 0);

     /* time resolution */
     label = gtk_label_new (_("Time resolution"));
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_table_attach (GTK_TABLE (table), label,
                           0, 1, 7, 8,
                           GTK_FILL,
                           GTK_SHRINK,
                           0, 0);
     res = gtk_spin_button_new_with_range (1, 600, 1);
     gtk_widget_set_tooltip_text (res,
                                _("Gpredict will try to show the pass details "\
                                  "with the specified time resolution."));
     gtk_spin_button_set_digits (GTK_SPIN_BUTTON (res), 0);
     gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (res), TRUE);
     gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (res), FALSE);
     gtk_spin_button_set_value (GTK_SPIN_BUTTON (res),
                                      sat_cfg_get_int (SAT_CFG_INT_PRED_RESOLUTION));
     g_signal_connect (G_OBJECT (res), "value-changed",
                           G_CALLBACK (spin_changed_cb), NULL);
     gtk_table_attach (GTK_TABLE (table), res,
                           1, 2, 7, 8,
                           GTK_FILL,
                           GTK_SHRINK,
                           0, 0);
     label = gtk_label_new (_("[sec]"));
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_table_attach (GTK_TABLE (table), label,
                           2, 3, 7, 8,
                           GTK_FILL | GTK_EXPAND,
                           GTK_SHRINK,
                           0, 0);

     /* number of entries */
     label = gtk_label_new (_("Number of entries"));
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_table_attach (GTK_TABLE (table), label,
                           0, 1, 8, 9,
                           GTK_FILL,
                           GTK_SHRINK,
                           0, 0);
     nument = gtk_spin_button_new_with_range (10, 200, 1);
     gtk_widget_set_tooltip_text (nument,
                                  _("Gpredict will try to keep the number of rows " \
                                    "in the detailed prediction within this limit."));
     gtk_spin_button_set_digits (GTK_SPIN_BUTTON (nument), 0);
     gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (nument), TRUE);
     gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (nument), FALSE);
     gtk_spin_button_set_value (GTK_SPIN_BUTTON (nument),
                                      sat_cfg_get_int (SAT_CFG_INT_PRED_NUM_ENTRIES));
     g_signal_connect (G_OBJECT (nument), "value-changed",
                           G_CALLBACK (spin_changed_cb), NULL);
     gtk_table_attach (GTK_TABLE (table), nument,
                           1, 2, 8, 9,
                           GTK_FILL,
                           GTK_SHRINK,
                           0, 0);

    /* separator */
    gtk_table_attach (GTK_TABLE (table),
                      gtk_hseparator_new (),
                      0, 3, 9, 10,
                      GTK_FILL | GTK_EXPAND,
                      GTK_SHRINK,
                      0, 0);

    /* satellite visibility */
    label = gtk_label_new (NULL);
    gtk_label_set_markup (GTK_LABEL (label), _("<b>Satellite Visibility:</b>"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label,
                      0, 1, 10, 11,
                      GTK_FILL,
                      GTK_SHRINK,
                      0, 0);

    /* twilight threshold */
    label = gtk_label_new (_("Twilight threshold"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label,
                      0, 1, 11, 12,
                      GTK_FILL,
                      GTK_SHRINK,
                      0, 0);
    twspin = gtk_spin_button_new_with_range (-18, 0, 1);
    gtk_widget_set_tooltip_text (twspin,
                          _("Satellites are only considered visible if the elevation "\
                            "of the Sun is below the specified threshold.\n"\
                            "  \342\200\242 Astronomical: -18\302\260 to -12\302\260\n"\
                            "  \342\200\242 Nautical: -12\302\260 to -6\302\260\n"\
                            "  \342\200\242 Civil: -6\302\260 to 0\302\260"));
    gtk_spin_button_set_digits (GTK_SPIN_BUTTON (twspin), 0);
    gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (twspin), TRUE);
    gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (twspin), FALSE);
    gtk_spin_button_set_value (GTK_SPIN_BUTTON (twspin),
                               sat_cfg_get_int (SAT_CFG_INT_PRED_TWILIGHT_THLD));
    g_signal_connect (G_OBJECT (twspin), "value-changed",
                      G_CALLBACK (spin_changed_cb), NULL);
    gtk_table_attach (GTK_TABLE (table), twspin,
                      1, 2, 11, 12,
                      GTK_FILL,
                      GTK_SHRINK,
                      0, 0);
    label = gtk_label_new (_("[deg]"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label,
                      2, 3, 11, 12,
                      GTK_FILL | GTK_EXPAND,
                      GTK_SHRINK,
                      0, 0);
    
    /* separator */
    gtk_table_attach (GTK_TABLE (table),
                      gtk_hseparator_new (),
                      0, 3, 12, 13,
                      GTK_FILL | GTK_EXPAND,
                      GTK_SHRINK,
                      0, 0);

    /* T0 for predictions */
    tzero = gtk_check_button_new_with_label (_("Always use real time for pass predictions"));
    gtk_widget_set_tooltip_text (tzero,
                                 _("Check this box if you want Gpredict to always use "\
                                   "the current (real) time as starting time when predicting "\
                                   "future satellite passes.\n\n"\
                                   "If you leave the box unchecked and the time controller is "\
                                   "active, Gpredict will use the time from the time controller "\
                                   "as starting time for predicting satellite passes."));
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tzero),
                                  sat_cfg_get_bool (SAT_CFG_BOOL_PRED_USE_REAL_T0));
    g_signal_connect (G_OBJECT (tzero), "toggled",
                      G_CALLBACK (spin_changed_cb), NULL);
     
    gtk_table_attach (GTK_TABLE (table), tzero, 0, 3, 13, 14,
                      GTK_FILL | GTK_EXPAND, GTK_SHRINK,
                      0, 0);
    
     /* create vertical box */
     vbox = gtk_vbox_new (FALSE, 0);
     gtk_container_set_border_width (GTK_CONTAINER (vbox), 20);
     gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0);

     /* create RESET button */
     create_reset_button (GTK_BOX (vbox));


     return vbox;
}
Exemplo n.º 12
0
/** \brief Predict first pass after a certain time.
 *  \param sat Pointer to the satellite data.
 *  \param qth Pointer to the location data.
 *  \param start Starting time.
 *  \param maxdt The maximum number of days to look ahead (0 for no limit).
 *  \return Pointer to a newly allocated pass_t structure or NULL if
 *          there was an error.
 *
 * This function will find the first upcoming pass with AOS no earlier than
 * t = start and no later than t = (start+maxdt).
 *
 * \note For no time limit use maxdt = 0.0
 *
 * \note the data in sat will be corrupt (future) and must be refreshed
 *       by the caller, if the caller will need it later on (eg. if the caller
 *       is GtkSatList).
 *
 * \note Prepending to a singly linked list is much faster than appending.
 *       Therefore, the elements are prepended whereafter the GSList is
 *       reversed
 */
pass_t *
get_pass   (sat_t *sat_in, qth_t *qth, gdouble start, gdouble maxdt)
{
    gdouble        aos = 0.0;    /* time of AOS */
    gdouble        tca = 0.0;    /* time of TCA */
    gdouble        los = 0.0;    /* time of LOS */
    gdouble        dt = 0.0;     /* time diff */
    gdouble        step = 0.0;   /* time step */
    gdouble        t0 = start;
    gdouble        t;            /* current time counter */
    gdouble        tres = 0.0; /* required time resolution */
    gdouble        max_el = 0.0; /* maximum elevation */
    pass_t        *pass = NULL;
    pass_detail_t *detail = NULL;
    gboolean       done = FALSE;
    guint          iter = 0;      /* number of iterations */
    sat_t         *sat,sat_working;
    /* FIXME: watchdog */

    /*copy sat_in to a working structure*/
    sat = memcpy(&sat_working,sat_in,sizeof(sat_t));

    /* get time resolution; sat-cfg stores it in seconds */
    tres = sat_cfg_get_int (SAT_CFG_INT_PRED_RESOLUTION) / 86400.0;

    /* loop until we find a pass with elevation > SAT_CFG_INT_PRED_MIN_EL
        or we run out of time
        FIXME: we should have a safety break
    */
    while (!done) {

        /* Find los of next pass or of current pass */
        los = find_los (sat, qth, t0, maxdt); // See if a pass is ongoing
        aos = find_aos (sat, qth, t0, maxdt);
        /* sat_log_log(SAT_LOG_LEVEL_MSG, "%s:%s:%d: found aos %f and los %f for t0=%f", */
        /*          __FILE__,  */
        /*          __FUNCTION__, */
        /*          __LINE__, */
        /*          aos, */
        /*          los,  */
        /*          t0); */
        if (aos > los) {
            // los is from an currently happening pass, find previous aos
            aos = find_prev_aos(sat, qth, t0);
        }

        /* aos = 0.0 means no aos */
        if (aos == 0.0) {
            done = TRUE;
        }

        /* check whether we are within time limits;
            maxdt = 0 mean no time limit.
        */
        else if ((maxdt > 0.0) && (aos > (start + maxdt)) ) {
            done = TRUE;
        }
        else {
            //los = find_los (sat, qth, aos + 0.001, maxdt); // +1.5 min later
            dt = los - aos;

            /* get time step, which will give us the max number of entries */
            step = dt / sat_cfg_get_int (SAT_CFG_INT_PRED_NUM_ENTRIES);

            /* but if this is smaller than the required resolution
                we go with the resolution
            */
            if (step < tres)
                step = tres;

            /* create a pass_t entry; FIXME: g_try_new in 2.8 */
            pass = g_new (pass_t, 1);
            
            pass->aos = aos;
            pass->los = los;
            pass->max_el = 0.0;
            pass->aos_az = 0.0;
            pass->los_az = 0.0;
            pass->maxel_az = 0.0;
            pass->vis[0] = '-';
            pass->vis[1] = '-';
            pass->vis[2] = '-';
            pass->vis[3] = 0;
            pass->satname = g_strdup (sat->nickname);
            pass->details = NULL;

            /* iterate over each time step */
            for (t = pass->aos; t <= pass->los; t += step) {
            
                /* calculate satellite data */
                predict_calc (sat, qth, t);

                /* in the first iter we want to store
                    pass->aos_az
                */
                if (t == pass->aos) {
                    pass->aos_az = sat->az;
                    pass->orbit = sat->orbit;
                }

                /* append details to sat->details */
                detail = g_new (pass_detail_t, 1);
                detail->time = t;
                detail->pos.x = sat->pos.x;
                detail->pos.y = sat->pos.y;
                detail->pos.z = sat->pos.z;
                detail->pos.w = sat->pos.w;
                detail->vel.x = sat->vel.x;
                detail->vel.y = sat->vel.y;
                detail->vel.z = sat->vel.z;
                detail->vel.w = sat->vel.w;
                detail->velo = sat->velo;
                detail->az = sat->az;
                detail->el = sat->el;
                detail->range = sat->range;
                detail->range_rate = sat->range_rate;
                detail->lat = sat->ssplat;
                detail->lon = sat->ssplon;
                detail->alt = sat->alt;
                detail->ma = sat->ma;
                detail->phase = sat->phase;
                detail->footprint = sat->footprint;
                detail->orbit = sat->orbit;
                detail->vis = get_sat_vis (sat, qth, t);

                /* also store visibility "bit" */
                switch (detail->vis) {
                case SAT_VIS_VISIBLE:
                    pass->vis[0] = 'V';
                    break;
                case SAT_VIS_DAYLIGHT:
                    pass->vis[1] = 'D';
                    break;
                case SAT_VIS_ECLIPSED:
                    pass->vis[2] = 'E';
                    break;
                default:
                    break;
                }

                pass->details = g_slist_prepend (pass->details, detail);

                /* store elevation if greater than the
                    previously stored one
                */
                if (sat->el > max_el) {
                    max_el = sat->el;
                    tca = t;
                    pass->maxel_az = sat->az;
                }

                /*     g_print ("TIME: %f\tAZ: %f\tEL: %f (MAX: %f)\n", */
                /*           t, sat->az, sat->el, max_el); */
            }

            pass->details = g_slist_reverse (pass->details);

            /* calculate satellite data */
            predict_calc (sat, qth, pass->los);
            /* store los_az, max_el and tca */
            pass->los_az = sat->az;
            pass->max_el = max_el;
            pass->tca    = tca;

            /* check whether this pass is good */
            if (max_el >= sat_cfg_get_int (SAT_CFG_INT_PRED_MIN_EL)) {
                done = TRUE;
            }
            else {
                done = FALSE;
                t0 = los + 0.014; // +20 min
                free_pass (pass);
                pass = NULL;
            }

            iter++;
        }
    }

    return pass;
}
Exemplo n.º 13
0
/** \brief Show details about a satellite pass.
 *  \param parent The parent widget.
 *  \param satname The name of the satellite.
 *  \param qth Pointer to the QTH data.
 *  \param pass The pass info.
 *  \param toplevel The toplevel window or NULL.
 *
 * This function creates a dialog window containing a notebook with three pages:
 *   1. A list showing the details of a pass
 *   2. Polar plot of the pass
 *   3. Az/El plot of the pass
 *
 * Reference to the parent widget is needed to acquire the correct top-level
 * window, otherwise simply using the main window would bring that to front
 * covering any possible module windows. This would be unfortunate in the case
 * of fullscreen modules.
 *
 */
void show_pass (const gchar *satname, qth_t *qth, pass_t *pass, GtkWidget *toplevel)
{
    GtkWidget         *dialog;      /* the dialogue window */
    GtkWidget         *notebook;    /* the notebook widet */
    GtkWidget         *list;
    GtkListStore      *liststore;
    GtkCellRenderer   *renderer;
    GtkTreeViewColumn *column;
    GtkTreeIter        item;
    GtkWidget         *swin;        /* scrolled window containing the list view */
    GtkWidget         *polar;       /* polar plot */
    GtkWidget         *azel;        /* Az/El plot */
    GtkWidget         *hbox;        /* hbox used in tab headers */
    GtkWidget         *image;       /* icon used in tab header */
    gchar             *title;
    guint              flags;
    guint              i, num;
    pass_detail_t     *detail;
    gchar             *buff;
    gint               retcode;
    gdouble            doppler;
    gdouble            delay;
    gdouble            loss;
    obs_astro_t        astro;
    gdouble            ra,dec;


    /* get columns flags */
    flags = sat_cfg_get_int (SAT_CFG_INT_PRED_SINGLE_COL);

    /* create list */
    list = gtk_tree_view_new ();
    gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (list), TRUE);

    for (i = 0; i < SINGLE_PASS_COL_NUMBER; i++) {

        renderer = gtk_cell_renderer_text_new ();
        g_object_set (G_OBJECT (renderer), "xalign", SINGLE_PASS_COL_XALIGN[i], NULL);
        column = gtk_tree_view_column_new_with_attributes (_(SINGLE_PASS_COL_TITLE[i]),
                                                           renderer,
                                                           "text", i,
                                                           NULL);
        gtk_tree_view_insert_column (GTK_TREE_VIEW (list), column, -1);

        /* only aligns the headers */
        gtk_tree_view_column_set_alignment (column, 0.5);

        /* set cell data function; allows to format data before rendering */
        check_and_set_single_cell_renderer (column, renderer, i);

        /* hide columns that have not been specified */
        if (!(flags & (1 << i))) {
            gtk_tree_view_column_set_visible (column, FALSE);
        }


    }

    /* create and fill model */
    liststore = gtk_list_store_new (SINGLE_PASS_COL_NUMBER,
                                    G_TYPE_DOUBLE,   // time
                                    G_TYPE_DOUBLE,   // az
                                    G_TYPE_DOUBLE,   // el
                                    G_TYPE_DOUBLE,   // ra
                                    G_TYPE_DOUBLE,   // dec
                                    G_TYPE_DOUBLE,   // range
                                    G_TYPE_DOUBLE,   // range rate
                                    G_TYPE_DOUBLE,   // lat
                                    G_TYPE_DOUBLE,   // lon
                                    G_TYPE_STRING,   // SSP
                                    G_TYPE_DOUBLE,   // footprint
                                    G_TYPE_DOUBLE,   // alt
                                    G_TYPE_DOUBLE,   // vel
                                    G_TYPE_DOUBLE,   // doppler
                                    G_TYPE_DOUBLE,   // loss
                                    G_TYPE_DOUBLE,   // delay
                                    G_TYPE_DOUBLE,   // ma
                                    G_TYPE_DOUBLE,   // phase
                                    G_TYPE_STRING);  // visibility

    /* add rows to list store */
    num = g_slist_length (pass->details);

    
    for (i = 0; i < num; i++) {

        detail = PASS_DETAIL(g_slist_nth_data (pass->details, i));

        gtk_list_store_append (liststore, &item);
        gtk_list_store_set (liststore, &item,
                            SINGLE_PASS_COL_TIME, detail->time,
                            SINGLE_PASS_COL_AZ, detail->az,
                            SINGLE_PASS_COL_EL, detail->el,
                            SINGLE_PASS_COL_RANGE, detail->range,
                            SINGLE_PASS_COL_RANGE_RATE, detail->range_rate,
                            SINGLE_PASS_COL_LAT, detail->lat,
                            SINGLE_PASS_COL_LON, detail->lon,
                            SINGLE_PASS_COL_FOOTPRINT, detail->footprint,
                            SINGLE_PASS_COL_ALT, detail->alt,
                            SINGLE_PASS_COL_VEL, detail->velo,
                            SINGLE_PASS_COL_MA, detail->ma,
                            SINGLE_PASS_COL_PHASE, detail->phase,
                            -1);

        /*     SINGLE_PASS_COL_RA */
        /*     SINGLE_PASS_COL_DEC */
        if (flags & (SINGLE_PASS_FLAG_RA | SINGLE_PASS_FLAG_DEC)) {

            Calc_RADec (detail->time, detail->az, detail->el, qth, &astro);

            ra = Degrees(astro.ra);
            dec = Degrees(astro.dec);

            gtk_list_store_set (liststore, &item,
                                SINGLE_PASS_COL_RA, ra,
                                SINGLE_PASS_COL_DEC, dec,
                                -1);
        }
        
        /*     SINGLE_PASS_COL_SSP */
        if (flags & SINGLE_PASS_FLAG_SSP) {
            
            buff = g_try_malloc (7);

            retcode = longlat2locator (detail->lon, detail->lat, buff, 3);
            if (retcode == RIG_OK) {
                buff[6] = '\0';
                gtk_list_store_set (liststore, &item,
                                    SINGLE_PASS_COL_SSP, buff,
                                    -1);
            }
            g_free (buff);
        }
        
        /*      SINGLE_PASS_COL_DOPPLER */
        if (flags & SINGLE_PASS_FLAG_DOPPLER) {
            doppler = -100.0e06 * (detail->range_rate / 299792.4580); // Hz
            gtk_list_store_set (liststore, &item,
                                SINGLE_PASS_COL_DOPPLER, doppler,
                                -1);                        
        }

        /*     SINGLE_PASS_COL_LOSS */
        if (flags & SINGLE_PASS_FLAG_LOSS) {
            loss = 72.4 + 20.0*log10(detail->range);               // dB
            gtk_list_store_set (liststore, &item,
                                SINGLE_PASS_COL_LOSS, loss,
                                -1);                        
        }

        /*     SINGLE_PASS_COL_DELAY */
        if (flags & SINGLE_PASS_FLAG_DELAY) {
            delay   = detail->range / 299.7924580;         // msec 
            gtk_list_store_set (liststore, &item,
                                SINGLE_PASS_COL_DELAY, delay,
                                -1);                        
        }

        /*     SINGLE_PASS_COL_VIS */
        if (flags & SINGLE_PASS_FLAG_VIS) {
            buff = g_strdup_printf ("%c", vis_to_chr (detail->vis));
            gtk_list_store_set (liststore, &item,
                                SINGLE_PASS_COL_VIS, buff,
                                -1);                        
            g_free (buff);
        }

    }

    /* connect model to tree view */
    gtk_tree_view_set_model (GTK_TREE_VIEW (list), GTK_TREE_MODEL (liststore));
    g_object_unref (liststore);

    /* scrolled window */
    swin = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
                                    GTK_POLICY_NEVER,
                                    GTK_POLICY_AUTOMATIC);



    gtk_container_add (GTK_CONTAINER (swin), list);


    /* create notebook and add pages */
    notebook = gtk_notebook_new ();
    image = gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_FILL, GTK_ICON_SIZE_MENU);
    hbox = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
    gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("Data")), FALSE, TRUE, 5);
    gtk_widget_show_all (hbox);
    gtk_notebook_append_page (GTK_NOTEBOOK (notebook), swin, hbox);

    /* polar plot */
    polar = gtk_polar_plot_new (qth, pass);
    buff = icon_file_name ("gpredict-polar-small.png");
    image = gtk_image_new_from_file (buff);
    g_free (buff);
    hbox = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
    gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("Polar")), FALSE, TRUE, 5);
    gtk_widget_show_all (hbox);
    gtk_notebook_append_page (GTK_NOTEBOOK (notebook), polar, hbox);

    /* Az/El plot */
    azel = gtk_azel_plot_new (qth, pass);
    buff = icon_file_name ("gpredict-azel-small.png");
    image = gtk_image_new_from_file (buff);
    g_free (buff);
    hbox = gtk_hbox_new (FALSE, 0);
    gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, TRUE, 0);
    gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("Az/El")), FALSE, TRUE, 5);
    gtk_widget_show_all (hbox);
    gtk_notebook_append_page (GTK_NOTEBOOK (notebook), azel, hbox);


    /* create dialog */
    title = g_strdup_printf (_("Pass details for %s (orbit %d)"),
                             satname, pass->orbit);

    /* use NULL as parent to avoid conflict when using undocked windows
       as parents.
    */
    dialog = gtk_dialog_new_with_buttons (title,
                                          GTK_WINDOW (toplevel),
                                          GTK_DIALOG_DESTROY_WITH_PARENT,
                                          GTK_STOCK_PRINT, RESPONSE_PRINT,
                                          GTK_STOCK_SAVE, RESPONSE_SAVE,
                                          GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
                                          NULL);
    g_free (title);

    /* Make Close button default */
    gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);

    /* window icon */
    buff = icon_file_name ("gpredict-sat-list.png");
    gtk_window_set_icon_from_file (GTK_WINDOW (dialog), buff, NULL);
    g_free (buff);

    /* allow interaction with other windows */
    gtk_window_set_modal (GTK_WINDOW (dialog), FALSE);

    g_object_set_data (G_OBJECT (dialog), "sat", (gpointer) satname);
    g_object_set_data (G_OBJECT (dialog), "qth", qth);
    g_object_set_data (G_OBJECT (dialog), "pass", pass);


    g_signal_connect (dialog, "response",
                      G_CALLBACK (single_pass_response), NULL);
    g_signal_connect (dialog, "destroy",
                      G_CALLBACK (single_pass_dialog_destroy), NULL);
    g_signal_connect (dialog, "delete_event",
                      G_CALLBACK (single_pass_dialog_delete), NULL);    


    gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area(GTK_DIALOG(dialog))), notebook);

    gtk_window_set_default_size (GTK_WINDOW (dialog), -1, 300);
    gtk_widget_show_all (dialog);

}
Exemplo n.º 14
0
/** \brief Create and initialise widgets for the sky-at-glance tab.
 *
 * The widgets must be preloaded with values from config. If a config value
 * is NULL, sensible default values, eg. those from defaults.h should
 * be laoded.
 */
GtkWidget *sat_pref_sky_at_glance_create ()
{
    GtkWidget   *table;
    GtkWidget   *label;
    GtkWidget   *vbox;
    GdkColor     col;
    guint        rgb;   /* 0xRRGGBB encoded colour */
    guint        y;



    dirty = FALSE;
    reset = FALSE;

    table = gtk_table_new (16, 5, FALSE);
    gtk_table_set_row_spacings (GTK_TABLE (table), 5);
    gtk_table_set_col_spacings (GTK_TABLE (table), 5);


    label = gtk_label_new (NULL);
    gtk_label_set_markup (GTK_LABEL (label), _("<b>Time:</b>"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label,
                      0, 1, 0, 1,
                      GTK_FILL,
                      GTK_SHRINK,
                      0, 0);

    /* number of hours */
    label = gtk_label_new (_("Find and show passes that occur within"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label,
                      0, 1, 1, 2,
                      GTK_FILL,
                      GTK_SHRINK,
                      0, 0);
    timesp = gtk_spin_button_new_with_range (1, 24, 1);
    gtk_widget_set_tooltip_text (timesp,
                          _("The passes shown on the Sky at a Glance chart\n"\
                            "will begin within this number of hours."));
    gtk_spin_button_set_digits (GTK_SPIN_BUTTON (timesp), 0);
    gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (timesp), TRUE);
    gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (timesp), FALSE);
    gtk_spin_button_set_value (GTK_SPIN_BUTTON (timesp),
                               sat_cfg_get_int (SAT_CFG_INT_SKYATGL_TIME));
    g_signal_connect (G_OBJECT (timesp), "value-changed",
                      G_CALLBACK (spin_changed_cb), NULL);
    gtk_table_attach (GTK_TABLE (table), timesp,
                      1, 2, 1, 2,
                      GTK_SHRINK, GTK_SHRINK,
                      0, 0);
    label = gtk_label_new (_("hours"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label,
                      2, 3, 1, 2,
                      GTK_FILL,
                      GTK_SHRINK,
                      0, 0);
    
    /* separator */
    gtk_table_attach (GTK_TABLE (table),
                      gtk_hseparator_new (),
                      0, 5, 2, 3,
                      GTK_FILL | GTK_EXPAND,
                      GTK_SHRINK,
                      0, 0);



    y = 3;

    label = gtk_label_new (NULL);
    gtk_label_set_markup (GTK_LABEL (label), _("<b>Colours:</b>"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label,
                      0, 1, y, y+1,
                      GTK_FILL,
                      GTK_SHRINK,
                      0, 0);

    /* colour 1 */
    label = gtk_label_new (_("Colour for satellite 1: "));
    gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label,
                      0, 1, y+1, y+2,
                      GTK_SHRINK, GTK_SHRINK, 0, 0);
    col1 = gtk_color_button_new ();
    gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (col1), FALSE);
    gtk_color_button_set_title (GTK_COLOR_BUTTON (col1), _("Select colour 1"));
    gtk_table_attach (GTK_TABLE (table), col1,
                      1, 2, y+1, y+2,
                      GTK_FILL , GTK_FILL, 0, 0);
    gtk_widget_set_tooltip_text ( col1,
                                 _("Click to select a colour"));
    rgb = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_01);

    rgb2gdk (rgb, &col);
    gtk_color_button_set_color (GTK_COLOR_BUTTON (col1), &col);
    g_signal_connect (col1, "color-set", G_CALLBACK (colour_changed), NULL);

    /* colour 2 */
    label = gtk_label_new (_("Colour for satellite 2: "));
    gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label,
                      0, 1, y+2, y+3,
                      GTK_SHRINK, GTK_SHRINK, 0, 0);
    col2 = gtk_color_button_new ();
    gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (col2), FALSE);
    gtk_color_button_set_title (GTK_COLOR_BUTTON (col1), _("Select colour 2"));
    gtk_table_attach (GTK_TABLE (table), col2,
                      1, 2, y+2, y+3,
                      GTK_FILL , GTK_FILL, 0, 0);
    gtk_widget_set_tooltip_text ( col2,
                                 _("Click to select a colour"));
    rgb = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_02);

    rgb2gdk (rgb, &col);
    gtk_color_button_set_color (GTK_COLOR_BUTTON (col2), &col);
    g_signal_connect (col2, "color-set", G_CALLBACK (colour_changed), NULL);

    /* colour 3 */
    label = gtk_label_new (_("Colour for satellite 3: "));
    gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label,
                      0, 1, y+3, y+4,
                      GTK_SHRINK, GTK_SHRINK, 0, 0);
    col3 = gtk_color_button_new ();
    gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (col3), FALSE);
    gtk_color_button_set_title (GTK_COLOR_BUTTON (col3), _("Select colour 3"));
    gtk_table_attach (GTK_TABLE (table), col3,
                      1, 2, y+3, y+4,
                      GTK_FILL , GTK_FILL, 0, 0);
    gtk_widget_set_tooltip_text (col3,
                                 _("Click to select a colour"));
    rgb = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_03);

    rgb2gdk (rgb, &col);
    gtk_color_button_set_color (GTK_COLOR_BUTTON (col3), &col);
    g_signal_connect (col3, "color-set", G_CALLBACK (colour_changed), NULL);

    /* colour 4 */
    label = gtk_label_new (_("Colour for satellite 4: "));
    gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label,
                      0, 1, y+4, y+5,
                      GTK_SHRINK, GTK_SHRINK, 0, 0);
    col4 = gtk_color_button_new ();
    gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (col4), FALSE);
    gtk_color_button_set_title (GTK_COLOR_BUTTON (col4), _("Select colour 4"));
    gtk_table_attach (GTK_TABLE (table), col4,
                      1, 2, y+4, y+5,
                      GTK_FILL , GTK_FILL, 0, 0);
    gtk_widget_set_tooltip_text (col4,
                                 _("Click to select a colour"));
    rgb = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_04);

    rgb2gdk (rgb, &col);
    gtk_color_button_set_color (GTK_COLOR_BUTTON (col4), &col);
    g_signal_connect (col4, "color-set", G_CALLBACK (colour_changed), NULL);

    /* colour 5 */
    label = gtk_label_new (_("Colour for satellite 5: "));
    gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label,
                      0, 1, y+5, y+6,
                      GTK_SHRINK, GTK_SHRINK, 0, 0);
    col5 = gtk_color_button_new ();
    gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (col5), FALSE);
    gtk_color_button_set_title (GTK_COLOR_BUTTON (col5), _("Select colour 5"));
    gtk_table_attach (GTK_TABLE (table), col5,
                      1, 2, y+5, y+6,
                      GTK_FILL , GTK_FILL, 0, 0);
    gtk_widget_set_tooltip_text (col5,
                                 _("Click to select a colour"));
    rgb = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_05);

    rgb2gdk (rgb, &col);
    gtk_color_button_set_color (GTK_COLOR_BUTTON (col5), &col);
    g_signal_connect (col5, "color-set", G_CALLBACK (colour_changed), NULL);


    /* colour 6 */
    label = gtk_label_new (_("Colour for satellite 6: "));
    gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label,
                      3, 4, y+1, y+2,
                      GTK_SHRINK, GTK_SHRINK, 0, 0);
    col6 = gtk_color_button_new ();
    gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (col6), FALSE);
    gtk_color_button_set_title (GTK_COLOR_BUTTON (col6), _("Select colour 6"));
    gtk_table_attach (GTK_TABLE (table), col6,
                      4, 5, y+1, y+2,
                      GTK_FILL , GTK_FILL, 0, 0);
    gtk_widget_set_tooltip_text (col6,
                                 _("Click to select a colour"));
    rgb = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_06);

    rgb2gdk (rgb, &col);
    gtk_color_button_set_color (GTK_COLOR_BUTTON (col6), &col);
    g_signal_connect (col6, "color-set", G_CALLBACK (colour_changed), NULL);

    /* colour 7 */
    label = gtk_label_new (_("Colour for satellite 7: "));
    gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label,
                      3, 4, y+2, y+3,
                      GTK_SHRINK, GTK_SHRINK, 0, 0);
    col7 = gtk_color_button_new ();
    gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (col7), FALSE);
    gtk_color_button_set_title (GTK_COLOR_BUTTON (col7), _("Select colour 7"));
    gtk_table_attach (GTK_TABLE (table), col7,
                      4, 5, y+2, y+3,
                      GTK_FILL , GTK_FILL, 0, 0);
    gtk_widget_set_tooltip_text (col7,
                                 _("Click to select a colour"));
    rgb = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_07);

    rgb2gdk (rgb, &col);
    gtk_color_button_set_color (GTK_COLOR_BUTTON (col7), &col);
    g_signal_connect (col7, "color-set", G_CALLBACK (colour_changed), NULL);

    /* colour 8 */
    label = gtk_label_new (_("Colour for satellite 8: "));
    gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label,
                      3, 4, y+3, y+4,
                      GTK_SHRINK, GTK_SHRINK, 0, 0);
    col8 = gtk_color_button_new ();
    gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (col8), FALSE);
    gtk_color_button_set_title (GTK_COLOR_BUTTON (col8), _("Select colour 8"));
    gtk_table_attach (GTK_TABLE (table), col8,
                      4, 5, y+3, y+4,
                      GTK_FILL , GTK_FILL, 0, 0);
    gtk_widget_set_tooltip_text (col8,
                                 _("Click to select a colour"));
    rgb = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_08);

    rgb2gdk (rgb, &col);
    gtk_color_button_set_color (GTK_COLOR_BUTTON (col8), &col);
    g_signal_connect (col8, "color-set", G_CALLBACK (colour_changed), NULL);

    /* colour 9 */
    label = gtk_label_new (_("Colour for satellite 9: "));
    gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label,
                      3, 4, y+4, y+5,
                      GTK_SHRINK, GTK_SHRINK, 0, 0);
    col9 = gtk_color_button_new ();
    gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (col9), FALSE);
    gtk_color_button_set_title (GTK_COLOR_BUTTON (col9), _("Select colour 9"));
    gtk_table_attach (GTK_TABLE (table), col9,
                      4, 5, y+4, y+5,
                      GTK_FILL , GTK_FILL, 0, 0);
    gtk_widget_set_tooltip_text (col9,
                                 _("Click to select a colour"));
    rgb = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_09);

    rgb2gdk (rgb, &col);
    gtk_color_button_set_color (GTK_COLOR_BUTTON (col9), &col);
    g_signal_connect (col9, "color-set", G_CALLBACK (colour_changed), NULL);

    /* colour 10 */
    label = gtk_label_new (_("Colour for satellite 10: "));
    gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label,
                      3, 4, y+5, y+6,
                      GTK_SHRINK, GTK_SHRINK, 0, 0);
    col10 = gtk_color_button_new ();
    gtk_color_button_set_use_alpha (GTK_COLOR_BUTTON (col10), FALSE);
    gtk_color_button_set_title (GTK_COLOR_BUTTON (col10), _("Select colour 10"));
    gtk_table_attach (GTK_TABLE (table), col10,
                      4, 5, y+5, y+6,
                      GTK_FILL , GTK_FILL, 0, 0);
    gtk_widget_set_tooltip_text (col10,
                          _("Click to select a colour"));
    rgb = sat_cfg_get_int (SAT_CFG_INT_SKYATGL_COL_10);

    rgb2gdk (rgb, &col);
    gtk_color_button_set_color (GTK_COLOR_BUTTON (col10), &col);
    g_signal_connect (col10, "color-set", G_CALLBACK (colour_changed), NULL);




    /* create vertical box */
    vbox = gtk_vbox_new (FALSE, 0);
    gtk_container_set_border_width (GTK_CONTAINER (vbox), 20);
    gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0);

    /* create RESET button */
    create_reset_button (GTK_BOX (vbox));


    return vbox;

}
Exemplo n.º 15
0
/** \brief Create and initialise widgets.
 *
 */
GtkWidget *sat_pref_help_create ()
{
    GtkWidget *vbox;    /* vbox containing the list part and the details part */
    GtkWidget *table;
    GtkWidget *label;
    guint      i;
    gint       idx;

    vbox = gtk_vbox_new (FALSE, 10);
    gtk_container_set_border_width (GTK_CONTAINER (vbox), 20);

    /* header */
    label = gtk_label_new (NULL);
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    gtk_label_set_markup (GTK_LABEL (label),
                          _("<b>Html Browser:</b>"));
    gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);

    /* table for combo box and command string */
    table = gtk_table_new (2, 2, TRUE);
    gtk_table_set_col_spacings (GTK_TABLE (table), 10);
    gtk_table_set_row_spacings (GTK_TABLE (table), 10);
    gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, TRUE, 0);

    /* browser type */
    label = gtk_label_new (_("Browser type:"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);

    combo = gtk_combo_box_new_text ();
    for (i = 0; i < BROWSER_TYPE_NUM; i++)
        gtk_combo_box_append_text (GTK_COMBO_BOX (combo), sat_help[i].type);
    gtk_table_attach (GTK_TABLE (table), combo, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
    g_signal_connect (combo, "changed", G_CALLBACK (browser_changed_cb), NULL);

    /* command string */
    label = gtk_label_new (_("Command string:"));
    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
    gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0);

    entry = gtk_entry_new ();
    gtk_entry_set_max_length (GTK_ENTRY (entry), 100);
    gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 0);

    /* get curreent browser */
    idx = sat_cfg_get_int (SAT_CFG_INT_WEB_BROWSER_TYPE);

    /* some sanity check before accessing the arrays ;-) */
    if ((idx < BROWSER_TYPE_NONE) || (idx >= BROWSER_TYPE_NUM)) {
        idx = BROWSER_TYPE_NONE;
    }

    gtk_combo_box_set_active (GTK_COMBO_BOX (combo), idx);
    if (idx == BROWSER_TYPE_OTHER)
        gtk_entry_set_text (GTK_ENTRY (entry),
                            sat_cfg_get_str (SAT_CFG_STR_WEB_BROWSER));


    /** FIXME */
    gtk_widget_set_sensitive (vbox, FALSE);


    dirty = FALSE;

    return vbox;
}
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 ((sat->otype != ORBIT_TYPE_GEO) && (sat->otype != ORBIT_TYPE_DECAYED) &&
        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);
    }

}
Exemplo n.º 17
0
/** \brief Show details about a satellite pass.
 *  \param satname The name of the satellite.
 *  \param qth Pointer to the QTH data.
 *  \param passes List of passes to show.
 *  \param toplevel The toplevel window or NULL.
 *
 * This function creates a dialog window with a list showing the
 * details of a pass.
 *
 */
void show_passes (const gchar *satname, qth_t *qth, GSList *passes, GtkWidget *toplevel)
{
    GtkWidget         *dialog;
    GtkWidget         *list;
    GtkListStore      *liststore;
    GtkCellRenderer   *renderer;
    GtkTreeViewColumn *column;
    GtkTreeIter        item;
    GtkWidget         *swin;
    gchar             *title;
    guint              flags;
    guint              i, num;
    pass_t            *pass = NULL; 
    gchar             *buff;



    /* get columns flags */
    flags = sat_cfg_get_int (SAT_CFG_INT_PRED_MULTI_COL);

    /* create list */
    list = gtk_tree_view_new ();
    gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (list), TRUE);

    for (i = 0; i < MULTI_PASS_COL_NUMBER; i++) {

        renderer = gtk_cell_renderer_text_new ();
        g_object_set (G_OBJECT (renderer), "xalign", MULTI_PASS_COL_XALIGN[i], NULL);
        column = gtk_tree_view_column_new_with_attributes (_(MULTI_PASS_COL_TITLE[i]),
                                                           renderer,
                                                           "text", i,
                                                           NULL);
        gtk_tree_view_insert_column (GTK_TREE_VIEW (list), column, -1);

        /* only aligns the headers */
        gtk_tree_view_column_set_alignment (column, 0.5);

        /* set cell data function; allows to format data before rendering */
        check_and_set_multi_cell_renderer (column, renderer, i);

        /* hide columns that have not been specified */
        if (!(flags & (1 << i))) {
            gtk_tree_view_column_set_visible (column, FALSE);
        }


    }

    /* create and fill model */
    liststore = gtk_list_store_new (MULTI_PASS_COL_NUMBER+1,
                                    G_TYPE_DOUBLE,   // aos time
                                    G_TYPE_DOUBLE,   // tca time
                                    G_TYPE_DOUBLE,   // los time
                                    G_TYPE_DOUBLE,   // duration
                                    G_TYPE_DOUBLE,   // aos az
                                    G_TYPE_DOUBLE,   // max el
                                    G_TYPE_DOUBLE,   // az @ max el
                                    G_TYPE_DOUBLE,   // los az
                                    G_TYPE_INT,      // orbit
                                    G_TYPE_STRING,   // visibility
                                    G_TYPE_INT);     // row number

    /* add rows to list store */
    num = g_slist_length (passes);
    
    for (i = 0; i < num; i++) {

        pass = PASS(g_slist_nth_data (passes, i));

        gtk_list_store_append (liststore, &item);
        gtk_list_store_set (liststore, &item,
                            MULTI_PASS_COL_AOS_TIME, pass->aos,
                            MULTI_PASS_COL_TCA, pass->tca,
                            MULTI_PASS_COL_LOS_TIME, pass->los,
                            MULTI_PASS_COL_DURATION, (pass->los - pass->aos),
                            MULTI_PASS_COL_AOS_AZ, pass->aos_az,
                            MULTI_PASS_COL_MAX_EL, pass->max_el,
                            MULTI_PASS_COL_MAX_EL_AZ, pass->maxel_az,
                            MULTI_PASS_COL_LOS_AZ, pass->los_az,
                            MULTI_PASS_COL_ORBIT, pass->orbit,
                            MULTI_PASS_COL_VIS, pass->vis,
                            MULTI_PASS_COL_NUMBER, i,
                            -1);


    }

    /* connect model to tree view */
    gtk_tree_view_set_model (GTK_TREE_VIEW (list), GTK_TREE_MODEL (liststore));
    g_object_unref (liststore);

    /* store reference to passes and QTH */
    g_object_set_data (G_OBJECT (list), "passes", passes);
    g_object_set_data (G_OBJECT (list), "qth", qth);

    /* mouse events => popup menu */
    g_signal_connect (list, "button-press-event",
                      G_CALLBACK (button_press_cb), NULL);
    g_signal_connect (list, "popup-menu",
                      G_CALLBACK (popup_menu_cb), NULL);


    /* "row-activated" signal is used to catch double click events, which means
       a pass has been double clicked => show details */
    g_signal_connect (list, "row-activated",
                      G_CALLBACK(row_activated_cb), toplevel);


    /* scrolled window */
    swin = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
                                    GTK_POLICY_NEVER,
                                    GTK_POLICY_AUTOMATIC);

    gtk_container_add (GTK_CONTAINER (swin), list);


    /* create dialog */
    title = g_strdup_printf (_("Upcoming passes for %s"), satname);

    /* use NULL as parent to avoid conflict when using undocked windows
       as parents.    */
    dialog = gtk_dialog_new_with_buttons (title,
                                          GTK_WINDOW (toplevel),
                                          GTK_DIALOG_DESTROY_WITH_PARENT,
                                          GTK_STOCK_PRINT, RESPONSE_PRINT,
                                          GTK_STOCK_SAVE, RESPONSE_SAVE,
                                          GTK_STOCK_CLOSE,
                                          GTK_RESPONSE_CLOSE,
                                          NULL);
    g_free (title);

    /* Make Close button default */
    gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);

    /* window icon */
    buff = icon_file_name ("gpredict-sat-list.png");
    gtk_window_set_icon_from_file (GTK_WINDOW (dialog), buff, NULL);
    g_free (buff);

    /* allow interaction with other windows */
    gtk_window_set_modal (GTK_WINDOW (dialog), FALSE);

    g_object_set_data (G_OBJECT (dialog), "sat", (gpointer) satname);
    g_object_set_data (G_OBJECT (dialog), "qth", qth);
    g_object_set_data (G_OBJECT (dialog), "passes", passes);

    g_signal_connect (dialog, "response",
                      G_CALLBACK (multi_pass_response), NULL);
    g_signal_connect (dialog, "destroy",
                      G_CALLBACK (multi_pass_dialog_destroy), NULL);
    g_signal_connect (dialog, "delete_event",
                      G_CALLBACK (multi_pass_dialog_delete), NULL);


    gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area(GTK_DIALOG (dialog))), swin);

    gtk_window_set_default_size (GTK_WINDOW (dialog), -1, 300);
    gtk_widget_show_all (dialog);


}
Exemplo n.º 18
0
/** \brief Create and initialise widgets for the refresh rates tab.
 *
 * The widgets must be preloaded with values from config. If a config value
 * is NULL, sensible default values, eg. those from defaults.h should
 * be laoded.
 */
GtkWidget *sat_pref_refresh_create (GKeyFile *cfg)
{
     GtkWidget *table;
     GtkWidget *vbox;
     GtkWidget *label;
     gint       val;

     dirty = FALSE;
     reset = FALSE;

     /* create table */
     table = gtk_table_new (6, 3, FALSE);
     gtk_table_set_row_spacings (GTK_TABLE (table), 10);
     gtk_table_set_col_spacings (GTK_TABLE (table), 5);

     /* data refresh */
     label = gtk_label_new (_("Refresh data every"));
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
                 GTK_FILL,
                 GTK_SHRINK,
                 0, 0);

     dataspin = gtk_spin_button_new_with_range (100, 10000, 1);
     gtk_spin_button_set_increments (GTK_SPIN_BUTTON (dataspin), 1, 100);
     gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (dataspin), TRUE);
     gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (dataspin),
                            GTK_UPDATE_IF_VALID);
     if (cfg != NULL) {
          val = mod_cfg_get_int (cfg,
                           MOD_CFG_GLOBAL_SECTION,
                           MOD_CFG_TIMEOUT_KEY,
                           SAT_CFG_INT_MODULE_TIMEOUT);
     }
     else {
          val = sat_cfg_get_int (SAT_CFG_INT_MODULE_TIMEOUT);
     }
     gtk_spin_button_set_value (GTK_SPIN_BUTTON (dataspin), val);
     g_signal_connect (G_OBJECT (dataspin), "value-changed",
                 G_CALLBACK (spin_changed_cb), NULL);
     gtk_table_attach (GTK_TABLE (table), dataspin, 1, 2, 0, 1,
                 GTK_FILL,
                 GTK_SHRINK,
                 0, 0);

     label = gtk_label_new (_("[msec]"));
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1,
                 GTK_FILL | GTK_EXPAND,
                 GTK_SHRINK,
                 0, 0);

     /* separator */
     gtk_table_attach (GTK_TABLE (table),
                 gtk_hseparator_new (),
                 0, 3, 1, 2,
                 GTK_FILL | GTK_EXPAND,
                 GTK_SHRINK,
                 0, 0);


     /* List View */
     label = gtk_label_new (_("Refresh list view every"));
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
                 GTK_FILL,
                 GTK_SHRINK,
                 0, 0);

     listspin = gtk_spin_button_new_with_range (1, 50, 1);
     gtk_spin_button_set_increments (GTK_SPIN_BUTTON (listspin), 1, 5);
     gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (listspin), TRUE);
     gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (listspin),
                            GTK_UPDATE_IF_VALID);
     if (cfg != NULL) {
          val = mod_cfg_get_int (cfg,
                           MOD_CFG_LIST_SECTION,
                           MOD_CFG_LIST_REFRESH,
                           SAT_CFG_INT_LIST_REFRESH);
     }
     else {
          val = sat_cfg_get_int (SAT_CFG_INT_LIST_REFRESH);
     }
     gtk_spin_button_set_value (GTK_SPIN_BUTTON (listspin), val);
     g_signal_connect (G_OBJECT (listspin), "value-changed",
                 G_CALLBACK (spin_changed_cb), NULL);
     gtk_table_attach (GTK_TABLE (table), listspin, 1, 2, 2, 3,
                 GTK_FILL,
                 GTK_SHRINK,
                 0, 0);

     label = gtk_label_new (_("[cycle]"));
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_table_attach (GTK_TABLE (table), label, 2, 3, 2, 3,
                 GTK_FILL | GTK_EXPAND,
                 GTK_SHRINK,
                 0, 0);


     /* Map View */
     label = gtk_label_new (_("Refresh map view every"));
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
                 GTK_FILL,
                 GTK_SHRINK,
                 0, 0);

     mapspin = gtk_spin_button_new_with_range (1, 50, 1);
     gtk_spin_button_set_increments (GTK_SPIN_BUTTON (mapspin), 1, 5);
     gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (mapspin), TRUE);
     gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (mapspin),
                            GTK_UPDATE_IF_VALID);
     if (cfg != NULL) {
          val = mod_cfg_get_int (cfg,
                           MOD_CFG_MAP_SECTION,
                           MOD_CFG_MAP_REFRESH,
                           SAT_CFG_INT_MAP_REFRESH);
     }
     else {
          val = sat_cfg_get_int (SAT_CFG_INT_MAP_REFRESH);
     }
     gtk_spin_button_set_value (GTK_SPIN_BUTTON (mapspin), val);
     g_signal_connect (G_OBJECT (mapspin), "value-changed",
                 G_CALLBACK (spin_changed_cb), NULL);
     gtk_table_attach (GTK_TABLE (table), mapspin, 1, 2, 3, 4,
                 GTK_FILL,
                 GTK_SHRINK,
                 0, 0);

     label = gtk_label_new (_("[cycle]"));
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_table_attach (GTK_TABLE (table), label, 2, 3, 3, 4,
                 GTK_FILL | GTK_EXPAND,
                 GTK_SHRINK,
                 0, 0);


     /* Polar View */
     label = gtk_label_new (_("Refresh polar view every"));
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_table_attach (GTK_TABLE (table), label, 0, 1, 4, 5,
                 GTK_FILL,
                 GTK_SHRINK,
                 0, 0);

     polarspin = gtk_spin_button_new_with_range (1, 50, 1);
     gtk_spin_button_set_increments (GTK_SPIN_BUTTON (polarspin), 1, 5);
     gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (polarspin), TRUE);
     gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (polarspin),
                            GTK_UPDATE_IF_VALID);
     if (cfg != NULL) {
          val = mod_cfg_get_int (cfg,
                           MOD_CFG_POLAR_SECTION,
                           MOD_CFG_POLAR_REFRESH,
                           SAT_CFG_INT_POLAR_REFRESH);
     }
     else {
          val = sat_cfg_get_int (SAT_CFG_INT_POLAR_REFRESH);
     }
     gtk_spin_button_set_value (GTK_SPIN_BUTTON (polarspin), val);
     g_signal_connect (G_OBJECT (polarspin), "value-changed",
                 G_CALLBACK (spin_changed_cb), NULL);
     gtk_table_attach (GTK_TABLE (table), polarspin, 1, 2, 4, 5,
                 GTK_FILL,
                 GTK_SHRINK,
                 0, 0);

     label = gtk_label_new (_("[cycle]"));
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_table_attach (GTK_TABLE (table), label, 2, 3, 4, 5,
                 GTK_FILL | GTK_EXPAND,
                 GTK_SHRINK,
                 0, 0);


     /* Single-Sat View */
     label = gtk_label_new (_("Refresh single-sat view every"));
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_table_attach (GTK_TABLE (table), label, 0, 1, 5, 6,
                 GTK_FILL,
                 GTK_SHRINK,
                 0, 0);

     singlespin = gtk_spin_button_new_with_range (1, 50, 1);
     gtk_spin_button_set_increments (GTK_SPIN_BUTTON (singlespin), 1, 5);
     gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (singlespin), TRUE);
     gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (singlespin),
                            GTK_UPDATE_IF_VALID);
     if (cfg != NULL) {
          val = mod_cfg_get_int (cfg,
                           MOD_CFG_SINGLE_SAT_SECTION,
                           MOD_CFG_SINGLE_SAT_REFRESH,
                           SAT_CFG_INT_SINGLE_SAT_REFRESH);
     }
     else {
          val = sat_cfg_get_int (SAT_CFG_INT_SINGLE_SAT_REFRESH);
     }
     gtk_spin_button_set_value (GTK_SPIN_BUTTON (singlespin), val);
     g_signal_connect (G_OBJECT (singlespin), "value-changed",
                 G_CALLBACK (spin_changed_cb), NULL);
     gtk_table_attach (GTK_TABLE (table), singlespin, 1, 2, 5, 6,
                 GTK_FILL,
                 GTK_SHRINK,
                 0, 0);

     label = gtk_label_new (_("[cycle]"));
     gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
     gtk_table_attach (GTK_TABLE (table), label, 2, 3, 5, 6,
                 GTK_FILL | GTK_EXPAND,
                 GTK_SHRINK,
                 0, 0);


     /* create vertical box */
     vbox = gtk_vbox_new (FALSE, 0);
     gtk_container_set_border_width (GTK_CONTAINER (vbox), 20);
     gtk_box_pack_start (GTK_BOX (vbox), table, TRUE, TRUE, 0);

     /* create RESET button */
     create_reset_button (cfg, GTK_BOX (vbox));
     

        return vbox;
}
Exemplo n.º 19
0
GtkWidget      *sat_pref_debug_create()
{
    GtkWidget      *vbox;       /* vbox containing the list part and the details part */
    GtkWidget      *hbox;
    GtkWidget      *rbut;
    GtkWidget      *label;
    GtkWidget      *butbox;
    gchar          *msg;
    gchar          *confdir;

    vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
    gtk_box_set_homogeneous(GTK_BOX(vbox), FALSE);
    gtk_container_set_border_width(GTK_CONTAINER(vbox), 20);
    gtk_box_set_spacing(GTK_BOX(vbox), 10);

    /* debug level */
    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
    gtk_box_set_homogeneous(GTK_BOX(hbox), FALSE);

    label = gtk_label_new(_("Debug level:"));
    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);

    level = gtk_combo_box_text_new();
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(level),
                                   _("Level 0: None"));
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(level),
                                   _("Level 1: Error"));
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(level),
                                   _("Level 2: Warning"));
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(level),
                                   _("Level 3: Info"));
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(level),
                                   _("Level 4: Debug"));
    gtk_combo_box_set_active(GTK_COMBO_BOX(level),
                             sat_cfg_get_int(SAT_CFG_INT_LOG_LEVEL));
    g_signal_connect(G_OBJECT(level), "realize",
                     G_CALLBACK(gpredict_set_combo_tooltips),
                     _("Select the debug level. The higher the level, "
                       "the more messages will be logged."));
    g_signal_connect(G_OBJECT(level), "changed", G_CALLBACK(state_change_cb),
                     NULL);

    gtk_box_pack_start(GTK_BOX(hbox), level, FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

    /* clean frequency */
    hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
    gtk_box_set_homogeneous(GTK_BOX(hbox), FALSE);

    label = gtk_label_new(_("Delete log files older than:"));
    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);

    age = gtk_combo_box_text_new();
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(age),
                                   _("Always delete"));
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(age), _("1 day"));
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(age), _("1 week"));
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(age), _("1 month"));
    select_age();
    g_signal_connect(G_OBJECT(age), "realize",
                     G_CALLBACK(gpredict_set_combo_tooltips),
                     _("Select how often gpredict should delete "
                       "old log files."));
    g_signal_connect(G_OBJECT(age), "changed", G_CALLBACK(state_change_cb),
                     NULL);
    gtk_box_pack_start(GTK_BOX(hbox), age, FALSE, FALSE, 10);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);

    /* separator */
    gtk_box_pack_start(GTK_BOX(vbox),
                       gtk_separator_new(GTK_ORIENTATION_HORIZONTAL),
                       FALSE, FALSE, 0);

    /* info label */
    confdir = get_user_conf_dir();
    msg =
        g_strdup_printf(_
                        ("Gpredict stores all run-time messages in the %s%slogs%s\n"
                         "directory. The current log file is called gpredict.log and the file is\n"
                         "always kept until the next execution, so that you can examine it in case\n"
                         "of a failure. If old log files are kept, they are called gpredict-XYZ.log\n"
                         "where XYZ is a unique timestamp."), 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);
    g_free(msg);

    /* reset button */
    rbut = gtk_button_new_with_label(_("Reset"));
    gtk_widget_set_tooltip_text(rbut,
                                _("Reset settings to the default values."));
    g_signal_connect(G_OBJECT(rbut), "clicked", G_CALLBACK(reset_cb), NULL);
    butbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
    gtk_button_box_set_layout(GTK_BUTTON_BOX(butbox), GTK_BUTTONBOX_END);
    gtk_box_pack_end(GTK_BOX(butbox), rbut, FALSE, TRUE, 10);

    gtk_box_pack_end(GTK_BOX(vbox), butbox, FALSE, TRUE, 0);

    return vbox;
}