[evolution-patches] vfolder sources uri decoding, #41398
- From: Not Zed <notzed ximian com>
- To: evolution-patches ximian com
- Subject: [evolution-patches] vfolder sources uri decoding, #41398
- Date: 18 Apr 2003 13:46:44 +0930
Bit of a hack to try to make sense of a uri and present it to the user
in a reasonable format rather than in raw url-encoded format.
people dont want url's, but you need to contain all of the info this
patch does otherwise the dialog is too hard to follow. it also has to
be able to list folders which aren't currently available (e..g in
offline mode/or it hasn't connected yet).
Index: filter/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/filter/ChangeLog,v
retrieving revision 1.364
diff -u -3 -r1.364 ChangeLog
--- filter/ChangeLog 11 Apr 2003 20:09:26 -0000 1.364
+++ filter/ChangeLog 18 Apr 2003 02:58:21 -0000
@@ -1,3 +1,17 @@
+2003-04-18 Not Zed <NotZed Ximian com>
+
+ * rule-editor.c (d): removed debug spew.
+
+ * addresses #41398
+
+ * vfolder-rule.c (format_source): helper function to decode a url
+ into a more user-friendly format.
+ (source_add, get_widget): add the formatted data as another
+ column to the table.
+ (vfolder_editor_sourcelist_new): add another column to the table,
+ a formatted uri as well as the raw one.
+ (d): turned off debug vomit while i'm here.
+
2003-04-11 Jeffrey Stedfast <fejj ximian com>
Fixes for bugs: #41149, #41150, #41151, #41152, #41153, #41155,
Index: filter/rule-editor.c
===================================================================
RCS file: /cvs/gnome/evolution/filter/rule-editor.c,v
retrieving revision 1.52
diff -u -3 -r1.52 rule-editor.c
--- filter/rule-editor.c 11 Apr 2003 19:11:50 -0000 1.52
+++ filter/rule-editor.c 18 Apr 2003 02:58:23 -0000
@@ -37,7 +37,7 @@
void rule_editor_add_undo (RuleEditor *re, int type, FilterRule *rule, int rank, int newrank);
void rule_editor_play_undo (RuleEditor *re);
-#define d(x) x
+#define d(x)
static void set_source (RuleEditor *re, const char *source);
static void set_sensitive (RuleEditor *re);
Index: filter/vfolder-rule.c
===================================================================
RCS file: /cvs/gnome/evolution/filter/vfolder-rule.c,v
retrieving revision 1.35
diff -u -3 -r1.35 vfolder-rule.c
--- filter/vfolder-rule.c 17 Mar 2003 21:44:44 -0000 1.35
+++ filter/vfolder-rule.c 18 Apr 2003 02:58:24 -0000
@@ -31,11 +31,12 @@
#include <glade/glade.h>
#include <libgnome/gnome-i18n.h>
+#include "camel/camel-url.h"
#include "vfolder-context.h"
#include "vfolder-rule.h"
#include "shell/evolution-shell-client.h"
-#define d(x) x
+#define d(x)
static int validate(FilterRule *);
static int vfolder_eq(FilterRule *fr, FilterRule *cm);
@@ -391,6 +392,35 @@
filter_rule_set_source ((FilterRule *) data->vr, source);
}
+/* attempt to make a 'nice' folder name out of the raw uri */
+static char *format_source(const char *uri)
+{
+ CamelURL *url = camel_url_new(uri, NULL);
+ GString *out;
+ char *res;
+
+ /* bad uri */
+ if (url == NULL)
+ return g_strdup(uri);
+
+ out = g_string_new(url->protocol);
+ g_string_append_c(out, ':');
+ if (url->user && url->host) {
+ g_string_append_printf(out, "%s %s", url->user, url->host);
+ if (url->port)
+ g_string_append_printf(out, ":%d", url->port);
+ }
+ if (url->fragment)
+ g_string_append(out, url->fragment);
+ else if (url->path)
+ g_string_append(out, url->path);
+
+ res = out->str;
+ g_string_free(out, FALSE);
+
+ return res;
+}
+
static void
source_add (GtkWidget *widget, struct _source_data *data)
{
@@ -399,7 +429,7 @@
GtkTreeSelection *selection;
GtkWidget *window;
GtkTreeIter iter;
- char *uri;
+ char *uri, *urinice;
window = gtk_widget_get_toplevel (widget);
gtk_widget_set_sensitive (window, FALSE);
@@ -414,7 +444,9 @@
data->vr->sources = g_list_append (data->vr->sources, uri);
gtk_list_store_append (data->model, &iter);
- gtk_list_store_set (data->model, &iter, 0, uri, -1);
+ urinice = format_source(uri);
+ gtk_list_store_set (data->model, &iter, 0, urinice, 1, uri, -1);
+ g_free(urinice);
selection = gtk_tree_view_get_selection (data->list);
gtk_tree_selection_select_iter (selection, &iter);
data->current = uri;
@@ -490,7 +522,7 @@
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- model = gtk_list_store_new (1, G_TYPE_STRING);
+ model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
table = gtk_tree_view_new_with_model ((GtkTreeModel *) model);
gtk_tree_view_set_headers_visible ((GtkTreeView *) table, FALSE);
@@ -557,8 +589,11 @@
source = NULL;
while ((source = vfolder_rule_next_source (vr, source))) {
+ char *nice = format_source(source);
+
gtk_list_store_append (data->model, &iter);
- gtk_list_store_set (data->model, &iter, 0, source, -1);
+ gtk_list_store_set (data->model, &iter, 0, nice, 1, source, -1);
+ g_free(nice);
}
g_signal_connect (data->list, "cursor-changed", G_CALLBACK (select_source), data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]