[evolution/wip/webkit-composer: 936/966] Move "busy" property from EEditor to EMsgComposer
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit-composer: 936/966] Move "busy" property from EEditor to EMsgComposer
- Date: Wed, 23 Apr 2014 11:12:07 +0000 (UTC)
commit 6100c80a3d3d96a6aee39aa372078c65f33036eb
Author: Tomas Popela <tpopela redhat com>
Date: Wed Mar 26 15:31:31 2014 +0100
Move "busy" property from EEditor to EMsgComposer
composer/e-composer-private.c | 10 +++--
composer/e-composer-private.h | 6 +++-
composer/e-msg-composer.c | 81 +++++++++++++++++++++++++++++++++++++++++
composer/e-msg-composer.h | 1 +
e-util/e-editor-private.h | 6 ---
e-util/e-editor.c | 79 ++++------------------------------------
e-util/e-editor.h | 3 +-
7 files changed, 103 insertions(+), 83 deletions(-)
---
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 6d2d10b..de8788a 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -136,6 +136,8 @@ e_composer_private_constructed (EMsgComposer *composer)
priv->is_from_new_message = FALSE;
priv->set_signature_from_message = FALSE;
priv->disable_signature = FALSE;
+ priv->busy = FALSE;
+ priv->saved_editable= FALSE;
e_composer_actions_init (composer);
@@ -316,17 +318,17 @@ e_composer_private_constructed (EMsgComposer *composer)
}
/* Disable actions that start asynchronous activities while an
- * asynchronous activity is in progress. We enforce this with
- * a simple inverted binding to EEditor's "busy" property. */
+ * asynchronous activity is in progress. We enforce this with
+ * a simple inverted binding to EMsgComposer's "busy" property. */
g_object_bind_property (
- editor, "busy",
+ composer, "busy",
priv->async_actions, "sensitive",
G_BINDING_SYNC_CREATE |
G_BINDING_INVERT_BOOLEAN);
g_object_bind_property (
- editor, "busy",
+ composer, "busy",
priv->header_table, "sensitive",
G_BINDING_SYNC_CREATE |
G_BINDING_INVERT_BOOLEAN);
diff --git a/composer/e-composer-private.h b/composer/e-composer-private.h
index 89c4fd7..8e4c7b8 100644
--- a/composer/e-composer-private.h
+++ b/composer/e-composer-private.h
@@ -92,11 +92,15 @@ struct _EMsgComposerPrivate {
CamelMimeMessage *redirect;
+ gboolean busy;
+ gboolean disable_signature;
gboolean is_from_draft;
gboolean is_from_message;
gboolean is_from_new_message;
+ /* The web view is uneditable while the editor is busy.
+ * This is used to restore the previous editable state. */
+ gboolean saved_editable;
gboolean set_signature_from_message;
- gboolean disable_signature;
};
void e_composer_private_constructed (EMsgComposer *composer);
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 75629aa..1c4e055 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -87,6 +87,7 @@ typedef enum {
enum {
PROP_0,
+ PROP_BUSY,
PROP_EDITOR,
PROP_FOCUS_TRACKER,
PROP_SHELL
@@ -1993,6 +1994,12 @@ msg_composer_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_BUSY:
+ g_value_set_boolean (
+ value, e_msg_composer_is_busy (
+ E_MSG_COMPOSER (object)));
+ return;
+
case PROP_FOCUS_TRACKER:
g_value_set_object (
value, e_msg_composer_get_focus_tracker (
@@ -2052,10 +2059,51 @@ msg_composer_gallery_drag_data_get (GtkIconView *icon_view,
}
static void
+composer_notify_activity_cb (EActivityBar *activity_bar,
+ GParamSpec *pspec,
+ EMsgComposer *composer)
+{
+ EEditor *editor;
+ EEditorWidget *editor_widget;
+ WebKitWebView *web_view;
+ gboolean editable;
+ gboolean busy;
+
+ busy = (e_activity_bar_get_activity (activity_bar) != NULL);
+
+ if (busy == composer->priv->busy)
+ return;
+
+ composer->priv->busy = busy;
+
+ if (busy)
+ e_msg_composer_save_focused_widget (composer);
+
+ editor = e_msg_composer_get_editor (composer);
+ editor_widget = e_editor_get_editor_widget (editor);
+ web_view = WEBKIT_WEB_VIEW (editor_widget);
+
+ if (busy) {
+ editable = webkit_web_view_get_editable (web_view);
+ webkit_web_view_set_editable (web_view, FALSE);
+ composer->priv->saved_editable = editable;
+ } else {
+ editable = composer->priv->saved_editable;
+ webkit_web_view_set_editable (web_view, editable);
+ }
+
+ g_object_notify (G_OBJECT (composer), "busy");
+
+ if (!busy)
+ e_msg_composer_restore_focus_on_composer (composer);
+}
+
+static void
msg_composer_constructed (GObject *object)
{
EShell *shell;
EMsgComposer *composer;
+ EActivityBar *activity_bar;
EAttachmentView *view;
EAttachmentStore *store;
EComposerHeaderTable *table;
@@ -2105,6 +2153,12 @@ msg_composer_constructed (GObject *object)
"/org/gnome/evolution/mail/composer-window/",
E_RESTORE_WINDOW_SIZE);
+ activity_bar = e_editor_get_activity_bar (editor);
+ g_signal_connect (
+ activity_bar, "notify::activity",
+ G_CALLBACK (composer_notify_activity_cb), composer);
+
+
/* Honor User Preferences */
/* FIXME This should be an EMsgComposer property. */
@@ -2334,6 +2388,22 @@ msg_composer_accumulator_false_abort (GSignalInvocationHint *ihint,
return v_boolean;
}
+/**
+ * e_msg_composer_is_busy:
+ * @composer: an #EMsgComposer
+ *
+ * Returns %TRUE only while an #EActivity is in progress.
+ *
+ * Returns: whether @composer is busy
+ **/
+gboolean
+e_msg_composer_is_busy (EMsgComposer *composer)
+{
+ g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), FALSE);
+
+ return composer->priv->busy;
+}
+
static void
e_msg_composer_class_init (EMsgComposerClass *class)
{
@@ -2357,6 +2427,17 @@ e_msg_composer_class_init (EMsgComposerClass *class)
g_object_class_install_property (
object_class,
+ PROP_BUSY,
+ g_param_spec_boolean (
+ "busy",
+ "Busy",
+ "Whether an activity is in progress",
+ FALSE,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
PROP_FOCUS_TRACKER,
g_param_spec_object (
"focus-tracker",
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index 54f108e..472032b 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -190,6 +190,7 @@ void e_save_spell_languages (const GList *spell_languages);
void e_msg_composer_is_from_new_message
(EMsgComposer *composer,
gboolean is_from_new_message);
+gboolean e_msg_composer_is_busy (EMsgComposer *composer);
G_END_DECLS
#endif /* E_MSG_COMPOSER_H */
diff --git a/e-util/e-editor-private.h b/e-util/e-editor-private.h
index 981f1d0..0ac4334 100644
--- a/e-util/e-editor-private.h
+++ b/e-util/e-editor-private.h
@@ -94,12 +94,6 @@ struct _EEditorPrivate {
WebKitDOMNode *table_cell;
gint editor_layout_row;
-
- gboolean busy;
-
- /* The web view is uneditable while the editor is busy.
- * This is used to restore the previous editable state. */
- gboolean saved_editable;
};
void editor_actions_init (EEditor *editor);
diff --git a/e-util/e-editor.c b/e-util/e-editor.c
index d5aac8e..77f142e 100644
--- a/e-util/e-editor.c
+++ b/e-util/e-editor.c
@@ -67,7 +67,6 @@
enum {
PROP_0,
- PROP_BUSY,
PROP_FILENAME
};
@@ -559,38 +558,6 @@ editor_parent_changed (GtkWidget *widget,
}
static void
-editor_notify_activity_cb (EActivityBar *activity_bar,
- GParamSpec *pspec,
- EEditor *editor)
-{
- EEditorWidget *editor_widget;
- WebKitWebView *web_view;
- gboolean editable;
- gboolean busy;
-
- busy = (e_activity_bar_get_activity (activity_bar) != NULL);
-
- if (busy == editor->priv->busy)
- return;
-
- editor->priv->busy = busy;
-
- editor_widget = e_editor_get_editor_widget (editor);
- web_view = WEBKIT_WEB_VIEW (editor_widget);
-
- if (busy) {
- editable = webkit_web_view_get_editable (web_view);
- webkit_web_view_set_editable (web_view, FALSE);
- editor->priv->saved_editable = editable;
- } else {
- editable = editor->priv->saved_editable;
- webkit_web_view_set_editable (web_view, editable);
- }
-
- g_object_notify (G_OBJECT (editor), "busy");
-}
-
-static void
editor_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -615,12 +582,6 @@ editor_get_property (GObject *object,
GParamSpec *pspec)
{
switch (property_id) {
- case PROP_BUSY:
- g_value_set_boolean (
- value, e_editor_is_busy (
- E_EDITOR (object)));
- return;
-
case PROP_FILENAME:
g_value_set_string (
value, e_editor_get_filename (
@@ -664,11 +625,6 @@ editor_constructed (GObject *object)
gtk_widget_set_hexpand (widget, TRUE);
gtk_grid_attach (GTK_GRID (editor), widget, 0, 2, 1, 1);
priv->activity_bar = g_object_ref (widget);
- /* EActivityBar controls its own visibility. */
-
- g_signal_connect (
- widget, "notify::activity",
- G_CALLBACK (editor_notify_activity_cb), editor);
/* Construct the alert bar for errors. */
@@ -859,17 +815,6 @@ e_editor_class_init (EEditorClass *class)
g_object_class_install_property (
object_class,
- PROP_BUSY,
- g_param_spec_boolean (
- "busy",
- "Busy",
- "Whether an activity is in progress",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (
- object_class,
PROP_FILENAME,
g_param_spec_string (
"filename",
@@ -959,22 +904,6 @@ e_editor_new (void)
}
/**
- * e_editor_is_busy:
- * @editor: an #EEditor
- *
- * Returns %TRUE only while an #EActivity is in progress.
- *
- * Returns: whether @editor is busy
- **/
-gboolean
-e_editor_is_busy (EEditor *editor)
-{
- g_return_val_if_fail (E_IS_EDITOR (editor), FALSE);
-
- return editor->priv->busy;
-}
-
-/**
* e_editor_get_editor_widget:
* @editor: an #EEditor
*
@@ -1135,6 +1064,14 @@ e_editor_set_filename (EEditor *editor,
g_object_notify (G_OBJECT (editor), "filename");
}
+EActivityBar *
+e_editor_get_activity_bar (EEditor *editor)
+{
+ g_return_val_if_fail (E_IS_EDITOR (editor), NULL);
+
+ return E_ACTIVITY_BAR (editor->priv->activity_bar);
+}
+
/**
* e_editor_new_activity:
* @editor: an #EEditor
diff --git a/e-util/e-editor.h b/e-util/e-editor.h
index 31db13b..4b5e736 100644
--- a/e-util/e-editor.h
+++ b/e-util/e-editor.h
@@ -27,6 +27,7 @@
#include <gtk/gtk.h>
#include <e-util/e-activity.h>
+#include <e-util/e-activity-bar.h>
#include <e-util/e-editor-widget.h>
/* Standard GObject macros */
@@ -70,7 +71,6 @@ struct _EEditorClass {
GType e_editor_get_type (void) G_GNUC_CONST;
GtkWidget * e_editor_new (void);
-gboolean e_editor_is_busy (EEditor *editor);
EEditorWidget * e_editor_get_editor_widget (EEditor *editor);
GtkBuilder * e_editor_get_builder (EEditor *editor);
GtkUIManager * e_editor_get_ui_manager (EEditor *editor);
@@ -86,6 +86,7 @@ GtkWidget * e_editor_get_style_combo_box (EEditor *editor);
const gchar * e_editor_get_filename (EEditor *editor);
void e_editor_set_filename (EEditor *editor,
const gchar *filename);
+EActivityBar * e_editor_get_activity_bar (EEditor *editor);
EActivity * e_editor_new_activity (EEditor *editor);
void e_editor_pack_above (EEditor *editor,
GtkWidget *child);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]