[anjal] Pack a unread column of pixbuf toggle type. Move del/junk to pixbuf
- From: Srinivasa Ragavan <sragavan src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjal] Pack a unread column of pixbuf toggle type. Move del/junk to pixbuf
- Date: Mon, 30 Mar 2009 01:35:31 -0400 (EDT)
commit 0d7843e1a2e2d9c140463a29e56ef1ca74f1ef35
Author: Srinivasa Ragavan <sragavan novell com>
Date: Mon Mar 30 10:55:59 2009 +0530
Pack a unread column of pixbuf toggle type. Move del/junk to pixbuf
toggle renderer and some coloring with cairo
---
src/mail-folder-view.c | 125 +++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 107 insertions(+), 18 deletions(-)
diff --git a/src/mail-folder-view.c b/src/mail-folder-view.c
index 0759e1f..f43f441 100644
--- a/src/mail-folder-view.c
+++ b/src/mail-folder-view.c
@@ -34,6 +34,7 @@
#include "em-tree-store.h"
#include "custom-cell-renderer-hbox.h"
#include "custom-cell-renderer-vbox.h"
+#include "custom-cell-renderer-toggle-pixbuf.h"
#include <e-util/e-icon-factory.h>
#include <e-util/e-util.h>
@@ -66,7 +67,8 @@ enum {
};
static const char * mfv_get_selected_uid (GtkTreeView *tree, MailFolderView *mfv);
-
+static const char *unread_image = ANJAL_IMAGEDIR"unread.png";
+
static guint signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (MailFolderView, mail_folder_view, GTK_TYPE_VBOX)
@@ -524,7 +526,11 @@ draw_img (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *t
GtkCellRenderer *child = (GtkCellRenderer *)tmp->data;
char *data = g_object_get_data (child, "data");
GdkPixbuf *img;
-
+
+ if (!GTK_IS_CELL_RENDERER_PIXBUF(child)) {
+ tmp = tmp->next;
+ continue;
+ }
if (data) {
img = e_icon_factory_get_icon (data, E_ICON_SIZE_MENU);
g_object_set (child, "pixbuf", img, NULL);
@@ -731,6 +737,48 @@ draw_text (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *
}
}
+static void
+draw_flags (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, MailFolderView *mfv)
+{
+ char *text;
+ CustomCellRendererVBox *cellprogress = CUSTOM_CELL_RENDERER_VBOX (cell);
+ int i=0;
+ gboolean bold, ellipsize, strike, markup;
+ gboolean unread;
+ guint32 flags;
+
+ GList *tmp = cellprogress->children;
+ while (tmp) {
+ GtkCellRenderer *child = (GtkCellRenderer *)tmp->data;
+
+ if (CUSTOM_IS_CELL_RENDERER_TOGGLE_PIXBUF (child)) {
+ i = GPOINTER_TO_INT(g_object_get_data(child, "data"));
+ ellipsize = GPOINTER_TO_INT(g_object_get_data(child, "p-ellipsize")) ? TRUE : FALSE;
+ bold = GPOINTER_TO_INT(g_object_get_data(child, "p-bold")) ? TRUE : FALSE;
+ strike = GPOINTER_TO_INT(g_object_get_data(child, "p-strike")) ? TRUE : FALSE;
+ markup = GPOINTER_TO_INT(g_object_get_data(child, "p-markup")) ? TRUE : FALSE;
+ if (i !=-1) {
+ GValue v1 = {0};
+ g_value_init (&v1, G_TYPE_BOOLEAN);
+ g_value_unset (&v1);
+
+ if (mfv->priv->light) {
+// gtk_tree_model_get_value (tree_model, iter, COL_FLAGS, &v);
+ /* unread for light tbd */
+ } else {
+ gtk_tree_model_get_value (tree_model, iter, EMTS_COL_UNREAD, &v1);
+ }
+
+ if(!mfv->priv->light)
+ unread = g_value_get_boolean (&v1);
+ g_object_set (child, "active", unread, NULL);
+ }
+ }
+
+ tmp = tmp->next;
+ }
+}
+
void
mail_folder_view_show_list (MailFolderView *mfv)
{
@@ -856,9 +904,23 @@ mfv_msg_delete (GtkCellRenderer *cell, GdkEvent *event,GtkWidget *widget,const
}
static gboolean
+mfv_msg_unread (GtkCellRenderer *cell, GdkEvent *event,GtkWidget *widget,const gchar *path,const GdkRectangle *background_area,const GdkRectangle *cell_area,GtkCellRendererState flags)
+{
+ CamelMessageInfo *info = mfv_get_info (cell, path);
+
+ if (camel_message_info_flags(info) & CAMEL_MESSAGE_SEEN)
+ camel_message_info_set_flags (info, CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_DELETED, 0);
+ else
+ camel_message_info_set_flags (info, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
+
+ return TRUE;
+}
+
+static gboolean
mfv_msg_junk (GtkCellRenderer *cell, GdkEvent *event,GtkWidget *widget,const gchar *path,const GdkRectangle *background_area,const GdkRectangle *cell_area,GtkCellRendererState flags)
{
CamelMessageInfo *info = mfv_get_info (cell, path);
+
camel_message_info_set_flags (info, CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_JUNK|CAMEL_MESSAGE_NOTJUNK|CAMEL_MESSAGE_JUNK_LEARN, CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_JUNK|CAMEL_MESSAGE_JUNK_LEARN);
return TRUE;
}
@@ -985,7 +1047,36 @@ mail_folder_view_construct (MailFolderView *shell)
g_signal_connect (shell->tree, "row-activated", G_CALLBACK (mfv_message_activated), shell);
g_signal_connect (shell->tree, "button-press-event", G_CALLBACK(mfv_button_clicked), shell);
g_signal_connect (shell->tree, "key-press-event", G_CALLBACK(mfv_key_pressed), shell);
-
+
+ /* Create the single column for flags */
+ column = gtk_tree_view_column_new ();
+ gtk_tree_view_column_set_fixed_width (column, 24);
+ gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_title (column, _("Flags"));
+ gtk_tree_view_append_column (GTK_TREE_VIEW (shell->tree), column);
+ gtk_tree_view_column_set_resizable (column, TRUE);
+
+ vbox = custom_cell_renderer_vbox_new ();
+ g_object_set_data (vbox, "mfv", shell);
+ g_object_set (vbox, "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL);
+ gtk_tree_view_column_pack_start (column, vbox, TRUE);
+ gtk_tree_view_column_set_cell_data_func (column, vbox, draw_flags, shell, NULL);
+
+ /* Pack a renderer for unread indication */
+ cell = custom_cell_renderer_toggle_pixbuf_new (gdk_pixbuf_new_from_file(unread_image, NULL), gdk_pixbuf_new_from_file(unread_image, NULL));
+ g_object_set_data (cell, "activate_func", mfv_msg_unread);
+ if (shell->priv->light)
+ g_object_set_data (cell, "data", GINT_TO_POINTER (COL_FLAGS));
+ else
+ g_object_set_data (cell, "data", GINT_TO_POINTER (EMTS_COL_UNREAD));
+ custom_cell_renderer_vbox_append (vbox, cell);
+
+ /* dummy renderers for nice packing */
+ cell = custom_cell_renderer_toggle_pixbuf_new (gdk_pixbuf_new_from_xpm_data ((const char **) empty_xpm), gdk_pixbuf_new_from_xpm_data ((const char **) empty_xpm));
+ custom_cell_renderer_vbox_append (vbox, cell);
+ cell = custom_cell_renderer_toggle_pixbuf_new (gdk_pixbuf_new_from_xpm_data ((const char **) empty_xpm), gdk_pixbuf_new_from_xpm_data ((const char **) empty_xpm));
+ custom_cell_renderer_vbox_append (vbox, cell);
+
/* Create the single column */
column = gtk_tree_view_column_new ();
@@ -1025,7 +1116,8 @@ mail_folder_view_construct (MailFolderView *shell)
/* Pack From at the start of the cell */
custom_cell_renderer_hbox_pack_start (hbox, cell, FALSE);
-
+#if 0
+ /* Not required, since we pack a separate column for this. */
/* Pack a renderer for unread indication */
cell = gtk_cell_renderer_toggle_new ();
if (shell->priv->light)
@@ -1034,6 +1126,7 @@ mail_folder_view_construct (MailFolderView *shell)
g_object_set_data (cell, "data", GINT_TO_POINTER (EMTS_COL_UNREAD));
/* Pack toggle at the start of the cell */
custom_cell_renderer_hbox_pack_start (hbox, cell, FALSE);
+#endif
/* Show a box for number of mails */
if (!shell->priv->light) {
@@ -1107,34 +1200,30 @@ mail_folder_view_construct (MailFolderView *shell)
gtk_tree_view_column_pack_end (column, vbox, FALSE);
gtk_tree_view_column_set_cell_data_func (column, vbox, draw_img, NULL, NULL);
+
/* Cell rendere for Delete */
- cell = gtk_cell_renderer_pixbuf_new ();
+ cell = custom_cell_renderer_toggle_pixbuf_new (e_icon_factory_get_icon ("stock_delete", E_ICON_SIZE_MENU), e_icon_factory_get_icon ("stock_delete", E_ICON_SIZE_MENU));
custom_cell_renderer_vbox_append (vbox, cell);
g_object_set_data (cell, "data", "stock_delete");
+ g_object_set_data (cell, "sel-highlight", GINT_TO_POINTER(1));
g_object_set_data (cell, "activate_func", mfv_msg_delete);
+
/* Empty image */
if (!shell->priv->light) {
cell = gtk_cell_renderer_pixbuf_new ();
custom_cell_renderer_vbox_append (vbox, cell);
g_object_set_data (cell, "data", NULL);
- g_object_set_data (cell, "activate_func", NULL);
- }
+ g_object_set_data (cell, "activate_func", NULL);
+ }
- /* Cell rendere for Junk */
- cell = gtk_cell_renderer_pixbuf_new ();
+ /* Cell rendere for Junk */
+ cell = custom_cell_renderer_toggle_pixbuf_new (e_icon_factory_get_icon ("mail-mark-junk", E_ICON_SIZE_MENU), e_icon_factory_get_icon ("mail-mark-junk", E_ICON_SIZE_MENU));
custom_cell_renderer_vbox_append (vbox, cell);
+ g_object_set_data (cell, "sel-highlight", GINT_TO_POINTER(1));
g_object_set_data (cell, "data", "mail-mark-junk");
- g_object_set_data (cell, "activate_func", mfv_msg_junk);
+ g_object_set_data (cell, "activate_func", mfv_msg_junk);
-
- /* Empty image */
- if (!shell->priv->light) {
- cell = gtk_cell_renderer_pixbuf_new ();
- custom_cell_renderer_vbox_append (vbox, cell);
- g_object_set_data (cell, "data", NULL);
- g_object_set_data (cell, "activate_func", NULL);
- }
gtk_tree_view_columns_autosize (shell->tree);
shell->mail = mail_conv_view_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]