Author: baby-guest
Date: 2007-07-04 09:20:01 +0000 (Wed, 04 Jul 2007)
New Revision: 3228

Modified:
   software/ui/src/pkgbrowser.cpp
Log:
Check if a real package is selected



Modified: software/ui/src/pkgbrowser.cpp
===================================================================
--- software/ui/src/pkgbrowser.cpp      2007-07-04 09:16:36 UTC (rev 3227)
+++ software/ui/src/pkgbrowser.cpp      2007-07-04 09:20:01 UTC (rev 3228)
@@ -64,88 +64,91 @@
                printf("  #%d : \"%s\"\n", n, (const char *)data);
                fflush(stdout);
 
-               char filename[PATH_MAX];
-               struct stat fileinfo;
-               Fl_Image *img = NULL;
-               if (snprintf(filename, PATH_MAX, "%s/%s.png", THUMBNAILSDIR, 
(const char *)data) &&
-                       stat(filename, &fileinfo) == 0)
-               { // Portable Network Graphics (PNG) image files
-                       // 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)
-               { // Joint Photographic Experts Group (JPEG) File Interchange 
Format (JFIF) images.
-                       img = new Fl_JPEG_Image(filename);
-                       printf("  JPEG Screenshot : \"%s\"\n", filename);
-               }
-               else if (snprintf(filename, PATH_MAX, "%s/%s.jpeg", 
THUMBNAILSDIR, (const char *)data) &&
-                       stat(filename, &fileinfo) == 0)
+               if (data)
                {
-                       img = new Fl_JPEG_Image(filename);
-                       printf("  JPEG Screenshot : \"%s\"\n", filename);
-               }
-               else if (snprintf(filename, PATH_MAX, "%s/%s.bmp", 
THUMBNAILSDIR, (const char *)data) &&
-                       stat(filename, &fileinfo) == 0)
-               { // Windows Bitmap (BMP) image files
-                       img = new Fl_BMP_Image(filename);
-                       printf("  BMP Screenshot : \"%s\"\n", filename);
-               }
-               else
-               { // TODO: Portable Anymap (PNM, PBM, PGM, PPM) image files
-                       img = NULL;
-               }
-               if (img && !img->count())
-               {
-                       printf("  Wrong Screenshot.\n");
-                       delete img;
-                       img = NULL;
-               }
-               if (!img)
-               {
-                       strncpy(filename, FILE_NO_SCREENSHOT, PATH_MAX);
-                       img = new Fl_PNG_Image(FILE_NO_SCREENSHOT);
-               }
+                       char filename[PATH_MAX];
+                       struct stat fileinfo;
+                       Fl_Image *img = NULL;
+                       if (snprintf(filename, PATH_MAX, "%s/%s.png", 
THUMBNAILSDIR, (const char *)data) &&
+                               stat(filename, &fileinfo) == 0)
+                       { // Portable Network Graphics (PNG) image files
+                               // 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)
+                       { // Joint Photographic Experts Group (JPEG) File 
Interchange Format (JFIF) images.
+                               img = new Fl_JPEG_Image(filename);
+                               printf("  JPEG Screenshot : \"%s\"\n", 
filename);
+                       }
+                       else if (snprintf(filename, PATH_MAX, "%s/%s.jpeg", 
THUMBNAILSDIR, (const char *)data) &&
+                               stat(filename, &fileinfo) == 0)
+                       {
+                               img = new Fl_JPEG_Image(filename);
+                               printf("  JPEG Screenshot : \"%s\"\n", 
filename);
+                       }
+                       else if (snprintf(filename, PATH_MAX, "%s/%s.bmp", 
THUMBNAILSDIR, (const char *)data) &&
+                               stat(filename, &fileinfo) == 0)
+                       { // Windows Bitmap (BMP) image files
+                               img = new Fl_BMP_Image(filename);
+                               printf("  BMP Screenshot : \"%s\"\n", filename);
+                       }
+                       else
+                       { // TODO: Portable Anymap (PNM, PBM, PGM, PPM) image 
files
+                               img = NULL;
+                       }
+                       if (img && !img->count())
+                       {
+                               printf("  Wrong Screenshot.\n");
+                               delete img;
+                               img = NULL;
+                       }
+                       if (!img)
+                       {
+                               strncpy(filename, FILE_NO_SCREENSHOT, PATH_MAX);
+                               img = new Fl_PNG_Image(FILE_NO_SCREENSHOT);
+                       }
 
-               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);
+                       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);
 
-               PackageRecord rec(ui->engine->apt().rawRecord((const char 
*)data));
+                       PackageRecord rec(ui->engine->apt().rawRecord((const 
char *)data));
 
-               char *pkg_txt = new char[4096];
-               if (ui)
-               {
-                       snprintf(pkg_txt, 4096, "<center><h1><a 
href=\"pkg:%s\">%s</a></h1></center><br /><center>%s</center><hr /><p>%s</p>",
-                               rec.package().c_str(),
-                               rec.package().c_str(),
-                               rec.shortDescription().c_str(),
-                               rec.longDescription().c_str()
-                       );
-                       ui->InfoView->value(pkg_txt);
-               }
-               delete [] pkg_txt;
+                       char *pkg_txt = new char[4096];
+                       if (ui)
+                       {
+                               snprintf(pkg_txt, 4096, "<center><h1><a 
href=\"pkg:%s\">%s</a></h1></center><br /><center>%s</center><hr /><p>%s</p>",
+                                       rec.package().c_str(),
+                                       rec.package().c_str(),
+                                       rec.shortDescription().c_str(),
+                                       rec.longDescription().c_str()
+                               );
+                               ui->InfoView->value(pkg_txt);
+                       }
+                       delete [] pkg_txt;
 
-               static int widths[] = { 80, 80, 0 }; // widths for each column
-               ui->DebTagsBrowser->clear();
-               ui->DebTagsBrowser->showcolsep(1);
-               ui->DebTagsBrowser->column_widths(widths);
-               ui->DebTagsBrowser->add("@[EMAIL PROTECTED]@[EMAIL 
PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL 
PROTECTED]");
+                       static int widths[] = { 80, 80, 0 }; // widths for each 
column
+                       ui->DebTagsBrowser->clear();
+                       ui->DebTagsBrowser->showcolsep(1);
+                       ui->DebTagsBrowser->column_widths(widths);
+                       ui->DebTagsBrowser->add("@[EMAIL PROTECTED]@[EMAIL 
PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL 
PROTECTED]");
 
-               set<Tag> tags = ui->engine->debtags().getTagsOfItem((const char 
*)data);
-               char *tag_txt = new char[512];
-               for (set<Tag>::const_iterator i = tags.begin(); i != 
tags.end(); ++i)
-               {
-                       snprintf(tag_txt, 512, "%s\t%s\t%s",
-                               gettext(i->facet().name().c_str()),
-                               gettext(i->name().c_str()),
-                               gettext(i->shortDescription().c_str())
-                       );
-                       ui->DebTagsBrowser->add(tag_txt);
+                       set<Tag> tags = 
ui->engine->debtags().getTagsOfItem((const char *)data);
+                       char *tag_txt = new char[512];
+                       for (set<Tag>::const_iterator i = tags.begin(); i != 
tags.end(); ++i)
+                       {
+                               snprintf(tag_txt, 512, "%s\t%s\t%s",
+                                       gettext(i->facet().name().c_str()),
+                                       gettext(i->name().c_str()),
+                                       gettext(i->shortDescription().c_str())
+                               );
+                               ui->DebTagsBrowser->add(tag_txt);
+                       }
+                       delete [] tag_txt;
                }
-               delete [] tag_txt;
 
                fflush(stdout);
        }


_______________________________________________
Pkg-games-commits mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/pkg-games-commits

Reply via email to