More C++
This commit is contained in:
parent
7e468b2810
commit
c640dc0edf
@ -1,6 +1,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <mooedit/mooeditfileinfo.h>
|
#include <mooedit/mooeditfileinfo.h>
|
||||||
#include <moocpp/gobjectutils.h>
|
#include "moocpp/gobjtypes.h"
|
||||||
|
|
||||||
static MooOpenInfo *
|
static MooOpenInfo *
|
||||||
parse_filename (const char *filename)
|
parse_filename (const char *filename)
|
||||||
|
@ -566,7 +566,7 @@ gboolean App::Private::check_signal ()
|
|||||||
static gboolean
|
static gboolean
|
||||||
emit_started (App *app)
|
emit_started (App *app)
|
||||||
{
|
{
|
||||||
g_signal_emit_by_name (app, "started");
|
app->signal_emit_by_name ("started");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -853,36 +853,30 @@ void App::Private::save_session ()
|
|||||||
|
|
||||||
void App::Private::write_session ()
|
void App::Private::write_session ()
|
||||||
{
|
{
|
||||||
char *filename;
|
|
||||||
GError *error = NULL;
|
|
||||||
MooFileWriter *writer;
|
MooFileWriter *writer;
|
||||||
|
|
||||||
if (session_file.empty())
|
if (session_file.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
filename = moo_get_user_cache_file (session_file);
|
gstr filename = gstr::wrap_new (moo_get_user_cache_file (session_file));
|
||||||
|
|
||||||
if (!session)
|
if (!session)
|
||||||
{
|
{
|
||||||
mgw_errno_t err;
|
mgw_errno_t err;
|
||||||
mgw_unlink (filename, &err);
|
mgw_unlink (filename, &err);
|
||||||
g_free (filename);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((writer = moo_config_writer_new (filename, FALSE, &error)))
|
gerrp error;
|
||||||
|
|
||||||
|
if ((writer = moo_config_writer_new (filename, FALSE, error)))
|
||||||
{
|
{
|
||||||
moo_markup_write_pretty (session.gobj(), writer, 1);
|
moo_markup_write_pretty (session.gobj(), writer, 1);
|
||||||
moo_file_writer_close (writer, &error);
|
moo_file_writer_close (writer, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
|
||||||
g_critical ("could not save session file %s: %s", filename, error->message);
|
g_critical ("could not save session file %s: %s", filename, error->message);
|
||||||
g_error_free (error);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (filename);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::load_session ()
|
void App::load_session ()
|
||||||
@ -1122,14 +1116,13 @@ void App::Private::report_bug (GtkWidget *window)
|
|||||||
|
|
||||||
void App::Private::save_prefs ()
|
void App::Private::save_prefs ()
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
gerrp error;
|
||||||
|
|
||||||
if (!moo_prefs_save (rc_files[MOO_PREFS_RC],
|
if (!moo_prefs_save (rc_files[MOO_PREFS_RC],
|
||||||
rc_files[MOO_PREFS_STATE],
|
rc_files[MOO_PREFS_STATE],
|
||||||
&error))
|
error))
|
||||||
{
|
{
|
||||||
g_warning ("could not save config files: %s", moo_error_message (error));
|
g_warning ("could not save config files: %s", moo_error_message (error));
|
||||||
g_error_free (error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1172,7 +1165,7 @@ void App::Private::prefs_dialog (GtkWidget *parent)
|
|||||||
|
|
||||||
void App::Private::load_prefs ()
|
void App::Private::load_prefs ()
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
gerrp error;
|
||||||
char **sys_files;
|
char **sys_files;
|
||||||
|
|
||||||
rc_files[MOO_PREFS_RC].take(moo_get_user_data_file (MOO_PREFS_XML_FILE_NAME));
|
rc_files[MOO_PREFS_RC].take(moo_get_user_data_file (MOO_PREFS_XML_FILE_NAME));
|
||||||
@ -1183,10 +1176,9 @@ void App::Private::load_prefs ()
|
|||||||
if (!moo_prefs_load (sys_files,
|
if (!moo_prefs_load (sys_files,
|
||||||
rc_files[MOO_PREFS_RC],
|
rc_files[MOO_PREFS_RC],
|
||||||
rc_files[MOO_PREFS_STATE],
|
rc_files[MOO_PREFS_STATE],
|
||||||
&error))
|
error))
|
||||||
{
|
{
|
||||||
g_warning ("could not read config files: %s", moo_error_message (error));
|
g_warning ("could not read config files: %s", moo_error_message (error));
|
||||||
g_error_free (error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_strfreev (sys_files);
|
g_strfreev (sys_files);
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "marshals.h"
|
#include "marshals.h"
|
||||||
#include "mooutils/mooutils-misc.h"
|
#include "mooutils/mooutils-misc.h"
|
||||||
#include "mooutils/moocompat.h"
|
#include "mooutils/moocompat.h"
|
||||||
#include "moocpp/gobjectutils.h"
|
#include "moocpp/gobjtypes.h"
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <mooglib/moo-glib.h>
|
#include <mooglib/moo-glib.h>
|
||||||
|
@ -160,16 +160,4 @@ struct class_helper
|
|||||||
|
|
||||||
} // namespace moo
|
} // namespace moo
|
||||||
|
|
||||||
MOO_DEFINE_FLAGS(GSignalFlags);
|
|
||||||
MOO_DEFINE_FLAGS(GdkEventMask);
|
|
||||||
MOO_DEFINE_FLAGS(GdkModifierType);
|
|
||||||
MOO_DEFINE_FLAGS(GtkCellRendererState);
|
|
||||||
MOO_DEFINE_FLAGS(GtkAttachOptions);
|
|
||||||
MOO_DEFINE_FLAGS(GdkDragAction);
|
|
||||||
MOO_DEFINE_FLAGS(GConnectFlags);
|
|
||||||
MOO_DEFINE_FLAGS(GSpawnFlags);
|
|
||||||
MOO_DEFINE_FLAGS(GIOCondition);
|
|
||||||
MOO_DEFINE_FLAGS(GLogLevelFlags);
|
|
||||||
MOO_DEFINE_FLAGS(GRegexCompileFlags);
|
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
@ -96,7 +96,7 @@ public:
|
|||||||
operator const Object* () const { return gobj(); }
|
operator const Object* () const { return gobj(); }
|
||||||
operator ref_type*() const { return m_ref.self(); }
|
operator ref_type*() const { return m_ref.self(); }
|
||||||
ref_type* operator->() const { return m_ref.self(); }
|
ref_type* operator->() const { return m_ref.self(); }
|
||||||
ref_type& operator*() const { return m_ref; }
|
ref_type operator*() const { return m_ref; }
|
||||||
|
|
||||||
// These are nasty. Because of ref_type* conversion this can be converted to void*,
|
// These are nasty. Because of ref_type* conversion this can be converted to void*,
|
||||||
// which in turn can be passed to g_object_ref or g_free, etc.
|
// which in turn can be passed to g_object_ref or g_free, etc.
|
||||||
|
@ -85,67 +85,6 @@ private:
|
|||||||
mutable gobj_ref<Object> m_ref;
|
mutable gobj_ref<Object> m_ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Object>
|
|
||||||
class gobj_raw_ptr<const Object>
|
|
||||||
{
|
|
||||||
using ref_type = gobj_ref<Object>;
|
|
||||||
|
|
||||||
public:
|
|
||||||
gobj_raw_ptr(const Object* obj = nullptr) { m_ref._set_gobj(const_cast<Object*>(obj)); }
|
|
||||||
|
|
||||||
operator const Object*() const { return gobj(); }
|
|
||||||
operator const GTypeInstance*() const { return reinterpret_cast<GTypeInstance*>(gobj()); }
|
|
||||||
operator const void*() const { return gobj(); }
|
|
||||||
operator const gobj_ref<Object>*() const { return m_ref.self(); }
|
|
||||||
|
|
||||||
const ref_type* operator->() const { return m_ref.self(); }
|
|
||||||
const ref_type& operator*() const { return m_ref; }
|
|
||||||
|
|
||||||
const Object* gobj() const { return m_ref.gobj(); }
|
|
||||||
void set(const Object* p) { m_ref._set_gobj(p); }
|
|
||||||
|
|
||||||
template<typename Super>
|
|
||||||
const Super* gobj() const
|
|
||||||
{
|
|
||||||
return gobj_is_subclass<Object, Super>::down_cast(m_ref.gobj());
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename Subclass>
|
|
||||||
void set(const Subclass* p)
|
|
||||||
{
|
|
||||||
set(gobj_is_subclass<Subclass, Object>::down_cast(p));
|
|
||||||
}
|
|
||||||
|
|
||||||
operator bool() const { return gobj() != nullptr; }
|
|
||||||
bool operator!() const { return gobj() == nullptr; }
|
|
||||||
|
|
||||||
gobj_raw_ptr(const gobj_raw_ptr& other) = default;
|
|
||||||
gobj_raw_ptr& operator=(const gobj_raw_ptr& other) = default;
|
|
||||||
|
|
||||||
gobj_raw_ptr(gobj_raw_ptr&& other)
|
|
||||||
: m_ref(other.gobj())
|
|
||||||
{
|
|
||||||
other = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
gobj_raw_ptr& operator=(gobj_raw_ptr&& other)
|
|
||||||
{
|
|
||||||
m_ref._set_gobj(other.gobj());
|
|
||||||
other.m_ref._set_gobj(nullptr);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
gobj_raw_ptr& operator=(const T* p)
|
|
||||||
{
|
|
||||||
set(p);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
mutable gobj_ref<Object> m_ref;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace moo
|
} // namespace moo
|
||||||
|
|
||||||
template<typename X>
|
template<typename X>
|
||||||
|
@ -56,12 +56,9 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
GObject* gobj() { return m_gobj; }
|
GObject* gobj() const { return m_gobj; }
|
||||||
const GObject* gobj() const { return m_gobj; }
|
operator GObject&() const { return *m_gobj; }
|
||||||
operator GObject&() { return *m_gobj; }
|
operator GTypeInstance&() const { return *reinterpret_cast<GTypeInstance*>(m_gobj); }
|
||||||
operator const GObject&() const { return *m_gobj; }
|
|
||||||
operator GTypeInstance&() { return *reinterpret_cast<GTypeInstance*>(m_gobj); }
|
|
||||||
operator const GTypeInstance&() const { return *reinterpret_cast<const GTypeInstance*>(m_gobj); }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GObject* raw_gobj() const { return const_cast<GObject*>(m_gobj); }
|
GObject* raw_gobj() const { return const_cast<GObject*>(m_gobj); }
|
||||||
@ -93,7 +90,6 @@ class gobj_ref<GObject>; // : public gobj_ref_base
|
|||||||
protected: \
|
protected: \
|
||||||
friend class gobj_ptr<object_type>; \
|
friend class gobj_ptr<object_type>; \
|
||||||
friend class gobj_raw_ptr<object_type>; \
|
friend class gobj_raw_ptr<object_type>; \
|
||||||
friend class gobj_raw_ptr<const object_type>; \
|
|
||||||
\
|
\
|
||||||
gobj_ref() {} \
|
gobj_ref() {} \
|
||||||
\
|
\
|
||||||
@ -103,24 +99,13 @@ public:
|
|||||||
_set_gobj(&gobj); \
|
_set_gobj(&gobj); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
object_type* gobj() \
|
object_type* gobj() const \
|
||||||
{ \
|
{ \
|
||||||
return reinterpret_cast<object_type*>(raw_gobj()); \
|
return reinterpret_cast<object_type*>(raw_gobj()); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
const object_type* gobj() const \
|
|
||||||
{ \
|
|
||||||
return reinterpret_cast<const object_type*>(raw_gobj()); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
template<typename X> \
|
template<typename X> \
|
||||||
X* gobj() \
|
X* gobj() const \
|
||||||
{ \
|
|
||||||
return nc_gobj<X>(); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
template<typename X> \
|
|
||||||
const X* gobj() const \
|
|
||||||
{ \
|
{ \
|
||||||
return nc_gobj<X>(); \
|
return nc_gobj<X>(); \
|
||||||
} \
|
} \
|
||||||
@ -140,10 +125,8 @@ public:
|
|||||||
gobj_ref* self() { return this; } \
|
gobj_ref* self() { return this; } \
|
||||||
const gobj_ref* self() const { return this; } \
|
const gobj_ref* self() const { return this; } \
|
||||||
\
|
\
|
||||||
operator object_type&() { return *gobj(); } \
|
operator object_type&() const { return *gobj(); } \
|
||||||
operator const object_type&() const { return *gobj(); } \
|
gobj_raw_ptr<object_type> operator&() const { return nc_gobj(); } \
|
||||||
gobj_raw_ptr<object_type> operator&() { return nc_gobj(); } \
|
|
||||||
gobj_raw_ptr<const object_type> operator&() const { return nc_gobj(); } \
|
|
||||||
\
|
\
|
||||||
gobj_ref(const gobj_ref&) = default; \
|
gobj_ref(const gobj_ref&) = default; \
|
||||||
gobj_ref& operator=(const gobj_ref&) = default; \
|
gobj_ref& operator=(const gobj_ref&) = default; \
|
||||||
|
@ -21,7 +21,7 @@ using namespace moo::g;
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// gobj_ref<GFile>
|
// GFile
|
||||||
//
|
//
|
||||||
|
|
||||||
FilePtr File::new_for_path(const char* path)
|
FilePtr File::new_for_path(const char* path)
|
||||||
@ -89,9 +89,9 @@ FilePtr File::get_child(const char* name)
|
|||||||
return FilePtr::wrap_new(g_file_get_child(nc_gobj(), name));
|
return FilePtr::wrap_new(g_file_get_child(nc_gobj(), name));
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePtr File::get_child_for_display_name(const char* display_name, GError** error)
|
FilePtr File::get_child_for_display_name(const char* display_name, gerrp& error)
|
||||||
{
|
{
|
||||||
return FilePtr::wrap_new(g_file_get_child_for_display_name(nc_gobj(), display_name, error));
|
return FilePtr::wrap_new(g_file_get_child_for_display_name(nc_gobj(), display_name, &error));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool File::has_prefix(File prefix)
|
bool File::has_prefix(File prefix)
|
||||||
@ -124,6 +124,41 @@ gstr File::get_uri_scheme()
|
|||||||
return gstr::wrap_new(g_file_get_uri_scheme(nc_gobj()));
|
return gstr::wrap_new(g_file_get_uri_scheme(nc_gobj()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g::FileInputStreamPtr File::read(GCancellable* cancellable, gerrp& error)
|
||||||
|
{
|
||||||
|
return wrap_new (g_file_read(gobj(), cancellable, &error));
|
||||||
|
}
|
||||||
|
|
||||||
|
g::FileOutputStreamPtr File::append_to(GFileCreateFlags flags, GCancellable* cancellable, gerrp& error)
|
||||||
|
{
|
||||||
|
return wrap_new (g_file_append_to(gobj(), flags, cancellable, &error));
|
||||||
|
}
|
||||||
|
|
||||||
|
g::FileOutputStreamPtr File::create(GFileCreateFlags flags, GCancellable* cancellable, gerrp& error)
|
||||||
|
{
|
||||||
|
return wrap_new (g_file_create(gobj(), flags, cancellable, &error));
|
||||||
|
}
|
||||||
|
|
||||||
|
g::FileOutputStreamPtr File::replace(const char* etag, gboolean make_backup, GFileCreateFlags flags, GCancellable* cancellable, gerrp& error)
|
||||||
|
{
|
||||||
|
return wrap_new (g_file_replace(gobj(), etag, make_backup, flags, cancellable, &error));
|
||||||
|
}
|
||||||
|
|
||||||
|
g::FileIOStreamPtr File::open_readwrite(GCancellable* cancellable, gerrp& error)
|
||||||
|
{
|
||||||
|
return wrap_new (g_file_open_readwrite(gobj(), cancellable, &error));
|
||||||
|
}
|
||||||
|
|
||||||
|
g::FileIOStreamPtr File::create_readwrite(GFileCreateFlags flags, GCancellable* cancellable, gerrp& error)
|
||||||
|
{
|
||||||
|
return wrap_new (g_file_create_readwrite(gobj(), flags, cancellable, &error));
|
||||||
|
}
|
||||||
|
|
||||||
|
g::FileIOStreamPtr File::replace_readwrite(const char* etag, gboolean make_backup, GFileCreateFlags flags, GCancellable* cancellable, gerrp& error)
|
||||||
|
{
|
||||||
|
return wrap_new (g_file_replace_readwrite(gobj(), etag, make_backup, flags, cancellable, &error));
|
||||||
|
}
|
||||||
|
|
||||||
bool File::query_exists(GCancellable* cancellable)
|
bool File::query_exists(GCancellable* cancellable)
|
||||||
{
|
{
|
||||||
return g_file_query_exists(nc_gobj(), cancellable);
|
return g_file_query_exists(nc_gobj(), cancellable);
|
||||||
@ -134,67 +169,163 @@ GFileType File::query_file_type(GFileQueryInfoFlags flags, GCancellable* cancell
|
|||||||
return g_file_query_file_type(nc_gobj(), flags, cancellable);
|
return g_file_query_file_type(nc_gobj(), flags, cancellable);
|
||||||
}
|
}
|
||||||
|
|
||||||
GFileInfo* File::query_info(const char *attributes, GFileQueryInfoFlags flags, GCancellable* cancellable, GError** error)
|
FileInfoPtr File::query_info(const char *attributes, GFileQueryInfoFlags flags, GCancellable* cancellable, gerrp& error)
|
||||||
{
|
{
|
||||||
return g_file_query_info(nc_gobj(), attributes, flags, cancellable, error);
|
return wrap_new(g_file_query_info(nc_gobj(), attributes, flags, cancellable, &error));
|
||||||
}
|
}
|
||||||
|
|
||||||
GFileInfo* File::query_filesystem_info(const char *attributes, GCancellable* cancellable, GError** error)
|
FileInfoPtr File::query_filesystem_info(const char *attributes, GCancellable* cancellable, gerrp& error)
|
||||||
{
|
{
|
||||||
return g_file_query_filesystem_info(nc_gobj(), attributes, cancellable, error);
|
return wrap_new(g_file_query_filesystem_info(nc_gobj(), attributes, cancellable, &error));
|
||||||
}
|
}
|
||||||
|
|
||||||
GFileEnumerator* File::enumerate_children(const char *attributes, GFileQueryInfoFlags flags, GCancellable* cancellable, GError** error)
|
GFileEnumerator* File::enumerate_children(const char *attributes, GFileQueryInfoFlags flags, GCancellable* cancellable, gerrp& error)
|
||||||
{
|
{
|
||||||
return g_file_enumerate_children(nc_gobj(), attributes, flags, cancellable, error);
|
return g_file_enumerate_children(nc_gobj(), attributes, flags, cancellable, &error);
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePtr File::set_display_name(const char* display_name, GCancellable* cancellable, GError** error)
|
FilePtr File::set_display_name(const char* display_name, GCancellable* cancellable, gerrp& error)
|
||||||
{
|
{
|
||||||
return FilePtr::wrap_new(g_file_set_display_name(nc_gobj(), display_name, cancellable, error));
|
return FilePtr::wrap_new(g_file_set_display_name(nc_gobj(), display_name, cancellable, &error));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool File::delete_(GCancellable* cancellable, GError** error)
|
bool File::delete_(GCancellable* cancellable, gerrp& error)
|
||||||
{
|
{
|
||||||
return g_file_delete(nc_gobj(), cancellable, error);
|
return g_file_delete(nc_gobj(), cancellable, &error);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool File::trash(GCancellable* cancellable, GError** error)
|
bool File::trash(GCancellable* cancellable, gerrp& error)
|
||||||
{
|
{
|
||||||
return g_file_trash(nc_gobj(), cancellable, error);
|
return g_file_trash(nc_gobj(), cancellable, &error);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool File::copy(File destination, GFileCopyFlags flags, GCancellable* cancellable, GFileProgressCallback progress_callback, gpointer progress_callback_data, GError** error)
|
bool File::copy(File destination, GFileCopyFlags flags, GCancellable* cancellable, GFileProgressCallback progress_callback, gpointer progress_callback_data, gerrp& error)
|
||||||
{
|
{
|
||||||
return g_file_copy(nc_gobj(), destination.gobj(), flags, cancellable, progress_callback, progress_callback_data, error);
|
return g_file_copy(nc_gobj(), destination.gobj(), flags, cancellable, progress_callback, progress_callback_data, &error);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool File::move(File destination, GFileCopyFlags flags, GCancellable* cancellable, GFileProgressCallback progress_callback, gpointer progress_callback_data, GError** error)
|
bool File::move(File destination, GFileCopyFlags flags, GCancellable* cancellable, GFileProgressCallback progress_callback, gpointer progress_callback_data, gerrp& error)
|
||||||
{
|
{
|
||||||
return g_file_move(nc_gobj(), destination.gobj(), flags, cancellable, progress_callback, progress_callback_data, error);
|
return g_file_move(nc_gobj(), destination.gobj(), flags, cancellable, progress_callback, progress_callback_data, &error);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool File::make_directory(GCancellable* cancellable, GError** error)
|
bool File::make_directory(GCancellable* cancellable, gerrp& error)
|
||||||
{
|
{
|
||||||
return g_file_make_directory(nc_gobj(), cancellable, error);
|
return g_file_make_directory(nc_gobj(), cancellable, &error);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool File::make_directory_with_parents(GCancellable* cancellable, GError** error)
|
bool File::make_directory_with_parents(GCancellable* cancellable, gerrp& error)
|
||||||
{
|
{
|
||||||
return g_file_make_directory_with_parents(nc_gobj(), cancellable, error);
|
return g_file_make_directory_with_parents(nc_gobj(), cancellable, &error);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool File::make_symbolic_link(const char *symlink_value, GCancellable* cancellable, GError** error)
|
bool File::make_symbolic_link(const char *symlink_value, GCancellable* cancellable, gerrp& error)
|
||||||
{
|
{
|
||||||
return g_file_make_symbolic_link(nc_gobj(), symlink_value, cancellable, error);
|
return g_file_make_symbolic_link(nc_gobj(), symlink_value, cancellable, &error);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool File::load_contents(GCancellable* cancellable, char** contents, gsize* length, char** etag_out, GError** error)
|
bool File::load_contents(GCancellable* cancellable, char** contents, gsize* length, char** etag_out, gerrp& error)
|
||||||
{
|
{
|
||||||
return g_file_load_contents(nc_gobj(), cancellable, contents, length, etag_out, error);
|
return g_file_load_contents(nc_gobj(), cancellable, contents, length, etag_out, &error);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool File::replace_contents(const char* contents, gsize length, const char* etag, gboolean make_backup, GFileCreateFlags flags, char** new_etag, GCancellable* cancellable, GError** error)
|
bool File::replace_contents(const char* contents, gsize length, const char* etag, gboolean make_backup, GFileCreateFlags flags, char** new_etag, GCancellable* cancellable, gerrp& error)
|
||||||
{
|
{
|
||||||
return g_file_replace_contents(nc_gobj(), contents, length, etag, make_backup, flags, new_etag, cancellable, error);
|
return g_file_replace_contents(nc_gobj(), contents, length, etag, make_backup, flags, new_etag, cancellable, &error);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// GOutputStream
|
||||||
|
//
|
||||||
|
|
||||||
|
gssize OutputStream::write(const void* buffer, gsize count, GCancellable* cancellable, gerrp& error)
|
||||||
|
{
|
||||||
|
return g_output_stream_write(gobj(), buffer, count, cancellable, &error);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OutputStream::write_all(const void* buffer, gsize count, gsize* bytes_written, GCancellable* cancellable, gerrp& error)
|
||||||
|
{
|
||||||
|
return g_output_stream_write_all(gobj(), buffer, count, bytes_written, cancellable, &error);
|
||||||
|
}
|
||||||
|
|
||||||
|
gssize OutputStream::splice(g::InputStream source, GOutputStreamSpliceFlags flags, GCancellable* cancellable, gerrp& error)
|
||||||
|
{
|
||||||
|
return g_output_stream_splice(gobj(), source.gobj(), flags, cancellable, &error);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OutputStream::flush(GCancellable* cancellable, gerrp& error)
|
||||||
|
{
|
||||||
|
return g_output_stream_flush(gobj(), cancellable, &error);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OutputStream::close(GCancellable* cancellable, gerrp& error)
|
||||||
|
{
|
||||||
|
return g_output_stream_close(gobj(), cancellable, &error);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputStream::write_async(const void* buffer, gsize count, int io_priority, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer user_data)
|
||||||
|
{
|
||||||
|
g_output_stream_write_async(gobj(), buffer, count, io_priority, cancellable, callback, user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
gssize OutputStream::write_finish(GAsyncResult* result, gerrp& error)
|
||||||
|
{
|
||||||
|
return g_output_stream_write_finish(gobj(), result, &error);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputStream::splice_async(g::InputStream source, GOutputStreamSpliceFlags flags, int io_priority, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer user_data)
|
||||||
|
{
|
||||||
|
g_output_stream_splice_async(gobj(), source.gobj(), flags, io_priority, cancellable, callback, user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
gssize OutputStream::splice_finish(GAsyncResult* result, gerrp& error)
|
||||||
|
{
|
||||||
|
return g_output_stream_splice_finish(gobj(), result, &error);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputStream::flush_async(int io_priority, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer user_data)
|
||||||
|
{
|
||||||
|
g_output_stream_flush_async(gobj(), io_priority, cancellable, callback, user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OutputStream::flush_finish(GAsyncResult* result, gerrp& error)
|
||||||
|
{
|
||||||
|
return g_output_stream_flush_finish(gobj(), result, &error);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputStream::close_async(int io_priority, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer user_data)
|
||||||
|
{
|
||||||
|
g_output_stream_close_async(gobj(), io_priority, cancellable, callback, user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OutputStream::close_finish(GAsyncResult* result, gerrp& error)
|
||||||
|
{
|
||||||
|
return g_output_stream_close_finish(gobj(), result, &error);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OutputStream::is_closed()
|
||||||
|
{
|
||||||
|
return g_output_stream_is_closed(gobj());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OutputStream::is_closing()
|
||||||
|
{
|
||||||
|
return g_output_stream_is_closing(gobj());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OutputStream::has_pending()
|
||||||
|
{
|
||||||
|
return g_output_stream_has_pending(gobj());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OutputStream::set_pending(gerrp& error)
|
||||||
|
{
|
||||||
|
return g_output_stream_set_pending(gobj(), &error);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputStream::clear_pending()
|
||||||
|
{
|
||||||
|
g_output_stream_clear_pending(gobj());
|
||||||
}
|
}
|
||||||
|
@ -24,13 +24,30 @@
|
|||||||
#include "moocpp/strutils.h"
|
#include "moocpp/strutils.h"
|
||||||
|
|
||||||
MOO_DEFINE_GOBJ_TYPE(GFile, GObject, G_TYPE_FILE)
|
MOO_DEFINE_GOBJ_TYPE(GFile, GObject, G_TYPE_FILE)
|
||||||
|
MOO_DEFINE_GOBJ_TYPE(GFileInfo, GObject, G_TYPE_FILE_INFO)
|
||||||
|
|
||||||
|
MOO_DEFINE_GOBJ_TYPE(GOutputStream, GObject, G_TYPE_OUTPUT_STREAM)
|
||||||
|
MOO_DEFINE_GOBJ_TYPE(GFileOutputStream, GOutputStream, G_TYPE_FILE_OUTPUT_STREAM)
|
||||||
|
MOO_DEFINE_GOBJ_TYPE(GInputStream, GObject, G_TYPE_INPUT_STREAM)
|
||||||
|
MOO_DEFINE_GOBJ_TYPE(GFileInputStream, GInputStream, G_TYPE_FILE_INPUT_STREAM)
|
||||||
|
MOO_DEFINE_GOBJ_TYPE(GIOStream, GObject, G_TYPE_IO_STREAM)
|
||||||
|
MOO_DEFINE_GOBJ_TYPE(GFileIOStream, GIOStream, G_TYPE_FILE_IO_STREAM)
|
||||||
|
|
||||||
MOO_DECLARE_CUSTOM_GOBJ_TYPE(GFile)
|
MOO_DECLARE_CUSTOM_GOBJ_TYPE(GFile)
|
||||||
|
MOO_DECLARE_CUSTOM_GOBJ_TYPE(GOutputStream)
|
||||||
|
|
||||||
namespace moo {
|
namespace moo {
|
||||||
|
|
||||||
namespace g {
|
namespace g {
|
||||||
|
|
||||||
MOO_GOBJ_TYPEDEFS(File, GFile);
|
MOO_GOBJ_TYPEDEFS(File, GFile);
|
||||||
|
MOO_GOBJ_TYPEDEFS(FileInfo, GFileInfo);
|
||||||
|
MOO_GOBJ_TYPEDEFS(OutputStream, GOutputStream);
|
||||||
|
MOO_GOBJ_TYPEDEFS(FileOutputStream, GFileOutputStream);
|
||||||
|
MOO_GOBJ_TYPEDEFS(InputStream, GInputStream);
|
||||||
|
MOO_GOBJ_TYPEDEFS(FileInputStream, GFileInputStream);
|
||||||
|
MOO_GOBJ_TYPEDEFS(IOStream, GIOStream);
|
||||||
|
MOO_GOBJ_TYPEDEFS(FileIOStream, GFileIOStream);
|
||||||
|
|
||||||
} // namespace g
|
} // namespace g
|
||||||
|
|
||||||
@ -56,82 +73,82 @@ public:
|
|||||||
bool has_parent (g::File parent);
|
bool has_parent (g::File parent);
|
||||||
g::FilePtr get_child (const char* name);
|
g::FilePtr get_child (const char* name);
|
||||||
g::FilePtr get_child_for_display_name (const char* display_name,
|
g::FilePtr get_child_for_display_name (const char* display_name,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
bool has_prefix (g::File prefix);
|
bool has_prefix (g::File prefix);
|
||||||
gstr get_relative_path (g::File descendant);
|
gstr get_relative_path (g::File descendant);
|
||||||
g::FilePtr resolve_relative_path (const char *relative_path);
|
g::FilePtr resolve_relative_path (const char *relative_path);
|
||||||
bool is_native ();
|
bool is_native ();
|
||||||
bool has_uri_scheme (const char *uri_scheme);
|
bool has_uri_scheme (const char *uri_scheme);
|
||||||
gstr get_uri_scheme ();
|
gstr get_uri_scheme ();
|
||||||
GFileInputStream* read (GCancellable* cancellable,
|
g::FileInputStreamPtr read (GCancellable* cancellable,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
GFileOutputStream* append_to (GFileCreateFlags flags,
|
g::FileOutputStreamPtr append_to (GFileCreateFlags flags,
|
||||||
GCancellable* cancellable,
|
GCancellable* cancellable,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
GFileOutputStream* create (GFileCreateFlags flags,
|
g::FileOutputStreamPtr create (GFileCreateFlags flags,
|
||||||
GCancellable* cancellable,
|
GCancellable* cancellable,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
GFileOutputStream* replace (const char *etag,
|
g::FileOutputStreamPtr replace (const char *etag,
|
||||||
gboolean make_backup,
|
gboolean make_backup,
|
||||||
GFileCreateFlags flags,
|
GFileCreateFlags flags,
|
||||||
GCancellable* cancellable,
|
GCancellable* cancellable,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
GFileIOStream* open_readwrite (GCancellable* cancellable,
|
g::FileIOStreamPtr open_readwrite (GCancellable* cancellable,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
GFileIOStream* create_readwrite (GFileCreateFlags flags,
|
g::FileIOStreamPtr create_readwrite (GFileCreateFlags flags,
|
||||||
GCancellable* cancellable,
|
GCancellable* cancellable,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
GFileIOStream* replace_readwrite (const char *etag,
|
g::FileIOStreamPtr replace_readwrite (const char *etag,
|
||||||
gboolean make_backup,
|
gboolean make_backup,
|
||||||
GFileCreateFlags flags,
|
GFileCreateFlags flags,
|
||||||
GCancellable* cancellable,
|
GCancellable* cancellable,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
bool query_exists (GCancellable* cancellable);
|
bool query_exists (GCancellable* cancellable);
|
||||||
GFileType query_file_type (GFileQueryInfoFlags flags,
|
GFileType query_file_type (GFileQueryInfoFlags flags,
|
||||||
GCancellable* cancellable);
|
GCancellable* cancellable);
|
||||||
GFileInfo* query_info (const char *attributes,
|
g::FileInfoPtr query_info (const char *attributes,
|
||||||
GFileQueryInfoFlags flags,
|
GFileQueryInfoFlags flags,
|
||||||
GCancellable* cancellable,
|
GCancellable* cancellable,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
GFileInfo* query_filesystem_info (const char *attributes,
|
g::FileInfoPtr query_filesystem_info (const char *attributes,
|
||||||
GCancellable* cancellable,
|
GCancellable* cancellable,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
GFileEnumerator* enumerate_children (const char *attributes,
|
GFileEnumerator* enumerate_children (const char *attributes,
|
||||||
GFileQueryInfoFlags flags,
|
GFileQueryInfoFlags flags,
|
||||||
GCancellable* cancellable,
|
GCancellable* cancellable,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
g::FilePtr set_display_name (const char* display_name,
|
g::FilePtr set_display_name (const char* display_name,
|
||||||
GCancellable* cancellable,
|
GCancellable* cancellable,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
bool delete_ (GCancellable* cancellable,
|
bool delete_ (GCancellable* cancellable,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
bool trash (GCancellable* cancellable,
|
bool trash (GCancellable* cancellable,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
bool copy (g::File destination,
|
bool copy (g::File destination,
|
||||||
GFileCopyFlags flags,
|
GFileCopyFlags flags,
|
||||||
GCancellable* cancellable,
|
GCancellable* cancellable,
|
||||||
GFileProgressCallback progress_callback,
|
GFileProgressCallback progress_callback,
|
||||||
gpointer progress_callback_data,
|
gpointer progress_callback_data,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
bool move (g::File destination,
|
bool move (g::File destination,
|
||||||
GFileCopyFlags flags,
|
GFileCopyFlags flags,
|
||||||
GCancellable* cancellable,
|
GCancellable* cancellable,
|
||||||
GFileProgressCallback progress_callback,
|
GFileProgressCallback progress_callback,
|
||||||
gpointer progress_callback_data,
|
gpointer progress_callback_data,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
bool make_directory (GCancellable* cancellable,
|
bool make_directory (GCancellable* cancellable,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
bool make_directory_with_parents (GCancellable* cancellable,
|
bool make_directory_with_parents (GCancellable* cancellable,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
bool make_symbolic_link (const char *symlink_value,
|
bool make_symbolic_link (const char *symlink_value,
|
||||||
GCancellable* cancellable,
|
GCancellable* cancellable,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
|
|
||||||
bool load_contents (GCancellable* cancellable,
|
bool load_contents (GCancellable* cancellable,
|
||||||
char** contents,
|
char** contents,
|
||||||
gsize* length,
|
gsize* length,
|
||||||
char** etag_out,
|
char** etag_out,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
bool replace_contents (const char* contents,
|
bool replace_contents (const char* contents,
|
||||||
gsize length,
|
gsize length,
|
||||||
const char* etag,
|
const char* etag,
|
||||||
@ -139,11 +156,73 @@ public:
|
|||||||
GFileCreateFlags flags,
|
GFileCreateFlags flags,
|
||||||
char** new_etag,
|
char** new_etag,
|
||||||
GCancellable* cancellable,
|
GCancellable* cancellable,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
class gobj_ref<GOutputStream> : public gobj_ref_parent<GOutputStream>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MOO_DEFINE_GOBJREF_METHODS(GOutputStream)
|
||||||
|
|
||||||
|
gssize write (const void *buffer,
|
||||||
|
gsize count,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
gerrp& error);
|
||||||
|
bool write_all (const void *buffer,
|
||||||
|
gsize count,
|
||||||
|
gsize *bytes_written,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
gerrp& error);
|
||||||
|
gssize splice (g::InputStream source,
|
||||||
|
GOutputStreamSpliceFlags flags,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
gerrp& error);
|
||||||
|
bool flush (GCancellable *cancellable,
|
||||||
|
gerrp& error);
|
||||||
|
bool close (GCancellable *cancellable,
|
||||||
|
gerrp& error);
|
||||||
|
void write_async (const void *buffer,
|
||||||
|
gsize count,
|
||||||
|
int io_priority,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
gssize write_finish (GAsyncResult *result,
|
||||||
|
gerrp& error);
|
||||||
|
void splice_async (g::InputStream source,
|
||||||
|
GOutputStreamSpliceFlags flags,
|
||||||
|
int io_priority,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
gssize splice_finish (GAsyncResult *result,
|
||||||
|
gerrp& error);
|
||||||
|
void flush_async (int io_priority,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
bool flush_finish (GAsyncResult *result,
|
||||||
|
gerrp& error);
|
||||||
|
void close_async (int io_priority,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
bool close_finish (GAsyncResult *result,
|
||||||
|
gerrp& error);
|
||||||
|
|
||||||
|
bool is_closed ();
|
||||||
|
bool is_closing ();
|
||||||
|
bool has_pending ();
|
||||||
|
bool set_pending (gerrp& error);
|
||||||
|
void clear_pending ();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace moo
|
} // namespace moo
|
||||||
|
|
||||||
MOO_REGISTER_CUSTOM_GOBJ_TYPE(GFile)
|
MOO_REGISTER_CUSTOM_GOBJ_TYPE(GFile)
|
||||||
|
MOO_REGISTER_CUSTOM_GOBJ_TYPE(GOutputStream)
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <mooglib/moo-glib.h>
|
#include <mooglib/moo-glib.h>
|
||||||
#include "moocpp/gobjptr.h"
|
#include "moocpp/gobjptr.h"
|
||||||
|
#include "moocpp/gobjectutils.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
@ -27,7 +28,7 @@
|
|||||||
using CppObject = ::moo::gobj_ref<CObject>; \
|
using CppObject = ::moo::gobj_ref<CObject>; \
|
||||||
using CppObject##Ptr = ::moo::gobj_ptr<CObject>; \
|
using CppObject##Ptr = ::moo::gobj_ptr<CObject>; \
|
||||||
using CppObject##RawPtr = ::moo::gobj_raw_ptr<CObject>; \
|
using CppObject##RawPtr = ::moo::gobj_raw_ptr<CObject>; \
|
||||||
using Const##CppObject##Ptr = ::moo::gobj_raw_ptr<const CObject>; \
|
|
||||||
|
|
||||||
#define MOO_DECLARE_CUSTOM_GOBJ_TYPE(CObject) \
|
#define MOO_DECLARE_CUSTOM_GOBJ_TYPE(CObject) \
|
||||||
namespace moo { \
|
namespace moo { \
|
||||||
@ -39,6 +40,13 @@ template<> class gobj_ref<CObject>; \
|
|||||||
"gobj_ref must be bit-compatible with a raw pointer, " \
|
"gobj_ref must be bit-compatible with a raw pointer, " \
|
||||||
"otherwise operator& will break"); \
|
"otherwise operator& will break"); \
|
||||||
|
|
||||||
|
MOO_DEFINE_FLAGS(GSignalFlags);
|
||||||
|
MOO_DEFINE_FLAGS(GConnectFlags);
|
||||||
|
MOO_DEFINE_FLAGS(GSpawnFlags);
|
||||||
|
MOO_DEFINE_FLAGS(GLogLevelFlags);
|
||||||
|
MOO_DEFINE_FLAGS(GRegexCompileFlags);
|
||||||
|
MOO_DEFINE_FLAGS(GIOCondition);
|
||||||
|
|
||||||
namespace moo {
|
namespace moo {
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -35,7 +35,7 @@ void test()
|
|||||||
|
|
||||||
{
|
{
|
||||||
gobj_ptr<GtkObject> p;
|
gobj_ptr<GtkObject> p;
|
||||||
gobj_ref<GtkObject>& r = *p;
|
gobj_ref<GtkObject> r = *p;
|
||||||
GtkObject* o1 = r.gobj();
|
GtkObject* o1 = r.gobj();
|
||||||
GtkObject* o2 = p->gobj();
|
GtkObject* o2 = p->gobj();
|
||||||
g_assert(o1 == o2);
|
g_assert(o1 == o2);
|
||||||
@ -51,7 +51,7 @@ void test()
|
|||||||
|
|
||||||
{
|
{
|
||||||
gobj_ptr<GtkWidget> p = wrap_new(gtk_widget_new(0, "blah", nullptr, nullptr));
|
gobj_ptr<GtkWidget> p = wrap_new(gtk_widget_new(0, "blah", nullptr, nullptr));
|
||||||
gobj_ref<GtkWidget>& r = *p;
|
gobj_ref<GtkWidget> r = *p;
|
||||||
GtkWidget* o1 = r.gobj();
|
GtkWidget* o1 = r.gobj();
|
||||||
GtkWidget* o2 = p->gobj();
|
GtkWidget* o2 = p->gobj();
|
||||||
g_assert(o1 == o2);
|
g_assert(o1 == o2);
|
||||||
|
@ -53,4 +53,10 @@ public:
|
|||||||
|
|
||||||
MOO_REGISTER_CUSTOM_GOBJ_TYPE(GtkTextView);
|
MOO_REGISTER_CUSTOM_GOBJ_TYPE(GtkTextView);
|
||||||
|
|
||||||
|
MOO_DEFINE_FLAGS(GdkEventMask);
|
||||||
|
MOO_DEFINE_FLAGS(GdkModifierType);
|
||||||
|
MOO_DEFINE_FLAGS(GtkCellRendererState);
|
||||||
|
MOO_DEFINE_FLAGS(GtkAttachOptions);
|
||||||
|
MOO_DEFINE_FLAGS(GdkDragAction);
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
@ -102,4 +102,8 @@ protected:
|
|||||||
|
|
||||||
} // namespace moo
|
} // namespace moo
|
||||||
|
|
||||||
|
void g_signal_emit_valist(const moo::gobj_wrapper_base*, guint, GQuark, va_list) = delete;
|
||||||
|
void g_signal_emit(const moo::gobj_wrapper_base*, guint, GQuark, ...) = delete;
|
||||||
|
void g_signal_emit_by_name(const moo::gobj_wrapper_base*, const gchar*, ...) = delete;
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
@ -15,8 +15,14 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
#include <mooglib/moo-glib.h>
|
#include <mooglib/moo-glib.h>
|
||||||
#include <moocpp/memutils.h>
|
#include <moocpp/memutils.h>
|
||||||
|
#include <moocpp/utils.h>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <utility>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace moo {
|
namespace moo {
|
||||||
|
|
||||||
@ -100,6 +106,47 @@ bool operator!=(const gstr& s1, const char* s2);
|
|||||||
bool operator!=(const char* s1, const gstr& s2);
|
bool operator!=(const char* s1, const gstr& s2);
|
||||||
bool operator!=(const gstr& s1, const gstr& s2);
|
bool operator!=(const gstr& s1, const gstr& s2);
|
||||||
|
|
||||||
|
|
||||||
|
class gerrp
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit gerrp(GError** errp = nullptr) : m_errp(errp ? errp : &m_local), m_local(nullptr) {}
|
||||||
|
|
||||||
|
~gerrp()
|
||||||
|
{
|
||||||
|
if (m_errp != &m_local)
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
operator bool() const { return (*m_errp) != nullptr; }
|
||||||
|
bool operator!() const { return (*m_errp) == nullptr; }
|
||||||
|
|
||||||
|
GError* get() const { return (*m_errp); }
|
||||||
|
GError* operator->() const { return (*m_errp); }
|
||||||
|
GError** operator&() { return m_errp; }
|
||||||
|
|
||||||
|
//void propagate(GError** dest) { g_propagate_error(dest, m_err); m_err = nullptr; }
|
||||||
|
void clear() { if (*m_errp) g_error_free(*m_errp); *m_errp = nullptr; m_local = nullptr; }
|
||||||
|
|
||||||
|
MOO_DISABLE_COPY_OPS(gerrp);
|
||||||
|
|
||||||
|
gerrp(gerrp&& other) = delete;
|
||||||
|
|
||||||
|
gerrp& operator=(gerrp&& other)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
g_propagate_error (m_errp, other.get());
|
||||||
|
other.m_errp = &other.m_local;
|
||||||
|
other.m_local = nullptr;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
GError** m_errp;
|
||||||
|
GError* m_local;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace moo
|
} // namespace moo
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
@ -110,4 +157,6 @@ struct hash<moo::gstr>
|
|||||||
const size_t operator()(const moo::gstr& s) const;
|
const size_t operator()(const moo::gstr& s) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace std
|
||||||
|
|
||||||
|
#endif // __cplusplus
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <mooutils/mooutils-misc.h>
|
|
||||||
#include <mooglib/moo-glib.h>
|
#include <mooglib/moo-glib.h>
|
||||||
|
|
||||||
namespace moo {
|
namespace moo {
|
||||||
|
@ -53,32 +53,32 @@ MOO_DEFINE_QUARK (MooEditFileErrorQuark, _moo_edit_file_error_quark)
|
|||||||
static GSList *UNTITLED = NULL;
|
static GSList *UNTITLED = NULL;
|
||||||
static GHashTable *UNTITLED_NO = NULL;
|
static GHashTable *UNTITLED_NO = NULL;
|
||||||
|
|
||||||
static void block_buffer_signals (Edit& edit);
|
static void block_buffer_signals (Edit edit);
|
||||||
static void unblock_buffer_signals (Edit& edit);
|
static void unblock_buffer_signals (Edit edit);
|
||||||
static void check_file_status (Edit& edit);
|
static void check_file_status (Edit edit);
|
||||||
static void file_modified_on_disk (Edit& edit);
|
static void file_modified_on_disk (Edit edit);
|
||||||
static void file_deleted (Edit& edit);
|
static void file_deleted (Edit edit);
|
||||||
static void add_status (Edit& edit,
|
static void add_status (Edit edit,
|
||||||
MooEditStatus s);
|
MooEditStatus s);
|
||||||
|
|
||||||
static void moo_edit_load_text (Edit& edit,
|
static void moo_edit_load_text (Edit edit,
|
||||||
const g::File& file,
|
g::File file,
|
||||||
const char* encoding,
|
const char* encoding,
|
||||||
const char* text);
|
const char* text);
|
||||||
static bool moo_edit_reload_local (Edit& edit,
|
static bool moo_edit_reload_local (Edit edit,
|
||||||
const char* encoding,
|
const char* encoding,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
static bool moo_edit_save_local (Edit& edit,
|
static bool moo_edit_save_local (Edit edit,
|
||||||
const g::File& file,
|
g::File file,
|
||||||
const char* encoding,
|
const char* encoding,
|
||||||
MooEditSaveFlags flags,
|
MooEditSaveFlags flags,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
static bool moo_edit_save_copy_local (Edit& edit,
|
static bool moo_edit_save_copy_local (Edit edit,
|
||||||
const g::File& file,
|
g::File file,
|
||||||
const char* encoding,
|
const char* encoding,
|
||||||
MooEditSaveFlags flags,
|
MooEditSaveFlags flags,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
static void _moo_edit_start_file_watch (Edit& edit);
|
static void _moo_edit_start_file_watch (Edit edit);
|
||||||
|
|
||||||
static char *moo_convert_file_data_to_utf8 (const char *data,
|
static char *moo_convert_file_data_to_utf8 (const char *data,
|
||||||
gsize len,
|
gsize len,
|
||||||
@ -91,11 +91,11 @@ static bool encoding_needs_bom_save (const char *enc,
|
|||||||
gsize *bom_len);
|
gsize *bom_len);
|
||||||
static bool encoding_is_utf8 (const char *encoding);
|
static bool encoding_is_utf8 (const char *encoding);
|
||||||
|
|
||||||
static bool check_regular (const g::File& file,
|
static bool check_regular (g::File file,
|
||||||
GError** error);
|
gerrp& error);
|
||||||
|
|
||||||
|
|
||||||
bool _moo_is_file_error_cancelled(GError *error)
|
bool _moo_is_file_error_cancelled(const gerrp& error)
|
||||||
{
|
{
|
||||||
return error && error->domain == MOO_EDIT_FILE_ERROR &&
|
return error && error->domain == MOO_EDIT_FILE_ERROR &&
|
||||||
error->code == MOO_EDIT_FILE_ERROR_CANCELLED;
|
error->code == MOO_EDIT_FILE_ERROR_CANCELLED;
|
||||||
@ -122,7 +122,7 @@ normalize_encoding (const gstr& encoding,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool _moo_edit_file_is_new(const g::File& file)
|
bool _moo_edit_file_is_new(g::File file)
|
||||||
{
|
{
|
||||||
gstr filename = file.get_path();
|
gstr filename = file.get_path();
|
||||||
g_return_val_if_fail(!filename.empty(), FALSE);
|
g_return_val_if_fail(!filename.empty(), FALSE);
|
||||||
@ -131,10 +131,10 @@ bool _moo_edit_file_is_new(const g::File& file)
|
|||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
load_file_contents (const g::File& file,
|
load_file_contents (g::File file,
|
||||||
char** data,
|
char** data,
|
||||||
gsize* data_len,
|
gsize* data_len,
|
||||||
GError** error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
if (!check_regular (file, error))
|
if (!check_regular (file, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -143,19 +143,19 @@ load_file_contents (const g::File& file,
|
|||||||
|
|
||||||
if (path.empty())
|
if (path.empty())
|
||||||
{
|
{
|
||||||
g_set_error (error, MOO_EDIT_FILE_ERROR,
|
g_set_error (&error, MOO_EDIT_FILE_ERROR,
|
||||||
MOO_EDIT_FILE_ERROR_NOT_IMPLEMENTED,
|
MOO_EDIT_FILE_ERROR_NOT_IMPLEMENTED,
|
||||||
"Loading remote files is not implemented");
|
"Loading remote files is not implemented");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_file_get_contents (path, data, data_len, error);
|
return g_file_get_contents (path, data, data_len, &error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
convert_file_data_to_utf8_with_prompt (const char* data,
|
convert_file_data_to_utf8_with_prompt (const char* data,
|
||||||
gsize data_len,
|
gsize data_len,
|
||||||
const g::File& file,
|
g::File file,
|
||||||
const char* encoding,
|
const char* encoding,
|
||||||
const char* cached_encoding,
|
const char* cached_encoding,
|
||||||
/*out*/ gstr& used_encoding)
|
/*out*/ gstr& used_encoding)
|
||||||
@ -200,14 +200,13 @@ convert_file_data_to_utf8_with_prompt (const char* data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
_moo_edit_load_file (Edit& edit,
|
_moo_edit_load_file (Edit edit,
|
||||||
const g::File& file,
|
g::File file,
|
||||||
const gstr& init_encoding,
|
const gstr& init_encoding,
|
||||||
const gstr& init_cached_encoding,
|
const gstr& init_cached_encoding,
|
||||||
GError** error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
GError *error_here = NULL;
|
|
||||||
char *data = NULL;
|
char *data = NULL;
|
||||||
gsize data_len = 0;
|
gsize data_len = 0;
|
||||||
char *data_utf8 = NULL;
|
char *data_utf8 = NULL;
|
||||||
@ -220,16 +219,14 @@ _moo_edit_load_file (Edit& edit,
|
|||||||
if (!init_cached_encoding.empty())
|
if (!init_cached_encoding.empty())
|
||||||
cached_encoding = normalize_encoding(init_cached_encoding, false);
|
cached_encoding = normalize_encoding(init_cached_encoding, false);
|
||||||
|
|
||||||
if (!load_file_contents(file, &data, &data_len, &error_here))
|
if (!load_file_contents(file, &data, &data_len, error))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
data_utf8 = convert_file_data_to_utf8_with_prompt(data, data_len, file, encoding, cached_encoding, /*out*/ used_encoding);
|
data_utf8 = convert_file_data_to_utf8_with_prompt(data, data_len, file, encoding, cached_encoding, /*out*/ used_encoding);
|
||||||
|
|
||||||
if (data_utf8 == NULL)
|
if (data_utf8 == NULL)
|
||||||
{
|
{
|
||||||
error_here = g_error_new(MOO_EDIT_FILE_ERROR,
|
g_set_error (&error, MOO_EDIT_FILE_ERROR, MOO_EDIT_FILE_ERROR_CANCELLED, "Cancelled");
|
||||||
MOO_EDIT_FILE_ERROR_CANCELLED,
|
|
||||||
"Cancelled");
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,9 +237,6 @@ done:
|
|||||||
if (!result)
|
if (!result)
|
||||||
edit._stop_file_watch();
|
edit._stop_file_watch();
|
||||||
|
|
||||||
if (error_here)
|
|
||||||
g_propagate_error(error, error_here);
|
|
||||||
|
|
||||||
g_free(data_utf8);
|
g_free(data_utf8);
|
||||||
g_free(data);
|
g_free(data);
|
||||||
return result;
|
return result;
|
||||||
@ -252,41 +246,28 @@ done:
|
|||||||
bool
|
bool
|
||||||
_moo_edit_reload_file(Edit edit,
|
_moo_edit_reload_file(Edit edit,
|
||||||
const char* encoding,
|
const char* encoding,
|
||||||
GError** error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
GError *error_here = NULL;
|
return moo_edit_reload_local(edit, encoding, error);
|
||||||
bool result = moo_edit_reload_local(edit, encoding, &error_here);
|
|
||||||
|
|
||||||
if (error_here)
|
|
||||||
g_propagate_error(error, error_here);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool _moo_edit_save_file(Edit& edit,
|
bool _moo_edit_save_file(Edit edit,
|
||||||
const g::File& file,
|
g::File file,
|
||||||
const char* encoding,
|
const char* encoding,
|
||||||
MooEditSaveFlags flags,
|
MooEditSaveFlags flags,
|
||||||
GError** error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
gstr encoding_copy = gstr::make_copy(normalize_encoding(encoding, true));
|
gstr encoding_copy = gstr::make_copy(normalize_encoding(encoding, true));
|
||||||
|
return moo_edit_save_local(edit, file, encoding_copy, flags, error);
|
||||||
GError *error_here = NULL;
|
|
||||||
bool result = moo_edit_save_local(edit, file, encoding_copy, flags, &error_here);
|
|
||||||
|
|
||||||
if (error_here)
|
|
||||||
g_propagate_error(error, error_here);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool _moo_edit_save_file_copy(Edit edit,
|
bool _moo_edit_save_file_copy(Edit edit,
|
||||||
const g::File& file,
|
g::File file,
|
||||||
const char* encoding,
|
const char* encoding,
|
||||||
MooEditSaveFlags flags,
|
MooEditSaveFlags flags,
|
||||||
GError** error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
gstr encoding_copy = gstr::make_copy(normalize_encoding(encoding, true));
|
gstr encoding_copy = gstr::make_copy(normalize_encoding(encoding, true));
|
||||||
return moo_edit_save_copy_local(edit, file, encoding_copy, flags, error);
|
return moo_edit_save_copy_local(edit, file, encoding_copy, flags, error);
|
||||||
@ -294,14 +275,13 @@ bool _moo_edit_save_file_copy(Edit edit,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_encoding_error (GError **error)
|
set_encoding_error (gerrp& error)
|
||||||
{
|
{
|
||||||
GError *tmp_error = NULL;
|
gerrp tmp_error;
|
||||||
g_set_error (&tmp_error, MOO_EDIT_FILE_ERROR,
|
g_set_error (&tmp_error, MOO_EDIT_FILE_ERROR,
|
||||||
MOO_EDIT_FILE_ERROR_ENCODING,
|
MOO_EDIT_FILE_ERROR_ENCODING,
|
||||||
"%s", *error ? (*error)->message : "ERROR");
|
"%s", error ? error->message : "ERROR");
|
||||||
g_clear_error (error);
|
error = std::move(tmp_error);
|
||||||
g_propagate_error (error, tmp_error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -349,7 +329,7 @@ moo_edit_set_line_end_type (MooEdit *edit,
|
|||||||
/* File loading
|
/* File loading
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void do_load_text(Edit& edit,
|
static void do_load_text(Edit edit,
|
||||||
const char* text);
|
const char* text);
|
||||||
|
|
||||||
static std::list<gstr>
|
static std::list<gstr>
|
||||||
@ -395,37 +375,33 @@ get_encodings (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool check_regular (const g::File& file,
|
static bool check_regular (g::File file, gerrp& error)
|
||||||
GError** error)
|
|
||||||
{
|
{
|
||||||
GFileInfo *info;
|
|
||||||
GFileType type;
|
|
||||||
gboolean retval = TRUE;
|
|
||||||
|
|
||||||
if (!file.is_native())
|
if (!file.is_native())
|
||||||
return TRUE;
|
return true;
|
||||||
|
|
||||||
if (!(info = file.query_info(G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, nullptr, nullptr)))
|
gerrp ignored;
|
||||||
return TRUE;
|
g::FileInfoPtr info;
|
||||||
|
if (!(info = file.query_info(G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, nullptr, ignored)))
|
||||||
|
return true;
|
||||||
|
|
||||||
type = g_file_info_get_file_type (info);
|
GFileType type = g_file_info_get_file_type (info.gobj());
|
||||||
if (type != G_FILE_TYPE_REGULAR && type != G_FILE_TYPE_UNKNOWN)
|
if (type != G_FILE_TYPE_REGULAR && type != G_FILE_TYPE_UNKNOWN)
|
||||||
{
|
{
|
||||||
g_set_error (error, MOO_EDIT_FILE_ERROR,
|
g_set_error (&error, MOO_EDIT_FILE_ERROR,
|
||||||
MOO_EDIT_FILE_ERROR_FAILED,
|
MOO_EDIT_FILE_ERROR_FAILED,
|
||||||
"%s", D_("Not a regular file", "glib20"));
|
"%s", D_("Not a regular file", "glib20"));
|
||||||
retval = FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (info);
|
return true;
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
moo_edit_load_text (Edit& edit,
|
moo_edit_load_text (Edit edit,
|
||||||
const g::File& file,
|
g::File file,
|
||||||
const char* encoding,
|
const char* encoding,
|
||||||
const char* text)
|
const char* text)
|
||||||
{
|
{
|
||||||
MooEditPrivate& priv = edit.get_priv();
|
MooEditPrivate& priv = edit.get_priv();
|
||||||
|
|
||||||
@ -473,7 +449,7 @@ moo_edit_load_text (Edit& edit,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void do_load_text(Edit& edit, const char* text)
|
static void do_load_text(Edit edit, const char* text)
|
||||||
{
|
{
|
||||||
MooLineEndType le = MOO_LE_NONE;
|
MooLineEndType le = MOO_LE_NONE;
|
||||||
|
|
||||||
@ -550,9 +526,9 @@ static void do_load_text(Edit& edit, const char* text)
|
|||||||
|
|
||||||
|
|
||||||
/* XXX */
|
/* XXX */
|
||||||
static bool moo_edit_reload_local(Edit& edit,
|
static bool moo_edit_reload_local(Edit edit,
|
||||||
const char* encoding,
|
const char* encoding,
|
||||||
GError** error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
g::FilePtr file = wrap_new(moo_edit_get_file(&edit));
|
g::FilePtr file = wrap_new(moo_edit_get_file(&edit));
|
||||||
moo_return_error_if_fail(file != nullptr);
|
moo_return_error_if_fail(file != nullptr);
|
||||||
@ -568,7 +544,7 @@ static bool moo_edit_reload_local(Edit& edit,
|
|||||||
priv.status = (MooEditStatus) 0;
|
priv.status = (MooEditStatus) 0;
|
||||||
moo_edit_set_modified(&edit, false);
|
moo_edit_set_modified(&edit, false);
|
||||||
_moo_edit_start_file_watch(edit);
|
_moo_edit_start_file_watch(edit);
|
||||||
g_clear_error(error);
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -614,7 +590,7 @@ get_contents_with_fixed_line_end (GtkTextBuffer *buffer, const char *le, gsize l
|
|||||||
return g_string_free (contents, FALSE);
|
return g_string_free (contents, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gstr get_contents(MooEdit& edit)
|
static gstr get_contents(MooEdit edit)
|
||||||
{
|
{
|
||||||
const char *le = "\n";
|
const char *le = "\n";
|
||||||
gsize le_len = 1;
|
gsize le_len = 1;
|
||||||
@ -642,13 +618,13 @@ static gstr get_contents(MooEdit& edit)
|
|||||||
return gstr::wrap_new(get_contents_with_fixed_line_end(buffer, le, le_len));
|
return gstr::wrap_new(get_contents_with_fixed_line_end(buffer, le, le_len));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool do_write(const g::File& file,
|
static bool do_write(g::File file,
|
||||||
const char* data1,
|
const char* data1,
|
||||||
gsize len1,
|
gsize len1,
|
||||||
const char* data2,
|
const char* data2,
|
||||||
gsize len2,
|
gsize len2,
|
||||||
MooEditSaveFlags flags,
|
MooEditSaveFlags flags,
|
||||||
GError** error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
MooFileWriter *writer;
|
MooFileWriter *writer;
|
||||||
MooFileWriterFlags writer_flags;
|
MooFileWriterFlags writer_flags;
|
||||||
@ -656,7 +632,7 @@ static bool do_write(const g::File& file,
|
|||||||
|
|
||||||
writer_flags = (flags & MOO_EDIT_SAVE_BACKUP) ? MOO_FILE_WRITER_SAVE_BACKUP : (MooFileWriterFlags) 0;
|
writer_flags = (flags & MOO_EDIT_SAVE_BACKUP) ? MOO_FILE_WRITER_SAVE_BACKUP : (MooFileWriterFlags) 0;
|
||||||
|
|
||||||
if ((writer = moo_file_writer_new_for_file (file.nc_gobj(), writer_flags, error)))
|
if ((writer = moo_file_writer_new_for_file (file, writer_flags, error)))
|
||||||
{
|
{
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
if (success && len1 > 0)
|
if (success && len1 > 0)
|
||||||
@ -671,15 +647,14 @@ static bool do_write(const g::File& file,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
do_save_local(Edit& edit,
|
do_save_local(Edit edit,
|
||||||
const g::File& file,
|
g::File file,
|
||||||
const char* encoding,
|
const char* encoding,
|
||||||
MooEditSaveFlags flags,
|
MooEditSaveFlags flags,
|
||||||
GError** error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
const char *to_save;
|
const char *to_save;
|
||||||
gsize to_save_size;
|
gsize to_save_size;
|
||||||
GError *encoding_error = NULL;
|
|
||||||
const char *enc_no_bom = NULL;
|
const char *enc_no_bom = NULL;
|
||||||
const char *bom = NULL;
|
const char *bom = NULL;
|
||||||
gsize bom_len = 0;
|
gsize bom_len = 0;
|
||||||
@ -697,6 +672,7 @@ do_save_local(Edit& edit,
|
|||||||
{
|
{
|
||||||
gsize bytes_read;
|
gsize bytes_read;
|
||||||
gsize bytes_written;
|
gsize bytes_written;
|
||||||
|
gerrp encoding_error;
|
||||||
gstr encoded = gstr::wrap_new(g_convert(utf8_contents, -1,
|
gstr encoded = gstr::wrap_new(g_convert(utf8_contents, -1,
|
||||||
encoding, "UTF-8",
|
encoding, "UTF-8",
|
||||||
&bytes_read, &bytes_written,
|
&bytes_read, &bytes_written,
|
||||||
@ -709,8 +685,8 @@ do_save_local(Edit& edit,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_propagate_error(error, encoding_error);
|
error = std::move (encoding_error);
|
||||||
set_encoding_error(error);
|
set_encoding_error (error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -728,11 +704,11 @@ do_save_local(Edit& edit,
|
|||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
moo_edit_save_local(Edit& edit,
|
moo_edit_save_local(Edit edit,
|
||||||
const g::File& file,
|
g::File file,
|
||||||
const char* encoding,
|
const char* encoding,
|
||||||
MooEditSaveFlags flags,
|
MooEditSaveFlags flags,
|
||||||
GError** error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
if (!do_save_local(edit, file, encoding, flags, error))
|
if (!do_save_local(edit, file, encoding, flags, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -745,11 +721,11 @@ moo_edit_save_local(Edit& edit,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool moo_edit_save_copy_local(Edit& edit,
|
static bool moo_edit_save_copy_local(Edit edit,
|
||||||
const g::File& file,
|
g::File file,
|
||||||
const char* encoding,
|
const char* encoding,
|
||||||
MooEditSaveFlags flags,
|
MooEditSaveFlags flags,
|
||||||
GError** error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
return do_save_local(edit, file, encoding, flags, error);
|
return do_save_local(edit, file, encoding, flags, error);
|
||||||
}
|
}
|
||||||
@ -760,14 +736,14 @@ static bool moo_edit_save_copy_local(Edit& edit,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
block_buffer_signals(Edit& edit)
|
block_buffer_signals(Edit edit)
|
||||||
{
|
{
|
||||||
g_signal_handler_block (moo_edit_get_buffer (&edit), edit.get_priv().modified_changed_handler_id);
|
g_signal_handler_block (moo_edit_get_buffer (&edit), edit.get_priv().modified_changed_handler_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unblock_buffer_signals(Edit& edit)
|
unblock_buffer_signals(Edit edit)
|
||||||
{
|
{
|
||||||
g_signal_handler_unblock(moo_edit_get_buffer(&edit), edit.get_priv().modified_changed_handler_id);
|
g_signal_handler_unblock(moo_edit_get_buffer(&edit), edit.get_priv().modified_changed_handler_id);
|
||||||
}
|
}
|
||||||
@ -811,7 +787,7 @@ file_watch_callback(G_GNUC_UNUSED MooFileWatch& watch,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void _moo_edit_start_file_watch(Edit& edit)
|
static void _moo_edit_start_file_watch(Edit edit)
|
||||||
{
|
{
|
||||||
auto& priv = edit.get_priv();
|
auto& priv = edit.get_priv();
|
||||||
|
|
||||||
@ -853,7 +829,7 @@ void Edit::_stop_file_watch()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void check_file_status(Edit& edit)
|
static void check_file_status(Edit edit)
|
||||||
{
|
{
|
||||||
auto& priv = edit.get_priv();
|
auto& priv = edit.get_priv();
|
||||||
|
|
||||||
@ -867,7 +843,7 @@ static void check_file_status(Edit& edit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void file_modified_on_disk(Edit& edit)
|
static void file_modified_on_disk(Edit edit)
|
||||||
{
|
{
|
||||||
auto& priv = edit.get_priv();
|
auto& priv = edit.get_priv();
|
||||||
|
|
||||||
@ -887,7 +863,7 @@ static void file_modified_on_disk(Edit& edit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void file_deleted (Edit& edit)
|
static void file_deleted (Edit edit)
|
||||||
{
|
{
|
||||||
auto& priv = edit.get_priv();
|
auto& priv = edit.get_priv();
|
||||||
|
|
||||||
@ -907,14 +883,14 @@ static void file_deleted (Edit& edit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void add_status(Edit& edit, MooEditStatus s)
|
static void add_status(Edit edit, MooEditStatus s)
|
||||||
{
|
{
|
||||||
edit.get_priv().status |= s;
|
edit.get_priv().status |= s;
|
||||||
edit.signal_emit_by_name("doc-status-changed", NULL);
|
edit.signal_emit_by_name("doc-status-changed", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Edit::_remove_untitled(const Edit& doc)
|
void Edit::_remove_untitled(Edit doc)
|
||||||
{
|
{
|
||||||
gpointer n = g_hash_table_lookup (UNTITLED_NO, &doc);
|
gpointer n = g_hash_table_lookup (UNTITLED_NO, &doc);
|
||||||
|
|
||||||
@ -926,7 +902,7 @@ void Edit::_remove_untitled(const Edit& doc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int add_untitled(Edit& edit)
|
static int add_untitled(Edit edit)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
@ -948,7 +924,7 @@ static int add_untitled(Edit& edit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gstr moo_file_get_display_basename(const g::File& file)
|
static gstr moo_file_get_display_basename(g::File file)
|
||||||
{
|
{
|
||||||
const char *slash;
|
const char *slash;
|
||||||
|
|
||||||
@ -984,7 +960,7 @@ static gstr normalize_filename_for_comparison(const char *filename)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
gstr Edit::_get_normalized_name(const g::File& file)
|
gstr Edit::_get_normalized_name(g::File file)
|
||||||
{
|
{
|
||||||
gstr tmp = file.get_path();
|
gstr tmp = file.get_path();
|
||||||
|
|
||||||
@ -1001,8 +977,8 @@ gstr Edit::_get_normalized_name(const g::File& file)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Edit::_set_file(gobj_raw_ptr<const GFile> file,
|
void Edit::_set_file(g::FileRawPtr file,
|
||||||
const char* encoding)
|
const char* encoding)
|
||||||
{
|
{
|
||||||
if (!UNTITLED_NO)
|
if (!UNTITLED_NO)
|
||||||
UNTITLED_NO = g_hash_table_new(g_direct_hash, g_direct_equal);
|
UNTITLED_NO = g_hash_table_new(g_direct_hash, g_direct_equal);
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include "moocpp/utils.h"
|
#include "moocpp/utils.h"
|
||||||
#include "moocpp/strutils.h"
|
#include "moocpp/strutils.h"
|
||||||
|
#include "mooutils/mooutils-misc.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
const char *_moo_get_default_encodings (void);
|
const char *_moo_get_default_encodings (void);
|
||||||
@ -46,24 +47,24 @@ MOO_DEFINE_FLAGS(MooEditSaveFlags)
|
|||||||
|
|
||||||
GQuark _moo_edit_file_error_quark (void) G_GNUC_CONST;
|
GQuark _moo_edit_file_error_quark (void) G_GNUC_CONST;
|
||||||
|
|
||||||
bool _moo_is_file_error_cancelled (GError* error);
|
bool _moo_is_file_error_cancelled (const moo::gerrp& error);
|
||||||
|
|
||||||
bool _moo_edit_file_is_new (const moo::g::File& file);
|
bool _moo_edit_file_is_new (moo::g::File file);
|
||||||
bool _moo_edit_load_file (Edit& edit,
|
bool _moo_edit_load_file (Edit edit,
|
||||||
const moo::g::File& file,
|
moo::g::File file,
|
||||||
const moo::gstr& init_encoding,
|
const moo::gstr& init_encoding,
|
||||||
const moo::gstr& init_cached_encoding,
|
const moo::gstr& init_cached_encoding,
|
||||||
GError** error);
|
moo::gerrp& error);
|
||||||
bool _moo_edit_reload_file (Edit edit,
|
bool _moo_edit_reload_file (Edit edit,
|
||||||
const char* encoding,
|
const char* encoding,
|
||||||
GError** error);
|
moo::gerrp& error);
|
||||||
bool _moo_edit_save_file (Edit& edit,
|
bool _moo_edit_save_file (Edit edit,
|
||||||
const moo::g::File& floc,
|
moo::g::File floc,
|
||||||
const char* encoding,
|
const char* encoding,
|
||||||
MooEditSaveFlags flags,
|
MooEditSaveFlags flags,
|
||||||
GError** error);
|
moo::gerrp& error);
|
||||||
bool _moo_edit_save_file_copy (Edit edit,
|
bool _moo_edit_save_file_copy (Edit edit,
|
||||||
const moo::g::File& file,
|
moo::g::File file,
|
||||||
const char* encoding,
|
const char* encoding,
|
||||||
MooEditSaveFlags flags,
|
MooEditSaveFlags flags,
|
||||||
GError** error);
|
moo::gerrp& error);
|
||||||
|
@ -56,9 +56,9 @@ public:
|
|||||||
|
|
||||||
void _closed ();
|
void _closed ();
|
||||||
|
|
||||||
void _set_file (g::ConstFilePtr file,
|
void _set_file (g::FileRawPtr file,
|
||||||
const char* encoding);
|
const char* encoding);
|
||||||
void _remove_untitled (const Edit& doc);
|
void _remove_untitled (Edit doc);
|
||||||
|
|
||||||
void _ensure_newline ();
|
void _ensure_newline ();
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ public:
|
|||||||
|
|
||||||
MooActionCollection& _get_actions ();
|
MooActionCollection& _get_actions ();
|
||||||
|
|
||||||
static moo::gstr _get_normalized_name (const g::File& file);
|
static moo::gstr _get_normalized_name (g::File file);
|
||||||
const moo::gstr& _get_normalized_name () const;
|
const moo::gstr& _get_normalized_name () const;
|
||||||
|
|
||||||
MooEditPrivate& get_priv () { return *gobj()->priv; }
|
MooEditPrivate& get_priv () { return *gobj()->priv; }
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
#include "mooutils/mooatom.h"
|
#include "mooutils/mooatom.h"
|
||||||
#include "mooutils/moocompat.h"
|
#include "mooutils/moocompat.h"
|
||||||
#include "mooedit/mooeditprogress-gxml.h"
|
#include "mooedit/mooeditprogress-gxml.h"
|
||||||
#include "moocpp/gobjectutils.h"
|
#include "moocpp/gobjtypes.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
@ -412,7 +412,7 @@ _moo_edit_save_multiple_changes_dialog (MooEditArray *docs,
|
|||||||
/* Error dialogs
|
/* Error dialogs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void _moo_edit_save_error_dialog(Edit& doc, const g::File& file, GError *error)
|
void _moo_edit_save_error_dialog(Edit& doc, g::File file, GError *error)
|
||||||
{
|
{
|
||||||
gstr filename = moo_file_get_display_name (file);
|
gstr filename = moo_file_get_display_name (file);
|
||||||
gstr msg = gstr::wrap_new(g_strdup_printf(_("Could not save file\n%s"), filename));
|
gstr msg = gstr::wrap_new(g_strdup_printf(_("Could not save file\n%s"), filename));
|
||||||
@ -460,9 +460,9 @@ moo_edit_question_dialog (MooEdit *doc,
|
|||||||
return res == GTK_RESPONSE_YES;
|
return res == GTK_RESPONSE_YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _moo_edit_save_error_enc_dialog(Edit& doc,
|
bool _moo_edit_save_error_enc_dialog(Edit& doc,
|
||||||
const g::File& file,
|
g::File file,
|
||||||
const char* encoding)
|
const char* encoding)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (encoding != NULL, FALSE);
|
g_return_val_if_fail (encoding != NULL, FALSE);
|
||||||
|
|
||||||
@ -479,9 +479,9 @@ bool _moo_edit_save_error_enc_dialog(Edit& doc,
|
|||||||
|
|
||||||
|
|
||||||
MooEditTryEncodingResponse
|
MooEditTryEncodingResponse
|
||||||
_moo_edit_try_encoding_dialog (const g::File& file,
|
_moo_edit_try_encoding_dialog (g::File file,
|
||||||
const char* encoding,
|
const char* encoding,
|
||||||
/*out*/ gstr& new_encoding)
|
/*out*/ gstr& new_encoding)
|
||||||
{
|
{
|
||||||
MooEditWindow *window;
|
MooEditWindow *window;
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
@ -548,28 +548,26 @@ _moo_edit_try_encoding_dialog (const g::File& file,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_moo_edit_open_error_dialog (GtkWidget *widget,
|
_moo_edit_open_error_dialog (GtkWidget* widget,
|
||||||
GFile *file,
|
g::File* file,
|
||||||
GError *error)
|
GError* error)
|
||||||
{
|
{
|
||||||
char *filename, *msg = NULL;
|
gstr msg;
|
||||||
char *secondary;
|
gstr secondary;
|
||||||
|
|
||||||
filename = moo_file_get_display_name (file);
|
g_warn_if_fail (file != nullptr);
|
||||||
|
gstr filename = file ? moo_file_get_display_name (*file) : gstr ();
|
||||||
|
|
||||||
if (filename)
|
if (!filename.empty())
|
||||||
/* Could not open file foo.txt */
|
/* Could not open file foo.txt */
|
||||||
msg = g_strdup_printf (_("Could not open file\n%s"), filename);
|
msg.take (g_strdup_printf (_("Could not open file\n%s"), filename.get()));
|
||||||
else
|
else
|
||||||
msg = g_strdup (_("Could not open file"));
|
msg.literal (_("Could not open file"));
|
||||||
|
|
||||||
secondary = error ? g_strdup (error->message) : NULL;
|
if (error)
|
||||||
|
secondary.borrow (error->message);
|
||||||
|
|
||||||
moo_error_dialog (msg, secondary, widget);
|
moo_error_dialog (msg, secondary, widget);
|
||||||
|
|
||||||
g_free (msg);
|
|
||||||
g_free (secondary);
|
|
||||||
g_free (filename);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,9 +38,6 @@ MooSaveChangesResponse _moo_edit_save_multiple_changes_dialog (MooEdit
|
|||||||
gboolean _moo_edit_reload_modified_dialog (MooEdit *doc);
|
gboolean _moo_edit_reload_modified_dialog (MooEdit *doc);
|
||||||
gboolean _moo_edit_overwrite_modified_dialog (MooEdit *doc);
|
gboolean _moo_edit_overwrite_modified_dialog (MooEdit *doc);
|
||||||
|
|
||||||
void _moo_edit_open_error_dialog (GtkWidget *widget,
|
|
||||||
GFile *file,
|
|
||||||
GError *error);
|
|
||||||
void _moo_edit_reload_error_dialog (MooEdit *doc,
|
void _moo_edit_reload_error_dialog (MooEdit *doc,
|
||||||
GError *error);
|
GError *error);
|
||||||
|
|
||||||
@ -59,14 +56,17 @@ G_END_DECLS
|
|||||||
|
|
||||||
#include <moocpp/strutils.h>
|
#include <moocpp/strutils.h>
|
||||||
|
|
||||||
MooEditTryEncodingResponse _moo_edit_try_encoding_dialog (const moo::g::File& file,
|
MooEditTryEncodingResponse _moo_edit_try_encoding_dialog (moo::g::File file,
|
||||||
const char* encoding,
|
const char* encoding,
|
||||||
/*out*/ moo::gstr& new_encoding);
|
/*out*/ moo::gstr& new_encoding);
|
||||||
bool _moo_edit_save_error_enc_dialog (Edit& doc,
|
bool _moo_edit_save_error_enc_dialog (Edit& doc,
|
||||||
const moo::g::File& file,
|
moo::g::File file,
|
||||||
const char* encoding);
|
const char* encoding);
|
||||||
void _moo_edit_save_error_dialog (Edit& doc,
|
void _moo_edit_save_error_dialog (Edit& doc,
|
||||||
const moo::g::File& file,
|
moo::g::File file,
|
||||||
|
GError* error);
|
||||||
|
void _moo_edit_open_error_dialog (GtkWidget* widget,
|
||||||
|
moo::g::File* file,
|
||||||
GError* error);
|
GError* error);
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "mooeditfileinfo.h"
|
#include "mooeditfileinfo.h"
|
||||||
#include "moocpp/strutils.h"
|
#include "moocpp/strutils.h"
|
||||||
#include "moocpp/gobjectutils.h"
|
#include "moocpp/gobjtypes.h"
|
||||||
|
|
||||||
using namespace moo;
|
using namespace moo;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "mooedit/mooedithistoryitem.h"
|
#include "mooedit/mooedithistoryitem.h"
|
||||||
#include "mooedit/mooedit-ui.h"
|
#include "mooedit/mooedit-ui.h"
|
||||||
#include "mooedit/medit-ui.h"
|
#include "mooedit/medit-ui.h"
|
||||||
#include "moocpp/gobjectutils.h"
|
#include "moocpp/gobjtypes.h"
|
||||||
#include "mooutils/moomenuaction.h"
|
#include "mooutils/moomenuaction.h"
|
||||||
#include "marshals.h"
|
#include "marshals.h"
|
||||||
#include "mooutils/mooutils-misc.h"
|
#include "mooutils/mooutils-misc.h"
|
||||||
@ -948,13 +948,13 @@ moo_editor_load_file(MooEditor *editor,
|
|||||||
GtkWidget *parent,
|
GtkWidget *parent,
|
||||||
gboolean silent,
|
gboolean silent,
|
||||||
gboolean add_history,
|
gboolean add_history,
|
||||||
GError **error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
MooEditView *view = NULL;
|
MooEditView *view = NULL;
|
||||||
gboolean new_doc = FALSE;
|
gboolean new_doc = FALSE;
|
||||||
gboolean new_object = FALSE;
|
gboolean new_object = FALSE;
|
||||||
const char *recent_encoding = NULL;
|
const char *recent_encoding = NULL;
|
||||||
GError *error_here = NULL;
|
gerrp error_here;
|
||||||
gboolean success = TRUE;
|
gboolean success = TRUE;
|
||||||
|
|
||||||
moo_return_error_if_fail_p(MOO_IS_EDITOR(editor));
|
moo_return_error_if_fail_p(MOO_IS_EDITOR(editor));
|
||||||
@ -1023,7 +1023,7 @@ moo_editor_load_file(MooEditor *editor,
|
|||||||
success = _moo_edit_load_file(*doc, *info->file,
|
success = _moo_edit_load_file(*doc, *info->file,
|
||||||
gstr::make_borrowed(info->encoding),
|
gstr::make_borrowed(info->encoding),
|
||||||
gstr::make_borrowed(recent_encoding),
|
gstr::make_borrowed(recent_encoding),
|
||||||
&error_here);
|
error_here);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1035,22 +1035,20 @@ moo_editor_load_file(MooEditor *editor,
|
|||||||
window = moo_editor_get_active_window (editor);
|
window = moo_editor_get_active_window (editor);
|
||||||
if (!parent && window)
|
if (!parent && window)
|
||||||
parent = GTK_WIDGET (window);
|
parent = GTK_WIDGET (window);
|
||||||
_moo_edit_open_error_dialog(parent, info->file.gobj(), error_here);
|
_moo_edit_open_error_dialog(parent, info->file, error_here.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
g_propagate_error (error, error_here);
|
error = std::move (error_here);
|
||||||
error_here = NULL;
|
|
||||||
}
|
}
|
||||||
else if (!new_doc && (info->flags & MOO_OPEN_FLAG_RELOAD))
|
else if (!new_doc && (info->flags & MOO_OPEN_FLAG_RELOAD))
|
||||||
{
|
{
|
||||||
success = _moo_edit_reload_file(*doc, info->encoding, &error_here);
|
success = _moo_edit_reload_file(*doc, info->encoding, error_here);
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
if (!silent && !_moo_is_file_error_cancelled (error_here))
|
if (!silent && !_moo_is_file_error_cancelled (error_here))
|
||||||
_moo_edit_reload_error_dialog (doc.gobj(), error_here);
|
_moo_edit_reload_error_dialog (doc.gobj(), error_here.get());
|
||||||
g_propagate_error (error, error_here);
|
error = std::move (error_here);
|
||||||
error_here = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1195,10 +1193,10 @@ moo_editor_load_file(MooEditor *editor,
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
static MooEditArray *
|
static MooEditArray *
|
||||||
_moo_editor_open_files (MooEditor *editor,
|
_moo_editor_open_files (MooEditor* editor,
|
||||||
MooOpenInfoArray *files,
|
MooOpenInfoArray* files,
|
||||||
GtkWidget *parent,
|
GtkWidget* parent,
|
||||||
GError **error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
MooEdit *bring_to_front = NULL;
|
MooEdit *bring_to_front = NULL;
|
||||||
@ -1745,7 +1743,8 @@ load_doc_session (MooEditor *editor,
|
|||||||
const char *encoding = moo_markup_get_prop (elm, "encoding");
|
const char *encoding = moo_markup_get_prop (elm, "encoding");
|
||||||
std::unique_ptr<MooOpenInfo> info(moo_open_info_new_uri(uri, encoding, -1, MOO_OPEN_FLAGS_NONE));
|
std::unique_ptr<MooOpenInfo> info(moo_open_info_new_uri(uri, encoding, -1, MOO_OPEN_FLAGS_NONE));
|
||||||
|
|
||||||
return moo_editor_load_file(editor, info.get(), window, GTK_WIDGET(window), TRUE, FALSE, NULL);
|
gerrp ignored;
|
||||||
|
return moo_editor_load_file(editor, info.get(), window, GTK_WIDGET(window), TRUE, FALSE, ignored);
|
||||||
}
|
}
|
||||||
|
|
||||||
static MooMarkupNode *
|
static MooMarkupNode *
|
||||||
@ -1975,7 +1974,9 @@ moo_editor_open_files (MooEditor *editor,
|
|||||||
moo_return_error_if_fail (MOO_IS_EDITOR (editor));
|
moo_return_error_if_fail (MOO_IS_EDITOR (editor));
|
||||||
moo_return_error_if_fail (!moo_open_info_array_is_empty (files));
|
moo_return_error_if_fail (!moo_open_info_array_is_empty (files));
|
||||||
|
|
||||||
docs = _moo_editor_open_files (editor, files, parent, error);
|
gerrp error_here(error);
|
||||||
|
docs = _moo_editor_open_files (editor, files, parent, error_here);
|
||||||
|
|
||||||
ret = !moo_edit_array_is_empty (docs);
|
ret = !moo_edit_array_is_empty (docs);
|
||||||
|
|
||||||
moo_assert (moo_edit_array_is_empty (docs) ||
|
moo_assert (moo_edit_array_is_empty (docs) ||
|
||||||
@ -2036,7 +2037,8 @@ moo_editor_open_file (MooEditor *editor,
|
|||||||
files = moo_open_info_array_new ();
|
files = moo_open_info_array_new ();
|
||||||
moo_open_info_array_append (files, info);
|
moo_open_info_array_append (files, info);
|
||||||
|
|
||||||
docs = _moo_editor_open_files (editor, files, parent, error);
|
gerrp error_here(error);
|
||||||
|
docs = _moo_editor_open_files (editor, files, parent, error_here);
|
||||||
|
|
||||||
moo_open_info_array_free (files);
|
moo_open_info_array_free (files);
|
||||||
|
|
||||||
@ -2315,10 +2317,10 @@ gboolean
|
|||||||
moo_editor_reload (MooEditor *editor,
|
moo_editor_reload (MooEditor *editor,
|
||||||
MooEdit *doc,
|
MooEdit *doc,
|
||||||
MooReloadInfo *info,
|
MooReloadInfo *info,
|
||||||
GError **error)
|
GError **errorp)
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
GError *error_here = NULL;
|
gerrp error(errorp);
|
||||||
MooEditViewArray *views = NULL;
|
MooEditViewArray *views = NULL;
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
@ -2326,7 +2328,7 @@ moo_editor_reload (MooEditor *editor,
|
|||||||
|
|
||||||
if (Edit(*doc)._is_busy())
|
if (Edit(*doc)._is_busy())
|
||||||
{
|
{
|
||||||
g_set_error (error,
|
g_set_error (&error,
|
||||||
MOO_EDIT_RELOAD_ERROR,
|
MOO_EDIT_RELOAD_ERROR,
|
||||||
MOO_EDIT_RELOAD_ERROR_BUSY,
|
MOO_EDIT_RELOAD_ERROR_BUSY,
|
||||||
"document is busy");
|
"document is busy");
|
||||||
@ -2335,7 +2337,7 @@ moo_editor_reload (MooEditor *editor,
|
|||||||
|
|
||||||
if (moo_edit_is_untitled (doc))
|
if (moo_edit_is_untitled (doc))
|
||||||
{
|
{
|
||||||
g_set_error (error,
|
g_set_error (&error,
|
||||||
MOO_EDIT_RELOAD_ERROR,
|
MOO_EDIT_RELOAD_ERROR,
|
||||||
MOO_EDIT_RELOAD_ERROR_UNTITLED,
|
MOO_EDIT_RELOAD_ERROR_UNTITLED,
|
||||||
"document is untitled");
|
"document is untitled");
|
||||||
@ -2346,7 +2348,7 @@ moo_editor_reload (MooEditor *editor,
|
|||||||
moo_edit_is_modified (doc) &&
|
moo_edit_is_modified (doc) &&
|
||||||
!_moo_edit_reload_modified_dialog (doc))
|
!_moo_edit_reload_modified_dialog (doc))
|
||||||
{
|
{
|
||||||
g_set_error (error,
|
g_set_error (&error,
|
||||||
MOO_EDIT_RELOAD_ERROR,
|
MOO_EDIT_RELOAD_ERROR,
|
||||||
MOO_EDIT_RELOAD_ERROR_CANCELLED,
|
MOO_EDIT_RELOAD_ERROR_CANCELLED,
|
||||||
"cancelled by user");
|
"cancelled by user");
|
||||||
@ -2375,12 +2377,10 @@ moo_editor_reload (MooEditor *editor,
|
|||||||
g_object_set_data (G_OBJECT (view), "moo-reload-cursor-offset", GINT_TO_POINTER (cursor_offset));
|
g_object_set_data (G_OBJECT (view), "moo-reload-cursor-offset", GINT_TO_POINTER (cursor_offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_moo_edit_reload_file(*doc, info ? (const char*) info->encoding : nullptr, &error_here))
|
if (!_moo_edit_reload_file(*doc, info ? (const char*) info->encoding : nullptr, error))
|
||||||
{
|
{
|
||||||
if (!_moo_is_file_error_cancelled (error_here))
|
if (!_moo_is_file_error_cancelled (error))
|
||||||
_moo_edit_reload_error_dialog (doc, error_here);
|
_moo_edit_reload_error_dialog (doc, error.get());
|
||||||
|
|
||||||
g_propagate_error (error, error_here);
|
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (doc), "moo-scroll-to", NULL);
|
g_object_set_data (G_OBJECT (doc), "moo-scroll-to", NULL);
|
||||||
goto out;
|
goto out;
|
||||||
@ -2438,14 +2438,14 @@ moo_editor_will_save (G_GNUC_UNUSED MooEditor *editor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
do_save(MooEditor& editor,
|
do_save(MooEditor& editor,
|
||||||
Edit doc,
|
Edit doc,
|
||||||
const g::File& file,
|
g::File file,
|
||||||
const char* encoding,
|
const char* encoding,
|
||||||
GError** error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
int response = MOO_SAVE_RESPONSE_CONTINUE;
|
int response = MOO_SAVE_RESPONSE_CONTINUE;
|
||||||
GError *error_here = NULL;
|
gerrp error_here;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
g_signal_emit(&editor, signals[BEFORE_SAVE], 0, doc, file, &response);
|
g_signal_emit(&editor, signals[BEFORE_SAVE], 0, doc, file, &response);
|
||||||
@ -2455,7 +2455,7 @@ do_save(MooEditor& editor,
|
|||||||
|
|
||||||
if (response == MOO_SAVE_RESPONSE_CANCEL)
|
if (response == MOO_SAVE_RESPONSE_CANCEL)
|
||||||
{
|
{
|
||||||
g_set_error(error,
|
g_set_error(&error,
|
||||||
MOO_EDIT_SAVE_ERROR,
|
MOO_EDIT_SAVE_ERROR,
|
||||||
MOO_EDIT_SAVE_ERROR_CANCELLED,
|
MOO_EDIT_SAVE_ERROR_CANCELLED,
|
||||||
"cancelled");
|
"cancelled");
|
||||||
@ -2467,22 +2467,21 @@ do_save(MooEditor& editor,
|
|||||||
|
|
||||||
result = _moo_edit_save_file(doc, file, encoding,
|
result = _moo_edit_save_file(doc, file, encoding,
|
||||||
moo_editor_get_save_flags(&editor),
|
moo_editor_get_save_flags(&editor),
|
||||||
&error_here);
|
error_here);
|
||||||
if (!result && error_here->domain == MOO_EDIT_FILE_ERROR &&
|
if (!result && error_here->domain == MOO_EDIT_FILE_ERROR &&
|
||||||
error_here->code == MOO_EDIT_FILE_ERROR_ENCODING)
|
error_here->code == MOO_EDIT_FILE_ERROR_ENCODING)
|
||||||
{
|
{
|
||||||
g_error_free(error_here);
|
error_here.clear();
|
||||||
error_here = NULL;
|
|
||||||
|
|
||||||
if (_moo_edit_save_error_enc_dialog(doc, file, encoding))
|
if (_moo_edit_save_error_enc_dialog(doc, file, encoding))
|
||||||
{
|
{
|
||||||
result = _moo_edit_save_file(doc, file, "UTF-8",
|
result = _moo_edit_save_file(doc, file, "UTF-8",
|
||||||
moo_editor_get_save_flags(&editor),
|
moo_editor_get_save_flags(&editor),
|
||||||
&error_here);
|
error_here);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_set_error(error,
|
g_set_error(&error,
|
||||||
MOO_EDIT_SAVE_ERROR,
|
MOO_EDIT_SAVE_ERROR,
|
||||||
MOO_EDIT_SAVE_ERROR_CANCELLED,
|
MOO_EDIT_SAVE_ERROR_CANCELLED,
|
||||||
"cancelled");
|
"cancelled");
|
||||||
@ -2492,8 +2491,8 @@ do_save(MooEditor& editor,
|
|||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
_moo_edit_save_error_dialog(doc, file, error_here);
|
_moo_edit_save_error_dialog(doc, file, error_here.get());
|
||||||
g_propagate_error(error, error_here);
|
error = std::move(error_here);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2513,8 +2512,6 @@ moo_editor_save (MooEditor *editor,
|
|||||||
MooEdit *doc,
|
MooEdit *doc,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean result = FALSE;
|
|
||||||
|
|
||||||
moo_return_error_if_fail (MOO_IS_EDITOR (editor));
|
moo_return_error_if_fail (MOO_IS_EDITOR (editor));
|
||||||
moo_return_error_if_fail (MOO_IS_EDIT (doc));
|
moo_return_error_if_fail (MOO_IS_EDIT (doc));
|
||||||
|
|
||||||
@ -2540,14 +2537,11 @@ moo_editor_save (MooEditor *editor,
|
|||||||
MOO_EDIT_SAVE_ERROR,
|
MOO_EDIT_SAVE_ERROR,
|
||||||
MOO_EDIT_SAVE_ERROR_CANCELLED,
|
MOO_EDIT_SAVE_ERROR_CANCELLED,
|
||||||
"cancelled by user");
|
"cancelled by user");
|
||||||
goto out;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = do_save(*editor, *doc, *file, encoding, error);
|
gerrp error_here(error);
|
||||||
|
return do_save(*editor, *doc, *file, encoding, error_here);
|
||||||
/* fall through */
|
|
||||||
out:
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2602,7 +2596,8 @@ moo_editor_save_as (MooEditor *editor,
|
|||||||
|
|
||||||
update_history_item_for_doc(editor, doc, FALSE);
|
update_history_item_for_doc(editor, doc, FALSE);
|
||||||
|
|
||||||
return do_save(*editor, *doc, *info->file, info->encoding, error);
|
gerrp error_here(error);
|
||||||
|
return do_save(*editor, *doc, *info->file, info->encoding, error_here);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2614,18 +2609,15 @@ moo_editor_save_copy (MooEditor *editor,
|
|||||||
MooSaveInfo *info,
|
MooSaveInfo *info,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
gboolean retval;
|
|
||||||
|
|
||||||
moo_return_error_if_fail (MOO_IS_EDITOR (editor));
|
moo_return_error_if_fail (MOO_IS_EDITOR (editor));
|
||||||
moo_return_error_if_fail (MOO_IS_EDIT (doc));
|
moo_return_error_if_fail (MOO_IS_EDIT (doc));
|
||||||
moo_return_error_if_fail (info != nullptr && info->file != nullptr);
|
moo_return_error_if_fail (info != nullptr && info->file != nullptr);
|
||||||
|
|
||||||
retval = _moo_edit_save_file_copy (*doc, *info->file,
|
gerrp error_here(error);
|
||||||
!info->encoding.empty() ? info->encoding : moo_edit_get_encoding (doc),
|
return _moo_edit_save_file_copy (*doc, *info->file,
|
||||||
moo_editor_get_save_flags (editor),
|
!info->encoding.empty() ? info->encoding : moo_edit_get_encoding (doc),
|
||||||
error);
|
moo_editor_get_save_flags (editor),
|
||||||
|
error_here);
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,8 +24,7 @@
|
|||||||
#include "mooutils/mooprefs.h"
|
#include "mooutils/mooprefs.h"
|
||||||
#include "marshals.h"
|
#include "marshals.h"
|
||||||
#include "mooutils/moo-mime.h"
|
#include "mooutils/moo-mime.h"
|
||||||
#include "moocpp/gobjectutils.h"
|
#include "moocpp/gobjtypes.h"
|
||||||
#include "moocpp/gobjtypes-gio.h"
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
using namespace moo;
|
using namespace moo;
|
||||||
@ -371,8 +370,8 @@ file_blacklisted (MooLangMgr* mgr,
|
|||||||
|
|
||||||
|
|
||||||
MooLang *
|
MooLang *
|
||||||
moo_lang_mgr_get_lang_for_file (MooLangMgr* mgr,
|
moo_lang_mgr_get_lang_for_file (MooLangMgr* mgr,
|
||||||
const g::File& file)
|
g::File file)
|
||||||
{
|
{
|
||||||
MooLang *lang = NULL;
|
MooLang *lang = NULL;
|
||||||
const char *mime_type;
|
const char *mime_type;
|
||||||
|
@ -43,7 +43,7 @@ MooLang *moo_lang_mgr_get_lang (MooLangMgr* mgr,
|
|||||||
const char* lang_id);
|
const char* lang_id);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
MooLang *moo_lang_mgr_get_lang_for_file (MooLangMgr* mgr,
|
MooLang *moo_lang_mgr_get_lang_for_file (MooLangMgr* mgr,
|
||||||
const moo::g::File& file);
|
moo::g::File file);
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
/* list must be freed, content unref'ed */
|
/* list must be freed, content unref'ed */
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <mooutils/moouixml.h>
|
#include <mooutils/moouixml.h>
|
||||||
#include <moocpp/gobjectutils.h>
|
#include <moocpp/gobjtypes.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include "mooutils/mooutils-debug.h"
|
#include "mooutils/mooutils-debug.h"
|
||||||
#include "mooutils/mooaccel.h"
|
#include "mooutils/mooaccel.h"
|
||||||
#include "mooutils/moocompat.h"
|
#include "mooutils/moocompat.h"
|
||||||
#include "moocpp/gobjectutils.h"
|
#include <moocpp/gobjtypes.h>
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#include "mooutils/mooutils.h"
|
#include "mooutils/mooutils.h"
|
||||||
#include "mooutils/moofilewatch.h"
|
#include "mooutils/moofilewatch.h"
|
||||||
#include "marshals.h"
|
#include "marshals.h"
|
||||||
#include "moocpp/gobjectutils.h"
|
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#ifndef __WIN32__
|
#ifndef __WIN32__
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#include "moocpp/grefptr.h"
|
#include "moocpp/grefptr.h"
|
||||||
#include "moocpp/gobjectutils.h"
|
#include "moocpp/gobjtypes.h"
|
||||||
#include "mooutils/moofilewatch.h"
|
#include "mooutils/moofilewatch.h"
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include "moofileview/moofileprops-gxml.h"
|
#include "moofileview/moofileprops-gxml.h"
|
||||||
#include "moofileview/moocreatefolder-gxml.h"
|
#include "moofileview/moocreatefolder-gxml.h"
|
||||||
#include "moofileview/moofileview-drop-gxml.h"
|
#include "moofileview/moofileview-drop-gxml.h"
|
||||||
#include "moocpp/gobjectutils.h"
|
#include <moocpp/gobjtypes.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "mooutils/mooutils-gobject.h"
|
#include "mooutils/mooutils-gobject.h"
|
||||||
#include "mooutils/mooutils-misc.h"
|
#include "mooutils/mooutils-misc.h"
|
||||||
#include "mooutils/moocompat.h"
|
#include "mooutils/moocompat.h"
|
||||||
#include "moocpp/gobjectutils.h"
|
#include "moocpp/gobjtypes.h"
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include "mooutils/mooprefs.h"
|
#include "mooutils/mooprefs.h"
|
||||||
#include "mooutils/mooutils-tests.h"
|
#include "mooutils/mooutils-tests.h"
|
||||||
#include "mooutils/moocompat.h"
|
#include "mooutils/moocompat.h"
|
||||||
|
#include "moocpp/gobjtypes.h"
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "mooutils/moocombo.h"
|
#include "mooutils/moocombo.h"
|
||||||
#include "mooutils/mooentry.h"
|
#include "mooutils/mooentry.h"
|
||||||
#include "mooutils/moocompat.h"
|
#include "mooutils/moocompat.h"
|
||||||
#include "moocpp/gobjectutils.h"
|
#include <moocpp/gobjtypes.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -39,7 +39,7 @@ create_message_dialog (GtkWindow *parent,
|
|||||||
type,
|
type,
|
||||||
message_dialog_buttons,
|
message_dialog_buttons,
|
||||||
"<span weight=\"bold\" size=\"larger\">%s</span>", text);
|
"<span weight=\"bold\" size=\"larger\">%s</span>", text);
|
||||||
if (secondary_text)
|
if (secondary_text && *secondary_text)
|
||||||
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
||||||
"%s", secondary_text);
|
"%s", secondary_text);
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include "mooutils/mooutils-gobject.h"
|
#include "mooutils/mooutils-gobject.h"
|
||||||
#include "mooutils/mooeditops.h"
|
#include "mooutils/mooeditops.h"
|
||||||
#include "mooutils/mooi18n.h"
|
#include "mooutils/mooi18n.h"
|
||||||
#include "moocpp/gobjectutils.h"
|
#include <moocpp/gobjtypes.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* moofilewriter-private.h
|
* moofilewriter-private.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2004-2010 by Yevgen Muntyan <emuntyan@users.sourceforge.net>
|
* Copyright (C) 2004-2016 by Yevgen Muntyan <emuntyan@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This file is part of medit. medit is free software; you can
|
* This file is part of medit. medit is free software; you can
|
||||||
* redistribute it and/or modify it under the terms of the
|
* redistribute it and/or modify it under the terms of the
|
||||||
@ -13,74 +13,64 @@
|
|||||||
* License along with medit. If not, see <http://www.gnu.org/licenses/>.
|
* License along with medit. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MOO_FILE_WRITER_PRIVATE_H
|
#pragma once
|
||||||
#define MOO_FILE_WRITER_PRIVATE_H
|
|
||||||
|
|
||||||
#include "mooutils/moofilewriter.h"
|
#include "mooutils/moofilewriter.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
struct MooFileReader
|
||||||
|
{
|
||||||
|
MooFileReader();
|
||||||
|
~MooFileReader();
|
||||||
|
|
||||||
#define MOO_TYPE_FILE_READER (moo_file_reader_get_type ())
|
void close_file();
|
||||||
#define MOO_FILE_READER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MOO_TYPE_FILE_READER, MooFileReader))
|
|
||||||
#define MOO_FILE_READER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOO_TYPE_FILE_READER, MooFileReaderClass))
|
|
||||||
#define MOO_IS_FILE_READER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), MOO_TYPE_FILE_READER))
|
|
||||||
#define MOO_IS_FILE_READER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOO_TYPE_FILE_READER))
|
|
||||||
#define MOO_FILE_READER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOO_TYPE_FILE_READER, MooFileReaderClass))
|
|
||||||
|
|
||||||
typedef struct _MooFileReaderClass MooFileReaderClass;
|
MOO_DISABLE_COPY_OPS(MooFileReader);
|
||||||
|
|
||||||
struct _MooFileReaderClass {
|
MGW_FILE *file;
|
||||||
GObjectClass base_class;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct MooFileWriter
|
||||||
|
{
|
||||||
|
virtual ~MooFileWriter() {}
|
||||||
|
|
||||||
#define MOO_TYPE_FILE_WRITER (moo_file_writer_get_type ())
|
virtual bool write (const char* data,
|
||||||
#define MOO_FILE_WRITER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MOO_TYPE_FILE_WRITER, MooFileWriter))
|
gsize len) = 0;
|
||||||
#define MOO_FILE_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOO_TYPE_FILE_WRITER, MooFileWriterClass))
|
virtual bool printf (const char* fmt,
|
||||||
#define MOO_IS_FILE_WRITER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), MOO_TYPE_FILE_WRITER))
|
va_list args) G_GNUC_PRINTF (2, 0) = 0;
|
||||||
#define MOO_IS_FILE_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOO_TYPE_FILE_WRITER))
|
virtual bool close (moo::gerrp& error) = 0;
|
||||||
#define MOO_FILE_WRITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOO_TYPE_FILE_WRITER, MooFileWriterClass))
|
|
||||||
|
|
||||||
typedef struct _MooFileWriterClass MooFileWriterClass;
|
|
||||||
|
|
||||||
struct _MooFileWriter {
|
|
||||||
GObject base;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MooFileWriterClass {
|
struct MooLocalFileWriter : public MooFileWriter
|
||||||
GObjectClass base_class;
|
{
|
||||||
|
MooLocalFileWriter();
|
||||||
|
~MooLocalFileWriter();
|
||||||
|
|
||||||
gboolean (*meth_write) (MooFileWriter *writer,
|
bool write (const char* data,
|
||||||
const char *data,
|
gsize len) override;
|
||||||
gsize len);
|
bool printf (const char* fmt,
|
||||||
gboolean (*meth_printf) (MooFileWriter *writer,
|
va_list args) G_GNUC_PRINTF (2, 0) override;
|
||||||
const char *fmt,
|
bool close (moo::gerrp& error) override;
|
||||||
va_list args) G_GNUC_PRINTF (2, 0);
|
|
||||||
gboolean (*meth_close) (MooFileWriter *writer,
|
MOO_DISABLE_COPY_OPS(MooLocalFileWriter);
|
||||||
GError **error);
|
|
||||||
|
moo::g::FilePtr file;
|
||||||
|
moo::g::FileOutputStreamPtr stream;
|
||||||
|
MooFileWriterFlags flags;
|
||||||
|
moo::gerrp error;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct MooStringWriter : public MooFileWriter
|
||||||
|
{
|
||||||
|
MooStringWriter();
|
||||||
|
~MooStringWriter();
|
||||||
|
|
||||||
#define MOO_TYPE_LOCAL_FILE_WRITER (moo_local_file_writer_get_type ())
|
bool write (const char* data,
|
||||||
#define MOO_LOCAL_FILE_WRITER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), MOO_TYPE_LOCAL_FILE_WRITER, MooLocalFileWriter))
|
gsize len) override;
|
||||||
|
bool printf (const char* fmt,
|
||||||
|
va_list args) G_GNUC_PRINTF (2, 0) override;
|
||||||
|
bool close (moo::gerrp& error) override;
|
||||||
|
|
||||||
typedef struct _MooLocalFileWriter MooLocalFileWriter;
|
MOO_DISABLE_COPY_OPS(MooStringWriter);
|
||||||
typedef struct _MooLocalFileWriterClass MooLocalFileWriterClass;
|
|
||||||
|
|
||||||
struct _MooLocalFileWriterClass {
|
GString *string;
|
||||||
MooFileWriterClass base_class;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define MOO_TYPE_STRING_WRITER (moo_string_writer_get_type ())
|
|
||||||
|
|
||||||
typedef struct _MooStringWriter MooStringWriter;
|
|
||||||
typedef struct _MooStringWriterClass MooStringWriterClass;
|
|
||||||
|
|
||||||
struct _MooStringWriterClass {
|
|
||||||
MooFileWriterClass base_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* MOO_FILE_WRITER_PRIVATE_H */
|
|
||||||
|
@ -29,59 +29,41 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using namespace moo;
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* MooFileReader
|
/* MooFileReader
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct _MooFileReader {
|
MooFileReader::MooFileReader()
|
||||||
GObject base;
|
: file(nullptr)
|
||||||
MGW_FILE *file;
|
|
||||||
};
|
|
||||||
|
|
||||||
MOO_DEFINE_TYPE_STATIC (MooFileReader, moo_file_reader, G_TYPE_OBJECT)
|
|
||||||
|
|
||||||
static void
|
|
||||||
moo_file_reader_init (MooFileReader *reader)
|
|
||||||
{
|
{
|
||||||
reader->file = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void MooFileReader::close_file ()
|
||||||
moo_file_reader_close_file (MooFileReader *reader)
|
|
||||||
{
|
{
|
||||||
if (reader->file)
|
if (file)
|
||||||
{
|
{
|
||||||
mgw_fclose (reader->file);
|
mgw_fclose (file);
|
||||||
reader->file = NULL;
|
file = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
MooFileReader::~MooFileReader()
|
||||||
moo_file_reader_dispose (GObject *object)
|
|
||||||
{
|
{
|
||||||
MooFileReader *reader = MOO_FILE_READER (object);
|
close_file();
|
||||||
moo_file_reader_close_file (reader);
|
|
||||||
G_OBJECT_CLASS (moo_file_reader_parent_class)->dispose (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
moo_file_reader_class_init (MooFileReaderClass *klass)
|
|
||||||
{
|
|
||||||
G_OBJECT_CLASS (klass)->dispose = moo_file_reader_dispose;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
moo_file_reader_close (MooFileReader *reader)
|
moo_file_reader_close (MooFileReader *reader)
|
||||||
{
|
{
|
||||||
g_return_if_fail (MOO_IS_FILE_READER (reader));
|
delete reader;
|
||||||
moo_file_reader_close_file (reader);
|
|
||||||
g_object_unref (reader);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static MooFileReader *
|
static MooFileReader *
|
||||||
moo_file_reader_new_real (const char *filename,
|
moo_file_reader_new_real (const char *filename,
|
||||||
gboolean binary,
|
gboolean binary,
|
||||||
GError **error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
const char *mode = binary ? "rb" : "r";
|
const char *mode = binary ? "rb" : "r";
|
||||||
MGW_FILE *file;
|
MGW_FILE *file;
|
||||||
@ -89,33 +71,33 @@ moo_file_reader_new_real (const char *filename,
|
|||||||
mgw_errno_t err;
|
mgw_errno_t err;
|
||||||
|
|
||||||
g_return_val_if_fail (filename != NULL, NULL);
|
g_return_val_if_fail (filename != NULL, NULL);
|
||||||
g_return_val_if_fail (!error || !*error, NULL);
|
g_return_val_if_fail (!error, NULL);
|
||||||
|
|
||||||
if (!(file = mgw_fopen (filename, mode, &err)))
|
if (!(file = mgw_fopen (filename, mode, &err)))
|
||||||
{
|
{
|
||||||
g_set_error (error, MOO_FILE_ERROR,
|
g_set_error (&error, MOO_FILE_ERROR,
|
||||||
_moo_file_error_from_errno (err),
|
_moo_file_error_from_errno (err),
|
||||||
_("Could not open %s: %s"), filename,
|
_("Could not open %s: %s"), filename,
|
||||||
mgw_strerror (err));
|
mgw_strerror (err));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
reader = MOO_FILE_READER (g_object_new (MOO_TYPE_FILE_READER, nullptr));
|
reader = new MooFileReader();
|
||||||
reader->file = file;
|
reader->file = file;
|
||||||
|
|
||||||
return reader;
|
return reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
MooFileReader *
|
MooFileReader *
|
||||||
moo_file_reader_new (const char *filename,
|
moo_file_reader_new (const char* filename,
|
||||||
GError **error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
return moo_file_reader_new_real (filename, TRUE, error);
|
return moo_file_reader_new_real (filename, TRUE, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
MooFileReader *
|
MooFileReader *
|
||||||
moo_text_reader_new (const char *filename,
|
moo_text_reader_new (const char* filename,
|
||||||
GError **error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
return moo_file_reader_new_real (filename, FALSE, error);
|
return moo_file_reader_new_real (filename, FALSE, error);
|
||||||
}
|
}
|
||||||
@ -125,14 +107,14 @@ moo_file_reader_read (MooFileReader *reader,
|
|||||||
char *buf,
|
char *buf,
|
||||||
gsize buf_size,
|
gsize buf_size,
|
||||||
gsize *size_read_p,
|
gsize *size_read_p,
|
||||||
GError **error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
gsize size_read;
|
gsize size_read;
|
||||||
mgw_errno_t err;
|
mgw_errno_t err;
|
||||||
|
|
||||||
g_return_val_if_fail (MOO_IS_FILE_READER (reader), FALSE);
|
g_return_val_if_fail (reader != nullptr, FALSE);
|
||||||
g_return_val_if_fail (size_read_p != NULL, FALSE);
|
g_return_val_if_fail (size_read_p != NULL, FALSE);
|
||||||
g_return_val_if_fail (!error || !*error, FALSE);
|
g_return_val_if_fail (!error, FALSE);
|
||||||
g_return_val_if_fail (reader->file != NULL, FALSE);
|
g_return_val_if_fail (reader->file != NULL, FALSE);
|
||||||
g_return_val_if_fail (buf_size == 0 || buf != NULL, FALSE);
|
g_return_val_if_fail (buf_size == 0 || buf != NULL, FALSE);
|
||||||
|
|
||||||
@ -143,7 +125,7 @@ moo_file_reader_read (MooFileReader *reader,
|
|||||||
|
|
||||||
if (size_read != buf_size && mgw_ferror (reader->file))
|
if (size_read != buf_size && mgw_ferror (reader->file))
|
||||||
{
|
{
|
||||||
g_set_error (error, MOO_FILE_ERROR,
|
g_set_error (&error, MOO_FILE_ERROR,
|
||||||
_moo_file_error_from_errno (err),
|
_moo_file_error_from_errno (err),
|
||||||
"error reading file: %s",
|
"error reading file: %s",
|
||||||
mgw_strerror (err));
|
mgw_strerror (err));
|
||||||
@ -159,24 +141,12 @@ moo_file_reader_read (MooFileReader *reader,
|
|||||||
/* MooFileWriter
|
/* MooFileWriter
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MOO_DEFINE_TYPE_STATIC (MooFileWriter, moo_file_writer, G_TYPE_OBJECT)
|
|
||||||
|
|
||||||
static void
|
|
||||||
moo_file_writer_init (G_GNUC_UNUSED MooFileWriter *writer)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
moo_file_writer_class_init (G_GNUC_UNUSED MooFileWriterClass *klass)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
moo_file_writer_write (MooFileWriter *writer,
|
moo_file_writer_write (MooFileWriter *writer,
|
||||||
const char *data,
|
const char *data,
|
||||||
gssize len)
|
gssize len)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (MOO_IS_FILE_WRITER (writer), FALSE);
|
g_return_val_if_fail (writer != nullptr, FALSE);
|
||||||
g_return_val_if_fail (data != NULL, FALSE);
|
g_return_val_if_fail (data != NULL, FALSE);
|
||||||
|
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
@ -184,7 +154,7 @@ moo_file_writer_write (MooFileWriter *writer,
|
|||||||
if (!len)
|
if (!len)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
return MOO_FILE_WRITER_GET_CLASS (writer)->meth_write (writer, data, len);
|
return writer->write (data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
@ -195,11 +165,11 @@ moo_file_writer_printf (MooFileWriter *writer,
|
|||||||
va_list args;
|
va_list args;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
g_return_val_if_fail (MOO_IS_FILE_WRITER (writer), FALSE);
|
g_return_val_if_fail (writer != nullptr, FALSE);
|
||||||
g_return_val_if_fail (fmt != NULL, FALSE);
|
g_return_val_if_fail (fmt != NULL, FALSE);
|
||||||
|
|
||||||
va_start (args, fmt);
|
va_start (args, fmt);
|
||||||
ret = MOO_FILE_WRITER_GET_CLASS (writer)->meth_printf (writer, fmt, args);
|
ret = writer->printf (fmt, args);
|
||||||
va_end (args);
|
va_end (args);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -210,38 +180,40 @@ moo_file_writer_printf_markup (MooFileWriter *writer,
|
|||||||
const char *fmt,
|
const char *fmt,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
va_list args;
|
g_return_val_if_fail (writer != nullptr, FALSE);
|
||||||
gboolean ret;
|
|
||||||
char *string;
|
|
||||||
|
|
||||||
g_return_val_if_fail (MOO_IS_FILE_WRITER (writer), FALSE);
|
|
||||||
g_return_val_if_fail (fmt != NULL, FALSE);
|
g_return_val_if_fail (fmt != NULL, FALSE);
|
||||||
|
|
||||||
|
va_list args;
|
||||||
va_start (args, fmt);
|
va_start (args, fmt);
|
||||||
string = g_markup_vprintf_escaped (fmt, args);
|
gstr string = gstr::wrap_new (g_markup_vprintf_escaped (fmt, args));
|
||||||
va_end (args);
|
va_end (args);
|
||||||
|
|
||||||
g_return_val_if_fail (string != NULL, FALSE);
|
g_return_val_if_fail (!string.is_null(), FALSE);
|
||||||
|
|
||||||
ret = moo_file_writer_write (writer, string, -1);
|
return moo_file_writer_write (writer, string, -1);
|
||||||
|
}
|
||||||
|
|
||||||
g_free (string);
|
gboolean
|
||||||
|
moo_file_writer_close (MooFileWriter* writer,
|
||||||
|
gerrp& error)
|
||||||
|
{
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
|
g_return_val_if_fail (writer != nullptr, FALSE);
|
||||||
|
g_return_val_if_fail (!error, FALSE);
|
||||||
|
|
||||||
|
ret = writer->close (error);
|
||||||
|
|
||||||
|
delete writer;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
moo_file_writer_close (MooFileWriter *writer,
|
moo_file_writer_close (MooFileWriter *writer,
|
||||||
GError **error)
|
GError **errorp)
|
||||||
{
|
{
|
||||||
gboolean ret;
|
gerrp error(errorp);
|
||||||
|
return moo_file_writer_close (writer, error);
|
||||||
g_return_val_if_fail (MOO_IS_FILE_WRITER (writer), FALSE);
|
|
||||||
g_return_val_if_fail (!error || !*error, FALSE);
|
|
||||||
|
|
||||||
ret = MOO_FILE_WRITER_GET_CLASS (writer)->meth_close (writer, error);
|
|
||||||
|
|
||||||
g_object_unref (writer);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -249,113 +221,88 @@ moo_file_writer_close (MooFileWriter *writer,
|
|||||||
/* MooLocalFileWriter
|
/* MooLocalFileWriter
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct _MooLocalFileWriter {
|
MooLocalFileWriter::MooLocalFileWriter()
|
||||||
MooFileWriter base;
|
: flags(MOO_FILE_WRITER_FLAGS_NONE)
|
||||||
GFile *file;
|
{
|
||||||
GOutputStream *stream;
|
}
|
||||||
MooFileWriterFlags flags;
|
|
||||||
GError *error;
|
|
||||||
};
|
|
||||||
|
|
||||||
MOO_DEFINE_TYPE_STATIC (MooLocalFileWriter, moo_local_file_writer, MOO_TYPE_FILE_WRITER)
|
MooLocalFileWriter::~MooLocalFileWriter()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static MooFileWriter *
|
static MooFileWriter *
|
||||||
moo_local_file_writer_new (GFile *file,
|
moo_local_file_writer_new (g::File file,
|
||||||
MooFileWriterFlags flags,
|
MooFileWriterFlags flags,
|
||||||
GError **error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
MooLocalFileWriter *writer = NULL;
|
|
||||||
GFileOutputStream *stream = NULL;
|
|
||||||
GFile *file_copy = NULL;
|
|
||||||
|
|
||||||
g_return_val_if_fail (G_IS_FILE (file), NULL);
|
|
||||||
|
|
||||||
if (flags & MOO_FILE_WRITER_CONFIG_MODE)
|
if (flags & MOO_FILE_WRITER_CONFIG_MODE)
|
||||||
{
|
{
|
||||||
char *dirname;
|
|
||||||
char *filename;
|
|
||||||
mgw_errno_t err;
|
mgw_errno_t err;
|
||||||
|
|
||||||
filename = g_file_get_path (file);
|
gstr filename = file.get_path ();
|
||||||
dirname = filename ? g_path_get_dirname (filename) : NULL;
|
gstr dirname = !filename.empty() ? gstr::wrap_new (g_path_get_dirname (filename)) : gstr();
|
||||||
|
|
||||||
if (dirname && _moo_mkdir_with_parents (dirname, &err) != 0)
|
if (!dirname.empty() && _moo_mkdir_with_parents (dirname, &err) != 0)
|
||||||
{
|
{
|
||||||
char *display_name = g_filename_display_name (dirname);
|
gstr display_name = gstr::wrap_new (g_filename_display_name (dirname));
|
||||||
g_set_error (error, G_FILE_ERROR,
|
g_set_error (&error, G_FILE_ERROR,
|
||||||
mgw_file_error_from_errno (err),
|
mgw_file_error_from_errno (err),
|
||||||
_("Could not create folder %s: %s"),
|
_("Could not create folder %s: %s"),
|
||||||
display_name, mgw_strerror (err));
|
display_name, mgw_strerror (err));
|
||||||
g_free (display_name);
|
return nullptr;
|
||||||
g_free (dirname);
|
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (dirname);
|
|
||||||
g_free (filename);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
file_copy = g_file_dup (file);
|
g::FilePtr file_copy = file.dup ();
|
||||||
stream = g_file_replace (file_copy, NULL,
|
g::FileOutputStreamPtr stream = file_copy->replace (NULL,
|
||||||
(flags & MOO_FILE_WRITER_SAVE_BACKUP) != 0,
|
(flags & MOO_FILE_WRITER_SAVE_BACKUP) != 0,
|
||||||
G_FILE_CREATE_NONE,
|
G_FILE_CREATE_NONE,
|
||||||
NULL, error);
|
NULL, error);
|
||||||
|
|
||||||
if (!stream)
|
if (!stream)
|
||||||
goto error;
|
return nullptr;
|
||||||
|
|
||||||
|
auto writer = make_unique<MooLocalFileWriter>();
|
||||||
|
|
||||||
writer = MOO_LOCAL_FILE_WRITER (g_object_new (MOO_TYPE_LOCAL_FILE_WRITER, nullptr));
|
|
||||||
writer->file = file_copy;
|
writer->file = file_copy;
|
||||||
writer->stream = G_OUTPUT_STREAM (stream);
|
writer->stream = stream;
|
||||||
writer->flags = flags;
|
writer->flags = flags;
|
||||||
|
|
||||||
return MOO_FILE_WRITER (writer);
|
return writer.release ();
|
||||||
|
|
||||||
error:
|
|
||||||
if (file_copy)
|
|
||||||
g_object_unref (file_copy);
|
|
||||||
if (stream)
|
|
||||||
g_object_unref (stream);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MooFileWriter *
|
MooFileWriter *
|
||||||
moo_file_writer_new (const char *filename,
|
moo_file_writer_new (const char* filename,
|
||||||
MooFileWriterFlags flags,
|
MooFileWriterFlags flags,
|
||||||
GError **error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
GFile *file;
|
g_return_val_if_fail (filename != nullptr, nullptr);
|
||||||
MooFileWriter *writer;
|
g_return_val_if_fail (!error, nullptr);
|
||||||
|
|
||||||
g_return_val_if_fail (filename != NULL, NULL);
|
g::FilePtr file = g::File::new_for_path (filename);
|
||||||
g_return_val_if_fail (!error || !*error, NULL);
|
g_return_val_if_fail (file != nullptr, nullptr);
|
||||||
|
|
||||||
file = g_file_new_for_path (filename);
|
return moo_local_file_writer_new (*file, flags, error);
|
||||||
writer = moo_local_file_writer_new (file, flags, error);
|
|
||||||
|
|
||||||
g_object_unref (file);
|
|
||||||
return writer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MooFileWriter *
|
MooFileWriter *
|
||||||
moo_file_writer_new_for_file (GFile *file,
|
moo_file_writer_new_for_file (g::File file,
|
||||||
MooFileWriterFlags flags,
|
MooFileWriterFlags flags,
|
||||||
GError **error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (G_IS_FILE (file), NULL);
|
g_return_val_if_fail (!error, NULL);
|
||||||
g_return_val_if_fail (!error || !*error, NULL);
|
|
||||||
return moo_local_file_writer_new (file, flags, error);
|
return moo_local_file_writer_new (file, flags, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
MooFileWriter *
|
MooFileWriter *
|
||||||
moo_config_writer_new (const char *filename,
|
moo_config_writer_new (const char *filename,
|
||||||
gboolean save_backup,
|
gboolean save_backup,
|
||||||
GError **error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
MooFileWriterFlags flags;
|
MooFileWriterFlags flags;
|
||||||
|
|
||||||
g_return_val_if_fail (filename != NULL, NULL);
|
g_return_val_if_fail (filename != NULL, NULL);
|
||||||
g_return_val_if_fail (!error || !*error, NULL);
|
g_return_val_if_fail (!error, NULL);
|
||||||
|
|
||||||
flags = MOO_FILE_WRITER_CONFIG_MODE | MOO_FILE_WRITER_TEXT_MODE;
|
flags = MOO_FILE_WRITER_CONFIG_MODE | MOO_FILE_WRITER_TEXT_MODE;
|
||||||
if (save_backup)
|
if (save_backup)
|
||||||
@ -364,15 +311,19 @@ moo_config_writer_new (const char *filename,
|
|||||||
return moo_file_writer_new (filename, flags, error);
|
return moo_file_writer_new (filename, flags, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MooFileWriter *
|
||||||
static gboolean
|
moo_config_writer_new (const char *filename,
|
||||||
moo_local_file_writer_write (MooFileWriter *fwriter,
|
gboolean save_backup,
|
||||||
const char *data,
|
GError **errorp)
|
||||||
gsize len)
|
|
||||||
{
|
{
|
||||||
MooLocalFileWriter *writer = (MooLocalFileWriter*) fwriter;
|
gerrp error(errorp);
|
||||||
|
return moo_config_writer_new(filename, save_backup, error);
|
||||||
|
}
|
||||||
|
|
||||||
if (writer->error)
|
|
||||||
|
bool MooLocalFileWriter::write (const char* data, gsize len)
|
||||||
|
{
|
||||||
|
if (error)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
while (len > 0)
|
while (len > 0)
|
||||||
@ -385,7 +336,7 @@ moo_local_file_writer_write (MooFileWriter *fwriter,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
if (writer->flags & MOO_FILE_WRITER_TEXT_MODE)
|
if (flags & MOO_FILE_WRITER_TEXT_MODE)
|
||||||
{
|
{
|
||||||
gsize le_start, le_len;
|
gsize le_start, le_len;
|
||||||
if (moo_find_line_end (data, len, &le_start, &le_len))
|
if (moo_find_line_end (data, len, &le_start, &le_len))
|
||||||
@ -397,20 +348,18 @@ moo_local_file_writer_write (MooFileWriter *fwriter,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!g_output_stream_write_all (writer->stream,
|
if (!stream->write_all (data, chunk_len,
|
||||||
data, chunk_len,
|
&bytes_written, NULL,
|
||||||
&bytes_written, NULL,
|
error))
|
||||||
&writer->error))
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
data += next_chunk;
|
data += next_chunk;
|
||||||
len -= next_chunk;
|
len -= next_chunk;
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
if (need_le && !g_output_stream_write_all (writer->stream,
|
if (need_le && !stream->write_all ("\r\n", 2,
|
||||||
"\r\n", 2,
|
&bytes_written, NULL,
|
||||||
&bytes_written, NULL,
|
error))
|
||||||
&writer->error))
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -418,71 +367,30 @@ moo_local_file_writer_write (MooFileWriter *fwriter,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
G_GNUC_PRINTF (2, 0)
|
bool MooLocalFileWriter::printf (const char* fmt, va_list args)
|
||||||
static gboolean
|
|
||||||
moo_local_file_writer_printf (MooFileWriter *fwriter,
|
|
||||||
const char *fmt,
|
|
||||||
va_list args)
|
|
||||||
{
|
{
|
||||||
MooLocalFileWriter *writer = (MooLocalFileWriter*) fwriter;
|
if (error)
|
||||||
char *text;
|
|
||||||
gboolean retval;
|
|
||||||
|
|
||||||
if (writer->error)
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
text = g_strdup_vprintf (fmt, args);
|
gstr text = gstr::wrap_new (g_strdup_vprintf (fmt, args));
|
||||||
retval = moo_local_file_writer_write (fwriter, text, strlen (text));
|
return write (text, strlen (text));
|
||||||
g_free (text);
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
bool MooLocalFileWriter::close (gerrp& out_error)
|
||||||
moo_local_file_writer_close (MooFileWriter *fwriter,
|
|
||||||
GError **error)
|
|
||||||
{
|
{
|
||||||
MooLocalFileWriter *writer = (MooLocalFileWriter*) fwriter;
|
g_return_val_if_fail (stream != nullptr, FALSE);
|
||||||
gboolean retval;
|
|
||||||
|
|
||||||
g_return_val_if_fail (writer->stream != NULL, FALSE);
|
if (!error)
|
||||||
|
|
||||||
if (!writer->error)
|
|
||||||
{
|
{
|
||||||
g_output_stream_flush (writer->stream, NULL, &writer->error);
|
stream->flush (NULL, error);
|
||||||
g_output_stream_close (writer->stream, NULL,
|
gerrp second;
|
||||||
writer->error ? NULL : &writer->error);
|
stream->close (NULL, error ? second : error);
|
||||||
g_object_unref (writer->stream);
|
stream.reset ();
|
||||||
g_object_unref (writer->file);
|
file.reset ();
|
||||||
writer->stream = NULL;
|
|
||||||
writer->file = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = writer->error == NULL;
|
out_error = std::move (error);
|
||||||
|
return !out_error;
|
||||||
if (writer->error)
|
|
||||||
g_propagate_error (error, writer->error);
|
|
||||||
|
|
||||||
writer->error = NULL;
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
moo_local_file_writer_class_init (MooLocalFileWriterClass *klass)
|
|
||||||
{
|
|
||||||
MooFileWriterClass *writer_class = MOO_FILE_WRITER_CLASS (klass);
|
|
||||||
writer_class->meth_write = moo_local_file_writer_write;
|
|
||||||
writer_class->meth_printf = moo_local_file_writer_printf;
|
|
||||||
writer_class->meth_close = moo_local_file_writer_close;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
moo_local_file_writer_init (MooLocalFileWriter *writer)
|
|
||||||
{
|
|
||||||
writer->file = NULL;
|
|
||||||
writer->stream = NULL;
|
|
||||||
writer->error = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -490,88 +398,44 @@ moo_local_file_writer_init (MooLocalFileWriter *writer)
|
|||||||
/* MooStringWriter
|
/* MooStringWriter
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct _MooStringWriter {
|
bool MooStringWriter::write (const char* data, gsize len)
|
||||||
MooFileWriter base;
|
|
||||||
GString *string;
|
|
||||||
};
|
|
||||||
|
|
||||||
MOO_DEFINE_TYPE_STATIC (MooStringWriter, moo_string_writer, MOO_TYPE_FILE_WRITER)
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
moo_string_writer_write (MooFileWriter *fwriter,
|
|
||||||
const char *data,
|
|
||||||
gsize len)
|
|
||||||
{
|
{
|
||||||
MooStringWriter *writer = (MooStringWriter*) fwriter;
|
g_string_append_len (string, data, len);
|
||||||
g_string_append_len (writer->string, data, len);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
G_GNUC_PRINTF (2, 0)
|
bool MooStringWriter::printf (const char* fmt, va_list args)
|
||||||
static gboolean
|
|
||||||
moo_string_writer_printf (MooFileWriter *fwriter,
|
|
||||||
const char *fmt,
|
|
||||||
va_list args)
|
|
||||||
{
|
{
|
||||||
char *buf;
|
strp buf;
|
||||||
gint len;
|
gint len = g_vasprintf (buf.pp(), fmt, args);
|
||||||
MooStringWriter *writer = (MooStringWriter*) fwriter;
|
|
||||||
|
|
||||||
len = g_vasprintf (&buf, fmt, args);
|
|
||||||
|
|
||||||
if (len >= 0)
|
if (len >= 0)
|
||||||
{
|
g_string_append_len (string, buf.get(), len);
|
||||||
g_string_append_len (writer->string, buf, len);
|
|
||||||
g_free (buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
bool MooStringWriter::close (G_GNUC_UNUSED gerrp& error)
|
||||||
moo_string_writer_close (MooFileWriter *fwriter,
|
|
||||||
G_GNUC_UNUSED GError **error)
|
|
||||||
{
|
{
|
||||||
MooStringWriter *writer = (MooStringWriter*) fwriter;
|
g_string_free (string, TRUE);
|
||||||
g_string_free (writer->string, TRUE);
|
string = NULL;
|
||||||
writer->string = NULL;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
MooStringWriter::MooStringWriter()
|
||||||
moo_string_writer_class_init (MooStringWriterClass *klass)
|
: string (g_string_new (NULL))
|
||||||
{
|
{
|
||||||
MooFileWriterClass *writer_class = MOO_FILE_WRITER_CLASS (klass);
|
|
||||||
writer_class->meth_write = moo_string_writer_write;
|
|
||||||
writer_class->meth_printf = moo_string_writer_printf;
|
|
||||||
writer_class->meth_close = moo_string_writer_close;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
MooStringWriter::~MooStringWriter()
|
||||||
moo_string_writer_init (MooStringWriter *writer)
|
|
||||||
{
|
{
|
||||||
writer->string = g_string_new (NULL);
|
g_assert (!string);
|
||||||
}
|
}
|
||||||
|
|
||||||
MooFileWriter *
|
MooFileWriter *
|
||||||
moo_string_writer_new (void)
|
moo_string_writer_new (void)
|
||||||
{
|
{
|
||||||
return MOO_FILE_WRITER (g_object_new (MOO_TYPE_STRING_WRITER, nullptr));
|
return new MooStringWriter();
|
||||||
}
|
|
||||||
|
|
||||||
const char *
|
|
||||||
moo_string_writer_get_string (MooFileWriter *fwriter,
|
|
||||||
gsize *len)
|
|
||||||
{
|
|
||||||
MooStringWriter *writer = (MooStringWriter*) fwriter;
|
|
||||||
|
|
||||||
g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE ((writer), MOO_TYPE_STRING_WRITER), NULL);
|
|
||||||
g_return_val_if_fail (writer->string != NULL, NULL);
|
|
||||||
|
|
||||||
if (len)
|
|
||||||
*len = writer->string->len;
|
|
||||||
|
|
||||||
return writer->string->str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -628,7 +492,7 @@ test_moo_file_writer (void)
|
|||||||
const char *dir;
|
const char *dir;
|
||||||
char *my_dir, *filename, *bak_filename;
|
char *my_dir, *filename, *bak_filename;
|
||||||
MooFileWriter *writer;
|
MooFileWriter *writer;
|
||||||
GError *error = NULL;
|
gerrp error;
|
||||||
|
|
||||||
dir = moo_test_get_working_dir ();
|
dir = moo_test_get_working_dir ();
|
||||||
my_dir = g_build_filename (dir, "cfg-writer", NULL);
|
my_dir = g_build_filename (dir, "cfg-writer", NULL);
|
||||||
@ -639,11 +503,7 @@ test_moo_file_writer (void)
|
|||||||
TEST_ASSERT_MSG (writer != NULL,
|
TEST_ASSERT_MSG (writer != NULL,
|
||||||
"moo_cfg_writer_new failed: %s",
|
"moo_cfg_writer_new failed: %s",
|
||||||
moo_error_message (error));
|
moo_error_message (error));
|
||||||
if (error)
|
error.clear ();
|
||||||
{
|
|
||||||
g_error_free (error);
|
|
||||||
error = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (writer)
|
if (writer)
|
||||||
{
|
{
|
||||||
@ -653,11 +513,7 @@ test_moo_file_writer (void)
|
|||||||
TEST_ASSERT_MSG (moo_file_writer_close (writer, &error),
|
TEST_ASSERT_MSG (moo_file_writer_close (writer, &error),
|
||||||
"moo_file_writer_close failed: %s",
|
"moo_file_writer_close failed: %s",
|
||||||
moo_error_message (error));
|
moo_error_message (error));
|
||||||
if (error)
|
error.clear ();
|
||||||
{
|
|
||||||
g_error_free (error);
|
|
||||||
error = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
#define LE "\r\n"
|
#define LE "\r\n"
|
||||||
@ -682,11 +538,7 @@ test_moo_file_writer (void)
|
|||||||
TEST_ASSERT_MSG (moo_file_writer_close (writer, &error),
|
TEST_ASSERT_MSG (moo_file_writer_close (writer, &error),
|
||||||
"moo_file_writer_close failed: %s",
|
"moo_file_writer_close failed: %s",
|
||||||
moo_error_message (error));
|
moo_error_message (error));
|
||||||
if (error)
|
error.clear ();
|
||||||
{
|
|
||||||
g_error_free (error);
|
|
||||||
error = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_ASSERT (g_file_test (filename, G_FILE_TEST_EXISTS));
|
TEST_ASSERT (g_file_test (filename, G_FILE_TEST_EXISTS));
|
||||||
TEST_ASSERT (g_file_test (bak_filename, G_FILE_TEST_EXISTS));
|
TEST_ASSERT (g_file_test (bak_filename, G_FILE_TEST_EXISTS));
|
||||||
@ -703,11 +555,7 @@ test_moo_file_writer (void)
|
|||||||
writer = moo_config_writer_new ("K:\\nowayyouhaveit\\file.ini", TRUE, &error);
|
writer = moo_config_writer_new ("K:\\nowayyouhaveit\\file.ini", TRUE, &error);
|
||||||
#endif
|
#endif
|
||||||
TEST_ASSERT (writer == NULL);
|
TEST_ASSERT (writer == NULL);
|
||||||
TEST_ASSERT (error != NULL);
|
TEST_ASSERT (error);
|
||||||
|
|
||||||
if (error)
|
|
||||||
g_error_free (error);
|
|
||||||
error = NULL;
|
|
||||||
|
|
||||||
g_free (bak_filename);
|
g_free (bak_filename);
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
|
@ -15,44 +15,65 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <gio/gio.h>
|
#include <mooutils/mooutils-misc.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
#include <moocpp/gobjtypes-gio.h>
|
||||||
|
|
||||||
typedef struct _MooFileReader MooFileReader;
|
struct MooFileReader;
|
||||||
|
struct MooFileWriter;
|
||||||
|
|
||||||
|
void g_object_ref(MooFileReader*) = delete;
|
||||||
|
void g_object_unref(MooFileReader*) = delete;
|
||||||
|
void g_object_ref(MooFileWriter*) = delete;
|
||||||
|
void g_object_unref(MooFileWriter*) = delete;
|
||||||
|
|
||||||
MooFileReader *moo_file_reader_new (const char *filename,
|
MooFileReader *moo_file_reader_new (const char *filename,
|
||||||
GError **error);
|
moo::gerrp& error);
|
||||||
MooFileReader *moo_text_reader_new (const char *filename,
|
MooFileReader *moo_text_reader_new (const char *filename,
|
||||||
GError **error);
|
moo::gerrp& error);
|
||||||
gboolean moo_file_reader_read (MooFileReader *reader,
|
gboolean moo_file_reader_read (MooFileReader *reader,
|
||||||
char *buf,
|
char *buf,
|
||||||
gsize buf_size,
|
gsize buf_size,
|
||||||
gsize *size_read,
|
gsize *size_read,
|
||||||
GError **error);
|
moo::gerrp& error);
|
||||||
void moo_file_reader_close (MooFileReader *reader);
|
void moo_file_reader_close (MooFileReader *reader);
|
||||||
|
|
||||||
typedef struct _MooFileWriter MooFileWriter;
|
|
||||||
|
|
||||||
typedef enum /*< flags >*/
|
typedef enum /*< flags >*/
|
||||||
{
|
{
|
||||||
|
MOO_FILE_WRITER_FLAGS_NONE = 0,
|
||||||
MOO_FILE_WRITER_SAVE_BACKUP = 1 << 0,
|
MOO_FILE_WRITER_SAVE_BACKUP = 1 << 0,
|
||||||
MOO_FILE_WRITER_CONFIG_MODE = 1 << 1,
|
MOO_FILE_WRITER_CONFIG_MODE = 1 << 1,
|
||||||
MOO_FILE_WRITER_TEXT_MODE = 1 << 2
|
MOO_FILE_WRITER_TEXT_MODE = 1 << 2
|
||||||
} MooFileWriterFlags;
|
} MooFileWriterFlags;
|
||||||
|
|
||||||
|
MOO_DEFINE_FLAGS(MooFileWriterFlags);
|
||||||
|
|
||||||
MooFileWriter *moo_file_writer_new (const char *filename,
|
MooFileWriter *moo_file_writer_new (const char *filename,
|
||||||
MooFileWriterFlags flags,
|
MooFileWriterFlags flags,
|
||||||
GError **error);
|
moo::gerrp& error);
|
||||||
MooFileWriter *moo_file_writer_new_for_file (GFile *file,
|
MooFileWriter *moo_file_writer_new_for_file (moo::g::File file,
|
||||||
MooFileWriterFlags flags,
|
MooFileWriterFlags flags,
|
||||||
GError **error);
|
moo::gerrp& error);
|
||||||
|
MooFileWriter *moo_config_writer_new (const char *filename,
|
||||||
|
gboolean save_backup,
|
||||||
|
moo::gerrp& error);
|
||||||
|
MooFileWriter *moo_string_writer_new (void);
|
||||||
|
|
||||||
|
gboolean moo_file_writer_close (MooFileWriter *writer,
|
||||||
|
moo::gerrp& error);
|
||||||
|
|
||||||
|
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
typedef struct MooFileWriter MooFileWriter;
|
||||||
|
|
||||||
MooFileWriter *moo_config_writer_new (const char *filename,
|
MooFileWriter *moo_config_writer_new (const char *filename,
|
||||||
gboolean save_backup,
|
gboolean save_backup,
|
||||||
GError **error);
|
GError **error);
|
||||||
MooFileWriter *moo_string_writer_new (void);
|
|
||||||
|
|
||||||
gboolean moo_file_writer_write (MooFileWriter *writer,
|
gboolean moo_file_writer_write (MooFileWriter *writer,
|
||||||
const char *data,
|
const char *data,
|
||||||
gssize len);
|
gssize len);
|
||||||
@ -65,13 +86,4 @@ gboolean moo_file_writer_printf_markup (MooFileWriter *writer,
|
|||||||
gboolean moo_file_writer_close (MooFileWriter *writer,
|
gboolean moo_file_writer_close (MooFileWriter *writer,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
const char *moo_string_writer_get_string (MooFileWriter *writer,
|
|
||||||
gsize *len);
|
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#include <moocpp/gobjectutils.h>
|
|
||||||
MOO_DEFINE_FLAGS(MooFileWriterFlags);
|
|
||||||
#endif
|
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
using namespace moo;
|
||||||
|
|
||||||
#define N_MENU_ITEMS 10
|
#define N_MENU_ITEMS 10
|
||||||
#define MAX_ITEM_NUMBER 5000
|
#define MAX_ITEM_NUMBER 5000
|
||||||
|
|
||||||
@ -794,7 +796,7 @@ static void
|
|||||||
moo_history_mgr_save (MooHistoryMgr *mgr)
|
moo_history_mgr_save (MooHistoryMgr *mgr)
|
||||||
{
|
{
|
||||||
const char *filename;
|
const char *filename;
|
||||||
GError *error = NULL;
|
gerrp error;
|
||||||
MooFileWriter *writer;
|
MooFileWriter *writer;
|
||||||
|
|
||||||
g_return_if_fail (MOO_IS_HISTORY_MGR (mgr));
|
g_return_if_fail (MOO_IS_HISTORY_MGR (mgr));
|
||||||
@ -811,7 +813,7 @@ moo_history_mgr_save (MooHistoryMgr *mgr)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((writer = moo_config_writer_new (filename, FALSE, &error)))
|
if ((writer = moo_config_writer_new (filename, FALSE, error)))
|
||||||
{
|
{
|
||||||
GString *string;
|
GString *string;
|
||||||
MooHistoryItemList *l;
|
MooHistoryItemList *l;
|
||||||
@ -833,14 +835,13 @@ moo_history_mgr_save (MooHistoryMgr *mgr)
|
|||||||
g_string_free (string, TRUE);
|
g_string_free (string, TRUE);
|
||||||
|
|
||||||
moo_file_writer_write (writer, "</" ELM_ROOT ">\n", -1);
|
moo_file_writer_write (writer, "</" ELM_ROOT ">\n", -1);
|
||||||
moo_file_writer_close (writer, &error);
|
moo_file_writer_close (writer, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
g_critical ("could not save file '%s': %s",
|
g_critical ("could not save file '%s': %s",
|
||||||
filename, moo_error_message (error));
|
filename, moo_error_message (error));
|
||||||
g_error_free (error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <mooglib/moo-glib.h>
|
#include <mooglib/moo-glib.h>
|
||||||
|
|
||||||
|
using namespace moo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
MooMarkupDoc *doc;
|
MooMarkupDoc *doc;
|
||||||
@ -1297,7 +1298,7 @@ gboolean
|
|||||||
moo_parse_markup_file (const char *filename,
|
moo_parse_markup_file (const char *filename,
|
||||||
const GMarkupParser *parser,
|
const GMarkupParser *parser,
|
||||||
gpointer data,
|
gpointer data,
|
||||||
GError **error)
|
GError **errorp)
|
||||||
{
|
{
|
||||||
GMarkupParseContext *ctx;
|
GMarkupParseContext *ctx;
|
||||||
MooFileReader *reader;
|
MooFileReader *reader;
|
||||||
@ -1307,7 +1308,9 @@ moo_parse_markup_file (const char *filename,
|
|||||||
|
|
||||||
g_return_val_if_fail (filename != NULL, FALSE);
|
g_return_val_if_fail (filename != NULL, FALSE);
|
||||||
g_return_val_if_fail (parser != NULL, FALSE);
|
g_return_val_if_fail (parser != NULL, FALSE);
|
||||||
g_return_val_if_fail (!error || !*error, FALSE);
|
g_return_val_if_fail (!errorp || !*errorp, FALSE);
|
||||||
|
|
||||||
|
gerrp error(errorp);
|
||||||
|
|
||||||
if (!(reader = moo_text_reader_new (filename, error)))
|
if (!(reader = moo_text_reader_new (filename, error)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1325,14 +1328,14 @@ moo_parse_markup_file (const char *filename,
|
|||||||
if (!size)
|
if (!size)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!g_markup_parse_context_parse (ctx, buf, size, error))
|
if (!g_markup_parse_context_parse (ctx, buf, size, &error))
|
||||||
{
|
{
|
||||||
seen_error = TRUE;
|
seen_error = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!seen_error && !g_markup_parse_context_end_parse (ctx, error))
|
if (!seen_error && !g_markup_parse_context_end_parse (ctx, &error))
|
||||||
seen_error = TRUE;
|
seen_error = TRUE;
|
||||||
|
|
||||||
g_markup_parse_context_free (ctx);
|
g_markup_parse_context_free (ctx);
|
||||||
|
@ -38,7 +38,6 @@
|
|||||||
#include "mooutils-gobject.h"
|
#include "mooutils-gobject.h"
|
||||||
#include "mooi18n.h"
|
#include "mooi18n.h"
|
||||||
|
|
||||||
#include "moocpp/gobjectutils.h"
|
|
||||||
#include "moocpp/gobjtypes.h"
|
#include "moocpp/gobjtypes.h"
|
||||||
using namespace moo;
|
using namespace moo;
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include "mooutils-misc.h"
|
#include "mooutils-misc.h"
|
||||||
#include "moocpp/gobjectutils.h"
|
#include "moocpp/gobjtypes.h"
|
||||||
#include "moocompat.h"
|
#include "moocompat.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include <gobject/gvaluecollector.h>
|
#include <gobject/gvaluecollector.h>
|
||||||
#include <mooglib/moo-glib.h>
|
#include <mooglib/moo-glib.h>
|
||||||
|
|
||||||
|
using namespace moo;
|
||||||
|
|
||||||
#define MOO_PREFS_ELEMENT "moo-prefs"
|
#define MOO_PREFS_ELEMENT "moo-prefs"
|
||||||
#define PROP_VERSION "version"
|
#define PROP_VERSION "version"
|
||||||
#define MOO_PREFS_VERSION "1.0"
|
#define MOO_PREFS_VERSION "1.0"
|
||||||
@ -597,7 +599,7 @@ process_item (MooMarkupElement *elm,
|
|||||||
static gboolean
|
static gboolean
|
||||||
load_file (const char *file,
|
load_file (const char *file,
|
||||||
int prefs_kind,
|
int prefs_kind,
|
||||||
GError **error)
|
moo::gerrp& error)
|
||||||
{
|
{
|
||||||
MooMarkupDoc *xml;
|
MooMarkupDoc *xml;
|
||||||
MooMarkupNode *root;
|
MooMarkupNode *root;
|
||||||
@ -625,7 +627,7 @@ load_file (const char *file,
|
|||||||
if (!g_file_test (file, G_FILE_TEST_EXISTS))
|
if (!g_file_test (file, G_FILE_TEST_EXISTS))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
xml = moo_markup_parse_file (file, error);
|
xml = moo_markup_parse_file (file, &error);
|
||||||
|
|
||||||
if (!xml)
|
if (!xml)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -679,11 +681,11 @@ load_file (const char *file,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
bool
|
||||||
moo_prefs_load (char **sys_files,
|
moo_prefs_load (char **sys_files,
|
||||||
const char *file_rc,
|
const char *file_rc,
|
||||||
const char *file_state,
|
const char *file_state,
|
||||||
GError **error)
|
moo::gerrp& error)
|
||||||
{
|
{
|
||||||
moo_prefs_set_modified (FALSE);
|
moo_prefs_set_modified (FALSE);
|
||||||
|
|
||||||
@ -846,9 +848,9 @@ check_modified (MooPrefsKind prefs_kind)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
save_file (const char *file,
|
save_file (const char* file,
|
||||||
MooPrefsKind prefs_kind,
|
MooPrefsKind prefs_kind,
|
||||||
GError **error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
MooMarkupDoc *xml = NULL;
|
MooMarkupDoc *xml = NULL;
|
||||||
MooMarkupNode *node;
|
MooMarkupNode *node;
|
||||||
@ -899,10 +901,10 @@ save_file (const char *file,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
bool
|
||||||
moo_prefs_save (const char *file_rc,
|
moo_prefs_save (const char* file_rc,
|
||||||
const char *file_state,
|
const char* file_state,
|
||||||
GError **error)
|
gerrp& error)
|
||||||
{
|
{
|
||||||
PrefsStore *prefs = prefs_instance ();
|
PrefsStore *prefs = prefs_instance ();
|
||||||
|
|
||||||
|
@ -13,27 +13,19 @@
|
|||||||
* License along with medit. If not, see <http://www.gnu.org/licenses/>.
|
* License along with medit. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MOO_PREFS_H
|
#pragma once
|
||||||
#define MOO_PREFS_H
|
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <mooutils/moomarkup.h>
|
#include <mooutils/moomarkup.h>
|
||||||
#include <mooutils/mooutils-file.h>
|
#include <mooutils/mooutils-file.h>
|
||||||
|
#include <moocpp/strutils.h>
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MOO_PREFS_RC,
|
MOO_PREFS_RC,
|
||||||
MOO_PREFS_STATE
|
MOO_PREFS_STATE
|
||||||
} MooPrefsKind;
|
} MooPrefsKind;
|
||||||
|
|
||||||
gboolean moo_prefs_load (char **sys_files,
|
G_BEGIN_DECLS
|
||||||
const char *file_rc,
|
|
||||||
const char *file_state,
|
|
||||||
GError **error);
|
|
||||||
gboolean moo_prefs_save (const char *file_rc,
|
|
||||||
const char *file_state,
|
|
||||||
GError **error);
|
|
||||||
|
|
||||||
MooMarkupNode *moo_prefs_get_markup (MooPrefsKind prefs_kind);
|
MooMarkupNode *moo_prefs_get_markup (MooPrefsKind prefs_kind);
|
||||||
|
|
||||||
@ -91,4 +83,14 @@ void moo_prefs_set_bool (const char *key,
|
|||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* MOO_PREFS_H */
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
bool moo_prefs_load (char** sys_files,
|
||||||
|
const char* file_rc,
|
||||||
|
const char* file_state,
|
||||||
|
moo::gerrp& error);
|
||||||
|
bool moo_prefs_save (const char* file_rc,
|
||||||
|
const char* file_state,
|
||||||
|
moo::gerrp& error);
|
||||||
|
|
||||||
|
#endif // __cplusplus
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include "mooutils/moospawn.h"
|
#include "mooutils/moospawn.h"
|
||||||
#include "marshals.h"
|
#include "marshals.h"
|
||||||
#include "mooutils/mooutils-misc.h"
|
#include "mooutils/mooutils-misc.h"
|
||||||
#include "moocpp/gobjectutils.h"
|
#include "moocpp/gobjtypes.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifndef __WIN32__
|
#ifndef __WIN32__
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include "mooutils/mooundo.h"
|
#include "mooutils/mooundo.h"
|
||||||
#include "marshals.h"
|
#include "marshals.h"
|
||||||
#include "moocpp/gobjectutils.h"
|
#include "moocpp/gobjtypes.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,17 +7,10 @@ using namespace moo;
|
|||||||
|
|
||||||
MOO_DEFINE_OBJECT_ARRAY_FULL (MooFileArray, moo_file_array, GFile)
|
MOO_DEFINE_OBJECT_ARRAY_FULL (MooFileArray, moo_file_array, GFile)
|
||||||
|
|
||||||
char *
|
|
||||||
moo_file_get_display_name (GFile *file)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (G_IS_FILE (file), NULL);
|
|
||||||
return g_file_get_parse_name (file);
|
|
||||||
}
|
|
||||||
|
|
||||||
gstr
|
gstr
|
||||||
moo_file_get_display_name(const g::File& file)
|
moo_file_get_display_name(g::File file)
|
||||||
{
|
{
|
||||||
return gstr::wrap_new(moo_file_get_display_name(file.nc_gobj()));
|
return file.get_parse_name();
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -16,7 +16,6 @@ moo_file_free (GFile *file)
|
|||||||
|
|
||||||
gboolean moo_file_fnmatch (GFile* file,
|
gboolean moo_file_fnmatch (GFile* file,
|
||||||
const char* glob);
|
const char* glob);
|
||||||
char *moo_file_get_display_name (GFile* file);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
@ -25,6 +24,6 @@ G_END_DECLS
|
|||||||
#include <moocpp/strutils.h>
|
#include <moocpp/strutils.h>
|
||||||
#include <moocpp/gobjtypes-gio.h>
|
#include <moocpp/gobjtypes-gio.h>
|
||||||
|
|
||||||
moo::gstr moo_file_get_display_name (const moo::g::File& file);
|
moo::gstr moo_file_get_display_name (moo::g::File file);
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
@ -130,42 +130,6 @@ MOO_STMT_START { \
|
|||||||
#define moo_return_if_reached() moo_return_val_if_reached(;)
|
#define moo_return_if_reached() moo_return_val_if_reached(;)
|
||||||
|
|
||||||
|
|
||||||
GQuark moo_error_quark (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
#define MOO_ERROR (moo_error_quark ())
|
|
||||||
|
|
||||||
enum {
|
|
||||||
MOO_ERROR_UNEXPECTED = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
#define moo_return_error_if_fail_val(cond, val) \
|
|
||||||
MOO_STMT_START { \
|
|
||||||
if (cond) \
|
|
||||||
{ \
|
|
||||||
} \
|
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
moo_critical("Condition '%s' failed", #cond); \
|
|
||||||
g_set_error (error, MOO_ERROR, MOO_ERROR_UNEXPECTED,\
|
|
||||||
"unexpected error"); \
|
|
||||||
return val; \
|
|
||||||
} \
|
|
||||||
} MOO_STMT_END
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#define moo_err_false_ret__ false
|
|
||||||
#define moo_err_null_ret__ nullptr
|
|
||||||
#else
|
|
||||||
#define moo_err_false_ret__ FALSE
|
|
||||||
#define moo_err_null_ret__ NULL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define moo_return_error_if_fail(cond) \
|
|
||||||
moo_return_error_if_fail_val (cond, moo_err_false_ret__)
|
|
||||||
|
|
||||||
#define moo_return_error_if_fail_p(cond) \
|
|
||||||
moo_return_error_if_fail_val (cond, moo_err_null_ret__)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Suppress warnings when GCC is in -pedantic mode and not -std=c99
|
* Suppress warnings when GCC is in -pedantic mode and not -std=c99
|
||||||
*/
|
*/
|
||||||
|
@ -53,6 +53,8 @@
|
|||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using namespace moo;
|
||||||
|
|
||||||
MOO_DEFINE_QUARK(moo - error, moo_error_quark)
|
MOO_DEFINE_QUARK(moo - error, moo_error_quark)
|
||||||
|
|
||||||
static gpointer copy_pointer(gpointer p)
|
static gpointer copy_pointer(gpointer p)
|
||||||
@ -1703,24 +1705,23 @@ moo_get_user_cache_file (const char *basename)
|
|||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
save_config_file (const char *filename,
|
save_config_file (const char *filename,
|
||||||
const char *content,
|
const char *content,
|
||||||
gssize len,
|
gssize len,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
MooFileWriter *writer;
|
MooFileWriter *writer;
|
||||||
gboolean retval;
|
|
||||||
|
|
||||||
g_return_val_if_fail (filename != NULL, FALSE);
|
g_return_val_if_fail (filename != NULL, FALSE);
|
||||||
g_return_val_if_fail (content != NULL, FALSE);
|
g_return_val_if_fail (content != NULL, FALSE);
|
||||||
|
|
||||||
if (!(writer = moo_config_writer_new (filename, TRUE, error)))
|
gerrp error_here(error);
|
||||||
|
|
||||||
|
if (!(writer = moo_config_writer_new (filename, TRUE, error_here)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
moo_file_writer_write (writer, content, len);
|
moo_file_writer_write (writer, content, len);
|
||||||
retval = moo_file_writer_close (writer, error);
|
return moo_file_writer_close (writer, error_here);
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -1730,21 +1731,17 @@ save_user_data_file (const char *basename,
|
|||||||
gssize len,
|
gssize len,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
char *file;
|
|
||||||
gboolean result;
|
|
||||||
|
|
||||||
g_return_val_if_fail (basename != NULL, FALSE);
|
g_return_val_if_fail (basename != NULL, FALSE);
|
||||||
g_return_val_if_fail (content != NULL, FALSE);
|
g_return_val_if_fail (content != NULL, FALSE);
|
||||||
|
|
||||||
|
gstr file;
|
||||||
|
|
||||||
if (cache)
|
if (cache)
|
||||||
file = moo_get_user_cache_file (basename);
|
file.take (moo_get_user_cache_file (basename));
|
||||||
else
|
else
|
||||||
file = moo_get_user_data_file (basename);
|
file.take (moo_get_user_data_file (basename));
|
||||||
|
|
||||||
result = save_config_file (file, content, len, error);
|
return save_config_file (file, content, len, error);
|
||||||
|
|
||||||
g_free (file);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
@ -2231,6 +2228,12 @@ moo_error_message (GError *error)
|
|||||||
return error->message;
|
return error->message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
moo::gstr
|
||||||
|
moo_error_message(const moo::gerrp& err)
|
||||||
|
{
|
||||||
|
return gstr::make_borrowed (moo_error_message (err.get ()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
moo_signal_accumulator_continue_cancel (G_GNUC_UNUSED GSignalInvocationHint *ihint,
|
moo_signal_accumulator_continue_cancel (G_GNUC_UNUSED GSignalInvocationHint *ihint,
|
||||||
|
@ -267,29 +267,66 @@ moo_os_win32 (void)
|
|||||||
#include <moocpp/strutils.h>
|
#include <moocpp/strutils.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace moo
|
|
||||||
{
|
|
||||||
|
|
||||||
class gerrp
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
gerrp();
|
|
||||||
~gerrp();
|
|
||||||
|
|
||||||
operator bool() const { return m_err != nullptr; }
|
|
||||||
bool operator!() const { return m_err == nullptr; }
|
|
||||||
|
|
||||||
GError* get() const { return m_err; }
|
|
||||||
GError* operator->() const { return m_err; }
|
|
||||||
GError** operator&() { return &m_err; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
GError* m_err;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace moo
|
|
||||||
|
|
||||||
std::vector<moo::gstr> moo_get_data_subdirs(const moo::gstr& subdir);
|
std::vector<moo::gstr> moo_get_data_subdirs(const moo::gstr& subdir);
|
||||||
moo::gstr moo_error_message(const moo::gerrp& err);
|
moo::gstr moo_error_message(const moo::gerrp& err);
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
GQuark moo_error_quark (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
#define MOO_ERROR (moo_error_quark ())
|
||||||
|
|
||||||
|
enum {
|
||||||
|
MOO_ERROR_UNEXPECTED = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
#define moo_err_false_ret__ false
|
||||||
|
#define moo_err_null_ret__ nullptr
|
||||||
|
|
||||||
|
inline void moo_err_set_unexpected_error(GError** error)
|
||||||
|
{
|
||||||
|
g_set_error (error, MOO_ERROR, MOO_ERROR_UNEXPECTED, "unexpected error");
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void moo_err_set_unexpected_error(moo::gerrp& error)
|
||||||
|
{
|
||||||
|
moo_err_set_unexpected_error(&error);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // !__cplusplus
|
||||||
|
|
||||||
|
#define moo_err_false_ret__ FALSE
|
||||||
|
#define moo_err_null_ret__ NULL
|
||||||
|
|
||||||
|
#define moo_err_set_unexpected_error(error) \
|
||||||
|
g_set_error (error, \
|
||||||
|
MOO_ERROR, \
|
||||||
|
MOO_ERROR_UNEXPECTED, \
|
||||||
|
"unexpected error")
|
||||||
|
|
||||||
|
#endif // !__cplusplus
|
||||||
|
|
||||||
|
#define moo_return_error_if_fail_val(cond, val) \
|
||||||
|
MOO_STMT_START { \
|
||||||
|
if (cond) \
|
||||||
|
{ \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
moo_critical("Condition '%s' failed", #cond); \
|
||||||
|
moo_err_set_unexpected_error(error); \
|
||||||
|
return val; \
|
||||||
|
} \
|
||||||
|
} MOO_STMT_END
|
||||||
|
|
||||||
|
#define moo_return_error_if_fail(cond) \
|
||||||
|
moo_return_error_if_fail_val (cond, moo_err_false_ret__)
|
||||||
|
|
||||||
|
#define moo_return_error_if_fail_p(cond) \
|
||||||
|
moo_return_error_if_fail_val (cond, moo_err_null_ret__)
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "mooutils/mooutils-gobject.h"
|
#include "mooutils/mooutils-gobject.h"
|
||||||
#include "mooutils/moocompat.h"
|
#include "mooutils/moocompat.h"
|
||||||
#include "mooutils/mootype-macros.h"
|
#include "mooutils/mootype-macros.h"
|
||||||
#include "moocpp/gobjectutils.h"
|
#include "moocpp/gobjtypes.h"
|
||||||
#include "marshals.h"
|
#include "marshals.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gobject/gvaluecollector.h>
|
#include <gobject/gvaluecollector.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user