1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
From f9840c342e4b5767ee35f0d326b7f7eaf56850ed Mon Sep 17 00:00:00 2001
From: Alexandre Franke <alexandre.franke@gmail.com>
Date: Mon, 05 Mar 2012 17:22:56 +0000
Subject: Fix for broken "open file on startup" behaviour
Switch to gtk_init_with_args from GnomeProgam broke opening of files from command line and when double clicking on file in file browser.
Based on patches 193670 and 193835 by Maxim Zakharov.
https://bugzilla.gnome.org/show_bug.cgi?id=656373
---
diff --git a/src/planner-main.c b/src/planner-main.c
index cdeb8ea..c0aabd2 100644
--- a/src/planner-main.c
+++ b/src/planner-main.c
@@ -37,7 +37,7 @@ static gchar **args_remaining = NULL;
static GOptionEntry options[] = {
{ "geometry", 'g', 0, G_OPTION_ARG_STRING, &geometry, N_("Create the initial window with the given geometry."), N_("GEOMETRY")},
- { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &args_remaining, NULL, N_("FILES") },
+ { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &args_remaining, NULL, N_("FILES|URIs") },
{ NULL }
};
@@ -92,26 +92,27 @@ main (int argc, char **argv)
gtk_widget_show_all (main_window);
- if (argc > 1) {
- i = 1;
- while (argv[i]) {
- if (g_str_has_prefix (argv[i], "file:")) {
+ if (args_remaining != NULL) {
+ for (i = 0; args_remaining[i]; i++) {
+ gchar *scheme = g_uri_parse_scheme(args_remaining[i]);
+ if (scheme != NULL) {
planner_window_open_in_existing_or_new (
- PLANNER_WINDOW (main_window), argv[i], FALSE);
+ PLANNER_WINDOW (main_window), args_remaining[i], FALSE);
+ g_free(scheme);
} else {
gchar *uri;
- if (!g_path_is_absolute (argv[i])) {
+ if (!g_path_is_absolute (args_remaining[i])) {
/* Relative path. */
gchar *cwd, *tmp;
cwd = g_get_current_dir ();
- tmp = g_build_filename (cwd, argv[i], NULL);
+ tmp = g_build_filename (cwd, args_remaining[i], NULL);
uri = g_filename_to_uri (tmp, NULL, NULL);
g_free (tmp);
g_free (cwd);
} else {
- uri = g_filename_to_uri (argv[i], NULL, NULL);
+ uri = g_filename_to_uri (args_remaining[i], NULL, NULL);
}
if (uri) {
@@ -120,8 +121,6 @@ main (int argc, char **argv)
g_free (uri);
}
}
-
- i++;
}
}
diff --git a/src/planner-window.c b/src/planner-window.c
index 73f1766..b0536c3 100644
--- a/src/planner-window.c
+++ b/src/planner-window.c
@@ -1726,36 +1726,24 @@ planner_window_open_in_existing_or_new (PlannerWindow *window,
{
PlannerWindowPriv *priv;
GtkWidget *new_window;
- gchar *filename;
gboolean ret;
priv = window->priv;
-
- filename = g_filename_from_uri (uri, NULL, NULL);
- if (!filename) {
- return FALSE;
- }
-
if (mrp_project_is_empty (priv->project)) {
- ret = planner_window_open (window, filename, internal);
- g_free (filename);
+ ret = planner_window_open (window, uri, internal);
return ret;
} else {
new_window = planner_application_new_window (priv->application);
- if (planner_window_open (PLANNER_WINDOW (new_window), filename, internal)) {
- g_free (filename);
+ if (planner_window_open (PLANNER_WINDOW (new_window), uri, internal)) {
gtk_widget_show_all (new_window);
return TRUE;
} else {
- g_free (filename);
g_signal_emit (new_window, signals[CLOSED], 0, NULL);
gtk_widget_destroy (new_window);
return FALSE;
}
}
- g_free (filename);
-
return FALSE;
}
--
cgit v0.9.2
|