glibmm r688 - in trunk: . gio/src tools/m4
- From: murrayc svn gnome org
- To: svn-commits-list gnome org
- Subject: glibmm r688 - in trunk: . gio/src tools/m4
- Date: Wed, 16 Jul 2008 12:09:59 +0000 (UTC)
Author: murrayc
Date: Wed Jul 16 12:09:59 2008
New Revision: 688
URL: http://svn.gnome.org/viewvc/glibmm?rev=688&view=rev
Log:
2008-07-16 Murray Cumming <murrayc murrayc com>
* gio/src/file.ccg:
* gio/src/file.hg: Added make_directory_with_parents(),
query_file_type(), monitor().
* gio/src/fileenumerator.ccg:
* gio/src/fileenumerator.hg: Added get_container().
* gio/src/mount.hg: Added guess_content_type() and
guess_content_type_finish().
* gio/src/themedicon.hg: Added prepend_name().
* gio/src/volume.hg: Added get_activation_root().
* tools/m4/convert_gio.m4: Added a necessary conversion.
Modified:
trunk/ChangeLog
trunk/gio/src/file.ccg
trunk/gio/src/file.hg
trunk/gio/src/fileenumerator.ccg
trunk/gio/src/fileenumerator.hg
trunk/gio/src/mount.ccg
trunk/gio/src/mount.hg
trunk/gio/src/themedicon.hg
trunk/gio/src/volume.hg
trunk/tools/m4/convert_gio.m4
Modified: trunk/gio/src/file.ccg
==============================================================================
--- trunk/gio/src/file.ccg (original)
+++ trunk/gio/src/file.ccg Wed Jul 16 12:09:59 2008
@@ -313,6 +313,10 @@
return g_file_query_exists(const_cast<GFile*>(gobj()), NULL);
}
+FileType File::query_file_type(FileQueryInfoFlags flags) const
+{
+ return (FileType)g_file_query_file_type(const_cast<GFile*>(gobj()), (GFileQueryInfoFlags)flags, NULL);
+}
void
File::query_info_async(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, const std::string& attributes, FileQueryInfoFlags flags, int io_priority) const
@@ -1620,6 +1624,46 @@
return retvalue;
}
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+Glib::RefPtr<FileMonitor> File::monitor(const Glib::RefPtr<Cancellable>& cancellable, FileMonitorFlags flags)
+#else
+Glib::RefPtr<FileMonitor> File::monitor(const Glib::RefPtr<Cancellable>& cancellable, FileMonitorFlags flags, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+ GError* gerror = 0;
+ Glib::RefPtr<FileMonitor> retvalue = Glib::wrap(g_file_monitor(gobj(), ((GFileMonitorFlags)(flags)), const_cast<GCancellable*>(Glib::unwrap(cancellable)), &(gerror)));
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ if(gerror)
+ ::Glib::Error::throw_exception(gerror);
+#else
+ if(gerror)
+ error = ::Glib::Error::throw_exception(gerror);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+ return retvalue;
+}
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+Glib::RefPtr<FileMonitor> File::monitor(FileMonitorFlags flags)
+#else
+Glib::RefPtr<FileMonitor> File::monitor(FileMonitorFlags flags, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+ GError* gerror = 0;
+ Glib::RefPtr<FileMonitor> retvalue = Glib::wrap(g_file_monitor(gobj(), ((GFileMonitorFlags)(flags)), NULL, &(gerror)));
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ if(gerror)
+ ::Glib::Error::throw_exception(gerror);
+#else
+ if(gerror)
+ error = ::Glib::Error::throw_exception(gerror);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+ return retvalue;
+}
+
+
#ifdef GLIBMM_EXCEPTIONS_ENABLED
Glib::RefPtr<FileInputStream> File::read()
#else
Modified: trunk/gio/src/file.hg
==============================================================================
--- trunk/gio/src/file.hg (original)
+++ trunk/gio/src/file.hg Wed Jul 16 12:09:59 2008
@@ -567,7 +567,6 @@
_WRAP_METHOD(bool query_exists(const Glib::RefPtr<Cancellable>& cancellable) const, g_file_query_exists)
-
/** Utility function to check if a particular file exists. This is
* implemented using query_info() and as such does blocking I/O.
*
@@ -596,6 +595,21 @@
bool query_exists() const;
+ _WRAP_METHOD(FileType query_file_type(FileQueryInfoFlags flags, const Glib::RefPtr<Cancellable>& cancellable) const, g_file_query_file_type)
+
+ /** Utility function to inspect the #GFileType of a file. This is
+ * implemented using query_info() and as such does blocking I/O.
+ *
+ * The primary use case of this method is to check if a file is a regular file,
+ * directory, or symlink.
+ *
+ * @param flags: a set of FileQueryInfoFlags passed to query_info().
+ * @results The FileType of the file, or FILE_TYPE_UNKNOWN if the file does not exist.
+ *
+ * @newin2p18
+ */
+ FileType query_file_type(FileQueryInfoFlags flags = FILE_QUERY_INFO_NONE) const;
+
/** Asynchronously gets the requested information about specified file. The result is a FileInfo object that contains key-value attributes (such as type or size for the file).
*
* For more details, see query_info() which is the synchronous version of this call.
@@ -1109,7 +1123,13 @@
g_file_make_directory,
errthrow)
- /** Creates a directory.
+ /** Creates a directory.
+ * Note that this will only create a child directory of the immediate parent
+ * directory of the path or URI given by the File. To recursively create
+ * directories, see make_directory_with_parents(). This function will fail if
+ * the parent directory does not exist, throwing an exception with
+ * IO_ERROR_NOT_FOUND. If the file system doesn't support creating directories,
+ * this function will fail, throwing an exception with IO_ERROR_NOT_SUPPORTED.
*
* @return <tt>true</tt> on successful creation, <tt>false</tt> otherwise.
*/
@@ -1119,6 +1139,25 @@
bool make_directory(std::auto_ptr<Glib::Error>& error);
#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+ _WRAP_METHOD(bool make_directory_with_parents(const Glib::RefPtr<Cancellable>& cancellable),
+ g_file_make_directory_with_parents,
+ errthrow)
+
+ /** Creates a directory and any parent directories that may not exist, similar to 'mkdir -p'.
+ * If the file system does not support creating directories, this function will fail,
+ * throwing an exception with IO_ERROR_NOT_SUPPORTED.
+ *
+ * @return <tt>true</tt> on successful creation, <tt>false</tt> otherwise.
+ *
+ * @newin2p18
+ */
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ bool make_directory_with_parents();
+#else
+ bool make_directory_with_parents(std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
_WRAP_METHOD(bool make_symbolic_link(const std::string& symlink_value, const Glib::RefPtr<Cancellable>& cancellable),
g_file_make_symbolic_link,
errthrow)
@@ -1621,6 +1660,45 @@
#endif //GLIBMM_EXCEPTIONS_ENABLED
_IGNORE(g_file_monitor_file)
+
+ /** Obtains a file monitor for the given file. If no file notification
+ * mechanism exists, then regular polling of the file is used.
+ *
+ * The operation can be cancelled by triggering the cancellable object from another thread. If the operation
+ * was cancelled, a Gio::Error with CANCELLED will be thrown.
+ *
+ * @param flags A set of FileMonitorFlags.
+ * @param A Cancellable object.
+ * @return A FileMonitor for the file.
+ *
+ * @newin2p18
+ */
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ Glib::RefPtr<FileMonitor> monitor(const Glib::RefPtr<Cancellable>& cancellable, FileMonitorFlags flags = FILE_MONITOR_NONE);
+#else
+ Glib::RefPtr<FileMonitor> monitor(const Glib::RefPtr<Cancellable>& cancellable, FileMonitorFlags flags, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+ /** Obtains a file monitor for the given file. If no file notification
+ * mechanism exists, then regular polling of the file is used.
+ *
+ * The operation can be cancelled by triggering the cancellable object from another thread. If the operation
+ * was cancelled, a Gio::Error with CANCELLED will be thrown.
+ *
+ * @param flags A set of FileMonitorFlags.
+ * @param A Cancellable object.
+ * @return A FileMonitor for the file.
+ *
+ * @newin2p18
+ */
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ Glib::RefPtr<FileMonitor> monitor(FileMonitorFlags flags = FILE_MONITOR_NONE);
+#else
+ Glib::RefPtr<FileMonitor> monitor(FileMonitorFlags flags, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+ _IGNORE(g_file_monitor)
+
+
_WRAP_METHOD(Glib::RefPtr<AppInfo> query_default_handler(const Glib::RefPtr<Cancellable>& cancellable),
g_file_query_default_handler,
errthrow)
Modified: trunk/gio/src/fileenumerator.ccg
==============================================================================
--- trunk/gio/src/fileenumerator.ccg (original)
+++ trunk/gio/src/fileenumerator.ccg Wed Jul 16 12:09:59 2008
@@ -18,11 +18,13 @@
*/
#include <gio/gio.h>
+#include <giomm/file.h>
#include <glibmm/error.h>
#include <glibmm/exceptionhandler.h>
#include "slot_async.h"
-namespace Gio {
+namespace Gio
+{
void
FileEnumerator::next_files_async(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, int num_files, int io_priority)
Modified: trunk/gio/src/fileenumerator.hg
==============================================================================
--- trunk/gio/src/fileenumerator.hg (original)
+++ trunk/gio/src/fileenumerator.hg Wed Jul 16 12:09:59 2008
@@ -23,6 +23,7 @@
#include <giomm/asyncresult.h>
#include <giomm/cancellable.h>
#include <giomm/fileinfo.h>
+//#include <giomm/file.h>
_DEFS(giomm,gio)
_PINCLUDE(glibmm/private/object_p.h)
@@ -30,6 +31,8 @@
namespace Gio
{
+class File;
+
//TODO: Consider wrapping this like a std::iterator (or at least renaming it), though the asyncness probably makes that unsuitable.
/** Enumerated Files Routines.
@@ -155,6 +158,9 @@
_WRAP_METHOD(bool is_closed() const, g_file_enumerator_is_closed)
_WRAP_METHOD(bool has_pending() const, g_file_enumerator_has_pending)
_WRAP_METHOD(void set_pending(bool pending = true), g_file_enumerator_set_pending)
+
+ _WRAP_METHOD(Glib::RefPtr<File> get_container(), g_file_enumerator_get_container, refreturn)
+ _WRAP_METHOD(Glib::RefPtr<const File> get_container() const, g_file_enumerator_get_container, refreturn)
};
} // namespace Gio
Modified: trunk/gio/src/mount.ccg
==============================================================================
--- trunk/gio/src/mount.ccg (original)
+++ trunk/gio/src/mount.ccg Wed Jul 16 12:09:59 2008
@@ -151,6 +151,43 @@
}
+void Mount::guess_content_type(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, bool force_rescan)
+{
+ // Create a copy of the slot.
+ // A pointer to it will be passed through the callback's data parameter
+ // and deleted in the callback.
+ SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
+
+ g_mount_guess_content_type(gobj(),
+ force_rescan,
+ cancellable->gobj(),
+ &SignalProxy_async_callback,
+ slot_copy);
+}
+
+void Mount::guess_content_type(const SlotAsyncReady& slot, bool force_rescan)
+{
+ // Create a copy of the slot.
+ // A pointer to it will be passed through the callback's data parameter
+ // and deleted in the callback.
+ SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
+
+ g_mount_guess_content_type(gobj(),
+ force_rescan,
+ NULL,
+ &SignalProxy_async_callback,
+ slot_copy);
+}
+
+void Mount::guess_content_type(bool force_rescan)
+{
+ g_mount_guess_content_type(gobj(),
+ force_rescan,
+ NULL,
+ NULL,
+ NULL);
+}
+
} // namespace Gio
Modified: trunk/gio/src/mount.hg
==============================================================================
--- trunk/gio/src/mount.hg (original)
+++ trunk/gio/src/mount.hg Wed Jul 16 12:09:59 2008
@@ -173,6 +173,59 @@
_WRAP_METHOD(bool eject_finish(const Glib::RefPtr<AsyncResult>& result), g_mount_eject_finish, errthrow)
+
+
+
+ /** Tries to guess the type of content stored on the mount.
+ * Returns one or more textual identifiers of well-known content types (typically
+ * prefixed with "x-content/"), e.g. x-content/image-dcf for camera
+ * memory cards. See the <ulink url="http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec">shared-mime-info</ulink> specification for more on x-content types.
+ *
+ * This is an asynchronous operation, and is finished by calling
+ * guess_content_type_finish().
+ *
+ * @param slot A callback which will be called when the operation is completed or canceled.
+ * @param cancellable A cancellable object which can be used to cancel the operation.
+ * @param force_rescan Whether to force a rescan of the content. Otherwise a cached result will be used if available.
+ *
+ * @newin2p18
+ */
+ void guess_content_type(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, bool force_rescan = true);
+
+ /** Tries to guess the type of content stored on the mount.
+ * Returns one or more textual identifiers of well-known content types (typically
+ * prefixed with "x-content/"), e.g. x-content/image-dcf for camera
+ * memory cards. See the <ulink url="http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec">shared-mime-info</ulink> specification for more on x-content types.
+ *
+ * This is an asynchronous operation, and is finished by calling
+ * guess_content_type_finish().
+ *
+ * @param slot A callback which will be called when the operation is completed or canceled.
+ * @param force_rescan Whether to force a rescan of the content. Otherwise a cached result will be used if available.
+ *
+ * @newin2p18
+ */
+ void guess_content_type(const SlotAsyncReady& slot, bool force_rescan = true);
+
+ /** Tries to guess the type of content stored on the mount.
+ * Returns one or more textual identifiers of well-known content types (typically
+ * prefixed with "x-content/"), e.g. x-content/image-dcf for camera
+ * memory cards. See the <ulink url="http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec">shared-mime-info</ulink> specification for more on x-content types.
+ *
+ * @param force_rescan Whether to force a rescan of the content. Otherwise a cached result will be used if available.
+ *
+ * @newin2p18
+ */
+ void guess_content_type(bool force_rescan = true);
+ _IGNORE(g_mount_eject)
+
+
+ #m4 _CONVERSION(`gchar**',`Glib::StringArrayHandle',`Glib::StringArrayHandle($3, Glib::OWNERSHIP_DEEP)')
+
+ //TODO: Correct the documentation:
+ _WRAP_METHOD(Glib::StringArrayHandle guess_content_type_finish(const Glib::RefPtr<AsyncResult>& result), g_mount_guess_content_type_finish, errthrow)
+
+
_WRAP_SIGNAL(void changed(), changed)
_WRAP_SIGNAL(void unmounted(), unmounted)
Modified: trunk/gio/src/themedicon.hg
==============================================================================
--- trunk/gio/src/themedicon.hg (original)
+++ trunk/gio/src/themedicon.hg Wed Jul 16 12:09:59 2008
@@ -56,6 +56,7 @@
//TODO: GIcon *g_themed_icon_new_from_names (char **iconnames, int len);
+ _WRAP_METHOD(void prepend_name(const std::string& iconname), g_themed_icon_prepend_name)
_WRAP_METHOD(void append_name(const std::string& iconname), g_themed_icon_append_name)
#m4 _CONVERSION(`const char*const*',`Glib::StringArrayHandle',`Glib::StringArrayHandle($3, Glib::OWNERSHIP_DEEP)')
Modified: trunk/gio/src/volume.hg
==============================================================================
--- trunk/gio/src/volume.hg (original)
+++ trunk/gio/src/volume.hg Wed Jul 16 12:09:59 2008
@@ -152,6 +152,9 @@
_WRAP_METHOD(Glib::StringArrayHandle enumerate_identifiers() const,
g_volume_enumerate_identifiers)
+ _WRAP_METHOD(Glib::RefPtr<File> get_activation_root(), g_volume_get_activation_root)
+ _WRAP_METHOD(Glib::RefPtr<const File> get_activation_root() const, g_volume_get_activation_root)
+
_WRAP_SIGNAL(void changed(), changed)
_WRAP_SIGNAL(void removed(), removed)
Modified: trunk/tools/m4/convert_gio.m4
==============================================================================
--- trunk/tools/m4/convert_gio.m4 (original)
+++ trunk/tools/m4/convert_gio.m4 Wed Jul 16 12:09:59 2008
@@ -47,6 +47,7 @@
_CONVERSION(`const Glib::RefPtr<File>&',`GFile*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`const Glib::RefPtr<const File>&',`GFile*',__CONVERT_CONST_REFPTR_TO_P_SUN(Gio::File))
_CONVERSION(`GFile*',`Glib::RefPtr<File>',`Glib::wrap($3)')
+_CONVERSION(`GFile*',`Glib::RefPtr<const File>',`Glib::wrap($3)')
# FileAttribute
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]