| 1 |
/***************************************************************************** |
| 2 |
* |
| 3 |
* cdebconf - An implementation of the Debian Configuration Management |
| 4 |
* System |
| 5 |
* |
| 6 |
* cdebconf is (c) 2000-2007 Randolph Chung and others under the following |
| 7 |
* license. |
| 8 |
* |
| 9 |
* Redistribution and use in source and binary forms, with or without |
| 10 |
* modification, are permitted provided that the following conditions |
| 11 |
* are met: |
| 12 |
* |
| 13 |
* 1. Redistributions of source code must retain the above copyright |
| 14 |
* notice, this list of conditions and the following disclaimer. |
| 15 |
* |
| 16 |
* 2. Redistributions in binary form must reproduce the above copyright |
| 17 |
* notice, this list of conditions and the following disclaimer in the |
| 18 |
* documentation and/or other materials provided with the distribution. |
| 19 |
* |
| 20 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND |
| 21 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 22 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 23 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
| 24 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 25 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 26 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 27 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 28 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 29 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 30 |
* SUCH DAMAGE. |
| 31 |
* |
| 32 |
*****************************************************************************/ |
| 33 |
|
| 34 |
/** @file choice_model.h |
| 35 |
* wrapper around GtkTreeModel for choice based question handlers (header) |
| 36 |
* @internal |
| 37 |
*/ |
| 38 |
|
| 39 |
#ifndef _CHOICE_MODEL_H_ |
| 40 |
#define _CHOICE_MODEL_H_ |
| 41 |
|
| 42 |
#include <stdarg.h> |
| 43 |
#include <gtk/gtk.h> |
| 44 |
|
| 45 |
#include "frontend.h" |
| 46 |
#include "question.h" |
| 47 |
|
| 48 |
GtkTreeModel * cdebconf_gtk_choice_model_create(struct frontend * obj, |
| 49 |
struct question * question); |
| 50 |
|
| 51 |
/** A function that determines if the given choice should be considered |
| 52 |
* as the parent of the next choices while constructing the model. |
| 53 |
* |
| 54 |
* @param index index of the examined choice |
| 55 |
* @param choice canonical value of the examined choice |
| 56 |
* @param translated_choice translated value of the examined choice |
| 57 |
* @return TRUE if the choice should be considered as a parent, |
| 58 |
* FALSE otherwise |
| 59 |
*/ |
| 60 |
typedef gboolean (* parent_predicate)(int index, const char * choice, |
| 61 |
const char * translated_choice); |
| 62 |
|
| 63 |
GtkTreeModel * cdebconf_gtk_choice_model_create_full( |
| 64 |
struct frontend * obj, struct question * question, |
| 65 |
parent_predicate is_parent); |
| 66 |
|
| 67 |
GtkTreePath * cdebconf_gtk_choice_model_find_value( |
| 68 |
GtkTreeModel * model, const char * searched_value); |
| 69 |
|
| 70 |
GtkTreePath * cdebconf_gtk_choice_model_get_first_selected( |
| 71 |
GtkTreeModel * model); |
| 72 |
|
| 73 |
guint cdebconf_gtk_choice_model_get_length(GtkTreeModel * model); |
| 74 |
|
| 75 |
void cdebconf_gtk_choice_model_set(GtkTreeModel * model, |
| 76 |
GtkTreeIter * iter, ...); |
| 77 |
|
| 78 |
/** Names for the columns in the model. |
| 79 |
*/ |
| 80 |
enum { |
| 81 |
/* index of the choice */ |
| 82 |
CHOICE_MODEL_INDEX, |
| 83 |
/* has the choice been selected */ |
| 84 |
CHOICE_MODEL_SELECTED, |
| 85 |
/* canonical value of the choice */ |
| 86 |
CHOICE_MODEL_VALUE, |
| 87 |
/* translated value of the choice */ |
| 88 |
CHOICE_MODEL_TRANSLATED_VALUE, |
| 89 |
/* total number of columns in the model */ |
| 90 |
CHOICE_MODEL_COLUMN_COUNT |
| 91 |
}; |
| 92 |
|
| 93 |
#endif /* !_CHOICE_MODEL_H_ */ |
| 94 |
|
| 95 |
/* vim et sw=4 si |
| 96 |
*/ |