[evolution/webkit-composer: 54/130] Some more fixes in the dialogs
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit-composer: 54/130] Some more fixes in the dialogs
- Date: Sat, 19 Jan 2013 14:31:38 +0000 (UTC)
commit a83212affea79c3729293e23071bc071d20be16b
Author: Dan VrÃtil <dvratil redhat com>
Date: Mon Aug 20 22:31:44 2012 +0200
Some more fixes in the dialogs
- make the dialog modal
- fix gtk_window_set_transient_for()
- always give focus to WebKit so that text selection is painted even when
there's a modal dialog on top of the main window which has the actual focus
e-util/e-editor-actions.c | 1 +
e-util/e-editor-dialog.c | 21 ++++++++++++---
e-util/e-editor-find-dialog.c | 7 +++++
e-util/e-editor-hrule-dialog.c | 2 +-
e-util/e-editor-page-dialog.c | 2 +-
e-util/e-editor-spell-check-dialog.c | 48 ++++++++++++++++++++++++----------
6 files changed, 61 insertions(+), 20 deletions(-)
---
diff --git a/e-util/e-editor-actions.c b/e-util/e-editor-actions.c
index 84254a7..77386ff 100644
--- a/e-util/e-editor-actions.c
+++ b/e-util/e-editor-actions.c
@@ -1931,6 +1931,7 @@ editor_actions_init (EEditor *editor)
gtk_action_set_sensitive (ACTION (UNINDENT), FALSE);
gtk_action_set_sensitive (ACTION (FIND_AGAIN), FALSE);
+ gtk_action_set_sensitive (ACTION (SPELL_CHECK), FALSE);
g_object_bind_property (
editor_widget, "can-redo",
diff --git a/e-util/e-editor-dialog.c b/e-util/e-editor-dialog.c
index 5f6a18f..0adfa56 100644
--- a/e-util/e-editor-dialog.c
+++ b/e-util/e-editor-dialog.c
@@ -39,16 +39,13 @@ enum {
PROP_EDITOR,
};
+
static void
editor_dialog_set_editor (EEditorDialog *dialog,
EEditor *editor)
{
dialog->priv->editor = g_object_ref (editor);
- gtk_window_set_transient_for (
- GTK_WINDOW (dialog),
- GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (editor))));
-
g_object_notify (G_OBJECT (dialog), "editor");
}
@@ -86,6 +83,20 @@ editor_dialog_set_property (GObject *object,
}
static void
+editor_dialog_constructed (GObject *object)
+{
+ EEditorDialog *dialog = E_EDITOR_DIALOG (object);
+
+ /* Chain up to parent implementation first */
+ G_OBJECT_CLASS (e_editor_dialog_parent_class)->constructed (object);
+
+ gtk_window_set_transient_for (
+ GTK_WINDOW (dialog),
+ GTK_WINDOW (gtk_widget_get_toplevel (
+ GTK_WIDGET (dialog->priv->editor))));
+}
+
+static void
editor_dialog_show (GtkWidget *widget)
{
gtk_widget_show_all (GTK_WIDGET (E_EDITOR_DIALOG (widget)->priv->container));
@@ -118,6 +129,7 @@ e_editor_dialog_class_init (EEditorDialogClass *klass)
object_class->get_property = editor_dialog_get_property;
object_class->set_property = editor_dialog_set_property;
object_class->dispose = editor_dialog_dispose;
+ object_class->constructed = editor_dialog_constructed;
widget_class = GTK_WIDGET_CLASS (klass);
widget_class->show = editor_dialog_show;
@@ -171,6 +183,7 @@ e_editor_dialog_init (EEditorDialog *dialog)
g_object_set (
G_OBJECT (dialog),
"destroy-with-parent", TRUE,
+ "modal", TRUE,
"resizable", FALSE,
"type-hint", GDK_WINDOW_TYPE_HINT_POPUP_MENU,
"window-position", GTK_WIN_POS_CENTER_ON_PARENT,
diff --git a/e-util/e-editor-find-dialog.c b/e-util/e-editor-find-dialog.c
index eeb0553..ae28732 100644
--- a/e-util/e-editor-find-dialog.c
+++ b/e-util/e-editor-find-dialog.c
@@ -85,6 +85,13 @@ editor_find_dialog_find_cb (EEditorFindDialog *dialog)
gtk_widget_set_sensitive (dialog->priv->find_button, found);
+ /* We give focus to WebKit so that the selection is highlited.
+ * Without focus selection is not visible (at least with my default
+ * color scheme). The focus in fact is not given to WebKit, because
+ * this dialog is modal, but it satisfies it in a way that it paints
+ * the selection :) */
+ gtk_widget_grab_focus (GTK_WIDGET (editor_widget));
+
if (!found) {
gtk_label_set_label (
GTK_LABEL (dialog->priv->result_label),
diff --git a/e-util/e-editor-hrule-dialog.c b/e-util/e-editor-hrule-dialog.c
index 0f2134f..1c572a5 100644
--- a/e-util/e-editor-hrule-dialog.c
+++ b/e-util/e-editor-hrule-dialog.c
@@ -51,7 +51,7 @@ editor_hrule_dialog_set_alignment (EEditorHRuleDialog *dialog)
g_return_if_fail (WEBKIT_DOM_IS_HTMLHR_ELEMENT (dialog->priv->hr_element));
alignment = gtk_combo_box_get_active_id (
- GTK_COMBO_BOX_TEXT (dialog->priv->alignment_combo));
+ GTK_COMBO_BOX (dialog->priv->alignment_combo));
webkit_dom_htmlhr_element_set_align (dialog->priv->hr_element, alignment);
}
diff --git a/e-util/e-editor-page-dialog.c b/e-util/e-editor-page-dialog.c
index 6976172..0ce56a4 100644
--- a/e-util/e-editor-page-dialog.c
+++ b/e-util/e-editor-page-dialog.c
@@ -255,7 +255,7 @@ editor_page_dialog_set_background_image (EEditorPageDialog *dialog)
EEditorWidget *widget;
WebKitDOMDocument *document;
WebKitDOMHTMLElement *body;
- const gchar *uri;
+ gchar *uri;
editor = e_editor_dialog_get_editor(E_EDITOR_DIALOG (dialog));
widget = e_editor_get_editor_widget (editor);
diff --git a/e-util/e-editor-spell-check-dialog.c b/e-util/e-editor-spell-check-dialog.c
index 2447ec5..0b2594a 100644
--- a/e-util/e-editor-spell-check-dialog.c
+++ b/e-util/e-editor-spell-check-dialog.c
@@ -60,6 +60,8 @@ static void
editor_spell_check_dialog_set_word (EEditorSpellCheckDialog *dialog,
const gchar *word)
{
+ EEditor *editor;
+ EEditorWidget *editor_widget;
GtkListStore *store;
gchar *markup;
gchar **suggestions;
@@ -95,17 +97,29 @@ editor_spell_check_dialog_set_word (EEditorSpellCheckDialog *dialog,
}
g_strfreev (suggestions);
+
+ /* We give focus to WebKit so that the currently selected word
+ * is highlited. Without focus selection is not visible (at
+ * least with my default color scheme). The focus in fact is not
+ * given to WebKit, because this dialog is modal, but it satisfies
+ * it in a way that it paints the selection :) */
+ editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
+ editor_widget = e_editor_get_editor_widget (editor);
+ gtk_widget_grab_focus (GTK_WIDGET (editor_widget));
}
static gboolean
select_next_word (EEditorSpellCheckDialog *dialog)
{
- WebKitDOMNode *anchor;
- gulong anchor_offset;
+ WebKitDOMNode *anchor, *focus;
+ gulong anchor_offset, focus_offset;
anchor = webkit_dom_dom_selection_get_anchor_node (dialog->priv->selection);
anchor_offset = webkit_dom_dom_selection_get_anchor_offset (dialog->priv->selection);
+ focus = webkit_dom_dom_selection_get_focus_node (dialog->priv->selection);
+ focus_offset = webkit_dom_dom_selection_get_focus_offset (dialog->priv->selection);
+
/* Jump _behind_ next word */
webkit_dom_dom_selection_modify (
dialog->priv->selection, "move", "forward", "word");
@@ -116,16 +130,20 @@ select_next_word (EEditorSpellCheckDialog *dialog)
webkit_dom_dom_selection_modify (
dialog->priv->selection, "extend", "forward", "word");
- /* If the selection start didn't change, then we have most probably
+ /* If the selection didn't change, then we have most probably
* reached the end of document - return FALSE */
- return ((anchor != webkit_dom_dom_selection_get_anchor_node (
- dialog->priv->selection)) ||
- (anchor_offset != webkit_dom_dom_selection_get_anchor_offset (
+ return !((anchor == webkit_dom_dom_selection_get_anchor_node (
+ dialog->priv->selection)) &&
+ (anchor_offset == webkit_dom_dom_selection_get_anchor_offset (
+ dialog->priv->selection)) &&
+ (focus == webkit_dom_dom_selection_get_focus_node (
+ dialog->priv->selection)) &&
+ (focus_offset == webkit_dom_dom_selection_get_focus_offset (
dialog->priv->selection)));
}
-static void
+static gboolean
editor_spell_check_dialog_next (EEditorSpellCheckDialog *dialog)
{
WebKitDOMNode *start = NULL, *end = NULL;
@@ -163,7 +181,7 @@ editor_spell_check_dialog_next (EEditorSpellCheckDialog *dialog)
if (loc != -1) {
editor_spell_check_dialog_set_word (dialog, word);
g_free (word);
- return;
+ return TRUE;
}
g_free (word);
@@ -179,6 +197,7 @@ editor_spell_check_dialog_next (EEditorSpellCheckDialog *dialog)
/* Close the dialog */
gtk_widget_hide (GTK_WIDGET (dialog));
+ return FALSE;
}
static gboolean
@@ -208,7 +227,7 @@ select_previous_word (EEditorSpellCheckDialog *dialog)
dialog->priv->selection)));
}
-static void
+static gboolean
editor_spell_check_dialog_prev (EEditorSpellCheckDialog *dialog)
{
WebKitDOMNode *start = NULL, *end = NULL;
@@ -248,7 +267,7 @@ editor_spell_check_dialog_prev (EEditorSpellCheckDialog *dialog)
if (loc != -1) {
editor_spell_check_dialog_set_word (dialog, word);
g_free (word);
- return;
+ return TRUE;
}
g_free (word);
@@ -264,6 +283,7 @@ editor_spell_check_dialog_prev (EEditorSpellCheckDialog *dialog)
/* Close the dialog */
gtk_widget_hide (GTK_WIDGET (dialog));
+ return FALSE;
}
static void
@@ -395,10 +415,10 @@ editor_spell_check_dialog_show (GtkWidget *gtk_widget)
window = webkit_dom_document_get_default_view (document);
dialog->priv->selection = webkit_dom_dom_window_get_selection (window);
- /* Select the first word */
- editor_spell_check_dialog_next (dialog);
-
- GTK_WIDGET_CLASS (e_editor_spell_check_dialog_parent_class)->show (gtk_widget);
+ /* Select the first word or quit */
+ if (editor_spell_check_dialog_next (dialog)) {
+ GTK_WIDGET_CLASS (e_editor_spell_check_dialog_parent_class)->show (gtk_widget);
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]