Yattm - unified GTK instant-messaging client logo
   [Generated for version 0.2-17 - Mon Jan 6 19:01:23 GMT+1 2003]

Home - Main Page - Data Structures - File List - Data Fields - Globals

progress_window.c File Reference

#include "intl.h"
#include <gtk/gtk.h>
#include <string.h>
#include "progress_window.h"

Include dependency graph for progress_window.c:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  progress_window_data

Functions

void destroy (GtkWidget *widget, gpointer data)
int progress_window_new (char *filename, unsigned long size)
void update_progress (int tag, unsigned long progress)
void progress_window_close (int tag)

Variables

GList * bars = NULL
int last = 0


Function Documentation

void destroy GtkWidget *    widget,
gpointer    data
[static]
 

Definition at line 44 of file progress_window.c.

References bars, and last.

Referenced by progress_window_new().

00045 {
00046     progress_window_data * pwd = data;
00047     GList * l;
00048 
00049     for(l = bars; l; l = l->next)
00050     {
00051         if(pwd == l->data) {
00052             bars = g_list_remove_link(bars, l);
00053             g_free(pwd);
00054 
00055             /* small hack - reset last if there are no more bars */
00056             if(bars == NULL)
00057                 last = 0;
00058 
00059             break;
00060         }
00061     }
00062 }

void progress_window_close int    tag
 

Definition at line 115 of file progress_window.c.

References bars, progress_window_data::progress_window, and progress_window_data::tag.

Referenced by accept_file(), get_file2(), and update_send_progress().

00116 {
00117     GList * l;
00118     for(l = bars; l; l=l->next)
00119     {
00120         progress_window_data * pwd = l->data;
00121         if(pwd->tag == tag) {
00122             gtk_widget_destroy(pwd->progress_window);
00123             break;
00124         }
00125     }
00126 }

int progress_window_new char *    filename,
unsigned long    size
 

Definition at line 64 of file progress_window.c.

References _, bars, destroy(), last, progress_window_data::progress_meter, progress_window_data::progress_window, progress_window_data::size, and progress_window_data::tag.

Referenced by get_file(), and send_file().

00065 {
00066     progress_window_data *pwd = g_new0(progress_window_data, 1);
00067     
00068     GtkWidget * vbox = gtk_vbox_new( FALSE, 5);
00069     GtkWidget * label;
00070     gchar buff[2048];
00071 
00072     pwd->size = size;
00073     pwd->tag = ++last;
00074 
00075     g_snprintf( buff, sizeof(buff), _("Transfering %s"), filename);
00076     label = gtk_label_new(buff);
00077 
00078     gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 5);
00079     gtk_widget_show(label);
00080 
00081     pwd->progress_meter = gtk_progress_bar_new();
00082     gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(pwd->progress_meter), 
00083             GTK_PROGRESS_LEFT_TO_RIGHT );
00084 
00085     gtk_box_pack_start(GTK_BOX(vbox),pwd->progress_meter, TRUE, TRUE, 5);
00086     gtk_widget_show(pwd->progress_meter);
00087 
00088     pwd->progress_window = gtk_window_new(GTK_WINDOW_DIALOG);
00089     gtk_window_set_position(GTK_WINDOW(pwd->progress_window), GTK_WIN_POS_MOUSE);
00090     gtk_container_add(GTK_CONTAINER(pwd->progress_window), vbox);
00091         gtk_signal_connect( GTK_OBJECT(pwd->progress_window), "destroy",
00092                             GTK_SIGNAL_FUNC(destroy), pwd );
00093 
00094     gtk_widget_show(vbox);
00095     gtk_widget_show(pwd->progress_window);
00096 
00097     bars = g_list_append(bars, pwd);
00098 
00099     return pwd->tag;
00100 }

void update_progress int    tag,
unsigned long    progress
 

Definition at line 102 of file progress_window.c.

References bars, progress_window_data::progress_meter, progress_window_data::size, and progress_window_data::tag.

Referenced by get_file2(), and update_send_progress().

00103 {
00104     GList * l;
00105     for(l = bars; l; l=l->next)
00106     {
00107         progress_window_data * pwd = l->data;
00108         if(pwd->tag == tag) {
00109             gtk_progress_bar_update(GTK_PROGRESS_BAR(pwd->progress_meter), ((float)progress)/((float)pwd->size));
00110             break;
00111         }
00112     }
00113 }


Variable Documentation

GList* bars = NULL [static]
 

Definition at line 41 of file progress_window.c.

Referenced by destroy(), progress_window_close(), progress_window_new(), and update_progress().

int last = 0 [static]
 

Definition at line 42 of file progress_window.c.

Referenced by destroy(), and progress_window_new().


Contact: Andy Maloney     [Documentation generated by doxygen]