Diff of /trunk/src/misc.c

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

revision 316 by harbaum, Wed Dec 16 20:07:58 2009 UTC revision 317 by harbaum, Thu Dec 17 16:54:18 2009 UTC
# Line 19  Line 19 
19    
20  #include "appdata.h"  #include "appdata.h"
21    
22    #ifdef FREMANTLE
23    #include <hildon/hildon-check-button.h>
24    #include <hildon/hildon-picker-button.h>
25    #include <hildon/hildon-entry.h>
26    #include <hildon/hildon-touch-selector-entry.h>
27    #include <hildon/hildon-note.h>
28    #endif
29    
30  static void vmessagef(GtkWidget *parent, int type, int buttons,  static void vmessagef(GtkWidget *parent, int type, int buttons,
31                        char *title, const char *fmt,                        char *title, const char *fmt,
32                        va_list args) {                        va_list args) {
# Line 351  GtkWidget *entry_new(void) { Line 359  GtkWidget *entry_new(void) {
359  #endif  #endif
360  }  }
361    
362    GType entry_type(void) {
363    #ifndef FREMANTLE
364      return GTK_TYPE_ENTRY;
365    #else
366      return HILDON_TYPE_ENTRY;
367    #endif
368    }
369    
370  GtkWidget *button_new(void) {  GtkWidget *button_new(void) {
371    GtkWidget *button = gtk_button_new();    GtkWidget *button = gtk_button_new();
372  #ifdef FREMANTLE  #ifdef FREMANTLE
# Line 381  GtkWidget *check_button_new_with_label(c Line 397  GtkWidget *check_button_new_with_label(c
397  #endif  #endif
398  }  }
399    
400    GType check_button_type(void) {
401    #ifndef FREMANTLE
402      return GTK_TYPE_CHECK_BUTTON;
403    #else
404      return HILDON_TYPE_CHECK_BUTTON;
405    #endif
406    }
407    
408  void check_button_set_active(GtkWidget *button, gboolean active) {  void check_button_set_active(GtkWidget *button, gboolean active) {
409  #ifndef FREMANTLE  #ifndef FREMANTLE
410    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), active);
# Line 484  void notebook_append_page(GtkWidget *not Line 508  void notebook_append_page(GtkWidget *not
508  #endif  #endif
509  }  }
510    
511    void on_value_changed(HildonPickerButton *widget, gpointer  user_data) {
512      g_signal_emit_by_name(widget, "changed");
513    }
514    
515    static GtkWidget *combo_box_new_with_selector(char *title, GtkWidget *selector) {
516      GtkWidget *button =
517        hildon_picker_button_new(HILDON_SIZE_FINGER_HEIGHT |
518                                 HILDON_SIZE_AUTO_WIDTH,
519                                 HILDON_BUTTON_ARRANGEMENT_VERTICAL);
520    
521      hildon_button_set_title_alignment(HILDON_BUTTON(button), 0.5, 0.5);
522      hildon_button_set_value_alignment(HILDON_BUTTON(button), 0.5, 0.5);
523    
524      /* allow button to emit "changed" signal */
525      g_signal_connect(button, "value-changed", G_CALLBACK(on_value_changed), NULL);
526    
527      hildon_button_set_title(HILDON_BUTTON (button), title);
528    
529      hildon_picker_button_set_selector(HILDON_PICKER_BUTTON(button),
530                                        HILDON_TOUCH_SELECTOR(selector));
531    
532      return button;
533    }
534    
535    /* the title is only used on fremantle with the picker widget */
536    GtkWidget *combo_box_new(char *title) {
537    #ifndef FREMANTLE
538      return gtk_combo_box_new_text();
539    #else
540      GtkWidget *selector = hildon_touch_selector_new_text();
541      return combo_box_new_with_selector(title, selector);
542    #endif
543    }
544    
545    GtkWidget *combo_box_entry_new(char *title) {
546    #ifndef FREMANTLE
547      return gtk_combo_box_entry_new_text();
548    #else
549      GtkWidget *selector = hildon_touch_selector_entry_new_text();
550      return combo_box_new_with_selector(title, selector);
551    #endif
552    }
553    
554    void combo_box_append_text(GtkWidget *cbox, char *text) {
555    #ifndef FREMANTLE
556      gtk_combo_box_append_text(GTK_COMBO_BOX(cbox), text);
557    #else
558      HildonTouchSelector *selector =
559        hildon_picker_button_get_selector(HILDON_PICKER_BUTTON(cbox));
560    
561      hildon_touch_selector_append_text(selector, text);
562    #endif
563    }
564    
565    void combo_box_set_active(GtkWidget *cbox, int index) {
566    #ifndef FREMANTLE
567      gtk_combo_box_set_active(GTK_COMBO_BOX(cbox), index);
568    #else
569      hildon_picker_button_set_active(HILDON_PICKER_BUTTON(cbox), index);
570    #endif
571    }
572    
573    int combo_box_get_active(GtkWidget *cbox) {
574    #ifndef FREMANTLE
575      return gtk_combo_box_get_active(GTK_COMBO_BOX(cbox));
576    #else
577      return hildon_picker_button_get_active(HILDON_PICKER_BUTTON(cbox));
578    #endif
579    }
580    
581    const char *combo_box_get_active_text(GtkWidget *cbox) {
582    #ifndef FREMANTLE
583      return gtk_combo_box_get_active_text(GTK_COMBO_BOX(cbox));
584    #else
585      return hildon_button_get_value(HILDON_BUTTON(cbox));
586    #endif
587    }
588    
589    GType combo_box_type(void) {
590    #ifndef FREMANTLE
591      return GTK_TYPE_COMBO_BOX;
592    #else
593      return HILDON_TYPE_PICKER_BUTTON;
594    #endif
595    }
596    
597    void misc_init(void) {
598    #ifdef FREMANTLE
599      g_signal_new ("changed", HILDON_TYPE_PICKER_BUTTON,
600                    G_SIGNAL_RUN_FIRST, 0, NULL, NULL,
601                    g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
602    #endif
603    }

Legend:
Removed from v.316  
changed lines
  Added in v.317