[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Graveman-cvs] Changes to graveman/current/src/gtk-mng-view.c
From: |
sylvain cresto |
Subject: |
[Graveman-cvs] Changes to graveman/current/src/gtk-mng-view.c |
Date: |
Fri, 29 Apr 2005 19:05:33 -0400 |
Index: graveman/current/src/gtk-mng-view.c
diff -u graveman/current/src/gtk-mng-view.c:1.1
graveman/current/src/gtk-mng-view.c:1.2
--- graveman/current/src/gtk-mng-view.c:1.1 Mon Apr 4 01:37:42 2005
+++ graveman/current/src/gtk-mng-view.c Fri Apr 29 23:05:29 2005
@@ -44,6 +44,7 @@
* Boston, MA 02111-1307, USA.
*/
+#include <graveman.h>
#include <gtk/gtkmain.h>
#include "gtk-mng-view.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -494,6 +495,58 @@
return TRUE;
}
+Tmng *gtk_mng_free(Tmng *Amng)
+{
+ if (!Amng) return NULL;
+
+ g_free(Amng->mng_data);
+
+ g_free(Amng);
+
+ return NULL;
+}
+
+Tmng *gtk_mng_read_file (const gchar* Afileformat, ...)
+{
+ gint fd;
+ guint bytes_read = 0;
+ Tmng *Lmng = g_malloc0(sizeof (Tmng));
+ va_list Largs;
+ gchar Lfile[MAXPATHLEN];
+
+ va_start(Largs, Afileformat);
+ g_vsnprintf(Lfile, MAXPATHLEN-1, Afileformat, Largs);
+ va_end(Largs);
+
+ if ((fd = open (Lfile, O_RDONLY)) == -1)
+ {
+ g_warning (Lfile);
+ g_free(Lmng);
+ return NULL;
+ }
+
+ Lmng->mng_data = g_new (guchar, _MNG_BLOCK_SIZE);
+ while ((bytes_read = read (fd, Lmng->mng_data + Lmng->size,
_MNG_BLOCK_SIZE)))
+ {
+ Lmng->size += bytes_read;
+ Lmng->mng_data = (guchar *) g_realloc (Lmng->mng_data, Lmng->size +
_MNG_BLOCK_SIZE);
+ }
+ close (fd);
+ Lmng->mng_data = (guchar *) g_realloc (Lmng->mng_data, Lmng->size);
+
+ return Lmng;
+}
+
+GtkMngView *gtk_mng_view_new_init(Tmng *Amng)
+{
+ GtkMngView *Awidgetmng = GTK_MNG_VIEW(gtk_mng_view_new());
+
+ if (Amng && Amng->mng_data && Amng->size)
+ gtk_mng_view_load_mng_from_memory(Awidgetmng, Amng->mng_data, Amng->size);
+
+ return Awidgetmng;
+}
+
/*
* vim:et:ts=8:sts=2:sw=2
*/
- [Graveman-cvs] Changes to graveman/current/src/gtk-mng-view.c,
sylvain cresto <=