aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-08-31 11:26:15 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-08-31 11:26:15 +0800
commit674a09b0f31fb2a0216ceb67e17718ce93fdc5fc (patch)
tree61dec7495992d73029a2fcb8a5938107107eb2bc /mail
parentf7d31c11f5c3fbd42e0a172e34a1bc8d28e7a44e (diff)
downloadgsoc2013-evolution-674a09b0f31fb2a0216ceb67e17718ce93fdc5fc.tar
gsoc2013-evolution-674a09b0f31fb2a0216ceb67e17718ce93fdc5fc.tar.gz
gsoc2013-evolution-674a09b0f31fb2a0216ceb67e17718ce93fdc5fc.tar.bz2
gsoc2013-evolution-674a09b0f31fb2a0216ceb67e17718ce93fdc5fc.tar.lz
gsoc2013-evolution-674a09b0f31fb2a0216ceb67e17718ce93fdc5fc.tar.xz
gsoc2013-evolution-674a09b0f31fb2a0216ceb67e17718ce93fdc5fc.tar.zst
gsoc2013-evolution-674a09b0f31fb2a0216ceb67e17718ce93fdc5fc.zip
** See bug #64377.
2004-08-30 Not Zed <NotZed@Ximian.com> ** See bug #64377. * em-folder-selector.c (emfs_response): only set the uri if we have one to set. * em-folder-tree.c (em_folder_tree_finalize): Removed cose using selected_path and selected_uri strings. (emft_popup_new_folder): " (emft_popup_copy_folder_selected): " (emft_tree_selection_changed): (emft_tree_row_activated): ", free paths after use. * em-folder-selector.c (emfs_create_name_changed): free get_selected_uri return. (emfs_create_name_activate): " (em_folder_selector_get_selected_path): handle api change, store the selected_path too. * em-folder-tree.c (em_folder_tree_get_selected_uri): de-constify,and get the selection directly from the tree. (em_folder_tree_get_selected_path): same. svn path=/trunk/; revision=27092
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog24
-rw-r--r--mail/em-folder-selector.c35
-rw-r--r--mail/em-folder-tree.c75
-rw-r--r--mail/em-folder-tree.h4
4 files changed, 90 insertions, 48 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index d73bcf8895..c17a8b3fa5 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,27 @@
+2004-08-30 Not Zed <NotZed@Ximian.com>
+
+ ** See bug #64377.
+
+ * em-folder-selector.c (emfs_response): only set the uri if we
+ have one to set.
+
+ * em-folder-tree.c (em_folder_tree_finalize): Removed
+ cose using selected_path and selected_uri strings.
+ (emft_popup_new_folder): "
+ (emft_popup_copy_folder_selected): "
+ (emft_tree_selection_changed):
+ (emft_tree_row_activated): ", free paths after use.
+
+ * em-folder-selector.c (emfs_create_name_changed): free
+ get_selected_uri return.
+ (emfs_create_name_activate): "
+ (em_folder_selector_get_selected_path): handle api change, store
+ the selected_path too.
+
+ * em-folder-tree.c (em_folder_tree_get_selected_uri):
+ de-constify,and get the selection directly from the tree.
+ (em_folder_tree_get_selected_path): same.
+
2004-08-27 Not Zed <NotZed@Ximian.com>
** See bug #63456.
diff --git a/mail/em-folder-selector.c b/mail/em-folder-selector.c
index d5aecd9667..7df4d50e9f 100644
--- a/mail/em-folder-selector.c
+++ b/mail/em-folder-selector.c
@@ -166,7 +166,8 @@ emfs_response (GtkWidget *dialog, int response, EMFolderSelector *emfs)
dialog = em_folder_selector_create_new (emft, 0, _("Create New Folder"), _("Specify where to create the folder:"));
gtk_window_set_transient_for ((GtkWindow *) dialog, (GtkWindow *) emfs);
uri = em_folder_selector_get_selected_uri (emfs);
- em_folder_tree_set_selected (emft, uri);
+ if (uri)
+ em_folder_tree_set_selected (emft, uri);
if (gtk_dialog_run ((GtkDialog *) dialog) == GTK_RESPONSE_OK) {
uri = em_folder_selector_get_selected_uri ((EMFolderSelector *) dialog);
@@ -189,16 +190,17 @@ emfs_response (GtkWidget *dialog, int response, EMFolderSelector *emfs)
static void
emfs_create_name_changed (GtkEntry *entry, EMFolderSelector *emfs)
{
- const char *path, *text = NULL;
+ char *path;
+ const char *text = NULL;
gboolean active;
if (emfs->name_entry->text_length > 0)
text = gtk_entry_get_text (emfs->name_entry);
path = em_folder_tree_get_selected_uri(emfs->emft);
-
active = text && path && !strchr (text, '/');
-
+ g_free(path);
+
gtk_dialog_set_response_sensitive ((GtkDialog *) emfs, GTK_RESPONSE_OK, active);
}
@@ -276,13 +278,15 @@ static void
emfs_create_name_activate (GtkEntry *entry, EMFolderSelector *emfs)
{
if (emfs->name_entry->text_length > 0) {
- const char *path, *text;
+ char *path;
+ const char *text;
text = gtk_entry_get_text (emfs->name_entry);
path = em_folder_tree_get_selected_uri(emfs->emft);
if (text && path && !strchr (text, '/'))
g_signal_emit_by_name (emfs, "response", GTK_RESPONSE_OK);
+ g_free(path);
}
}
@@ -333,7 +337,8 @@ em_folder_selector_set_selected_list (EMFolderSelector *emfs, GList *list)
const char *
em_folder_selector_get_selected_uri (EMFolderSelector *emfs)
{
- const char *uri, *name;
+ char *uri;
+ const char *name;
if (!(uri = em_folder_tree_get_selected_uri (emfs->emft))) {
d(printf ("no selected folder?\n"));
@@ -397,32 +402,36 @@ em_folder_selector_get_selected_paths (EMFolderSelector *emfs)
const char *
em_folder_selector_get_selected_path (EMFolderSelector *emfs)
{
- const char *path;
+ char *uri, *path;
if (emfs->selected_path) {
/* already did the work in a previous call */
return emfs->selected_path;
}
- if (!em_folder_tree_get_selected_uri(emfs->emft)) {
+ if ((uri = em_folder_tree_get_selected_uri(emfs->emft)) == NULL) {
d(printf ("no selected folder?\n"));
return NULL;
}
+ g_free(uri);
path = em_folder_tree_get_selected_path(emfs->emft);
- path = path?path:"";
if (emfs->name_entry) {
const char *name;
char *newpath;
name = gtk_entry_get_text (emfs->name_entry);
if (strcmp (path, "") != 0)
- newpath = g_strdup_printf ("%s/%s", path, name);
+ newpath = g_strdup_printf ("%s/%s", path?path:"", name);
else
newpath = g_strdup (name);
- path = emfs->selected_path = newpath;
+ g_free(path);
+ emfs->selected_path = newpath;
+ } else {
+ g_free(emfs->selected_path);
+ emfs->selected_path = path?path:g_strdup("");
}
-
- return path;
+
+ return emfs->selected_path;
}
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index bd5ea3a369..ae14a2b40c 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -86,9 +86,6 @@ struct _EMFolderTreePrivate {
GSList *select_uris; /* selected_uri structures of each path pending selection. */
GHashTable *select_uris_table; /*Removed as they're encountered, so use this to find uri's not presnet but selected */
- char *selected_uri;
- char *selected_path;
-
guint32 excluded;
int do_multiselect:1; /* multiple select mode */
@@ -378,8 +375,6 @@ em_folder_tree_init (EMFolderTree *emft)
priv = g_new0 (struct _EMFolderTreePrivate, 1);
priv->select_uris_table = g_hash_table_new(g_str_hash, g_str_equal);
- priv->selected_uri = NULL;
- priv->selected_path = NULL;
priv->treeview = NULL;
priv->model = NULL;
priv->drag_row = NULL;
@@ -399,8 +394,6 @@ em_folder_tree_finalize (GObject *obj)
emft->priv->select_uris = NULL;
}
- g_free (emft->priv->selected_uri);
- g_free (emft->priv->selected_path);
g_free (emft->priv);
G_OBJECT_CLASS (parent_class)->finalize (obj);
@@ -1933,14 +1926,11 @@ emft_tree_row_activated (GtkTreeView *treeview, GtkTreePath *tree_path, GtkTreeV
emft_clear_selected_list(emft);
- g_free (priv->selected_uri);
- priv->selected_uri = uri;
-
- g_free (priv->selected_path);
- priv->selected_path = full_name;
-
g_signal_emit (emft, signals[FOLDER_SELECTED], 0, full_name, uri, flags);
g_signal_emit (emft, signals[FOLDER_ACTIVATED], 0, full_name, uri);
+
+ g_free(full_name);
+ g_free(uri);
}
#if 0
@@ -2141,7 +2131,7 @@ emft_popup_copy_folder_selected (const char *uri, void *data)
struct _copy_folder_data *cfd = data;
struct _EMFolderTreePrivate *priv;
CamelStore *fromstore = NULL, *tostore = NULL;
- char *tobase = NULL, *frombase;
+ char *tobase = NULL, *frombase = NULL, *fromuri = NULL;
CamelException ex;
CamelURL *url;
@@ -2155,9 +2145,13 @@ emft_popup_copy_folder_selected (const char *uri, void *data)
d(printf ("%sing folder '%s' to '%s'\n", cfd->delete ? "move" : "copy", priv->selected_path, uri));
camel_exception_init (&ex);
- frombase = priv->selected_path;
-
- if (!(fromstore = camel_session_get_store (session, priv->selected_uri, &ex))) {
+
+ fromuri = em_folder_tree_get_selected_uri(cfd->emft);
+ g_return_if_fail(fromuri != NULL);
+ frombase = em_folder_tree_get_selected_path(cfd->emft);
+ g_return_if_fail(frombase != NULL);
+
+ if (!(fromstore = camel_session_get_store (session, fromuri, &ex))) {
e_error_run((GtkWindow *)gtk_widget_get_toplevel((GtkWidget *) cfd->emft),
cfd->delete?"mail:no-move-folder-notexist":"mail:no-copy-folder-notexist", frombase, uri, ex.desc, NULL);
goto fail;
@@ -2191,6 +2185,8 @@ fail:
camel_object_unref(fromstore);
if (tostore)
camel_object_unref(tostore);
+ g_free(frombase);
+ g_free(fromuri);
camel_exception_clear (&ex);
g_free (cfd);
}
@@ -2427,11 +2423,14 @@ emft_popup_new_folder (GtkWidget *item, EMFolderTree *emft)
{
EMFolderTree *folder_tree;
GtkWidget *dialog;
-
+ char *uri;
+
folder_tree = (EMFolderTree *) em_folder_tree_new_with_model (emft->priv->model);
dialog = em_folder_selector_create_new (folder_tree, 0, _("Create folder"), _("Specify where to create the folder:"));
- em_folder_selector_set_selected ((EMFolderSelector *) dialog, emft->priv->selected_uri);
+ uri = em_folder_tree_get_selected_uri(emft);
+ em_folder_selector_set_selected ((EMFolderSelector *) dialog, uri);
+ g_free(uri);
g_signal_connect (dialog, "response", G_CALLBACK (emft_popup_new_folder_response), emft);
gtk_widget_show (dialog);
}
@@ -2840,7 +2839,6 @@ emft_tree_user_event (GtkTreeView *treeview, GdkEvent *e, EMFolderTree *emft)
static void
emft_tree_selection_changed (GtkTreeSelection *selection, EMFolderTree *emft)
{
- struct _EMFolderTreePrivate *priv = emft->priv;
char *full_name, *uri;
GtkTreeModel *model;
GtkTreeIter iter;
@@ -2852,16 +2850,11 @@ emft_tree_selection_changed (GtkTreeSelection *selection, EMFolderTree *emft)
gtk_tree_model_get (model, &iter, COL_STRING_FULL_NAME, &full_name,
COL_STRING_URI, &uri, COL_UINT_FLAGS, &flags, -1);
- g_free (priv->selected_uri);
- priv->selected_uri = uri;
-
- g_free (priv->selected_path);
- priv->selected_path = full_name;
-
g_signal_emit (emft, signals[FOLDER_SELECTED], 0, full_name, uri, flags);
+ g_free(uri);
+ g_free(full_name);
}
-
void
em_folder_tree_set_selected (EMFolderTree *emft, const char *uri)
{
@@ -2873,24 +2866,40 @@ em_folder_tree_set_selected (EMFolderTree *emft, const char *uri)
g_list_free(l);
}
-const char *
+char *
em_folder_tree_get_selected_uri (EMFolderTree *emft)
{
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ char *uri = NULL;
+
g_return_val_if_fail (EM_IS_FOLDER_TREE (emft), NULL);
+
+ selection = gtk_tree_view_get_selection(emft->priv->treeview);
+ if (gtk_tree_selection_get_selected(selection, &model, &iter))
+ gtk_tree_model_get(model, &iter, COL_STRING_URI, &uri, -1);
- return emft->priv->selected_uri;
+ return uri;
}
-
-const char *
+char *
em_folder_tree_get_selected_path (EMFolderTree *emft)
{
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ char *name = NULL;
+
g_return_val_if_fail (EM_IS_FOLDER_TREE (emft), NULL);
+
+ selection = gtk_tree_view_get_selection(emft->priv->treeview);
+ if (gtk_tree_selection_get_selected(selection, &model, &iter))
+ gtk_tree_model_get(model, &iter, COL_STRING_FULL_NAME, &name, -1);
- return emft->priv->selected_path;
+ return name;
}
-
EMFolderTreeModel *
em_folder_tree_get_model (EMFolderTree *emft)
{
diff --git a/mail/em-folder-tree.h b/mail/em-folder-tree.h
index 9b97ec0e9b..8ce1ad5873 100644
--- a/mail/em-folder-tree.h
+++ b/mail/em-folder-tree.h
@@ -80,8 +80,8 @@ GList *em_folder_tree_get_selected_uris (EMFolderTree *emft);
GList *em_folder_tree_get_selected_paths (EMFolderTree *emft);
void em_folder_tree_set_selected (EMFolderTree *emft, const char *uri);
-const char *em_folder_tree_get_selected_uri (EMFolderTree *emft);
-const char *em_folder_tree_get_selected_path (EMFolderTree *emft);
+char *em_folder_tree_get_selected_uri (EMFolderTree *emft);
+char *em_folder_tree_get_selected_path (EMFolderTree *emft);
EMFolderTreeModel *em_folder_tree_get_model (EMFolderTree *emft);