fe_gtk.c File Reference

"Main" file for the GTK+ frontend of cdebconf. More...

#include <syslog.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <signal.h>
#include <string.h>
#include <errno.h>
#include "common.h"
#include "template.h"
#include "question.h"
#include "frontend.h"
#include "database.h"
#include "plugin.h"
#include "strutl.h"
#include "fe_gtk.h"
#include "fe_data.h"
#include "handlers.h"
#include "select_handlers.h"
#include "descriptions.h"
#include "progress.h"
#include "go.h"
#include "ui.h"
#include "di.h"

Include dependency graph for fe_gtk.c:

Go to the source code of this file.

Functions

char * fe_gtk_get_text (struct frontend *fe, const char *template, const char *fallback)
 Get the description of a given template.
static void * handle_gtk_events (void *dummy)
 A GThreadFunc calling the GTK+ main loop.
gboolean fe_gtk_is_first_question (struct question *question)
 Determines if a question is the first question requiring user input of the current question row.
void fe_gtk_force_quit (struct frontend *fe)
 Force cdebconf to quit.
static void destroy_frontend_data (struct frontend *fe)
 De-allocate and de-init all elements of the GTK+ frontend data.
static gboolean create_frontend_data (struct frontend *fe)
 Allocate and initialize non-graphical elements of the GTK+ frontend.
static int fe_gtk_shutdown (struct frontend *fe)
 Implements the shutdown method of cdebconf frontends.
static void show_main_window (struct frontend *fe)
 Show the GTK+ frontend window.
int fe_gtk_get_answer (struct frontend *fe)
 Get the pending debconf answer in a thread-safe way.
void fe_gtk_set_answer (struct frontend *fe, int answer)
 Set the pending debconf answer in a thread-safe way.
void fe_gtk_set_answer_ok (struct frontend *fe)
 Set the pending debconf answer to DC_OK.
void fe_gtk_set_answer_notok (struct frontend *fe)
 Set the pending debconf answer to DC_NOTOK.
void fe_gtk_set_answer_goback (struct frontend *fe)
 Set the pending debconf answer to DC_GOBACK.
static gboolean create_event_listener_thread (struct frontend *fe)
 Create the event listener thread.
static int fe_gtk_initialize (struct frontend *fe, struct configuration *conf)
 Implements the initialize method of cdebconf frontends.
static void fe_gtk_set_title (struct frontend *fe, const char *title)
 Implements the set_title method of cdebconf frontends.
static bool fe_gtk_can_go_back (struct frontend *fe, struct question *question)
 Implements the can_go_back function of cdebconf frontends.
static unsigned long fe_gtk_query_capability (struct frontend *fe)
 Implements the query_capability function of cdebconf frontends.

Variables

frontend_module debconf_frontend_module
 Describe our frontend implementation to cdebconf.


Detailed Description

"Main" file for the GTK+ frontend of cdebconf.

Definition in file fe_gtk.c.


Function Documentation

static gboolean create_event_listener_thread ( struct frontend *  fe  )  [static]

Create the event listener thread.

Parameters:
fe cdebconf frontend
Returns:
FALSE in case of errors, TRUE otherwise
See also:
handle_gtk_events()

Definition at line 306 of file fe_gtk.c.

References frontend_data::event_listener, and handle_gtk_events().

Referenced by fe_gtk_initialize().

static gboolean create_frontend_data ( struct frontend *  fe  )  [static]

Allocate and initialize non-graphical elements of the GTK+ frontend.

The data field of the given frontend will be set to the newly allocated structure.

Parameters:
fe cdebconf frontend
See also:
frontend_data

Definition at line 184 of file fe_gtk.c.

References frontend_data::answer_cond, frontend_data::answer_mutex, destroy_frontend_data(), and frontend_data::plugins.

Referenced by fe_gtk_initialize().

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

De-allocate and de-init all elements of the GTK+ frontend data.

Parameters:
fe cdebconf frontend

Definition at line 143 of file fe_gtk.c.

References frontend_data::action_box, fe_gtk_progress_stop(), fe_gtk_set_answer_notok(), frontend_data::plugins, frontend_data::target_box, frontend_data::title, and frontend_data::window.

Referenced by create_frontend_data(), and fe_gtk_shutdown().

static bool fe_gtk_can_go_back ( struct frontend *  fe,
struct question *  question 
) [static]

Implements the can_go_back function of cdebconf frontends.

Parameters:
fe cdebconf frontend
question question which needs to be backed up
Returns:
TRUE if backup is possible, FALSE otherwise

Definition at line 401 of file fe_gtk.c.

void fe_gtk_force_quit ( struct frontend *  fe  ) 

Force cdebconf to quit.

This function is currently used when the main window is closed.

It is implemented by sending a TERM signal to the current process,

Parameters:
fe cdebconf frontend

Definition at line 132 of file fe_gtk.c.

Referenced by handle_closed_main_window().

int fe_gtk_get_answer ( struct frontend *  fe  ) 

Get the pending debconf answer in a thread-safe way.

Parameters:
fe cdebconf frontend
Returns:
the current answer

Definition at line 260 of file fe_gtk.c.

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

char* fe_gtk_get_text ( struct frontend *  fe,
const char *  template,
const char *  fallback 
)

Get the description of a given template.

The caller is responsible to free the returned string.

Todo:
There is no real reason that we can't use question_get_text defined in cdebconf except that question_get_text doesn't strdup the fallback string. This means than there is no way to have correct memory management. question_get_text should be fixed and this function removed from the GTK+ frontend.
Parameters:
fe cdebconf frontend
template template name
fallback fallback string when the template does not exists
Returns:
a newly allocated string containing the description of the template or a copy of fallback if the template was not found

Definition at line 84 of file fe_gtk.c.

Referenced by create_cancel_button(), create_dialog_action_box(), create_goback_button(), fe_gtk_create_continue_button(), get_text_direction(), handle_boolean_buttons(), handle_boolean_radio(), and popup_success().

static int fe_gtk_initialize ( struct frontend *  fe,
struct configuration *  conf 
) [static]

Implements the initialize method of cdebconf frontends.

This will initialize the GTK+ frontend data, the GTK+ window and common widgets and forks the event handling thread.

Returns:
DC_OK if initialization goes fine, DC_NOTOK if something went wrong

Definition at line 331 of file fe_gtk.c.

References create_event_listener_thread(), create_frontend_data(), fe_gtk_create_main_window(), fe_gtk_di_setup(), fe_gtk_shutdown(), and show_main_window().

gboolean fe_gtk_is_first_question ( struct question *  question  ) 

Determines if a question is the first question requiring user input of the current question row.

Parameters:
question question that will be tested
Returns:
TRUE if the question is the first question requiring user input

Definition at line 116 of file fe_gtk.c.

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

static unsigned long fe_gtk_query_capability ( struct frontend *  fe  )  [static]

Implements the query_capability function of cdebconf frontends.

Parameters:
fe cdebconf frontend
Returns:
capability flags

Definition at line 412 of file fe_gtk.c.

void fe_gtk_set_answer ( struct frontend *  fe,
int  answer 
)

Set the pending debconf answer in a thread-safe way.

Parameters:
fe cdebconf frontend
answer the new answer value

Definition at line 272 of file fe_gtk.c.

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

Referenced by fe_gtk_go(), fe_gtk_progress_start(), fe_gtk_set_answer_goback(), fe_gtk_set_answer_notok(), and fe_gtk_set_answer_ok().

void fe_gtk_set_answer_goback ( struct frontend *  fe  ) 

Set the pending debconf answer to DC_GOBACK.

This function is provided by convenience as a possible argument for g_signal_connect_swapped().

Parameters:
fe cdebconf frontend

Definition at line 295 of file fe_gtk.c.

References fe_gtk_set_answer().

Referenced by create_cancel_button(), create_goback_button(), handle_cancel_key(), and handle_goback_key().

void fe_gtk_set_answer_notok ( struct frontend *  fe  ) 

Set the pending debconf answer to DC_NOTOK.

This function is provided by convenience as a possible argument for g_signal_connect_swapped().

Parameters:
fe cdebconf frontend

Definition at line 289 of file fe_gtk.c.

References fe_gtk_set_answer().

Referenced by destroy_frontend_data().

void fe_gtk_set_answer_ok ( struct frontend *  fe  ) 

Set the pending debconf answer to DC_OK.

This function is provided by convenience as a possible argument for g_signal_connect_swapped().

Parameters:
fe cdebconf frontend

Definition at line 283 of file fe_gtk.c.

References fe_gtk_set_answer().

Referenced by create_select_list(), fe_gtk_create_continue_button(), handle_false_button(), and handle_true_button().

static void fe_gtk_set_title ( struct frontend *  fe,
const char *  title 
) [static]

Implements the set_title method of cdebconf frontends.

When build for the debian-installer, this will only update the corresponding fields in frontend data. The title widget will then be updated by fe_gtk_di_run_dialog() on the next GO or progress start.

Parameters:
fe cdebconf frontend
title new frontend title

Definition at line 384 of file fe_gtk.c.

References fe_gtk_update_frontend_title().

static int fe_gtk_shutdown ( struct frontend *  fe  )  [static]

Implements the shutdown method of cdebconf frontends.

Parameters:
fe cdebconf frontend

Definition at line 226 of file fe_gtk.c.

References destroy_frontend_data(), frontend_data::event_listener, fe_gtk_destroy_main_window(), and fe_gtk_di_shutdown().

Referenced by fe_gtk_initialize().

static void* handle_gtk_events ( void *  dummy  )  [static]

A GThreadFunc calling the GTK+ main loop.

This function will be run in another thread and will happily process GTK+ events resulting in user interaction.

Parameters:
dummy an unused parameter
Returns:
always return NULL

Definition at line 101 of file fe_gtk.c.

Referenced by create_event_listener_thread().

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

Show the GTK+ frontend window.

Parameters:
fe cdebconf frontend

Definition at line 250 of file fe_gtk.c.

References frontend_data::window.

Referenced by fe_gtk_initialize().


Variable Documentation

struct frontend_module debconf_frontend_module

Initial value:

 {
    initialize: fe_gtk_initialize,
    shutdown: fe_gtk_shutdown,
    can_go_back: fe_gtk_can_go_back,
    query_capability: fe_gtk_query_capability,
    set_title: fe_gtk_set_title,
    
    go: fe_gtk_go,
    
    can_cancel_progress: fe_gtk_can_cancel_progress,
    progress_start: fe_gtk_progress_start,
    progress_info: fe_gtk_progress_info,
    progress_set: fe_gtk_progress_set,
    progress_stop: fe_gtk_progress_stop,
}
Describe our frontend implementation to cdebconf.

Definition at line 419 of file fe_gtk.c.


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