choice_model.c File Reference

wrapper around GtkTreeModel for choice based question handlers More...

#include "choice_model.h"
#include <string.h>
#include <gtk/gtk.h>
#include "frontend.h"
#include "question.h"
#include "strutl.h"

Include dependency graph for choice_model.c:

Go to the source code of this file.

Data Structures

struct  search_result
 Internal data structure used by fe_gtk_choice_model_find_value(). More...

Functions

static gboolean is_searched_value (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, struct search_result *result)
 GtkTreeModelForeachFunc used by fe_gtk_choice_model_find_value().
GtkTreePath * fe_gtk_choice_model_find_value (GtkTreeModel *model, const char *searched_value)
 Search for a given value in a model.
GtkTreeModel * fe_gtk_choice_model_create_full (struct frontend *fe, struct question *question, parent_predicate is_parent)
 Full interface to create a tree model from a given question.
GtkTreeModel * fe_gtk_choice_model_create (struct frontend *fe, struct question *question)
 Create a one level model for a given question.
static gboolean increment_model_length (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, guint *length)
 GtkTreeModelForeachFunc used by fe_gtk_choice_model_get_length().
guint fe_gtk_choice_model_get_length (GtkTreeModel *model)
 Get the total number of choices in the given model.
static gboolean is_selected (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, GtkTreePath **result)
 GtkTreeModelForeachFunc used by fe_gtk_choice_model_get_first_selected().
GtkTreePath * fe_gtk_choice_model_get_first_selected (GtkTreeModel *model)
 Get the first selected choice in the given model.
void fe_gtk_choice_model_set (GtkTreeModel *model, GtkTreeIter *iter,...)
 Set a given row in the model.


Detailed Description

wrapper around GtkTreeModel for choice based question handlers

For internal use only.

Definition in file choice_model.c.


Function Documentation

GtkTreeModel* fe_gtk_choice_model_create ( struct frontend *  fe,
struct question *  question 
)

Create a one level model for a given question.

Parameters:
fe cdebconf frontend
question a select or multiselect question
Returns:
a newly created model or NULL in case of errors

Definition at line 222 of file choice_model.c.

References fe_gtk_choice_model_create_full().

Referenced by handle_all().

GtkTreeModel* fe_gtk_choice_model_create_full ( struct frontend *  fe,
struct question *  question,
parent_predicate  is_parent 
)

Full interface to create a tree model from a given question.

Parameters:
fe cdebconf frontend
question select or multiselect question
is_parent helper determining if a choice is the parent of the next choices
Returns:
the newly created model or NULL in case of errors
See also:
parent_predicate

Definition at line 113 of file choice_model.c.

References fe_gtk_choice_model_find_value(), and path.

Referenced by create_select_list(), and fe_gtk_choice_model_create().

GtkTreePath* fe_gtk_choice_model_find_value ( GtkTreeModel *  model,
const char *  searched_value 
)

Search for a given value in a model.

The allocated GtkTreePath must be freed by the caller.

Parameters:
model model to be searched
searched_value value to be found
Returns:
the path to the value when found, NULL otherwise

Definition at line 91 of file choice_model.c.

References is_searched_value(), search_result::path, and search_result::searched_value.

Referenced by fe_gtk_choice_model_create_full().

GtkTreePath* fe_gtk_choice_model_get_first_selected ( GtkTreeModel *  model  ) 

Get the first selected choice in the given model.

The returned path must be free'd by the caller.

Parameters:
model searched model
Returns:
path to the first selected value or NULL if no value is selected

Definition at line 291 of file choice_model.c.

References is_selected().

Referenced by create_select_list(), and set_selected_active().

guint fe_gtk_choice_model_get_length ( GtkTreeModel *  model  ) 

Get the total number of choices in the given model.

Parameters:
model measured model
Returns:
total number of choices in the given model

Definition at line 250 of file choice_model.c.

References increment_model_length().

Referenced by create_multiselect_checkboxes(), and set_value_from_multiselect().

void fe_gtk_choice_model_set ( GtkTreeModel *  model,
GtkTreeIter *  iter,
  ... 
)

Set a given row in the model.

This function has the same interface than gtk_tree_store_set(), and the same effect. It is just here to abstract over the GtkTreeModel implementation used for choice models.

Parameters:
model the model to modify
iter position in the model

Definition at line 309 of file choice_model.c.

Referenced by update_selection_for_toggle().

static gboolean increment_model_length ( GtkTreeModel *  model,
GtkTreePath *  path,
GtkTreeIter *  iter,
guint *  length 
) [static]

GtkTreeModelForeachFunc used by fe_gtk_choice_model_get_length().

Parameters:
model traversed model
path path of the current value
iter iter pointing to the current value
length current known size of the model
Returns:
FALSE in any case. :)

Definition at line 237 of file choice_model.c.

Referenced by fe_gtk_choice_model_get_length().

static gboolean is_searched_value ( GtkTreeModel *  model,
GtkTreePath *  path,
GtkTreeIter *  iter,
struct search_result result 
) [static]

GtkTreeModelForeachFunc used by fe_gtk_choice_model_find_value().

Parameters:
model searched model
path path of the current value
iter iter pointing to the current value
result search result structure
Returns:
TRUE when the data has been found, FALSE otherwise

Definition at line 68 of file choice_model.c.

References search_result::path, and search_result::searched_value.

Referenced by fe_gtk_choice_model_find_value().

static gboolean is_selected ( GtkTreeModel *  model,
GtkTreePath *  path,
GtkTreeIter *  iter,
GtkTreePath **  result 
) [static]

GtkTreeModelForeachFunc used by fe_gtk_choice_model_get_first_selected().

Parameters:
model searched model
path path of the current value
iter iter pointing to the current value
result search result structure
Returns:
TRUE when a selected choice has been found, FALSE otherwise

Definition at line 269 of file choice_model.c.

Referenced by fe_gtk_choice_model_get_first_selected().


Generated on Sat Jul 7 23:41:41 2007 for fe_gtk by  doxygen 1.5.1