[maemo-commits] [maemo-commits] r12491 - in projects/haf/trunk/hildon-plugins-settings: . src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Tue Jun 26 18:16:42 EEST 2007
- Previous message: [maemo-commits] r12490 - in projects/haf/trunk/hildon-desktop: . src
- Next message: [maemo-commits] r12492 - projects/haf/trunk/hildon-desktop/src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: moimart Date: 2007-06-26 18:16:31 +0300 (Tue, 26 Jun 2007) New Revision: 12491 Modified: projects/haf/trunk/hildon-plugins-settings/ChangeLog projects/haf/trunk/hildon-plugins-settings/src/hildon-plugin-settings-dialog.c projects/haf/trunk/hildon-plugins-settings/src/hildon-plugin-settings-dialog.h projects/haf/trunk/hildon-plugins-settings/src/hildon-plugin-settings.c Log: 2007-06-26 Moises Martinez <moises.martinez at nokia.com> * src/hildon-plugin-settings-dialog.[ch]: - Added method to set limit of items for a container. - Implemented limitation of selected items. * src/hildon-plugin-settings.c: - Set limit to 3 items for Tasknavigator. * ChangeLog updated. Modified: projects/haf/trunk/hildon-plugins-settings/ChangeLog =================================================================== --- projects/haf/trunk/hildon-plugins-settings/ChangeLog 2007-06-26 14:31:49 UTC (rev 12490) +++ projects/haf/trunk/hildon-plugins-settings/ChangeLog 2007-06-26 15:16:31 UTC (rev 12491) @@ -1,3 +1,11 @@ +2007-06-26 Moises Martinez <moises.martinez at nokia.com> + + * src/hildon-plugin-settings-dialog.[ch]: + - Added method to set limit of items for a container. + - Implemented limitation of selected items. + * src/hildon-plugin-settings.c: + - Set limit to 3 items for Tasknavigator. + 2007-06-18 Moises Martinez <moises.martinez at nokia.com> * src/hildon-plugin-config-parser.[ch]: Modified: projects/haf/trunk/hildon-plugins-settings/src/hildon-plugin-settings-dialog.c =================================================================== --- projects/haf/trunk/hildon-plugins-settings/src/hildon-plugin-settings-dialog.c 2007-06-26 14:31:49 UTC (rev 12490) +++ projects/haf/trunk/hildon-plugins-settings/src/hildon-plugin-settings-dialog.c 2007-06-26 15:16:31 UTC (rev 12491) @@ -68,6 +68,7 @@ #define HILDON_PLUGIN_SETTINGS_DIALOG_GET_PRIVATE(object) \ (G_TYPE_INSTANCE_GET_PRIVATE ((object), HILDON_PLUGIN_TYPE_SETTINGS_DIALOG, HildonPluginSettingsDialogPrivate)) + G_DEFINE_TYPE (HildonPluginSettingsDialog, hildon_plugin_settings_dialog, GTK_TYPE_DIALOG); typedef struct @@ -77,6 +78,8 @@ GtkTreeView *tw; GtkTreeModel *filter; gboolean is_sorted; + gint limit; + guint counter_limit; } HPSDTab; @@ -184,6 +187,34 @@ } +static void +hildon_plugin_settings_dialog_check_limits (GtkTreeView *tw, HPSDTab *tab) +{ + gboolean selected; + GtkTreeIter iter; + GtkTreeModel *tm; /* We shouldn't care about whether we use a filter or not + we want to check the limits according what user sees + */ + + tm = gtk_tree_view_get_model (tw); + + gtk_tree_model_get_iter_first (tm, &iter); + + do + { + gtk_tree_model_get (tm, &iter, + HP_COL_CHECKBOX, &selected, + -1); + + if (selected) + tab->counter_limit++; + } + while (gtk_tree_model_iter_next (tm, &iter)); + + if (tab->counter_limit > 0) + tab->limit = tab->counter_limit; +} + static GObject * hildon_plugin_settings_dialog_constructor (GType gtype, guint n_params, @@ -285,6 +316,11 @@ tab->tw = GTK_TREE_VIEW (tw); + g_object_set_data (G_OBJECT (tw), "tab-data", tab); + + if (tab->limit != HPSD_NO_LIMIT) + hildon_plugin_settings_dialog_check_limits (GTK_TREE_VIEW (tw), tab); + hildon_plugin_settings_dialog_fill_treeview (settings, GTK_TREE_VIEW (tw)); gtk_container_add (GTK_CONTAINER (scrolled_window), tw); @@ -642,6 +678,8 @@ tab->tw = NULL; tab->filter = NULL; tab->is_sorted = is_sorted; + tab->limit = HPSD_NO_LIMIT; + tab->counter_limit = 0; /*Note to myself: create the damned _new function!!! */ g_free (path_to_save); @@ -714,6 +752,7 @@ GtkTreeIter iter; gboolean selected; GtkTreeModel *tm = gtk_tree_view_get_model (tw); + HPSDTab *tab = NULL; if (!gtk_tree_model_get_iter_from_string (tm, &iter, path)) return; @@ -721,6 +760,20 @@ gtk_tree_model_get (tm, &iter, HP_COL_CHECKBOX, &selected, -1); + + tab = g_object_get_data (G_OBJECT (tw),"tab-data"); + + if (tab && tab->limit != HPSD_NO_LIMIT) + { + if (!selected && tab->counter_limit >= tab->limit) + return; + else + if (tab->counter_limit <= tab->limit) + tab->counter_limit = (!selected) ? tab->counter_limit + 1: tab->counter_limit - 1; + + if (tab->counter_limit < 0) + tab->counter_limit = 0; + } if (GTK_IS_TREE_MODEL_FILTER (tm)) { @@ -790,6 +843,29 @@ return names; } +void +hildon_plugin_settings_dialog_set_choosing_limit (HildonPluginSettingsDialog *settings, + const gchar *container_name, + gint limit) +{ + GList *container_tab = NULL; + + + container_tab = + g_list_find_custom (settings->priv->tabs, + container_name, + (GCompareFunc)hildon_plugin_settings_dialog_compare_tab); + + if (!container_tab) + return; + + HPSDTab *tab = (HPSDTab *)container_tab->data; + + tab->limit = limit; + + hildon_plugin_settings_dialog_check_limits (tab->tw, tab); +} + GtkTreeModel * hildon_plugin_settings_dialog_set_visibility_filter (HildonPluginSettingsDialog *settings, const gchar *container_name, Modified: projects/haf/trunk/hildon-plugins-settings/src/hildon-plugin-settings-dialog.h =================================================================== --- projects/haf/trunk/hildon-plugins-settings/src/hildon-plugin-settings-dialog.h 2007-06-26 14:31:49 UTC (rev 12490) +++ projects/haf/trunk/hildon-plugins-settings/src/hildon-plugin-settings-dialog.h 2007-06-26 15:16:31 UTC (rev 12491) @@ -36,6 +36,8 @@ #define HILDON_PLUGIN_SETTINGS_DIALOG_TYPE_DIALOG TRUE #define HILDON_PLUGIN_SETTINGS_DIALOG_TYPE_WINDOW FALSE +#define HPSD_NO_LIMIT -1 + typedef enum { HPSD_COLUMN_PB, @@ -92,6 +94,11 @@ GList * hildon_plugin_settings_dialog_get_container_names (HildonPluginSettingsDialog *settings); + +void +hildon_plugin_settings_dialog_set_choosing_limit (HildonPluginSettingsDialog *settings, + const gchar *container_name, + gint limit); GtkTreeModel * hildon_plugin_settings_dialog_set_visibility_filter (HildonPluginSettingsDialog *settings, const gchar *container_name, Modified: projects/haf/trunk/hildon-plugins-settings/src/hildon-plugin-settings.c =================================================================== --- projects/haf/trunk/hildon-plugins-settings/src/hildon-plugin-settings.c 2007-06-26 14:31:49 UTC (rev 12490) +++ projects/haf/trunk/hildon-plugins-settings/src/hildon-plugin-settings.c 2007-06-26 15:16:31 UTC (rev 12491) @@ -89,39 +89,6 @@ } -static void -_tn_cell_selection_data_func (GtkTreeViewColumn *tc, - GtkCellRenderer *cell, - GtkTreeModel *tm, - GtkTreeIter *iter, - gpointer data) -{ - GtkTreeIter _iter; - guint selection = 0; - gboolean toggled; - GtkTreeModel *real_tm = GTK_IS_TREE_MODEL_FILTER (tm) ? - gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (tm)) : - tm; - - gtk_tree_model_get_iter_first (real_tm, &_iter); - - do - { - gtk_tree_model_get (real_tm, &_iter, - HP_COL_CHECKBOX, &toggled, - -1); - - if (toggled) - selection++; - } - while (gtk_tree_model_iter_next (real_tm, &_iter)); - - g_debug ("selection %d", selection); - - if (selection >= TN_MAX_ITEMS) - { - } -} osso_return_t execute (osso_context_t *osso, gpointer user_data, @@ -154,13 +121,10 @@ NULL, NULL); - hildon_plugin_settings_dialog_set_cell_data_func + hildon_plugin_settings_dialog_set_choosing_limit (HILDON_PLUGIN_SETTINGS_DIALOG (dialog), - HPSD_COLUMN_TOGGLE, "Tasknavigator", - _tn_cell_selection_data_func, - NULL, - NULL); + 3); gtk_widget_show (dialog);
- Previous message: [maemo-commits] r12490 - in projects/haf/trunk/hildon-desktop: . src
- Next message: [maemo-commits] r12492 - projects/haf/trunk/hildon-desktop/src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]