progress.c File Reference

progress bar support for the GTK+ frontend of cdebconf More...

#include "progress.h"
#include <string.h>
#include <glib.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include "frontend.h"
#include "fe_gtk.h"
#include "fe_data.h"
#include "ui.h"
#include "di.h"

Include dependency graph for progress.c:

Go to the source code of this file.

Data Structures

struct  progress_data
 Internal data for progress bar support. More...

Defines

#define PROGRESSBAR_HPADDING   60
 Horizontal padding of the progress bar.
#define PROGRESSBAR_VPADDING   60
 Vertical padding of the progress bar.

Functions

static void create_progress_bar (struct progress_data *progress_data, GtkWidget *container)
 Create the progress bar widget in the given container.
static void destroy_progress_bar (struct progress_data *progress_data)
 Unference the progress bar.
static void create_progress_label (struct progress_data *progress_data, GtkWidget *container)
 Create the label widget in the given container.
static void destroy_progress_label (struct progress_data *progress_data)
 Unreference the label.
static void create_progress_box (struct progress_data *progress_data)
 Create the container including the progress bar and the associated information label.
static void destroy_progress_box (struct progress_data *progress_data)
 Unreference the container with the progress bar and the associated label.
void fe_gtk_show_progress (struct frontend *fe)
 Show the progress widgets.
void fe_gtk_hide_progress (struct frontend *fe)
 Hide the progress widgets.
static gboolean handle_cancel_key (GtkWidget *widget, GdkEventKey *key, struct frontend *fe)
 Key event handler implementing the "Cancel" key shortcut.
static void create_cancel_button (struct progress_data *progress_data)
 Create the "Cancel" button.
static void destroy_cancel_button (struct progress_data *progress_data)
 Unreference and destroy the "Cancel" button.
bool fe_gtk_can_cancel_progress (struct frontend *fe)
 Implements the can_cancel_progress method of cdebconf frontends.
static gboolean init_progress (struct frontend *fe)
 Init progress handling.
static void destroy_progress (struct frontend *fe)
 Destroy the progress handling widgets and data structures.
static void update_progress_bar (struct frontend *fe, gdouble fraction)
 Update the progress bar filling and title.
void fe_gtk_progress_start (struct frontend *fe, int min, int max, const char *title)
 Implements the progress_start method of cdebconf frontends.
int fe_gtk_progress_set (struct frontend *fe, int val)
 Implements the progress_set methods of cdebconf frontends.
int fe_gtk_progress_info (struct frontend *fe, const char *info)
 Implements the progress_info method of cdebconf frontends.
void fe_gtk_progress_stop (struct frontend *fe)
 Implements the progress_stop method of cdebconf frontends.


Detailed Description

progress bar support for the GTK+ frontend of cdebconf

Definition in file progress.c.


Function Documentation

static void create_cancel_button ( struct progress_data progress_data  )  [static]

Create the "Cancel" button.

Parameters:
progress_data progress data
See also:
frontend_data::action_box

Definition at line 286 of file progress.c.

References progress_data::cancel_button, progress_data::fe, fe_gtk_add_button(), fe_gtk_add_global_key_handler(), fe_gtk_get_text(), fe_gtk_set_answer_goback(), and handle_cancel_key().

Referenced by init_progress().

static void create_progress_bar ( struct progress_data progress_data,
GtkWidget *  container 
) [static]

Create the progress bar widget in the given container.

Parameters:
progress_data progress data
container the container where will be added the progress bar

Definition at line 90 of file progress.c.

References progress_data::progress_bar.

Referenced by create_progress_box().

static void create_progress_box ( struct progress_data progress_data  )  [static]

Create the container including the progress bar and the associated information label.

Parameters:
progress_data progress data

Definition at line 172 of file progress.c.

References create_progress_bar(), create_progress_label(), fe_gtk_center_widget(), progress_data::progress_box, PROGRESSBAR_HPADDING, and PROGRESSBAR_VPADDING.

Referenced by init_progress().

static void create_progress_label ( struct progress_data progress_data,
GtkWidget *  container 
) [static]

Create the label widget in the given container.

Parameters:
progress_data progress data
container the container where the label will be added

Definition at line 131 of file progress.c.

References DEFAULT_PADDING, and progress_data::progress_label.

Referenced by create_progress_box().

static void destroy_cancel_button ( struct progress_data progress_data  )  [static]

Unreference and destroy the "Cancel" button.

Parameters:
progress_data progress data

Definition at line 310 of file progress.c.

References progress_data::cancel_button.

Referenced by destroy_progress().

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

Destroy the progress handling widgets and data structures.

Parameters:
fe cdebconf frontend

Definition at line 364 of file progress.c.

References destroy_cancel_button(), destroy_progress_box(), and frontend_data::progress_data.

Referenced by fe_gtk_progress_stop().

static void destroy_progress_bar ( struct progress_data progress_data  )  [static]

Unference the progress bar.

The container has to take care of destroying the widget.

Parameters:
progress_data progress data

Definition at line 115 of file progress.c.

References progress_data::progress_bar.

Referenced by destroy_progress_box().

static void destroy_progress_box ( struct progress_data progress_data  )  [static]

Unreference the container with the progress bar and the associated label.

This will take care of destroying the label and the progress bar widgets.

Parameters:
progress_data progress data

Definition at line 196 of file progress.c.

References destroy_progress_bar(), destroy_progress_label(), and progress_data::progress_box.

Referenced by destroy_progress().

static void destroy_progress_label ( struct progress_data progress_data  )  [static]

Unreference the label.

The container has to take care of destroying the widget.

Parameters:
progress_data progress data

Definition at line 156 of file progress.c.

References progress_data::progress_label.

Referenced by destroy_progress_box().

bool fe_gtk_can_cancel_progress ( struct frontend *  fe  ) 

Implements the can_cancel_progress method of cdebconf frontends.

Parameters:
fe cdebconf frontend
Returns:
TRUE if progress bar can be canceled

Definition at line 326 of file progress.c.

void fe_gtk_hide_progress ( struct frontend *  fe  ) 

Hide the progress widgets.

This will actually remove the widgets from their respective containers in order to leave the room for GO handling.

Parameters:
fe cdebconf frotend
See also:
fe_gtk_show_progress

Definition at line 245 of file progress.c.

References progress_data::cancel_button, progress_data::progress_box, frontend_data::progress_data, and frontend_data::target_box.

Referenced by fe_gtk_go().

int fe_gtk_progress_info ( struct frontend *  fe,
const char *  info 
)

Implements the progress_info method of cdebconf frontends.

This will update the progress label.

Parameters:
fe cdebconf frontend
info current information about the operation in progress
See also:
progress_data::progress_label

Definition at line 488 of file progress.c.

References frontend_data::answer, DC_NO_ANSWER, frontend_data::progress_data, and progress_data::progress_label.

int fe_gtk_progress_set ( struct frontend *  fe,
int  val 
)

Implements the progress_set methods of cdebconf frontends.

Parameters:
fe cdebconf frontend
val current value representing the operation in progress
Returns:
DC_GOBACK if progress was canceled, DC_NOTOK if error happened and DC_OK otherwise.

Definition at line 453 of file progress.c.

References frontend_data::answer, fe_gtk_show_progress(), frontend_data::progress_data, and update_progress_bar().

void fe_gtk_progress_start ( struct frontend *  fe,
int  min,
int  max,
const char *  title 
)

Implements the progress_start method of cdebconf frontends.

Parameters:
fe cdebconf frontend
min minimum value representing the operation in progress
max maximum value representing the operation in progress
title initial title of the operation in progress

Definition at line 405 of file progress.c.

References DC_NO_ANSWER, fe_gtk_di_run_dialog(), fe_gtk_progress_stop(), fe_gtk_set_answer(), fe_gtk_show_progress(), init_progress(), frontend_data::progress_data, frontend_data::setters, and update_progress_bar().

void fe_gtk_progress_stop ( struct frontend *  fe  ) 

Implements the progress_stop method of cdebconf frontends.

This will destroy the widgets and data structures.

Parameters:
fe cdebconf frontend

Definition at line 517 of file progress.c.

References destroy_progress(), and frontend_data::progress_data.

Referenced by destroy_frontend_data(), and fe_gtk_progress_start().

void fe_gtk_show_progress ( struct frontend *  fe  ) 

Show the progress widgets.

This will actually add the widgets to the corresponding containers.

Parameters:
fe cdebconf frontend
See also:
fe_gtk_hide_progress

Definition at line 216 of file progress.c.

References frontend_data::action_box, progress_data::cancel_button, DEFAULT_PADDING, progress_data::progress_box, frontend_data::progress_data, and frontend_data::target_box.

Referenced by fe_gtk_progress_set(), and fe_gtk_progress_start().

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

Key event handler implementing the "Cancel" key shortcut.

Parameters:
widget main window
key the pressed key
fe cdebconf frontend
Returns:
TRUE if "Cancel" was handled, FALSE otherwise

Definition at line 271 of file progress.c.

References fe_gtk_set_answer_goback().

Referenced by create_cancel_button().

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

Init progress handling.

This will create the private data structure and the necessary widgets.

Parameters:
fe cdebconf frontend
Returns:
TRUE if initialization was successful, FALSE otherwise

Definition at line 339 of file progress.c.

References CAN_CANCEL_PROGRESS, create_cancel_button(), create_progress_box(), and frontend_data::progress_data.

Referenced by fe_gtk_progress_start().

static void update_progress_bar ( struct frontend *  fe,
gdouble  fraction 
) [static]

Update the progress bar filling and title.

The title will be taken from the progress_title field of the frontend.

Parameters:
fe cdebconf frontend
fraction progress bar filling value

Definition at line 385 of file progress.c.

References progress_data::progress_bar, and frontend_data::progress_data.

Referenced by fe_gtk_progress_set(), and fe_gtk_progress_start().


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