2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2001 Hiroyuki Yamamoto
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.
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.
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.
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>
34 #include "progressdialog.h"
38 ProgressDialog *progress_dialog_create(void)
40 ProgressDialog *progress;
45 GtkWidget *cancel_btn;
46 GtkWidget *cancel_area;
47 GtkWidget *progressbar;
48 GtkWidget *scrolledwin;
50 gchar *text[] = {NULL, NULL, NULL};
52 text[1] = _("Account");
53 text[2] = _("Status");
55 debug_print(_("Creating progress dialog...\n"));
56 progress = g_new0(ProgressDialog, 1);
58 window = gtk_window_new(GTK_WINDOW_DIALOG);
59 gtk_widget_set_usize(window, 450, -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);
65 vbox = gtk_vbox_new(FALSE, 8);
66 gtk_container_add(GTK_CONTAINER(window), vbox);
67 gtk_widget_show(vbox);
69 hbox = gtk_hbox_new(FALSE, 0);
70 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 8);
71 gtk_widget_show(hbox);
73 label = gtk_label_new("");
74 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 8);
75 gtk_widget_show(label);
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);
83 progressbar = gtk_progress_bar_new();
84 gtk_box_pack_start(GTK_BOX(vbox), progressbar, FALSE, FALSE, 0);
85 gtk_widget_show(progressbar);
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),
92 GTK_POLICY_AUTOMATIC);
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_usize(clist, -1, 120);
98 gtk_clist_set_column_justification(GTK_CLIST(clist), 0,
100 gtk_clist_set_column_width(GTK_CLIST(clist), 0, 16);
101 gtk_clist_set_column_width(GTK_CLIST(clist), 1, 180);
103 progress->window = window;
104 progress->label = label;
105 progress->cancel_btn = cancel_btn;
106 progress->progressbar = progressbar;
107 progress->clist = clist;
112 void progress_dialog_set_label(ProgressDialog *progress, gchar *str)
114 gtk_label_set_text(GTK_LABEL(progress->label), str);
117 void progress_dialog_set_value(ProgressDialog *progress, gfloat value)
119 gtk_progress_set_value(GTK_PROGRESS(progress->progressbar), value);
122 void progress_dialog_set_percentage(ProgressDialog *progress,
125 gtk_progress_set_percentage(GTK_PROGRESS(progress->progressbar),
129 void progress_dialog_destroy(ProgressDialog *progress)
132 gtk_widget_destroy(progress->window);