Diff of /trunk/src/misc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 165 by harbaum, Sun Nov 8 20:32:55 2009 UTC revision 198 by harbaum, Thu Nov 19 12:38:03 2009 UTC
# Line 26  Line 26 
26    
27  #include "gpxview.h"  #include "gpxview.h"
28    
29    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5)
30    #include <hildon/hildon-entry.h>
31    #endif
32    
33  char strlastchr(char *str) {  char strlastchr(char *str) {
34    return str[strlen(str)]-1;    return str[strlen(str)]-1;
35  }  }
# Line 151  float pos_parse_lon(char *str) { Line 155  float pos_parse_lon(char *str) {
155    
156  const char *pos_get_bearing_str(pos_t from, pos_t to) {  const char *pos_get_bearing_str(pos_t from, pos_t to) {
157    static const char *bear_str[]={    static const char *bear_str[]={
158      "N", "NE", "E", "SE", "S", "SW", "W", "NW" };      "N", "NE", "E", "SE", "S", "SW", "W", "NW", "" };
159    int idx = (gpx_pos_get_bearing(from, to)+22.5)/45.0;  
160    /* make sure we stay in icon bounds */    float bearing = gpx_pos_get_bearing(from, to);
161    while(idx < 0) idx += 8;    if(!isnan(bearing)) {
162    while(idx > 7) idx -= 8;      int idx = (bearing+22.5)/45.0;
163    return _(bear_str[idx]);      /* make sure we stay in icon bounds */
164        while(idx < 0) idx += 8;
165        while(idx > 7) idx -= 8;
166        return _(bear_str[idx]);
167      }
168    
169      return bear_str[8];  // empty string
170  }  }
171    
172  /* the maemo font size is quite huge, so we adjust some fonts */  /* the maemo font size is quite huge, so we adjust some fonts */
# Line 300  static void callback_modified_lat(GtkWid Line 310  static void callback_modified_lat(GtkWid
310  /* a entry that is colored red when being "active" */  /* a entry that is colored red when being "active" */
311  GtkWidget *lat_entry_new(float lat) {  GtkWidget *lat_entry_new(float lat) {
312    GdkColor color;    GdkColor color;
313    
314    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
315    GtkWidget *widget = gtk_entry_new();    GtkWidget *widget = gtk_entry_new();
316    #else
317      GtkWidget *widget = hildon_entry_new(HILDON_SIZE_AUTO);
318    #endif
319    
320    gdk_color_parse("#ff0000", &color);    gdk_color_parse("#ff0000", &color);
321    gtk_widget_modify_text(widget, TAG_STATE, &color);    gtk_widget_modify_text(widget, TAG_STATE, &color);
322    
# Line 322  static void callback_modified_lon(GtkWid Line 338  static void callback_modified_lon(GtkWid
338  /* a entry that is colored red when filled with invalid coordinate */  /* a entry that is colored red when filled with invalid coordinate */
339  GtkWidget *lon_entry_new(float lon) {  GtkWidget *lon_entry_new(float lon) {
340    GdkColor color;    GdkColor color;
341    
342    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
343    GtkWidget *widget = gtk_entry_new();    GtkWidget *widget = gtk_entry_new();
344    #else
345      GtkWidget *widget = hildon_entry_new(HILDON_SIZE_AUTO);
346      //  gtk_entry_set_width_chars(GTK_ENTRY(widget), 14);
347    #endif
348    
349    gdk_color_parse("#ff0000", &color);    gdk_color_parse("#ff0000", &color);
350    gtk_widget_modify_text(widget, TAG_STATE, &color);    gtk_widget_modify_text(widget, TAG_STATE, &color);
351    
# Line 357  static void callback_modified_dist(GtkWi Line 380  static void callback_modified_dist(GtkWi
380  /* a entry that is colored red when filled with invalid distance */  /* a entry that is colored red when filled with invalid distance */
381  GtkWidget *dist_entry_new(float dist, gboolean mil) {  GtkWidget *dist_entry_new(float dist, gboolean mil) {
382    GdkColor color;    GdkColor color;
383    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
384    GtkWidget *widget = gtk_entry_new();    GtkWidget *widget = gtk_entry_new();
385    #else
386      GtkWidget *widget = hildon_entry_new(HILDON_SIZE_AUTO);
387    #endif
388    gdk_color_parse("#ff0000", &color);    gdk_color_parse("#ff0000", &color);
389    gtk_widget_modify_text(widget, TAG_STATE, &color);    gtk_widget_modify_text(widget, TAG_STATE, &color);
390    
# Line 509  GtkWidget *simple_text_widget(char *text Line 536  GtkWidget *simple_text_widget(char *text
536    
537    return label;    return label;
538  }  }
539    
540    
541    /* a label that is left aligned */
542    GtkWidget *left_label_new(char *str) {
543      GtkWidget *widget = gtk_label_new(str);
544      gtk_misc_set_alignment(GTK_MISC(widget), 0.0f, 0.5f);
545      return widget;
546    }

Legend:
Removed from v.165  
changed lines
  Added in v.198