[anjal] Delete & Junk buttons respond to click. They don't act yet, but put a
- From: Srinivasa Ragavan <sragavan src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjal] Delete & Junk buttons respond to click. They don't act yet, but put a
- Date: Sat, 21 Mar 2009 07:29:54 -0400 (EDT)
commit 756c7e600cee69aa376856e111660ad8e88727b3
Author: Srinivasa Ragavan <sragavan novell com>
Date: Sat Mar 21 00:24:12 2009 +0530
Delete & Junk buttons respond to click. They don't act yet, but put a
log on the console.
---
src/custom-cell-renderer-hbox.c | 2 +-
src/custom-cell-renderer-hbox.h | 1 -
src/custom-cell-renderer-vbox.c | 61 ++++++++++++++++++++++++++++++++++++++-
src/custom-cell-renderer-vbox.h | 1 +
src/mail-folder-view.c | 27 ++++++++++++-----
5 files changed, 81 insertions(+), 11 deletions(-)
diff --git a/src/custom-cell-renderer-hbox.c b/src/custom-cell-renderer-hbox.c
index 777a7b8..fb0d6f0 100644
--- a/src/custom-cell-renderer-hbox.c
+++ b/src/custom-cell-renderer-hbox.c
@@ -477,7 +477,7 @@ custom_cell_renderer_hbox_render (GtkCellRenderer *cell,
cell_area->x = cell_area->x - cw - (child->xpad);
if (custom && cw >20) {
extern GdkColor *pcolor_sel;
- cr = gdk_cairo_create (window);
+ cr = gdk_cairo_create (window);
gdk_cairo_set_source_color (cr, pcolor_sel);
draw_rounded_rectangle (cr, cell_area->x, cell_area->y+cy+(1*cell->ypad), cw, ch);
cairo_fill(cr);
diff --git a/src/custom-cell-renderer-hbox.h b/src/custom-cell-renderer-hbox.h
index c857e03..48530f7 100644
--- a/src/custom-cell-renderer-hbox.h
+++ b/src/custom-cell-renderer-hbox.h
@@ -56,7 +56,6 @@ struct _CustomCellRendererHBoxClass
GtkCellRendererClass parent_class;
};
-
GType custom_cell_renderer_hbox_get_type (void);
GtkCellRenderer *custom_cell_renderer_hbox_new (void);
diff --git a/src/custom-cell-renderer-vbox.c b/src/custom-cell-renderer-vbox.c
index 6b021a1..5635c80 100644
--- a/src/custom-cell-renderer-vbox.c
+++ b/src/custom-cell-renderer-vbox.c
@@ -73,6 +73,14 @@ enum
static gpointer parent_class;
+static gboolean
+cc_vbox_activate (GtkCellRenderer *cell,
+ GdkEventButton *event,
+ GtkWidget *widget,
+ const gchar *path,
+ GdkRectangle *background_area,
+ GdkRectangle *cell_area,
+ GtkCellRendererState flags);
/***************************************************************************
*
@@ -130,7 +138,6 @@ custom_cell_renderer_vbox_init (CustomCellRendererVBox *cellrendererprogress)
GTK_CELL_RENDERER(cellrendererprogress)->ypad = 2;
}
-
/***************************************************************************
*
* custom_cell_renderer_vbox_class_init:
@@ -157,6 +164,7 @@ custom_cell_renderer_vbox_class_init (CustomCellRendererVBoxClass *klass)
* custom cell renderer properties */
object_class->get_property = custom_cell_renderer_vbox_get_property;
object_class->set_property = custom_cell_renderer_vbox_set_property;
+ cell_class->activate = cc_vbox_activate;
/* Override the two crucial functions that are the heart
* of a cell renderer in the parent class */
@@ -335,6 +343,8 @@ custom_cell_renderer_vbox_render (GtkCellRenderer *cell,
gint store_x;
GList *tmp = cellprogress->children;
int i=0;
+
+
custom_cell_renderer_vbox_get_size (cell, widget, cell_area,
&x_offset, &y_offset,
&width, &height);
@@ -353,6 +363,55 @@ custom_cell_renderer_vbox_render (GtkCellRenderer *cell,
cell_area->y += 3*2; /* 2 - cell-pad */
tmp = tmp->next;
}
+ if ( flags & GTK_CELL_RENDERER_SELECTED)
+ g_object_set (cell, "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, NULL);
+ else
+ g_object_set (cell, "mode", GTK_CELL_RENDERER_MODE_INERT, NULL);
}
+static gboolean
+cc_vbox_activate (GtkCellRenderer *cell,
+ GdkEventButton *event,
+ GtkWidget *widget,
+ const gchar *path,
+ GdkRectangle *background_area,
+ GdkRectangle *cell_area,
+ GtkCellRendererState flags)
+{
+ CustomCellRendererVBox *cellprogress = CUSTOM_CELL_RENDERER_VBOX (cell);
+ GtkStateType state;
+ gint width, height;
+ gint x_offset, y_offset;
+ gint store_x, i=0;
+ GList *tmp = cellprogress->children;
+
+ if (!event)
+ return TRUE;
+ custom_cell_renderer_vbox_get_size (cell, widget, cell_area,
+ &x_offset, &y_offset,
+ &width, &height);
+ cell_area->y = cell_area->y - (4 * cell->ypad);
+ store_x = cell_area->x;
+ while(tmp) {
+ GtkCellRenderer *child = (GtkCellRenderer *)tmp->data;
+ gint cx, cy, cw, ch;
+
+ cell_area->x = store_x;
+ gtk_cell_renderer_get_size (child, widget, cell_area, &cx, &cy, &cw, &ch);
+ if ((event->x >= cell_area->x && event->x <= cell_area->x+cw) &&
+ (event->y >= cell_area->y +ch&& event->y <= cell_area->y+(2*ch))) {
+ CellRenderActivateFunc func = g_object_get_data (child, "activate_func");
+ if (func) {
+ (*func)(cell, event, widget, path, background_area, cell_area, flags);
+ break;
+ }
+ }
+
+ cell_area->y += ch - (2*2)+ i; /* 2-cellpad*/
+ i+=4;
+ cell_area->y += 3*2; /* 2 - cell-pad */
+ tmp = tmp->next;
+ }
+ return FALSE;
+}
diff --git a/src/custom-cell-renderer-vbox.h b/src/custom-cell-renderer-vbox.h
index 9416dc6..6e57064 100644
--- a/src/custom-cell-renderer-vbox.h
+++ b/src/custom-cell-renderer-vbox.h
@@ -41,6 +41,7 @@ typedef struct _CustomCellRendererVBoxClass CustomCellRendererVBoxClass;
/* CustomCellRendererVBox: Our custom cell renderer
* structure. Extend according to need */
+typedef gboolean (*CellRenderActivateFunc) (GtkCellRenderer *cell, GdkEvent *event,GtkWidget *widget,const gchar *path,const GdkRectangle *background_area,const GdkRectangle *cell_area,GtkCellRendererState flags);
struct _CustomCellRendererVBox
{
diff --git a/src/mail-folder-view.c b/src/mail-folder-view.c
index 779ffda..50ff71a 100644
--- a/src/mail-folder-view.c
+++ b/src/mail-folder-view.c
@@ -737,12 +737,21 @@ mfv_tree_resize (GtkWidget *w, GtkAllocation *req, GtkTreeViewColumn *col)
gtk_tree_view_column_set_fixed_width (col, req->width - 24);
}
-static void
-mfv_unread_toggled (GtkCellRendererToggle *cell, gchar *path, gpointer user_data)
+
+static gboolean
+mfv_msg_delete (GtkCellRenderer *cell, GdkEvent *event,GtkWidget *widget,const gchar *path,const GdkRectangle *background_area,const GdkRectangle *cell_area,GtkCellRendererState flags)
+{
+ printf("Delete\n");
+}
+
+static gboolean
+mfv_msg_junk (GtkCellRenderer *cell, GdkEvent *event,GtkWidget *widget,const gchar *path,const GdkRectangle *background_area,const GdkRectangle *cell_area,GtkCellRendererState flags)
{
- printf("%s toggled\n");
+ printf("Junk\n");
+ return TRUE;
}
+
void
mail_folder_view_construct (MailFolderView *shell)
{
@@ -778,7 +787,6 @@ mail_folder_view_construct (MailFolderView *shell)
gtk_widget_show (shell);
shell->tree = (GtkTreeView *)gtk_tree_view_new ();
-
gtk_tree_view_set_enable_search (shell->tree, FALSE);
gtk_container_add (priv->view_scroller, shell->tree);
gtk_tree_view_set_fixed_height_mode (shell->tree, TRUE);
@@ -801,6 +809,7 @@ mail_folder_view_construct (MailFolderView *shell)
//g_signal_connect (shell->tree, "size-allocate", mfv_tree_resize, column);
/* Main VBOX renderer, that shows multi line. */
vbox = custom_cell_renderer_vbox_new ();
+
gtk_tree_view_column_pack_start (column, vbox, TRUE);
gtk_tree_view_column_set_cell_data_func (column, vbox, draw_text, shell, NULL);
@@ -831,8 +840,6 @@ 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);
- g_object_set (cell, "activatable", TRUE, NULL);
- g_signal_connect (cell, "toggled", G_CALLBACK(mfv_unread_toggled), shell);
/* Show a box for number of mails */
if (!shell->priv->light) {
@@ -908,24 +915,28 @@ mail_folder_view_construct (MailFolderView *shell)
cell = gtk_cell_renderer_pixbuf_new ();
custom_cell_renderer_vbox_append (vbox, cell);
g_object_set_data (cell, "data", "stock_delete");
-
+ 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);
}
/* Cell rendere for Junk */
cell = gtk_cell_renderer_pixbuf_new ();
custom_cell_renderer_vbox_append (vbox, cell);
g_object_set_data (cell, "data", "mail-mark-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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]