glibmm r695 - in trunk: . gio/src tests tests/giomm_ioerror



Author: murrayc
Date: Fri Jul 25 14:28:32 2008
New Revision: 695
URL: http://svn.gnome.org/viewvc/glibmm?rev=695&view=rev

Log:
2008-07-25  Murray Cumming  <murrayc murrayc com>

* gio/src/volumemonitor.hg: Added the drive_eject_button signal.

2008-07-25  Murray Cumming  <murrayc murrayc com>

* gio/src/gio_enums.defs: Hacked in a replacement 
enum for Gio::Error::HOST_NOT_FOUND as 
Gio::Error::HOST_WAS_NOT_FOUND, to avoid a clash with 
a netdb.h define.
Bug #529496.
* configure.in:
* tests/Makefile.am:
* tests/giomm_ioerror/Makefile.am:
* tests/giomm_ioerror/main.cc: Added a test to make sure 
that our hacked-in enum value stays hacked in.

Added:
   trunk/tests/giomm_ioerror/
   trunk/tests/giomm_ioerror/Makefile.am
   trunk/tests/giomm_ioerror/main.cc
Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/gio/src/gio_enums.defs
   trunk/gio/src/volumemonitor.hg
   trunk/tests/Makefile.am

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Fri Jul 25 14:28:32 2008
@@ -304,6 +304,7 @@
     tests/glibmm_value/Makefile
     tests/glibmm_tree/Makefile
     tests/giomm_simple/Makefile
+    tests/giomm_ioerror/Makefile
     tests/glibmm_date/Makefile
 
   examples/Makefile

Modified: trunk/gio/src/gio_enums.defs
==============================================================================
--- trunk/gio/src/gio_enums.defs	(original)
+++ trunk/gio/src/gio_enums.defs	Fri Jul 25 14:28:32 2008
@@ -162,6 +162,12 @@
   )
 )
 
+; We added G_IO_ERROR_HOST_WAS_NOT_FOUND and deprecated G_IO_ERROR_HOST_WAS_NOT_FOUND,
+; because it clashes with a HOST_NOT_FOUND define in netdb.h.
+; http://bugzilla.gnome.org/show_bug.cgi?id=529496
+; We need to deprecate HOST_NOT_FOUND, but we don't currently document generated enums 
+; at all: http://bugzilla.gnome.org/show_bug.cgi?id=544692
+; murrayc
 (define-enum-extended IOErrorEnum
   (in-module "G")
   (c-name "GIOErrorEnum")
@@ -195,6 +201,7 @@
     '("busy" "G_IO_ERROR_BUSY" "26")
     '("would-block" "G_IO_ERROR_WOULD_BLOCK" "27")
     '("host-not-found" "G_IO_ERROR_HOST_NOT_FOUND" "28")
+    '("host-was-not-found" "G_IO_ERROR_HOST_WAS_NOT_FOUND" "28")
     '("would-merge" "G_IO_ERROR_WOULD_MERGE" "29")
     '("failed-handled" "G_IO_ERROR_FAILED_HANDLED" "30")
   )

Modified: trunk/gio/src/volumemonitor.hg
==============================================================================
--- trunk/gio/src/volumemonitor.hg	(original)
+++ trunk/gio/src/volumemonitor.hg	Fri Jul 25 14:28:32 2008
@@ -73,6 +73,9 @@
   _WRAP_SIGNAL(void drive_disconnected(const Glib::RefPtr<Drive>& drive), drive_disconnected)
   _WRAP_SIGNAL(void drive_changed(const Glib::RefPtr<Drive>& drive), drive_changed)
 
+  //TODO: Remove no_default_handler when we can break ABI:
+  _WRAP_SIGNAL(void drive_eject_button(const Glib::RefPtr<Drive>& drive), drive_eject_button, no_default_handler)
+
   gboolean (*is_supported)          (void);
 
   //TODO: Use ListHandle?

Modified: trunk/tests/Makefile.am
==============================================================================
--- trunk/tests/Makefile.am	(original)
+++ trunk/tests/Makefile.am	Fri Jul 25 14:28:32 2008
@@ -1,4 +1,4 @@
-test_dirs = glibmm_value glibmm_tree glibmm_date giomm_simple 
+test_dirs = glibmm_value glibmm_tree glibmm_date giomm_simple giomm_ioerror
 
 SUBDIRS = $(test_dirs)
 EXTRA_DIST = Makefile.am_fragment

Added: trunk/tests/giomm_ioerror/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/tests/giomm_ioerror/Makefile.am	Fri Jul 25 14:28:32 2008
@@ -0,0 +1,7 @@
+include $(top_srcdir)/tests/Makefile.am_fragment
+
+noinst_PROGRAMS = test
+test_SOURCES = main.cc
+
+
+

Added: trunk/tests/giomm_ioerror/main.cc
==============================================================================
--- (empty file)
+++ trunk/tests/giomm_ioerror/main.cc	Fri Jul 25 14:28:32 2008
@@ -0,0 +1,50 @@
+#include <giomm.h>
+#include <iostream>
+#include <string.h>
+
+int main(int argc, char** argv)
+{
+  Glib::init();
+  Gio::init();
+
+  try
+  {
+    Glib::RefPtr<Gio::File> file = Gio::File::create_for_path("/home/murrayc/test.txt");
+    if(!file)
+      std::cerr << "Gio::File::create_for_path() returned an empty RefPtr." << std::endl;
+
+    Glib::RefPtr<Gio::FileInputStream> stream = file->read();
+    if(!stream)
+      std::cerr << "Gio::File::read() returned an empty RefPtr." << std::endl;
+
+    gchar buffer[1000]; //TODO: This is unpleasant.
+    memset(buffer, 0, 1000);
+    const gsize bytes_read = stream->read(buffer, 1000);
+    
+    if(bytes_read)
+      std::cout << "File contents read: " << buffer << std::endl;
+    else
+      std::cerr << "Gio::InputStream::read() read 0 bytes." << std::endl;
+
+  }
+  catch(const Gio::Error& ex)
+  {
+    //This is just here to check that HOST_WAS_NOT_FOUND is still in our API,
+    //because we hack it into our gio_enums.defs file and there is a risk of 
+    //losing it when we regenerate that file. murrayc.
+    if(ex.code() == Gio::Error::HOST_WAS_NOT_FOUND)
+    {
+      std::cerr << "Host was not found." << std::endl;
+    }
+    else
+      std::cerr << "Gio::Error exception caught: " << ex.what() << std::endl; 
+  }
+  catch(const Glib::Exception& ex)
+  {
+    std::cerr << "Exception caught: " << ex.what() << std::endl; 
+  }
+
+
+  return 0;
+}
+



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