Remove all placeholder code in HildonEntry/TextView now that it's in GTK
[hildon] / hildon / hildon-picker-dialog.c
1 /*
2  * This file is a part of hildon
3  *
4  * Copyright (C) 2005, 2008, 2009 Nokia Corporation.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version. or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20
21 /**
22  * SECTION:hildon-picker-dialog
23  * @short_description: A utility widget that shows a #HildonTouchSelector widget
24  *
25  * #HildonPickerDialog is a dialog that is used to show a
26  * #HildonTouchSelector widget and a 'Done' button to allow users to
27  * finish their selections.
28  *
29  * The #HildonPickerDialog will show a 'Done' button in case the
30  * #HildonTouchSelector allows multiple selection. The label of the
31  * button can be set using hildon_picker_dialog_set_done_label() and
32  * retrieved using hildon_picker_dialog_get_done_label()
33  *
34  * Note that in most cases developers don't need to deal directly with
35  * this widget. #HildonPickerButton is designed to pop up a
36  * #HildonPickerDialog and manage the interaction with it.
37  */
38
39 #ifdef HAVE_CONFIG_H
40 #include <config.h>
41 #endif
42
43 #include <string.h>
44 #include <stdlib.h>
45 #include <libintl.h>
46
47 #include "hildon-touch-selector.h"
48 #include "hildon-touch-selector-entry.h"
49 #include "hildon-picker-dialog.h"
50
51 #define _(String)  dgettext("hildon-libs", String)
52
53 #define HILDON_PICKER_DIALOG_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), HILDON_TYPE_PICKER_DIALOG, HildonPickerDialogPrivate))
54
55 G_DEFINE_TYPE (HildonPickerDialog, hildon_picker_dialog, HILDON_TYPE_DIALOG)
56
57 struct _HildonPickerDialogPrivate
58 {
59   GtkWidget *selector;
60   GtkWidget *button;
61
62   gulong signal_changed_id;
63   gulong signal_columns_changed_id;
64
65   gboolean center_on_show;
66   GSList *current_selection;
67   gchar *current_text;
68 };
69
70 /* properties */
71 enum
72 {
73   PROP_0,
74   PROP_DONE_BUTTON_TEXT,
75   PROP_CENTER_ON_SHOW,
76   PROP_LAST
77 };
78
79 enum
80 {
81   RESPONSE,
82   LAST_SIGNAL
83 };
84
85 #define DEFAULT_DONE_BUTTON_TEXT        _("wdgt_bd_done")
86
87 static void
88 hildon_picker_dialog_set_property               (GObject * object,
89                                                  guint prop_id,
90                                                  const GValue * value,
91                                                  GParamSpec * pspec);
92
93 static void
94 hildon_picker_dialog_get_property               (GObject * object,
95                                                  guint prop_id,
96                                                  GValue * value, GParamSpec * pspec);
97
98 static void
99 hildon_picker_dialog_finalize                   (GObject *object);
100
101 /* gtkwidget */
102 static void
103 hildon_picker_dialog_show                       (GtkWidget *widget);
104
105 static void
106 hildon_picker_dialog_realize                    (GtkWidget *widget);
107
108 static void
109 hildon_picker_dialog_size_request               (GtkWidget *widget,
110                                                  GtkRequisition *requisition);
111
112 /* private functions */
113 static gboolean
114 requires_done_button                            (HildonPickerDialog * dialog);
115
116 static void
117 prepare_action_area                             (HildonPickerDialog *dialog);
118
119 static void
120 setup_interaction_mode                          (HildonPickerDialog * dialog);
121
122 static void
123 _select_on_selector_changed_cb                  (HildonTouchSelector * dialog,
124                                                  gint column,
125                                                  gpointer data);
126
127 static gboolean
128 _hildon_picker_dialog_set_selector              (HildonPickerDialog * dialog,
129                                                  HildonTouchSelector * selector);
130
131 static void
132 _on_dialog_response                             (GtkDialog *dialog,
133                                                  gint response_id,
134                                                  gpointer data);
135
136 static void
137 _save_current_selection                         (HildonPickerDialog *dialog);
138
139 static void
140 _restore_current_selection                      (HildonPickerDialog *dialog);
141
142 static void
143 _clean_current_selection                        (HildonPickerDialog *dialog);
144
145 static guint
146 hildon_picker_dialog_get_max_height             (HildonPickerDialog *dialog);
147
148 /**********************************************************************************/
149
150 static void
151 hildon_picker_dialog_class_init (HildonPickerDialogClass * class)
152 {
153   GObjectClass *gobject_class;
154   GtkObjectClass *object_class;
155   GtkWidgetClass *widget_class;
156   GtkContainerClass *container_class;
157
158   gobject_class = (GObjectClass *) class;
159   object_class = (GtkObjectClass *) class;
160   widget_class = (GtkWidgetClass *) class;
161   container_class = (GtkContainerClass *) class;
162
163   /* GObject */
164   gobject_class->set_property = hildon_picker_dialog_set_property;
165   gobject_class->get_property = hildon_picker_dialog_get_property;
166   gobject_class->finalize = hildon_picker_dialog_finalize;
167
168   /* GtkWidget */
169   widget_class->show = hildon_picker_dialog_show;
170   widget_class->realize = hildon_picker_dialog_realize;
171   widget_class->size_request = hildon_picker_dialog_size_request,
172
173   /* HildonPickerDialog */
174   class->set_selector = _hildon_picker_dialog_set_selector;
175
176   /* signals */
177
178   /* properties */
179   /**
180    * HildonPickerDialog
181    *
182    * Button label
183    *
184    * Since: 2.2
185    */
186   g_object_class_install_property (gobject_class,
187                                    PROP_DONE_BUTTON_TEXT,
188                                    g_param_spec_string ("done-button-text",
189                                                         "Done Button Label",
190                                                         "Done Button Label",
191                                                         DEFAULT_DONE_BUTTON_TEXT,
192                                                         G_PARAM_READABLE |
193                                                         G_PARAM_WRITABLE |
194                                                         G_PARAM_CONSTRUCT));
195
196   g_object_class_install_property (gobject_class,
197                                    PROP_CENTER_ON_SHOW,
198                                    g_param_spec_boolean ("center-on-show",
199                                                          "Center on show",
200                                                          "If the dialog should center"
201                                                          " on the current selection"
202                                                          " when it is showed",
203                                                          TRUE,
204                                                          G_PARAM_READWRITE |
205                                                          G_PARAM_CONSTRUCT));
206
207   /* Using the default height, we get 5 full rows. With the header it sums 404 pixels */
208   gtk_widget_class_install_style_property (widget_class,
209                                            g_param_spec_uint
210                                            ("max-height-landscape",
211                                             "Max dialog height on landscape mode",
212                                             "Maximum dialog height on landscape mode",
213                                             0,
214                                             G_MAXUINT,
215                                             358,
216                                             G_PARAM_READWRITE));
217
218   /* Using the default height, we get 9 full rows. With the header it sums 684 pixels */
219   gtk_widget_class_install_style_property (widget_class,
220                                            g_param_spec_uint
221                                            ("max-height-portrait",
222                                             "Max dialog height on portrait mode",
223                                             "Maximum dialog height on portrait mode",
224                                             0,
225                                             G_MAXUINT,
226                                             638,
227                                             G_PARAM_READWRITE));
228
229   g_type_class_add_private (object_class, sizeof (HildonPickerDialogPrivate));
230 }
231
232
233 static void
234 hildon_picker_dialog_init (HildonPickerDialog * dialog)
235 {
236   dialog->priv = HILDON_PICKER_DIALOG_GET_PRIVATE (dialog);
237
238   dialog->priv->selector = NULL;
239   dialog->priv->button =
240     gtk_dialog_add_button (GTK_DIALOG (dialog), "", GTK_RESPONSE_OK);
241   gtk_widget_grab_default (dialog->priv->button);
242   gtk_button_set_focus_on_click (GTK_BUTTON (dialog->priv->button), FALSE);
243   gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
244
245   dialog->priv->signal_changed_id = 0;
246   dialog->priv->signal_columns_changed_id = 0;
247   dialog->priv->center_on_show = TRUE;
248   dialog->priv->current_selection = NULL;
249   dialog->priv->current_text = NULL;
250
251   g_signal_connect (G_OBJECT (dialog),
252                     "response", G_CALLBACK (_on_dialog_response),
253                     NULL);
254 }
255
256
257 static void
258 hildon_picker_dialog_set_property (GObject * object,
259                                    guint param_id,
260                                    const GValue * value, GParamSpec * pspec)
261 {
262   HildonPickerDialog *dialog;
263
264   dialog = HILDON_PICKER_DIALOG (object);
265
266   switch (param_id) {
267   case PROP_DONE_BUTTON_TEXT:
268     hildon_picker_dialog_set_done_label (HILDON_PICKER_DIALOG (object),
269                                          g_value_get_string (value));
270     break;
271   case PROP_CENTER_ON_SHOW:
272     dialog->priv->center_on_show = g_value_get_boolean (value);
273     break;
274   default:
275     G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
276     break;
277   }
278 }
279
280 static void
281 hildon_picker_dialog_get_property (GObject * object,
282                                    guint param_id,
283                                    GValue * value, GParamSpec * pspec)
284 {
285   HildonPickerDialog *dialog;
286
287   dialog = HILDON_PICKER_DIALOG (object);
288
289   switch (param_id) {
290   case PROP_DONE_BUTTON_TEXT:
291     g_value_set_string (value, hildon_picker_dialog_get_done_label (dialog));
292     break;
293   case PROP_CENTER_ON_SHOW:
294     g_value_set_boolean (value, dialog->priv->center_on_show);
295     break;
296   default:
297     G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
298     break;
299   }
300 }
301
302 static void
303 hildon_picker_dialog_finalize (GObject *object)
304 {
305   _clean_current_selection (HILDON_PICKER_DIALOG (object));
306
307   G_OBJECT_CLASS (hildon_picker_dialog_parent_class)->finalize (object);
308 }
309
310 static void
311 hildon_picker_dialog_show                       (GtkWidget *widget)
312 {
313   HildonPickerDialog *dialog = HILDON_PICKER_DIALOG (widget);
314   HildonTouchSelector *selector;
315
316   GTK_WIDGET_CLASS (hildon_picker_dialog_parent_class)->show (widget);
317
318   if (dialog->priv->center_on_show) {
319     selector = hildon_picker_dialog_get_selector (dialog);
320     hildon_touch_selector_center_on_selected (selector);
321   }
322
323   _save_current_selection (dialog);
324   prepare_action_area (dialog);
325
326 }
327
328 static void
329 hildon_picker_dialog_size_request               (GtkWidget *widget,
330                                                  GtkRequisition *requisition)
331 {
332   HildonTouchSelector *selector;
333
334   selector = hildon_picker_dialog_get_selector (HILDON_PICKER_DIALOG (widget));
335
336   if (selector) {
337     GtkRequisition child_requisition;
338     GtkRequisition optimal_requisition;
339     GtkBin *bin;
340     guint max_height;
341
342     bin = GTK_BIN (widget);
343
344     requisition->width = GTK_CONTAINER (widget)->border_width * 2;
345     /* Adding pannable container border using 4 instead of 2 */
346     requisition->height = GTK_CONTAINER (widget)->border_width * 4;
347
348     /* assure the requisition is done */
349     gtk_widget_size_request (bin->child, &child_requisition);
350
351     hildon_touch_selector_optimal_size_request (selector,
352                                                 &optimal_requisition);
353
354     requisition->width += child_requisition.width;
355
356     max_height = hildon_picker_dialog_get_max_height (HILDON_PICKER_DIALOG (widget));
357
358     requisition->height = MIN (max_height,
359                                requisition->height + optimal_requisition.height);
360   } else
361     GTK_WIDGET_CLASS (hildon_picker_dialog_parent_class)->size_request
362       (widget, requisition);
363 }
364
365 static void
366 hildon_picker_dialog_realize (GtkWidget *widget)
367 {
368   setup_interaction_mode (HILDON_PICKER_DIALOG (widget));
369
370   GTK_WIDGET_CLASS (hildon_picker_dialog_parent_class)->realize (widget);
371 }
372
373 /* ------------------------------ PRIVATE METHODS ---------------------------- */
374
375 static guint
376 hildon_picker_dialog_get_max_height             (HildonPickerDialog *dialog)
377 {
378   gboolean landscape = TRUE;
379   guint max_value = 0;
380   GdkScreen *screen = NULL;
381
382   screen = gtk_widget_get_screen (GTK_WIDGET (dialog));
383   if (screen != NULL) {
384     if (gdk_screen_get_width (screen) > gdk_screen_get_height (screen)) {
385       landscape = TRUE;
386     } else {
387       landscape = FALSE;
388     }
389   }
390
391   if (landscape) {
392     gtk_widget_style_get (GTK_WIDGET (dialog), "max-height-landscape",
393                           &max_value, NULL);
394   } else {
395     gtk_widget_style_get (GTK_WIDGET (dialog), "max-height-portrait",
396                           &max_value, NULL);
397   }
398
399   return max_value;
400 }
401
402
403 static void
404 _select_on_selector_changed_cb (HildonTouchSelector * selector,
405                                 gint column, gpointer data)
406 {
407   g_return_if_fail (HILDON_IS_PICKER_DIALOG (data));
408
409   gtk_dialog_response (GTK_DIALOG (data), GTK_RESPONSE_OK);
410 }
411
412 static gboolean
413 selection_completed (HildonPickerDialog *dialog)
414 {
415   HildonPickerDialogPrivate *priv;
416   GList *list;
417   gint i, n_cols;
418   gboolean all_selected = TRUE;
419   HildonUIMode mode = HILDON_UI_MODE_NORMAL;
420
421   priv = HILDON_PICKER_DIALOG_GET_PRIVATE (dialog);
422
423   mode = hildon_touch_selector_get_hildon_ui_mode (HILDON_TOUCH_SELECTOR (priv->selector));
424   if (mode == HILDON_UI_MODE_NORMAL) {
425     return TRUE;
426   }
427
428   n_cols = hildon_touch_selector_get_num_columns (HILDON_TOUCH_SELECTOR (priv->selector));
429   for (i = 0; i < n_cols; i++) {
430     list = hildon_touch_selector_get_selected_rows (HILDON_TOUCH_SELECTOR (priv->selector), i);
431     if (list == NULL) {
432       all_selected = FALSE;
433       break;
434     }
435     g_list_foreach (list, (GFunc)gtk_tree_path_free, NULL);
436     g_list_free (list);
437   }
438
439   return all_selected;
440 }
441
442 static void
443 _on_dialog_response                             (GtkDialog *dialog,
444                                                  gint response_id,
445                                                  gpointer data)
446 {
447   if (response_id == GTK_RESPONSE_OK) {
448     if (selection_completed (HILDON_PICKER_DIALOG (dialog)) == FALSE) {
449       g_signal_stop_emission_by_name (dialog, "response");
450     }
451   } else if (response_id == GTK_RESPONSE_DELETE_EVENT) {
452     _restore_current_selection (HILDON_PICKER_DIALOG (dialog));
453   }
454 }
455
456 static void
457 on_selector_columns_changed (HildonTouchSelector * selector, gpointer userdata)
458 {
459   HildonPickerDialog * dialog;
460
461   dialog = HILDON_PICKER_DIALOG (userdata);
462
463   prepare_action_area (dialog);
464   if (GTK_WIDGET_REALIZED (dialog)) {
465     setup_interaction_mode (dialog);
466   }
467 }
468
469 /**
470  * hildon_picker_dialog_set_done_label:
471  * @dialog: a #HildonPickerDialog
472  * @label: a string
473  *
474  * Sets a custom string to be used as the 'Done' button label in @dialog.
475  *
476  * Since: 2.2
477  **/
478 void
479 hildon_picker_dialog_set_done_label (HildonPickerDialog * dialog,
480                                      const gchar * label)
481 {
482   HildonPickerDialogPrivate *priv;
483
484   g_return_if_fail (HILDON_IS_PICKER_DIALOG (dialog));
485   g_return_if_fail (label != NULL);
486
487   priv = HILDON_PICKER_DIALOG_GET_PRIVATE (dialog);
488
489   gtk_button_set_label (GTK_BUTTON (priv->button), label);
490 }
491
492 /**
493  * hildon_picker_dialog_get_done_label:
494  * @dialog: a #HildonPickerDialog
495  *
496  * Retrieves current 'Done' button label.
497  *
498  * Returns: the custom string to be used.
499  *
500  * Since: 2.2
501  **/
502 const gchar *
503 hildon_picker_dialog_get_done_label (HildonPickerDialog * dialog)
504 {
505   HildonPickerDialogPrivate *priv;
506
507   g_return_val_if_fail (HILDON_IS_PICKER_DIALOG (dialog), NULL);
508
509   priv = HILDON_PICKER_DIALOG_GET_PRIVATE (dialog);
510
511   return gtk_button_get_label (GTK_BUTTON (priv->button));
512 }
513
514 static void
515 free_path_list (GList *list)
516 {
517   g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL);
518   g_list_free (list);
519 }
520
521 static void
522 _clean_current_selection (HildonPickerDialog *dialog)
523 {
524   if (dialog->priv->current_selection) {
525     g_slist_foreach (dialog->priv->current_selection, (GFunc) free_path_list, NULL);
526     g_slist_free (dialog->priv->current_selection);
527     dialog->priv->current_selection = NULL;
528   }
529   if (dialog->priv->current_text) {
530     g_free (dialog->priv->current_text);
531     dialog->priv->current_text = NULL;
532   }
533 }
534
535 static void
536 _save_current_selection (HildonPickerDialog *dialog)
537 {
538   HildonTouchSelector *selector;
539   gint i, columns;
540
541   selector = HILDON_TOUCH_SELECTOR (dialog->priv->selector);
542
543   _clean_current_selection (dialog);
544
545   columns = hildon_touch_selector_get_num_columns (selector);
546   for (i = 0; i  < columns; i++) {
547     dialog->priv->current_selection
548       = g_slist_append (dialog->priv->current_selection,
549                         hildon_touch_selector_get_selected_rows (selector, i));
550   }
551   if (HILDON_IS_TOUCH_SELECTOR_ENTRY (selector)) {
552           HildonEntry *entry = hildon_touch_selector_entry_get_entry (HILDON_TOUCH_SELECTOR_ENTRY (selector));
553           dialog->priv->current_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
554   }
555 }
556
557 static void
558 _restore_current_selection (HildonPickerDialog *dialog)
559 {
560   GSList *current_selection, *iter;
561   GList *selected, *selected_iter;
562   GtkTreePath *current_path;
563   HildonTouchSelector *selector;
564   GtkTreeModel *model;
565   GtkTreeIter tree_iter;
566   gint i;
567
568   if (dialog->priv->current_selection == NULL)
569     return;
570
571   current_selection = dialog->priv->current_selection;
572   selector = HILDON_TOUCH_SELECTOR (dialog->priv->selector);
573
574   if (hildon_touch_selector_get_num_columns (selector) !=
575       g_slist_length (current_selection)) {
576     /* We conclude that if the current selection has the same
577        numbers of columns that the selector, all this ok
578        Anyway this shouldn't happen. */
579     g_critical ("Trying to restore the selection on a selector after change"
580                 " the number of columns. Are you removing columns while the"
581                 " dialog is open?");
582     return;
583   }
584
585   if (dialog->priv->signal_changed_id)
586     g_signal_handler_block (selector, dialog->priv->signal_changed_id);
587   for (iter = current_selection, i = 0; iter; iter = g_slist_next (iter), i++) {
588     selected = (GList *) (iter->data);
589     model = hildon_touch_selector_get_model (selector, i);
590     hildon_touch_selector_unselect_all (selector, i);
591     for (selected_iter = selected; selected_iter; selected_iter = g_list_next (selected_iter)) {
592       current_path = (GtkTreePath *) selected_iter->data;
593       gtk_tree_model_get_iter (model, &tree_iter, current_path);
594       hildon_touch_selector_select_iter (selector, i, &tree_iter, FALSE);
595     }
596   }
597   if (HILDON_IS_TOUCH_SELECTOR_ENTRY (selector) && dialog->priv->current_text != NULL) {
598     HildonEntry *entry = hildon_touch_selector_entry_get_entry (HILDON_TOUCH_SELECTOR_ENTRY (selector));
599     gtk_entry_set_text (GTK_ENTRY (entry), dialog->priv->current_text);
600   }
601   if (dialog->priv->signal_changed_id)
602     g_signal_handler_unblock (selector, dialog->priv->signal_changed_id);
603 }
604
605 static gboolean
606 requires_done_button (HildonPickerDialog * dialog)
607 {
608   return hildon_touch_selector_has_multiple_selection
609     (HILDON_TOUCH_SELECTOR (dialog->priv->selector));
610 }
611
612 static void
613 prepare_action_area (HildonPickerDialog *dialog)
614 {
615   if (requires_done_button (dialog)) {
616     gtk_widget_show (GTK_DIALOG (dialog)->action_area);
617   } else {
618     gtk_widget_hide (GTK_DIALOG (dialog)->action_area);
619   }
620 }
621
622 static void
623 setup_interaction_mode (HildonPickerDialog * dialog)
624 {
625   if (dialog->priv->signal_changed_id) {
626     g_signal_handler_disconnect (dialog->priv->selector,
627                                  dialog->priv->signal_changed_id);
628   }
629
630   if (requires_done_button (dialog) == FALSE) {
631     dialog->priv->signal_changed_id =
632       g_signal_connect (G_OBJECT (dialog->priv->selector), "changed",
633                         G_CALLBACK (_select_on_selector_changed_cb), dialog);
634   }
635 }
636
637 /*------------------------- PUBLIC METHODS ---------------------------- */
638
639 /**
640  * hildon_picker_dialog_new:
641  * @parent: the parent window
642  *
643  * Creates a new #HildonPickerDialog
644  *
645  * Returns: a new #HildonPickerDialog
646  *
647  * Since: 2.2
648  **/
649 GtkWidget *
650 hildon_picker_dialog_new (GtkWindow * parent)
651 {
652   GtkDialog *dialog = NULL;
653
654   dialog = g_object_new (HILDON_TYPE_PICKER_DIALOG, NULL);
655
656   if (parent) {
657     gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
658   }
659
660   return GTK_WIDGET (dialog);
661 }
662
663
664 static gboolean
665 _hildon_picker_dialog_set_selector (HildonPickerDialog * dialog,
666                                     HildonTouchSelector * selector)
667 {
668   g_object_ref (selector);
669
670   /* Remove the old selector, if any */
671   if (dialog->priv->selector != NULL) {
672     gtk_container_remove (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
673                           dialog->priv->selector);
674     if (dialog->priv->signal_columns_changed_id) {
675             g_signal_handler_disconnect (dialog->priv->selector,
676                                          dialog->priv->signal_columns_changed_id);
677     }
678   }
679
680   dialog->priv->selector = GTK_WIDGET (selector);
681
682   /* Pack the new selector */
683   gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
684                       dialog->priv->selector, TRUE, TRUE, 0);
685
686   g_object_unref (selector);
687
688   gtk_widget_show (dialog->priv->selector);
689
690   prepare_action_area (dialog);
691   if (GTK_WIDGET_REALIZED (dialog)) {
692     setup_interaction_mode (dialog);
693   }
694
695   dialog->priv->signal_columns_changed_id = g_signal_connect (G_OBJECT (dialog->priv->selector),
696                                                               "columns-changed",
697                                                               G_CALLBACK (on_selector_columns_changed), dialog);
698   return TRUE;
699 }
700
701 /**
702  * hildon_picker_dialog_set_selector:
703  * @dialog: a #HildonPickerDialog
704  * @selector: a #HildonTouchSelector
705  *
706  * Sets @selector as the #HildonTouchSelector to be shown in @dialog
707  *
708  * Returns: %TRUE if @selector was set, %FALSE otherwise
709  *
710  * Since: 2.2
711  **/
712 gboolean
713 hildon_picker_dialog_set_selector (HildonPickerDialog * dialog,
714                                    HildonTouchSelector * selector)
715 {
716   g_return_val_if_fail (HILDON_IS_PICKER_DIALOG (dialog), FALSE);
717   g_return_val_if_fail (HILDON_IS_TOUCH_SELECTOR (selector), FALSE);
718
719   return HILDON_PICKER_DIALOG_GET_CLASS (dialog)->set_selector (dialog, selector);
720 }
721
722 /**
723  * hildon_picker_dialog_get_selector:
724  * @dialog: a #HildonPickerDialog
725  *
726  * Retrieves the #HildonTouchSelector associated to @dialog.
727  *
728  * Returns: a #HildonTouchSelector
729  *
730  * Since: 2.2
731  **/
732 HildonTouchSelector *
733 hildon_picker_dialog_get_selector (HildonPickerDialog * dialog)
734 {
735   g_return_val_if_fail (HILDON_IS_PICKER_DIALOG (dialog), NULL);
736
737   return HILDON_TOUCH_SELECTOR (dialog->priv->selector);
738 }