aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-06-08 09:36:09 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-06-08 09:36:09 +0000
commit7931ec60671f8c66c9bcca030fb510180975765e (patch)
tree7edf1de25689e4cea1232081d924a81819d94d1a
parent34aaba6028b814cb6e0902e03382c3afcb209251 (diff)
reimplemented progress dialog with GtkTreeView.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@321 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog7
-rw-r--r--ChangeLog.ja7
-rw-r--r--src/inc.c68
-rw-r--r--src/progressdialog.c159
-rw-r--r--src/progressdialog.h43
-rw-r--r--src/send_message.c14
6 files changed, 229 insertions, 69 deletions
diff --git a/ChangeLog b/ChangeLog
index f3da3607..59b46104 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2005-06-08
+ * src/inc.c
+ src/send_message.c
+ src/progressdialog.[ch]: reimplemented progress dialog with
+ GtkTreeView. Added some APIs.
+
+2005-06-08
+
* sylpheed.spec.in: modified for the latest RPM (thanks to Paul
Dickson).
diff --git a/ChangeLog.ja b/ChangeLog.ja
index 2c1f7c58..eb2b918c 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,5 +1,12 @@
2005-06-08
+ * src/inc.c
+ src/send_message.c
+ src/progressdialog.[ch]: プログレスダイアログを GtkTreeView で
+ 再実装。いくつかの API を追加。
+
+2005-06-08
+
* sylpheed.spec.in: 最新の RPM にあわせて修正(Paul Dickson さん
thanks)。
diff --git a/src/inc.c b/src/inc.c
index de7e9e9f..aa35ebcb 100644
--- a/src/inc.c
+++ b/src/inc.c
@@ -70,12 +70,9 @@ static GList *inc_dialog_list = NULL;
static guint inc_lock_count = 0;
-static GdkPixmap *currentxpm;
-static GdkBitmap *currentxpmmask;
-static GdkPixmap *errorxpm;
-static GdkBitmap *errorxpmmask;
-static GdkPixmap *okxpm;
-static GdkBitmap *okxpmmask;
+static GdkPixbuf *current_pixbuf;
+static GdkPixbuf *error_pixbuf;
+static GdkPixbuf *ok_pixbuf;
#define MSGBUFSIZE 8192
@@ -345,13 +342,10 @@ static IncProgressDialog *inc_progress_dialog_create(gboolean autocheck)
progress_dialog_set_value(progress, 0.0);
- gtk_widget_realize(progress->clist);
- stock_pixmap_gdk(progress->clist, STOCK_PIXMAP_COMPLETE,
- &okxpm, &okxpmmask);
- stock_pixmap_gdk(progress->clist, STOCK_PIXMAP_CONTINUE,
- &currentxpm, &currentxpmmask);
- stock_pixmap_gdk(progress->clist, STOCK_PIXMAP_ERROR,
- &errorxpm, &errorxpmmask);
+ stock_pixbuf_gdk(progress->treeview, STOCK_PIXMAP_COMPLETE, &ok_pixbuf);
+ stock_pixbuf_gdk(progress->treeview, STOCK_PIXMAP_CONTINUE,
+ &current_pixbuf);
+ stock_pixbuf_gdk(progress->treeview, STOCK_PIXMAP_ERROR, &error_pixbuf);
if (prefs_common.recv_dialog_mode == RECV_DIALOG_ALWAYS ||
(prefs_common.recv_dialog_mode == RECV_DIALOG_MANUAL &&
@@ -378,14 +372,11 @@ static void inc_progress_dialog_set_list(IncProgressDialog *inc_dialog)
for (list = inc_dialog->queue_list; list != NULL; list = list->next) {
IncSession *session = list->data;
Pop3Session *pop3_session = POP3_SESSION(session->session);
- gchar *text[3];
session->data = inc_dialog;
-
- text[0] = NULL;
- text[1] = pop3_session->ac_prefs->account_name;
- text[2] = _("Standby");
- gtk_clist_append(GTK_CLIST(inc_dialog->dialog->clist), text);
+ progress_dialog_append(inc_dialog->dialog, NULL,
+ pop3_session->ac_prefs->account_name,
+ _("Standby"), NULL);
}
}
@@ -453,7 +444,6 @@ static void inc_session_destroy(IncSession *session)
static gint inc_start(IncProgressDialog *inc_dialog)
{
IncSession *session;
- GtkCList *clist = GTK_CLIST(inc_dialog->dialog->clist);
GList *qlist;
Pop3Session *pop3_session;
IncState inc_state;
@@ -502,10 +492,12 @@ static gint inc_start(IncProgressDialog *inc_dialog)
qlist = next;
}
-#define SET_PIXMAP_AND_TEXT(xpm, xpmmask, str) \
-{ \
- gtk_clist_set_pixmap(clist, inc_dialog->cur_row, 0, xpm, xpmmask); \
- gtk_clist_set_text(clist, inc_dialog->cur_row, 2, str); \
+#define SET_PIXMAP_AND_TEXT(pixbuf, str) \
+{ \
+ progress_dialog_set_row_pixbuf(inc_dialog->dialog, \
+ inc_dialog->cur_row, pixbuf); \
+ progress_dialog_set_row_status(inc_dialog->dialog, \
+ inc_dialog->cur_row, str); \
}
for (; inc_dialog->queue_list != NULL; inc_dialog->cur_row++) {
@@ -513,7 +505,7 @@ static gint inc_start(IncProgressDialog *inc_dialog)
pop3_session = POP3_SESSION(session->session);
if (pop3_session->pass == NULL) {
- SET_PIXMAP_AND_TEXT(okxpm, okxpmmask, _("Cancelled"));
+ SET_PIXMAP_AND_TEXT(ok_pixbuf, _("Cancelled"));
inc_session_destroy(session);
inc_dialog->queue_list =
g_list_remove(inc_dialog->queue_list, session);
@@ -521,10 +513,10 @@ static gint inc_start(IncProgressDialog *inc_dialog)
}
inc_progress_dialog_clear(inc_dialog);
- gtk_clist_moveto(clist, inc_dialog->cur_row, -1, 1.0, 0.0);
+ progress_dialog_scroll_to_row(inc_dialog->dialog,
+ inc_dialog->cur_row);
- SET_PIXMAP_AND_TEXT(currentxpm, currentxpmmask,
- _("Retrieving"));
+ SET_PIXMAP_AND_TEXT(current_pixbuf, _("Retrieving"));
/* begin POP3 session */
inc_state = inc_pop3_session_do(session);
@@ -538,33 +530,31 @@ static gint inc_start(IncProgressDialog *inc_dialog)
to_human_readable(pop3_session->cur_total_recv_bytes));
else
msg = g_strdup_printf(_("Done (no new messages)"));
- SET_PIXMAP_AND_TEXT(okxpm, okxpmmask, msg);
+ SET_PIXMAP_AND_TEXT(ok_pixbuf, msg);
g_free(msg);
break;
case INC_CONNECT_ERROR:
- SET_PIXMAP_AND_TEXT(errorxpm, errorxpmmask,
+ SET_PIXMAP_AND_TEXT(error_pixbuf,
_("Connection failed"));
break;
case INC_AUTH_FAILED:
- SET_PIXMAP_AND_TEXT(errorxpm, errorxpmmask,
- _("Auth failed"));
+ SET_PIXMAP_AND_TEXT(error_pixbuf, _("Auth failed"));
break;
case INC_LOCKED:
- SET_PIXMAP_AND_TEXT(errorxpm, errorxpmmask,
- _("Locked"));
+ SET_PIXMAP_AND_TEXT(error_pixbuf, _("Locked"));
break;
case INC_ERROR:
case INC_NO_SPACE:
case INC_IO_ERROR:
case INC_SOCKET_ERROR:
case INC_EOF:
- SET_PIXMAP_AND_TEXT(errorxpm, errorxpmmask, _("Error"));
+ SET_PIXMAP_AND_TEXT(error_pixbuf, _("Error"));
break;
case INC_TIMEOUT:
- SET_PIXMAP_AND_TEXT(errorxpm, errorxpmmask, _("Timeout"));
+ SET_PIXMAP_AND_TEXT(error_pixbuf, _("Timeout"));
break;
case INC_CANCEL:
- SET_PIXMAP_AND_TEXT(okxpm, okxpmmask, _("Cancelled"));
+ SET_PIXMAP_AND_TEXT(ok_pixbuf, _("Cancelled"));
break;
default:
break;
@@ -854,8 +844,8 @@ static void inc_progress_dialog_set_progress(IncProgressDialog *inc_dialog,
pop3_session->cur_total_num,
to_human_readable
(pop3_session->cur_total_recv_bytes));
- gtk_clist_set_text(GTK_CLIST(inc_dialog->dialog->clist),
- inc_dialog->cur_row, 2, buf);
+ progress_dialog_set_row_status(inc_dialog->dialog,
+ inc_dialog->cur_row, buf);
}
}
diff --git a/src/progressdialog.c b/src/progressdialog.c
index 6612430a..d1dd40ab 100644
--- a/src/progressdialog.c
+++ b/src/progressdialog.c
@@ -28,6 +28,11 @@
#include <gtk/gtklabel.h>
#include <gtk/gtkprogressbar.h>
#include <gtk/gtkscrolledwindow.h>
+#include <gtk/gtkliststore.h>
+#include <gtk/gtktreeview.h>
+#include <gtk/gtktreeselection.h>
+#include <gtk/gtkcellrendererpixbuf.h>
+#include <gtk/gtkcellrenderertext.h>
#include <gtk/gtkbutton.h>
#include <gtk/gtkstock.h>
@@ -44,11 +49,11 @@ ProgressDialog *progress_dialog_create(void)
GtkWidget *cancel_btn;
GtkWidget *progressbar;
GtkWidget *scrolledwin;
- GtkWidget *clist;
- gchar *text[] = {NULL, NULL, NULL};
-
- text[1] = _("Account");
- text[2] = _("Status");
+ GtkWidget *treeview;
+ GtkListStore *store;
+ GtkTreeSelection *selection;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
debug_print(_("Creating progress dialog...\n"));
progress = g_new0(ProgressDialog, 1);
@@ -92,25 +97,65 @@ ProgressDialog *progress_dialog_create(void)
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwin),
+ GTK_SHADOW_IN);
+
+ store = gtk_list_store_new(PROG_N_COLS, GDK_TYPE_PIXBUF, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_POINTER);
+
+ treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
+ g_object_unref(G_OBJECT(store));
+ gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), TRUE);
+ gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE);
+ gtk_widget_show(treeview);
+ gtk_container_add(GTK_CONTAINER(scrolledwin), treeview);
+ gtk_widget_set_size_request(treeview, -1, 120);
+
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
+ gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE);
+
+ renderer = gtk_cell_renderer_pixbuf_new();
+ g_object_set(renderer, "xalign", 0.5, NULL);
+ column = gtk_tree_view_column_new_with_attributes
+ (NULL, renderer, "pixbuf", PROG_COL_PIXBUF, NULL);
+ gtk_tree_view_column_set_alignment(column, 0.5);
+ gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_fixed_width(column, 20);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes
+ (_("Account"), renderer, "text", PROG_COL_NAME, NULL);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+ gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_fixed_width(column, 160);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
- clist = gtk_clist_new_with_titles(3, text);
- gtk_widget_show(clist);
- gtk_container_add(GTK_CONTAINER(scrolledwin), clist);
- gtk_widget_set_size_request(clist, -1, 120);
- gtk_clist_set_column_justification(GTK_CLIST(clist), 0,
- GTK_JUSTIFY_CENTER);
- gtk_clist_set_column_width(GTK_CLIST(clist), 0, 16);
- gtk_clist_set_column_width(GTK_CLIST(clist), 1, 160);
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes
+ (_("Status"), renderer, "text", PROG_COL_STATUS, NULL);
+ gtk_tree_view_column_set_resizable(column, TRUE);
+ gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
progress->window = dialog;
progress->label = label;
progress->cancel_btn = cancel_btn;
progress->progressbar = progressbar;
- progress->clist = clist;
+ progress->treeview = treeview;
+ progress->store = store;
return progress;
}
+void progress_dialog_destroy(ProgressDialog *progress)
+{
+ if (progress) {
+ gtk_widget_destroy(progress->window);
+ g_free(progress);
+ }
+}
+
void progress_dialog_set_label(ProgressDialog *progress, gchar *str)
{
gtk_label_set_text(GTK_LABEL(progress->label), str);
@@ -128,10 +173,88 @@ void progress_dialog_set_percentage(ProgressDialog *progress,
percentage);
}
-void progress_dialog_destroy(ProgressDialog *progress)
+void progress_dialog_append(ProgressDialog *progress, GdkPixbuf *pixbuf,
+ const gchar *name, const gchar *status,
+ gpointer data)
{
- if (progress) {
- gtk_widget_destroy(progress->window);
- g_free(progress);
+ GtkListStore *store = progress->store;
+ GtkTreeIter iter;
+
+ gtk_list_store_append(store, &iter);
+
+ gtk_list_store_set(store, &iter,
+ PROG_COL_PIXBUF, pixbuf,
+ PROG_COL_NAME, name,
+ PROG_COL_STATUS, status,
+ PROG_COL_POINTER, data,
+ -1);
+}
+
+void progress_dialog_set_row(ProgressDialog *progress, gint row,
+ GdkPixbuf *pixbuf, const gchar *name,
+ const gchar *status, gpointer data)
+{
+ GtkListStore *store = progress->store;
+ GtkTreeIter iter;
+
+ if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store),
+ &iter, NULL, row)) {
+ gtk_list_store_set(store, &iter,
+ PROG_COL_PIXBUF, pixbuf,
+ PROG_COL_NAME, name,
+ PROG_COL_STATUS, status,
+ PROG_COL_POINTER, data,
+ -1);
+ }
+}
+
+void progress_dialog_set_row_pixbuf(ProgressDialog *progress, gint row,
+ GdkPixbuf *pixbuf)
+{
+ GtkListStore *store = progress->store;
+ GtkTreeIter iter;
+
+ if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store),
+ &iter, NULL, row)) {
+ gtk_list_store_set(store, &iter, PROG_COL_PIXBUF, pixbuf, -1);
+ }
+}
+
+void progress_dialog_set_row_name(ProgressDialog *progress, gint row,
+ const gchar *name)
+{
+ GtkListStore *store = progress->store;
+ GtkTreeIter iter;
+
+ if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store),
+ &iter, NULL, row)) {
+ gtk_list_store_set(store, &iter, PROG_COL_NAME, name, -1);
+ }
+}
+
+void progress_dialog_set_row_status(ProgressDialog *progress, gint row,
+ const gchar *status)
+{
+ GtkListStore *store = progress->store;
+ GtkTreeIter iter;
+
+ if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store),
+ &iter, NULL, row)) {
+ gtk_list_store_set(store, &iter, PROG_COL_STATUS, status, -1);
}
}
+
+void progress_dialog_scroll_to_row(ProgressDialog *progress, gint row)
+{
+ GtkTreeModel *model = GTK_TREE_MODEL(progress->store);
+ GtkTreeIter iter;
+ GtkTreePath *path;
+
+ if (!gtk_tree_model_iter_nth_child(model, &iter, NULL, row))
+ return;
+
+ path = gtk_tree_model_get_path(model, &iter);
+ gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(progress->treeview),
+ path, NULL, FALSE, 0.0, 0.0);
+ gtk_tree_path_free(path);
+}
diff --git a/src/progressdialog.h b/src/progressdialog.h
index 26887a26..33cf9836 100644
--- a/src/progressdialog.h
+++ b/src/progressdialog.h
@@ -22,6 +22,8 @@
#include <glib.h>
#include <gtk/gtkwidget.h>
+#include <gtk/gtkliststore.h>
+#include <gdk/gdkpixbuf.h>
typedef struct _ProgressDialog ProgressDialog;
@@ -31,16 +33,53 @@ struct _ProgressDialog
GtkWidget *label;
GtkWidget *cancel_btn;
GtkWidget *progressbar;
- GtkWidget *clist;
+
+ GtkWidget *treeview;
+ GtkListStore *store;
};
+typedef enum
+{
+ PROG_COL_PIXBUF,
+ PROG_COL_NAME,
+ PROG_COL_STATUS,
+ PROG_COL_POINTER,
+ PROG_N_COLS
+} ProgressColumn;
+
ProgressDialog *progress_dialog_create (void);
+void progress_dialog_destroy (ProgressDialog *progress);
+
void progress_dialog_set_label (ProgressDialog *progress,
gchar *str);
void progress_dialog_set_value (ProgressDialog *progress,
gfloat value);
void progress_dialog_set_percentage (ProgressDialog *progress,
gfloat percentage);
-void progress_dialog_destroy (ProgressDialog *progress);
+
+void progress_dialog_append (ProgressDialog *progress,
+ GdkPixbuf *pixbuf,
+ const gchar *name,
+ const gchar *status,
+ gpointer data);
+void progress_dialog_set_row (ProgressDialog *progress,
+ gint row,
+ GdkPixbuf *pixbuf,
+ const gchar *name,
+ const gchar *status,
+ gpointer data);
+
+void progress_dialog_set_row_pixbuf (ProgressDialog *progress,
+ gint row,
+ GdkPixbuf *pixbuf);
+void progress_dialog_set_row_name (ProgressDialog *progress,
+ gint row,
+ const gchar *name);
+void progress_dialog_set_row_status (ProgressDialog *progress,
+ gint row,
+ const gchar *status);
+
+void progress_dialog_scroll_to_row (ProgressDialog *progress,
+ gint row);
#endif /* __PROGRESS_H__ */
diff --git a/src/send_message.c b/src/send_message.c
index a719a1ee..81940763 100644
--- a/src/send_message.c
+++ b/src/send_message.c
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2003 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2005 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,7 +28,6 @@
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkwindow.h>
-#include <gtk/gtkclist.h>
#include <stdio.h>
#include <string.h>
@@ -363,8 +362,6 @@ static gint send_message_smtp(PrefsAccount *ac_prefs, GSList *to_list, FILE *fp)
SMTPSession *smtp_session;
gushort port;
SendProgressDialog *dialog;
- GtkCList *clist;
- const gchar *text[3];
gchar buf[BUFFSIZE];
gint ret = 0;
@@ -443,11 +440,8 @@ static gint send_message_smtp(PrefsAccount *ac_prefs, GSList *to_list, FILE *fp)
dialog = send_progress_dialog_create();
dialog->session = session;
- text[0] = NULL;
- text[1] = ac_prefs->smtp_server;
- text[2] = _("Connecting");
- clist = GTK_CLIST(dialog->dialog->clist);
- gtk_clist_append(clist, (gchar **)text);
+ progress_dialog_append(dialog->dialog, NULL, ac_prefs->smtp_server,
+ _("Connecting"), NULL);
g_snprintf(buf, sizeof(buf), _("Connecting to SMTP server: %s ..."),
ac_prefs->smtp_server);
@@ -554,7 +548,7 @@ static gint send_recv_message(Session *session, const gchar *msg, gpointer data)
}
progress_dialog_set_label(dialog->dialog, buf);
- gtk_clist_set_text(GTK_CLIST(dialog->dialog->clist), 0, 2, state_str);
+ progress_dialog_set_row_status(dialog->dialog, 0, state_str);
return 0;
}