Statistics
| Revision:

root / src / progressdialog.c @ 1

History | View | Annotate | Download (3.99 KB)

1
/*
2
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3
 * Copyright (C) 1999-2001 Hiroyuki Yamamoto
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
 */
19

    
20
#ifdef HAVE_CONFIG_H
21
#  include "config.h"
22
#endif
23

    
24
#include <glib.h>
25
#include <gtk/gtkwindow.h>
26
#include <gtk/gtkvbox.h>
27
#include <gtk/gtkhbox.h>
28
#include <gtk/gtklabel.h>
29
#include <gtk/gtkprogressbar.h>
30
#include <gtk/gtkscrolledwindow.h>
31
#include <gtk/gtkbutton.h>
32

    
33
#include "intl.h"
34
#include "progressdialog.h"
35
#include "gtkutils.h"
36
#include "utils.h"
37

    
38
ProgressDialog *progress_dialog_create(void)
39
{
40
        ProgressDialog *progress;
41
        GtkWidget *window;
42
        GtkWidget *vbox;
43
        GtkWidget *hbox;
44
        GtkWidget *label;
45
        GtkWidget *cancel_btn;
46
        GtkWidget *cancel_area;
47
        GtkWidget *progressbar;
48
        GtkWidget *scrolledwin;
49
        GtkWidget *clist;
50
        gchar *text[] = {NULL, NULL, NULL};
51

    
52
        text[1] = _("Account");
53
        text[2] = _("Status");
54

    
55
        debug_print(_("Creating progress dialog...\n"));
56
        progress = g_new0(ProgressDialog, 1);
57

    
58
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
59
        gtk_widget_set_size_request(window, 460, -1);
60
        gtk_container_set_border_width(GTK_CONTAINER(window), 8);
61
        gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
62
        gtk_window_set_policy(GTK_WINDOW(window), FALSE, TRUE, TRUE);
63
        gtk_widget_realize(window);
64

    
65
        vbox = gtk_vbox_new(FALSE, 8);
66
        gtk_container_add(GTK_CONTAINER(window), vbox);
67
        gtk_widget_show(vbox);
68

    
69
        hbox = gtk_hbox_new(FALSE, 0);
70
        gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 8);
71
        gtk_widget_show(hbox);
72

    
73
        label = gtk_label_new("");
74
        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 8);
75
        gtk_widget_show(label);
76

    
77
        gtkut_button_set_create(&cancel_area, &cancel_btn, _("Cancel"),
78
                                NULL, NULL, NULL, NULL);
79
        gtk_box_pack_end(GTK_BOX(vbox), cancel_area, FALSE, FALSE, 0);
80
        gtk_widget_grab_default(cancel_btn);
81
        gtk_widget_show_all(cancel_area);
82

    
83
        progressbar = gtk_progress_bar_new();
84
        gtk_box_pack_start(GTK_BOX(vbox), progressbar, FALSE, FALSE, 0);
85
        gtk_widget_show(progressbar);
86

    
87
        scrolledwin = gtk_scrolled_window_new(NULL, NULL);
88
        gtk_widget_show(scrolledwin);
89
        gtk_box_pack_start(GTK_BOX(vbox), scrolledwin, TRUE, TRUE, 0);
90
        gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
91
                                       GTK_POLICY_AUTOMATIC,
92
                                       GTK_POLICY_AUTOMATIC);
93

    
94
        clist = gtk_clist_new_with_titles(3, text);
95
        gtk_widget_show(clist);
96
        gtk_container_add(GTK_CONTAINER(scrolledwin), clist);
97
        gtk_widget_set_size_request(clist, -1, 120);
98
        gtk_clist_set_column_justification(GTK_CLIST(clist), 0,
99
                                           GTK_JUSTIFY_CENTER);
100
        gtk_clist_set_column_width(GTK_CLIST(clist), 0, 16);
101
        gtk_clist_set_column_width(GTK_CLIST(clist), 1, 160);
102

    
103
        progress->window      = window;
104
        progress->label       = label;
105
        progress->cancel_btn  = cancel_btn;
106
        progress->progressbar = progressbar;
107
        progress->clist       = clist;
108

    
109
        return progress;
110
}
111

    
112
void progress_dialog_set_label(ProgressDialog *progress, gchar *str)
113
{
114
        gtk_label_set_text(GTK_LABEL(progress->label), str);
115
}
116

    
117
void progress_dialog_set_value(ProgressDialog *progress, gfloat value)
118
{
119
        gtk_progress_set_value(GTK_PROGRESS(progress->progressbar), value);
120
}
121

    
122
void progress_dialog_set_percentage(ProgressDialog *progress,
123
                                    gfloat percentage)
124
{
125
        gtk_progress_set_percentage(GTK_PROGRESS(progress->progressbar),
126
                                    percentage);
127
}
128

    
129
void progress_dialog_destroy(ProgressDialog *progress)
130
{
131
        if (progress) {
132
                gtk_widget_destroy(progress->window);
133
                g_free(progress);
134
        }
135
}