go.c File Reference

GO support for the GTK+ frontend of cdebconf. More...

#include "go.h"
#include <string.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "frontend.h"
#include "question.h"
#include "template.h"
#include "plugin.h"
#include "database.h"
#include "fe_gtk.h"
#include "fe_data.h"
#include "ui.h"
#include "handlers.h"
#include "select_handlers.h"
#include "progress.h"
#include "di.h"

Include dependency graph for go.c:

Go to the source code of this file.

Data Structures

struct  setter
 Store callbacks from question handlers run after "Continue". More...

Functions

void fe_gtk_register_setter (struct frontend *fe, setter_function func, struct question *question, void *user_data)
 Register the given setter.
static void call_setters (struct frontend *fe)
 Call all registered setters.
static void free_setters (struct frontend_data *fe_data)
 Free all registered setters.
static gboolean handle_goback_key (GtkWidget *widget, GdkEventKey *key, struct frontend *fe)
 Key event handler implementing the "Go Back" key shortcut.
static void create_goback_button (struct frontend *fe)
 Create the "Go Back" button.
GtkWidget * fe_gtk_create_continue_button (struct frontend *fe)
 Create the "Continue" button.
static void create_default_buttons_if_needed (struct frontend *fe)
 Create default buttons if no other buttons has been added to the action box.
static void destroy_buttons (struct frontend *fe)
 Destroy all buttons in the main action box.
static fe_gtk_handler find_internal_handler (const char *type)
 Find a internal handler for the given question type.
static fe_gtk_handler find_external_handler (struct frontend *fe, const char *type)
 Find an external handler (plugin) for the given question type.
static void update_question_database (struct frontend *fe)
 Update the question database with the value currently set to each questions referenced by the frontend.
static gboolean call_question_handlers (struct frontend *fe, GtkWidget *question_box)
 Call the relevant handlers for every questions currently referenced by the frontend.
static GtkWidget * create_question_box (struct frontend *fe, GtkWidget *container)
 Create the container for question widgets in the given container.
static void wait_answer (struct frontend *fe)
 Wait for an answer to be set asynchronously, either by a button or a key shortcut.
int fe_gtk_go (struct frontend *fe)
 Implements the "go" method of cdebconf frontends.

Variables

struct {
   const char *   type
 Question type.
   fe_gtk_handler   handler
 Handler function for the corresponding type.
question_handlers []
 List of internal question handlers.


Detailed Description

GO support for the GTK+ frontend of cdebconf.

Definition in file go.c.


Function Documentation

static gboolean call_question_handlers ( struct frontend *  fe,
GtkWidget *  question_box 
) [static]

Call the relevant handlers for every questions currently referenced by the frontend.

Handlers are expected to add their widgets in the given question box.

Parameters:
fe cdebconf frontend
question_box container for question handler widgets
Returns:
FALSE if an error happened, TRUE otherwise

Definition at line 322 of file go.c.

References find_external_handler(), find_internal_handler(), and handler.

Referenced by fe_gtk_go().

static void call_setters ( struct frontend *  fe  )  [static]

Call all registered setters.

Parameters:
fe cdebconf frontend

Definition at line 111 of file go.c.

References setter::func, setter::next, setter::question, frontend_data::setters, and setter::user_data.

Referenced by fe_gtk_go().

static void create_default_buttons_if_needed ( struct frontend *  fe  )  [static]

Create default buttons if no other buttons has been added to the action box.

Default buttons currently means the "Continue" button.

Parameters:
fe cdebconf frontend

Definition at line 209 of file go.c.

References frontend_data::action_box, and fe_gtk_create_continue_button().

Referenced by fe_gtk_go().

static void create_goback_button ( struct frontend *  fe  )  [static]

Create the "Go Back" button.

The button will be added to the main action box.

Parameters:
fe cdebconf frontend

Definition at line 164 of file go.c.

References fe_gtk_add_button(), fe_gtk_add_global_key_handler(), fe_gtk_get_text(), fe_gtk_set_answer_goback(), fe_gtk_set_button_secondary(), and handle_goback_key().

Referenced by fe_gtk_go().

static GtkWidget* create_question_box ( struct frontend *  fe,
GtkWidget *  container 
) [static]

Create the container for question widgets in the given container.

This will add the question box to the container on top of returning it.

The actual container will vary if GO has been called for only one question or more: since all widgets used to display single questions have native scrolling capabilities or do not need scrolling (too small) they can manage scrolling be autonomously.

Vice-versa the most simple approach when displaying multiple questions togheter (whose handling wigets haven't native scrolling capabilities) is to pack them all inside a viewport.

Todo:
This currently breaks the focus chain for widgets not currently shown by the viewports. Not sure on how to fix that correctly.
Parameters:
fe cdebconf frontend
container the container in which the question box will be added
Returns:
the newly created question box

Definition at line 367 of file go.c.

References DEFAULT_PADDING, and IS_QUESTION_SINGLE.

Referenced by fe_gtk_go().

static void destroy_buttons ( struct frontend *  fe  )  [static]

Destroy all buttons in the main action box.

Parameters:
fe cdebconf frontend

Definition at line 223 of file go.c.

References frontend_data::action_box.

Referenced by fe_gtk_go().

GtkWidget* fe_gtk_create_continue_button ( struct frontend *  fe  ) 

Create the "Continue" button.

The button will be added to the main action box on top of being returned. This also a specific question handler to have more control over the button during the input.

Parameters:
fe cdebconf frontend
Returns:
the newly created "Continue" button

Definition at line 183 of file go.c.

References fe_gtk_add_button(), fe_gtk_get_text(), and fe_gtk_set_answer_ok().

Referenced by create_default_buttons_if_needed().

int fe_gtk_go ( struct frontend *  fe  ) 

Implements the "go" method of cdebconf frontends.

The processing is currently divided into three stages:

If a progress was running, the widgets are hidden at the beginning of the procedure.

Parameters:
fe cdebconf frontend
Returns:
the debconf status corresponding to user actions

Definition at line 438 of file go.c.

References frontend_data::answer, call_question_handlers(), call_setters(), CAN_GO_BACK, create_default_buttons_if_needed(), create_goback_button(), create_question_box(), DC_NO_ANSWER, destroy_buttons(), fe_gtk_di_run_dialog(), fe_gtk_empty_target_box(), fe_gtk_hide_progress(), fe_gtk_set_answer(), fe_gtk_set_buttons_sensitive(), fe_gtk_show_buttons(), fe_gtk_show_target_box(), free_setters(), frontend_data::progress_data, frontend_data::target_box, update_question_database(), and wait_answer().

void fe_gtk_register_setter ( struct frontend *  fe,
setter_function  func,
struct question *  question,
void *  user_data 
)

Register the given setter.

The setter will be prepended to the setters list.

Parameters:
fe cdebconf frontend
func function updating the debconf database with user input
question question that will be updated
user_data question handler private data

Definition at line 92 of file go.c.

References frontend_data::setters.

Referenced by create_multiselect_checkboxes(), create_multiselect_list(), create_select_combo(), create_select_list(), fe_gtk_handle_password(), fe_gtk_handle_string(), and handle_boolean_radio().

static fe_gtk_handler find_external_handler ( struct frontend *  fe,
const char *  type 
) [static]

Find an external handler (plugin) for the given question type.

This will save the plugin in a cache for future use.

Parameters:
fe cdebconf frontend
type the question type
Returns:
the corresponding handler if found, NULL otherwise
See also:
frontend_data::plugins

Definition at line 277 of file go.c.

References frontend_data::plugins.

Referenced by call_question_handlers().

static fe_gtk_handler find_internal_handler ( const char *  type  )  [static]

Find a internal handler for the given question type.

Parameters:
type the question type
Returns:
the corresponding handler if found, NULL otherwise

Definition at line 256 of file go.c.

References handler, and question_handlers.

Referenced by call_question_handlers().

static void free_setters ( struct frontend_data fe_data  )  [static]

Free all registered setters.

Parameters:
fe_data the GTK+ frontend data

Definition at line 127 of file go.c.

References setter::next, and frontend_data::setters.

Referenced by fe_gtk_go().

static gboolean handle_goback_key ( GtkWidget *  widget,
GdkEventKey *  key,
struct frontend *  fe 
) [static]

Key event handler implementing the "Go Back" key shortcut.

Parameters:
widget main window
key pressed key
fe cdebconf frontend
Returns:
TRUE if "Go Back" shortcut has been pressed, FALSE otherwise

Definition at line 148 of file go.c.

References fe_gtk_set_answer_goback().

Referenced by create_goback_button().

static void update_question_database ( struct frontend *  fe  )  [static]

Update the question database with the value currently set to each questions referenced by the frontend.

Parameters:
fe cdebconf frontend

Definition at line 302 of file go.c.

Referenced by fe_gtk_go().

static void wait_answer ( struct frontend *  fe  )  [static]

Wait for an answer to be set asynchronously, either by a button or a key shortcut.

Parameters:
fe cdebconf frontend
See also:
fe_data::answer

Definition at line 405 of file go.c.

References frontend_data::answer, frontend_data::answer_cond, frontend_data::answer_mutex, and DC_NO_ANSWER.

Referenced by fe_gtk_go().


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