[Xfce4-commits] <gigolo:master> Implement basic version of path component for WebDav URIs. Not really tested yet.
Enrico Tröger
noreply at xfce.org
Wed Nov 18 00:34:01 CET 2009
Updating branch refs/heads/master
to e90eb6ce2734df9217cd266b1b4578dea6b98d6d (commit)
from 40c55694b2fb0c17f6457075a8a4a50c97da9bf8 (commit)
commit e90eb6ce2734df9217cd266b1b4578dea6b98d6d
Author: Enrico Tröger <enrico at xfce.org>
Date: Wed Nov 18 00:33:22 2009 +0100
Implement basic version of path component for WebDav URIs. Not really tested yet.
src/bookmark.c | 31 ++++++++++++++++++++++++++++++-
src/bookmark.h | 3 +++
src/bookmarkdialog.c | 6 ++++++
src/bookmarkeditdialog.c | 40 +++++++++++++++++++++++++++++++++++++---
src/settings.c | 7 ++++++-
5 files changed, 82 insertions(+), 5 deletions(-)
diff --git a/src/bookmark.c b/src/bookmark.c
index dd83551..5ea06dd 100644
--- a/src/bookmark.c
+++ b/src/bookmark.c
@@ -38,6 +38,7 @@ struct _GigoloBookmarkPrivate
gchar *scheme;
gchar *host;
gchar *folder;
+ gchar *path;
gchar *domain;
gchar *share;
guint port;
@@ -61,6 +62,7 @@ void gigolo_bookmark_bookmark_clear(GigoloBookmark *bookmark)
g_free(priv->scheme);
g_free(priv->host);
g_free(priv->folder);
+ g_free(priv->path);
g_free(priv->domain);
g_free(priv->share);
g_free(priv->user);
@@ -70,6 +72,7 @@ void gigolo_bookmark_bookmark_clear(GigoloBookmark *bookmark)
priv->host = NULL;
priv->port = 0;
priv->domain = NULL;
+ priv->path = NULL;
priv->folder = NULL;
priv->share = NULL;
priv->user = NULL;
@@ -211,6 +214,7 @@ gboolean gigolo_bookmark_parse_uri(GigoloBookmark *bookmark, const gchar *uri)
priv->port = (guint) atoi(tmp);
g_free(tmp);
}
+ /* TODO handle WebDav path parts */
if (NZV(end) && *end == '/' && gigolo_str_equal("smb", priv->scheme))
{
end++; /* skip the slash */
@@ -275,6 +279,7 @@ void gigolo_bookmark_clone(GigoloBookmark *dst, const GigoloBookmark *src)
priv_dst->scheme = g_strdup(priv_src->scheme);
priv_dst->domain = g_strdup(priv_src->domain);
priv_dst->folder = g_strdup(priv_src->folder);
+ priv_dst->path = g_strdup(priv_src->path);
priv_dst->share = g_strdup(priv_src->share);
priv_dst->user = g_strdup(priv_src->user);
priv_dst->port = priv_src->port;
@@ -304,7 +309,7 @@ static gchar *gigolo_bookmark_get_uri_real(GigoloBookmark *bookmark, gboolean es
domain = gigolo_bookmark_get_domain(bookmark);
- result = g_strdup_printf("%s://%s%s%s%s%s%s/%s%s",
+ result = g_strdup_printf("%s://%s%s%s%s%s%s/%s%s%s%s",
priv->scheme,
(NZV(domain)) ? domain : "",
(NZV(domain)) ? ";" : "",
@@ -312,6 +317,8 @@ static gchar *gigolo_bookmark_get_uri_real(GigoloBookmark *bookmark, gboolean es
(NZV(user) || NZV(domain)) ? "@" : "",
priv->host,
(port) ? port : "",
+ (NZV(priv->path)) ? priv->path : "",
+ (NZV(priv->path)) ? "/" : "",
(NZV(priv->share)) ? priv->share : "",
(NZV(priv->share)) ? "/" : "");
@@ -437,6 +444,28 @@ void gigolo_bookmark_set_folder(GigoloBookmark *bookmark, const gchar *folder)
}
+const gchar *gigolo_bookmark_get_path(GigoloBookmark *bookmark)
+{
+ g_return_val_if_fail(bookmark != NULL, NULL);
+
+ return GIGOLO_BOOKMARK_GET_PRIVATE(bookmark)->path;
+}
+
+
+void gigolo_bookmark_set_path(GigoloBookmark *bookmark, const gchar *path)
+{
+ GigoloBookmarkPrivate *priv;
+
+ g_return_if_fail(bookmark != NULL);
+ g_return_if_fail(path != NULL);
+
+ priv = GIGOLO_BOOKMARK_GET_PRIVATE(bookmark);
+
+ g_free(priv->path);
+ priv->path = g_strdup(path);
+}
+
+
guint gigolo_bookmark_get_port(GigoloBookmark *bookmark)
{
g_return_val_if_fail(bookmark != NULL, 0);
diff --git a/src/bookmark.h b/src/bookmark.h
index 569b685..07453cd 100644
--- a/src/bookmark.h
+++ b/src/bookmark.h
@@ -68,6 +68,9 @@ void gigolo_bookmark_set_host (GigoloBookmark *bookmark, const gchar *host);
const gchar* gigolo_bookmark_get_folder (GigoloBookmark *bookmark);
void gigolo_bookmark_set_folder (GigoloBookmark *bookmark, const gchar *folder);
+const gchar* gigolo_bookmark_get_path (GigoloBookmark *bookmark);
+void gigolo_bookmark_set_path (GigoloBookmark *bookmark, const gchar *path);
+
guint gigolo_bookmark_get_port (GigoloBookmark *bookmark);
void gigolo_bookmark_set_port (GigoloBookmark *bookmark, guint port);
diff --git a/src/bookmarkdialog.c b/src/bookmarkdialog.c
index 647927e..0d45951 100644
--- a/src/bookmarkdialog.c
+++ b/src/bookmarkdialog.c
@@ -104,6 +104,12 @@ static void update_row_in_model(GigoloBookmarkDialog *dialog, GtkTreeIter *iter,
g_string_append(other_text, ", ");
g_string_append_printf(other_text, _("Folder: %s"), tmp);
}
+ if (NZV(tmp = gigolo_bookmark_get_path(bm)))
+ {
+ if (other_text->len > 0)
+ g_string_append(other_text, ", ");
+ g_string_append_printf(other_text, _("Path: %s"), tmp);
+ }
gtk_list_store_set(priv->store, iter,
COL_NAME, gigolo_bookmark_get_name(bm),
diff --git a/src/bookmarkeditdialog.c b/src/bookmarkeditdialog.c
index 062918d..ded22b1 100644
--- a/src/bookmarkeditdialog.c
+++ b/src/bookmarkeditdialog.c
@@ -65,6 +65,9 @@ struct _GigoloBookmarkEditDialogPrivate
GtkWidget *folder_label;
GtkWidget *folder_entry;
+ GtkWidget *path_label;
+ GtkWidget *path_entry;
+
GtkWidget *port_label;
GtkWidget *port_spin;
@@ -114,7 +117,8 @@ enum {
SHOW_USER = 0x00000040,
SHOW_DOMAIN = 0x00000080,
SHOW_DEVICE = 0x00000100,
- SHOW_FOLDER = 0x00000200
+ SHOW_FOLDER = 0x00000200,
+ SHOW_PATH = 0x00000400
};
enum {
@@ -138,8 +142,8 @@ static struct MethodInfo methods[] = {
{ "ftp", 21, SHOW_PORT | SHOW_USER | SHOW_FOLDER },
{ "sftp", 22, SHOW_PORT | SHOW_USER | SHOW_FOLDER },
{ "smb", 0, SHOW_SHARE | SHOW_USER | SHOW_DOMAIN | SHOW_FOLDER },
- { "dav", 80, SHOW_PORT | SHOW_USER | SHOW_FOLDER },
- { "davs", 443, SHOW_PORT | SHOW_USER | SHOW_FOLDER },
+ { "dav", 80, SHOW_PATH | SHOW_PORT | SHOW_USER | SHOW_FOLDER },
+ { "davs", 443, SHOW_PATH | SHOW_PORT | SHOW_USER | SHOW_FOLDER },
{ "obex", 0, SHOW_DEVICE },
{ NULL, 0, 0 }
};
@@ -426,6 +430,10 @@ static void init_values(GigoloBookmarkEditDialog *dialog)
tmp = gigolo_bookmark_get_domain(priv->bookmark_init);
if (tmp != NULL)
gtk_entry_set_text(GTK_ENTRY(priv->domain_entry), tmp);
+ /* Path */
+ tmp = gigolo_bookmark_get_path(priv->bookmark_init);
+ if (tmp != NULL)
+ gtk_entry_set_text(GTK_ENTRY(priv->path_entry), tmp);
/* Port */
port = gigolo_bookmark_get_port(priv->bookmark_init);
@@ -490,6 +498,11 @@ static void setup_for_type(GigoloBookmarkEditDialog *dialog)
gtk_container_remove(GTK_CONTAINER(priv->table), priv->domain_label);
gtk_container_remove(GTK_CONTAINER(priv->table), priv->domain_entry);
}
+ if (gtk_widget_get_parent(priv->path_entry) != NULL)
+ {
+ gtk_container_remove(GTK_CONTAINER(priv->table), priv->path_label);
+ gtk_container_remove(GTK_CONTAINER(priv->table), priv->path_entry);
+ }
if (gtk_widget_get_parent(priv->share_combo) != NULL)
{
gtk_container_remove(GTK_CONTAINER(priv->table), priv->share_label);
@@ -555,6 +568,20 @@ static void setup_for_type(GigoloBookmarkEditDialog *dialog)
i++;
}
+ if (meth->flags & SHOW_PATH)
+ {
+ gtk_misc_set_alignment(GTK_MISC(priv->path_label), 0.0, 0.5);
+ gtk_widget_show(priv->path_label);
+ gtk_table_attach(GTK_TABLE(table), priv->path_label,
+ 0, 1, i, i+1, GTK_FILL, GTK_FILL, 0, 0);
+
+ gtk_label_set_mnemonic_widget(GTK_LABEL(priv->path_label), priv->path_entry);
+ gtk_widget_show(priv->path_entry);
+ gtk_table_attach(GTK_TABLE(table), priv->path_entry,
+ 1, 2, i, i+1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+
+ i++;
+ }
}
if (meth->flags & (SHOW_PORT | SHOW_DOMAIN | SHOW_USER))
@@ -755,6 +782,8 @@ static void update_bookmark(GigoloBookmarkEditDialog *dialog)
gigolo_bookmark_set_folder(priv->bookmark_update, tmp);
tmp = gtk_entry_get_text(GTK_ENTRY(priv->user_entry));
gigolo_bookmark_set_user(priv->bookmark_update, tmp);
+ tmp = gtk_entry_get_text(GTK_ENTRY(priv->path_entry));
+ gigolo_bookmark_set_path(priv->bookmark_update, tmp);
tmp = gtk_entry_get_text(GTK_ENTRY(priv->domain_entry));
gigolo_bookmark_set_domain(priv->bookmark_update, tmp);
tmp = gtk_entry_get_text(GTK_ENTRY(priv->share_entry));
@@ -952,6 +981,7 @@ static void gigolo_bookmark_edit_dialog_init(GigoloBookmarkEditDialog *dialog)
priv->uri_entry = gtk_entry_new();
priv->host_entry = gtk_entry_new();
priv->folder_entry = gtk_entry_new();
+ priv->path_entry = gtk_entry_new();
priv->port_spin = gtk_spin_button_new_with_range(0, 65535, 1);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(priv->port_spin), 0.0);
gtk_widget_set_tooltip_text(priv->port_spin, _("Set the port to 0 to use the default port"));
@@ -963,6 +993,7 @@ static void gigolo_bookmark_edit_dialog_init(GigoloBookmarkEditDialog *dialog)
priv->uri_label = gtk_label_new_with_mnemonic(_("_Location (URI):"));
priv->host_label = gtk_label_new_with_mnemonic(_("_Server:"));
priv->folder_label = gtk_label_new_with_mnemonic(_("_Folder:"));
+ priv->path_label = gtk_label_new_with_mnemonic(_("_Path:"));
priv->user_label = gtk_label_new_with_mnemonic(_("_User Name:"));
priv->information_label = gtk_label_new(_("Optional information:"));
priv->port_label = gtk_label_new_with_mnemonic(_("_Port:"));
@@ -972,6 +1003,7 @@ static void gigolo_bookmark_edit_dialog_init(GigoloBookmarkEditDialog *dialog)
gtk_entry_set_activates_default(GTK_ENTRY(priv->name_entry), TRUE);
gtk_entry_set_activates_default(GTK_ENTRY(priv->uri_entry), TRUE);
gtk_entry_set_activates_default(GTK_ENTRY(priv->folder_entry), TRUE);
+ gtk_entry_set_activates_default(GTK_ENTRY(priv->path_entry), TRUE);
gtk_entry_set_activates_default(GTK_ENTRY(priv->host_entry), TRUE);
gtk_entry_set_activates_default(GTK_ENTRY(priv->port_spin), TRUE);
gtk_entry_set_activates_default(GTK_ENTRY(priv->user_entry), TRUE);
@@ -992,6 +1024,8 @@ static void gigolo_bookmark_edit_dialog_init(GigoloBookmarkEditDialog *dialog)
g_object_ref(priv->host_label);
g_object_ref(priv->folder_entry);
g_object_ref(priv->folder_label);
+ g_object_ref(priv->path_entry);
+ g_object_ref(priv->path_label);
g_object_ref(priv->port_label);
g_object_ref(priv->port_spin);
g_object_ref(priv->user_entry);
diff --git a/src/settings.c b/src/settings.c
index 01d0048..9ab8941 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -463,6 +463,7 @@ static void write_settings_bookmarks(GigoloSettings *settings)
set_setting_string(k, name, "scheme", gigolo_bookmark_get_scheme(bm));
set_setting_string(k, name, "share", gigolo_bookmark_get_share(bm));
set_setting_string(k, name, "domain", gigolo_bookmark_get_domain(bm));
+ set_setting_string(k, name, "path", gigolo_bookmark_get_path(bm));
set_setting_int(k, name, "port", gigolo_bookmark_get_port(bm));
set_setting_int(k, name, "autoconnect", gigolo_bookmark_get_autoconnect(bm));
}
@@ -571,7 +572,7 @@ static void load_settings_read_bookmarks(GigoloSettingsPrivate *priv)
GError *error = NULL;
gsize len, i;
gchar **groups;
- gchar *scheme, *host, *user, *domain, *share, *folder;
+ gchar *scheme, *host, *user, *domain, *share, *folder, *path;
gint port;
gboolean autoconnect;
GigoloBookmark *bm;
@@ -591,6 +592,7 @@ static void load_settings_read_bookmarks(GigoloSettingsPrivate *priv)
scheme = get_setting_string(k, groups[i], "scheme", "");
host = get_setting_string(k, groups[i], "host", "");
folder = get_setting_string(k, groups[i], "folder", "");
+ path = get_setting_string(k, groups[i], "path", "");
user = get_setting_string(k, groups[i], "user", "");
domain = get_setting_string(k, groups[i], "domain", "");
share = get_setting_string(k, groups[i], "share", "");
@@ -608,6 +610,8 @@ static void load_settings_read_bookmarks(GigoloSettingsPrivate *priv)
gigolo_bookmark_set_user(bm, user);
if (NZV(domain))
gigolo_bookmark_set_domain(bm, domain);
+ if (NZV(path))
+ gigolo_bookmark_set_path(bm, path);
if (NZV(share))
gigolo_bookmark_set_share(bm, share);
gigolo_bookmark_set_port(bm, port);
@@ -618,6 +622,7 @@ static void load_settings_read_bookmarks(GigoloSettingsPrivate *priv)
g_free(scheme);
g_free(host);
g_free(folder);
+ g_free(path);
g_free(user);
g_free(domain);
g_free(share);
More information about the Xfce4-commits
mailing list