aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-08-10 04:39:18 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-08-10 12:14:32 +0800
commita58ded435786d5174735b4a501878d8d30240ba1 (patch)
treedffbee6986cf54cb4074f5cd162bfd14e0171cc8 /mail
parentfe67798104f76f0a794093bddcaf9d165df50bf5 (diff)
downloadgsoc2013-evolution-a58ded435786d5174735b4a501878d8d30240ba1.tar.gz
gsoc2013-evolution-a58ded435786d5174735b4a501878d8d30240ba1.tar.zst
gsoc2013-evolution-a58ded435786d5174735b4a501878d8d30240ba1.zip
EMFolderSelectionButton: Add a "folder-uri" property.
And rename a couple get/set functions to match the property name.
Diffstat (limited to 'mail')
-rw-r--r--mail/em-account-editor.c24
-rw-r--r--mail/em-filter-folder-element.c4
-rw-r--r--mail/em-folder-selection-button.c59
-rw-r--r--mail/em-folder-selection-button.h6
-rw-r--r--mail/importers/evolution-mbox-importer.c4
5 files changed, 62 insertions, 35 deletions
diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c
index 8e3b596551..c689ca61b7 100644
--- a/mail/em-account-editor.c
+++ b/mail/em-account-editor.c
@@ -622,11 +622,11 @@ default_folders_clicked (GtkButton *button, gpointer user_data)
const gchar *uri;
uri = e_mail_local_get_folder_uri (E_MAIL_LOCAL_FOLDER_DRAFTS);
- em_folder_selection_button_set_selection ((EMFolderSelectionButton *) emae->priv->drafts_folder_button, uri);
+ em_folder_selection_button_set_folder_uri ((EMFolderSelectionButton *) emae->priv->drafts_folder_button, uri);
emae_account_folder_changed ((EMFolderSelectionButton *) emae->priv->drafts_folder_button, emae);
uri = e_mail_local_get_folder_uri (E_MAIL_LOCAL_FOLDER_SENT);
- em_folder_selection_button_set_selection ((EMFolderSelectionButton *) emae->priv->sent_folder_button, uri);
+ em_folder_selection_button_set_folder_uri ((EMFolderSelectionButton *) emae->priv->sent_folder_button, uri);
emae_account_folder_changed ((EMFolderSelectionButton *) emae->priv->sent_folder_button, emae);
gtk_toggle_button_set_active (emae->priv->trash_folder_check, FALSE);
@@ -1100,7 +1100,7 @@ emae_account_folder_changed (EMFolderSelectionButton *folder, EMAccountEditor *e
account = em_account_editor_get_modified_account (emae);
data = g_object_get_data (G_OBJECT (folder), "account-item");
- selection = em_folder_selection_button_get_selection (folder);
+ selection = em_folder_selection_button_get_folder_uri (folder);
e_account_set_string (account, GPOINTER_TO_INT (data), selection);
}
@@ -1121,10 +1121,10 @@ emae_account_folder (EMAccountEditor *emae, const gchar *name, gint item, gint d
uri = e_account_get_string (account, item);
if (uri != NULL) {
- em_folder_selection_button_set_selection (folder, uri);
+ em_folder_selection_button_set_folder_uri (folder, uri);
} else {
uri = e_mail_local_get_folder_uri (deffolder);
- em_folder_selection_button_set_selection (folder, uri);
+ em_folder_selection_button_set_folder_uri (folder, uri);
}
g_object_set_data ((GObject *)folder, "account-item", GINT_TO_POINTER(item));
@@ -3051,7 +3051,7 @@ emae_real_url_toggled (GtkToggleButton *check, EMAccountEditor *emae)
camel_url_free (url);
/* clear the previous selection */
- em_folder_selection_button_set_selection ((EMFolderSelectionButton *)butt, "");
+ em_folder_selection_button_set_folder_uri ((EMFolderSelectionButton *)butt, "");
}
}
@@ -3080,7 +3080,7 @@ emae_real_url_folder_changed (EMFolderSelectionButton *folder, EMAccountEditor *
url = emae_account_url (emae, emae_service_info[emae->priv->source.type].account_uri_key);
- curi_selected = em_folder_selection_button_get_selection (folder);
+ curi_selected = em_folder_selection_button_get_folder_uri (folder);
if (!curi_selected || !*curi_selected) {
camel_url_set_param (url, param_key, NULL);
changed = TRUE;
@@ -3101,7 +3101,7 @@ emae_real_url_folder_changed (EMFolderSelectionButton *folder, EMAccountEditor *
changed = TRUE;
} else {
e_notice (NULL, GTK_MESSAGE_ERROR, "%s", _("Please select a folder from the current account."));
- em_folder_selection_button_set_selection (folder, "");
+ em_folder_selection_button_set_folder_uri (folder, "");
}
g_free (selected_folder_name);
@@ -3146,7 +3146,7 @@ setup_checkable_folder (EMAccountEditor *emae,
if (value && *value) {
gchar *url_string = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
if (!url_string) {
- em_folder_selection_button_set_selection (folderbutt, "");
+ em_folder_selection_button_set_folder_uri (folderbutt, "");
} else {
CamelURL *copy = camel_url_new (url_string, NULL);
@@ -3156,14 +3156,14 @@ setup_checkable_folder (EMAccountEditor *emae,
g_free (url_string);
url_string = camel_url_to_string (copy, CAMEL_URL_HIDE_ALL);
- em_folder_selection_button_set_selection (folderbutt, url_string ? url_string : "");
+ em_folder_selection_button_set_folder_uri (folderbutt, url_string ? url_string : "");
g_free (url_string);
}
} else {
- em_folder_selection_button_set_selection (folderbutt, "");
+ em_folder_selection_button_set_folder_uri (folderbutt, "");
}
- value = em_folder_selection_button_get_selection (folderbutt);
+ value = em_folder_selection_button_get_folder_uri (folderbutt);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), value && *value);
gtk_widget_set_sensitive (button, available && value && *value);
diff --git a/mail/em-filter-folder-element.c b/mail/em-filter-folder-element.c
index 502ec5d45f..74f386481e 100644
--- a/mail/em-filter-folder-element.c
+++ b/mail/em-filter-folder-element.c
@@ -65,7 +65,7 @@ filter_folder_element_selected_cb (EMFolderSelectionButton *button,
GtkWidget *toplevel;
const gchar *uri;
- uri = em_folder_selection_button_get_selection (button);
+ uri = em_folder_selection_button_get_folder_uri (button);
g_free (ff->priv->uri);
ff->priv->uri = g_strdup (uri);
@@ -239,7 +239,7 @@ filter_folder_element_get_widget (EFilterElement *fe)
button = em_folder_selection_button_new (
backend, _("Select Folder"), NULL);
- em_folder_selection_button_set_selection (
+ em_folder_selection_button_set_folder_uri (
EM_FOLDER_SELECTION_BUTTON (button), ff->priv->uri);
gtk_widget_show (button);
diff --git a/mail/em-folder-selection-button.c b/mail/em-folder-selection-button.c
index d4ff9a1127..ec0479dfea 100644
--- a/mail/em-folder-selection-button.c
+++ b/mail/em-folder-selection-button.c
@@ -45,15 +45,16 @@ struct _EMFolderSelectionButtonPrivate {
GtkWidget *icon;
GtkWidget *label;
- gchar *uri;
gchar *title;
gchar *caption;
+ gchar *folder_uri;
};
enum {
PROP_0,
PROP_BACKEND,
PROP_CAPTION,
+ PROP_FOLDER_URI,
PROP_TITLE
};
@@ -92,12 +93,13 @@ folder_selection_button_set_contents (EMFolderSelectionButton *button)
label = GTK_LABEL (button->priv->label);
backend = em_folder_selection_button_get_backend (button);
- if (backend != NULL && button->priv->uri != NULL) {
+ if (backend != NULL && button->priv->folder_uri != NULL) {
EMailSession *session;
session = e_mail_backend_get_session (backend);
e_mail_folder_uri_parse (
- CAMEL_SESSION (session), button->priv->uri,
+ CAMEL_SESSION (session),
+ button->priv->folder_uri,
&store, &folder_name, NULL);
}
@@ -143,6 +145,12 @@ folder_selection_button_set_property (GObject *object,
g_value_get_string (value));
return;
+ case PROP_FOLDER_URI:
+ em_folder_selection_button_set_folder_uri (
+ EM_FOLDER_SELECTION_BUTTON (object),
+ g_value_get_string (value));
+ return;
+
case PROP_TITLE:
em_folder_selection_button_set_title (
EM_FOLDER_SELECTION_BUTTON (object),
@@ -174,6 +182,13 @@ folder_selection_button_get_property (GObject *object,
EM_FOLDER_SELECTION_BUTTON (object)));
return;
+ case PROP_FOLDER_URI:
+ g_value_set_string (
+ value,
+ em_folder_selection_button_get_folder_uri (
+ EM_FOLDER_SELECTION_BUTTON (object)));
+ return;
+
case PROP_TITLE:
g_value_set_string (
value,
@@ -209,9 +224,9 @@ folder_selection_button_finalize (GObject *object)
priv = EM_FOLDER_SELECTION_BUTTON_GET_PRIVATE (object);
- g_free (priv->uri);
g_free (priv->title);
g_free (priv->caption);
+ g_free (priv->folder_uri);
/* Chain up to parent's finalize() method. */
G_OBJECT_CLASS (em_folder_selection_button_parent_class)->
@@ -249,13 +264,13 @@ folder_selection_button_clicked (GtkButton *button)
EMFT_EXCLUDE_VIRTUAL |
EMFT_EXCLUDE_VTRASH);
- em_folder_tree_set_selected (folder_tree, priv->uri, FALSE);
+ em_folder_tree_set_selected (folder_tree, priv->folder_uri, FALSE);
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
const gchar *uri;
uri = em_folder_selector_get_selected_uri (selector);
- em_folder_selection_button_set_selection (
+ em_folder_selection_button_set_folder_uri (
EM_FOLDER_SELECTION_BUTTON (button), uri);
g_signal_emit (button, signals[SELECTED], 0);
@@ -305,6 +320,17 @@ em_folder_selection_button_class_init (EMFolderSelectionButtonClass *class)
g_object_class_install_property (
object_class,
+ PROP_FOLDER_URI,
+ g_param_spec_string (
+ "folder-uri",
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ g_object_class_install_property (
+ object_class,
PROP_TITLE,
g_param_spec_string (
"title",
@@ -344,8 +370,6 @@ em_folder_selection_button_init (EMFolderSelectionButton *emfsb)
gtk_misc_set_alignment (GTK_MISC (emfsb->priv->label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (box), emfsb->priv->label, TRUE, TRUE, 0);
gtk_widget_show (emfsb->priv->label);
-
- folder_selection_button_set_contents (emfsb);
}
GtkWidget *
@@ -382,26 +406,29 @@ em_folder_selection_button_set_caption (EMFolderSelectionButton *button,
}
const gchar *
-em_folder_selection_button_get_selection (EMFolderSelectionButton *button)
+em_folder_selection_button_get_folder_uri (EMFolderSelectionButton *button)
{
g_return_val_if_fail (EM_IS_FOLDER_SELECTION_BUTTON (button), NULL);
- return button->priv->uri;
+ return button->priv->folder_uri;
}
void
-em_folder_selection_button_set_selection (EMFolderSelectionButton *button,
- const gchar *uri)
+em_folder_selection_button_set_folder_uri (EMFolderSelectionButton *button,
+ const gchar *folder_uri)
{
g_return_if_fail (EM_IS_FOLDER_SELECTION_BUTTON (button));
- if (g_strcmp0 (button->priv->uri, uri) == 0)
- return;
+ /* An empty string is equivalent to NULL. */
+ if (folder_uri != NULL && *folder_uri == '\0')
+ folder_uri = NULL;
- g_free (button->priv->uri);
- button->priv->uri = g_strdup (uri);
+ g_free (button->priv->folder_uri);
+ button->priv->folder_uri = g_strdup (folder_uri);
folder_selection_button_set_contents (button);
+
+ g_object_notify (G_OBJECT (button), "folder-uri");
}
EMailBackend *
diff --git a/mail/em-folder-selection-button.h b/mail/em-folder-selection-button.h
index 8b31100e84..91c5e3ae78 100644
--- a/mail/em-folder-selection-button.h
+++ b/mail/em-folder-selection-button.h
@@ -75,11 +75,11 @@ const gchar * em_folder_selection_button_get_caption
void em_folder_selection_button_set_caption
(EMFolderSelectionButton *button,
const gchar *caption);
-const gchar * em_folder_selection_button_get_selection
+const gchar * em_folder_selection_button_get_folder_uri
(EMFolderSelectionButton *button);
-void em_folder_selection_button_set_selection
+void em_folder_selection_button_set_folder_uri
(EMFolderSelectionButton *button,
- const gchar *uri);
+ const gchar *folder_uri);
void em_folder_selection_button_set_backend
(EMFolderSelectionButton *button,
EMailBackend *backend);
diff --git a/mail/importers/evolution-mbox-importer.c b/mail/importers/evolution-mbox-importer.c
index d0697b1850..4b3a258e18 100644
--- a/mail/importers/evolution-mbox-importer.c
+++ b/mail/importers/evolution-mbox-importer.c
@@ -74,7 +74,7 @@ static void
folder_selected (EMFolderSelectionButton *button, EImportTargetURI *target)
{
g_free (target->uri_dest);
- target->uri_dest = g_strdup (em_folder_selection_button_get_selection (button));
+ target->uri_dest = g_strdup (em_folder_selection_button_get_folder_uri (button));
}
static GtkWidget *
@@ -142,7 +142,7 @@ mbox_getwidget (EImport *ei, EImportTarget *target, EImportImporter *im)
_("Select folder"),
_("Select folder to import into"));
gtk_label_set_mnemonic_widget (label, w);
- em_folder_selection_button_set_selection (
+ em_folder_selection_button_set_folder_uri (
EM_FOLDER_SELECTION_BUTTON (w), select_uri);
folder_selected (
EM_FOLDER_SELECTION_BUTTON (w), (EImportTargetURI *) target);