Skip to content

Commit 837cfca

Browse files
jasonuhercsete
authored andcommitted
Add operational status to the list view
Closes #132
1 parent 162fbce commit 837cfca

2 files changed

Lines changed: 76 additions & 3 deletions

File tree

src/gtk-sat-list.c

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const gchar *SAT_LIST_COL_TITLE[SAT_LIST_COL_NUMBER] = {
7373
N_("Orbit"),
7474
N_("Vis"),
7575
N_("Decayed"),
76+
N_("Status"),
7677
N_("BOLD") /* should never be seen */
7778
};
7879

@@ -105,6 +106,7 @@ const gchar *SAT_LIST_COL_HINT[SAT_LIST_COL_NUMBER] = {
105106
N_("Orbit Number"),
106107
N_("Visibility"),
107108
N_("Decayed"),
109+
N_("Operational Status"),
108110
N_("---")
109111
};
110112

@@ -134,6 +136,7 @@ const gfloat SAT_LIST_COL_XALIGN[SAT_LIST_COL_NUMBER] = {
134136
0.0, // phase
135137
1.0, // orbit
136138
0.5, // visibility
139+
0.0, // Operational Status
137140
};
138141

139142
static void gtk_sat_list_class_init(GtkSatListClass * class);
@@ -184,11 +187,20 @@ static void two_dec_cell_data_function(GtkTreeViewColumn * col,
184187
GtkTreeIter * iter,
185188
gpointer column);
186189

190+
191+
static void operational_status_cell_data_function(GtkTreeViewColumn * col,
192+
GtkCellRenderer * renderer,
193+
GtkTreeModel * model,
194+
GtkTreeIter * iter,
195+
gpointer column);
196+
197+
187198
static void event_cell_data_function(GtkTreeViewColumn * col,
188199
GtkCellRenderer * renderer,
189200
GtkTreeModel * model,
190201
GtkTreeIter * iter, gpointer column);
191202

203+
192204
static gint event_cell_compare_function(GtkTreeModel * model,
193205
GtkTreeIter * a, GtkTreeIter * b,
194206
gpointer user_data);
@@ -440,6 +452,7 @@ static GtkTreeModel *create_and_fill_model(GHashTable * sats)
440452
G_TYPE_LONG, // orbit
441453
G_TYPE_STRING, // visibility
442454
G_TYPE_BOOLEAN, // decay
455+
G_TYPE_INT, // Operational Status
443456
G_TYPE_INT // weight/bold
444457
);
445458

@@ -485,8 +498,9 @@ static void sat_list_add_satellites(gpointer key, gpointer value,
485498
SAT_LIST_COL_DELAY, 0.0,
486499
SAT_LIST_COL_MA, sat->ma,
487500
SAT_LIST_COL_PHASE, sat->phase,
488-
SAT_LIST_COL_ORBIT, sat->orbit, SAT_LIST_COL_DECAY,
489-
!decayed(sat), -1);
501+
SAT_LIST_COL_ORBIT, sat->orbit,
502+
SAT_LIST_COL_STAT_OPERATIONAL, (char *) sat->tle.status,
503+
SAT_LIST_COL_DECAY, !decayed(sat), -1);
490504
}
491505

492506
/** Update satellites */
@@ -856,12 +870,69 @@ static void check_and_set_cell_renderer(GtkTreeViewColumn * column,
856870
event_cell_data_function,
857871
GUINT_TO_POINTER(i), NULL);
858872
break;
873+
874+
case SAT_LIST_COL_STAT_OPERATIONAL:
875+
gtk_tree_view_column_set_cell_data_func(column,
876+
renderer,
877+
operational_status_cell_data_function,
878+
GUINT_TO_POINTER(i), NULL);
879+
break;
880+
859881

860882
default:
861883
break;
862884
}
863885
}
864886

887+
/* Render column containing the operational status */
888+
static void operational_status_cell_data_function(GtkTreeViewColumn * col,
889+
GtkCellRenderer * renderer,
890+
GtkTreeModel * model,
891+
GtkTreeIter * iter,
892+
gpointer column)
893+
{
894+
gint number;
895+
guint coli = GPOINTER_TO_UINT(column);
896+
897+
(void)col; /* avoid unusued parameter compiler warning */
898+
899+
gtk_tree_model_get(model, iter, coli, &number, -1);
900+
901+
switch (number)
902+
{
903+
904+
case OP_STAT_OPERATIONAL:
905+
g_object_set(renderer, "text", "Operational", NULL);
906+
break;
907+
908+
case OP_STAT_NONOP:
909+
g_object_set(renderer, "text", "Non-operational", NULL);
910+
break;
911+
912+
case OP_STAT_PARTIAL:
913+
g_object_set(renderer, "text", "Partially operational", NULL);
914+
break;
915+
916+
case OP_STAT_STDBY:
917+
g_object_set(renderer, "text", "Backup/Standby", NULL);
918+
break;
919+
920+
case OP_STAT_SPARE:
921+
g_object_set(renderer, "text", "Spare", NULL);
922+
break;
923+
924+
case OP_STAT_EXTENDED:
925+
g_object_set(renderer, "text", "Extended Mission", NULL);
926+
break;
927+
928+
default:
929+
g_object_set(renderer, "text", "Unknown", NULL);
930+
break;
931+
932+
}
933+
934+
}
935+
865936
/* Render column containg lat/lon
866937
by using this instead of the default data function, we can
867938
control the number of decimals and display the coordinates in a

src/gtk-sat-list.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ typedef enum {
103103
SAT_LIST_COL_ORBIT, /*!< Orbit Number. */
104104
SAT_LIST_COL_VISIBILITY, /*!< Visibility. */
105105
SAT_LIST_COL_DECAY, /*!< Whether the satellite is decayed or not. */
106+
SAT_LIST_COL_STAT_OPERATIONAL, /*!< Operational Status . */
106107
SAT_LIST_COL_BOLD, /*!< Used to render the satellites above the horizon bold. */
107108
SAT_LIST_COL_NUMBER
108109
} sat_list_col_t;
@@ -134,7 +135,8 @@ typedef enum {
134135
SAT_LIST_FLAG_PHASE = 1 << SAT_LIST_COL_PHASE, /*!< Phase. */
135136
SAT_LIST_FLAG_ORBIT = 1 << SAT_LIST_COL_ORBIT, /*!< Orbit Number. */
136137
SAT_LIST_FLAG_VISIBILITY = 1 << SAT_LIST_COL_VISIBILITY, /*!< Visibility. */
137-
SAT_LIST_FLAG_DECAY = 1 << SAT_LIST_COL_DECAY /*!< Decayed. */
138+
SAT_LIST_FLAG_STAT_OPERATIONAL = 1 << SAT_LIST_COL_STAT_OPERATIONAL, /*!< Operational Status . */
139+
SAT_LIST_FLAG_DECAY = 1 << SAT_LIST_COL_DECAY /*!< Decayed. */
138140
} sat_list_flag_t;
139141

140142
GType gtk_sat_list_get_type(void);

0 commit comments

Comments
 (0)