Diff of /trunk/src/misc.c

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

revision 77 by harbaum, Tue Aug 25 12:49:03 2009 UTC revision 165 by harbaum, Sun Nov 8 20:32:55 2009 UTC
# Line 412  void rmdir_recursive(char *path) { Line 412  void rmdir_recursive(char *path) {
412    g_rmdir(path);    g_rmdir(path);
413  }  }
414    
415    #ifdef ENABLE_BROWSER_INTERFACE
416    static void on_link_clicked(GtkButton *button, gpointer data) {
417      appdata_t *appdata = (appdata_t*)data;
418      char *url = g_object_get_data(G_OBJECT(button), "url");
419      if(url) browser_url(appdata, url);
420    }
421    #endif
422    
423    /* a button containing a weblink */
424    GtkWidget *link_button_attrib(appdata_t *appdata, char *str, char *url,
425                           int size, int strikethrough) {
426    
427    #ifdef ENABLE_BROWSER_INTERFACE
428      if(url) {
429        GtkWidget *button = gtk_button_attrib(str, size, strikethrough);
430        g_object_set_data(G_OBJECT(button), "url", url);
431        gtk_signal_connect(GTK_OBJECT(button), "clicked",
432                           (GtkSignalFunc)on_link_clicked, appdata);
433    
434        return button;
435      }
436    #endif
437      return gtk_label_attrib(str, size, strikethrough);
438    }
439    
440    #ifdef ENABLE_BROWSER_INTERFACE
441    static void on_link_id_clicked(GtkButton *button, gpointer data) {
442      appdata_t *appdata = (appdata_t*)data;
443    
444      unsigned int id = (unsigned int)g_object_get_data(G_OBJECT(button), "id");
445      char *type = g_object_get_data(G_OBJECT(button), "type");
446    
447      char *url = g_strdup_printf("http://www.geocaching.com/%s?id=%u",
448                                  type, id);
449    
450      if(url) {
451        browser_url(appdata, url);
452        g_free(url);
453      }
454    }
455    #endif
456    
457    GtkWidget *link_button_by_id(appdata_t *appdata, char *str,
458                                 const char *type, int id) {
459    
460    #ifdef ENABLE_BROWSER_INTERFACE
461      if(id) {
462        GtkWidget *ref = gtk_button_new_with_label(str);
463    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)
464        //    hildon_gtk_widget_set_theme_size(ref,
465        //         (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
466    #endif
467        g_object_set_data(G_OBJECT(ref), "id", (gpointer)id);
468        g_object_set_data(G_OBJECT(ref), "type", (gpointer)type);
469        gtk_signal_connect(GTK_OBJECT(ref), "clicked",
470                           GTK_SIGNAL_FUNC(on_link_id_clicked), appdata);
471    
472        return ref;
473      }
474    #endif
475      return gtk_label_new(str);
476    }
477    
478    
479    GtkWidget *link_icon_button_by_id(appdata_t *appdata, GtkWidget *icon,
480                                 const char *type, int id) {
481    
482    #ifdef ENABLE_BROWSER_INTERFACE
483      if(id) {
484        GtkWidget *ref = gtk_button_new();
485        gtk_button_set_image(GTK_BUTTON(ref), icon);
486    
487    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)
488        //    hildon_gtk_widget_set_theme_size(ref,
489        //         (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
490    #endif
491        g_object_set_data(G_OBJECT(ref), "id", (gpointer)id);
492        g_object_set_data(G_OBJECT(ref), "type", (gpointer)type);
493        gtk_signal_connect(GTK_OBJECT(ref), "clicked",
494                           GTK_SIGNAL_FUNC(on_link_id_clicked), appdata);
495    
496        return ref;
497      }
498    #endif
499      return icon;
500    }
501    
502    /* left aligned, word wrapped multiline widget */
503    GtkWidget *simple_text_widget(char *text) {
504      GtkWidget *label = gtk_label_new(text);
505    
506      gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
507      gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD);
508      gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
509    
510      return label;
511    }

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