[glade--]Fixes for image.cc and label.cc



Fixes the following problems:
  label.cc:
  - support for markup on strings

  image.cc: (embedding images had many errors)
  - avoids embedding the same image several times in the same file
  - casts the char data written to the file to ints instead (with gcc 3.0
    the data written would be the raw data from the image file...)
  - removed the extra error parameter to PixbufLoader::write(). Todo:
    catch exceptions instead.

See the attached diffs for details...

Have a nice day =)

-- 
Björn Axelsson
? .image.cc.swp
? diffs.txt
Index: image.cc
===================================================================
RCS file: /cvs/gnome/glade--/src/writers/image.cc,v
retrieving revision 1.24
diff -u -r1.24 image.cc
--- image.cc	31 Jul 2002 12:36:29 -0000	1.24
+++ image.cc	9 Dec 2002 13:16:17 -0000
@@ -21,6 +21,8 @@
 #include "misc.hh"
 #include <fstream>
 
+#include <set>
+
 class Gtk_Image : public Gtk_Misc
 {public:
 	typedef Gtk_Misc Parent;
@@ -37,9 +39,13 @@
 	virtual void ApplyPreferences(Tag &t) const;
 private:
 	void EmbedImage(CxxFile &f,const std::string &pixbuf) const;
+
+    static std::map<std::string, std::set<std::string, less<std::string> > > embeddedImages;    
 };
 
 static Gtk_Image Gtk_Image;
+    
+std::map<std::string, std::set<std::string, less<std::string> > > Gtk_Image::embeddedImages;  
 
 const std::string Gtk_Image::TypeName(const Widget &w) const
 {  return GtkPrefix()+"Image";
@@ -60,9 +66,13 @@
    if (Configuration.embed_images)
    {  if (!xpmname(pixbuf).empty())
          f.Include(Configuration.CString(Configuration.pixmap_dir_relative_to_src+"/"+pixbuf),true);
-      else if (GTKMM2)
-      {  f.Include("gdkmm/pixbufloader.h");
-         EmbedImage(f,pixbuf);
+      else if (GTKMM2)          
+      {  if (embeddedImages.find(f.FileName()) != embeddedImages.end()) 
+            f.Include("gdkmm/pixbufloader.h");
+         if (embeddedImages[f.FileName()].find(pixbuf) == embeddedImages[f.FileName()].end()) 
+         {  EmbedImage(f,pixbuf);
+            embeddedImages[f.FileName()].insert(pixbuf);
+         }
       }
    }      
 }
@@ -130,11 +140,9 @@
       else
       {  f.Declaration() << "Glib::RefPtr<Gdk::PixbufLoader> _" << instname
       		<< "_loader=Gdk::PixbufLoader::create()";
-      	 f.Declaration() << "GError *_" << instname << "_err=0";
       	 f.Statement() << "_" << instname << "_loader->write(" 
       	 	<< Configuration.CName(pixbuf) << "_data, sizeof " 
-      	 	<< Configuration.CName(pixbuf) << "_data, _" 
-      	 	<< instname << "_err)";
+      	 	<< Configuration.CName(pixbuf) << "_data)";
       	 f.Statement() << "_" << instname << "_loader->close()";
       }
      }
@@ -173,8 +181,8 @@
       {  /* unsigned ... hmmm g++3.1 does not like this ... */ char buf[16];
          is.read(buf,sizeof buf);
          size_t read=is.gcount();
-         f << '\t';
-         for (size_t x=0;x<read;++x) f << buf[x] << ',';
+         f << '\t';         
+         for (size_t x=0;x<read;++x) f << (unsigned int)(unsigned char)buf[x] << ',';
          f << '\n';
       }
    }
Index: label.cc
===================================================================
RCS file: /cvs/gnome/glade--/src/writers/label.cc,v
retrieving revision 1.25
diff -u -r1.25 label.cc
--- label.cc	15 Jun 2002 13:22:14 -0000	1.25
+++ label.cc	9 Dec 2002 13:16:17 -0000
@@ -61,4 +61,5 @@
 
    WriteEnumPropertyNS(w,f,instance, "justify");
    WriteBoolProperty(w,f,instance, "wrap", false, "line_wrap");
+   WriteBoolProperty(w,f,instance, "use_markup", false, "use_markup");
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]