[evolution/webkit-composer] Bug #689797 - Picture gallery should be above message body



commit 4fa7ae2b6a96b6d2e48c5981d77a0773a492568b
Author: Dan VrÃtil <dvratil redhat com>
Date:   Thu Dec 6 23:09:00 2012 +0100

    Bug #689797 - Picture gallery should be above message body
    
    Converted EEditor from GtkBox to GtkGrid and added method to
    insert widget between the EEditorWidget and toolbars.

 composer/e-composer-private.c     |   16 ++--------------
 widgets/editor/e-editor-private.h |    2 ++
 widgets/editor/e-editor-window.c  |   19 +++++++++++++++++++
 widgets/editor/e-editor-window.h  |    3 +++
 widgets/editor/e-editor.c         |   36 +++++++++++++++++++++++++++++-------
 widgets/editor/e-editor.h         |    7 +++++--
 6 files changed, 60 insertions(+), 23 deletions(-)
---
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 21908da..29af066 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -338,15 +338,6 @@ e_composer_private_constructed (EMsgComposer *composer)
 		gtk_box_pack_end (GTK_BOX (container), tmp_box, FALSE, FALSE, 3);
 	}
 
-	container = e_attachment_paned_get_content_area (
-		E_ATTACHMENT_PANED (priv->attachment_paned));
-
-	widget = gtk_vpaned_new ();
-	gtk_container_add (GTK_CONTAINER (container), widget);
-	gtk_widget_show (widget);
-
-	container = widget;
-
 	widget = gtk_scrolled_window_new (NULL, NULL);
 	gtk_scrolled_window_set_policy (
 		GTK_SCROLLED_WINDOW (widget),
@@ -354,14 +345,11 @@ e_composer_private_constructed (EMsgComposer *composer)
 	gtk_scrolled_window_set_shadow_type (
 		GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
 	gtk_widget_set_size_request (widget, -1, GALLERY_INITIAL_HEIGHT);
-	gtk_paned_pack1 (GTK_PANED (container), widget, FALSE, FALSE);
 	priv->gallery_scrolled_window = g_object_ref (widget);
-	gtk_widget_show (widget);
+        container = priv->gallery_scrolled_window;
+        e_editor_window_pack_inside (E_EDITOR_WINDOW (composer), container);
 
 	/* Construct the picture gallery. */
-
-	container = priv->gallery_scrolled_window;
-
 	gallery_path = e_shell_settings_get_string (
 		shell_settings, "composer-gallery-path");
 	widget = e_picture_gallery_new (gallery_path);
diff --git a/widgets/editor/e-editor-private.h b/widgets/editor/e-editor-private.h
index 0144b8d..e62f825 100644
--- a/widgets/editor/e-editor-private.h
+++ b/widgets/editor/e-editor-private.h
@@ -92,6 +92,8 @@ struct _EEditorPrivate {
 
 	WebKitDOMNode *image;
 	WebKitDOMNode *table_cell;
+
+	int editor_layout_row;
 };
 
 void		editor_actions_init		(EEditor *editor);
diff --git a/widgets/editor/e-editor-window.c b/widgets/editor/e-editor-window.c
index 9b77aaf..cbf1005 100644
--- a/widgets/editor/e-editor-window.c
+++ b/widgets/editor/e-editor-window.c
@@ -210,3 +210,22 @@ e_editor_window_pack_below (EEditorWindow *window,
 		window->priv->main_layout, child,
 		NULL, GTK_POS_BOTTOM, 1, 1);
 }
+
+/**
+ * e_editor_window_pack_inside:
+ * @window: an #EEditorWindow
+ * @child: a #GtkWidget
+ *
+ * Inserts @child between the editor's toolbars and the editor itself.
+ * If there are multiple children, the new @child is places at the end
+ * (immediatelly adjacent to the editor itself).
+ */
+void
+e_editor_window_pack_inside (EEditorWindow* window,
+			     GtkWidget* child)
+{
+	g_return_if_fail (E_IS_EDITOR_WINDOW (window));
+	g_return_if_fail (GTK_IS_WIDGET (child));
+
+	e_editor_pack_above (e_editor_window_get_editor (window), child);
+}
diff --git a/widgets/editor/e-editor-window.h b/widgets/editor/e-editor-window.h
index e3be8b6..88ff72a 100644
--- a/widgets/editor/e-editor-window.h
+++ b/widgets/editor/e-editor-window.h
@@ -68,6 +68,9 @@ EEditor *	e_editor_window_get_editor	(EEditorWindow *window);
 void		e_editor_window_pack_above	(EEditorWindow *window,
 						 GtkWidget *child);
 
+void		e_editor_window_pack_inside	(EEditorWindow *window,
+						 GtkWidget *child);
+
 void		e_editor_window_pack_below	(EEditorWindow *window,
 						 GtkWidget *child);
 
diff --git a/widgets/editor/e-editor.c b/widgets/editor/e-editor.c
index f7aa0b4..ecbaf28 100644
--- a/widgets/editor/e-editor.c
+++ b/widgets/editor/e-editor.c
@@ -33,7 +33,7 @@
 G_DEFINE_TYPE (
 	EEditor,
 	e_editor,
-	GTK_TYPE_BOX);
+	GTK_TYPE_GRID);
 
 /**
  * EEditor:
@@ -586,14 +586,16 @@ editor_constructed (GObject *object)
 
 	/* Construct main window widgets. */
 	widget = e_editor_get_managed_widget (editor, "/edit-toolbar");
+	gtk_widget_set_hexpand (widget, TRUE);
 	gtk_toolbar_set_style (GTK_TOOLBAR (widget), GTK_TOOLBAR_BOTH_HORIZ);
-	gtk_box_pack_start (GTK_BOX (editor), widget, FALSE, FALSE, 0);
+	gtk_grid_attach (GTK_GRID (editor), widget, 0, 0, 1, 1);
 	priv->edit_toolbar = g_object_ref (widget);
 	gtk_widget_show (widget);
 
 	widget = e_editor_get_managed_widget (editor, "/html-toolbar");
+	gtk_widget_set_hexpand (widget, TRUE);
 	gtk_toolbar_set_style (GTK_TOOLBAR (widget), GTK_TOOLBAR_BOTH_HORIZ);
-	gtk_box_pack_start (GTK_BOX (editor), widget, FALSE, FALSE, 0);
+	gtk_grid_attach (GTK_GRID (editor), widget, 0, 1, 1, 1);
 	priv->html_toolbar = g_object_ref (widget);
 	gtk_widget_show (widget);
 
@@ -603,7 +605,9 @@ editor_constructed (GObject *object)
 		GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
 	gtk_scrolled_window_set_shadow_type (
 		GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
-	gtk_box_pack_start (GTK_BOX (editor), widget, TRUE, TRUE, 0);
+	gtk_widget_set_hexpand (widget, TRUE);
+	gtk_widget_set_vexpand (widget, TRUE);
+	gtk_grid_attach (GTK_GRID (editor), widget, 0, 2, 1, 1);
 	priv->scrolled_window = g_object_ref (widget);
 	gtk_widget_show (widget);
 
@@ -800,6 +804,7 @@ e_editor_init (EEditor *editor)
 	g_free (filename);
 
 	editor_actions_init (editor);
+	priv->editor_layout_row = 2;
 }
 
 /**
@@ -812,9 +817,7 @@ e_editor_init (EEditor *editor)
 GtkWidget *
 e_editor_new (void)
 {
-	return g_object_new (E_TYPE_EDITOR,
-		"orientation", GTK_ORIENTATION_VERTICAL,
-		NULL);
+	return g_object_new (E_TYPE_EDITOR, NULL);
 }
 
 /**
@@ -969,6 +972,25 @@ e_editor_set_filename (EEditor *editor,
 }
 
 /**
+ * e_editor_pack_above:
+ * @editor: an #EEditor
+ * @child: a #GtkWidget
+ *
+ * Inserts @child right between the toolbars and the editor widget itself.
+ */
+void
+e_editor_pack_above (EEditor* editor,
+		     GtkWidget* child)
+{
+	g_return_if_fail (E_IS_EDITOR (editor));
+	g_return_if_fail (GTK_IS_WIDGET (child));
+
+	gtk_grid_insert_row (GTK_GRID (editor), editor->priv->editor_layout_row);
+	gtk_grid_attach (GTK_GRID (editor), child, 0, editor->priv->editor_layout_row, 1, 1);
+	editor->priv->editor_layout_row++;
+}
+
+/**
  * e_editor_save:
  * @editor: an #EEditor
  * @filename: file into which to save the content
diff --git a/widgets/editor/e-editor.h b/widgets/editor/e-editor.h
index 4d68fec..f7b667c 100644
--- a/widgets/editor/e-editor.h
+++ b/widgets/editor/e-editor.h
@@ -50,13 +50,13 @@ typedef struct _EEditorClass EEditorClass;
 typedef struct _EEditorPrivate EEditorPrivate;
 
 struct _EEditor {
-	GtkBox parent;
+	GtkGrid parent;
 
 	EEditorPrivate *priv;
 };
 
 struct _EEditorClass {
-	GtkBoxClass parent_class;
+	GtkGridClass parent_class;
 
 	void		(*update_actions)	(EEditor *editor,
 						 GdkEventButton *event);
@@ -86,6 +86,9 @@ const gchar *	e_editor_get_filename		(EEditor *editor);
 void		e_editor_set_filename		(EEditor *editor,
 						 const gchar *filename);
 
+void		e_editor_pack_above		(EEditor *editor,
+						 GtkWidget *child);
+
 void		e_editor_emit_spell_languages_changed
 						(EEditor *editor);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]