From b23827cdd1d1a4b1e828a60591d663ace62b38ef Mon Sep 17 00:00:00 2001 From: Artem Garmash Date: Thu, 17 Dec 2009 00:32:16 +0200 Subject: [PATCH] Show contact starter on header click --- src/el-home-applet.c | 60 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/src/el-home-applet.c b/src/el-home-applet.c index 3636be8..e9a69de 100644 --- a/src/el-home-applet.c +++ b/src/el-home-applet.c @@ -32,6 +32,7 @@ #include #include #include +#include #define EL_HOME_APPLET_GET_PRIVATE(obj) ( \ G_TYPE_INSTANCE_GET_PRIVATE (obj, \ @@ -69,7 +70,8 @@ struct _ELHomeAppletPrivate gchar *message; gint event_id; - gboolean active; + gboolean active_body; + gboolean active_header; guint unread_count; @@ -312,7 +314,14 @@ expose_event (GtkWidget *self, GdkEventExpose *event) cairo_close_path (cr); - cairo_set_source_rgba (cr, 0.2f, 0.2f, 0.2f, 0.8f); + if (priv->active_header) + cairo_set_source_rgba (cr, + priv->active_color.red, + priv->active_color.green, + priv->active_color.blue, + 0.8f); + else + cairo_set_source_rgba (cr, 0.2f, 0.2f, 0.2f, 0.8f); cairo_fill (cr); cairo_move_to (cr, 0, HEADER_HEIGHT); @@ -339,7 +348,7 @@ expose_event (GtkWidget *self, GdkEventExpose *event) grad = cairo_pattern_create_linear (0, HEADER_HEIGHT, 0, C_HEIGHT); - if (priv->active) { + if (priv->active_body) { cairo_pattern_add_color_stop_rgba (grad, 0.5f, priv->active_color.red, @@ -786,7 +795,10 @@ button_press_event_cb (GtkWidget *widget, ELHomeAppletPrivate *priv = self->priv; if (priv->event_id > 0) { - priv->active = TRUE; + if (event->y < C_Y + HEADER_HEIGHT) + priv->active_header = TRUE; + else + priv->active_body = TRUE; gtk_widget_queue_draw (widget); } @@ -794,14 +806,33 @@ button_press_event_cb (GtkWidget *widget, } static gboolean +start_starter (OssoABookAggregator *aggregator, const gchar *contact_id) +{ + GList *contacts = osso_abook_aggregator_lookup (aggregator, contact_id); + if (contacts && contacts->data) { + GtkWidget *starter = + osso_abook_touch_contact_starter_new_with_contact + (NULL, + OSSO_ABOOK_CONTACT (contacts->data)); + GtkWidget *dlg = osso_abook_touch_contact_starter_dialog_new + (NULL, + OSSO_ABOOK_TOUCH_CONTACT_STARTER (starter)); + gtk_widget_show_all (starter); + gtk_widget_show (dlg); + + return TRUE; + } + return FALSE; +} +static gboolean button_release_event_cb (GtkWidget *widget, GdkEventButton *event, ELHomeApplet *self) { ELHomeAppletPrivate *priv = self->priv; - if (priv->active) { - priv->active = FALSE; + if (priv->active_body) { + priv->active_body = FALSE; stop_scroll_anim (priv); if (priv->scroll_on_click) { priv->scroll_on_click = FALSE; @@ -817,6 +848,14 @@ button_release_event_cb (GtkWidget *widget, gtk_widget_queue_draw (widget); } + if (priv->active_header) { + priv->active_header = FALSE; + if (!start_starter (OSSO_ABOOK_AGGREGATOR (priv->aggregator), + priv->contact_id)) { + /* TODO: start temp contact dlg */ + } + gtk_widget_queue_draw (widget); + } return TRUE; } @@ -828,11 +867,16 @@ leave_notify_event_cb (GtkWidget *widget, { ELHomeAppletPrivate *priv = self->priv; - if (priv->active) { - priv->active = FALSE; + if (priv->active_body) { + priv->active_body = FALSE; + priv->active_header = FALSE; stop_scroll_anim (priv); gtk_widget_queue_draw (widget); } + if (priv->active_header) { + priv->active_header = FALSE; + gtk_widget_queue_draw (widget); + } return FALSE; } -- 1.7.9.5