+2005-01-07 [colin] 0.9.13cvs28.3
+
+ * src/gtk/progressdialog.c
+ * src/gtk/progressdialog.h
+ * src/inc.c
+ * src/send_message.c
+ GTK2 for the incorporation dialog. The CList isn't dead
+ yet, for a more smooth migration. Patch by Alfons.
+
2005-01-06 [colin] 0.9.13cvs28.2
* src/prefs_display_header.c
( cvs diff -u -r 1.43.2.12 -r 1.43.2.13 src/prefs_matcher.c; ) > 0.9.13cvs27.4.patchset
( cvs diff -u -r 1.43.2.13 -r 1.43.2.14 src/prefs_matcher.c; ) > 0.9.13cvs28.1.patchset
( cvs diff -u -r 1.16.2.5 -r 1.16.2.6 src/prefs_display_header.c; cvs diff -u -r 1.60.2.8 -r 1.60.2.9 src/prefs_actions.c; cvs diff -u -r 1.43.2.14 -r 1.43.2.15 src/prefs_matcher.c; ) > 0.9.13cvs28.2.patchset
+( cvs diff -u -r 1.1.4.4 -r 1.1.4.5 src/gtk/progressdialog.c; cvs diff -u -r 1.1.4.2 -r 1.1.4.3 src/gtk/progressdialog.h; cvs diff -u -r 1.149.2.18 -r 1.149.2.19 src/inc.c; cvs diff -u -r 1.17.2.5 -r 1.17.2.6 src/send_message.c; ) > 0.9.13cvs28.3.patchset
BINARY_AGE=0
EXTRA_VERSION=28
EXTRA_RELEASE=
-EXTRA_GTK2_VERSION=.2
+EXTRA_GTK2_VERSION=.3
if test \( $EXTRA_VERSION -eq 0 \) -o \( "x$EXTRA_RELEASE" != "x" \); then
VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}${EXTRA_RELEASE}${EXTRA_GTK2_VERSION}
#endif
#include <glib.h>
+#include <gtk/gtk.h>
#include <gtk/gtkwindow.h>
#include <gtk/gtkvbox.h>
#include <gtk/gtkhbox.h>
#include "gtkutils.h"
#include "utils.h"
+enum {
+ PROGRESS_IMAGE,
+ PROGRESS_ACCOUNT,
+ PROGRESS_STATE,
+ N_PROGRESS_COLUMNS
+};
+
+
+static GtkListStore* progress_dialog_create_data_store(void);
+static gint progress_dialog_list_view_insert_account(GtkWidget *list_view,
+ gint row,
+ const gchar *account,
+ const gchar *status,
+ GdkPixbuf *image);
+static GtkWidget *progress_dialog_list_view_create(void);
+static void progress_dialog_create_list_view_columns(GtkTreeView *list_view);
+
ProgressDialog *progress_dialog_create(void)
{
ProgressDialog *progress;
GtkWidget *progressbar;
GtkWidget *scrolledwin;
GtkWidget *clist;
+ GtkWidget *list_view;
gchar *text[] = {NULL, NULL, NULL};
text[1] = _("Account");
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 8);
gtk_widget_show(label);
- gtkut_button_set_create(&cancel_area, &cancel_btn, _("Cancel"),
- NULL, NULL, NULL, NULL);
+ gtkut_button_set_create_stock(&cancel_area, &cancel_btn,
+ GTK_STOCK_CANCEL, NULL, NULL,
+ NULL, NULL);
gtk_box_pack_end(GTK_BOX(vbox), cancel_area, FALSE, FALSE, 0);
gtk_widget_grab_default(cancel_btn);
gtk_widget_show_all(cancel_area);
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
+ /* GTK2: we hide the clist, but it is available for migration
+ * purposes. now if there only was a way to catch "set clist
+ * things"!.. */
clist = gtk_clist_new_with_titles(3, text);
- gtk_widget_show(clist);
- gtk_container_add(GTK_CONTAINER(scrolledwin), clist);
- gtk_widget_set_usize(clist, -1, 120);
+ gtk_widget_hide(clist);
+ /* gtk_container_add(GTK_CONTAINER(scrolledwin), clist); */
+ /* gtk_widget_set_usize(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);
+ list_view = progress_dialog_list_view_create();
+ gtk_widget_show(list_view);
+ gtk_container_add(GTK_CONTAINER(scrolledwin), list_view);
+ gtk_widget_set_usize(list_view, -1, 120);
+
progress->window = window;
progress->label = label;
progress->cancel_btn = cancel_btn;
progress->progressbar = progressbar;
progress->clist = clist;
+ progress->list_view = list_view;
return progress;
}
g_free(progress);
}
}
+
+/*!
+ *\return gint Row where account was set
+ */
+gint progress_dialog_list_set_account(ProgressDialog *progress,
+ gint row,
+ const gchar *account_name)
+{
+ return progress_dialog_list_view_insert_account(progress->list_view,
+ row, account_name, NULL,
+ NULL);
+}
+
+/*!
+ *\return gint Row where image was set
+ */
+gint progress_dialog_list_set_image(ProgressDialog *progress,
+ gint row,
+ GdkPixbuf *image)
+{
+ return progress_dialog_list_view_insert_account(progress->list_view,
+ row, NULL, NULL,
+ image);
+}
+
+/*!
+ *\return gint Row where status was set
+ */
+gint progress_dialog_list_set_status(ProgressDialog *progress,
+ gint row,
+ const gchar *status)
+{
+ return progress_dialog_list_view_insert_account(progress->list_view,
+ row, NULL, status,
+ NULL);
+}
+
+/*!
+ *\return gint Row where data were set
+ */
+gint progress_dialog_list_set(ProgressDialog *progress,
+ gint row,
+ GdkPixbuf *image,
+ const gchar *account_name,
+ const gchar *status)
+{
+ return progress_dialog_list_view_insert_account(progress->list_view,
+ row, account_name,
+ status, image);
+}
+
+/* XXX: maybe scroll into view, but leaving that for someone else to
+ * pickup: I don't have that many accounts... */
+gboolean progress_dialog_list_select_row(ProgressDialog *progress,
+ gint row)
+{
+ GtkTreeSelection *selection = gtk_tree_view_get_selection
+ (GTK_TREE_VIEW(progress->list_view));
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+
+ model = gtk_tree_view_get_model(GTK_TREE_VIEW(progress->list_view));
+
+ if (!gtk_tree_model_iter_nth_child(model, &iter, NULL, row))
+ return FALSE;
+
+ gtk_tree_selection_select_iter(selection, &iter);
+
+ return TRUE;
+}
+
+static GtkListStore* progress_dialog_create_data_store(void)
+{
+ return gtk_list_store_new(N_PROGRESS_COLUMNS,
+ GDK_TYPE_PIXBUF,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ -1);
+}
+
+static gint progress_dialog_list_view_insert_account(GtkWidget *list_view,
+ gint row,
+ const gchar *account,
+ const gchar *status,
+ GdkPixbuf *image)
+{
+ GtkTreeIter iter;
+ GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model
+ (GTK_TREE_VIEW(list_view)));
+ gint result = -1;
+
+ if (account == NULL && status == NULL && image == NULL)
+ return -1;
+
+ /* see if row exists, if not append */
+ if (row < 0 || !gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store),
+ &iter, NULL, row)) {
+ result = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store),
+ NULL);
+ gtk_list_store_append(store, &iter);
+ } else
+ result = row;
+
+ /*
+ * XXX: uhm, when does the iter invalidate? sure not while
+ * just setting a row's column i hope?
+ */
+
+ if (account)
+ gtk_list_store_set(store, &iter,
+ PROGRESS_ACCOUNT, account,
+ -1);
+ if (status)
+ gtk_list_store_set(store, &iter,
+ PROGRESS_STATE, status,
+ -1);
+ if (image)
+ gtk_list_store_set(store, &iter,
+ PROGRESS_IMAGE, image,
+ -1);
+
+ return result;
+}
+
+static GtkWidget *progress_dialog_list_view_create(void)
+{
+ GtkTreeView *list_view;
+ GtkTreeModel *model;
+
+ model = GTK_TREE_MODEL(progress_dialog_create_data_store());
+ list_view = GTK_TREE_VIEW(gtk_tree_view_new_with_model(model));
+ g_object_unref(model);
+
+ gtk_tree_view_set_rules_hint(list_view, TRUE);
+
+ /* create the columns */
+ progress_dialog_create_list_view_columns(list_view);
+
+ return GTK_WIDGET(list_view);
+}
+
+static void progress_dialog_create_list_view_columns(GtkTreeView *list_view)
+{
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+
+ renderer = gtk_cell_renderer_pixbuf_new();
+ column = gtk_tree_view_column_new_with_attributes
+ ("", renderer,
+ "pixbuf", PROGRESS_IMAGE,
+ NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(list_view), column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes
+ (_("Account"),
+ renderer,
+ "text", PROGRESS_ACCOUNT,
+ NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(list_view), column);
+
+ renderer = gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes
+ (_("Status"),
+ renderer,
+ "text", PROGRESS_STATE,
+ NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(list_view), column);
+}
+
GtkWidget *cancel_btn;
GtkWidget *progressbar;
GtkWidget *clist;
+ GtkWidget *list_view;
};
ProgressDialog *progress_dialog_create (void);
gfloat percentage);
void progress_dialog_destroy (ProgressDialog *progress);
+
+/*
+ * Use these functions to access the dialog list
+ */
+
+gint progress_dialog_list_set_account (ProgressDialog *progress,
+ gint row,
+ const gchar *account_name);
+gint progress_dialog_list_set_image (ProgressDialog *progress,
+ gint row,
+ GdkPixbuf *image);
+gint progress_dialog_list_set_status (ProgressDialog *progress,
+ gint row,
+ const gchar *status);
+gint progress_dialog_list_set (ProgressDialog *progress,
+ gint row,
+ GdkPixbuf *image,
+ const gchar *account_name,
+ const gchar *status);
+
+gboolean progress_dialog_list_select_row(ProgressDialog *progress,
+ gint row);
+
#endif /* __PROGRESS_H__ */
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 *currentpix;
+static GdkPixbuf *errorpix;
+static GdkPixbuf *okpix;
#define MSGBUFSIZE 8192
progress_dialog_get_fraction(progress);
- stock_pixmap_gdk(progress->clist, STOCK_PIXMAP_COMPLETE,
- &okxpm, &okxpmmask);
- stock_pixmap_gdk(progress->clist, STOCK_PIXMAP_CONTINUE,
- ¤txpm, ¤txpmmask);
- stock_pixmap_gdk(progress->clist, STOCK_PIXMAP_ERROR,
- &errorxpm, &errorxpmmask);
+ stock_pixbuf_gdk(progress->list_view, STOCK_PIXMAP_COMPLETE,
+ &okpix);
+ stock_pixbuf_gdk(progress->list_view, STOCK_PIXMAP_CONTINUE,
+ ¤tpix);
+ stock_pixbuf_gdk(progress->list_view, STOCK_PIXMAP_ERROR,
+ &errorpix);
if (prefs_common.recv_dialog_mode == RECV_DIALOG_ALWAYS ||
(prefs_common.recv_dialog_mode == RECV_DIALOG_MANUAL &&
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_list_set(inc_dialog->dialog,
+ -1, NULL,
+ pop3_session->ac_prefs->account_name,
+ _("Standby"));
}
}
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;
qlist = next;
}
-#define SET_PIXMAP_AND_TEXT(xpm, xpmmask, str) \
+#define SET_PIXMAP_AND_TEXT(pix, str) \
{ \
- gtk_clist_set_pixmap(clist, inc_dialog->cur_row, 0, xpm, xpmmask); \
- gtk_clist_set_text(clist, inc_dialog->cur_row, 2, str); \
+ progress_dialog_list_set(inc_dialog->dialog, \
+ inc_dialog->cur_row, \
+ pix, \
+ NULL, \
+ str); \
}
for (; inc_dialog->queue_list != NULL; inc_dialog->cur_row++) {
pop3_session = POP3_SESSION(session->session);
if (pop3_session->pass == NULL) {
- SET_PIXMAP_AND_TEXT(okxpm, okxpmmask, _("Cancelled"));
+ SET_PIXMAP_AND_TEXT(okpix, _("Cancelled"));
inc_session_destroy(session);
inc_dialog->queue_list =
g_list_remove(inc_dialog->queue_list, session);
}
inc_progress_dialog_clear(inc_dialog);
- gtk_clist_moveto(clist, inc_dialog->cur_row, -1, 1.0, 0.0);
+ progress_dialog_list_select_row(inc_dialog->dialog,
+ inc_dialog->cur_row);
- SET_PIXMAP_AND_TEXT(currentxpm, currentxpmmask,
- _("Retrieving"));
+ SET_PIXMAP_AND_TEXT(currentpix, _("Retrieving"));
/* begin POP3 session */
inc_state = inc_pop3_session_do(session);
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(okpix, msg);
g_free(msg);
break;
case INC_CONNECT_ERROR:
- SET_PIXMAP_AND_TEXT(errorxpm, errorxpmmask,
- _("Connection failed"));
+ SET_PIXMAP_AND_TEXT(errorpix, _("Connection failed"));
break;
case INC_AUTH_FAILED:
- SET_PIXMAP_AND_TEXT(errorxpm, errorxpmmask,
- _("Auth failed"));
+ SET_PIXMAP_AND_TEXT(errorpix, _("Auth failed"));
break;
case INC_LOCKED:
- SET_PIXMAP_AND_TEXT(errorxpm, errorxpmmask,
- _("Locked"));
+ SET_PIXMAP_AND_TEXT(errorpix, _("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(errorpix, _("Error"));
break;
case INC_TIMEOUT:
- SET_PIXMAP_AND_TEXT(errorxpm, errorxpmmask, _("Timeout"));
+ SET_PIXMAP_AND_TEXT(errorpix, _("Timeout"));
break;
case INC_CANCEL:
- SET_PIXMAP_AND_TEXT(okxpm, okxpmmask, _("Cancelled"));
+ SET_PIXMAP_AND_TEXT(okpix, _("Cancelled"));
break;
default:
break;
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_list_set_status(inc_dialog->dialog,
+ inc_dialog->cur_row,
+ buf);
}
}
SMTPSession *smtp_session;
gushort port;
SendProgressDialog *dialog;
- GtkCList *clist;
- const gchar *text[3];
gchar buf[BUFFSIZE];
gint ret = 0;
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_list_set(dialog->dialog, 0, NULL,
+ ac_prefs->smtp_server,
+ _("Connecting"));
if (ac_prefs->pop_before_smtp
&& (ac_prefs->protocol == A_APOP || ac_prefs->protocol == A_POP3)
g_snprintf(buf, sizeof(buf), _("Doing POP before SMTP..."));
log_message(buf);
progress_dialog_set_label(dialog->dialog, buf);
- gtk_clist_set_text(clist, 0, 2, _("POP before SMTP"));
+ progress_dialog_list_set_status(dialog->dialog, 0, _("POP before SMTP"));
GTK_EVENTS_FLUSH();
inc_pop_before_smtp(ac_prefs);
}
}
progress_dialog_set_label(dialog->dialog, buf);
- gtk_clist_set_text(GTK_CLIST(dialog->dialog->clist), 0, 2, state_str);
+ progress_dialog_list_set_status(dialog->dialog, 0, state_str);
return 0;
}