Diff of /trunk/src/misc.c

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

revision 137 by harbaum, Mon Oct 19 18:21:20 2009 UTC revision 185 by harbaum, Sat Nov 14 16:55:33 2009 UTC
# Line 151  float pos_parse_lon(char *str) { Line 151  float pos_parse_lon(char *str) {
151    
152  const char *pos_get_bearing_str(pos_t from, pos_t to) {  const char *pos_get_bearing_str(pos_t from, pos_t to) {
153    static const char *bear_str[]={    static const char *bear_str[]={
154      "N", "NE", "E", "SE", "S", "SW", "W", "NW" };      "N", "NE", "E", "SE", "S", "SW", "W", "NW", "" };
155    int idx = (gpx_pos_get_bearing(from, to)+22.5)/45.0;  
156    /* make sure we stay in icon bounds */    float bearing = gpx_pos_get_bearing(from, to);
157    while(idx < 0) idx += 8;    if(!isnan(bearing)) {
158    while(idx > 7) idx -= 8;      int idx = (bearing+22.5)/45.0;
159    return _(bear_str[idx]);      /* make sure we stay in icon bounds */
160        while(idx < 0) idx += 8;
161        while(idx > 7) idx -= 8;
162        return _(bear_str[idx]);
163      }
164    
165      return bear_str[8];  // empty string
166  }  }
167    
168  /* 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 475  GtkWidget *link_button_by_id(appdata_t * Line 481  GtkWidget *link_button_by_id(appdata_t *
481    return gtk_label_new(str);    return gtk_label_new(str);
482  }  }
483    
484    
485    GtkWidget *link_icon_button_by_id(appdata_t *appdata, GtkWidget *icon,
486                                 const char *type, int id) {
487    
488    #ifdef ENABLE_BROWSER_INTERFACE
489      if(id) {
490        GtkWidget *ref = gtk_button_new();
491        gtk_button_set_image(GTK_BUTTON(ref), icon);
492    
493    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)
494        //    hildon_gtk_widget_set_theme_size(ref,
495        //         (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
496    #endif
497        g_object_set_data(G_OBJECT(ref), "id", (gpointer)id);
498        g_object_set_data(G_OBJECT(ref), "type", (gpointer)type);
499        gtk_signal_connect(GTK_OBJECT(ref), "clicked",
500                           GTK_SIGNAL_FUNC(on_link_id_clicked), appdata);
501    
502        return ref;
503      }
504    #endif
505      return icon;
506    }
507    
508    /* left aligned, word wrapped multiline widget */
509    GtkWidget *simple_text_widget(char *text) {
510      GtkWidget *label = gtk_label_new(text);
511    
512      gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
513      gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD);
514      gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
515    
516      return label;
517    }

Legend:
Removed from v.137  
changed lines
  Added in v.185