diff options
author | Guido Günther <agx@sigxcpu.org> | 2014-08-06 21:12:27 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2014-08-06 21:12:27 +0200 |
commit | cb38bceaa0541601d4c4083fe2d61b1817e333eb (patch) | |
tree | 5feee28ca19dd45892606d39802f06887fe8f7c3 | |
parent | f04c4a269882f16664e297736a41c745e7fba14d (diff) |
Add color to the delay columns
-rw-r--r-- | src/tripview.ui | 8 | ||||
-rw-r--r-- | src/uplanfahrtripview.c | 14 |
2 files changed, 18 insertions, 4 deletions
diff --git a/src/tripview.ui b/src/tripview.ui index f4542ec..69a7b6d 100644 --- a/src/tripview.ui +++ b/src/tripview.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.16.1 --> +<!-- Generated with glade 3.18.3 --> <interface> <requires lib="gtk+" version="3.10"/> <object class="GtkListStore" id="liststore"> @@ -18,6 +18,10 @@ <column type="gchararray"/> <!-- column-name arrival_delay --> <column type="gchararray"/> + <!-- column-name departure_delay_color --> + <column type="gchararray"/> + <!-- column-name arrival_delay_color --> + <column type="gchararray"/> </columns> </object> <template class="UPlanFahrTripView" parent="GtkTreeView"> @@ -48,6 +52,7 @@ <child> <object class="GtkCellRendererText" id="cr_departure_delay"/> <attributes> + <attribute name="foreground">7</attribute> <attribute name="markup">5</attribute> </attributes> </child> @@ -72,6 +77,7 @@ <child> <object class="GtkCellRendererText" id="cr_arrivaL_delay"/> <attributes> + <attribute name="foreground">8</attribute> <attribute name="markup">6</attribute> </attributes> </child> diff --git a/src/uplanfahrtripview.c b/src/uplanfahrtripview.c index d36673a..7e6306b 100644 --- a/src/uplanfahrtripview.c +++ b/src/uplanfahrtripview.c @@ -12,6 +12,8 @@ #define COL_PARTS 4 #define COL_DEPARTURE_DELAY 5 #define COL_ARRIVAL_DELAY 6 +#define COL_DEPARTURE_DELAY_COLOR 7 +#define COL_ARRIVAL_DELAY_COLOR 8 struct _UPlanFahrTripView { @@ -61,17 +63,20 @@ u_plan_fahr_trip_view_new (void) } static gchar * -delay_str (GDateTime *dt, gint delay) +delay_str (GDateTime *dt, gint delay, const gchar **delay_color) { gchar sign, *str = NULL; if (dt) { if (delay > 0) { sign = '+'; + *delay_color = "red"; } else if (delay < 0) { sign = '-'; + *delay_color = "red"; } else { sign = ' '; + *delay_color = "green"; } str = g_strdup_printf("%c%d", sign, delay); } @@ -91,6 +96,7 @@ u_plan_fahr_trip_view_store_trips (UPlanFahrTripView *self, GSList *trips) LpfStop *start, *end; GDateTime *arrival, *departure, *rt_departure, *rt_arrival; gchar *deptime, *arrtime, *dep_delay, *arr_delay; + const gchar *dep_delay_color = NULL, *arr_delay_color = NULL; gint ddelay, adelay; priv = u_plan_fahr_trip_view_get_instance_private (U_PLAN_FAHR_TRIP_VIEW (self)); @@ -119,8 +125,8 @@ u_plan_fahr_trip_view_store_trips (UPlanFahrTripView *self, GSList *trips) NULL); arrtime = g_date_time_format (arrival, "%H:%M"); - dep_delay = delay_str (rt_departure, ddelay); - arr_delay = delay_str (rt_arrival, adelay); + dep_delay = delay_str (rt_departure, ddelay, &dep_delay_color); + arr_delay = delay_str (rt_arrival, adelay, &arr_delay_color); gtk_list_store_append (priv->liststore, &iter); gtk_list_store_set (priv->liststore, &iter, @@ -131,6 +137,8 @@ u_plan_fahr_trip_view_store_trips (UPlanFahrTripView *self, GSList *trips) COL_PARTS, g_slist_length(parts) - 1, COL_DEPARTURE_DELAY, dep_delay, COL_ARRIVAL_DELAY, arr_delay, + COL_DEPARTURE_DELAY_COLOR, dep_delay_color, + COL_ARRIVAL_DELAY_COLOR, arr_delay_color, -1); g_date_time_unref (departure); |