[Gpredict-svn] SF.net SVN: gpredict: [22] trunk
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
|
From: <cs...@us...> - 2008-01-24 23:34:50
|
Revision: 22
http://gpredict.svn.sourceforge.net/gpredict/?rev=22&view=rev
Author: csete
Date: 2008-01-24 15:34:50 -0800 (Thu, 24 Jan 2008)
Log Message:
-----------
Added rotator configuration code.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/Makefile.am
trunk/src/rotor-conf.c
trunk/src/rotor-conf.h
trunk/src/sat-pref-rig.c
trunk/src/sat-pref-rig.h
trunk/src/sat-pref-rot-data.h
trunk/src/sat-pref-rot-editor.c
trunk/src/sat-pref-rot.c
trunk/src/sat-pref-rot.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-01-24 22:58:40 UTC (rev 21)
+++ trunk/ChangeLog 2008-01-24 23:34:50 UTC (rev 22)
@@ -3,6 +3,17 @@
* src/sat-pref-rig-editor.[ch]:
Finished first draft of radio configuration editor.
+ * src/sat-pref-rig.c:
+ Finished radio configuration page.
+
+ * src/rotor-conf.[ch]:
+ * src/sat-pref-rot-editor.[ch]:
+ * src/sat-pref-rot-data.h:
+ Added files with functions to read and save rotator configuration.
+
+ * src/sat-pref-rot.c:
+ Updated to use new rotator configuration code.
+
2008-01-12; Alexandru Csete <oz...@gm...>
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2008-01-24 22:58:40 UTC (rev 21)
+++ trunk/src/Makefile.am 2008-01-24 23:34:50 UTC (rev 22)
@@ -92,7 +92,7 @@
sat-pref-interfaces.c sat-pref-interfaces.h \
sat-pref-rig.c sat-pref-rig.h sat-pref-rig-data.h \
sat-pref-rig-editor.c sat-pref-rig-editor.h \
- sat-pref-rot.c sat-pref-rot.h \
+ sat-pref-rot.c sat-pref-rot.h sat-pref-rot-data.h \
sat-pref-rot-editor.c sat-pref-rot-editor.h \
sat-pref-predict.c sat-pref-predict.h \
sat-pref-conditions.c sat-pref-conditions.h \
Modified: trunk/src/rotor-conf.c
===================================================================
--- trunk/src/rotor-conf.c 2008-01-24 22:58:40 UTC (rev 21)
+++ trunk/src/rotor-conf.c 2008-01-24 23:34:50 UTC (rev 22)
@@ -101,7 +101,7 @@
* .rig file. conf->name must contain the file name of the configuration
* (no path, just file name and without the .rot extension).
*/
-void rotor_conf_save (radio_conf_t *conf)
+void rotor_conf_save (rotor_conf_t *conf)
{
GKeyFile *cfg = NULL;
gchar *confdir;
Modified: trunk/src/rotor-conf.h
===================================================================
--- trunk/src/rotor-conf.h 2008-01-24 22:58:40 UTC (rev 21)
+++ trunk/src/rotor-conf.h 2008-01-24 23:34:50 UTC (rev 22)
@@ -55,6 +55,6 @@
gboolean rotor_conf_read (rotor_conf_t *conf);
-void rotor_conf_save (rtor_conf_t *conf);
+void rotor_conf_save (rotor_conf_t *conf);
#endif
Modified: trunk/src/sat-pref-rig.c
===================================================================
--- trunk/src/sat-pref-rig.c 2008-01-24 22:58:40 UTC (rev 21)
+++ trunk/src/sat-pref-rig.c 2008-01-24 23:34:50 UTC (rev 22)
@@ -40,7 +40,7 @@
#include "sat-pref-rig-editor.h"
#include "sat-pref-rig.h"
-
+#ifdef HAVE_HAMLIB
extern GtkWidget *window; /* dialog window defined in sat-pref.c */
@@ -800,6 +800,4 @@
}
-
-
-
+#endif
Modified: trunk/src/sat-pref-rig.h
===================================================================
--- trunk/src/sat-pref-rig.h 2008-01-24 22:58:40 UTC (rev 21)
+++ trunk/src/sat-pref-rig.h 2008-01-24 23:34:50 UTC (rev 22)
@@ -28,10 +28,10 @@
#ifndef SAT_PREF_RIG_H
#define SAT_PREF_RIG_H 1
-
+#ifdef HAVE_HAMLIB
GtkWidget *sat_pref_rig_create (void);
void sat_pref_rig_cancel (void);
void sat_pref_rig_ok (void);
+#endif
-
#endif
Modified: trunk/src/sat-pref-rot-data.h
===================================================================
--- trunk/src/sat-pref-rot-data.h 2008-01-24 22:58:40 UTC (rev 21)
+++ trunk/src/sat-pref-rot-data.h 2008-01-24 23:34:50 UTC (rev 22)
@@ -30,13 +30,13 @@
/** \brief Coumn definitions for rotator list. */
typedef enum {
- RIG_LIST_COL_NAME = 0, /*!< File name. */
- RIG_LIST_COL_MODEL, /*!< Model */
- RIG_LIST_COL_ID, /*!< Hamlib ID. */
- RIG_LIST_COL_TYPE, /*!< Rtator type. */
- RIG_LIST_COL_PORT, /*!< Port / Device, e.g. /dev/ttyS0. */
- RIG_LIST_COL_SPEED, /*!< Serial speed. */
- RIG_LIST_COL_NUM /*!< The number of fields in the list. */
+ ROT_LIST_COL_NAME = 0, /*!< File name. */
+ ROT_LIST_COL_MODEL, /*!< Model */
+ ROT_LIST_COL_ID, /*!< Hamlib ID. */
+ ROT_LIST_COL_TYPE, /*!< Rtator type. */
+ ROT_LIST_COL_PORT, /*!< Port / Device, e.g. /dev/ttyS0. */
+ ROT_LIST_COL_SPEED, /*!< Serial speed. */
+ ROT_LIST_COL_NUM /*!< The number of fields in the list. */
} rotor_list_col_t;
Modified: trunk/src/sat-pref-rot-editor.c
===================================================================
--- trunk/src/sat-pref-rot-editor.c 2008-01-24 22:58:40 UTC (rev 21)
+++ trunk/src/sat-pref-rot-editor.c 2008-01-24 23:34:50 UTC (rev 22)
@@ -26,7 +26,7 @@
along with this program; if not, visit http://www.fsf.org/
*/
-/** \brief Edit radio configuration.
+/** \brief Edit rotator configuration.
*
*/
@@ -40,11 +40,11 @@
#include "gpredict-utils.h"
#include "sat-cfg.h"
#include "sat-log.h"
-#include "radio-conf.h"
-#include "sat-pref-rig-editor.h"
+#include "rotor-conf.h"
+#include "sat-pref-rot-editor.h"
#ifdef HAVE_HAMLIB
-# include <hamlib/rig.h>
+# include <hamlib/rotator.h>
extern GtkWidget *window; /* dialog window defined in sat-pref.c */
@@ -54,45 +54,43 @@
/* private widgets */
static GtkWidget *dialog; /* dialog window */
static GtkWidget *name; /* Configuration name */
-static GtkWidget *model; /* radio model, e.g. TS-2000 */
-static GtkWidget *civ; /* Icom CI-V address */
-static GtkWidget *type; /* radio type */
+static GtkWidget *model; /* rotor model, e.g. TS-2000 */
+static GtkWidget *type; /* rotor type */
static GtkWidget *port; /* port selector */
static GtkWidget *speed; /* serial speed selector */
-static GtkWidget *dtr,*rts; /* DTR and RTS line states */
-static GtkWidget *create_editor_widgets (radio_conf_t *conf);
-static void update_widgets (radio_conf_t *conf);
+static GtkWidget *create_editor_widgets (rotor_conf_t *conf);
+static void update_widgets (rotor_conf_t *conf);
static void clear_widgets (void);
-static gboolean apply_changes (radio_conf_t *conf);
+static gboolean apply_changes (rotor_conf_t *conf);
static void name_changed (GtkWidget *widget, gpointer data);
-static GtkTreeModel *create_rig_model (void);
-static gint rig_list_add (const struct rig_caps *, void *);
-static gint rig_list_compare_mfg (gconstpointer, gconstpointer);
-static gint rig_list_compare_mod (gconstpointer, gconstpointer);
-static void is_rig_model (GtkCellLayout *cell_layout,
+static GtkTreeModel *create_rot_model (void);
+static gint rot_list_add (const struct rot_caps *, void *);
+static gint rot_list_compare_mfg (gconstpointer, gconstpointer);
+static gint rot_list_compare_mod (gconstpointer, gconstpointer);
+static void is_rot_model (GtkCellLayout *cell_layout,
GtkCellRenderer *cell,
GtkTreeModel *tree_model,
GtkTreeIter *iter,
gpointer data);
-static void select_rig (guint rigid);
+static void select_rot (guint rotid);
-/** \brief Add or edit a radio configuration.
- * \param conf Pointer to a radio configuration.
+/** \brief Add or edit a rotor configuration.
+ * \param conf Pointer to a rotator configuration.
*
- * Of conf->name is not NULL the widgets will be populated with the data.
+ * If conf->name is not NULL the widgets will be populated with the data.
*/
void
-sat_pref_rig_editor_run (radio_conf_t *conf)
+sat_pref_rot_editor_run (rotor_conf_t *conf)
{
gint response;
gboolean finished = FALSE;
/* crate dialog and add contents */
- dialog = gtk_dialog_new_with_buttons (_("Edit radio configuration"),
+ dialog = gtk_dialog_new_with_buttons (_("Edit rotator configuration"),
GTK_WINDOW (window),
GTK_DIALOG_MODAL |
GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -149,14 +147,12 @@
/** \brief Create and initialise widgets */
static GtkWidget *
-create_editor_widgets (radio_conf_t *conf)
+create_editor_widgets (rotor_conf_t *conf)
{
GtkWidget *table;
GtkWidget *label;
- GtkTreeModel *riglist;
+ GtkTreeModel *rotlist;
GtkCellRenderer *renderer;
- gchar *buff;
- guint i;
table = gtk_table_new (5, 5, FALSE);
@@ -172,7 +168,7 @@
name = gtk_entry_new ();
gtk_entry_set_max_length (GTK_ENTRY (name), 25);
gtk_widget_set_tooltip_text (name,
- _("Enter a short name for this configuration, e.g. IC910-1.\n"\
+ _("Enter a short name for this configuration, e.g. ROTOR-1.\n"\
"Allowed charachters: 0..9, a..z, A..Z, - and _"));
gtk_table_attach_defaults (GTK_TABLE (table), name, 1, 4, 0, 1);
@@ -186,9 +182,9 @@
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 1, 2);
- riglist = create_rig_model ();
- model = gtk_combo_box_new_with_model (riglist);
- g_object_unref (riglist);
+ rotlist = create_rot_model ();
+ model = gtk_combo_box_new_with_model (rotlist);
+ g_object_unref (rotlist);
gtk_table_attach_defaults (GTK_TABLE (table), model, 1, 2, 1, 2);
renderer = gtk_cell_renderer_text_new ();
@@ -198,46 +194,22 @@
NULL);
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (model),
renderer,
- is_rig_model,
+ is_rot_model,
NULL, NULL);
- gtk_widget_set_tooltip_text (model, _("Click to select a radio."));
- select_rig (1);
+ gtk_widget_set_tooltip_text (model, _("Click to select a driver."));
+ select_rot (1);
- /* ICOM CI-V adress */
- label = gtk_label_new (_("ICOM CI-V"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_table_attach_defaults (GTK_TABLE (table), label, 3, 4, 1, 2);
-
- civ = gtk_combo_box_new_text ();
- gtk_widget_set_tooltip_text (civ,
- _("Select ICOM CI-V address of the radio."));
-
- /* works, but pretty lame... */
- gtk_combo_box_append_text (GTK_COMBO_BOX (civ), _("Default"));
- for (i = 1; i < 0xF0; i++) {
- if (i < 0x10)
- buff = g_strdup_printf ("0x0%X", i);
- else
- buff = g_strdup_printf ("0x%X", i);
- gtk_combo_box_append_text (GTK_COMBO_BOX (civ), buff);
- g_free (buff);
- }
- gtk_combo_box_set_active (GTK_COMBO_BOX (civ), 0);
- gtk_table_attach_defaults (GTK_TABLE (table), civ, 4, 5, 1, 2);
-
-
/* Type */
label = gtk_label_new (_("Type"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 2, 3);
type = gtk_combo_box_new_text ();
- gtk_combo_box_append_text (GTK_COMBO_BOX (type), _("Receiver"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (type), _("Transmitter"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (type), _("RX + TX"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (type), _("Full Duplex"));
- gtk_combo_box_set_active (GTK_COMBO_BOX (type), 0);
+ gtk_combo_box_append_text (GTK_COMBO_BOX (type), _("AZ"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (type), _("EL"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (type), _("AZ / EL"));
+ gtk_combo_box_set_active (GTK_COMBO_BOX (type), 2);
gtk_widget_set_tooltip_text (type,
- _("Select radio type. Consult the user manual, if unsure"));
+ _("Select rotor type."));
gtk_table_attach_defaults (GTK_TABLE (table), type, 1, 2, 2, 3);
/* Port */
@@ -259,21 +231,6 @@
gtk_widget_set_tooltip_text (port, _("Select or enter communication port"));
gtk_table_attach_defaults (GTK_TABLE (table), port, 1, 2, 3, 4);
- /* DTR State */
- label = gtk_label_new (_("DTR Line"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_table_attach_defaults (GTK_TABLE (table), label, 3, 4, 3, 4);
-
- dtr = gtk_combo_box_new_text ();
- gtk_combo_box_append_text (GTK_COMBO_BOX (dtr), _("Undefined"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (dtr), _("OFF"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (dtr), _("ON"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (dtr), _("PTT"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (dtr), _("CW"));
- gtk_combo_box_set_active (GTK_COMBO_BOX (dtr), 0);
- gtk_widget_set_tooltip_text (dtr, _("Select status and use of DTR line"));
- gtk_table_attach_defaults (GTK_TABLE (table), dtr, 4, 5, 3, 4);
-
/* Speed */
label = gtk_label_new (_("Rate"));
@@ -293,25 +250,7 @@
gtk_widget_set_tooltip_text (speed, _("Select serial port speed"));
gtk_table_attach_defaults (GTK_TABLE (table), speed, 1, 2, 4, 5);
- /* RTS State */
- label = gtk_label_new (_("RTS Line"));
- gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
- gtk_table_attach_defaults (GTK_TABLE (table), label, 3, 4, 4, 5);
-
- rts = gtk_combo_box_new_text ();
- gtk_combo_box_append_text (GTK_COMBO_BOX (rts), _("Undefined"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (rts), _("OFF"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (rts), _("ON"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (rts), _("PTT"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (rts), _("CW"));
- gtk_combo_box_set_active (GTK_COMBO_BOX (rts), 0);
- gtk_widget_set_tooltip_text (rts, _("Select status and use of RTS line"));
- gtk_table_attach_defaults (GTK_TABLE (table), rts, 4, 5, 4, 5);
- /* separator between port/speed and DTR/RTS */
- gtk_table_attach (GTK_TABLE (table), gtk_vseparator_new(), 2, 3, 1, 5,
- GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 5, 0);
-
if (conf->name != NULL)
update_widgets (conf);
@@ -324,17 +263,17 @@
/** \brief Update widgets from the currently selected row in the treeview
*/
static void
-update_widgets (radio_conf_t *conf)
+update_widgets (rotor_conf_t *conf)
{
/* configuration name */
gtk_entry_set_text (GTK_ENTRY (name), conf->name);
/* model */
- select_rig (conf->id);
+ select_rot (conf->id);
/* type */
- gtk_combo_box_set_active (GTK_COMBO_BOX (type), conf->type);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (type), conf->type-1);
/* port */
gtk_combo_box_prepend_text (GTK_COMBO_BOX (port), conf->port);
@@ -371,12 +310,6 @@
break;
}
- /* CI-V */
- gtk_combo_box_set_active (GTK_COMBO_BOX (civ), conf->civ);
-
- /* DTR and RTS lines */
- gtk_combo_box_set_active (GTK_COMBO_BOX (dtr), conf->dtr);
- gtk_combo_box_set_active (GTK_COMBO_BOX (rts), conf->rts);
}
@@ -390,13 +323,10 @@
clear_widgets ()
{
gtk_entry_set_text (GTK_ENTRY (name), "");
- select_rig (1);
- gtk_combo_box_set_active (GTK_COMBO_BOX (type), 0);
+ select_rot (1);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (type), 2);
gtk_combo_box_set_active (GTK_COMBO_BOX (port), 0);
gtk_combo_box_set_active (GTK_COMBO_BOX (speed), 4);
- gtk_combo_box_set_active (GTK_COMBO_BOX (civ), 0);
- gtk_combo_box_set_active (GTK_COMBO_BOX (dtr), 0);
- gtk_combo_box_set_active (GTK_COMBO_BOX (rts), 0);
}
@@ -406,10 +336,10 @@
* This function is usually called when the user clicks the OK button.
*/
static gboolean
-apply_changes (radio_conf_t *conf)
+apply_changes (rotor_conf_t *conf)
{
GtkTreeIter iter1,iter2;
- GtkTreeModel *riglist;
+ GtkTreeModel *rotlist;
gchar *b1,*b2;
guint id;
@@ -426,22 +356,22 @@
/* iter1 is needed to construct full model name */
gtk_combo_box_get_active_iter (GTK_COMBO_BOX (model), &iter2);
- riglist = gtk_combo_box_get_model (GTK_COMBO_BOX (model));
- gtk_tree_model_iter_parent (riglist, &iter1, &iter2);
+ rotlist = gtk_combo_box_get_model (GTK_COMBO_BOX (model));
+ gtk_tree_model_iter_parent (rotlist, &iter1, &iter2);
/* build model string */
- gtk_tree_model_get (riglist, &iter1, 0, &b1, -1);
- gtk_tree_model_get (riglist, &iter2, 0, &b2, -1);
+ gtk_tree_model_get (rotlist, &iter1, 0, &b1, -1);
+ gtk_tree_model_get (rotlist, &iter2, 0, &b2, -1);
conf->model = g_strconcat (b1, " ", b2, NULL);
g_free (b1);
g_free (b2);
/* ID */
- gtk_tree_model_get (riglist, &iter2, 1, &id, -1);
+ gtk_tree_model_get (rotlist, &iter2, 1, &id, -1);
conf->id = id;
- /* radio type */
- conf->type = gtk_combo_box_get_active (GTK_COMBO_BOX (type));
+ /* rotor type */
+ conf->type = gtk_combo_box_get_active (GTK_COMBO_BOX (type))+1;
/* port / device */
if (conf->port)
@@ -449,8 +379,6 @@
conf->port = gtk_combo_box_get_active_text (GTK_COMBO_BOX (port));
- /* CI-V */
- conf->civ = gtk_combo_box_get_active (GTK_COMBO_BOX (civ));
/* serial speed */
switch (gtk_combo_box_get_active (GTK_COMBO_BOX (speed))) {
@@ -486,9 +414,6 @@
break;
}
- /* DTR and RTS */
- conf->dtr = gtk_combo_box_get_active (GTK_COMBO_BOX (dtr));
- conf->rts = gtk_combo_box_get_active (GTK_COMBO_BOX (rts));
return TRUE;
}
@@ -553,23 +478,23 @@
}
-/** \brief Radio info to be used when building the rig model */
+/** \brief Rotor info to be used when building the rot model */
typedef struct {
gint id; /*!< Model ID. */
gchar *mfg; /*!< Manufacurer name (eg. KENWOOD). */
- gchar *model; /*!< Radio model (eg. TS-440). */
-} rig_info_t;
+ gchar *model; /*!< rotor model (eg. TS-440). */
+} rot_info_t;
-/** \brief Build tree model containing radios.
- * \return A tree model where the radios are ordered according to
+/** \brief Build tree model containing rotators.
+ * \return A tree model where the rotator are ordered according to
* manufacturer.
*
*/
-static GtkTreeModel *create_rig_model ()
+static GtkTreeModel *create_rot_model ()
{
GArray *array;
- rig_info_t *info;
+ rot_info_t *info;
GtkTreeIter iter1; /* iter used for manufacturer */
GtkTreeIter iter2; /* iter used for model */
GtkTreeStore *store;
@@ -578,19 +503,19 @@
gint i;
- /* create araay containing rigs */
- array = g_array_new (FALSE, FALSE, sizeof (rig_info_t));
- rig_load_all_backends();
+ /* create araay containing rots */
+ array = g_array_new (FALSE, FALSE, sizeof (rot_info_t));
+ rot_load_all_backends();
- /* fill list using rig_list_foreach */
- status = rig_list_foreach (rig_list_add, (void *) array);
+ /* fill list using rot_list_foreach */
+ status = rot_list_foreach (rot_list_add, (void *) array);
/* sort the array, first by model then by mfg */
- g_array_sort (array, rig_list_compare_mod);
- g_array_sort (array, rig_list_compare_mfg);
+ g_array_sort (array, rot_list_compare_mod);
+ g_array_sort (array, rot_list_compare_mfg);
sat_log_log (SAT_LOG_LEVEL_DEBUG,
- _("%s:%d: Read %d distinct radios into array."),
+ _("%s:%d: Read %d distinct rotators into array."),
__FILE__, __LINE__, array->len);
/* create a tree store with two cols (name and ID) */
@@ -599,8 +524,8 @@
/* add array contents to treestore */
for (i = 0; i < array->len; i++) {
- /* get rig info struct */
- info = &g_array_index (array, rig_info_t, i);
+ /* get rotor info struct */
+ info = &g_array_index (array, rot_info_t, i);
if (gtk_tree_store_iter_is_valid (store, &iter1)) {
/* iter1 is valid, i.e. we already have a manufacturer */
@@ -620,7 +545,7 @@
gtk_tree_store_set (store, &iter1, 0, info->mfg, -1);
}
- /* iter1 points to the parent mfg; insert this rig */
+ /* iter1 points to the parent mfg; insert this rot */
gtk_tree_store_append (store, &iter2, &iter1);
gtk_tree_store_set (store, &iter2,
0, info->model,
@@ -638,29 +563,28 @@
}
-/** \brief Add new entry to list of radios.
- * \param caps Structure with the capablities of thecurrent radio.
+/** \brief Add new entry to list of rotators.
+ * \param caps Structure with the capablities of the current rotator.
* \param array Pointer to the GArray into which the new entry should be
* stored.
- * \return Always 1 to keep rig_list_foreach running.
+ * \return Always 1 to keep rot_list_foreach running.
*
- * This function is called by the rig_list_foreach hamlib function for each
- * supported radio. It copies the relevant data into a grig_rig_info_t
+ * This function is called by the rot_list_foreach hamlib function for each
+ * supported rotator. It copies the relevant data into a rot_info_t
* structure and adds the new entry to the GArray containing the list of
- * supported radios.
+ * supported rotators.
*
- * \sa rig_list_compare
*/
static gint
-rig_list_add (const struct rig_caps *caps, void *array)
+rot_list_add (const struct rot_caps *caps, void *array)
{
- rig_info_t *info;
+ rot_info_t *info;
/* create new entry */
- info = g_malloc (sizeof (rig_info_t));
+ info = g_malloc (sizeof (rot_info_t));
/* fill values */
- info->id = caps->rig_model;
+ info->id = caps->rot_model;
info->mfg = g_strdup (caps->mfg_name);
info->model = g_strdup (caps->model_name);
@@ -673,23 +597,22 @@
-/** \brief Compare two rig info entries.
+/** \brief Compare two rot info entries.
* \param a Pointer to the first entry.
* \param b Pointer to the second entry.
* \return Negative value if a < b; zero if a = b; positive value if a > b.
*
- * This function is used to compare two rig entries in the list of radios
- * when the list is sorted. It compares the manufacturer of the two radios.
+ * This function is used to compare two rot entries in the list of rotators
+ * when the list is sorted. It compares the manufacturer of the two rotators.
*
- * \sa rig_list_add
*/
static gint
-rig_list_compare_mfg (gconstpointer a, gconstpointer b)
+rot_list_compare_mfg (gconstpointer a, gconstpointer b)
{
gchar *ida, *idb;
- ida = ((rig_info_t *) a)->mfg;
- idb = ((rig_info_t *) b)->mfg;
+ ida = ((rot_info_t *) a)->mfg;
+ idb = ((rot_info_t *) b)->mfg;
if (g_ascii_strcasecmp(ida,idb) < 0) {
return -1;
@@ -705,23 +628,22 @@
-/** \brief Compare two rig info entries.
+/** \brief Compare two rot info entries.
* \param a Pointer to the first entry.
* \param b Pointer to the second entry.
* \return Negative value if a < b; zero if a = b; positive value if a > b.
*
- * This function is used to compare two rig entries in the list of radios
- * when the list is sorted. It compares the model of the two radios.
+ * This function is used to compare two rot entries in the list of rotators
+ * when the list is sorted. It compares the model of the two rotators
*
- * \sa rig_list_add
*/
static gint
-rig_list_compare_mod (gconstpointer a, gconstpointer b)
+rot_list_compare_mod (gconstpointer a, gconstpointer b)
{
gchar *ida, *idb;
- ida = ((rig_info_t *) a)->model;
- idb = ((rig_info_t *) b)->model;
+ ida = ((rot_info_t *) a)->model;
+ idb = ((rot_info_t *) b)->model;
if (g_ascii_strcasecmp(ida,idb) < 0) {
return -1;
@@ -738,12 +660,12 @@
/** \brief Set cell sensitivity.
*
- * This function is used to disable the sensitive of manifacturer entries
+ * This function is used to disable the sensitivity of manufacturer entries
* as children. Otherwise, the manufacturer would appear as the first entry
* in a submenu.
* */
static void
-is_rig_model (GtkCellLayout *cell_layout,
+is_rot_model (GtkCellLayout *cell_layout,
GtkCellRenderer *cell,
GtkTreeModel *tree_model,
GtkTreeIter *iter,
@@ -757,44 +679,44 @@
}
-/** \brief Select a radio in the combo box.
- * \param rigid The hamlib id of the radio.
+/** \brief Select a rotator in the combo box.
+ * \param rotid The hamlib id of the rotator.
*
- * This function selects the specified radio in the combobox. This is done
+ * This function selects the specified rotator in the combobox. This is done
* by looping over all items in the tree model until a match is reached
* (or there are no more items left).
*/
static void
-select_rig (guint rigid)
+select_rot (guint rotid)
{
GtkTreeIter iter1,iter2;
- GtkTreeModel *riglist;
+ GtkTreeModel *rotlist;
guint i,j,n,m;
- guint thisrig = 0;
+ guint thisrot = 0;
/* get the tree model */
- riglist = gtk_combo_box_get_model (GTK_COMBO_BOX (model));
+ rotlist = gtk_combo_box_get_model (GTK_COMBO_BOX (model));
/* get the number of toplevel nodes */
- n = gtk_tree_model_iter_n_children (riglist, NULL);
+ n = gtk_tree_model_iter_n_children (rotlist, NULL);
for (i = 0; i < n; i++) {
/* get the i'th toplevel node */
- if (gtk_tree_model_iter_nth_child (riglist, &iter1, NULL, i)) {
+ if (gtk_tree_model_iter_nth_child (rotlist, &iter1, NULL, i)) {
/* get the number of children */
- m = gtk_tree_model_iter_n_children (riglist, &iter1);
+ m = gtk_tree_model_iter_n_children (rotlist, &iter1);
for (j = 0; j < m; j++) {
/* get the j'th child */
- if (gtk_tree_model_iter_nth_child (riglist, &iter2, &iter1, j)) {
+ if (gtk_tree_model_iter_nth_child (rotlist, &iter2, &iter1, j)) {
/* get ID of this model */
- gtk_tree_model_get (riglist, &iter2, 1, &thisrig, -1);
+ gtk_tree_model_get (rotlist, &iter2, 1, &thisrot, -1);
- if (thisrig == rigid) {
- /* select this rig and terminate loop */
+ if (thisrot == rotid) {
+ /* select this rot and terminate loop */
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (model), &iter2);
j = m;
i = n;
Modified: trunk/src/sat-pref-rot.c
===================================================================
--- trunk/src/sat-pref-rot.c 2008-01-24 22:58:40 UTC (rev 21)
+++ trunk/src/sat-pref-rot.c 2008-01-24 23:34:50 UTC (rev 22)
@@ -27,38 +27,589 @@
*/
#include <gtk/gtk.h>
#include <glib/gi18n.h>
+#include <glib/gstdio.h>
#ifdef HAVE_CONFIG_H
# include <build-config.h>
#endif
+#include "gpredict-utils.h"
#include "sat-cfg.h"
+#include "sat-log.h"
+#include "compat.h"
+#include "rotor-conf.h"
+#include "sat-pref-rot-data.h"
+#include "sat-pref-rot-editor.h"
#include "sat-pref-rot.h"
-/** \brief Create and initialise widgets for the rotators tab.
+#ifdef HAVE_HAMLIB
+
+extern GtkWidget *window; /* dialog window defined in sat-pref.c */
+
+
+/* private function declarations */
+static void create_rot_list (void);
+static GtkTreeModel *create_and_fill_model (void);
+static GtkWidget *create_buttons (void);
+
+static void add_cb (GtkWidget *button, gpointer data);
+static void edit_cb (GtkWidget *button, gpointer data);
+static void delete_cb (GtkWidget *button, gpointer data);
+
+static void render_rot_type (GtkTreeViewColumn *col,
+ GtkCellRenderer *renderer,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer column);
+
+/* global objects */
+static GtkWidget *addbutton;
+static GtkWidget *editbutton;
+static GtkWidget *delbutton;
+static GtkWidget *rotlist;
+
+
+/** \brief Create and initialise widgets for the radios tab. */
+GtkWidget *sat_pref_rot_create ()
+{
+ GtkWidget *vbox; /* vbox containing the list part and the details part */
+ GtkWidget *swin;
+
+
+ vbox = gtk_vbox_new (FALSE, 10);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 10);
+
+ /* create rot list and pack into scrolled window */
+ create_rot_list ();
+ swin = gtk_scrolled_window_new (NULL, NULL);
+ gtk_container_add (GTK_CONTAINER (swin), rotlist);
+
+ gtk_box_pack_start (GTK_BOX (vbox), swin, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), create_buttons (), FALSE, FALSE, 0);
+
+ return vbox;
+}
+
+
+/** \brief Create Radio configuration list widget.
*
- * The widgets must be preloaded with values from config. If config
- * is NULL, sensible default values, eg. those from defaults.h should
- * be laoded.
*/
-GtkWidget *sat_pref_rot_create ()
+static void create_rot_list ()
{
- return gtk_label_new ("Rotators");
+ GtkTreeModel *model;
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+
+
+ rotlist = gtk_tree_view_new ();
+
+ model = create_and_fill_model ();
+ gtk_tree_view_set_model (GTK_TREE_VIEW (rotlist), model);
+ g_object_unref (model);
+
+ /* Conf name */
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes (_("Config Name"), renderer,
+ "text", ROT_LIST_COL_NAME,
+ NULL);
+ gtk_tree_view_insert_column (GTK_TREE_VIEW (rotlist), column, -1);
+
+ /* Model */
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes (_("Model"), renderer,
+ "text", ROT_LIST_COL_MODEL,
+ NULL);
+ gtk_tree_view_insert_column (GTK_TREE_VIEW (rotlist), column, -1);
+
+ /* Type */
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes (_("Type"), renderer,
+ "text", ROT_LIST_COL_TYPE,
+ NULL);
+ gtk_tree_view_column_set_cell_data_func (column, renderer,
+ render_rot_type,
+ GUINT_TO_POINTER(ROT_LIST_COL_TYPE),
+ NULL);
+ gtk_tree_view_insert_column (GTK_TREE_VIEW (rotlist), column, -1);
+
+ /* Port */
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes (_("Port"), renderer,
+ "text", ROT_LIST_COL_PORT,
+ NULL);
+ gtk_tree_view_insert_column (GTK_TREE_VIEW (rotlist), column, -1);
+
+ /* Speed */
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes (_("Speed"), renderer,
+ "text", ROT_LIST_COL_SPEED,
+ NULL);
+ gtk_tree_view_insert_column (GTK_TREE_VIEW (rotlist), column, -1);
+
}
+/** \brief Create data storage for rotator configuration list. */
+static GtkTreeModel *create_and_fill_model ()
+{
+ GtkListStore *liststore; /* the list store data structure */
+ GtkTreeIter item; /* new item added to the list store */
+ GDir *dir = NULL; /* directory handle */
+ GError *error = NULL; /* error flag and info */
+ gchar *cfgdir;
+ gchar *dirname; /* directory name */
+ gchar **vbuff;
+ const gchar *filename; /* file name */
+ rotor_conf_t conf;
+
+ /* create a new list store */
+ liststore = gtk_list_store_new (ROT_LIST_COL_NUM,
+ G_TYPE_STRING, // name
+ G_TYPE_STRING, // model
+ G_TYPE_INT, // hamlib id
+ G_TYPE_INT, // radio type
+ G_TYPE_STRING, // port
+ G_TYPE_INT // speed
+ );
+
+ /* open configuration directory */
+ cfgdir = get_conf_dir ();
+ dirname = g_strconcat (cfgdir, G_DIR_SEPARATOR_S,
+ "hwconf", NULL);
+ g_free (cfgdir);
+
+ dir = g_dir_open (dirname, 0, &error);
+ if (dir) {
+ /* read each .rot file */
+ while ((filename = g_dir_read_name (dir))) {
+
+ if (g_strrstr (filename, ".rot")) {
+
+ vbuff = g_strsplit (filename, ".rot", 0);
+ conf.name = g_strdup (vbuff[0]);
+ g_strfreev (vbuff);
+ if (rotor_conf_read (&conf)) {
+ /* insert conf into liststore */
+ gtk_list_store_append (liststore, &item);
+ gtk_list_store_set (liststore, &item,
+ ROT_LIST_COL_NAME, conf.name,
+ ROT_LIST_COL_MODEL, conf.model,
+ ROT_LIST_COL_ID, conf.id,
+ ROT_LIST_COL_TYPE, conf.type,
+ ROT_LIST_COL_PORT, conf.port,
+ ROT_LIST_COL_SPEED, conf.speed,
+ -1);
+
+ sat_log_log (SAT_LOG_LEVEL_DEBUG,
+ _("%s:%d: Read %s"),
+ __FILE__, __LINE__, filename);
+ /* clean up memory */
+ if (conf.name)
+ g_free (conf.name);
+
+ if (conf.model)
+ g_free (conf.model);
+
+ if (conf.port)
+ g_free (conf.port);
+ }
+ else {
+ /* there was an error */
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s:%d: Failed to read %s"),
+ __FILE__, __LINE__, conf.name);
+
+ g_free (conf.name);
+ }
+ }
+ }
+ }
+ else {
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s:%d: Failed to open hwconf dir (%s)"),
+ __FILE__, __LINE__, error->message);
+ g_clear_error (&error);
+ }
+
+ g_free (dirname);
+ g_dir_close (dir);
+
+ return GTK_TREE_MODEL (liststore);
+}
+
+
+/** \brief Create buttons.
+ * \return A button box containing the buttons.
+ *
+ * This function creates and initialises the three buttons below the rot list.
+ * The treeview widget is needed by the buttons when they are activated.
+ *
+ */
+static GtkWidget *create_buttons (void)
+{
+ GtkWidget *box;
+
+ /* add button */
+ addbutton = gpredict_hstock_button (GTK_STOCK_ADD,
+ _("Add New"),
+ _("Add a new rotator to the list"));
+ g_signal_connect (addbutton, "clicked", G_CALLBACK (add_cb), NULL);
+
+ /* edit button */
+ editbutton = gpredict_hstock_button (GTK_STOCK_EDIT,
+ _("Edit"),
+ _("Edit the currently selected rotator"));
+ g_signal_connect (editbutton, "clicked", G_CALLBACK (edit_cb), NULL);
+
+ /* delete button; don't forget to delete file.... */
+ delbutton = gpredict_hstock_button (GTK_STOCK_DELETE,
+ _("Delete"),
+ _("Delete the selected rotator"));
+ g_signal_connect (delbutton, "clicked", G_CALLBACK (delete_cb), NULL);
+
+ /* vertical button box */
+ box = gtk_hbutton_box_new ();
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (box), GTK_BUTTONBOX_START);
+
+ gtk_container_add (GTK_CONTAINER (box), addbutton);
+ gtk_container_add (GTK_CONTAINER (box), editbutton);
+ gtk_container_add (GTK_CONTAINER (box), delbutton);
+
+
+ return box;
+}
+
+
+
/** \brief User pressed cancel. Any changes to config must be cancelled.
*/
-void
-sat_pref_rot_cancel ()
+void sat_pref_rot_cancel ()
{
}
/** \brief User pressed OK. Any changes should be stored in config.
+ *
+ * First, all .rot files are deleted, whereafter the rotator configurations in
+ * the rotlist are saved one by one.
*/
-void
-sat_pref_rot_ok ()
+void sat_pref_rot_ok ()
{
+ GDir *dir = NULL; /* directory handle */
+ GError *error = NULL; /* error flag and info */
+ gchar *buff,*dirname;
+ const gchar *filename;
+ GtkTreeIter iter; /* new item added to the list store */
+ GtkTreeModel *model;
+ guint i,n;
+
+ rotor_conf_t conf = {
+ .name = NULL,
+ .model = NULL,
+ .id = 0,
+ .type = ROTOR_TYPE_AZEL,
+ .port = NULL,
+ .speed = 0,
+ };
+
+
+ /* delete all .rot files */
+ buff = get_conf_dir ();
+ dirname = g_strconcat (buff, G_DIR_SEPARATOR_S,
+ "hwconf", NULL);
+ g_free (buff);
+
+ dir = g_dir_open (dirname, 0, &error);
+ if (dir) {
+ /* read each .rot file */
+ while ((filename = g_dir_read_name (dir))) {
+
+ if (g_strrstr (filename, ".rot")) {
+
+ buff = g_strconcat (dirname, G_DIR_SEPARATOR_S, filename, NULL);
+ g_remove (buff);
+ g_free (buff);
+ }
+ }
+ }
+
+ g_free (dirname);
+ g_dir_close (dir);
+
+ /* create new .rot files for the radios in the rotlist */
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (rotlist));
+ n = gtk_tree_model_iter_n_children (model, NULL);
+ for (i = 0; i < n; i++) {
+
+ /* get radio conf */
+ if (gtk_tree_model_iter_nth_child (model, &iter, NULL, i)) {
+
+ /* store conf */
+ gtk_tree_model_get (model, &iter,
+ ROT_LIST_COL_NAME, &conf.name,
+ ROT_LIST_COL_MODEL, &conf.model,
+ ROT_LIST_COL_ID, &conf.id,
+ ROT_LIST_COL_TYPE, &conf.type,
+ ROT_LIST_COL_PORT, &conf.port,
+ ROT_LIST_COL_SPEED, &conf.speed,
+ -1);
+ rotor_conf_save (&conf);
+
+ /* free conf buffer */
+ if (conf.name)
+ g_free (conf.name);
+
+ if (conf.model)
+ g_free (conf.model);
+
+ if (conf.port)
+ g_free (conf.port);
+ }
+ else {
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: Failed to get ROT %s"),
+ __FUNCTION__, i);
+ }
+ }
+
}
+/** \brief Add a new rotor configuration
+ * \param button Pointer to the Add button.
+ * \param data User data (null).
+ *
+ * This function executes the rotor configuration editor.
+ */
+static void add_cb (GtkWidget *button, gpointer data)
+{
+ GtkTreeIter item; /* new item added to the list store */
+ GtkListStore *liststore;
+
+ rotor_conf_t conf = {
+ .name = NULL,
+ .model = NULL,
+ .id = 0,
+ .type = ROTOR_TYPE_AZEL,
+ .port = NULL,
+ .speed = 0,
+ };
+
+ /* run rot conf editor */
+ sat_pref_rot_editor_run (&conf);
+
+ /* add new rot to the list */
+ if (conf.name != NULL) {
+ liststore = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (rotlist)));
+ gtk_list_store_append (liststore, &item);
+ gtk_list_store_set (liststore, &item,
+ ROT_LIST_COL_NAME, conf.name,
+ ROT_LIST_COL_MODEL, conf.model,
+ ROT_LIST_COL_ID, conf.id,
+ ROT_LIST_COL_TYPE, conf.type,
+ ROT_LIST_COL_PORT, conf.port,
+ ROT_LIST_COL_SPEED, conf.speed,
+ -1);
+
+ g_free (conf.name);
+
+ if (conf.model != NULL)
+ g_free (conf.model);
+
+ if (conf.port != NULL)
+ g_free (conf.port);
+ }
+}
+
+
+/** \brief Add a new rotor configuration
+ * \param button Pointer to the Add button.
+ * \param data User data (null).
+ *
+ * This function executes the rotor configuration editor.
+ *
+ */
+static void edit_cb (GtkWidget *button, gpointer data)
+{
+ GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW(rotlist));
+ GtkTreeModel *selmod;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+
+ rotor_conf_t conf = {
+ .name = NULL,
+ .model = NULL,
+ .id = 0,
+ .type = ROTOR_TYPE_AZEL,
+ .port = NULL,
+ .speed = 0,
+ };
+
+
+ /* If there are no entries, we have a bug since the button should
+ have been disabled. */
+ if (gtk_tree_model_iter_n_children (model, NULL) < 1) {
+
+ sat_log_log (SAT_LOG_LEVEL_BUG,
+ _("%s:%s: Edit button should have been disabled."),
+ __FILE__, __FUNCTION__);
+ //gtk_widget_set_sensitive (button, FALSE);
+
+ return;
+ }
+
+ /* get selected row
+ FIXME: do we really need to work with two models?
+ */
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (rotlist));
+ if (gtk_tree_selection_get_selected(selection, &selmod, &iter)) {
+ gtk_tree_model_get (model, &iter,
+ ROT_LIST_COL_NAME, &conf.name,
+ ROT_LIST_COL_MODEL, &conf.model,
+ ROT_LIST_COL_ID, &conf.id,
+ ROT_LIST_COL_TYPE, &conf.type,
+ ROT_LIST_COL_PORT, &conf.port,
+ ROT_LIST_COL_SPEED, &conf.speed,
+ -1);
+
+ }
+ else {
+ GtkWidget *dialog;
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_MODAL |
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Select the rotator you want to edit\n"\
+ "and try again!"));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ return;
+ }
+
+ /* run radio configuration editor */
+ sat_pref_rot_editor_run (&conf);
+
+ /* apply changes */
+ if (conf.name != NULL) {
+ gtk_list_store_set (GTK_LIST_STORE(model), &iter,
+ ROT_LIST_COL_NAME, conf.name,
+ ROT_LIST_COL_MODEL, conf.model,
+ ROT_LIST_COL_ID, conf.id,
+ ROT_LIST_COL_TYPE, conf.type,
+ ROT_LIST_COL_PORT, conf.port,
+ ROT_LIST_COL_SPEED, conf.speed,
+ -1);
+
+ }
+
+ /* clean up memory */
+ if (conf.name)
+ g_free (conf.name);
+
+ if (conf.model != NULL)
+ g_free (conf.model);
+
+ if (conf.port != NULL)
+ g_free (conf.port);
+
+}
+
+
+/** \brief Delete selected rotator configuration
+ *
+ * This function is called when the user clicks the Delete button.
+ *
+ */
+static void delete_cb (GtkWidget *button, gpointer data)
+{
+ GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW(rotlist));
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+
+
+ /* If there are no entries, we have a bug since the button should
+ have been disabled. */
+ if (gtk_tree_model_iter_n_children (model, NULL) < 1) {
+
+ sat_log_log (SAT_LOG_LEVEL_BUG,
+ _("%s:%s: Delete button should have been disabled."),
+ __FILE__, __FUNCTION__);
+ //gtk_widget_set_sensitive (button, FALSE);
+
+ return;
+ }
+
+ /* get selected row */
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (rotlist));
+ if (gtk_tree_selection_get_selected(selection, NULL, &iter)) {
+ gtk_list_store_remove (GTK_LIST_STORE(model), &iter);
+ }
+ else {
+ GtkWidget *dialog;
+ dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+ GTK_DIALOG_MODAL |
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_OK,
+ _("Select the rotator you want to delete\n"\
+ "and try again!"));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+
+ }
+}
+
+
+
+
+
+/** \brief Render rotator type.
+ * \param col Pointer to the tree view column.
+ * \param renderer Pointer to the renderer.
+ * \param model Pointer to the tree model.
+ * \param iter Pointer to the tree iterator.
+ * \param column The column number in the model.
+ *
+ * This function renders the rotator type onto the rotator list.
+ * The rotator type is stored as enum; however, we want to display it
+ * using some escriptive text, e.g. "AZ", "EL", and so on
+ */
+static void render_rot_type (GtkTreeViewColumn *col,
+ GtkCellRenderer *renderer,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer column)
+{
+ guint number;
+ guint coli = GPOINTER_TO_UINT (column);
+
+ gtk_tree_model_get (model, iter, coli, &number, -1);
+
+ switch (number) {
+
+ case ROTOR_TYPE_AZ:
+ g_object_set (renderer, "text", "AZ", NULL);
+ break;
+
+ case ROTOR_TYPE_EL:
+ g_object_set (renderer, "text", "EL", NULL);
+ break;
+
+ case ROTOR_TYPE_AZEL:
+ g_object_set (renderer, "text", "AZ/EL", NULL);
+ break;
+
+ default:
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s:%s: Invalid type: %d. Using AZ."),
+ __FILE__, __FUNCTION__, number);
+ g_object_set (renderer, "text", "AZ", NULL);
+ break;
+
+ }
+
+}
+
+
+#endif
Modified: trunk/src/sat-pref-rot.h
===================================================================
--- trunk/src/sat-pref-rot.h 2008-01-24 22:58:40 UTC (rev 21)
+++ trunk/src/sat-pref-rot.h 2008-01-24 23:34:50 UTC (rev 22)
@@ -28,10 +28,10 @@
#ifndef SAT_PREF_ROT_H
#define SAT_PREF_ROT_H 1
-
+#ifdef HAVE_HAMLIB
GtkWidget *sat_pref_rot_create (void);
void sat_pref_rot_cancel (void);
void sat_pref_rot_ok (void);
+#endif
-
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|