Commit 3be465b9 authored by Johannes Schmid's avatar Johannes Schmid Committed by Johannes Schmid

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

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)	

svn path=/trunk/; revision=4927
parent 5eb70398
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)
2009-04-06 Yuriy Penkin <yuriy.penkin@gmail.com>
* plugins/project-wizard/anjuta-project-wizard.ui:
......@@ -2688,7 +2688,8 @@ interface IAnjutaMessageView
interface IAnjutaMessageManager
{
#include "ianjuta-message-view.h"
#include <gdk/gdk.h>
enum Error
{
DOESNT_EXIST
......@@ -2777,6 +2778,30 @@ interface IAnjutaMessageManager
*
*/
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);
}
/**
......
......@@ -461,6 +461,7 @@ build_context_destroy_command (BuildContext *context)
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 @@ build_context_destroy_view (BuildContext *context)
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 @@ build_regex_load ()
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 @@ on_build_terminated (AnjutaLauncher *launcher,
/* 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 @@ g_hashtable_foreach_true (gpointer key, gpointer value, gpointer user_data)
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 @@ build_get_context_with_message(BasicAutotoolsPlugin *plugin, const gchar *dir)
}
else
{
/* If no free context found, create one */
context = g_new0 (BuildContext, 1);
context->plugin = ANJUTA_PLUGIN(plugin);
......@@ -1159,6 +1209,7 @@ build_get_context_with_message(BasicAutotoolsPlugin *plugin, const gchar *dir)
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 @@ build_get_context_with_message(BasicAutotoolsPlugin *plugin, const gchar *dir)
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);
......
......@@ -495,6 +495,35 @@ anjuta_msgman_set_view_title (AnjutaMsgman *msgman, MessageView *view,
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)
{
......
......@@ -68,6 +68,12 @@ GList *anjuta_msgman_get_all_views (AnjutaMsgman * msgman);
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,
......
......@@ -392,6 +392,26 @@ ianjuta_msgman_set_view_title (IAnjutaMessageManager *plugin,
MESSAGE_VIEW (message_view), title);
}
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)
{
......@@ -402,6 +422,8 @@ ianjuta_msgman_iface_init (IAnjutaMessageManagerIface *iface)
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment