diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2012-06-15 20:21:30 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2012-06-15 20:22:52 +0800 |
commit | a3048b477f44f3d854c32cb12cbf3022c2ca7336 (patch) | |
tree | 852a47fd1c63628d60278d5e9db13343ac6e382a /widgets/misc | |
parent | 503b211d3d598316fc1040775f7a6669c32a47b1 (diff) | |
download | gsoc2013-evolution-a3048b477f44f3d854c32cb12cbf3022c2ca7336.tar gsoc2013-evolution-a3048b477f44f3d854c32cb12cbf3022c2ca7336.tar.gz gsoc2013-evolution-a3048b477f44f3d854c32cb12cbf3022c2ca7336.tar.bz2 gsoc2013-evolution-a3048b477f44f3d854c32cb12cbf3022c2ca7336.tar.lz gsoc2013-evolution-a3048b477f44f3d854c32cb12cbf3022c2ca7336.tar.xz gsoc2013-evolution-a3048b477f44f3d854c32cb12cbf3022c2ca7336.tar.zst gsoc2013-evolution-a3048b477f44f3d854c32cb12cbf3022c2ca7336.zip |
ESourceConfig: Lock down name when editing a collection member.
Diffstat (limited to 'widgets/misc')
-rw-r--r-- | widgets/misc/e-source-config.c | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/widgets/misc/e-source-config.c b/widgets/misc/e-source-config.c index 25e7923a4d..8372da1448 100644 --- a/widgets/misc/e-source-config.c +++ b/widgets/misc/e-source-config.c @@ -44,6 +44,7 @@ struct _ESourceConfigPrivate { GtkWidget *type_label; GtkWidget *type_combo; + GtkWidget *name_label; GtkWidget *name_entry; GtkWidget *backend_box; GtkSizeGroup *size_group; @@ -434,6 +435,11 @@ source_config_dispose (GObject *object) priv->type_combo = NULL; } + if (priv->name_label != NULL) { + g_object_unref (priv->name_label); + priv->name_label = NULL; + } + if (priv->name_entry != NULL) { g_object_unref (priv->name_entry); priv->name_entry = NULL; @@ -502,9 +508,17 @@ source_config_constructed (GObject *object) config, NULL, _("Type:"), config->priv->type_combo); - e_source_config_insert_widget ( - config, NULL, _("Name:"), - config->priv->name_entry); + /* If the original source is part of a collection then we assume + * the display name is server-assigned and not user-assigned, at + * least not assigned through Evolution. */ + if (collection_source != NULL) + e_source_config_insert_widget ( + config, NULL, _("Name:"), + config->priv->name_label); + else + e_source_config_insert_widget ( + config, NULL, _("Name:"), + config->priv->name_entry); source_config_init_backends (config); } @@ -568,6 +582,11 @@ source_config_init_candidate (ESourceConfig *config, { g_object_bind_property ( scratch_source, "display-name", + config->priv->name_label, "label", + G_BINDING_SYNC_CREATE); + + g_object_bind_property ( + scratch_source, "display-name", config->priv->name_entry, "text", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); @@ -780,15 +799,15 @@ e_source_config_init (ESourceConfig *config) config->priv->candidates = candidates; config->priv->size_group = size_group; - /* Either the combo box or the label is shown, never both. - * But we create both widgets and keep them both up-to-date - * regardless just because it makes the logic simpler. */ - attr_list = pango_attr_list_new (); attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD); pango_attr_list_insert (attr_list, attr); + /* Either the source type combo box or the label is shown, + * never both. But we create both widgets and keep them + * both up-to-date because it makes the logic simpler. */ + widget = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); gtk_label_set_attributes (GTK_LABEL (widget), attr_list); @@ -799,6 +818,16 @@ e_source_config_init (ESourceConfig *config) config->priv->type_combo = g_object_ref_sink (widget); gtk_widget_show (widget); + /* Similarly for the display name. Either the text entry + * or the label is shown, depending on whether the source + * is a collection member (new sources never are). */ + + widget = gtk_label_new (NULL); + gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); + gtk_label_set_attributes (GTK_LABEL (widget), attr_list); + config->priv->name_label = g_object_ref_sink (widget); + gtk_widget_show (widget); + widget = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); config->priv->name_entry = g_object_ref_sink (widget); |