anjuta r4927 - in trunk: . libanjuta/interfaces plugins/build-basic-autotools plugins/message-view



Author: jhs
Date: Mon Apr  6 08:02:38 2009
New Revision: 4927
URL: http://svn.gnome.org/viewvc/anjuta?rev=4927&view=rev

Log:
2009-04-06  Johannes Schmid  <jhs gnome org>

	Based on patch from : Maxim Ermilov <zaspire rambler ru>

	* libanjuta/interfaces/libanjuta.idl:
	* plugins/build-basic-autotools/plugin.c
	(build_context_destroy_view), (build_regex_load),
	(on_build_terminated), (build_set_animation),
	(build_get_context_with_message):
	* plugins/message-view/anjuta-msgman.c
	(anjuta_msgman_set_view_icon),
	(anjuta_msgman_set_view_icon_from_stock):
	* plugins/message-view/anjuta-msgman.h:
	* plugins/message-view/plugin.c
	(ianjuta_msgman_set_view_icon_from_stock),
	(ianjuta_msgman_set_view_icon), (ianjuta_msgman_iface_init):
  Add animation for running builds. Automatically cancel build once the
  message tab is destroyed. (#564128)	

Modified:
   trunk/ChangeLog
   trunk/libanjuta/interfaces/libanjuta.idl
   trunk/plugins/build-basic-autotools/plugin.c
   trunk/plugins/message-view/anjuta-msgman.c
   trunk/plugins/message-view/anjuta-msgman.h
   trunk/plugins/message-view/plugin.c

Modified: trunk/libanjuta/interfaces/libanjuta.idl
==============================================================================
--- trunk/libanjuta/interfaces/libanjuta.idl	(original)
+++ trunk/libanjuta/interfaces/libanjuta.idl	Mon Apr  6 08:02:38 2009
@@ -2688,7 +2688,8 @@
 interface IAnjutaMessageManager
 {
 	#include "ianjuta-message-view.h"
-	
+	#include <gdk/gdk.h>
+
 	enum Error
 	{
 		DOESNT_EXIST
@@ -2777,6 +2778,30 @@
 	 *
 	 */
 	void set_view_title (IAnjutaMessageView *view, const gchar *title);
+
+	/**
+	 * ianjuta_message_manager_set_view_icon:
+	 * @obj: Self
+	 * @view: A message view
+	 * @icon: Sets the icon of view.
+	 * @err: Error propagation and reporting
+	 *
+	 * Sets the icon of view.
+	 *
+	 */
+	void set_view_icon (IAnjutaMessageView *view, GdkPixbufAnimation *icon);
+
+	/**
+	 * ianjuta_message_manager_set_view_icon_from_stock:
+	 * @obj: Self
+	 * @view: A message view
+	 * @icon: Sets the icon of view.
+	 * @err: Error propagation and reporting
+	 *
+	 * Sets the icon of view.
+	 *
+	 */
+	void set_view_icon_from_stock (IAnjutaMessageView *view, const gchar *icon);
 }
 
 /**

Modified: trunk/plugins/build-basic-autotools/plugin.c
==============================================================================
--- trunk/plugins/build-basic-autotools/plugin.c	(original)
+++ trunk/plugins/build-basic-autotools/plugin.c	Mon Apr  6 08:02:38 2009
@@ -461,6 +461,7 @@
 static gboolean
 build_context_destroy_view (BuildContext *context)
 {
+	BasicAutotoolsPlugin* plugin = ANJUTA_PLUGIN_BASIC_AUTOTOOLS (context->plugin);
 	if (context->message_view)
 	{
 		gtk_widget_destroy (GTK_WIDGET (context->message_view));
@@ -482,21 +483,22 @@
 					 NULL);
 	g_slist_free (context->locations);
 	context->locations = NULL;
-	
+
 	/* Empty context, remove from pool */
 	if (context->launcher == NULL)
-	{
-		ANJUTA_PLUGIN_BASIC_AUTOTOOLS (context->plugin)->contexts_pool =
-			g_list_remove (ANJUTA_PLUGIN_BASIC_AUTOTOOLS (context->plugin)->contexts_pool,
-							context);
+	{	
+		plugin->contexts_pool =
+			g_list_remove (plugin->contexts_pool,
+			               context);
 		g_free (context);
-		
-		return TRUE;
 	}
 	else
 	{
-		return FALSE;
+		/* Kill process */
+		anjuta_launcher_signal (context->launcher, SIGKILL);
 	}
+
+	return TRUE;
 }
 	
 static void
@@ -546,8 +548,7 @@
 		gchar **tokens;
 		BuildPattern *pattern;
 		
-		fgets (buffer, 1024, fp);
-		if (ferror (fp))
+		if (!fgets (buffer, 1024, fp))
 			break;
 		tokens = g_strsplit (buffer, "|||", 3);
 		
@@ -1057,19 +1058,28 @@
 	/* Message view could have been destroyed before */
 	if (context->message_view)
 	{
+		IAnjutaMessageManager *mesg_manager;
 		gchar *buff1;
 	
 		buff1 = g_strdup_printf (_("Total time taken: %lu secs\n"),
 								 time_taken);
+		mesg_manager = anjuta_shell_get_interface (ANJUTA_PLUGIN (context->plugin)->shell,
+									IAnjutaMessageManager, NULL);
 		if (status)
 		{
 			ianjuta_message_view_buffer_append (context->message_view,
 									_("Completed unsuccessfully\n"), NULL);
+			ianjuta_message_manager_set_view_icon_from_stock (mesg_manager,
+									context->message_view,
+									GTK_STOCK_STOP, NULL);
 		}
 		else
 		{
 			ianjuta_message_view_buffer_append (context->message_view,
 									   _("Completed successfully\n"), NULL);
+			ianjuta_message_manager_set_view_icon_from_stock (mesg_manager,
+									context->message_view,
+									GTK_STOCK_APPLY, NULL);
 		}
 		ianjuta_message_view_buffer_append (context->message_view, buff1, NULL);
 		g_free (buff1);
@@ -1100,6 +1110,45 @@
 	return TRUE;
 }
 
+static void
+build_set_animation (IAnjutaMessageManager* mesg_manager, BuildContext* context)
+{
+	GtkIconTheme *icon_theme = gtk_icon_theme_get_default ();
+	GtkIconInfo *icon_info;
+	const gchar *name;
+	icon_info = gtk_icon_theme_lookup_icon (icon_theme, "process-working", 16, 0);
+	name = gtk_icon_info_get_filename (icon_info);
+	if (name != NULL)
+	{
+		int size = gtk_icon_info_get_base_size (icon_info);
+		GdkPixbufSimpleAnim* anim = gdk_pixbuf_simple_anim_new (size, size, 5);
+		GdkPixbuf *image = gdk_pixbuf_new_from_file (name, NULL);
+		if (image)
+		{
+			int grid_width = gdk_pixbuf_get_width (image);
+			int grid_height = gdk_pixbuf_get_height (image);
+			int x,y;
+			for (y = 0; y < grid_height; y += size)
+			{
+				for (x = 0; x < grid_width ; x += size)
+				{
+					GdkPixbuf *pixbuf = gdk_pixbuf_new_subpixbuf (image, x, y, size,size);
+					if (pixbuf)
+					{
+						gdk_pixbuf_simple_anim_add_frame (anim, pixbuf);
+					}
+				}
+			}
+			ianjuta_message_manager_set_view_icon (mesg_manager,
+			                                       context->message_view,
+			                                       GDK_PIXBUF_ANIMATION (anim), NULL);
+			g_object_unref (image);
+		}
+	}
+	gtk_icon_info_free (icon_info);
+}
+
+
 static BuildContext*
 build_get_context_with_message(BasicAutotoolsPlugin *plugin, const gchar *dir)
 {
@@ -1150,6 +1199,7 @@
 	}
 	else
 	{
+		
 		/* If no free context found, create one */
 		context = g_new0 (BuildContext, 1);
 		context->plugin = ANJUTA_PLUGIN(plugin);
@@ -1159,6 +1209,7 @@
 		context->message_view =
 			ianjuta_message_manager_add_view (mesg_manager, mname,
 											  ICON_FILE, NULL);
+
 		g_signal_connect (G_OBJECT (context->message_view), "buffer_flushed",
 						  G_CALLBACK (on_build_mesg_format), context);
 		g_signal_connect (G_OBJECT (context->message_view), "message_clicked",
@@ -1166,6 +1217,7 @@
 		g_object_weak_ref (G_OBJECT (context->message_view),
 						   (GWeakNotify)on_message_view_destroyed, context);
 	}
+	build_set_animation (mesg_manager, context);
 
 	ianjuta_message_manager_set_current_view (mesg_manager,
 											  context->message_view, NULL);

Modified: trunk/plugins/message-view/anjuta-msgman.c
==============================================================================
--- trunk/plugins/message-view/anjuta-msgman.c	(original)
+++ trunk/plugins/message-view/anjuta-msgman.c	Mon Apr  6 08:02:38 2009
@@ -495,6 +495,35 @@
 	gtk_label_set_text (GTK_LABEL (page->label), title);
 }
 
+void
+anjuta_msgman_set_view_icon (AnjutaMsgman *msgman, MessageView *view,
+							  GdkPixbufAnimation *icon)
+{
+	AnjutaMsgmanPage *page;
+	
+	g_return_if_fail (icon != NULL);
+	
+	page = anjuta_msgman_page_from_widget (msgman, view);
+	g_return_if_fail (page != NULL);
+	
+	gtk_image_set_from_animation (GTK_IMAGE (page->pixmap), icon);
+}
+
+void
+anjuta_msgman_set_view_icon_from_stock (AnjutaMsgman *msgman, MessageView *view,
+							  const gchar *icon)
+{
+	AnjutaMsgmanPage *page;
+	
+	g_return_if_fail (icon != NULL);
+	
+	page = anjuta_msgman_page_from_widget (msgman, view);
+	g_return_if_fail (page != NULL);
+	
+	gtk_image_set_from_stock (GTK_IMAGE (page->pixmap), icon,
+							  GTK_ICON_SIZE_MENU);
+}
+
 gboolean
 anjuta_msgman_serialize (AnjutaMsgman *msgman, AnjutaSerializer *serializer)
 {

Modified: trunk/plugins/message-view/anjuta-msgman.h
==============================================================================
--- trunk/plugins/message-view/anjuta-msgman.h	(original)
+++ trunk/plugins/message-view/anjuta-msgman.h	Mon Apr  6 08:02:38 2009
@@ -68,6 +68,12 @@
 void anjuta_msgman_set_view_title (AnjutaMsgman *msgman, MessageView *view,
 								   const gchar *title);
 
+void anjuta_msgman_set_view_icon (AnjutaMsgman *msgman, MessageView *view,
+								  GdkPixbufAnimation *icon);
+
+void anjuta_msgman_set_view_icon_from_stock (AnjutaMsgman *msgman, MessageView *view,
+								             const gchar *icon);
+
 gboolean anjuta_msgman_serialize (AnjutaMsgman *msgman,
 								  AnjutaSerializer *serializer);
 gboolean anjuta_msgman_deserialize (AnjutaMsgman *msgman,

Modified: trunk/plugins/message-view/plugin.c
==============================================================================
--- trunk/plugins/message-view/plugin.c	(original)
+++ trunk/plugins/message-view/plugin.c	Mon Apr  6 08:02:38 2009
@@ -393,6 +393,26 @@
 }
 
 static void
+ianjuta_msgman_set_view_icon_from_stock (IAnjutaMessageManager *plugin,
+							  IAnjutaMessageView *message_view,
+							  const gchar *icon, GError ** e)
+{
+	GtkWidget *msgman = ANJUTA_PLUGIN_MESSAGE_VIEW (plugin)->msgman;
+	anjuta_msgman_set_view_icon_from_stock (ANJUTA_MSGMAN (msgman),
+								  MESSAGE_VIEW (message_view), icon);
+}
+
+static void
+ianjuta_msgman_set_view_icon (IAnjutaMessageManager *plugin,
+							  IAnjutaMessageView *message_view,
+							  GdkPixbufAnimation *icon, GError ** e)
+{
+	GtkWidget *msgman = ANJUTA_PLUGIN_MESSAGE_VIEW (plugin)->msgman;
+	anjuta_msgman_set_view_icon (ANJUTA_MSGMAN (msgman),
+								 MESSAGE_VIEW (message_view), icon);
+}
+
+static void
 ianjuta_msgman_iface_init (IAnjutaMessageManagerIface *iface)
 {
 	iface->add_view = ianjuta_msgman_add_view;
@@ -402,6 +422,8 @@
 	iface->set_current_view = ianjuta_msgman_set_current_view;
 	iface->get_all_views = ianjuta_msgman_get_all_views;
 	iface->set_view_title = ianjuta_msgman_set_view_title;
+	iface->set_view_icon = ianjuta_msgman_set_view_icon;
+	iface->set_view_icon_from_stock = ianjuta_msgman_set_view_icon_from_stock;
 }
 
 static guint notify_id;



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