[evolution] I#1118 - Calendar: Disable import when no destination is selected
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] I#1118 - Calendar: Disable import when no destination is selected
- Date: Wed, 30 Sep 2020 13:46:32 +0000 (UTC)
commit 8a73f50190c57d8bf5056d769f8b9bdc06a71617
Author: Milan Crha <mcrha redhat com>
Date: Wed Sep 30 15:45:54 2020 +0200
I#1118 - Calendar: Disable import when no destination is selected
Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1118
src/calendar/importers/icalendar-importer.c | 23 +++++---
src/e-util/e-import-assistant.c | 33 ++++++++++-
src/e-util/e-import.c | 88 +++++++++++++++++++++++++++--
src/e-util/e-import.h | 3 +
4 files changed, 132 insertions(+), 15 deletions(-)
---
diff --git a/src/calendar/importers/icalendar-importer.c b/src/calendar/importers/icalendar-importer.c
index ef048f2258..837c2c111a 100644
--- a/src/calendar/importers/icalendar-importer.c
+++ b/src/calendar/importers/icalendar-importer.c
@@ -270,11 +270,15 @@ button_toggled_cb (GtkWidget *widget,
selector = E_SOURCE_SELECTOR (sd->selector);
source = e_source_selector_ref_primary_selection (selector);
- g_return_if_fail (source != NULL);
- g_datalist_set_data_full (
- &sd->target->data, "primary-source",
- source, (GDestroyNotify) g_object_unref);
+ e_import_set_widget_complete (sd->target->import, source != NULL);
+
+ if (source) {
+ g_datalist_set_data_full (
+ &sd->target->data, "primary-source",
+ source, (GDestroyNotify) g_object_unref);
+ }
+
g_datalist_set_data (
&sd->target->data, "primary-type",
GINT_TO_POINTER (import_type_map[sd->page]));
@@ -290,11 +294,14 @@ primary_selection_changed_cb (ESourceSelector *selector,
ESource *source;
source = e_source_selector_ref_primary_selection (selector);
- g_return_if_fail (source != NULL);
- g_datalist_set_data_full (
- &target->data, "primary-source",
- source, (GDestroyNotify) g_object_unref);
+ e_import_set_widget_complete (target->import, source != NULL);
+
+ if (source) {
+ g_datalist_set_data_full (
+ &target->data, "primary-source",
+ source, (GDestroyNotify) g_object_unref);
+ }
}
static void
diff --git a/src/e-util/e-import-assistant.c b/src/e-util/e-import-assistant.c
index f3f605fc42..982927461a 100644
--- a/src/e-util/e-import-assistant.c
+++ b/src/e-util/e-import-assistant.c
@@ -34,6 +34,7 @@
#include "e-dialog-utils.h"
#include "e-dialog-widgets.h"
#include "e-import.h"
+#include "e-misc-utils.h"
#include "e-util-private.h"
#define E_IMPORT_ASSISTANT_GET_PRIVATE(obj) \
@@ -759,7 +760,7 @@ prepare_destination_page (GtkAssistant *assistant,
priv->file_page.target, priv->file_page.importer);
gtk_box_pack_start (GTK_BOX (vbox), page->control, TRUE, TRUE, 0);
- gtk_assistant_set_page_complete (assistant, vbox, TRUE);
+ gtk_assistant_set_page_complete (assistant, vbox, e_import_get_widget_complete (priv->import));
return FALSE;
}
@@ -985,7 +986,7 @@ prepare_simple_page (GtkAssistant *assistant,
static gboolean
prepare_simple_destination_page (GtkAssistant *assistant,
- GtkWidget *vbox)
+ GtkWidget *vbox)
{
EImportAssistantPrivate *priv;
ImportDestinationPage *page;
@@ -1003,7 +1004,7 @@ prepare_simple_destination_page (GtkAssistant *assistant,
simple_page->target, simple_page->importer);
gtk_box_pack_start (GTK_BOX (vbox), page->control, TRUE, TRUE, 0);
- gtk_assistant_set_page_complete (assistant, vbox, TRUE);
+ gtk_assistant_set_page_complete (assistant, vbox, e_import_get_widget_complete (priv->import));
return FALSE;
}
@@ -1228,6 +1229,29 @@ import_assistant_key_press_event (GtkWidget *widget,
return parent_class->key_press_event (widget, event);
}
+static void
+import_assistant_notify_widget_complete_cb (EImport *import,
+ GParamSpec *param,
+ gpointer user_data)
+{
+ GtkAssistant *assistant = user_data;
+ gint page_no;
+ gboolean is_simple = FALSE;
+
+ g_return_if_fail (E_IS_IMPORT (import));
+ g_return_if_fail (E_IS_IMPORT_ASSISTANT (assistant));
+
+ page_no = gtk_assistant_get_current_page (assistant);
+ g_object_get (assistant, "is-simple", &is_simple, NULL);
+
+ if ((is_simple && page_no == 1) || (!is_simple && page_no == PAGE_FILE_DEST)) {
+ GtkWidget *page;
+
+ page = gtk_assistant_get_nth_page (assistant, page_no);
+ gtk_assistant_set_page_complete (assistant, page, e_import_get_widget_complete (import));
+ }
+}
+
static void
import_assistant_prepare (GtkAssistant *assistant,
GtkWidget *page)
@@ -1425,6 +1449,9 @@ import_assistant_construct (EImportAssistant *import_assistant)
forward_cb, import_assistant, NULL);
gtk_assistant_update_buttons_state (assistant);
+
+ e_signal_connect_notify_object (import_assistant->priv->import, "notify::widget-complete",
+ G_CALLBACK (import_assistant_notify_widget_complete_cb), import_assistant, 0);
}
static void
diff --git a/src/e-util/e-import.c b/src/e-util/e-import.c
index acbc4ead47..62822d7954 100644
--- a/src/e-util/e-import.c
+++ b/src/e-util/e-import.c
@@ -44,10 +44,16 @@ struct _EImportImporters {
gpointer data;
};
-G_DEFINE_TYPE (
- EImport,
- e_import,
- G_TYPE_OBJECT)
+typedef struct _EImportPrivate {
+ gboolean widget_complete;
+} EImportPrivate;
+
+enum {
+ PROP_0,
+ PROP_WIDGET_COMPLETE
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (EImport, e_import, G_TYPE_OBJECT)
static void
import_finalize (GObject *object)
@@ -60,6 +66,36 @@ import_finalize (GObject *object)
G_OBJECT_CLASS (e_import_parent_class)->finalize (object);
}
+static void
+import_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_WIDGET_COMPLETE:
+ e_import_set_widget_complete (E_IMPORT (object), g_value_get_boolean (value));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+import_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
+ case PROP_WIDGET_COMPLETE:
+ g_value_set_boolean (value, e_import_get_widget_complete (E_IMPORT (object)));
+ return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
static void
import_target_free (EImport *import,
EImportTarget *target)
@@ -87,13 +123,57 @@ e_import_class_init (EImportClass *class)
object_class = G_OBJECT_CLASS (class);
object_class->finalize = import_finalize;
+ object_class->set_property = import_set_property;
+ object_class->get_property = import_get_property;
class->target_free = import_target_free;
+
+ g_object_class_install_property (
+ object_class,
+ PROP_WIDGET_COMPLETE,
+ g_param_spec_boolean (
+ "widget-complete",
+ NULL,
+ NULL,
+ FALSE,
+ G_PARAM_READWRITE));
}
static void
e_import_init (EImport *import)
{
+ EImportPrivate *priv = e_import_get_instance_private (import);
+
+ priv->widget_complete = TRUE;
+}
+
+gboolean
+e_import_get_widget_complete (EImport *import)
+{
+ EImportPrivate *priv;
+
+ g_return_val_if_fail (E_IS_IMPORT (import), FALSE);
+
+ priv = e_import_get_instance_private (import);
+
+ return priv->widget_complete;
+}
+
+void
+e_import_set_widget_complete (EImport *import,
+ gboolean value)
+{
+ EImportPrivate *priv;
+
+ g_return_if_fail (E_IS_IMPORT (import));
+
+ priv = e_import_get_instance_private (import);
+
+ if ((priv->widget_complete ? 1 : 0) != (value ? 1 : 0)) {
+ priv->widget_complete = value;
+
+ g_object_notify (G_OBJECT (import), "widget-complete");
+ }
}
/**
diff --git a/src/e-util/e-import.h b/src/e-util/e-import.h
index 0c9b34d337..fd85a7ecff 100644
--- a/src/e-util/e-import.h
+++ b/src/e-util/e-import.h
@@ -223,6 +223,9 @@ GtkWidget * e_import_get_widget (EImport *import,
GtkWidget * e_import_get_preview_widget (EImport *import,
EImportTarget *target,
EImportImporter *im);
+gboolean e_import_get_widget_complete (EImport *import);
+void e_import_set_widget_complete (EImport *import,
+ gboolean value);
void e_import_status (EImport *import,
EImportTarget *target,
const gchar *what,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]