gtkmm-documentation r29 - in trunk: . examples/book/giomm examples/book/giomm/volumes



Author: murrayc
Date: Thu Jan 24 16:07:14 2008
New Revision: 29
URL: http://svn.gnome.org/viewvc/gtkmm-documentation?rev=29&view=rev

Log:
2008-01-24  Murray Cumming  <murrayc murrayc com>

* configure.in:
* examples/book/giomm/Makefile.am:
* examples/book/giomm/volumes/main.cc: Added example of the use of 
Gio::VolumeMonitor. However, this currently crashes due to 
gio bug #511814. We can work around that in giomm if necessary.

Added:
   trunk/examples/book/giomm/volumes/
      - copied from r28, /trunk/examples/book/giomm/directory_list/
Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/examples/book/giomm/Makefile.am
   trunk/examples/book/giomm/volumes/main.cc

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Thu Jan 24 16:07:14 2008
@@ -309,6 +309,7 @@
         examples/book/giomm/Makefile
           examples/book/giomm/directory_list/Makefile
           examples/book/giomm/read_file/Makefile
+          examples/book/giomm/volumes/Makefile
         examples/book/frame/Makefile
         examples/book/helloworld/Makefile
         examples/book/helloworld2/Makefile

Modified: trunk/examples/book/giomm/Makefile.am
==============================================================================
--- trunk/examples/book/giomm/Makefile.am	(original)
+++ trunk/examples/book/giomm/Makefile.am	Thu Jan 24 16:07:14 2008
@@ -1 +1 @@
-SUBDIRS = directory_list read_file
+SUBDIRS = directory_list read_file volumes

Modified: trunk/examples/book/giomm/volumes/main.cc
==============================================================================
--- /trunk/examples/book/giomm/directory_list/main.cc	(original)
+++ trunk/examples/book/giomm/volumes/main.cc	Thu Jan 24 16:07:14 2008
@@ -1,46 +1,29 @@
-//$Id: main.cc 836 2007-05-09 03:02:38Z jjongsma $ -*- c++ -*-
-
-/* gtkmm example Copyright (C) 2002 gtkmm development team
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
 #include <giomm.h>
 #include <iostream>
 
-
 int main(int argc, char** argv)
 {
   Gio::init();
 
   try
   {
-    Glib::RefPtr<Gio::File> directory = Gio::File::create_for_path("/home/murrayc/");
-    if(!directory)
-      std::cerr << "Gio::File::create_for_path() returned an empty RefPtr." << std::endl;
-
-    Glib::RefPtr<Gio::FileEnumerator> enumerator = directory->enumerate_children();
-    if(!enumerator)
-      std::cerr << "Gio::File::enumerate_children() returned an empty RefPtr." << std::endl;
+    Glib::RefPtr<Gio::VolumeMonitor> volume_monitor = Gio::VolumeMonitor::get();
+    if(!volume_monitor)
+      std::cerr << "Gio::VolumeMonitor::get() failed." << std::endl;
+
+    typedef std::list< Glib::RefPtr<Gio::Drive> > type_list_drives;
+    type_list_drives list_drives = volume_monitor->get_connected_drives();
 
-    Glib::RefPtr<Gio::FileInfo> file_info = enumerator->next_file();
-    while(file_info)
+    if(list_drives.empty())
+      std::cout << "No drives are connected." << std::endl;
+
+    for(type_list_drives::iterator iter = list_drives.begin(); iter != list_drives.end(); ++iter)
     {
-      std::cout << "file: " << file_info->get_name() << std::endl;
-      file_info = enumerator->next_file();
-    }
+      Glib::RefPtr<Gio::Drive> drive = *iter;
+      std::cout << "drive: " << drive->get_name() << std::endl;
 
+      //TODO: get the volumes in the drive.
+    }
   }
   catch(const Glib::Exception& ex)
   {
@@ -48,6 +31,7 @@
   }
 
 
+
   return 0;
 }
 



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