Author: Faheem Language: diff
Description: Not specified Timestamp: 2009-12-28 12:56:24 -0500
View raw paste Reply
  1. --- browser-switchboard-3.0.orig/config-ui/browser-switchboard-cp.c
  2. +++ browser-switchboard-3.0/config-ui/browser-switchboard-cp.c
  3. @@ -34,6 +34,10 @@
  4.  #include <glib/gstdio.h>
  5.  #include <gtk/gtk.h>
  6.  #ifdef HILDON
  7. +#include <hildon/hildon-touch-selector.h>
  8. +#include <hildon/hildon-picker-button.h>
  9. +#include <hildon/hildon-caption.h>
  10. +#include <hildon/hildon-entry.h>
  11.  #include <hildon/hildon-banner.h>
  12.  #include <hildon/hildon-program.h>
  13.  #ifdef HILDON_CP_APPLET
  14. @@ -45,6 +49,8 @@
  15.  
  16.  #define CONTINUOUS_MODE_DEFAULT 0
  17.  
  18. +#define _HILDON_SIZE_DEFAULT HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT
  19. +
  20.  struct browser_entry {
  21.         char *config;
  22.         char *displayname;
  23. @@ -59,9 +65,8 @@
  24.  };
  25.  
  26.  struct config_widgets {
  27. -       GtkWidget *continuous_mode_off_radio;
  28. -       GtkWidget *continuous_mode_on_radio;
  29. -       GtkWidget *default_browser_combo;
  30. +       GtkWidget *continuous_mode_selector;
  31. +       GtkWidget *default_browser_selector;
  32.         GtkWidget *other_browser_cmd_entry;
  33.         GtkWidget *other_browser_cmd_entry_label;
  34.  };
  35. @@ -74,17 +79,14 @@
  36.   **********************************************************************/
  37.  
  38.  static inline int get_continuous_mode(void) {
  39. -       return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cw.continuous_mode_on_radio));
  40. +       return hildon_touch_selector_get_active(HILDON_TOUCH_SELECTOR(cw.continuous_mode_selector), 0);
  41.  }
  42.  static inline void set_continuous_mode(int state) {
  43. -       if (state)
  44. -               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cw.continuous_mode_on_radio), TRUE);
  45. -       else
  46. -               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cw.continuous_mode_off_radio), TRUE);
  47. +       hildon_touch_selector_set_active(HILDON_TOUCH_SELECTOR(cw.continuous_mode_selector), 0, state);
  48.  }
  49.  
  50.  static inline char *get_default_browser(void) {
  51. -       return browsers[gtk_combo_box_get_active(GTK_COMBO_BOX(cw.default_browser_combo))].config;
  52. +       return browsers[hildon_touch_selector_get_active(HILDON_TOUCH_SELECTOR(cw.default_browser_selector), 0)].config;
  53.  }
  54.  static void set_default_browser(char *browser) {
  55.         gint i;
  56. @@ -97,7 +99,7 @@
  57.                 /* No match found, set to the default browser */
  58.                 i = 0;
  59.  
  60. -       gtk_combo_box_set_active(GTK_COMBO_BOX(cw.default_browser_combo), i);
  61. +       hildon_touch_selector_set_active(HILDON_TOUCH_SELECTOR(cw.default_browser_selector), 0, i);
  62.  }
  63.  
  64.  static inline char *get_other_browser_cmd(void) {
  65. @@ -271,11 +273,13 @@
  66.   * Callbacks
  67.   **********************************************************************/
  68.  
  69. -static void default_browser_combo_callback(GtkWidget *widget, gpointer data) {
  70. +static void default_browser_selector_callback(GtkWidget *widget, gint column G_GNUC_UNUSED, gpointer data) {
  71.         if (!strcmp(get_default_browser(), "other")) {
  72. +               gtk_editable_set_editable(GTK_EDITABLE(cw.other_browser_cmd_entry), TRUE);
  73.                 gtk_widget_set_sensitive(cw.other_browser_cmd_entry, TRUE);
  74.                 gtk_widget_set_sensitive(cw.other_browser_cmd_entry_label, TRUE);
  75.         } else {
  76. +               gtk_editable_set_editable(GTK_EDITABLE(cw.other_browser_cmd_entry), FALSE); /* Give the text the greyed-out look */
  77.                 gtk_widget_set_sensitive(cw.other_browser_cmd_entry, FALSE);
  78.                 gtk_widget_set_sensitive(cw.other_browser_cmd_entry_label, FALSE);
  79.         }
  80. @@ -289,10 +293,10 @@
  81.  static GtkDialog *swb_config_dialog(gpointer cp_window) {
  82.         GtkWidget *dialog_vbox;
  83.  
  84. -       GtkWidget *options_table;
  85. -       GtkWidget *default_browser_combo_label;
  86. -       GtkWidget *continuous_mode_label;
  87. +       GtkWidget *default_browser_selector_button;
  88. +       GtkWidget *continuous_mode_selector_button;
  89.         int i;
  90. +       HildonGtkInputMode input_mode;
  91.  
  92.         dialog = gtk_dialog_new_with_buttons(
  93.                 "Browser Switchboard",
  94. @@ -307,79 +311,41 @@
  95.         dialog_vbox = GTK_DIALOG(dialog)->vbox;
  96.  
  97.         /* Config options */
  98. -       options_table = gtk_table_new(3, 2, FALSE);
  99. -       gtk_table_set_row_spacings(GTK_TABLE(options_table), 5);
  100. -       gtk_box_pack_start(GTK_BOX(dialog_vbox), options_table, FALSE, FALSE, 0);
  101. -
  102. -       cw.default_browser_combo = gtk_combo_box_new_text();
  103. +       cw.default_browser_selector = hildon_touch_selector_new_text();
  104.         for (i = 0; browsers[i].config; ++i)
  105. -               gtk_combo_box_append_text(GTK_COMBO_BOX(cw.default_browser_combo),
  106. +               hildon_touch_selector_append_text(HILDON_TOUCH_SELECTOR(cw.default_browser_selector),
  107.                                           browsers[i].displayname);
  108. -       gtk_combo_box_set_active(GTK_COMBO_BOX(cw.default_browser_combo), 0);
  109. -       default_browser_combo_label = gtk_label_new("Default browser:");
  110. -       gtk_misc_set_alignment(GTK_MISC(default_browser_combo_label), 1, 0.5);
  111. -       g_signal_connect(G_OBJECT(cw.default_browser_combo), "changed",
  112. -                        G_CALLBACK(default_browser_combo_callback), NULL);
  113. -       gtk_table_attach(GTK_TABLE(options_table),
  114. -                       default_browser_combo_label,
  115. -                       0, 1,
  116. -                       0, 1,
  117. -                       GTK_FILL, GTK_FILL|GTK_EXPAND,
  118. -                       5, 0);
  119. -       gtk_table_attach(GTK_TABLE(options_table),
  120. -                       cw.default_browser_combo,
  121. -                       1, 2,
  122. -                       0, 1,
  123. -                       GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND,
  124. -                       5, 0);
  125. -
  126. -       cw.other_browser_cmd_entry = gtk_entry_new();
  127. -       cw.other_browser_cmd_entry_label = gtk_label_new("Command (%s for URI):");
  128. -       gtk_misc_set_alignment(GTK_MISC(cw.other_browser_cmd_entry_label), 1, 0.5);
  129. +       hildon_touch_selector_set_active(HILDON_TOUCH_SELECTOR(cw.default_browser_selector), 0, 0);
  130. +       default_browser_selector_button = hildon_picker_button_new(_HILDON_SIZE_DEFAULT, HILDON_BUTTON_ARRANGEMENT_HORIZONTAL);
  131. +       hildon_button_set_title (HILDON_BUTTON (default_browser_selector_button), "Default browser:");
  132. +       hildon_picker_button_set_selector(HILDON_PICKER_BUTTON(default_browser_selector_button), HILDON_TOUCH_SELECTOR(cw.default_browser_selector));
  133. +       hildon_button_set_alignment(HILDON_BUTTON(default_browser_selector_button), 0, 0.5, 0, 0);
  134. +       g_signal_connect(G_OBJECT(cw.default_browser_selector), "changed",
  135. +                        G_CALLBACK(default_browser_selector_callback), NULL);
  136. +       gtk_box_pack_start(GTK_BOX(dialog_vbox), default_browser_selector_button, FALSE, FALSE, 0);
  137. +
  138. +       cw.other_browser_cmd_entry = hildon_entry_new(_HILDON_SIZE_DEFAULT);
  139. +       input_mode = hildon_gtk_entry_get_input_mode(GTK_ENTRY(cw.other_browser_cmd_entry));
  140. +       input_mode &= ~HILDON_GTK_INPUT_MODE_AUTOCAP;
  141. +       input_mode &= ~HILDON_GTK_INPUT_MODE_DICTIONARY;
  142. +       hildon_gtk_entry_set_input_mode(GTK_ENTRY(cw.other_browser_cmd_entry), input_mode);
  143. +
  144. +       cw.other_browser_cmd_entry_label = hildon_caption_new(NULL, "Command (%s for URI):", cw.other_browser_cmd_entry, NULL, HILDON_CAPTION_OPTIONAL);
  145.         gtk_widget_set_sensitive(cw.other_browser_cmd_entry, FALSE);
  146.         gtk_widget_set_sensitive(cw.other_browser_cmd_entry_label, FALSE);
  147. -       gtk_table_attach(GTK_TABLE(options_table),
  148. -                       cw.other_browser_cmd_entry_label,
  149. -                       0, 1,
  150. -                       1, 2,
  151. -                       GTK_FILL, GTK_FILL|GTK_EXPAND,
  152. -                       5, 0);
  153. -       gtk_table_attach(GTK_TABLE(options_table),
  154. -                       cw.other_browser_cmd_entry,
  155. -                       1, 2,
  156. -                       1, 2,
  157. -                       GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND,
  158. -                       5, 0);
  159. -       gtk_table_set_row_spacing(GTK_TABLE(options_table), 1, 15);
  160. -
  161. -       continuous_mode_label = gtk_label_new("Optimize Browser Switchboard for:");
  162. -       gtk_misc_set_alignment(GTK_MISC(continuous_mode_label), 0, 0.5);
  163. -       cw.continuous_mode_off_radio = gtk_radio_button_new_with_label(NULL,
  164. -                       "Lower memory usage");
  165. -       cw.continuous_mode_on_radio = gtk_radio_button_new_with_label_from_widget(
  166. -                       GTK_RADIO_BUTTON(cw.continuous_mode_off_radio),
  167. -                       "Faster browser startup time");
  168. -       set_continuous_mode(CONTINUOUS_MODE_DEFAULT);
  169. -       gtk_table_attach(GTK_TABLE(options_table),
  170. -                       continuous_mode_label,
  171. -                       0, 2,
  172. -                       2, 3,
  173. -                       GTK_FILL, GTK_FILL|GTK_EXPAND,
  174. -                       5, 0);
  175. -       gtk_table_attach(GTK_TABLE(options_table),
  176. -                       cw.continuous_mode_off_radio,
  177. -                       0, 2,
  178. -                       3, 4,
  179. -                       GTK_FILL, GTK_FILL|GTK_EXPAND,
  180. -                       20, 0);
  181. -       gtk_table_attach(GTK_TABLE(options_table),
  182. -                       cw.continuous_mode_on_radio,
  183. -                       0, 2,
  184. -                       4, 5,
  185. -                       GTK_FILL, GTK_FILL|GTK_EXPAND,
  186. -                       20, 5);
  187. -       gtk_table_set_row_spacing(GTK_TABLE(options_table), 3, 0);
  188. +       hildon_gtk_widget_set_theme_size(cw.other_browser_cmd_entry_label, _HILDON_SIZE_DEFAULT);
  189. +       gtk_box_pack_start(GTK_BOX(dialog_vbox), cw.other_browser_cmd_entry_label, FALSE, FALSE, 0);
  190.  
  191. +       cw.continuous_mode_selector = hildon_touch_selector_new_text();
  192. +       hildon_touch_selector_append_text(HILDON_TOUCH_SELECTOR(cw.continuous_mode_selector), "Lower memory usage");
  193. +       hildon_touch_selector_append_text(HILDON_TOUCH_SELECTOR(cw.continuous_mode_selector), "Faster browser startup time");
  194. +
  195. +       continuous_mode_selector_button = hildon_picker_button_new(_HILDON_SIZE_DEFAULT, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
  196. +       hildon_button_set_title (HILDON_BUTTON (continuous_mode_selector_button), "Optimize Browser Switchboard for:");
  197. +       hildon_picker_button_set_selector(HILDON_PICKER_BUTTON(continuous_mode_selector_button), HILDON_TOUCH_SELECTOR(cw.continuous_mode_selector));
  198. +       hildon_button_set_alignment(HILDON_BUTTON(continuous_mode_selector_button), 0, 0, 0, 0);
  199. +       set_continuous_mode(CONTINUOUS_MODE_DEFAULT);
  200. +       gtk_box_pack_start(GTK_BOX(dialog_vbox), continuous_mode_selector_button, FALSE, FALSE, 0);
  201.  
  202.         gtk_widget_show_all(dialog);
  203.         return GTK_DIALOG(dialog);
View raw paste Reply