r3155 - in software/ui: data/screenshots src

Miriam Ruiz baby-guest at alioth.debian.org
Sat Jun 30 16:11:47 UTC 2007


Author: baby-guest
Date: 2007-06-30 16:11:47 +0000 (Sat, 30 Jun 2007)
New Revision: 3155

Added:
   software/ui/data/screenshots/foobillard.png
   software/ui/data/screenshots/pingus.png
   software/ui/data/screenshots/torcs.png
   software/ui/data/screenshots/wesnoth.png
Modified:
   software/ui/src/common.h
   software/ui/src/pkgbrowser.cpp
   software/ui/src/ui.fld
Log:
More development towards the support of screenshots



Added: software/ui/data/screenshots/foobillard.png
===================================================================
(Binary files differ)


Property changes on: software/ui/data/screenshots/foobillard.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: software/ui/data/screenshots/pingus.png
===================================================================
(Binary files differ)


Property changes on: software/ui/data/screenshots/pingus.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: software/ui/data/screenshots/torcs.png
===================================================================
(Binary files differ)


Property changes on: software/ui/data/screenshots/torcs.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: software/ui/data/screenshots/wesnoth.png
===================================================================
(Binary files differ)


Property changes on: software/ui/data/screenshots/wesnoth.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: software/ui/src/common.h
===================================================================
--- software/ui/src/common.h	2007-06-30 15:24:40 UTC (rev 3154)
+++ software/ui/src/common.h	2007-06-30 16:11:47 UTC (rev 3155)
@@ -37,6 +37,10 @@
 #define FILE_NO_SCREENSHOT DATADIR "/no_screenshot.png"
 #endif
 
+#ifndef THUMBNAILSDIR
+#define THUMBNAILSDIR DATADIR "/screenshots"
+#endif
+
 #include <stdlib.h>
 #include <stdio.h>
 

Modified: software/ui/src/pkgbrowser.cpp
===================================================================
--- software/ui/src/pkgbrowser.cpp	2007-06-30 15:24:40 UTC (rev 3154)
+++ software/ui/src/pkgbrowser.cpp	2007-06-30 16:11:47 UTC (rev 3155)
@@ -21,6 +21,7 @@
  */
 
 #include "pkgbrowser.h"
+#include "ui.h"
 #include "common.h"
 
 #include <stdio.h>
@@ -28,6 +29,8 @@
 #include <limits.h>
 #include <sys/stat.h>
 
+#include <FL/Fl_PNG_Image.H>
+
 PackageBrowser::PackageBrowser(int x, int y, int w, int h, const char *l)
 	: VersatileBrowser(x, y, w, h, l)
 {
@@ -49,15 +52,32 @@
 
 		char filename[PATH_MAX];
 		struct stat fileinfo;
-		snprintf(filename, PATH_MAX, "%s/screenshots/%s.png", DATADIR, (const char *)data);
-		if (stat(filename, &fileinfo) == 0)
-		{ // We were able to get the file attributes so the file obviously exists. 
+		Fl_Image *img = NULL;
+		if (snprintf(filename, PATH_MAX, "%s/%s.png", THUMBNAILSDIR, (const char *)data) &&
+			stat(filename, &fileinfo) == 0)
+		{ // We were able to get the file attributes so the file obviously exists.
+			img = new Fl_PNG_Image(filename);
+			printf("  PNG Screenshot : \"%s\"\n", filename);
 		}
+		else if (snprintf(filename, PATH_MAX, "%s/%s.jpg", THUMBNAILSDIR, (const char *)data) &&
+			stat(filename, &fileinfo) == 0)
+		{
+			img = new Fl_PNG_Image(FILE_NO_SCREENSHOT);
+		}
+		else if (snprintf(filename, PATH_MAX, "%s/%s.jpeg", THUMBNAILSDIR, (const char *)data) &&
+			stat(filename, &fileinfo) == 0)
+		{
+			img = new Fl_PNG_Image(FILE_NO_SCREENSHOT);
+		}
 		else
 		{
 			strncpy(filename, FILE_NO_SCREENSHOT, PATH_MAX);
+			img = new Fl_PNG_Image(FILE_NO_SCREENSHOT);
 		}
-		printf("  Screenshot : \"%s\"\n", filename);
+		Fl_Group *highest_parent=parent();
+		while (highest_parent->parent()) highest_parent = highest_parent->parent();
+		GamesUI *ui = highest_parent ? (GamesUI*)(highest_parent->user_data()) : NULL;
+		if (ui && img) ui->Screenshot(img);
 		fflush(stdout);
 	}
 }

Modified: software/ui/src/ui.fld
===================================================================
--- software/ui/src/ui.fld	2007-06-30 15:24:40 UTC (rev 3154)
+++ software/ui/src/ui.fld	2007-06-30 16:11:47 UTC (rev 3155)
@@ -21,17 +21,19 @@
     Fl_Image *i=ScreenshotWidget->image();
     ScreenshotWidget->image(NULL);
     delete i;
-  }} {selected
-    }
+  }} {}
   }
   Function {Screenshot(Fl_Image *img)} {open return_type void
   } {
-    code {if (ScreenshotWidget->image() == NULL) {
-    Fl_Image *i=ScreenshotWidget->image();
+    code {Fl_Image *i=ScreenshotWidget->image();
+  printf("Adding new  screenshot.\\n");
+  ScreenshotWidget->image(img);
+  if (i != NULL) {
+    printf("Deleting old screenshot.\\n");
     delete i;
+  }} {selected
+    }
   }
-  ScreenshotWidget->image(img);} {}
-  }
   Function {CreateMainWindow()} {open
   } {
     Fl_Window {} {open




More information about the Pkg-games-commits mailing list