[anjal] Anjal Clutterifications



commit 62ae7b0bd0d4bfebdbfac21c4d8925f081ff3c53
Author: Srinivasa Ragavan <sragavan gnome org>
Date:   Mon Jan 4 12:29:28 2010 +0530

    Anjal Clutterifications

 configure.ac            |   17 +++++
 src/Makefile.am         |    2 +
 src/mail-message-view.c |  153 +++++++++++++++++++++++++++++++++++++++++++----
 src/mail-shell.c        |    2 +-
 src/main.c              |    8 ++-
 5 files changed, 166 insertions(+), 16 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e622b22..e36b588 100644
--- a/configure.ac
+++ b/configure.ac
@@ -389,6 +389,23 @@ else
    AM_CONDITIONAL(ENABLE_UNIQUE, false)
 fi
 
+AC_MSG_CHECKING([whether to build with Clutter])
+AC_ARG_WITH([clutter],
+	[AC_HELP_STRING([--with-clutter],
+	[Build with Clutter [default=no]])],
+	with_clutter="$withval", with_clutter="no")
+AC_MSG_RESULT($with_clutter)
+
+if test "x$with_clutter" = "xyes"; then
+   PKG_CHECK_MODULES(CLUTTER, [mx-1.0 clutter-gtk-0.90 >= 0.90.0 clutter-1.0 >= 1.0.0])
+
+   AC_DEFINE(HAVE_CLUTTER, 1, [Clutter available])
+   AM_CONDITIONAL(ENABLE_CLUTTER, true)
+else
+   AC_DEFINE(HAVE_CLUTTER, 0, [Clutter not available])
+   AM_CONDITIONAL(ENABLE_CLUTTER, false)
+fi
+
 AC_MSG_CHECKING([whether to build with Anerley])
 AC_ARG_WITH([anerley],
 	[AC_HELP_STRING([--with-anerley],
diff --git a/src/Makefile.am b/src/Makefile.am
index a34e60c..45ce449 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -16,6 +16,7 @@ AM_CPPFLAGS = \
 	$(WEBKIT_CFLAGS) \
 	$(UNIQUE_CFLAGS) \
 	$(ANERLEY_CFLAGS) \
+	$(CLUTTER_CFLAGS) \
 	$(MANUAL_NSPR_CFLAGS) \
 	$(MANUAL_NSS_CFLAGS)
 
@@ -103,6 +104,7 @@ anjal_LDADD = $(ANJAL_LIBS) \
 	$(WEBKIT_LIBS) \
 	$(UNIQUE_LIBS) \
 	$(ANERLEY_LIBS) \
+	$(CLUTTER_LIBS) \
 	$(MANUAL_NSPR_LIBS) \
 	$(MANUAL_NSS_LIBS) \
 	-lemiscwidgets \
diff --git a/src/mail-message-view.c b/src/mail-message-view.c
index 0d7c2fd..49ff3dc 100644
--- a/src/mail-message-view.c
+++ b/src/mail-message-view.c
@@ -46,6 +46,12 @@
 #include "mail-utils.h"
 #include "em-format-mail-display.h"
 
+#if HAVE_CLUTTER
+#include <clutter/clutter.h>
+#include <mx/mx.h>
+#include <clutter-gtk/clutter-gtk.h>
+#endif
+
 extern char *scolor_norm;
 extern char *scolor_sel;
 extern GdkColor *pcolor_fg_norm;
@@ -56,6 +62,11 @@ struct _MailComposerView;
 void e_msg_composer_set_lite (void);
 void mail_composer_view_replace_composer (struct _MailComposerView *, GtkWidget *composer);
 
+#if HAVE_CLUTTER
+static ClutterActor * create_gtk_actor (GtkWidget *vbox);
+static void mmv_mx_expand (MxExpander  *expander, MailMessageView *mmv);
+#endif
+
 struct  _MailMessageViewPrivate {
 	CamelFolder *folder;
 	const char *uid;
@@ -81,6 +92,12 @@ struct  _MailMessageViewPrivate {
 	char *composer_changed_text;
 	int composer_text_length;
 	char *folder_uri;
+	GtkWidget *total_box;
+
+#if HAVE_CLUTTER	
+	GtkWidget *clutter_embed;
+	ClutterActor *mx_expander;
+#endif	
 };
 
 G_DEFINE_TYPE (MailMessageView, mail_message_view, GTK_TYPE_VBOX)
@@ -228,8 +245,8 @@ mmv_invalidate_row (GtkWidget *w)
 	int wid = w->allocation.width;
 	int heig = w->allocation.height;
 	GdkRectangle rect = {0, 0, wid, heig};
-		
-	gdk_window_invalidate_rect  (w->window, &rect, TRUE);	
+	if (w->window)	
+		gdk_window_invalidate_rect  (w->window, &rect, TRUE);	
 }
 
 static gboolean
@@ -256,6 +273,7 @@ mmv_focus_in (GtkWidget *w, GdkEventFocus *event, MailMessageView *mmv)
 	return FALSE;
 }
 
+
 static void
 mmv_show (MailMessageView *mmv)
 {
@@ -268,12 +286,16 @@ mmv_show (MailMessageView *mmv)
 		//	  mmv->priv->show_composer = FALSE;
 		// }
 	}
+
+	gtk_widget_show (mmv->priv->total_box);
 	gtk_widget_show (mmv->body);
 	gtk_widget_show_all (mmv->footer);
 	gtk_widget_hide (mmv->discard);
 	gtk_widget_hide (mmv->pop_out);
 	gtk_arrow_set ((GtkArrow *)mmv->priv->arrow, GTK_ARROW_DOWN, GTK_SHADOW_NONE);				
+#if !HAVE_CLUTTER	
 	gdk_window_invalidate_rect (((GtkWidget *)mmv)->window, NULL, TRUE);
+#endif	
 	gtk_widget_queue_draw ((GtkWidget *)mmv);
 }
 
@@ -291,8 +313,10 @@ mmv_hide (MailMessageView *mmv)
 	if (GTK_WIDGET_VISIBLE(mmv->main_header)) {
 		gtk_widget_hide (mmv->main_header);
 		gtk_label_set_markup ((GtkLabel *)mmv->more_details, _("<u>show details</u>"));
-	}			
+	}	
+#if !HAVE_CLUTTER		
 	gdk_window_invalidate_rect (((GtkWidget *)mmv)->window, NULL, TRUE);
+#endif	
 	gtk_widget_queue_draw ((GtkWidget *)mmv);
 }
 
@@ -311,6 +335,10 @@ mail_message_view_show_message (MailMessageView *mmv, gboolean show_composer)
 {
 	 if (show_composer)
 		  mmv->priv->show_composer = TRUE;
+
+#if HAVE_CLUTTER
+	mx_expander_set_expanded ((MxExpander *)mmv->priv->mx_expander, TRUE);
+#endif	
 	mmv_show (mmv);
 }
 
@@ -681,7 +709,6 @@ static void
 mmv_finished_loading_webkit (WebKitWebView  *webkitwebview, WebKitWebFrame *arg1, gpointer user_data)
 {
 	 MailMessageView *mmview = (MailMessageView *) user_data;
-	 GtkRequisition req;
 
 	// gtk_widget_hide (mmview->priv->table_headers);
 	// gtk_widget_show (mmview->priv->html_headers);
@@ -1132,6 +1159,62 @@ unread_leave(GtkWidget *widget, GdkEventCrossing *event, gpointer user_data)
 	return FALSE;
 }
 
+#if HAVE_CLUTTER
+static void
+mmv_fix_clutter_embed_width (GtkWidget *widget, GtkAllocation *allocation, gpointer user_data)
+{
+	MailMessageView *mmv = user_data;
+
+	gtk_widget_set_size_request (mmv->body, allocation->width-20, -1);
+	clutter_actor_set_size (mmv->priv->mx_expander, allocation->width-1, -1);
+}
+
+
+static ClutterActor *
+create_gtk_actor (GtkWidget *vbox)
+{
+  GtkWidget       *bin;
+  ClutterActor    *gtk_actor;
+
+  gtk_actor = gtk_clutter_actor_new ();
+  bin = gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (gtk_actor));
+
+  gtk_container_add (GTK_CONTAINER (bin), vbox);
+  
+  gtk_widget_show (bin);
+  gtk_widget_show(vbox);
+  return gtk_actor;
+}
+
+static void
+mmv_mx_expand (MxExpander  *expander,
+               MailMessageView *mmv)
+{
+  gboolean expanded;
+
+  expanded = mx_expander_get_expanded (expander);
+  printf ("expand complete (%s)\n",
+          (expanded) ? "open": "closed");
+  if (expanded) 
+	  mmv_show (mmv);
+  else
+	  mmv_hide (mmv);
+}
+
+
+static void
+mmv_stage_size_notify_cb (ClutterActor *stage,
+                      GParamSpec *pspec,
+                      MailMessageView *mmv)
+{
+  gfloat width, height;
+
+  clutter_actor_get_size (stage, &width, &height);
+  if (mmv->priv->clutter_embed)
+  	gtk_widget_set_size_request (mmv->priv->clutter_embed, -1, height+10);
+}
+#endif
+
 void
 mail_message_view_set_message (MailMessageView *mmview, CamelFolder *folder, const char *uri, const char *uid, gboolean show_composer)
 {
@@ -1141,7 +1224,6 @@ mail_message_view_set_message (MailMessageView *mmview, CamelFolder *folder, con
 	GtkWidget *box, *header_row, *details_row;
 	GtkWidget *reply, *reply_all, *forward;
 	char *str ,**strv;
-
 	gchar *boldmsg, *header_text;
 	GtkTable *table;
 	GtkWidget *vbox, *widget;
@@ -1156,9 +1238,18 @@ mail_message_view_set_message (MailMessageView *mmview, CamelFolder *folder, con
 
 	box = gtk_vbox_new (FALSE, 0);
 	gtk_widget_show (box);
+	mmview->priv->total_box = box;
+
+#if !HAVE_CLUTTER	
+	gtk_box_pack_start ((GtkBox *)mmview, mmview->priv->total_box, TRUE, FALSE, 0);
+#else
+	gtk_widget_hide (mmview->priv->total_box);
+#endif
+
+	box = gtk_vbox_new (FALSE, 0);
+	gtk_widget_show (box);
 
 	mmview->short_header = gtk_event_box_new ();
-	//gtk_container_set_focus_child (mmview, mmview->short_header);
 	g_signal_connect (mmview->short_header, "button-press-event", G_CALLBACK(mmv_collapse_view), mmview);
 
 	info = (CamelMessageInfoBase *)camel_folder_get_message_info (folder, uid);
@@ -1171,12 +1262,40 @@ mail_message_view_set_message (MailMessageView *mmview, CamelFolder *folder, con
 
 	gtk_box_pack_start ((GtkBox *)box, mmview->short_header, FALSE, FALSE, 0);
 
+#if HAVE_CLUTTER	
+	{
+		GtkWidget *embed;
+		ClutterActor *stage;
+		ClutterActor *expander;
+		ClutterActor *glbody;
+
+		embed = gtk_clutter_embed_new ();
+		gtk_widget_show (embed);
+		stage = gtk_clutter_embed_get_stage ((GtkClutterEmbed *)embed);
+		gtk_box_pack_start ((GtkBox *)mmview, embed, TRUE, TRUE, 4);
+		expander = mx_expander_new ();
+		clutter_container_add_actor ((ClutterContainer *)stage, expander);
+		g_signal_connect (expander, "notify::height",
+                    G_CALLBACK (mmv_stage_size_notify_cb), mmview);
+		g_signal_connect (expander, "expand-complete",
+					G_CALLBACK(mmv_mx_expand), mmview);
+		clutter_actor_set_position (expander, 1, 0);
+
+		clutter_actor_show_all (expander);
+		g_signal_connect (mmview, "size-allocate", G_CALLBACK(mmv_fix_clutter_embed_width), mmview);
+		mmview->priv->mx_expander = expander;
+		mmview->priv->clutter_embed = embed;
+
+		glbody = create_gtk_actor (mmview->priv->total_box);
+		clutter_actor_set_position (glbody, 0, 0);
+		clutter_container_add_actor ((ClutterContainer *)mmview->priv->mx_expander, glbody);
+	}
+#endif
+
 	details_row = gtk_hbox_new (FALSE, 0);
 	gtk_widget_show (details_row);
 	gtk_box_pack_start ((GtkBox *)box, details_row, FALSE, FALSE, 0);
 
-//	gtk_container_add (mmview->short_header, box);
-	
 	/* To draw focus */
 	mmview->priv->focus = gtk_button_new (); gtk_widget_show (mmview->priv->focus);
 	g_signal_connect (mmview->priv->focus,  "focus-out-event", G_CALLBACK(mmv_focus_out), mmview);
@@ -1186,7 +1305,9 @@ mail_message_view_set_message (MailMessageView *mmview, CamelFolder *folder, con
 	gtk_box_pack_start ((GtkBox *)header_row, mmview->priv->focus, FALSE, FALSE, 0);
 	mmview->priv->header_row = header_row;
 	EXPOSE(header_row, mmview);
-	
+#if HAVE_CLUTTER
+	gtk_widget_hide (header_row);
+#endif	
 	mmview->priv->arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
 	gtk_widget_show (mmview->priv->arrow);
 	gtk_box_pack_start ((GtkBox *)header_row, mmview->priv->arrow, FALSE, FALSE, 2);
@@ -1211,6 +1332,10 @@ mail_message_view_set_message (MailMessageView *mmview, CamelFolder *folder, con
 	mmview->priv->normal[0] = g_strdup_printf("%s - %s", *strv, camel_message_info_subject(info));
 	mmview->priv->bold[0] = g_strdup_printf("<b>%s - %s</b>", *strv, camel_message_info_subject(info));
 
+#if HAVE_CLUTTER	
+	mx_expander_set_label (MX_EXPANDER (mmview->priv->mx_expander),mmview->priv->normal[0]);
+#endif
+
 	tmp = gtk_label_new (NULL);
 	gtk_widget_modify_fg (tmp, GTK_STATE_NORMAL, pcolor_fg_norm);
 	gtk_label_set_ellipsize ((GtkLabel *)tmp, PANGO_ELLIPSIZE_END);
@@ -1264,7 +1389,7 @@ mail_message_view_set_message (MailMessageView *mmview, CamelFolder *folder, con
 
 	
 	gtk_widget_show(mmview->short_header);
-	gtk_box_pack_start ((GtkBox *)mmview, box, FALSE, FALSE, 0);
+	gtk_box_pack_start ((GtkBox *)mmview->priv->total_box, box, FALSE, FALSE, 0);
 
 	/* Full Headers */
 	table = (GtkTable *) gtk_table_new (1, 2, FALSE);
@@ -1359,7 +1484,7 @@ mail_message_view_set_message (MailMessageView *mmview, CamelFolder *folder, con
 	gtk_button_set_image ((GtkButton *)tmp, gtk_image_new_from_pixbuf(img));
 	gtk_box_pack_start ((GtkBox *)vbox, tmp, FALSE, FALSE, 0);
 	
-	gtk_box_pack_start ((GtkBox *)mmview, mmview->main_header, TRUE, TRUE, 0);
+	gtk_box_pack_start ((GtkBox *)mmview->priv->total_box, mmview->main_header, TRUE, TRUE, 0);
 	gtk_widget_show_all (mmview->main_header);
 	gtk_widget_hide (mmview->main_header);
 	gtk_widget_hide (mmview->priv->html_headers);
@@ -1378,9 +1503,11 @@ mail_message_view_set_message (MailMessageView *mmview, CamelFolder *folder, con
 	gtk_widget_show(tmp);
 	gtk_widget_hide (vbox);
 	mmview->priv->spinner = vbox;
+#if !HAVE_CLUTTER	
 	gtk_box_pack_start ((GtkBox *)mmview->body, mmview->priv->spinner, FALSE, FALSE, 0);
-	gtk_box_pack_start ((GtkBox *)mmview, mmview->body, FALSE, FALSE, 2);
-	
+#endif
+	gtk_box_pack_start ((GtkBox *)mmview->priv->total_box, mmview->body, FALSE, FALSE, 2);
+
 	mmview->footer = gtk_hbox_new (FALSE, 0);
 	gtk_box_pack_start ((GtkBox *)mmview, mmview->footer, FALSE, FALSE, 2);
 	
diff --git a/src/mail-shell.c b/src/mail-shell.c
index 8c909d7..5d4b149 100644
--- a/src/mail-shell.c
+++ b/src/mail-shell.c
@@ -429,7 +429,7 @@ mail_shell_finalize (GObject *object)
 {
 	//FIXME: Unintialize the cleanup timeout.
 	//
-	G_OBJECT_CLASS (mail_shell_parent_class)->finalize (object);
+	//G_OBJECT_CLASS (mail_shell_parent_class)->finalize (object);
 }
 #if 0
 static void
diff --git a/src/main.c b/src/main.c
index 2289402..984dd41 100644
--- a/src/main.c
+++ b/src/main.c
@@ -50,10 +50,12 @@
 #include <unique/unique.h>
 #endif
 
-#if HAVE_ANERLEY
+#if HAVE_ANERLEY|HAVE_CLUTTER
 #include <clutter-gtk/clutter-gtk.h>
+#if HAVE_ANERLEY
 #include <nbtk/nbtk.h>
 #endif
+#endif
 
 gboolean windowed = FALSE;
 gboolean anjal_icon_decoration = FALSE;
@@ -277,12 +279,14 @@ main (int argc, char *argv[])
 	
 	gtk_set_locale ();
 
-#if HAVE_ANERLEY
+#if HAVE_ANERLEY|HAVE_CLUTTER
 	if (!gtk_clutter_init_with_args (&argc, &argv, _("Anjal email client"), entries, NULL, &error)) {
 		g_error ("Unable to start Anjal: %s\n", error->message);
 		g_error_free(error);
 	}
+#if HAVE_ANERLEY	
 	nbtk_style_load_from_file (nbtk_style_get_default (), PACKAGE_DATA_DIR G_DIR_SEPARATOR_S "anerley" G_DIR_SEPARATOR_S "style.css", NULL);
+#endif
 
 #else
 	if (!gtk_init_with_args (&argc, &argv, _("Anjal email client"), entries, NULL, &error)) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]