[anjal] Draw high lighted arrow for selected msgs in conv view.
- From: Srinivasa Ragavan <sragavan src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjal] Draw high lighted arrow for selected msgs in conv view.
- Date: Thu, 26 Mar 2009 04:38:01 -0400 (EDT)
commit 0f1cebe9b9a0a9f3573a65883ddf70a88f470914
Author: Srinivasa Ragavan <sragavan novell com>
Date: Wed Mar 25 18:18:04 2009 +0530
Draw high lighted arrow for selected msgs in conv view.
---
src/mail-message-view.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 119 insertions(+), 2 deletions(-)
diff --git a/src/mail-message-view.c b/src/mail-message-view.c
index 38303ce..caf1e90 100644
--- a/src/mail-message-view.c
+++ b/src/mail-message-view.c
@@ -154,7 +154,7 @@ mmv_focus_in (GtkWidget *w, GdkEventFocus *event, MailMessageView *mmv)
gtk_widget_modify_fg (mmv->more_details, GTK_STATE_NORMAL, pcolor_fg_sel);
gtk_widget_modify_fg (mmv->sub_details, GTK_STATE_NORMAL, pcolor_fg_sel);
gtk_widget_modify_fg (mmv->date_details, GTK_STATE_NORMAL, pcolor_fg_sel);
- mmv->priv->active_color = scolor_sel;;
+ mmv->priv->active_color = scolor_sel;
mmv_invalidate_row (mmv->priv->header_row);
return FALSE;
@@ -403,6 +403,123 @@ draw_rounded_rectangle (cairo_t *cr, gdouble x, gdouble y, gdouble width, gdoubl
}
+/* HACK: None of the themes pick the color for Arrow. So I draw it. Its reqd.
+ * to show the selected messages arrow on a different color. It isn't visible
+ * otherwise. This bit of code is reffered from gtk+/gtk/gtkstyle.c */
+static int
+mmv_arrow_expose (GtkWidget *widget, GdkEventExpose *event, MailMessageView *mmv)
+{
+ GtkArrow *arrow = (GtkArrow *)widget;
+ if (GTK_WIDGET_DRAWABLE (widget)) {
+ GtkArrow *arrow = GTK_ARROW (widget);
+ GtkMisc *misc = GTK_MISC (widget);
+ GtkShadowType shadow_type;
+ gint width, height;
+ gint x, y;
+ gint extent;
+ gfloat xalign;
+ GtkArrowType effective_arrow_type;
+ gfloat arrow_scaling;
+ gboolean active = mmv->priv->active_color == scolor_sel ? TRUE : FALSE;
+
+ gtk_widget_style_get (widget, "arrow-scaling", &arrow_scaling, NULL);
+
+ width = widget->allocation.width - misc->xpad * 2;
+ height = widget->allocation.height - misc->ypad * 2;
+ extent = MIN (width, height) * arrow_scaling;
+ effective_arrow_type = arrow->arrow_type;
+
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
+ xalign = misc->xalign;
+ else {
+ xalign = 1.0 - misc->xalign;
+ if (arrow->arrow_type == GTK_ARROW_LEFT)
+ effective_arrow_type = GTK_ARROW_RIGHT;
+ else if (arrow->arrow_type == GTK_ARROW_RIGHT)
+ effective_arrow_type = GTK_ARROW_LEFT;
+ }
+
+ x = floor (widget->allocation.x + misc->xpad
+ + ((widget->allocation.width - extent) * xalign));
+ y = floor (widget->allocation.y + misc->ypad
+ + ((widget->allocation.height - extent) * misc->yalign));
+
+ shadow_type = arrow->shadow_type;
+
+ if (widget->state == GTK_STATE_ACTIVE) {
+ if (shadow_type == GTK_SHADOW_IN)
+ shadow_type = GTK_SHADOW_OUT;
+ else if (shadow_type == GTK_SHADOW_OUT)
+ shadow_type = GTK_SHADOW_IN;
+ else if (shadow_type == GTK_SHADOW_ETCHED_IN)
+ shadow_type = GTK_SHADOW_ETCHED_OUT;
+ else if (shadow_type == GTK_SHADOW_ETCHED_OUT)
+ shadow_type = GTK_SHADOW_ETCHED_IN;
+ }
+
+
+ widget->style->fg[widget->state] = active ? *pcolor_fg_sel : *pcolor_fg_norm;
+ /* gtk_paint_arrow (widget->style, widget->window,
+ widget->state, shadow_type,
+ &event->area, widget, "mrrow1",
+ effective_arrow_type, TRUE,
+ x, y, extent, extent); */
+
+
+ if (1) {
+ GdkWindow *window = widget->window;
+ GdkRectangle *area = &event->area;
+ GtkStateType state = widget->state;
+ GtkStyle *style = widget->style;
+ GtkShadowType shadow = shadow_type;
+ const gchar *detail = "arrow";
+ GtkArrowType arrow_type = effective_arrow_type;
+ gboolean fill = TRUE;
+ width = height = extent;
+ cairo_t *cr = gdk_cairo_create (window);
+ gdk_cairo_set_source_color (cr, active ? pcolor_fg_sel : pcolor_fg_norm);
+
+ if (area)
+ {
+ gdk_cairo_rectangle (cr, area);
+ cairo_clip (cr);
+ }
+
+ if (arrow_type == GTK_ARROW_DOWN)
+ {
+ cairo_move_to (cr, x, y);
+ cairo_line_to (cr, x + width, y);
+ cairo_line_to (cr, x + width / 2., y + height);
+ }
+ else if (arrow_type == GTK_ARROW_UP)
+ {
+ cairo_move_to (cr, x, y + height);
+ cairo_line_to (cr, x + width / 2., y);
+ cairo_line_to (cr, x + width, y + height);
+ }
+ else if (arrow_type == GTK_ARROW_LEFT)
+ {
+ cairo_move_to (cr, x + width, y);
+ cairo_line_to (cr, x + width, y + height);
+ cairo_line_to (cr, x, y + height / 2.);
+ }
+ else if (arrow_type == GTK_ARROW_RIGHT)
+ {
+ cairo_move_to (cr, x, y);
+ cairo_line_to (cr, x + width, y + height / 2.);
+ cairo_line_to (cr, x, y + height);
+ }
+
+ cairo_close_path (cr);
+ cairo_fill (cr);
+
+ cairo_destroy (cr);
+ }
+ }
+
+ return TRUE;
+}
+
static int
mmv_sh_color_expose (GtkWidget *w, GdkEventExpose *event, MailMessageView *mmv)
{
@@ -529,7 +646,7 @@ mail_message_view_set_message (MailMessageView *mmview, CamelFolder *folder, con
mmview->priv->arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
gtk_widget_show (mmview->priv->arrow);
gtk_box_pack_start (header_row, mmview->priv->arrow, FALSE, FALSE, 2);
-
+ g_signal_connect (mmview->priv->arrow, "expose-event", G_CALLBACK(mmv_arrow_expose), mmview);
tmp = gtk_event_box_new ();
EXPOSE(tmp, mmview);
mmview->priv->unread_image = gtk_image_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]