[gedit] Handle also application::open
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Handle also application::open
- Date: Tue, 12 Aug 2014 09:11:58 +0000 (UTC)
commit 718210725f07194ca349a324e2d1d412ed85e1c5
Author: Paolo Borelli <pborelli gnome org>
Date: Tue Aug 12 11:10:38 2014 +0200
Handle also application::open
Even if we do our own command line parsing, we still need to implement
open since the dbus method is used when activating files from nautilus.
https://bugzilla.gnome.org/show_bug.cgi?id=734175
gedit/gedit-app.c | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index 8ce0879..42b0365 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -992,6 +992,42 @@ gedit_app_handle_local_options (GApplication *application,
return -1;
}
+/* Note: when launched from command line we do not reach this method
+ * since we manually handle the command line parameters in order to
+ * parse +LINE:COL, stdin, etc.
+ * However this method is called when open() is called via dbus, for
+ * instance when double clicking on a file in nautilus
+ */
+static void
+gedit_app_open (GApplication *application,
+ GFile **files,
+ gint n_files,
+ const gchar *hint)
+{
+ gint i;
+ GSList *file_list = NULL;
+
+ for (i = 0; i < n_files; i++)
+ {
+ file_list = g_slist_prepend (file_list, files[i]);
+ }
+
+ file_list = g_slist_reverse (file_list);
+
+ open_files (application,
+ FALSE,
+ FALSE,
+ NULL,
+ 0,
+ 0,
+ NULL,
+ NULL,
+ file_list,
+ NULL);
+
+ g_slist_free (file_list);
+}
+
static gboolean
ensure_user_config_dir (void)
{
@@ -1186,6 +1222,7 @@ gedit_app_class_init (GeditAppClass *klass)
app_class->activate = gedit_app_activate;
app_class->command_line = gedit_app_command_line;
app_class->handle_local_options = gedit_app_handle_local_options;
+ app_class->open = gedit_app_open;
app_class->shutdown = gedit_app_shutdown;
klass->show_help = gedit_app_show_help_impl;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]