about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorStevan Andjelkovic <stevan@student.chalmers.se>2011-01-29 21:17:13 +0000
committerStevan Andjelkovic <stevan@student.chalmers.se>2011-01-29 21:17:13 +0000
commit1191b565425246fbb16d3067eff239c1a9767565 (patch)
treef0c9e5a34aacc3dcb7fa1bca3ffe7565278115cd
parentcde05359b167b7bb34db2245ac215f272d99d59b (diff)
downloadxombrero-1191b565425246fbb16d3067eff239c1a9767565.tar.gz
Fixed encoding for arguments to aliases, enabling searching for "C++",
"C#" etc, and fixed so that guess_url_type is called on all input uris.
-rw-r--r--xxxterm.c72
1 files changed, 30 insertions, 42 deletions
diff --git a/xxxterm.c b/xxxterm.c
index 19cb4b8..6221366 100644
--- a/xxxterm.c
+++ b/xxxterm.c
@@ -942,7 +942,7 @@ match_alias(char *url_in)
 {
 	struct alias		*a;
 	char			*arg;
-	char			*url_out = NULL, *search;
+	char			*url_out = NULL, *search, *enc_arg;
 
 	search = g_strdup(url_in);
 	arg = search;
@@ -957,9 +957,11 @@ match_alias(char *url_in)
 	if (a != NULL) {
 		DNPRINTF(XT_D_URL, "match_alias: matched alias %s\n",
 			a->a_name);
-		if (arg != NULL)
-			url_out = g_strdup_printf(a->a_uri, arg);
-		else
+		if (arg != NULL) {
+			enc_arg = soup_uri_encode(arg, XT_RESERVED_CHARS);
+			url_out = g_strdup_printf(a->a_uri, enc_arg);
+			g_free(enc_arg);
+		} else
 			url_out = g_strdup(a->a_uri);
 	}
 
@@ -989,6 +991,22 @@ guess_url_type(char *url_in)
 	return (url_out);
 }
 
+void
+load_uri(WebKitWebView *wv, gchar *uri)
+{
+	gchar		*newuri = NULL;
+
+	if (valid_url_type(uri)) {
+		newuri = guess_url_type(uri);
+		uri = newuri;
+	}
+
+	webkit_web_view_load_uri(wv, uri);
+
+	if (newuri)
+		g_free(newuri);
+}
+
 int
 add_alias(struct settings *s, char *line)
 {
@@ -1756,10 +1774,10 @@ paste_uri_cb(GtkClipboard *clipboard, const gchar *text, gpointer data)
 
 	switch(pap->i) {
 	case XT_PASTE_CURRENT_TAB:
-		webkit_web_view_load_uri(pap->t->wv, text);
+		load_uri(pap->t->wv, (gchar *)text);
 		break;
 	case XT_PASTE_NEW_TAB:
-		create_new_tab((char *)text, NULL, 1);
+		create_new_tab((gchar *)text, NULL, 1);
 		break;
 	}
 
@@ -3131,7 +3149,7 @@ int
 tabaction(struct tab *t, struct karg *args)
 {
 	int			rv = XT_CB_HANDLED;
-	char			*url = NULL, *newuri = NULL;
+	char			*url = NULL;
 	struct undo		*u;
 
 	DNPRINTF(XT_D_TAB, "tabaction: %p %d %d\n", t, args->i, t->focus_wv);
@@ -3164,14 +3182,7 @@ tabaction(struct tab *t, struct karg *args)
 			rv = XT_CB_PASSTHROUGH;
 			goto done;
 		}
-
-		if (valid_url_type(url)) {
-			newuri = guess_url_type(url);
-			url = newuri;
-		}
-		webkit_web_view_load_uri(t->wv, url);
-		if (newuri)
-			g_free(newuri);
+		load_uri(t->wv, url);
 		break;
 	case XT_TAB_SHOW:
 		if (show_tabs == 0) {
@@ -4056,12 +4067,7 @@ print_page(struct tab *t, struct karg *args)
 int
 go_home(struct tab *t, struct karg *args)
 {
-	char			*newuri;
-
-	newuri = guess_url_type((char *)home);
-	webkit_web_view_load_uri(t->wv, newuri);
-	free(newuri);
-
+	load_uri(t->wv, home);
 	return (0);
 }
 
@@ -4556,7 +4562,6 @@ void
 activate_uri_entry_cb(GtkWidget* entry, struct tab *t)
 {
 	const gchar		*uri = gtk_entry_get_text(GTK_ENTRY(entry));
-	char			*newuri = NULL;
 
 	DNPRINTF(XT_D_URL, "activate_uri_entry_cb: %s\n", uri);
 
@@ -4570,17 +4575,9 @@ activate_uri_entry_cb(GtkWidget* entry, struct tab *t)
 
 	/* if xxxt:// treat specially */
 	if (!parse_xtp_url(t, uri)) {
-		if (valid_url_type((char *)uri)) {
-			newuri = guess_url_type((char *)uri);
-			uri = newuri;
-		}
-
-		webkit_web_view_load_uri(t->wv, uri);
+		load_uri(t->wv, (gchar *)uri);
 		gtk_widget_grab_focus(GTK_WIDGET(t->wv));
 	}
-
-	if (newuri)
-		g_free(newuri);
 }
 
 void
@@ -5926,7 +5923,6 @@ create_new_tab(char *title, struct undo *u, int focus)
 {
 	struct tab			*t, *tt;
 	int				load = 1, id, notfound;
-	char				*newuri = NULL;
 	GtkWidget			*b, *bb;
 	WebKitWebHistoryItem		*item;
 	GList				*items;
@@ -5944,11 +5940,6 @@ create_new_tab(char *title, struct undo *u, int focus)
 	if (title == NULL) {
 		title = "(untitled)";
 		load = 0;
-	} else {
-		if (valid_url_type(title)) {
-			newuri = guess_url_type(title);
-			title = newuri;
-		}
 	}
 
 	t->vbox = gtk_vbox_new(FALSE, 0);
@@ -6082,7 +6073,7 @@ create_new_tab(char *title, struct undo *u, int focus)
 	}
 
 	if (load)
-		webkit_web_view_load_uri(t->wv, title);
+		load_uri(t->wv, title);
 	else {
 		if (show_url == 1)
 			gtk_widget_grab_focus(GTK_WIDGET(t->uri_entry));
@@ -6107,9 +6098,6 @@ create_new_tab(char *title, struct undo *u, int focus)
 		g_list_free(items);
 		g_list_free(u->history);
 	}
-
-	if (newuri)
-		g_free(newuri);
 }
 
 void
@@ -6265,7 +6253,7 @@ create_canvas(void)
 	gtk_widget_set_size_request(arrow, -1, -1);
 	gtk_container_add(GTK_CONTAINER(abtn), arrow);
 	gtk_widget_set_size_request(abtn, -1, 20);
-	gtk_notebook_set_action_widget(notebook, abtn, GTK_PACK_END);
+	// gtk_notebook_set_action_widget(notebook, abtn, GTK_PACK_END);
 
 	gtk_widget_set_size_request(GTK_WIDGET(notebook), -1, -1);
 	gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(notebook), TRUE, TRUE, 0);
@lavabit.com> 2010-02-16 01:56:21 +0100 committer hut <hut@lavabit.com> 2010-02-16 02:03:46 +0100 incremented version number and updated pydoc html files' href='/akspecs/ranger/commit/doc/pydoc/test.tc_keyapi.html?h=v1.7.0&id=34a60763e79546e0f84e30fbcc430632f3dbb39e'>34a60763 ^
4c13e1f2 ^





34a60763 ^
4c13e1f2 ^

34a60763 ^
4c13e1f2 ^

34a60763 ^
4c13e1f2 ^



34a60763 ^
4c13e1f2 ^
34a60763 ^
4c13e1f2 ^
34a60763 ^
4c13e1f2 ^






4c13e1f2 ^

34a60763 ^
4c13e1f2 ^
34a60763 ^





4c13e1f2 ^
34a60763 ^

4c13e1f2 ^
34a60763 ^
4c13e1f2 ^
34a60763 ^





4c13e1f2 ^
34a60763 ^

4c13e1f2 ^
34a60763 ^





4c13e1f2 ^






34a60763 ^

4c13e1f2 ^
34a60763 ^

4c13e1f2 ^












34a60763 ^
4c13e1f2 ^


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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194