diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2014-03-18 04:39:05 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2014-03-27 08:24:33 +0800 |
commit | 5747a285f7d2c857e7e8faec71c6e8a8e0ac6abf (patch) | |
tree | aaa4a5583d5003ebc6a342191fb0995b44c6c1a7 | |
parent | 1b1c33e4b634f89037af6a077212fec3c42b1a0e (diff) | |
download | gsoc2013-evolution-5747a285f7d2c857e7e8faec71c6e8a8e0ac6abf.tar gsoc2013-evolution-5747a285f7d2c857e7e8faec71c6e8a8e0ac6abf.tar.gz gsoc2013-evolution-5747a285f7d2c857e7e8faec71c6e8a8e0ac6abf.tar.bz2 gsoc2013-evolution-5747a285f7d2c857e7e8faec71c6e8a8e0ac6abf.tar.lz gsoc2013-evolution-5747a285f7d2c857e7e8faec71c6e8a8e0ac6abf.tar.xz gsoc2013-evolution-5747a285f7d2c857e7e8faec71c6e8a8e0ac6abf.tar.zst gsoc2013-evolution-5747a285f7d2c857e7e8faec71c6e8a8e0ac6abf.zip |
EMFolderSelector: Add a "can-create" property.
Replaces the EM_FOLDER_SELECTOR_CAN_CREATE flag, and can also be set
after the selector dialog is instantiated.
This makes EMFolderSelector a little more "subclassable".
-rw-r--r-- | mail/e-mail-reader.c | 6 | ||||
-rw-r--r-- | mail/em-composer-utils.c | 4 | ||||
-rw-r--r-- | mail/em-folder-selection-button.c | 3 | ||||
-rw-r--r-- | mail/em-folder-selector.c | 96 | ||||
-rw-r--r-- | mail/em-folder-selector.h | 11 | ||||
-rw-r--r-- | mail/em-folder-utils.c | 5 | ||||
-rw-r--r-- | mail/em-vfolder-editor-rule.c | 8 | ||||
-rw-r--r-- | modules/mail/em-composer-prefs.c | 2 |
8 files changed, 104 insertions, 31 deletions
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index b7d380ac8d..fc9365e70c 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -344,10 +344,11 @@ action_mail_copy_cb (GtkAction *action, dialog = em_folder_selector_new ( window, model, - EM_FOLDER_SELECTOR_CAN_CREATE, _("Copy to Folder"), NULL, _("C_opy")); selector = EM_FOLDER_SELECTOR (dialog); + em_folder_selector_set_can_create (selector, TRUE); + folder_tree = em_folder_selector_get_folder_tree (selector); em_folder_tree_set_excluded ( @@ -844,10 +845,11 @@ action_mail_move_cb (GtkAction *action, dialog = em_folder_selector_new ( window, model, - EM_FOLDER_SELECTOR_CAN_CREATE, _("Move to Folder"), NULL, _("_Move")); selector = EM_FOLDER_SELECTOR (dialog); + em_folder_selector_set_can_create (selector, TRUE); + folder_tree = em_folder_selector_get_folder_tree (selector); em_folder_tree_set_excluded ( diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index 969f194953..74aa09e657 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -3036,12 +3036,14 @@ post_header_clicked_cb (EComposerPostHeader *header, dialog = em_folder_selector_new ( /* FIXME GTK_WINDOW (composer) */ NULL, - model, EM_FOLDER_SELECTOR_CAN_CREATE, + model, _("Posting destination"), _("Choose folders to post the message to."), NULL); selector = EM_FOLDER_SELECTOR (dialog); + em_folder_selector_set_can_create (selector, TRUE); + folder_tree = em_folder_selector_get_folder_tree (selector); em_folder_tree_set_excluded ( diff --git a/mail/em-folder-selection-button.c b/mail/em-folder-selection-button.c index 2fcd9ffdd7..83d5a6258f 100644 --- a/mail/em-folder-selection-button.c +++ b/mail/em-folder-selection-button.c @@ -271,12 +271,13 @@ folder_selection_button_clicked (GtkButton *button) dialog = em_folder_selector_new ( parent, model, - EM_FOLDER_SELECTOR_CAN_CREATE, priv->title, priv->caption, NULL); g_object_unref (model); selector = EM_FOLDER_SELECTOR (dialog); + em_folder_selector_set_can_create (selector, TRUE); + folder_tree = em_folder_selector_get_folder_tree (selector); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (folder_tree)); diff --git a/mail/em-folder-selector.c b/mail/em-folder-selector.c index 65a26e9df6..e5427d9479 100644 --- a/mail/em-folder-selector.c +++ b/mail/em-folder-selector.c @@ -49,10 +49,13 @@ struct _EMFolderSelectorPrivate { GtkEntry *name_entry; gchar *selected_uri; + + gboolean can_create; }; enum { PROP_0, + PROP_CAN_CREATE, PROP_MODEL }; @@ -85,6 +88,12 @@ folder_selector_set_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_CAN_CREATE: + em_folder_selector_set_can_create ( + EM_FOLDER_SELECTOR (object), + g_value_get_boolean (value)); + return; + case PROP_MODEL: folder_selector_set_model ( EM_FOLDER_SELECTOR (object), @@ -102,6 +111,13 @@ folder_selector_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_CAN_CREATE: + g_value_set_boolean ( + value, + em_folder_selector_get_can_create ( + EM_FOLDER_SELECTOR (object))); + return; + case PROP_MODEL: g_value_set_object ( value, @@ -218,6 +234,19 @@ em_folder_selector_class_init (EMFolderSelectorClass *class) g_object_class_install_property ( object_class, + PROP_CAN_CREATE, + g_param_spec_boolean ( + "can-create", + "Can Create", + "Allow the user to create a new folder " + "before making a final selection", + FALSE, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT | + G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property ( + object_class, PROP_MODEL, g_param_spec_object ( "model", @@ -290,7 +319,6 @@ folder_activated_cb (EMFolderTree *emft, static GtkWidget * folder_selector_construct (EMFolderSelector *selector, - guint32 flags, const gchar *text, const gchar *oklabel) { @@ -316,14 +344,9 @@ folder_selector_construct (EMFolderSelector *selector, container = vbox; - if (flags & EM_FOLDER_SELECTOR_CAN_CREATE) { - gtk_dialog_add_button ( - GTK_DIALOG (selector), _("_New"), - EM_FOLDER_SELECTOR_RESPONSE_NEW); - } - gtk_dialog_add_buttons ( GTK_DIALOG (selector), + _("_New"), EM_FOLDER_SELECTOR_RESPONSE_NEW, _("_Cancel"), GTK_RESPONSE_CANCEL, oklabel ? oklabel : _("_OK"), GTK_RESPONSE_OK, NULL); @@ -332,6 +355,14 @@ folder_selector_construct (EMFolderSelector *selector, gtk_dialog_set_default_response ( GTK_DIALOG (selector), GTK_RESPONSE_OK); + widget = gtk_dialog_get_widget_for_response ( + GTK_DIALOG (selector), EM_FOLDER_SELECTOR_RESPONSE_NEW); + + g_object_bind_property ( + selector, "can-create", + widget, "visible", + G_BINDING_SYNC_CREATE); + widget = e_alert_bar_new (); gtk_box_pack_end (GTK_BOX (container), widget, FALSE, FALSE, 0); selector->priv->alert_bar = g_object_ref (widget); @@ -380,7 +411,6 @@ folder_selector_construct (EMFolderSelector *selector, GtkWidget * em_folder_selector_new (GtkWindow *parent, EMFolderTreeModel *model, - guint32 flags, const gchar *title, const gchar *text, const gchar *oklabel) @@ -394,7 +424,7 @@ em_folder_selector_new (GtkWindow *parent, "transient-for", parent, "title", title, "model", model, NULL); - folder_selector_construct (selector, flags, text, oklabel); + folder_selector_construct (selector, text, oklabel); return GTK_WIDGET (selector); } @@ -431,7 +461,6 @@ folder_selector_create_name_activate (GtkEntry *entry, GtkWidget * em_folder_selector_create_new (GtkWindow *parent, EMFolderTreeModel *model, - guint32 flags, const gchar *title, const gchar *text) { @@ -443,10 +472,6 @@ em_folder_selector_create_new (GtkWindow *parent, g_return_val_if_fail (EM_IS_FOLDER_TREE_MODEL (model), NULL); - /* remove the CREATE flag if it is there since that's the - * whole purpose of this dialog */ - flags &= ~EM_FOLDER_SELECTOR_CAN_CREATE; - selector = g_object_new ( EM_TYPE_FOLDER_SELECTOR, "transient-for", parent, @@ -454,7 +479,7 @@ em_folder_selector_create_new (GtkWindow *parent, "model", model, NULL); container = folder_selector_construct ( - selector, flags, text, _("C_reate")); + selector, text, _("C_reate")); folder_tree = em_folder_selector_get_folder_tree (selector); em_folder_tree_set_excluded (folder_tree, EMFT_EXCLUDE_NOINFERIORS); @@ -488,6 +513,47 @@ em_folder_selector_create_new (GtkWindow *parent, return GTK_WIDGET (selector); } +/** + * em_folder_selector_get_can_create: + * @selector: an #EMFolderSelector + * + * Returns whether the user can create a new folder before making a final + * selection. When %TRUE, the action area of the dialog will show a "New" + * button. + * + * Returns: whether folder creation is allowed + **/ +gboolean +em_folder_selector_get_can_create (EMFolderSelector *selector) +{ + g_return_val_if_fail (EM_IS_FOLDER_SELECTOR (selector), FALSE); + + return selector->priv->can_create; +} + +/** + * em_folder_selector_set_can_create: + * @selector: an #EMFolderSelector + * @can_create: whether folder creation is allowed + * + * Sets whether the user can create a new folder before making a final + * selection. When %TRUE, the action area of the dialog will show a "New" + * button. + **/ +void +em_folder_selector_set_can_create (EMFolderSelector *selector, + gboolean can_create) +{ + g_return_if_fail (EM_IS_FOLDER_SELECTOR (selector)); + + if (can_create == selector->priv->can_create) + return; + + selector->priv->can_create = can_create; + + g_object_notify (G_OBJECT (selector), "can-create"); +} + EMFolderTreeModel * em_folder_selector_get_model (EMFolderSelector *selector) { diff --git a/mail/em-folder-selector.h b/mail/em-folder-selector.h index 46ece3cee6..57351b6553 100644 --- a/mail/em-folder-selector.h +++ b/mail/em-folder-selector.h @@ -60,22 +60,21 @@ struct _EMFolderSelectorClass { GtkDialogClass parent_class; }; -enum { - EM_FOLDER_SELECTOR_CAN_CREATE = 1 -}; - GType em_folder_selector_get_type (void); GtkWidget * em_folder_selector_new (GtkWindow *parent, EMFolderTreeModel *model, - guint32 flags, const gchar *title, const gchar *text, const gchar *oklabel); GtkWidget * em_folder_selector_create_new (GtkWindow *parent, EMFolderTreeModel *model, - guint32 flags, const gchar *title, const gchar *text); +gboolean em_folder_selector_get_can_create + (EMFolderSelector *selector); +void em_folder_selector_set_can_create + (EMFolderSelector *selector, + gboolean can_create); EMFolderTreeModel * em_folder_selector_get_model (EMFolderSelector *selector); EMFolderTree * em_folder_selector_get_folder_tree diff --git a/mail/em-folder-utils.c b/mail/em-folder-utils.c index af89fb0d9e..40db12bfe6 100644 --- a/mail/em-folder-utils.c +++ b/mail/em-folder-utils.c @@ -509,10 +509,11 @@ em_folder_utils_copy_folder (GtkWindow *parent, dialog = em_folder_selector_new ( parent, model, - EM_FOLDER_SELECTOR_CAN_CREATE, title, NULL, label); selector = EM_FOLDER_SELECTOR (dialog); + em_folder_selector_set_can_create (selector, TRUE); + folder_tree = em_folder_selector_get_folder_tree (selector); em_folder_tree_set_excluded_func ( @@ -600,7 +601,7 @@ em_folder_utils_create_folder (GtkWindow *parent, } dialog = em_folder_selector_create_new ( - parent, model, 0, + parent, model, _("Create Folder"), _("Specify where to create the folder:")); diff --git a/mail/em-vfolder-editor-rule.c b/mail/em-vfolder-editor-rule.c index 111a74c0f2..6df9df8c5e 100644 --- a/mail/em-vfolder-editor-rule.c +++ b/mail/em-vfolder-editor-rule.c @@ -377,6 +377,7 @@ source_add (GtkWidget *widget, { EMFolderTree *folder_tree; EMFolderTreeModel *model; + EMFolderSelector *selector; GtkTreeSelection *selection; GtkWidget *dialog; gpointer parent; @@ -388,11 +389,12 @@ source_add (GtkWidget *widget, dialog = em_folder_selector_new ( parent, model, - EM_FOLDER_SELECTOR_CAN_CREATE, _("Add Folder"), NULL, _("_Add")); - folder_tree = em_folder_selector_get_folder_tree ( - EM_FOLDER_SELECTOR (dialog)); + selector = EM_FOLDER_SELECTOR (dialog); + em_folder_selector_set_can_create (selector, TRUE); + + folder_tree = em_folder_selector_get_folder_tree (selector); em_folder_tree_set_excluded (folder_tree, EMFT_EXCLUDE_NOSELECT); diff --git a/modules/mail/em-composer-prefs.c b/modules/mail/em-composer-prefs.c index 495274d648..96c3c60935 100644 --- a/modules/mail/em-composer-prefs.c +++ b/modules/mail/em-composer-prefs.c @@ -440,7 +440,7 @@ sao_folders_add_button_clicked_cb (GtkButton *button, dialog = em_folder_selector_new ( window, em_folder_tree_model_get_default (), - 0, _("Select Folder to Add"), NULL, _("_Add")); + _("Select Folder to Add"), NULL, _("_Add")); selector = EM_FOLDER_SELECTOR (dialog); folder_tree = em_folder_selector_get_folder_tree (selector); |