X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/0d2b891f5f4673f0dd1142dcd7e1eb08e4248090..7f0d159195c28709c5f7f3a2e7658b4babcb9972:/src/viktrwlayer_propwin.c
diff --git a/src/viktrwlayer_propwin.c b/src/viktrwlayer_propwin.c
index 78fca4d9..78ce8066 100644
--- a/src/viktrwlayer_propwin.c
+++ b/src/viktrwlayer_propwin.c
@@ -100,6 +100,7 @@ typedef struct _propwidgets {
gboolean configure_dialog;
VikTrwLayer *vtl;
VikTrack *tr;
+ gpointer trk_id;
VikViewport *vvp;
VikLayersPanel *vlp;
gint profile_width;
@@ -124,6 +125,7 @@ typedef struct _propwidgets {
GtkWidget *w_time_start;
GtkWidget *w_time_end;
GtkWidget *w_time_dur;
+ GtkWidget *w_color;
GtkWidget *w_cur_dist; /*< Current distance */
GtkWidget *w_cur_elevation;
GtkWidget *w_cur_gradient_dist; /*< Current distance on gradient graph */
@@ -380,7 +382,7 @@ static VikTrackpoint *set_center_at_graph_position(gdouble event_x,
/* since vlp not set, vvp should be valid instead! */
if ( vvp )
vik_viewport_set_center_coord ( vvp, &coord );
- vik_layer_emit_update ( VIK_LAYER(vtl), FALSE );
+ vik_layer_emit_update ( VIK_LAYER(vtl) );
}
}
return trackpoint;
@@ -554,7 +556,7 @@ static void track_graph_click( GtkWidget *event_box, GdkEventButton *event, Prop
gdouble marker_x = (pc * widgets->profile_width) + MARGIN;
save_image_and_draw_graph_marks(image,
marker_x,
- window->style->black_gc,
+ gtk_widget_get_style(window)->black_gc,
-1, // Don't draw blob on clicks
0,
graph_saved_img,
@@ -762,7 +764,7 @@ void track_profile_move( GtkWidget *event_box, GdkEventMotion *event, PropWidget
save_image_and_draw_graph_marks (image,
marker_x,
- window->style->black_gc,
+ gtk_widget_get_style(window)->black_gc,
MARGIN+x,
y_blob,
&widgets->elev_graph_saved_img,
@@ -839,7 +841,7 @@ void track_gradient_move( GtkWidget *event_box, GdkEventMotion *event, PropWidge
save_image_and_draw_graph_marks (image,
marker_x,
- window->style->black_gc,
+ gtk_widget_get_style(window)->black_gc,
MARGIN+x,
y_blob,
&widgets->gradient_graph_saved_img,
@@ -930,7 +932,7 @@ void track_vt_move( GtkWidget *event_box, GdkEventMotion *event, PropWidgets *wi
save_image_and_draw_graph_marks (image,
marker_x,
- window->style->black_gc,
+ gtk_widget_get_style(window)->black_gc,
MARGIN+x,
y_blob,
&widgets->speed_graph_saved_img,
@@ -1009,7 +1011,7 @@ void track_dt_move( GtkWidget *event_box, GdkEventMotion *event, PropWidgets *wi
save_image_and_draw_graph_marks (image,
marker_x,
- window->style->black_gc,
+ gtk_widget_get_style(window)->black_gc,
MARGIN+x,
y_blob,
&widgets->dist_graph_saved_img,
@@ -1088,7 +1090,7 @@ void track_et_move( GtkWidget *event_box, GdkEventMotion *event, PropWidgets *wi
save_image_and_draw_graph_marks (image,
marker_x,
- window->style->black_gc,
+ gtk_widget_get_style(window)->black_gc,
MARGIN+x,
y_blob,
&widgets->elev_time_graph_saved_img,
@@ -1184,7 +1186,7 @@ void track_sd_move( GtkWidget *event_box, GdkEventMotion *event, PropWidgets *wi
save_image_and_draw_graph_marks (image,
marker_x,
- window->style->black_gc,
+ gtk_widget_get_style(window)->black_gc,
MARGIN+x,
y_blob,
&widgets->speed_dist_graph_saved_img,
@@ -1294,18 +1296,18 @@ static void draw_elevations (GtkWidget *image, VikTrack *tr, PropWidgets *widget
window = gtk_widget_get_toplevel (widgets->elev_box);
- pix = gdk_pixmap_new( window->window, widgets->profile_width + MARGIN, widgets->profile_height, -1 );
+ pix = gdk_pixmap_new( gtk_widget_get_window(window), widgets->profile_width + MARGIN, widgets->profile_height, -1 );
gtk_image_set_from_pixmap ( GTK_IMAGE(image), pix, NULL );
- no_alt_info = gdk_gc_new ( window->window );
+ no_alt_info = gdk_gc_new ( gtk_widget_get_window(window) );
gdk_color_parse ( "yellow", &color );
gdk_gc_set_rgb_fg_color ( no_alt_info, &color);
/* clear the image */
- gdk_draw_rectangle(GDK_DRAWABLE(pix), window->style->bg_gc[0],
+ gdk_draw_rectangle(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->bg_gc[0],
TRUE, 0, 0, MARGIN, widgets->profile_height);
- gdk_draw_rectangle(GDK_DRAWABLE(pix), window->style->mid_gc[0],
+ gdk_draw_rectangle(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->mid_gc[0],
TRUE, MARGIN, 0, widgets->profile_width, widgets->profile_height);
/* draw grid */
@@ -1315,7 +1317,7 @@ static void draw_elevations (GtkWidget *image, VikTrack *tr, PropWidgets *widget
int w, h;
pango_layout_set_alignment (pl, PANGO_ALIGN_RIGHT);
- pango_layout_set_font_description (pl, window->style->font_desc);
+ pango_layout_set_font_description (pl, gtk_widget_get_style(window)->font_desc);
switch (height_units) {
case VIK_UNITS_HEIGHT_METRES:
@@ -1331,10 +1333,10 @@ static void draw_elevations (GtkWidget *image, VikTrack *tr, PropWidgets *widget
}
pango_layout_set_text(pl, s, -1);
pango_layout_get_pixel_size (pl, &w, &h);
- gdk_draw_layout(GDK_DRAWABLE(pix), window->style->fg_gc[0], MARGIN-w-3,
+ gdk_draw_layout(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->fg_gc[0], MARGIN-w-3,
CLAMP((int)i*widgets->profile_height/LINES - h/2, 0, widgets->profile_height-h), pl);
- gdk_draw_line (GDK_DRAWABLE(pix), window->style->dark_gc[0],
+ gdk_draw_line (GDK_DRAWABLE(pix), gtk_widget_get_style(window)->dark_gc[0],
MARGIN, widgets->profile_height/LINES * i, MARGIN + widgets->profile_width, widgets->profile_height/LINES * i);
g_object_unref ( G_OBJECT ( pl ) );
pl = NULL;
@@ -1346,14 +1348,14 @@ static void draw_elevations (GtkWidget *image, VikTrack *tr, PropWidgets *widget
gdk_draw_line ( GDK_DRAWABLE(pix), no_alt_info,
i + MARGIN, 0, i + MARGIN, widgets->profile_height );
else
- gdk_draw_line ( GDK_DRAWABLE(pix), window->style->dark_gc[3],
+ gdk_draw_line ( GDK_DRAWABLE(pix), gtk_widget_get_style(window)->dark_gc[3],
i + MARGIN, widgets->profile_height, i + MARGIN, widgets->profile_height-widgets->profile_height*(widgets->altitudes[i]-mina)/(chunksa[widgets->cia]*LINES) );
if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widgets->w_show_dem)) ||
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widgets->w_show_alt_gps_speed)) ) {
- GdkGC *dem_alt_gc = gdk_gc_new ( window->window );
- GdkGC *gps_speed_gc = gdk_gc_new ( window->window );
+ GdkGC *dem_alt_gc = gdk_gc_new ( gtk_widget_get_window(window) );
+ GdkGC *gps_speed_gc = gdk_gc_new ( gtk_widget_get_window(window) );
gdk_color_parse ( "green", &color );
gdk_gc_set_rgb_fg_color ( dem_alt_gc, &color);
@@ -1384,7 +1386,7 @@ static void draw_elevations (GtkWidget *image, VikTrack *tr, PropWidgets *widget
}
/* draw border */
- gdk_draw_rectangle(GDK_DRAWABLE(pix), window->style->black_gc, FALSE, MARGIN, 0, widgets->profile_width-1, widgets->profile_height-1);
+ gdk_draw_rectangle(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->black_gc, FALSE, MARGIN, 0, widgets->profile_width-1, widgets->profile_height-1);
g_object_unref ( G_OBJECT(pix) );
g_object_unref ( G_OBJECT(no_alt_info) );
@@ -1457,14 +1459,14 @@ static void draw_gradients (GtkWidget *image, VikTrack *tr, PropWidgets *widgets
window = gtk_widget_get_toplevel (widgets->gradient_box);
- pix = gdk_pixmap_new( window->window, widgets->profile_width + MARGIN, widgets->profile_height, -1 );
+ pix = gdk_pixmap_new( gtk_widget_get_window(window), widgets->profile_width + MARGIN, widgets->profile_height, -1 );
gtk_image_set_from_pixmap ( GTK_IMAGE(image), pix, NULL );
/* clear the image */
- gdk_draw_rectangle(GDK_DRAWABLE(pix), window->style->bg_gc[0],
+ gdk_draw_rectangle(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->bg_gc[0],
TRUE, 0, 0, MARGIN, widgets->profile_height);
- gdk_draw_rectangle(GDK_DRAWABLE(pix), window->style->mid_gc[0],
+ gdk_draw_rectangle(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->mid_gc[0],
TRUE, MARGIN, 0, widgets->profile_width, widgets->profile_height);
/* draw grid */
@@ -1474,15 +1476,15 @@ static void draw_gradients (GtkWidget *image, VikTrack *tr, PropWidgets *widgets
int w, h;
pango_layout_set_alignment (pl, PANGO_ALIGN_RIGHT);
- pango_layout_set_font_description (pl, window->style->font_desc);
+ pango_layout_set_font_description (pl, gtk_widget_get_style(window)->font_desc);
sprintf(s, "%8d%%", (int)(mina + (LINES-i)*chunksg[widgets->cig]));
pango_layout_set_text(pl, s, -1);
pango_layout_get_pixel_size (pl, &w, &h);
- gdk_draw_layout(GDK_DRAWABLE(pix), window->style->fg_gc[0], MARGIN-w-3,
+ gdk_draw_layout(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->fg_gc[0], MARGIN-w-3,
CLAMP((int)i*widgets->profile_height/LINES - h/2, 0, widgets->profile_height-h), pl);
- gdk_draw_line (GDK_DRAWABLE(pix), window->style->dark_gc[0],
+ gdk_draw_line (GDK_DRAWABLE(pix), gtk_widget_get_style(window)->dark_gc[0],
MARGIN, widgets->profile_height/LINES * i, MARGIN + widgets->profile_width, widgets->profile_height/LINES * i);
g_object_unref ( G_OBJECT ( pl ) );
pl = NULL;
@@ -1490,11 +1492,11 @@ static void draw_gradients (GtkWidget *image, VikTrack *tr, PropWidgets *widgets
/* draw gradients */
for ( i = 0; i < widgets->profile_width; i++ )
- gdk_draw_line ( GDK_DRAWABLE(pix), window->style->dark_gc[3],
+ gdk_draw_line ( GDK_DRAWABLE(pix), gtk_widget_get_style(window)->dark_gc[3],
i + MARGIN, widgets->profile_height, i + MARGIN, widgets->profile_height-widgets->profile_height*(widgets->gradients[i]-mina)/(chunksg[widgets->cig]*LINES) );
if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widgets->w_show_gradient_gps_speed)) ) {
- GdkGC *gps_speed_gc = gdk_gc_new ( window->window );
+ GdkGC *gps_speed_gc = gdk_gc_new ( gtk_widget_get_window(window) );
gdk_color_parse ( "red", &color );
gdk_gc_set_rgb_fg_color ( gps_speed_gc, &color);
@@ -1516,7 +1518,7 @@ static void draw_gradients (GtkWidget *image, VikTrack *tr, PropWidgets *widgets
}
/* draw border */
- gdk_draw_rectangle(GDK_DRAWABLE(pix), window->style->black_gc, FALSE, MARGIN, 0, widgets->profile_width-1, widgets->profile_height-1);
+ gdk_draw_rectangle(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->black_gc, FALSE, MARGIN, 0, widgets->profile_width-1, widgets->profile_height-1);
g_object_unref ( G_OBJECT(pix) );
}
@@ -1565,7 +1567,7 @@ static void draw_vt ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets)
window = gtk_widget_get_toplevel (widgets->speed_box);
- pix = gdk_pixmap_new( window->window, widgets->profile_width + MARGIN, widgets->profile_height, -1 );
+ pix = gdk_pixmap_new( gtk_widget_get_window(window), widgets->profile_width + MARGIN, widgets->profile_height, -1 );
gtk_image_set_from_pixmap ( GTK_IMAGE(image), pix, NULL );
@@ -1580,9 +1582,9 @@ static void draw_vt ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets)
mins = widgets->draw_min_speed;
/* clear the image */
- gdk_draw_rectangle(GDK_DRAWABLE(pix), window->style->bg_gc[0],
+ gdk_draw_rectangle(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->bg_gc[0],
TRUE, 0, 0, MARGIN, widgets->profile_height);
- gdk_draw_rectangle(GDK_DRAWABLE(pix), window->style->mid_gc[0],
+ gdk_draw_rectangle(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->mid_gc[0],
TRUE, MARGIN, 0, widgets->profile_width, widgets->profile_height);
/* draw grid */
@@ -1592,7 +1594,7 @@ static void draw_vt ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets)
int w, h;
pango_layout_set_alignment (pl, PANGO_ALIGN_RIGHT);
- pango_layout_set_font_description (pl, window->style->font_desc);
+ pango_layout_set_font_description (pl, gtk_widget_get_style(window)->font_desc);
// NB: No need to convert here anymore as numbers are in the appropriate units
switch (speed_units) {
@@ -1615,10 +1617,10 @@ static void draw_vt ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets)
pango_layout_set_text(pl, s, -1);
pango_layout_get_pixel_size (pl, &w, &h);
- gdk_draw_layout(GDK_DRAWABLE(pix), window->style->fg_gc[0], MARGIN-w-3,
+ gdk_draw_layout(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->fg_gc[0], MARGIN-w-3,
CLAMP((int)i*widgets->profile_height/LINES - h/2, 0, widgets->profile_height-h), pl);
- gdk_draw_line (GDK_DRAWABLE(pix), window->style->dark_gc[0],
+ gdk_draw_line (GDK_DRAWABLE(pix), gtk_widget_get_style(window)->dark_gc[0],
MARGIN, widgets->profile_height/LINES * i, MARGIN + widgets->profile_width, widgets->profile_height/LINES * i);
g_object_unref ( G_OBJECT ( pl ) );
pl = NULL;
@@ -1627,13 +1629,13 @@ static void draw_vt ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets)
/* draw speeds */
for ( i = 0; i < widgets->profile_width; i++ )
- gdk_draw_line ( GDK_DRAWABLE(pix), window->style->dark_gc[3],
+ gdk_draw_line ( GDK_DRAWABLE(pix), gtk_widget_get_style(window)->dark_gc[3],
i + MARGIN, widgets->profile_height, i + MARGIN, widgets->profile_height-widgets->profile_height*(widgets->speeds[i]-mins)/(chunkss[widgets->cis]*LINES) );
if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->w_show_gps_speed)) ) {
- GdkGC *gps_speed_gc = gdk_gc_new ( window->window );
+ GdkGC *gps_speed_gc = gdk_gc_new ( gtk_widget_get_window(window) );
GdkColor color;
gdk_color_parse ( "red", &color );
gdk_gc_set_rgb_fg_color ( gps_speed_gc, &color);
@@ -1669,7 +1671,7 @@ static void draw_vt ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets)
}
/* draw border */
- gdk_draw_rectangle(GDK_DRAWABLE(pix), window->style->black_gc, FALSE, MARGIN, 0, widgets->profile_width-1, widgets->profile_height-1);
+ gdk_draw_rectangle(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->black_gc, FALSE, MARGIN, 0, widgets->profile_width-1, widgets->profile_height-1);
g_object_unref ( G_OBJECT(pix) );
}
@@ -1708,7 +1710,7 @@ static void draw_dt ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets )
window = gtk_widget_get_toplevel (widgets->dist_box);
- pix = gdk_pixmap_new( window->window, widgets->profile_width + MARGIN, widgets->profile_height, -1 );
+ pix = gdk_pixmap_new( gtk_widget_get_window(window), widgets->profile_width + MARGIN, widgets->profile_height, -1 );
gtk_image_set_from_pixmap ( GTK_IMAGE(image), pix, NULL );
@@ -1725,9 +1727,9 @@ static void draw_dt ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets )
get_new_min_and_chunk_index (0, maxd, chunksd, sizeof(chunksd)/sizeof(chunksd[0]), &dummy, &widgets->cid);
/* clear the image */
- gdk_draw_rectangle(GDK_DRAWABLE(pix), window->style->bg_gc[0],
+ gdk_draw_rectangle(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->bg_gc[0],
TRUE, 0, 0, MARGIN, widgets->profile_height);
- gdk_draw_rectangle(GDK_DRAWABLE(pix), window->style->mid_gc[0],
+ gdk_draw_rectangle(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->mid_gc[0],
TRUE, MARGIN, 0, widgets->profile_width, widgets->profile_height);
/* draw grid */
@@ -1737,7 +1739,7 @@ static void draw_dt ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets )
int w, h;
pango_layout_set_alignment (pl, PANGO_ALIGN_RIGHT);
- pango_layout_set_font_description (pl, window->style->font_desc);
+ pango_layout_set_font_description (pl, gtk_widget_get_style(window)->font_desc);
if ( dist_units == VIK_UNITS_DISTANCE_MILES )
sprintf(s, _("%.1f miles"), ((LINES-i)*chunksd[widgets->cid]));
@@ -1746,10 +1748,10 @@ static void draw_dt ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets )
pango_layout_set_text(pl, s, -1);
pango_layout_get_pixel_size (pl, &w, &h);
- gdk_draw_layout(GDK_DRAWABLE(pix), window->style->fg_gc[0], MARGIN-w-3,
+ gdk_draw_layout(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->fg_gc[0], MARGIN-w-3,
CLAMP((int)i*widgets->profile_height/LINES - h/2, 0, widgets->profile_height-h), pl);
- gdk_draw_line (GDK_DRAWABLE(pix), window->style->dark_gc[0],
+ gdk_draw_line (GDK_DRAWABLE(pix), gtk_widget_get_style(window)->dark_gc[0],
MARGIN, widgets->profile_height/LINES * i, MARGIN + widgets->profile_width, widgets->profile_height/LINES * i);
g_object_unref ( G_OBJECT ( pl ) );
pl = NULL;
@@ -1757,12 +1759,12 @@ static void draw_dt ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets )
/* draw distance */
for ( i = 0; i < widgets->profile_width; i++ )
- gdk_draw_line ( GDK_DRAWABLE(pix), window->style->dark_gc[3],
+ gdk_draw_line ( GDK_DRAWABLE(pix), gtk_widget_get_style(window)->dark_gc[3],
i + MARGIN, widgets->profile_height, i + MARGIN, widgets->profile_height-widgets->profile_height*(widgets->distances[i])/(chunksd[widgets->cid]*LINES) );
// Show speed indicator
if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->w_show_dist_speed)) ) {
- GdkGC *dist_speed_gc = gdk_gc_new ( window->window );
+ GdkGC *dist_speed_gc = gdk_gc_new ( gtk_widget_get_window(window) );
GdkColor color;
gdk_color_parse ( "red", &color );
gdk_gc_set_rgb_fg_color ( dist_speed_gc, &color);
@@ -1780,7 +1782,7 @@ static void draw_dt ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets )
}
/* draw border */
- gdk_draw_rectangle(GDK_DRAWABLE(pix), window->style->black_gc, FALSE, MARGIN, 0, widgets->profile_width-1, widgets->profile_height-1);
+ gdk_draw_rectangle(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->black_gc, FALSE, MARGIN, 0, widgets->profile_width-1, widgets->profile_height-1);
g_object_unref ( G_OBJECT(pix) );
@@ -1824,14 +1826,14 @@ static void draw_et ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets )
window = gtk_widget_get_toplevel (widgets->elev_time_box);
- pix = gdk_pixmap_new( window->window, widgets->profile_width + MARGIN, widgets->profile_height, -1 );
+ pix = gdk_pixmap_new( gtk_widget_get_window(window), widgets->profile_width + MARGIN, widgets->profile_height, -1 );
gtk_image_set_from_pixmap ( GTK_IMAGE(image), pix, NULL );
/* clear the image */
- gdk_draw_rectangle(GDK_DRAWABLE(pix), window->style->bg_gc[0],
+ gdk_draw_rectangle(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->bg_gc[0],
TRUE, 0, 0, MARGIN, widgets->profile_height);
- gdk_draw_rectangle(GDK_DRAWABLE(pix), window->style->mid_gc[0],
+ gdk_draw_rectangle(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->mid_gc[0],
TRUE, MARGIN, 0, widgets->profile_width, widgets->profile_height);
/* draw grid */
@@ -1841,7 +1843,7 @@ static void draw_et ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets )
int w, h;
pango_layout_set_alignment (pl, PANGO_ALIGN_RIGHT);
- pango_layout_set_font_description (pl, window->style->font_desc);
+ pango_layout_set_font_description (pl, gtk_widget_get_style(window)->font_desc);
switch (height_units) {
case VIK_UNITS_HEIGHT_METRES:
@@ -1857,10 +1859,10 @@ static void draw_et ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets )
}
pango_layout_set_text(pl, s, -1);
pango_layout_get_pixel_size (pl, &w, &h);
- gdk_draw_layout(GDK_DRAWABLE(pix), window->style->fg_gc[0], MARGIN-w-3,
+ gdk_draw_layout(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->fg_gc[0], MARGIN-w-3,
CLAMP((int)i*widgets->profile_height/LINES - h/2, 0, widgets->profile_height-h), pl);
- gdk_draw_line (GDK_DRAWABLE(pix), window->style->dark_gc[0],
+ gdk_draw_line (GDK_DRAWABLE(pix), gtk_widget_get_style(window)->dark_gc[0],
MARGIN, widgets->profile_height/LINES * i, MARGIN + widgets->profile_width, widgets->profile_height/LINES * i);
g_object_unref ( G_OBJECT ( pl ) );
pl = NULL;
@@ -1868,12 +1870,12 @@ static void draw_et ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets )
/* draw elevations */
for ( i = 0; i < widgets->profile_width; i++ )
- gdk_draw_line ( GDK_DRAWABLE(pix), window->style->dark_gc[3],
+ gdk_draw_line ( GDK_DRAWABLE(pix), gtk_widget_get_style(window)->dark_gc[3],
i + MARGIN, widgets->profile_height, i + MARGIN, widgets->profile_height-widgets->profile_height*(widgets->ats[i]-mina)/(chunksa[widgets->ciat]*LINES) );
// Show speed indicator
if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->w_show_elev_speed)) ) {
- GdkGC *elev_speed_gc = gdk_gc_new ( window->window );
+ GdkGC *elev_speed_gc = gdk_gc_new ( gtk_widget_get_window(window) );
GdkColor color;
gdk_color_parse ( "red", &color );
gdk_gc_set_rgb_fg_color ( elev_speed_gc, &color);
@@ -1891,7 +1893,7 @@ static void draw_et ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets )
}
/* draw border */
- gdk_draw_rectangle(GDK_DRAWABLE(pix), window->style->black_gc, FALSE, MARGIN, 0, widgets->profile_width-1, widgets->profile_height-1);
+ gdk_draw_rectangle(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->black_gc, FALSE, MARGIN, 0, widgets->profile_width-1, widgets->profile_height-1);
g_object_unref ( G_OBJECT(pix) );
@@ -1941,7 +1943,7 @@ static void draw_sd ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets)
window = gtk_widget_get_toplevel (widgets->speed_dist_box);
- pix = gdk_pixmap_new( window->window, widgets->profile_width + MARGIN, widgets->profile_height, -1 );
+ pix = gdk_pixmap_new( gtk_widget_get_window(window), widgets->profile_width + MARGIN, widgets->profile_height, -1 );
gtk_image_set_from_pixmap ( GTK_IMAGE(image), pix, NULL );
@@ -1957,9 +1959,9 @@ static void draw_sd ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets)
mins = widgets->draw_min_speed;
/* clear the image */
- gdk_draw_rectangle(GDK_DRAWABLE(pix), window->style->bg_gc[0],
+ gdk_draw_rectangle(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->bg_gc[0],
TRUE, 0, 0, MARGIN, widgets->profile_height);
- gdk_draw_rectangle(GDK_DRAWABLE(pix), window->style->mid_gc[0],
+ gdk_draw_rectangle(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->mid_gc[0],
TRUE, MARGIN, 0, widgets->profile_width, widgets->profile_height);
/* draw grid */
@@ -1969,7 +1971,7 @@ static void draw_sd ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets)
int w, h;
pango_layout_set_alignment (pl, PANGO_ALIGN_RIGHT);
- pango_layout_set_font_description (pl, window->style->font_desc);
+ pango_layout_set_font_description (pl, gtk_widget_get_style(window)->font_desc);
// NB: No need to convert here anymore as numbers are in the appropriate units
switch (speed_units) {
@@ -1992,10 +1994,10 @@ static void draw_sd ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets)
pango_layout_set_text(pl, s, -1);
pango_layout_get_pixel_size (pl, &w, &h);
- gdk_draw_layout(GDK_DRAWABLE(pix), window->style->fg_gc[0], MARGIN-w-3,
+ gdk_draw_layout(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->fg_gc[0], MARGIN-w-3,
CLAMP((int)i*widgets->profile_height/LINES - h/2, 0, widgets->profile_height-h), pl);
- gdk_draw_line (GDK_DRAWABLE(pix), window->style->dark_gc[0],
+ gdk_draw_line (GDK_DRAWABLE(pix), gtk_widget_get_style(window)->dark_gc[0],
MARGIN, widgets->profile_height/LINES * i, MARGIN + widgets->profile_width, widgets->profile_height/LINES * i);
g_object_unref ( G_OBJECT ( pl ) );
pl = NULL;
@@ -2004,13 +2006,13 @@ static void draw_sd ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets)
/* draw speeds */
for ( i = 0; i < widgets->profile_width; i++ )
- gdk_draw_line ( GDK_DRAWABLE(pix), window->style->dark_gc[3],
+ gdk_draw_line ( GDK_DRAWABLE(pix), gtk_widget_get_style(window)->dark_gc[3],
i + MARGIN, widgets->profile_height, i + MARGIN, widgets->profile_height-widgets->profile_height*(widgets->speeds_dist[i]-mins)/(chunkss[widgets->cisd]*LINES) );
if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->w_show_sd_gps_speed)) ) {
- GdkGC *gps_speed_gc = gdk_gc_new ( window->window );
+ GdkGC *gps_speed_gc = gdk_gc_new ( gtk_widget_get_window(window) );
GdkColor color;
gdk_color_parse ( "red", &color );
gdk_gc_set_rgb_fg_color ( gps_speed_gc, &color);
@@ -2047,7 +2049,7 @@ static void draw_sd ( GtkWidget *image, VikTrack *tr, PropWidgets *widgets)
}
/* draw border */
- gdk_draw_rectangle(GDK_DRAWABLE(pix), window->style->black_gc, FALSE, MARGIN, 0, widgets->profile_width-1, widgets->profile_height-1);
+ gdk_draw_rectangle(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->black_gc, FALSE, MARGIN, 0, widgets->profile_width-1, widgets->profile_height-1);
g_object_unref ( G_OBJECT(pix) );
}
@@ -2103,7 +2105,7 @@ static void draw_all_graphs ( GtkWidget *widget, PropWidgets *widgets, gboolean
save_image_and_draw_graph_marks (image,
marker_x,
- window->style->black_gc,
+ gtk_widget_get_style(window)->black_gc,
x_blob+MARGIN,
y_blob,
&widgets->elev_graph_saved_img,
@@ -2151,7 +2153,7 @@ static void draw_all_graphs ( GtkWidget *widget, PropWidgets *widgets, gboolean
save_image_and_draw_graph_marks (image,
marker_x,
- window->style->black_gc,
+ gtk_widget_get_style(window)->black_gc,
x_blob+MARGIN,
y_blob,
&widgets->gradient_graph_saved_img,
@@ -2201,7 +2203,7 @@ static void draw_all_graphs ( GtkWidget *widget, PropWidgets *widgets, gboolean
save_image_and_draw_graph_marks (image,
marker_x,
- window->style->black_gc,
+ gtk_widget_get_style(window)->black_gc,
x_blob+MARGIN,
y_blob,
&widgets->speed_graph_saved_img,
@@ -2251,7 +2253,7 @@ static void draw_all_graphs ( GtkWidget *widget, PropWidgets *widgets, gboolean
save_image_and_draw_graph_marks (image,
marker_x,
- window->style->black_gc,
+ gtk_widget_get_style(window)->black_gc,
x_blob+MARGIN,
y_blob,
&widgets->dist_graph_saved_img,
@@ -2300,7 +2302,7 @@ static void draw_all_graphs ( GtkWidget *widget, PropWidgets *widgets, gboolean
save_image_and_draw_graph_marks (image,
marker_x,
- window->style->black_gc,
+ gtk_widget_get_style(window)->black_gc,
x_blob+MARGIN,
y_blob,
&widgets->elev_time_graph_saved_img,
@@ -2348,7 +2350,7 @@ static void draw_all_graphs ( GtkWidget *widget, PropWidgets *widgets, gboolean
save_image_and_draw_graph_marks (image,
marker_x,
- window->style->black_gc,
+ gtk_widget_get_style(window)->black_gc,
x_blob+MARGIN,
y_blob,
&widgets->speed_dist_graph_saved_img,
@@ -2416,7 +2418,7 @@ GtkWidget *vik_trw_layer_create_profile ( GtkWidget *window, PropWidgets *widget
minmax_array(widgets->altitudes, min_alt, max_alt, TRUE, widgets->profile_width);
- pix = gdk_pixmap_new( window->window, widgets->profile_width + MARGIN, widgets->profile_height, -1 );
+ pix = gdk_pixmap_new( gtk_widget_get_window(window), widgets->profile_width + MARGIN, widgets->profile_height, -1 );
image = gtk_image_new_from_pixmap ( pix, NULL );
g_object_unref ( G_OBJECT(pix) );
@@ -2446,7 +2448,7 @@ GtkWidget *vik_trw_layer_create_gradient ( GtkWidget *window, PropWidgets *widge
return NULL;
}
- pix = gdk_pixmap_new( window->window, widgets->profile_width + MARGIN, widgets->profile_height, -1 );
+ pix = gdk_pixmap_new( gtk_widget_get_window(window), widgets->profile_width + MARGIN, widgets->profile_height, -1 );
image = gtk_image_new_from_pixmap ( pix, NULL );
g_object_unref ( G_OBJECT(pix) );
@@ -2474,26 +2476,26 @@ GtkWidget *vik_trw_layer_create_vtdiag ( GtkWidget *window, PropWidgets *widgets
if ( widgets->speeds == NULL )
return NULL;
- pix = gdk_pixmap_new( window->window, widgets->profile_width + MARGIN, widgets->profile_height, -1 );
+ pix = gdk_pixmap_new( gtk_widget_get_window(window), widgets->profile_width + MARGIN, widgets->profile_height, -1 );
image = gtk_image_new_from_pixmap ( pix, NULL );
#if 0
/* XXX this can go out, it's just a helpful dev tool */
{
int j;
- GdkGC **colors[8] = { window->style->bg_gc,
- window->style->fg_gc,
- window->style->light_gc,
- window->style->dark_gc,
- window->style->mid_gc,
- window->style->text_gc,
- window->style->base_gc,
- window->style->text_aa_gc };
+ GdkGC **colors[8] = { gtk_widget_get_style(window)->bg_gc,
+ gtk_widget_get_style(window)->fg_gc,
+ gtk_widget_get_style(window)->light_gc,
+ gtk_widget_get_style(window)->dark_gc,
+ gtk_widget_get_style(window)->mid_gc,
+ gtk_widget_get_style(window)->text_gc,
+ gtk_widget_get_style(window)->base_gc,
+ gtk_widget_get_style(window)->text_aa_gc };
for (i=0; i<5; i++) {
for (j=0; j<8; j++) {
gdk_draw_rectangle(GDK_DRAWABLE(pix), colors[j][i],
TRUE, i*20, j*20, 20, 20);
- gdk_draw_rectangle(GDK_DRAWABLE(pix), window->style->black_gc,
+ gdk_draw_rectangle(GDK_DRAWABLE(pix), gtk_widget_get_style(window)->black_gc,
FALSE, i*20, j*20, 20, 20);
}
}
@@ -2525,7 +2527,7 @@ GtkWidget *vik_trw_layer_create_dtdiag ( GtkWidget *window, PropWidgets *widgets
if ( widgets->distances == NULL )
return NULL;
- pix = gdk_pixmap_new( window->window, widgets->profile_width + MARGIN, widgets->profile_height, -1 );
+ pix = gdk_pixmap_new( gtk_widget_get_window(window), widgets->profile_width + MARGIN, widgets->profile_height, -1 );
image = gtk_image_new_from_pixmap ( pix, NULL );
g_object_unref ( G_OBJECT(pix) );
@@ -2554,7 +2556,7 @@ GtkWidget *vik_trw_layer_create_etdiag ( GtkWidget *window, PropWidgets *widgets
if ( widgets->ats == NULL )
return NULL;
- pix = gdk_pixmap_new( window->window, widgets->profile_width + MARGIN, widgets->profile_height, -1 );
+ pix = gdk_pixmap_new( gtk_widget_get_window(window), widgets->profile_width + MARGIN, widgets->profile_height, -1 );
image = gtk_image_new_from_pixmap ( pix, NULL );
g_object_unref ( G_OBJECT(pix) );
@@ -2582,7 +2584,7 @@ GtkWidget *vik_trw_layer_create_sddiag ( GtkWidget *window, PropWidgets *widgets
if ( widgets->speeds_dist == NULL )
return NULL;
- pix = gdk_pixmap_new( window->window, widgets->profile_width + MARGIN, widgets->profile_height, -1 );
+ pix = gdk_pixmap_new( gtk_widget_get_window(window), widgets->profile_width + MARGIN, widgets->profile_height, -1 );
image = gtk_image_new_from_pixmap ( pix, NULL );
g_object_unref ( G_OBJECT(pix) );
@@ -2617,10 +2619,13 @@ static void propwin_response_cb( GtkDialog *dialog, gint resp, PropWidgets *widg
case GTK_RESPONSE_ACCEPT:
vik_track_set_comment(tr, gtk_entry_get_text(GTK_ENTRY(widgets->w_comment)));
vik_track_set_description(tr, gtk_entry_get_text(GTK_ENTRY(widgets->w_description)));
+ gtk_color_button_get_color ( GTK_COLOR_BUTTON(widgets->w_color), &(tr->color) );
+ trw_layer_update_treeview ( widgets->vtl, widgets->tr, widgets->trk_id );
+ vik_layer_emit_update ( VIK_LAYER(vtl) );
break;
case VIK_TRW_LAYER_PROPWIN_REVERSE:
vik_track_reverse(tr);
- vik_layer_emit_update ( VIK_LAYER(vtl), FALSE );
+ vik_layer_emit_update ( VIK_LAYER(vtl) );
break;
case VIK_TRW_LAYER_PROPWIN_DEL_DUP:
vik_track_remove_dup_points(tr); // NB ignore the returned answer
@@ -2629,7 +2634,7 @@ static void propwin_response_cb( GtkDialog *dialog, gint resp, PropWidgets *widg
/* above operation could have deleted current_tp or last_tp */
trw_layer_cancel_tps_of_track ( vtl, tr );
- vik_layer_emit_update ( VIK_LAYER(vtl), FALSE );
+ vik_layer_emit_update ( VIK_LAYER(vtl) );
break;
case VIK_TRW_LAYER_PROPWIN_SPLIT:
{
@@ -2660,7 +2665,7 @@ static void propwin_response_cb( GtkDialog *dialog, gint resp, PropWidgets *widg
vik_trw_layer_delete_route ( vtl, tr );
else
vik_trw_layer_delete_track ( vtl, tr );
- vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); /* chase thru the hoops */
+ vik_layer_emit_update ( VIK_LAYER(vtl) ); /* chase thru the hoops */
}
}
break;
@@ -2694,7 +2699,7 @@ static void propwin_response_cb( GtkDialog *dialog, gint resp, PropWidgets *widg
vik_trw_layer_add_route(vtl, r_name, tr_right);
else
vik_trw_layer_add_track(vtl, r_name, tr_right);
- vik_layer_emit_update ( VIK_LAYER(vtl), FALSE );
+ vik_layer_emit_update ( VIK_LAYER(vtl) );
}
break;
default:
@@ -2756,13 +2761,19 @@ static GtkWidget *create_graph_page ( GtkWidget *graph,
return vbox;
}
-void vik_trw_layer_propwin_run ( GtkWindow *parent, VikTrwLayer *vtl, VikTrack *tr, gpointer vlp, VikViewport *vvp )
+void vik_trw_layer_propwin_run ( GtkWindow *parent,
+ VikTrwLayer *vtl,
+ VikTrack *tr,
+ gpointer vlp,
+ VikViewport *vvp,
+ gpointer *trk_id )
{
PropWidgets *widgets = prop_widgets_new();
widgets->vtl = vtl;
widgets->vvp = vvp;
widgets->vlp = vlp;
widgets->tr = tr;
+ widgets->trk_id = trk_id;
widgets->profile_width = PROPWIN_PROFILE_WIDTH;
widgets->profile_height = PROPWIN_PROFILE_HEIGHT;
gchar *title = g_strdup_printf(_("%s - Track Properties"), tr->name);
@@ -2813,7 +2824,8 @@ void vik_trw_layer_propwin_run ( GtkWindow *parent, VikTrwLayer *vtl, VikTrack *
N_("Total Elevation Gain/Loss:"),
N_("Start:"),
N_("End:"),
- N_("Duration:") };
+ N_("Duration:"),
+ N_("Color:") };
static gchar tmp_buf[50];
gdouble tmp_speed;
@@ -3006,14 +3018,10 @@ void vik_trw_layer_propwin_run ( GtkWindow *parent, VikTrwLayer *vtl, VikTrack *
t1 = VIK_TRACKPOINT(tr->trackpoints->data)->timestamp;
t2 = VIK_TRACKPOINT(g_list_last(tr->trackpoints)->data)->timestamp;
- strncpy(tmp_buf, ctime(&t1), sizeof(tmp_buf));
- tmp_buf[sizeof(tmp_buf)-1] = 0;
- g_strchomp(tmp_buf);
+ strftime (tmp_buf, sizeof(tmp_buf), "%c", localtime(&(t1)));
widgets->w_time_start = content[cnt++] = gtk_label_new(tmp_buf);
- strncpy(tmp_buf, ctime(&t2), sizeof(tmp_buf));
- tmp_buf[sizeof(tmp_buf)-1] = 0;
- g_strchomp(tmp_buf);
+ strftime (tmp_buf, sizeof(tmp_buf), "%c", localtime(&(t2)));
widgets->w_time_end = content[cnt++] = gtk_label_new(tmp_buf);
g_snprintf(tmp_buf, sizeof(tmp_buf), _("%d minutes"), (int)(t2-t1)/60);
@@ -3024,6 +3032,8 @@ void vik_trw_layer_propwin_run ( GtkWindow *parent, VikTrwLayer *vtl, VikTrack *
widgets->w_time_dur = content[cnt++] = gtk_label_new(_("No Data"));
}
+ widgets->w_color = content[cnt++] = gtk_color_button_new_with_color ( &(tr->color) );
+
table = GTK_TABLE(gtk_table_new (cnt, 2, FALSE));
gtk_table_set_col_spacing (table, 0, 10);
for (i=0; ivbox), graphs, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), graphs, FALSE, FALSE, 0);
gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog), VIK_TRW_LAYER_PROPWIN_SPLIT_MARKER, FALSE);
if (seg_count <= 1)