Bug #529331 - Be able to disallow selection of a certain ESource
authorMilan Crha <mcrha@redhat.com>
Thu, 25 Feb 2010 12:30:34 +0000 (13:30 +0100)
committerMilan Crha <mcrha@redhat.com>
Thu, 25 Feb 2010 12:30:34 +0000 (13:30 +0100)
libedataserverui/e-source-selector-dialog.c

index 29abf90..e301169 100644 (file)
@@ -129,6 +129,22 @@ primary_selection_changed_cb (ESourceSelector *selector, gpointer user_data)
        if (priv->selected_source)
                g_object_unref (priv->selected_source);
        priv->selected_source = e_source_selector_peek_primary_selection (selector);
+
+       /* FIXME: add an API to "except-source" or to get the ESourceSelector from outside */
+       if (priv->selected_source) {
+               ESource *except_source = g_object_get_data (G_OBJECT (dialog), "except-source");
+
+               if (except_source) {
+                       const gchar *except_uid, *selected_uid;
+
+                       except_uid = e_source_peek_uid (except_source);
+                       selected_uid = e_source_peek_uid (priv->selected_source);
+
+                       if (except_uid && selected_uid && g_str_equal (except_uid, selected_uid))
+                               priv->selected_source = NULL;
+               }
+       }
+
        if (priv->selected_source) {
                g_object_ref (priv->selected_source);
                gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, TRUE);