SF.net SVN: geany:[3454] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Fri Jan 9 18:21:13 UTC 2009
Revision: 3454
http://geany.svn.sourceforge.net/geany/?rev=3454&view=rev
Author: eht16
Date: 2009-01-09 18:21:12 +0000 (Fri, 09 Jan 2009)
Log Message:
-----------
Add checks for GIO (GLib >= 2.16) support.
Allow to specify files on the command line and from remote instances to be URIs (local and with GIO also remote URIs).
Modified Paths:
--------------
trunk/ChangeLog
trunk/configure.in
trunk/src/main.c
trunk/src/main.h
trunk/src/utils.c
trunk/src/utils.h
trunk/win32-config.h
trunk/wscript
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-01-08 17:27:57 UTC (rev 3453)
+++ trunk/ChangeLog 2009-01-09 18:21:12 UTC (rev 3454)
@@ -1,3 +1,12 @@
+2009-01-09 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+
+ * configure.in, win32-config.h, wscript, src/main.c, src/main.h,
+ src/utils.c, src/utils.h:
+ Add checks for GIO (GLib >= 2.16) support.
+ Allow to specify files on the command line and from remote instances
+ to be URIs (local and with GIO also remote URIs).
+
+
2009-01-08 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/prefs.c, src/stash.c, src/keyfile.c:
Modified: trunk/configure.in
===================================================================
--- trunk/configure.in 2009-01-08 17:27:57 UTC (rev 3453)
+++ trunk/configure.in 2009-01-09 18:21:12 UTC (rev 3454)
@@ -132,6 +132,10 @@
PKG_CHECK_MODULES(GTK, [$gtk_modules])
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
+# GIO checks
+gio_modules="gio-2.0 >= 2.16"
+PKG_CHECK_MODULES(GIO, [$gio_modules], have_gio=1, have_gio=0)
+AC_DEFINE_UNQUOTED(HAVE_GIO, $have_gio, [Whether GIO is available])
# --disable-deprecated switch for GTK2 purification
AC_ARG_ENABLE(deprecated, [ --disable-deprecated Disable deprecated GTK functions. ],
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2009-01-08 17:27:57 UTC (rev 3453)
+++ trunk/src/main.c 2009-01-09 18:21:12 UTC (rev 3454)
@@ -301,7 +301,7 @@
{
gchar *result;
- if (g_path_is_absolute(filename))
+ if (g_path_is_absolute(filename) || utils_is_uri(filename))
result = g_strdup(filename);
else
{
@@ -717,37 +717,46 @@
/* Used for command-line arguments at startup or from socket.
* this will strip any :line:col filename suffix from locale_filename */
-gboolean main_handle_filename(gchar *locale_filename)
+gboolean main_handle_filename(const gchar *locale_filename)
{
GeanyDocument *doc;
gint line = -1, column = -1;
+ gchar *filename;
g_return_val_if_fail(locale_filename, FALSE);
- get_line_and_column_from_filename(locale_filename, &line, &column);
+ /* check whether the passed filename is an URI */
+ filename = utils_get_path_from_uri(locale_filename);
+ if (filename == NULL)
+ return FALSE;
+
+ get_line_and_column_from_filename(filename, &line, &column);
if (line >= 0)
cl_options.goto_line = line;
if (column >= 0)
cl_options.goto_column = column;
- if (g_file_test(locale_filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
+ if (g_file_test(filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
{
- doc = document_open_file(locale_filename, FALSE, NULL, NULL);
+ doc = document_open_file(filename, FALSE, NULL, NULL);
/* add recent file manually if opening_session_files is set */
if (doc != NULL && main_status.opening_session_files)
ui_add_recent_file(doc->file_name);
+ g_free(filename);
return TRUE;
}
else if (file_prefs.cmdline_new_files)
{ /* create new file with the given filename */
- gchar *utf8_filename = utils_get_utf8_from_locale(locale_filename);
+ gchar *utf8_filename = utils_get_utf8_from_locale(filename);
doc = document_new_file(utf8_filename, NULL, NULL);
if (doc != NULL)
ui_add_recent_file(doc->file_name);
g_free(utf8_filename);
+ g_free(filename);
return TRUE;
}
+ g_free(filename);
return FALSE;
}
@@ -825,9 +834,18 @@
if (prefs.load_session)
{
if (load_project_from_cl)
- project_load_file(argv[1]);
- else
- if (cl_options.load_session && !cl_options.new_instance)
+ {
+ gchar *pfile = argv[1];
+ if (utils_is_uri(argv[1]))
+ pfile = utils_get_path_from_uri(argv[1]);
+ if (pfile != NULL)
+ {
+ project_load_file(pfile);
+ if (pfile != argv[1])
+ g_free(pfile);
+ }
+ }
+ else if (cl_options.load_session && !cl_options.new_instance)
load_session_project_file();
/* when we want a new instance, we still load project session files unless -s
Modified: trunk/src/main.h
===================================================================
--- trunk/src/main.h 2009-01-08 17:27:57 UTC (rev 3453)
+++ trunk/src/main.h 2009-01-09 18:21:12 UTC (rev 3454)
@@ -57,7 +57,7 @@
void main_quit(void);
-gboolean main_handle_filename(gchar *locale_filename);
+gboolean main_handle_filename(const gchar *locale_filename);
void main_reload_configuration(void);
Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c 2009-01-08 17:27:57 UTC (rev 3453)
+++ trunk/src/utils.c 2009-01-09 18:21:12 UTC (rev 3454)
@@ -1550,3 +1550,48 @@
}
+/* Retrieves the path for the given URI.
+ * It returns:
+ * - the path which was determined by g_filename_from_uri() or GIO
+ * - NULL if the URI is non-local and gvfs-fuse is not installed
+ * - a new copy of 'uri' if it is not an URI. */
+gchar *utils_get_path_from_uri(const gchar *uri)
+{
+ gchar *locale_filename;
+
+ g_return_val_if_fail(uri != NULL, NULL);
+
+ if (! utils_is_uri(uri))
+ return g_strdup(uri);
+
+ /* this will work only for 'file://' URIs */
+ locale_filename = g_filename_from_uri(uri, NULL, NULL);
+#ifdef HAVE_GIO
+ /* g_filename_from_uri() failed, so we probably have a non-local URI */
+ if (locale_filename == NULL)
+ {
+ GFile *file = g_file_new_for_uri(uri);
+ locale_filename = g_file_get_path(file);
+ g_object_unref(file);
+ if (locale_filename == NULL)
+ {
+ geany_debug("The URI '%s' could not be resolved to a local path. This means "
+ "that the URI is invalid or that you don't have gvfs-fuse installed.", uri);
+ return NULL;
+ }
+ }
+#endif
+ if (locale_filename == NULL)
+ geany_debug("The URI '%s' could not be resolved to a local path. This means that the "
+ "URI is invalid or that Geany can't use GVFS (maybe it is not installed).", uri);
+
+ return locale_filename;
+}
+
+
+gboolean utils_is_uri(const gchar *uri)
+{
+ g_return_val_if_fail(uri != NULL, FALSE);
+
+ return (strstr(uri, "://") != NULL);
+}
Modified: trunk/src/utils.h
===================================================================
--- trunk/src/utils.h 2009-01-08 17:27:57 UTC (rev 3453)
+++ trunk/src/utils.h 2009-01-09 18:21:12 UTC (rev 3454)
@@ -151,4 +151,8 @@
const gchar *utils_build_path(const gchar *first, ...) G_GNUC_NULL_TERMINATED;
+gchar *utils_get_path_from_uri(const gchar *uri);
+
+gboolean utils_is_uri(const gchar *uri);
+
#endif
Modified: trunk/win32-config.h
===================================================================
--- trunk/win32-config.h 2009-01-08 17:27:57 UTC (rev 3453)
+++ trunk/win32-config.h 2009-01-09 18:21:12 UTC (rev 3454)
@@ -321,3 +321,6 @@
/* Define if you want to detect a running instance */
#define HAVE_SOCKET 1
+/* Define if GIO should be used, need GLib 2.16.x or newer */
+#define HAVE_GIO 1
+
Modified: trunk/wscript
===================================================================
--- trunk/wscript 2009-01-08 17:27:57 UTC (rev 3453)
+++ trunk/wscript 2009-01-09 18:21:12 UTC (rev 3454)
@@ -184,6 +184,8 @@
have_gtk_210 = True
else:
gtk_version = 'Unknown'
+ # GIO check
+ conf.check_cfg(package='gio-2.0', uselib_store='GIO')
conf_define_from_opt('LIBDIR', Options.options.libdir, conf.env['PREFIX'] + '/lib')
conf_define_from_opt('DOCDIR', Options.options.docdir, conf.env['DATADIR'] + '/doc/geany')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list