[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r22040 - in gnunet-gtk: contrib src/fs src/lib
From: |
gnunet |
Subject: |
[GNUnet-SVN] r22040 - in gnunet-gtk: contrib src/fs src/lib |
Date: |
Sat, 16 Jun 2012 16:09:45 +0200 |
Author: grothoff
Date: 2012-06-16 16:09:45 +0200 (Sat, 16 Jun 2012)
New Revision: 22040
Added:
gnunet-gtk/src/lib/animations.c
Modified:
gnunet-gtk/contrib/gnunet_fs_gtk_publish_tab.glade
gnunet-gtk/contrib/gnunet_fs_gtk_search_tab.glade
gnunet-gtk/contrib/gnunet_fs_gtk_unindex.glade
gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
gnunet-gtk/src/fs/gnunet-fs-gtk_unindex.c
gnunet-gtk/src/lib/Makefile.am
Log:
-code towards fixing #2217
Modified: gnunet-gtk/contrib/gnunet_fs_gtk_publish_tab.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_fs_gtk_publish_tab.glade 2012-06-16 11:18:44 UTC
(rev 22039)
+++ gnunet-gtk/contrib/gnunet_fs_gtk_publish_tab.glade 2012-06-16 14:09:45 UTC
(rev 22040)
@@ -16,6 +16,8 @@
<column type="gpointer"/>
<!-- column-name result_string -->
<column type="gchararray"/>
+ <!-- column-name status_icon -->
+ <column type="GdkPixbuf"/>
</columns>
</object>
<object class="GtkWindow" id="_publish_frame_window">
Modified: gnunet-gtk/contrib/gnunet_fs_gtk_search_tab.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_fs_gtk_search_tab.glade 2012-06-16 11:18:44 UTC
(rev 22039)
+++ gnunet-gtk/contrib/gnunet_fs_gtk_search_tab.glade 2012-06-16 14:09:45 UTC
(rev 22040)
@@ -38,6 +38,8 @@
<column type="gchararray"/>
<!-- column-name downloaded_anonymity -->
<column type="gint"/>
+ <!-- column-name status_icon -->
+ <column type="GdkPixbuf"/>
</columns>
</object>
<object class="GtkWindow" id="_search_result_frame_window">
Modified: gnunet-gtk/contrib/gnunet_fs_gtk_unindex.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_fs_gtk_unindex.glade 2012-06-16 11:18:44 UTC
(rev 22039)
+++ gnunet-gtk/contrib/gnunet_fs_gtk_unindex.glade 2012-06-16 14:09:45 UTC
(rev 22040)
@@ -18,6 +18,8 @@
<column type="gboolean"/>
<!-- column-name error_message -->
<column type="gchararray"/>
+ <!-- column-name status_icon -->
+ <column type="GdkPixbuf"/>
</columns>
</object>
<object class="GtkDialog" id="GNUNET_FS_GTK_unindex_dialog">
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c 2012-06-16 11:18:44 UTC
(rev 22039)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c 2012-06-16 14:09:45 UTC
(rev 22040)
@@ -119,6 +119,12 @@
* A gint.
*/
SEARCH_TAB_MC_DOWNLOADED_ANONYMITY = 16,
+
+ /**
+ * A GdkPixbuf.
+ */
+ SEARCH_TAB_MC_STATUS_ICON = 17
+
};
@@ -156,6 +162,11 @@
* A gchararray.
*/
PUBLISH_TAB_MC_RESULT_STRING = 5,
+
+ /**
+ * A GdkPixbuf.
+ */
+ PUBLISH_TAB_MC_STATUS_ICON = 6
};
@@ -218,7 +229,6 @@
};
-
/**
* Head of linked list of tabs for searches.
*/
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_unindex.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_unindex.c 2012-06-16 11:18:44 UTC (rev
22039)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_unindex.c 2012-06-16 14:09:45 UTC (rev
22040)
@@ -67,7 +67,12 @@
/**
* A gchararray.
*/
- UNINDEX_MC_ERROR = 6
+ UNINDEX_MC_ERROR = 6,
+
+ /**
+ * A GdkPixbuf.
+ */
+ UNINDEX_MC_STATUS_ICON = 7
};
Modified: gnunet-gtk/src/lib/Makefile.am
===================================================================
--- gnunet-gtk/src/lib/Makefile.am 2012-06-16 11:18:44 UTC (rev 22039)
+++ gnunet-gtk/src/lib/Makefile.am 2012-06-16 14:09:45 UTC (rev 22040)
@@ -13,6 +13,7 @@
libgnunetgtk_la_SOURCES = \
about.c \
+ animations.c \
eventloop.c \
glade.c \
nls.c \
Added: gnunet-gtk/src/lib/animations.c
===================================================================
--- gnunet-gtk/src/lib/animations.c (rev 0)
+++ gnunet-gtk/src/lib/animations.c 2012-06-16 14:09:45 UTC (rev 22040)
@@ -0,0 +1,223 @@
+/*
+ This file is part of GNUnet.
+ (C) 2012 Christian Grothoff (and other contributing authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/lib/animations.c
+ * @brief drawing animations in gnunet-gtk
+ * @author Christian Grothoff
+ * @author LRN
+ */
+#include "gnunet_gtk.h"
+
+
+#define TICKER_DELAY GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_MILLISECONDS, 100)
+
+
+struct GNUNET_FS_AnimationContext
+{
+ struct GNUNET_FS_AnimationContext *next;
+
+ struct GNUNET_FS_AnimationContext *prev;
+
+ GdkPixbufAnimation *ani;
+
+ GdkPixbufAnimationIter *iter;
+
+ GdkPixbuf *pixbuf;
+
+};
+
+
+struct GNUNET_FS_AnimationTreeViewHandle
+{
+ struct GNUNET_FS_AnimationTreeViewHandle *next;
+
+ struct GNUNET_FS_AnimationTreeViewHandle *prev;
+
+ GtkTreeView *tv;
+
+ GtkTreeViewColumn *image_col;
+};
+
+
+static struct GNUNET_FS_AnimationContext *animation_head;
+
+static struct GNUNET_FS_AnimationContext *animation_tail;
+
+static struct GNUNET_FS_AnimationTreeViewHandle *atv_head;
+
+static struct GNUNET_FS_AnimationTreeViewHandle *atv_tail;
+
+static GNUNET_SCHEDULER_TaskIdentifier ticker_task;
+
+
+struct GNUNET_FS_AnimationContext *
+GNUNET_GTK_animation_context_create (const char *filename)
+{
+ GError *err = NULL;
+ struct GNUNET_FS_AnimationContext *ac;
+
+ ac = GNUNET_malloc (sizeof (struct GNUNET_FS_AnimationContext));
+ ac->ani = gdk_pixbuf_animation_new_from_file (filename, &err);
+ ac->iter = gdk_pixbuf_animation_get_iter (ac->ani, NULL);
+ ac->pixbuf = gdk_pixbuf_copy (gdk_pixbuf_animation_iter_get_pixbuf
(ac->iter));
+ GNUNET_CONTAINER_DLL_insert (animation_head,
+ animation_tail,
+ ac);
+ return ac;
+}
+
+
+void
+GNUNET_GTK_animation_context_destroy (struct GNUNET_FS_AnimationContext *ac)
+{
+ g_object_unref (ac->pixbuf);
+ g_object_unref (ac->iter);
+ g_object_unref (ac->ani);
+ GNUNET_CONTAINER_DLL_remove (animation_head,
+ animation_tail,
+ ac);
+ GNUNET_free (ac);
+}
+
+
+GdkPixbuf *
+GNUNET_GTK_animation_context_get_pixbuf (struct GNUNET_FS_AnimationContext *ac)
+{
+ return ac->pixbuf;
+}
+
+
+/**
+ * Advance the given animation by a frame, if the time is ripe.
+ *
+ * @param ac animation to advance
+ * @return 0 if nothing needed to be done
+ */
+static int
+tick_animation (struct GNUNET_FS_AnimationContext *ac)
+{
+ GdkPixbuf *pixbuf;
+ gint width;
+ gint height;
+
+ if (!gdk_pixbuf_animation_iter_advance (ac->iter, NULL))
+ return 0;
+ pixbuf = gdk_pixbuf_animation_iter_get_pixbuf (ac->iter);
+ width = gdk_pixbuf_get_width (pixbuf);
+ height = gdk_pixbuf_get_height (pixbuf);
+ gdk_pixbuf_copy_area (pixbuf, 0, 0, width, height, ac->pixbuf, 0, 0);
+ return 1;
+}
+
+
+static void
+redraw_tree_view (struct GNUNET_FS_AnimationTreeViewHandle *atv)
+{
+ GdkWindow *gw;
+ GdkRectangle r;
+ GdkRectangle tr;
+ gint x;
+ gint width;
+
+ gw = gtk_widget_get_window (GTK_WIDGET (atv->tv));
+
+ /* Get column x and width in bin window coordinates */
+ gtk_tree_view_get_cell_area (atv->tv, NULL, atv->image_col, &r);
+ /* Convert x and width to window coordinates */
+ x = r.x;
+ width = r.width;
+ gtk_tree_view_convert_bin_window_to_widget_coords (atv->tv, x, 0, &r.x,
NULL);
+ gtk_tree_view_convert_bin_window_to_widget_coords (atv->tv, x + width, 0,
&r.width, NULL);
+
+ /* Get visible area of the treeview, in tree coordinates */
+ gtk_tree_view_get_visible_rect (atv->tv, &tr);
+
+ /* Convert y and height of the visible area to widget coordinates */
+ gtk_tree_view_convert_tree_to_widget_coords (atv->tv, 0, tr.y, NULL, &r.y);
+ gtk_tree_view_convert_tree_to_widget_coords (atv->tv, 0, tr.y + tr.height,
NULL, &r.height);
+
+ /* r now encloses only column image_col, redraw it */
+ gdk_window_invalidate_rect (gw, &r, TRUE);
+}
+
+
+/**
+ * Task run periodically to advance all of our animations.
+ *
+ * @param cls closure, unused
+ * @param tc scheduler context, unused
+ */
+static void
+ticker (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct GNUNET_FS_AnimationContext *pos;
+ struct GNUNET_FS_AnimationTreeViewHandle *atv;
+ unsigned int counter;
+
+ ticker_task = GNUNET_SCHEDULER_add_delayed (TICKER_DELAY,
+ &ticker,
+ NULL);
+ counter = 0;
+ for (pos = animation_head; NULL != pos; pos = pos->next)
+ counter += tick_animation (pos);
+ if (0 == counter)
+ return; /* nothing to be done */
+ for (atv = atv_head; NULL != atv; atv = atv->next)
+ redraw_tree_view (atv);
+}
+
+
+struct GNUNET_FS_AnimationTreeViewHandle *
+GNUNET_GTK_animation_tree_view_register (GtkTreeView *tv,
+ GtkTreeViewColumn *image_col)
+{
+ struct GNUNET_FS_AnimationTreeViewHandle *atv;
+
+ atv = GNUNET_malloc (sizeof (struct GNUNET_FS_AnimationTreeViewHandle));
+ atv->tv = tv;
+ atv->image_col = image_col;
+ GNUNET_CONTAINER_DLL_insert (atv_head,
+ atv_tail,
+ atv);
+ if (GNUNET_SCHEDULER_NO_TASK == ticker_task)
+ ticker_task = GNUNET_SCHEDULER_add_delayed (TICKER_DELAY,
+ &ticker,
+ NULL);
+ return atv;
+}
+
+
+void
+GNUNET_GTK_animation_tree_view_unregister (struct
GNUNET_FS_AnimationTreeViewHandle *atv)
+{
+ GNUNET_CONTAINER_DLL_remove (atv_head,
+ atv_tail,
+ atv);
+ GNUNET_free (atv);
+ if (NULL != atv_head)
+ return;
+ GNUNET_SCHEDULER_cancel (ticker_task);
+ ticker_task = GNUNET_SCHEDULER_NO_TASK;
+}
+
+
+/* end of animations.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r22040 - in gnunet-gtk: contrib src/fs src/lib,
gnunet <=