[evolution/wip/webkit-composer: 104/372] Make 'Image Properties' dialog work
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit-composer: 104/372] Make 'Image Properties' dialog work
- Date: Thu, 6 Feb 2014 11:32:15 +0000 (UTC)
commit 79f914eb9822f3638cacc579f111c45ce8757ccf
Author: Dan Vrátil <dvratil redhat com>
Date: Mon Aug 13 16:28:06 2012 +0200
Make 'Image Properties' dialog work
The dialog is implemented in EEditorImageDialog class.
e-util/Makefile.am | 2 +
e-util/e-editor-actions.c | 9 +-
e-util/e-editor-image-dialog.c | 669 ++++++++++++++++++++++++++++++++++++++++
e-util/e-editor-image-dialog.h | 73 +++++
e-util/e-editor-private.h | 4 +
e-util/e-editor-widgets.h | 28 --
e-util/e-editor.c | 5 +
e-util/e-util.h | 1 +
8 files changed, 762 insertions(+), 29 deletions(-)
---
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index d10cfb8..3d7576a 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -181,6 +181,7 @@ evolution_util_include_HEADERS = \
e-editor-dialog.h \
e-editor-find-dialog.h \
e-editor-hrule-dialog.h \
+ e-editor-image-dialog.h \
e-editor-link-dialog.h \
e-editor-page-dialog.h \
e-editor-replace-dialog.h \
@@ -447,6 +448,7 @@ libevolution_util_la_SOURCES = \
e-editor-dialog.c \
e-editor-find-dialog.c \
e-editor-hrule-dialog.c \
+ e-editor-image-dialog.c \
e-editor-link-dialog.c \
e-editor-page-dialog.c \
e-editor-private.h \
diff --git a/e-util/e-editor-actions.c b/e-util/e-editor-actions.c
index cbd239c..f61be4a 100644
--- a/e-util/e-editor-actions.c
+++ b/e-util/e-editor-actions.c
@@ -906,7 +906,14 @@ static void
action_properties_image_cb (GtkAction *action,
EEditor *editor)
{
- gtk_window_present (GTK_WINDOW (WIDGET (IMAGE_PROPERTIES_WINDOW)));
+ if (editor->priv->image_dialog == NULL) {
+ editor->priv->image_dialog =
+ e_editor_image_dialog_new (editor);
+ }
+
+ e_editor_image_dialog_show (
+ E_EDITOR_IMAGE_DIALOG (editor->priv->image_dialog),
+ editor->priv->image);
}
static void
diff --git a/e-util/e-editor-image-dialog.c b/e-util/e-editor-image-dialog.c
new file mode 100644
index 0000000..56bcecf
--- /dev/null
+++ b/e-util/e-editor-image-dialog.c
@@ -0,0 +1,669 @@
+/*
+ * e-editor-image-dialog.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "e-editor-image-dialog.h"
+
+#include <stdlib.h>
+#include <glib/gi18n-lib.h>
+
+#include "e-editor-utils.h"
+#include "e-image-chooser-dialog.h"
+
+G_DEFINE_TYPE (
+ EEditorImageDialog,
+ e_editor_image_dialog,
+ E_TYPE_EDITOR_DIALOG);
+
+struct _EEditorImageDialogPrivate {
+ GtkWidget *file_chooser;
+ GtkWidget *description_edit;
+
+ GtkWidget *width_edit;
+ GtkWidget *width_units;
+ GtkWidget *height_edit;
+ GtkWidget *height_units;
+ GtkWidget *alignment;
+
+ GtkWidget *x_padding_edit;
+ GtkWidget *y_padding_edit;
+ GtkWidget *border_edit;
+
+ GtkWidget *url_edit;
+ GtkWidget *test_url_button;
+
+ GtkWidget *close_button;
+
+ WebKitDOMHTMLImageElement *image;
+};
+
+static void
+editor_image_dialog_set_src (EEditorImageDialog *dialog)
+{
+ webkit_dom_html_image_element_set_src (
+ dialog->priv->image,
+ gtk_file_chooser_get_uri (
+ GTK_FILE_CHOOSER (dialog->priv->file_chooser)));
+}
+
+static void
+editor_image_dialog_set_alt (EEditorImageDialog *dialog)
+{
+ webkit_dom_html_image_element_set_alt (
+ dialog->priv->image,
+ gtk_entry_get_text (GTK_ENTRY (dialog->priv->description_edit)));
+}
+
+static void
+editor_image_dialog_set_width (EEditorImageDialog *dialog)
+{
+ gint requested;
+ gulong natural;
+ gint width;
+
+ natural = webkit_dom_html_image_element_get_natural_width (
+ dialog->priv->image);
+ requested = gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (dialog->priv->width_edit));
+
+ switch (gtk_combo_box_get_active (
+ GTK_COMBO_BOX (dialog->priv->width_units))) {
+
+ case 0: /* px */
+ width = requested;
+ break;
+
+ case 1: /* percent */
+ width = natural * requested * 0.01;
+ break;
+
+ case 2: /* follow */
+ width = natural;
+ break;
+
+ }
+
+ webkit_dom_html_image_element_set_width (dialog->priv->image, width);
+}
+
+static void
+editor_image_dialog_set_width_units (EEditorImageDialog *dialog)
+{
+ gint requested;
+ gulong natural;
+ gint width = 0;
+
+ natural = webkit_dom_html_image_element_get_natural_width (
+ dialog->priv->image);
+ requested = gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (dialog->priv->width_edit));
+
+
+ switch (gtk_combo_box_get_active (
+ GTK_COMBO_BOX (dialog->priv->width_units))) {
+
+ case 0: /* px */
+ if (gtk_widget_is_sensitive (dialog->priv->width_edit)) {
+ width = requested * natural * 0.01;
+ } else {
+ width = natural;
+ }
+ gtk_widget_set_sensitive (dialog->priv->width_edit, TRUE);
+ break;
+
+ case 1: /* percent */
+ if (gtk_widget_is_sensitive (dialog->priv->width_edit)) {
+ width = (((gdouble) requested) / natural) * 100;
+ } else {
+ width = 100;
+ }
+ gtk_widget_set_sensitive (dialog->priv->width_edit, TRUE);
+ break;
+
+ case 2: /* follow */
+ gtk_widget_set_sensitive (dialog->priv->width_edit, FALSE);
+ break;
+ }
+
+ if (width != 0) {
+ gtk_spin_button_set_value (
+ GTK_SPIN_BUTTON (dialog->priv->width_edit), width);
+ }
+}
+
+static void
+editor_image_dialog_set_height (EEditorImageDialog *dialog)
+{
+ gint requested;
+ gulong natural;
+ gint height;
+
+ natural = webkit_dom_html_image_element_get_natural_height (
+ dialog->priv->image);
+ requested = gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (dialog->priv->height_edit));
+
+ switch (gtk_combo_box_get_active (
+ GTK_COMBO_BOX (dialog->priv->height_units))) {
+
+ case 0: /* px */
+ height = requested;
+ break;
+
+ case 1: /* percent */
+ height = natural * requested * 0.01;
+ break;
+
+ case 2: /* follow */
+ height = natural;
+ break;
+
+ }
+
+ webkit_dom_html_image_element_set_height (dialog->priv->image, height);
+}
+
+static void
+editor_image_dialog_set_height_units (EEditorImageDialog *dialog)
+{
+ gint requested;
+ gulong natural;
+ gint height = -1;
+
+ natural = webkit_dom_html_image_element_get_natural_height (
+ dialog->priv->image);
+ requested = gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (dialog->priv->height_edit));
+
+
+ switch (gtk_combo_box_get_active (
+ GTK_COMBO_BOX (dialog->priv->height_units))) {
+
+ case 0: /* px */
+ if (gtk_widget_is_sensitive (dialog->priv->height_edit)) {
+ height = requested * natural * 0.01;
+ } else {
+ height = natural;
+ }
+ gtk_widget_set_sensitive (dialog->priv->height_edit, TRUE);
+ break;
+
+ case 1: /* percent */
+ if (gtk_widget_is_sensitive (dialog->priv->height_edit)) {
+ height = (((gdouble) requested) / natural) * 100;
+ } else {
+ height = 100;
+ }
+ gtk_widget_set_sensitive (dialog->priv->height_edit, TRUE);
+ break;
+
+ case 2: /* follow */
+ gtk_widget_set_sensitive (dialog->priv->height_edit, FALSE);
+ break;
+ }
+
+ if (height != -1) {
+ gtk_spin_button_set_value (
+ GTK_SPIN_BUTTON (dialog->priv->height_edit), height);
+ }
+}
+
+static void
+editor_image_dialog_set_alignment (EEditorImageDialog *dialog)
+{
+ webkit_dom_html_image_element_set_align (
+ dialog->priv->image,
+ gtk_combo_box_get_active_id (
+ GTK_COMBO_BOX (dialog->priv->alignment)));
+}
+
+static void
+editor_image_dialog_set_x_padding (EEditorImageDialog *dialog)
+{
+ webkit_dom_html_image_element_set_hspace (
+ dialog->priv->image,
+ gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (dialog->priv->x_padding_edit)));
+}
+
+static void
+editor_image_dialog_set_y_padding (EEditorImageDialog *dialog)
+{
+ webkit_dom_html_image_element_set_vspace (
+ dialog->priv->image,
+ gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (dialog->priv->y_padding_edit)));
+}
+
+static void
+editor_image_dialog_set_border (EEditorImageDialog *dialog)
+{
+ gchar *val;
+
+ val = g_strdup_printf (
+ "%d", gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (dialog->priv->border_edit)));
+
+ webkit_dom_html_image_element_set_border (dialog->priv->image, val);
+
+ g_free (val);
+}
+
+static void
+editor_image_dialog_set_url (EEditorImageDialog *dialog)
+{
+ WebKitDOMElement *link;
+ const gchar *url;
+
+ url = gtk_entry_get_text (GTK_ENTRY (dialog->priv->url_edit));
+ link = e_editor_dom_node_get_parent_element (
+ (WebKitDOMNode *) dialog->priv->image,
+ WEBKIT_TYPE_DOM_HTML_ANCHOR_ELEMENT);
+
+ if (link) {
+ if (!url || !*url) {
+ webkit_dom_node_insert_before (
+ webkit_dom_node_get_parent_node (
+ (WebKitDOMNode *) link),
+ (WebKitDOMNode *) dialog->priv->image,
+ (WebKitDOMNode *) link, NULL);
+ webkit_dom_node_remove_child (
+ webkit_dom_node_get_parent_node (
+ (WebKitDOMNode *) link),
+ (WebKitDOMNode *) link, NULL);
+ } else {
+ webkit_dom_html_anchor_element_set_href (
+ (WebKitDOMHTMLAnchorElement *) link, url);
+ }
+ } else {
+ if (url && *url) {
+ WebKitDOMDocument *document;
+
+ document = webkit_dom_node_get_owner_document (
+ (WebKitDOMNode *) dialog->priv->image);
+ link = webkit_dom_document_create_element (
+ document, "A", NULL);
+
+ webkit_dom_html_anchor_element_set_href (
+ (WebKitDOMHTMLAnchorElement *) link, url);
+
+ webkit_dom_node_insert_before (
+ webkit_dom_node_get_parent_node (
+ (WebKitDOMNode *) dialog->priv->image),
+ (WebKitDOMNode *) link,
+ (WebKitDOMNode *) dialog->priv->image, NULL);
+
+ webkit_dom_node_append_child (
+ (WebKitDOMNode *) link,
+ (WebKitDOMNode *) dialog->priv->image, NULL);
+ }
+ }
+}
+
+static void
+editor_image_dialog_test_url (EEditorImageDialog *dialog)
+{
+ gtk_show_uri (
+ gtk_window_get_screen (GTK_WINDOW (dialog)),
+ gtk_entry_get_text (GTK_ENTRY (dialog->priv->url_edit)),
+ GDK_CURRENT_TIME,
+ NULL);
+}
+
+static void
+editor_image_dialog_show (GtkWidget *gtk_widget)
+{
+ EEditorImageDialog *dialog;
+ WebKitDOMElement *link;
+ gchar *tmp;
+ glong val;
+
+ dialog = E_EDITOR_IMAGE_DIALOG (gtk_widget);
+
+ if (!dialog->priv->image) {
+ return;
+ }
+
+ tmp = webkit_dom_html_image_element_get_src (dialog->priv->image);
+ gtk_file_chooser_set_uri (
+ GTK_FILE_CHOOSER (dialog->priv->file_chooser), tmp);
+ g_free (tmp);
+
+ tmp = webkit_dom_html_image_element_get_alt (dialog->priv->image);
+ gtk_entry_set_text (GTK_ENTRY (dialog->priv->description_edit), tmp ? tmp : "");
+ g_free (tmp);
+
+ val = webkit_dom_html_image_element_get_width (dialog->priv->image);
+ gtk_spin_button_set_value (
+ GTK_SPIN_BUTTON (dialog->priv->width_edit), val);
+ gtk_combo_box_set_active_id (
+ GTK_COMBO_BOX (dialog->priv->width_units), "units-px");
+
+ val = webkit_dom_html_image_element_get_height (dialog->priv->image);
+ gtk_spin_button_set_value (
+ GTK_SPIN_BUTTON (dialog->priv->height_edit), val);
+ gtk_combo_box_set_active_id (
+ GTK_COMBO_BOX (dialog->priv->height_units), "units-px");
+
+ tmp = webkit_dom_html_image_element_get_border (dialog->priv->image);
+ gtk_combo_box_set_active_id (
+ GTK_COMBO_BOX (dialog->priv->alignment),
+ (tmp && *tmp) ? tmp : "bottom");
+ g_free (tmp);
+
+ val = webkit_dom_html_image_element_get_hspace (dialog->priv->image);
+ gtk_spin_button_set_value (
+ GTK_SPIN_BUTTON (dialog->priv->x_padding_edit), val);
+
+ val = webkit_dom_html_image_element_get_vspace (dialog->priv->image);
+ gtk_spin_button_set_value (
+ GTK_SPIN_BUTTON (dialog->priv->y_padding_edit), val);
+
+
+ link = e_editor_dom_node_get_parent_element (
+ WEBKIT_DOM_NODE (dialog->priv->image), WEBKIT_TYPE_DOM_HTML_ANCHOR_ELEMENT);
+ if (link) {
+ tmp = webkit_dom_html_anchor_element_get_href (
+ (WebKitDOMHTMLAnchorElement *) link);
+ gtk_entry_set_text (GTK_ENTRY (dialog->priv->url_edit), tmp);
+ g_free (tmp);
+ }
+
+ /* Chain up to parent implementation */
+ GTK_WIDGET_CLASS (e_editor_image_dialog_parent_class)->show (gtk_widget);
+}
+
+static void
+editor_image_dialog_close (EEditorImageDialog *dialog)
+{
+ dialog->priv->image = NULL;
+
+ gtk_widget_hide (GTK_WIDGET (dialog));
+}
+
+static void
+e_editor_image_dialog_class_init (EEditorImageDialogClass *klass)
+{
+ GtkWidgetClass *widget_class;
+
+ e_editor_image_dialog_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (EEditorImageDialogPrivate));
+
+ widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class->show = editor_image_dialog_show;
+}
+
+static void
+e_editor_image_dialog_init (EEditorImageDialog *dialog)
+{
+ GtkBox *main_layout;
+ GtkGrid *grid;
+ GtkWidget *widget;
+ GtkFileFilter *file_filter;
+
+ dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
+ dialog, E_TYPE_EDITOR_IMAGE_DIALOG, EEditorImageDialogPrivate);
+
+ main_layout = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 5));
+ gtk_container_add (GTK_CONTAINER (dialog), GTK_WIDGET (main_layout));
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 10);
+
+ /* == General == */
+ widget = gtk_label_new ("");
+ gtk_label_set_markup (GTK_LABEL (widget), _("<b>General</b>"));
+ gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
+ gtk_box_pack_start (main_layout, widget, TRUE, TRUE, 5);
+
+ grid = GTK_GRID (gtk_grid_new ());
+ gtk_grid_set_row_spacing (grid, 5);
+ gtk_grid_set_column_spacing (grid, 5);
+ gtk_box_pack_start (main_layout, GTK_WIDGET (grid), TRUE, TRUE, 0);
+ gtk_widget_set_margin_left (GTK_WIDGET (grid), 10);
+
+ /* Source */
+ widget = e_image_chooser_dialog_new (
+ _("Choose Background Image"),
+ GTK_WINDOW (dialog));
+ gtk_file_chooser_set_action (
+ GTK_FILE_CHOOSER (widget), GTK_FILE_CHOOSER_ACTION_OPEN);
+
+ file_filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (file_filter, _("Images"));
+ gtk_file_filter_add_mime_type (file_filter, "image/*");
+
+ widget = gtk_file_chooser_button_new_with_dialog (widget);
+ gtk_widget_set_hexpand (widget, TRUE);
+ gtk_grid_attach (grid, widget, 1, 0, 1, 1);
+ g_signal_connect_swapped (
+ widget, "file-set",
+ G_CALLBACK (editor_image_dialog_set_src), dialog);
+ dialog->priv->file_chooser = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("Source:"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->file_chooser);
+ gtk_grid_attach (grid, widget, 0, 0, 1, 1);
+
+ /* Description */
+ widget = gtk_entry_new ();
+ gtk_widget_set_hexpand (widget, TRUE);
+ gtk_grid_attach (grid, widget, 1, 1, 1, 1);
+ g_signal_connect_swapped (
+ widget, "notify::text",
+ G_CALLBACK (editor_image_dialog_set_alt), dialog);
+ dialog->priv->description_edit = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("Description:"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->description_edit);
+ gtk_grid_attach (grid, widget, 0, 1, 1, 1);
+
+
+ /* == Layout == */
+ widget = gtk_label_new ("");
+ gtk_label_set_markup (GTK_LABEL (widget), _("<b>Layout</b>"));
+ gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
+ gtk_box_pack_start (main_layout, widget, TRUE, TRUE, 5);
+
+ grid = GTK_GRID (gtk_grid_new ());
+ gtk_grid_set_row_spacing (grid, 5);
+ gtk_grid_set_column_spacing (grid, 5);
+ gtk_box_pack_start (main_layout, GTK_WIDGET (grid), TRUE, TRUE, 0);
+ gtk_widget_set_margin_left (GTK_WIDGET (grid), 10);
+
+ /* Width */
+ widget = gtk_spin_button_new_with_range (1, G_MAXUINT, 1);
+ gtk_grid_attach (grid, widget, 1, 0, 1, 1);
+ g_signal_connect_swapped (
+ widget, "value-changed",
+ G_CALLBACK (editor_image_dialog_set_width), dialog);
+ dialog->priv->width_edit = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("Width:"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->width_edit);
+ gtk_grid_attach (grid, widget, 0, 0, 1, 1);
+
+ widget = gtk_combo_box_text_new ();
+ gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), "units-px", "px");
+ gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), "units-percent", "%");
+ gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), "units-follow", "follow");
+ gtk_combo_box_set_active_id (GTK_COMBO_BOX (widget), "units-px");
+ gtk_grid_attach (grid, widget, 2, 0, 1, 1);
+ g_signal_connect_swapped (
+ widget, "changed",
+ G_CALLBACK (editor_image_dialog_set_width_units), dialog);
+ dialog->priv->width_units = widget;
+
+ /* Height */
+ widget = gtk_spin_button_new_with_range (1, G_MAXUINT, 1);
+ gtk_grid_attach (grid, widget, 1, 1, 1, 1);
+ g_signal_connect_swapped (
+ widget, "value-changed",
+ G_CALLBACK (editor_image_dialog_set_height), dialog);
+ dialog->priv->height_edit = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("Height:"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->height_edit);
+ gtk_grid_attach (grid, widget, 0, 1, 1, 1);
+
+ widget = gtk_combo_box_text_new ();
+ gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), "units-px", "px");
+ gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), "units-percent", "%");
+ gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), "units-follow", "follow");
+ gtk_combo_box_set_active_id (GTK_COMBO_BOX (widget), "units-px");
+ gtk_grid_attach (grid, widget, 2, 1, 1, 1);
+ g_signal_connect_swapped (
+ widget, "changed",
+ G_CALLBACK (editor_image_dialog_set_height_units), dialog);
+ dialog->priv->height_units = widget;
+
+ /* Alignment */
+ widget = gtk_combo_box_text_new ();
+ gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), "top", _("Top"));
+ gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), "middle", _("Middle"));
+ gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), "bottom", _("Bottom"));
+ gtk_combo_box_set_active_id (GTK_COMBO_BOX (widget), "bottom");
+ gtk_grid_attach (grid, widget, 1, 2, 1, 1);
+ g_signal_connect_swapped (
+ widget, "changed",
+ G_CALLBACK (editor_image_dialog_set_alignment), dialog);
+ dialog->priv->alignment = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("Alignment"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->alignment);
+ gtk_grid_attach (grid, widget, 0, 2, 1, 1);
+
+ /* X Padding */
+ widget = gtk_spin_button_new_with_range (0, G_MAXUINT, 1);
+ gtk_grid_attach (grid, widget, 5, 0, 1, 1);
+ g_signal_connect_swapped (
+ widget, "value-changed",
+ G_CALLBACK (editor_image_dialog_set_x_padding), dialog);
+ dialog->priv->x_padding_edit = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("X-Padding:"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->x_padding_edit);
+ gtk_grid_attach (grid, widget, 4, 0, 1, 1);
+
+ widget = gtk_label_new ("px");
+ gtk_grid_attach (grid, widget, 6, 0, 1, 1);
+
+ /* Y Padding */
+ widget = gtk_spin_button_new_with_range (0, G_MAXUINT, 1);
+ gtk_grid_attach (grid, widget, 5, 1, 1, 1);
+ g_signal_connect_swapped (
+ widget, "value-changed",
+ G_CALLBACK (editor_image_dialog_set_y_padding), dialog);
+ dialog->priv->y_padding_edit = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("Y-Padding:"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->y_padding_edit);
+ gtk_grid_attach (grid, widget, 4, 1, 1, 1);
+
+ widget = gtk_label_new ("px");
+ gtk_grid_attach (grid, widget, 6, 1, 1, 1);
+
+ /* Border */
+ widget = gtk_spin_button_new_with_range (0, G_MAXUINT, 1);
+ gtk_grid_attach (grid, widget, 5, 2, 1, 1);
+ g_signal_connect_swapped (
+ widget, "value-changed",
+ G_CALLBACK (editor_image_dialog_set_border), dialog);
+ dialog->priv->border_edit = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("Border:"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->border_edit);
+ gtk_grid_attach (grid, widget, 4, 2, 1, 1);
+
+ widget = gtk_label_new ("px");
+ gtk_grid_attach (grid, widget, 6, 2, 1, 1);
+
+ /* == Layout == */
+ widget = gtk_label_new ("");
+ gtk_label_set_markup (GTK_LABEL (widget), _("<b>Link</b>"));
+ gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
+ gtk_box_pack_start (main_layout, widget, TRUE, TRUE, 5);
+
+ grid = GTK_GRID (gtk_grid_new ());
+ gtk_grid_set_row_spacing (grid, 5);
+ gtk_grid_set_column_spacing (grid, 5);
+ gtk_box_pack_start (main_layout, GTK_WIDGET (grid), TRUE, TRUE, 0);
+ gtk_widget_set_margin_left (GTK_WIDGET (grid), 10);
+
+ widget = gtk_entry_new ();
+ gtk_grid_attach (grid, widget, 1 ,0, 1, 1);
+ gtk_widget_set_hexpand (widget, TRUE);
+ g_signal_connect_swapped (
+ widget, "notify::text",
+ G_CALLBACK (editor_image_dialog_set_url), dialog);
+ dialog->priv->url_edit = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("URL:"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->url_edit);
+ gtk_grid_attach (grid, widget, 0, 0, 1, 1);
+
+ widget = gtk_button_new_with_label (_("Test URL..."));
+ gtk_grid_attach (grid, widget, 2, 0, 1, 1);
+ g_signal_connect_swapped (
+ widget, "clicked",
+ G_CALLBACK (editor_image_dialog_test_url), dialog);
+ dialog->priv->test_url_button = widget;
+
+ widget = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
+ g_signal_connect_swapped (
+ widget, "clicked",
+ G_CALLBACK (editor_image_dialog_close), dialog);
+ dialog->priv->close_button = widget;
+
+ widget = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (widget), GTK_BUTTONBOX_END);
+ gtk_box_pack_start (main_layout, widget, TRUE, TRUE, 5);
+ gtk_box_pack_start (GTK_BOX (widget), dialog->priv->close_button, FALSE, FALSE, 5);
+
+ gtk_widget_show_all (GTK_WIDGET (main_layout));
+}
+
+GtkWidget *
+e_editor_image_dialog_new (EEditor *editor)
+{
+ return GTK_WIDGET (
+ g_object_new (
+ E_TYPE_EDITOR_IMAGE_DIALOG,
+ "editor", editor,
+ "title", N_("Image Properties"),
+ NULL));
+}
+
+void
+e_editor_image_dialog_show (EEditorImageDialog *dialog,
+ WebKitDOMNode *image)
+{
+ EEditorImageDialogClass *klass;
+
+ g_return_if_fail (E_IS_EDITOR_IMAGE_DIALOG (dialog));
+
+ if (image) {
+ dialog->priv->image = (WebKitDOMHTMLImageElement *) image;
+ } else {
+ dialog->priv->image = NULL;
+ }
+
+ klass = E_EDITOR_IMAGE_DIALOG_GET_CLASS (dialog);
+ GTK_WIDGET_CLASS (klass)->show (GTK_WIDGET (dialog));
+}
diff --git a/e-util/e-editor-image-dialog.h b/e-util/e-editor-image-dialog.h
new file mode 100644
index 0000000..c6fdaa5
--- /dev/null
+++ b/e-util/e-editor-image-dialog.h
@@ -0,0 +1,73 @@
+/*
+ * e-editor-image-dialog.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
+#error "Only <e-util/e-util.h> should be included directly."
+#endif
+
+#ifndef E_EDITOR_IMAGE_DIALOG_H
+#define E_EDITOR_IMAGE_DIALOG_H
+
+#include <e-util/e-editor-dialog.h>
+
+/* Standard GObject macros */
+#define E_TYPE_EDITOR_IMAGE_DIALOG \
+ (e_editor_image_dialog_get_type ())
+#define E_EDITOR_IMAGE_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_EDITOR_IMAGE_DIALOG, EEditorImageDialog))
+#define E_EDITOR_IMAGE_DIALOG_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_EDITOR_IMAGE_DIALOG, EEditorImageDialogClass))
+#define E_IS_EDITOR_IMAGE_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_EDITOR_IMAGE_DIALOG))
+#define E_IS_EDITOR_IMAGE_DIALOG_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_EDITOR_IMAGE_DIALOG))
+#define E_EDITOR_IMAGE_DIALOG_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_EDITOR_IMAGE_DIALOG, EEditorImageDialogClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EEditorImageDialog EEditorImageDialog;
+typedef struct _EEditorImageDialogClass EEditorImageDialogClass;
+typedef struct _EEditorImageDialogPrivate EEditorImageDialogPrivate;
+
+struct _EEditorImageDialog {
+ EEditorDialog parent;
+
+ EEditorImageDialogPrivate *priv;
+};
+
+struct _EEditorImageDialogClass {
+ EEditorDialogClass parent_class;
+};
+
+GType e_editor_image_dialog_get_type (void);
+
+GtkWidget* e_editor_image_dialog_new (EEditor *editor);
+
+void e_editor_image_dialog_show (EEditorImageDialog *dialog,
+ WebKitDOMNode *image);
+
+G_END_DECLS
+
+#endif /* E_EDITOR_IMAGE_DIALOG_H */
+
diff --git a/e-util/e-editor-private.h b/e-util/e-editor-private.h
index 00d10c2..77bb54e 100644
--- a/e-util/e-editor-private.h
+++ b/e-util/e-editor-private.h
@@ -30,6 +30,7 @@
#include <e-editor-hrule-dialog.h>
#include <e-editor-table-dialog.h>
#include <e-editor-page-dialog.h>
+#include <e-editor-image-dialog.h>
#ifdef HAVE_XFREE
#include <X11/XF86keysym.h>
@@ -64,6 +65,7 @@ struct _EEditorPrivate {
GtkWidget *hrule_dialog;
GtkWidget *table_dialog;
GtkWidget *page_dialog;
+ GtkWidget *image_dialog;
GtkWidget *color_combo_box;
GtkWidget *mode_combo_box;
@@ -75,6 +77,8 @@ struct _EEditorPrivate {
EEditorSelection *selection;
gchar *filename;
+
+ WebKitDOMNode *image;
};
void editor_actions_init (EEditor *editor);
diff --git a/e-util/e-editor-widgets.h b/e-util/e-editor-widgets.h
index 6088c7b..997ae82 100644
--- a/e-util/e-editor-widgets.h
+++ b/e-util/e-editor-widgets.h
@@ -59,34 +59,6 @@
#define E_EDITOR_WIDGETS_CELL_PROPERTIES_WRAP_TEXT_CHECK_BUTTON(editor) \
E_EDITOR_WIDGETS ((editor), "cell-properties-wrap-text-check-button")
-/* Image Properties Window */
-#define E_EDITOR_WIDGETS_IMAGE_PROPERTIES_ALIGNMENT_COMBO_BOX(editor) \
- E_EDITOR_WIDGETS ((editor), "image-properties-alignment-combo-box")
-#define E_EDITOR_WIDGETS_IMAGE_PROPERTIES_BORDER_SPIN_BUTTON(editor) \
- E_EDITOR_WIDGETS ((editor), "image-properties-border-spin-button")
-#define E_EDITOR_WIDGETS_IMAGE_PROPERTIES_DESCRIPTION_ENTRY(editor) \
- E_EDITOR_WIDGETS ((editor), "image-properties-description-entry")
-#define E_EDITOR_WIDGETS_IMAGE_PROPERTIES_HEIGHT_COMBO_BOX(editor) \
- E_EDITOR_WIDGETS ((editor), "image-properties-height-combo-box")
-#define E_EDITOR_WIDGETS_IMAGE_PROPERTIES_HEIGHT_SPIN_BUTTON(editor) \
- E_EDITOR_WIDGETS ((editor), "image-properties-height-spin-button")
-#define E_EDITOR_WIDGETS_IMAGE_PROPERTIES_SOURCE_FILE_CHOOSER(editor) \
- E_EDITOR_WIDGETS ((editor), "image-properties-source-file-chooser")
-#define E_EDITOR_WIDGETS_IMAGE_PROPERTIES_URL_BUTTON(editor) \
- E_EDITOR_WIDGETS ((editor), "image-properties-url-button")
-#define E_EDITOR_WIDGETS_IMAGE_PROPERTIES_URL_ENTRY(editor) \
- E_EDITOR_WIDGETS ((editor), "image-properties-url-entry")
-#define E_EDITOR_WIDGETS_IMAGE_PROPERTIES_WIDTH_COMBO_BOX(editor) \
- E_EDITOR_WIDGETS ((editor), "image-properties-width-combo-box")
-#define E_EDITOR_WIDGETS_IMAGE_PROPERTIES_WIDTH_SPIN_BUTTON(editor) \
- E_EDITOR_WIDGETS ((editor), "image-properties-width-spin-button")
-#define E_EDITOR_WIDGETS_IMAGE_PROPERTIES_WINDOW(editor) \
- E_EDITOR_WIDGETS ((editor), "image-properties-window")
-#define E_EDITOR_WIDGETS_IMAGE_PROPERTIES_X_PADDING_SPIN_BUTTON(editor) \
- E_EDITOR_WIDGETS ((editor), "image-properties-x-padding-spin-button")
-#define E_EDITOR_WIDGETS_IMAGE_PROPERTIES_Y_PADDING_SPIN_BUTTON(editor) \
- E_EDITOR_WIDGETS ((editor), "image-properties-y-padding-spin-button")
-
/* Paragraph Properties Window */
#define E_EDITOR_WIDGETS_PARAGRAPH_PROPERTIES_CENTER_BUTTON(editor) \
E_EDITOR_WIDGETS ((editor), "paragraph-properties-center-button")
diff --git a/e-util/e-editor.c b/e-util/e-editor.c
index 892623f..fe94236 100644
--- a/e-util/e-editor.c
+++ b/e-util/e-editor.c
@@ -61,6 +61,8 @@ editor_update_actions (EEditor *editor,
webview = WEBKIT_WEB_VIEW (widget);
manager = e_editor_get_ui_manager (editor);
+ editor->priv->image = NULL;
+
/* Update context menu item visibility. */
hit_test = webkit_web_view_get_hit_test_result (webview, event);
g_object_get (
@@ -70,6 +72,9 @@ editor_update_actions (EEditor *editor,
visible = (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE);
gtk_action_set_visible (ACTION (CONTEXT_PROPERTIES_IMAGE), visible);
+ if (visible) {
+ editor->priv->image = node;
+ }
visible = (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK);
gtk_action_set_visible (ACTION (CONTEXT_PROPERTIES_LINK), visible);
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 9c02f5e..3eafea8 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -95,6 +95,7 @@
#include <e-util/e-editor-dialog.h>
#include <e-util/e-editor-find-dialog.h>
#include <e-util/e-editor-hrule-dialog.h>
+#include <e-util/e-editor-image-dialog.h>
#include <e-util/e-editor-link-dialog.h>
#include <e-util/e-editor-page-dialog.h>
#include <e-util/e-editor-replace-dialog.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]