* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; version 2.1 of
- * the License.
+ * the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
/**
* SECTION:hildon-sort-dialog
- * @short_description: A widget for defining the sorting order of items
+ * @short_description: A widget for defining the sorting order of items.
*
* HildonSortDialog is used to define an order (ascending/descending)
* and a field by which items are sorted in a list. The combo boxes
* display the current value when the dialog is opened.
+ *
+ * <example>
+ * <title>An example for using HildonSortDialog</title>
+ * <programlisting>
+ * HildonSortDialog *sort_dialog = HILDON_SORT_DIALOG (hildon_sort_dialog_new (parent));
+ * <!-- -->
+ * gint response_id, add_sort_index;
+ * <!-- -->
+ * sort_by[0] = STR_SORT_BY_DATE;
+ * sort_by[1] = STR_SORT_BY_NAME;
+ * sort_by[2] = STR_SORT_BY_SIZE;
+ * sort_by[3] = NULL;
+ * <!-- -->
+ * sorting_order[0] = STR_SORTING_ORDER_ASCENDING;
+ * sorting_order[1] = STR_SORTING_ORDER_DESCENDING;
+ * sorting_order[2] = NULL;
+ * <!-- -->
+ * add_sort_index = hildon_sort_dialog_add_sort_key (sort_dialog, STR_SORT_BY_DATE);
+ * <!-- -->
+ * hildon_sort_dialog_add_sort_key (sort_dialog, STR_SORT_BY_NAME);
+ * <!-- -->
+ * hildon_sort_dialog_add_sort_key (sort_dialog, STR_SORT_BY_SIZE);
+ * <!-- -->
+ * if (dialog.first_time_clicked == TRUE)
+ * {
+ * hildon_sort_dialog_set_sort_key (sort_dialog, add_sort_index);
+ * }
+ * <!-- -->
+ * if (dialog.first_time_clicked == FALSE)
+ * {
+ * hildon_sort_dialog_set_sort_key (sort_dialog, dialog.sort_key);
+ * hildon_sort_dialog_set_sort_order (sort_dialog, dialog.sort_order);
+ * }
+ * <!-- -->
+ * gtk_widget_show (GTK_WIDGET (sort_dialog));
+ * <!-- -->
+ * response_id = gtk_dialog_run (GTK_DIALOG (sort_dialog));
+ * <!-- -->
+ * if (response_id == GTK_RESPONSE_OK)
+ * {
+ * dialog.sort_key = hildon_sort_dialog_get_sort_key (sort_dialog);
+ * <!-- -->
+ * gtk_label_set_text (GTK_LABEL (dialog.label1), sort_by [dialog.sort_key]);
+ * <!-- -->
+ * dialog.sort_order = hildon_sort_dialog_get_sort_order (sort_dialog);
+ * <!-- -->
+ * gtk_label_set_text (GTK_LABEL (dialog.label2), sorting_order [dialog.sort_order]);
+ * <!-- -->
+ * dialog.first_time_clicked = FALSE;
+ * }
+ * </programlisting>
+ * </example>
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include "hildon-sort-dialog.h"
#include <stdio.h>
#include <libintl.h>
-#include <gtk/gtkcombobox.h>
-#include <gtk/gtkbox.h>
+
+#include "hildon-sort-dialog.h"
#include "hildon-caption.h"
#include "hildon-sort-dialog-private.h"
static void
hildon_sort_dialog_finalize (GObject *object);
+static gint
+hildon_sort_dialog_add_sort_key_with_sorting (HildonSortDialog *dialog,
+ const gchar *sort_key,
+ gboolean sorting);
+
enum
{
PROP_0,
priv->reversed = priv->key_reversed [index];
}
-/*
- * Initialises the sort dialog class.
- */
+/* Initialises the sort dialog class. */
static void
hildon_sort_dialog_class_init (HildonSortDialogClass *class)
{
gobject_class->set_property = hildon_sort_dialog_set_property;
gobject_class->get_property = hildon_sort_dialog_get_property;
gobject_class->finalize = (gpointer) hildon_sort_dialog_finalize;
-
+
+ /**
+ * HildonSortDialog:sort-key:
+ *
+ * The currently active sort key.
+ */
g_object_class_install_property (gobject_class, PROP_SORT_KEY,
g_param_spec_int ("sort-key",
"Sort Key",
"The currently active sort key",
- G_MININT,
- G_MAXINT,
+ G_MININT,
+ G_MAXINT,
0, G_PARAM_READWRITE));
-
+
+ /**
+ * HildonSortDialog:sort-order:
+ *
+ * The sort order for the currently active sort key.
+ */
g_object_class_install_property (gobject_class, PROP_SORT_ORDER,
g_param_spec_enum ("sort-order",
"Sort Order",
"The current sorting order",
- GTK_TYPE_SORT_TYPE,
+ GTK_TYPE_SORT_TYPE,
GTK_SORT_ASCENDING,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE));
}
-gint
+static gint
hildon_sort_dialog_add_sort_key_with_sorting (HildonSortDialog *dialog,
const gchar *sort_key,
gboolean sorting)
* Returns: HildonSortDialog type
*/
GType G_GNUC_CONST
-hildon_sort_dialog_get_type ()
+hildon_sort_dialog_get_type (void)
{
static GType dialog_type = 0;