Skip to content

Commit

Permalink
Add operational status to the list view
Browse files Browse the repository at this point in the history
Closes #132
  • Loading branch information
jasonuher authored and csete committed Oct 17, 2018
1 parent 162fbce commit 837cfca
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 3 deletions.
75 changes: 73 additions & 2 deletions src/gtk-sat-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const gchar *SAT_LIST_COL_TITLE[SAT_LIST_COL_NUMBER] = {
N_("Orbit"),
N_("Vis"),
N_("Decayed"),
N_("Status"),
N_("BOLD") /* should never be seen */
};

Expand Down Expand Up @@ -105,6 +106,7 @@ const gchar *SAT_LIST_COL_HINT[SAT_LIST_COL_NUMBER] = {
N_("Orbit Number"),
N_("Visibility"),
N_("Decayed"),
N_("Operational Status"),
N_("---")
};

Expand Down Expand Up @@ -134,6 +136,7 @@ const gfloat SAT_LIST_COL_XALIGN[SAT_LIST_COL_NUMBER] = {
0.0, // phase
1.0, // orbit
0.5, // visibility
0.0, // Operational Status
};

static void gtk_sat_list_class_init(GtkSatListClass * class);
Expand Down Expand Up @@ -184,11 +187,20 @@ static void two_dec_cell_data_function(GtkTreeViewColumn * col,
GtkTreeIter * iter,
gpointer column);


static void operational_status_cell_data_function(GtkTreeViewColumn * col,
GtkCellRenderer * renderer,
GtkTreeModel * model,
GtkTreeIter * iter,
gpointer column);


static void event_cell_data_function(GtkTreeViewColumn * col,
GtkCellRenderer * renderer,
GtkTreeModel * model,
GtkTreeIter * iter, gpointer column);


static gint event_cell_compare_function(GtkTreeModel * model,
GtkTreeIter * a, GtkTreeIter * b,
gpointer user_data);
Expand Down Expand Up @@ -440,6 +452,7 @@ static GtkTreeModel *create_and_fill_model(GHashTable * sats)
G_TYPE_LONG, // orbit
G_TYPE_STRING, // visibility
G_TYPE_BOOLEAN, // decay
G_TYPE_INT, // Operational Status
G_TYPE_INT // weight/bold
);

Expand Down Expand Up @@ -485,8 +498,9 @@ static void sat_list_add_satellites(gpointer key, gpointer value,
SAT_LIST_COL_DELAY, 0.0,
SAT_LIST_COL_MA, sat->ma,
SAT_LIST_COL_PHASE, sat->phase,
SAT_LIST_COL_ORBIT, sat->orbit, SAT_LIST_COL_DECAY,
!decayed(sat), -1);
SAT_LIST_COL_ORBIT, sat->orbit,
SAT_LIST_COL_STAT_OPERATIONAL, (char *) sat->tle.status,
SAT_LIST_COL_DECAY, !decayed(sat), -1);
}

/** Update satellites */
Expand Down Expand Up @@ -856,12 +870,69 @@ static void check_and_set_cell_renderer(GtkTreeViewColumn * column,
event_cell_data_function,
GUINT_TO_POINTER(i), NULL);
break;

case SAT_LIST_COL_STAT_OPERATIONAL:
gtk_tree_view_column_set_cell_data_func(column,
renderer,
operational_status_cell_data_function,
GUINT_TO_POINTER(i), NULL);
break;


default:
break;
}
}

/* Render column containing the operational status */
static void operational_status_cell_data_function(GtkTreeViewColumn * col,
GtkCellRenderer * renderer,
GtkTreeModel * model,
GtkTreeIter * iter,
gpointer column)
{
gint number;
guint coli = GPOINTER_TO_UINT(column);

(void)col; /* avoid unusued parameter compiler warning */

gtk_tree_model_get(model, iter, coli, &number, -1);

switch (number)
{

case OP_STAT_OPERATIONAL:
g_object_set(renderer, "text", "Operational", NULL);
break;

case OP_STAT_NONOP:
g_object_set(renderer, "text", "Non-operational", NULL);
break;

case OP_STAT_PARTIAL:
g_object_set(renderer, "text", "Partially operational", NULL);
break;

case OP_STAT_STDBY:
g_object_set(renderer, "text", "Backup/Standby", NULL);
break;

case OP_STAT_SPARE:
g_object_set(renderer, "text", "Spare", NULL);
break;

case OP_STAT_EXTENDED:
g_object_set(renderer, "text", "Extended Mission", NULL);
break;

default:
g_object_set(renderer, "text", "Unknown", NULL);
break;

}

}

/* Render column containg lat/lon
by using this instead of the default data function, we can
control the number of decimals and display the coordinates in a
Expand Down
4 changes: 3 additions & 1 deletion src/gtk-sat-list.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ typedef enum {
SAT_LIST_COL_ORBIT, /*!< Orbit Number. */
SAT_LIST_COL_VISIBILITY, /*!< Visibility. */
SAT_LIST_COL_DECAY, /*!< Whether the satellite is decayed or not. */
SAT_LIST_COL_STAT_OPERATIONAL, /*!< Operational Status . */
SAT_LIST_COL_BOLD, /*!< Used to render the satellites above the horizon bold. */
SAT_LIST_COL_NUMBER
} sat_list_col_t;
Expand Down Expand Up @@ -134,7 +135,8 @@ typedef enum {
SAT_LIST_FLAG_PHASE = 1 << SAT_LIST_COL_PHASE, /*!< Phase. */
SAT_LIST_FLAG_ORBIT = 1 << SAT_LIST_COL_ORBIT, /*!< Orbit Number. */
SAT_LIST_FLAG_VISIBILITY = 1 << SAT_LIST_COL_VISIBILITY, /*!< Visibility. */
SAT_LIST_FLAG_DECAY = 1 << SAT_LIST_COL_DECAY /*!< Decayed. */
SAT_LIST_FLAG_STAT_OPERATIONAL = 1 << SAT_LIST_COL_STAT_OPERATIONAL, /*!< Operational Status . */
SAT_LIST_FLAG_DECAY = 1 << SAT_LIST_COL_DECAY /*!< Decayed. */
} sat_list_flag_t;

GType gtk_sat_list_get_type(void);
Expand Down

0 comments on commit 837cfca

Please sign in to comment.