2 * e-html-editor-image-dialog.h
4 * Copyright (C) 2012 Dan Vrátil <dvratil@redhat.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) version 3.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with the program; if not, see <http://www.gnu.org/licenses/>
25 #include "e-html-editor-image-dialog.h"
28 #include <glib/gi18n-lib.h>
30 #include "e-html-editor-utils.h"
31 #include "e-image-chooser-dialog.h"
33 #define E_HTML_EDITOR_IMAGE_DIALOG_GET_PRIVATE(obj) \
34 (G_TYPE_INSTANCE_GET_PRIVATE \
35 ((obj), E_TYPE_HTML_EDITOR_IMAGE_DIALOG, EHTMLEditorImageDialogPrivate))
37 struct _EHTMLEditorImageDialogPrivate
{
38 GtkWidget
*file_chooser
;
39 GtkWidget
*description_edit
;
41 GtkWidget
*width_edit
;
42 GtkWidget
*width_units
;
43 GtkWidget
*height_edit
;
44 GtkWidget
*height_units
;
47 GtkWidget
*x_padding_edit
;
48 GtkWidget
*y_padding_edit
;
49 GtkWidget
*border_edit
;
52 GtkWidget
*test_url_button
;
54 WebKitDOMHTMLImageElement
*image
;
56 EHTMLEditorViewHistoryEvent
*history_event
;
60 EHTMLEditorImageDialog
,
61 e_html_editor_image_dialog
,
62 E_TYPE_HTML_EDITOR_DIALOG
);
65 html_editor_image_dialog_set_src (EHTMLEditorImageDialog
*dialog
)
68 EHTMLEditorSelection
*editor_selection
;
69 EHTMLEditorView
*view
;
72 editor
= e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog
));
73 view
= e_html_editor_get_view (editor
);
74 editor_selection
= e_html_editor_view_get_selection (view
);
76 uri
= gtk_file_chooser_get_uri (
77 GTK_FILE_CHOOSER (dialog
->priv
->file_chooser
));
79 e_html_editor_selection_replace_image_src (
80 editor_selection
, WEBKIT_DOM_ELEMENT (dialog
->priv
->image
), uri
);
86 html_editor_image_dialog_set_alt (EHTMLEditorImageDialog
*dialog
)
88 webkit_dom_html_image_element_set_alt (
90 gtk_entry_get_text (GTK_ENTRY (dialog
->priv
->description_edit
)));
94 html_editor_image_dialog_set_width (EHTMLEditorImageDialog
*dialog
)
100 natural
= webkit_dom_html_image_element_get_natural_width (
101 dialog
->priv
->image
);
102 requested
= gtk_spin_button_get_value_as_int (
103 GTK_SPIN_BUTTON (dialog
->priv
->width_edit
));
105 switch (gtk_combo_box_get_active (GTK_COMBO_BOX (dialog
->priv
->width_units
))) {
110 case 1: /* percent */
111 width
= natural
* requested
* 0.01;
122 webkit_dom_html_image_element_set_width (dialog
->priv
->image
, width
);
126 html_editor_image_dialog_set_width_units (EHTMLEditorImageDialog
*dialog
)
132 natural
= webkit_dom_html_image_element_get_natural_width (
133 dialog
->priv
->image
);
134 requested
= gtk_spin_button_get_value_as_int (
135 GTK_SPIN_BUTTON (dialog
->priv
->width_edit
));
137 switch (gtk_combo_box_get_active (
138 GTK_COMBO_BOX (dialog
->priv
->width_units
))) {
141 if (gtk_widget_is_sensitive (dialog
->priv
->width_edit
)) {
142 width
= requested
* natural
* 0.01;
146 webkit_dom_element_remove_attribute (
147 WEBKIT_DOM_ELEMENT (dialog
->priv
->image
), "style");
148 gtk_widget_set_sensitive (dialog
->priv
->width_edit
, TRUE
);
151 case 1: /* percent */
152 if (gtk_widget_is_sensitive (dialog
->priv
->width_edit
)) {
153 width
= (((gdouble
) requested
) / natural
) * 100;
157 webkit_dom_element_remove_attribute (
158 WEBKIT_DOM_ELEMENT (dialog
->priv
->image
), "style");
159 gtk_widget_set_sensitive (dialog
->priv
->width_edit
, TRUE
);
163 webkit_dom_element_set_attribute (
164 WEBKIT_DOM_ELEMENT (dialog
->priv
->image
),
168 gtk_widget_set_sensitive (dialog
->priv
->width_edit
, FALSE
);
173 gtk_spin_button_set_value (
174 GTK_SPIN_BUTTON (dialog
->priv
->width_edit
), width
);
179 html_editor_image_dialog_set_height (EHTMLEditorImageDialog
*dialog
)
185 natural
= webkit_dom_html_image_element_get_natural_height (
186 dialog
->priv
->image
);
187 requested
= gtk_spin_button_get_value_as_int (
188 GTK_SPIN_BUTTON (dialog
->priv
->height_edit
));
190 switch (gtk_combo_box_get_active (GTK_COMBO_BOX (dialog
->priv
->height_units
))) {
195 case 1: /* percent */
196 height
= natural
* requested
* 0.01;
207 webkit_dom_html_image_element_set_height (dialog
->priv
->image
, height
);
211 html_editor_image_dialog_set_height_units (EHTMLEditorImageDialog
*dialog
)
217 natural
= webkit_dom_html_image_element_get_natural_height (
218 dialog
->priv
->image
);
219 requested
= gtk_spin_button_get_value_as_int (
220 GTK_SPIN_BUTTON (dialog
->priv
->height_edit
));
222 switch (gtk_combo_box_get_active (
223 GTK_COMBO_BOX (dialog
->priv
->height_units
))) {
226 if (gtk_widget_is_sensitive (dialog
->priv
->height_edit
)) {
227 height
= requested
* natural
* 0.01;
231 webkit_dom_element_remove_attribute (
232 WEBKIT_DOM_ELEMENT (dialog
->priv
->image
), "style");
233 gtk_widget_set_sensitive (dialog
->priv
->height_edit
, TRUE
);
236 case 1: /* percent */
237 if (gtk_widget_is_sensitive (dialog
->priv
->height_edit
)) {
238 height
= (((gdouble
) requested
) / natural
) * 100;
242 webkit_dom_element_remove_attribute (
243 WEBKIT_DOM_ELEMENT (dialog
->priv
->image
), "style");
244 gtk_widget_set_sensitive (dialog
->priv
->height_edit
, TRUE
);
248 webkit_dom_element_set_attribute (
249 WEBKIT_DOM_ELEMENT (dialog
->priv
->image
),
253 gtk_widget_set_sensitive (dialog
->priv
->height_edit
, FALSE
);
258 gtk_spin_button_set_value (
259 GTK_SPIN_BUTTON (dialog
->priv
->height_edit
), height
);
264 html_editor_image_dialog_set_alignment (EHTMLEditorImageDialog
*dialog
)
266 webkit_dom_html_image_element_set_align (
268 gtk_combo_box_get_active_id (
269 GTK_COMBO_BOX (dialog
->priv
->alignment
)));
273 html_editor_image_dialog_set_x_padding (EHTMLEditorImageDialog
*dialog
)
275 webkit_dom_html_image_element_set_hspace (
277 gtk_spin_button_get_value_as_int (
278 GTK_SPIN_BUTTON (dialog
->priv
->x_padding_edit
)));
282 html_editor_image_dialog_set_y_padding (EHTMLEditorImageDialog
*dialog
)
284 webkit_dom_html_image_element_set_vspace (
286 gtk_spin_button_get_value_as_int (
287 GTK_SPIN_BUTTON (dialog
->priv
->y_padding_edit
)));
291 html_editor_image_dialog_set_border (EHTMLEditorImageDialog
*dialog
)
295 val
= g_strdup_printf (
296 "%d", gtk_spin_button_get_value_as_int (
297 GTK_SPIN_BUTTON (dialog
->priv
->border_edit
)));
299 webkit_dom_html_image_element_set_border (dialog
->priv
->image
, val
);
305 html_editor_image_dialog_set_url (EHTMLEditorImageDialog
*dialog
)
307 WebKitDOMElement
*link
;
310 url
= gtk_entry_get_text (GTK_ENTRY (dialog
->priv
->url_edit
));
311 link
= e_html_editor_dom_node_find_parent_element (
312 WEBKIT_DOM_NODE (dialog
->priv
->image
), "A");
316 webkit_dom_node_insert_before (
317 webkit_dom_node_get_parent_node (
318 WEBKIT_DOM_NODE (link
)),
319 WEBKIT_DOM_NODE (dialog
->priv
->image
),
320 WEBKIT_DOM_NODE (link
), NULL
);
321 webkit_dom_node_remove_child (
322 webkit_dom_node_get_parent_node (
323 WEBKIT_DOM_NODE (link
)),
324 WEBKIT_DOM_NODE (link
), NULL
);
326 webkit_dom_html_anchor_element_set_href (
327 WEBKIT_DOM_HTML_ANCHOR_ELEMENT (link
), url
);
331 WebKitDOMDocument
*document
;
333 document
= webkit_dom_node_get_owner_document (
334 WEBKIT_DOM_NODE (dialog
->priv
->image
));
335 link
= webkit_dom_document_create_element (
336 document
, "A", NULL
);
338 webkit_dom_html_anchor_element_set_href (
339 WEBKIT_DOM_HTML_ANCHOR_ELEMENT (link
), url
);
341 webkit_dom_node_insert_before (
342 webkit_dom_node_get_parent_node (
343 WEBKIT_DOM_NODE (dialog
->priv
->image
)),
344 WEBKIT_DOM_NODE (link
),
345 WEBKIT_DOM_NODE (dialog
->priv
->image
), NULL
);
347 webkit_dom_node_append_child (
348 WEBKIT_DOM_NODE (link
),
349 WEBKIT_DOM_NODE (dialog
->priv
->image
), NULL
);
355 html_editor_image_dialog_test_url (EHTMLEditorImageDialog
*dialog
)
358 gtk_window_get_screen (GTK_WINDOW (dialog
)),
359 gtk_entry_get_text (GTK_ENTRY (dialog
->priv
->url_edit
)),
365 html_editor_image_dialog_show (GtkWidget
*widget
)
367 EHTMLEditorImageDialog
*dialog
;
369 EHTMLEditorSelection
*selection
;
370 EHTMLEditorView
*view
;
371 WebKitDOMElement
*link
;
375 dialog
= E_HTML_EDITOR_IMAGE_DIALOG (widget
);
377 if (!dialog
->priv
->image
) {
381 editor
= e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog
));
382 view
= e_html_editor_get_view (editor
);
383 selection
= e_html_editor_view_get_selection (view
);
385 if (!e_html_editor_view_is_undo_redo_in_progress (view
)) {
386 EHTMLEditorViewHistoryEvent
*ev
;
388 ev
= g_new0 (EHTMLEditorViewHistoryEvent
, 1);
389 ev
->type
= HISTORY_IMAGE_DIALOG
;
391 e_html_editor_selection_get_selection_coordinates (
392 selection
, &ev
->before
.start
.x
, &ev
->before
.start
.y
, &ev
->before
.end
.x
, &ev
->before
.end
.y
);
393 ev
->data
.dom
.from
= webkit_dom_node_clone_node (
394 WEBKIT_DOM_NODE (dialog
->priv
->image
), FALSE
);
395 dialog
->priv
->history_event
= ev
;
398 tmp
= webkit_dom_element_get_attribute (
399 WEBKIT_DOM_ELEMENT (dialog
->priv
->image
), "data-uri");
401 gtk_file_chooser_set_uri (
402 GTK_FILE_CHOOSER (dialog
->priv
->file_chooser
), tmp
);
403 gtk_widget_set_sensitive (
404 GTK_WIDGET (dialog
->priv
->file_chooser
), TRUE
);
406 gtk_file_chooser_set_uri (
407 GTK_FILE_CHOOSER (dialog
->priv
->file_chooser
), "");
408 gtk_widget_set_sensitive (
409 GTK_WIDGET (dialog
->priv
->file_chooser
), FALSE
);
413 tmp
= webkit_dom_html_image_element_get_alt (dialog
->priv
->image
);
414 gtk_entry_set_text (GTK_ENTRY (dialog
->priv
->description_edit
), tmp
? tmp
: "");
417 val
= webkit_dom_html_image_element_get_width (dialog
->priv
->image
);
418 gtk_spin_button_set_value (
419 GTK_SPIN_BUTTON (dialog
->priv
->width_edit
), val
);
420 gtk_combo_box_set_active_id (
421 GTK_COMBO_BOX (dialog
->priv
->width_units
), "units-px");
423 val
= webkit_dom_html_image_element_get_height (dialog
->priv
->image
);
424 gtk_spin_button_set_value (
425 GTK_SPIN_BUTTON (dialog
->priv
->height_edit
), val
);
426 gtk_combo_box_set_active_id (
427 GTK_COMBO_BOX (dialog
->priv
->height_units
), "units-px");
429 tmp
= webkit_dom_html_image_element_get_border (dialog
->priv
->image
);
430 gtk_combo_box_set_active_id (
431 GTK_COMBO_BOX (dialog
->priv
->alignment
),
432 (tmp
&& *tmp
) ? tmp
: "bottom");
435 val
= webkit_dom_html_image_element_get_hspace (dialog
->priv
->image
);
436 gtk_spin_button_set_value (
437 GTK_SPIN_BUTTON (dialog
->priv
->x_padding_edit
), val
);
439 val
= webkit_dom_html_image_element_get_vspace (dialog
->priv
->image
);
440 gtk_spin_button_set_value (
441 GTK_SPIN_BUTTON (dialog
->priv
->y_padding_edit
), val
);
443 link
= e_html_editor_dom_node_find_parent_element (
444 WEBKIT_DOM_NODE (dialog
->priv
->image
), "A");
446 tmp
= webkit_dom_html_anchor_element_get_href (
447 WEBKIT_DOM_HTML_ANCHOR_ELEMENT (link
));
448 gtk_entry_set_text (GTK_ENTRY (dialog
->priv
->url_edit
), tmp
);
452 /* Chain up to parent implementation */
453 GTK_WIDGET_CLASS (e_html_editor_image_dialog_parent_class
)->show (widget
);
457 html_editor_image_dialog_hide (GtkWidget
*widget
)
459 EHTMLEditorImageDialogPrivate
*priv
;
460 EHTMLEditorViewHistoryEvent
*ev
;
462 priv
= E_HTML_EDITOR_IMAGE_DIALOG_GET_PRIVATE (widget
);
463 ev
= priv
->history_event
;
466 EHTMLEditorImageDialog
*dialog
;
468 EHTMLEditorSelection
*selection
;
469 EHTMLEditorView
*view
;
471 dialog
= E_HTML_EDITOR_IMAGE_DIALOG (widget
);
472 editor
= e_html_editor_dialog_get_editor (E_HTML_EDITOR_DIALOG (dialog
));
473 view
= e_html_editor_get_view (editor
);
474 selection
= e_html_editor_view_get_selection (view
);
476 ev
->data
.dom
.to
= webkit_dom_node_clone_node (
477 WEBKIT_DOM_NODE (priv
->image
), FALSE
);
479 e_html_editor_selection_get_selection_coordinates (
480 selection
, &ev
->after
.start
.x
, &ev
->after
.start
.y
, &ev
->after
.end
.x
, &ev
->after
.end
.y
);
481 e_html_editor_view_insert_new_history_event (view
, ev
);
484 g_object_unref (priv
->image
);
487 GTK_WIDGET_CLASS (e_html_editor_image_dialog_parent_class
)->hide (widget
);
491 e_html_editor_image_dialog_class_init (EHTMLEditorImageDialogClass
*class)
493 GtkWidgetClass
*widget_class
;
495 g_type_class_add_private (class, sizeof (EHTMLEditorImageDialogPrivate
));
497 widget_class
= GTK_WIDGET_CLASS (class);
498 widget_class
->show
= html_editor_image_dialog_show
;
499 widget_class
->hide
= html_editor_image_dialog_hide
;
503 e_html_editor_image_dialog_init (EHTMLEditorImageDialog
*dialog
)
505 GtkGrid
*main_layout
, *grid
;
507 GtkFileFilter
*file_filter
;
509 dialog
->priv
= E_HTML_EDITOR_IMAGE_DIALOG_GET_PRIVATE (dialog
);
511 main_layout
= e_html_editor_dialog_get_container (E_HTML_EDITOR_DIALOG (dialog
));
514 widget
= gtk_label_new ("");
515 gtk_label_set_markup (GTK_LABEL (widget
), _("<b>General</b>"));
516 gtk_misc_set_alignment (GTK_MISC (widget
), 0, 0.5);
517 gtk_grid_attach (main_layout
, widget
, 0, 0, 1, 1);
519 grid
= GTK_GRID (gtk_grid_new ());
520 gtk_grid_set_row_spacing (grid
, 5);
521 gtk_grid_set_column_spacing (grid
, 5);
522 gtk_grid_attach (main_layout
, GTK_WIDGET (grid
), 0, 1, 1, 1);
523 gtk_widget_set_margin_left (GTK_WIDGET (grid
), 10);
526 widget
= e_image_chooser_dialog_new (
527 _("Choose Background Image"),
528 GTK_WINDOW (dialog
));
529 gtk_file_chooser_set_action (
530 GTK_FILE_CHOOSER (widget
), GTK_FILE_CHOOSER_ACTION_OPEN
);
532 file_filter
= gtk_file_filter_new ();
533 gtk_file_filter_set_name (file_filter
, _("Images"));
534 gtk_file_filter_add_mime_type (file_filter
, "image/*");
536 widget
= gtk_file_chooser_button_new_with_dialog (widget
);
537 gtk_widget_set_hexpand (widget
, TRUE
);
538 gtk_grid_attach (grid
, widget
, 1, 0, 1, 1);
539 g_signal_connect_swapped (
541 G_CALLBACK (html_editor_image_dialog_set_src
), dialog
);
542 dialog
->priv
->file_chooser
= widget
;
544 widget
= gtk_label_new_with_mnemonic (_("_Source:"));
545 gtk_label_set_justify (GTK_LABEL (widget
), GTK_JUSTIFY_RIGHT
);
546 gtk_label_set_mnemonic_widget (GTK_LABEL (widget
), dialog
->priv
->file_chooser
);
547 gtk_grid_attach (grid
, widget
, 0, 0, 1, 1);
550 widget
= gtk_entry_new ();
551 gtk_widget_set_hexpand (widget
, TRUE
);
552 gtk_grid_attach (grid
, widget
, 1, 1, 1, 1);
553 g_signal_connect_swapped (
554 widget
, "notify::text",
555 G_CALLBACK (html_editor_image_dialog_set_alt
), dialog
);
556 dialog
->priv
->description_edit
= widget
;
558 widget
= gtk_label_new_with_mnemonic (_("_Description:"));
559 gtk_label_set_justify (GTK_LABEL (widget
), GTK_JUSTIFY_RIGHT
);
560 gtk_label_set_mnemonic_widget (GTK_LABEL (widget
), dialog
->priv
->description_edit
);
561 gtk_grid_attach (grid
, widget
, 0, 1, 1, 1);
564 widget
= gtk_label_new ("");
565 gtk_label_set_markup (GTK_LABEL (widget
), _("<b>Layout</b>"));
566 gtk_misc_set_alignment (GTK_MISC (widget
), 0, 0.5);
567 gtk_grid_attach (main_layout
, widget
, 0, 2, 1, 1);
569 grid
= GTK_GRID (gtk_grid_new ());
570 gtk_grid_set_row_spacing (grid
, 5);
571 gtk_grid_set_column_spacing (grid
, 5);
572 gtk_grid_attach (main_layout
, GTK_WIDGET (grid
), 0, 3, 1, 1);
573 gtk_widget_set_margin_left (GTK_WIDGET (grid
), 10);
576 widget
= gtk_spin_button_new_with_range (1, G_MAXUINT
, 1);
577 gtk_grid_attach (grid
, widget
, 1, 0, 1, 1);
578 g_signal_connect_swapped (
579 widget
, "value-changed",
580 G_CALLBACK (html_editor_image_dialog_set_width
), dialog
);
581 dialog
->priv
->width_edit
= widget
;
583 widget
= gtk_label_new_with_mnemonic (_("_Width:"));
584 gtk_label_set_justify (GTK_LABEL (widget
), GTK_JUSTIFY_RIGHT
);
585 gtk_label_set_mnemonic_widget (GTK_LABEL (widget
), dialog
->priv
->width_edit
);
586 gtk_grid_attach (grid
, widget
, 0, 0, 1, 1);
588 widget
= gtk_combo_box_text_new ();
589 gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget
), "units-px", "px");
590 gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget
), "units-percent", "%");
591 gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget
), "units-follow", "follow");
592 gtk_combo_box_set_active_id (GTK_COMBO_BOX (widget
), "units-px");
593 gtk_grid_attach (grid
, widget
, 2, 0, 1, 1);
594 g_signal_connect_swapped (
596 G_CALLBACK (html_editor_image_dialog_set_width_units
), dialog
);
597 dialog
->priv
->width_units
= widget
;
600 widget
= gtk_spin_button_new_with_range (1, G_MAXUINT
, 1);
601 gtk_grid_attach (grid
, widget
, 1, 1, 1, 1);
602 g_signal_connect_swapped (
603 widget
, "value-changed",
604 G_CALLBACK (html_editor_image_dialog_set_height
), dialog
);
605 dialog
->priv
->height_edit
= widget
;
607 widget
= gtk_label_new_with_mnemonic (_("_Height:"));
608 gtk_label_set_justify (GTK_LABEL (widget
), GTK_JUSTIFY_RIGHT
);
609 gtk_label_set_mnemonic_widget (GTK_LABEL (widget
), dialog
->priv
->height_edit
);
610 gtk_grid_attach (grid
, widget
, 0, 1, 1, 1);
612 widget
= gtk_combo_box_text_new ();
613 gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget
), "units-px", "px");
614 gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget
), "units-percent", "%");
615 gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget
), "units-follow", "follow");
616 gtk_combo_box_set_active_id (GTK_COMBO_BOX (widget
), "units-px");
617 gtk_grid_attach (grid
, widget
, 2, 1, 1, 1);
618 g_signal_connect_swapped (
620 G_CALLBACK (html_editor_image_dialog_set_height_units
), dialog
);
621 dialog
->priv
->height_units
= widget
;
624 widget
= gtk_combo_box_text_new ();
625 gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget
), "top", _("Top"));
626 gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget
), "middle", _("Middle"));
627 gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget
), "bottom", _("Bottom"));
628 gtk_combo_box_set_active_id (GTK_COMBO_BOX (widget
), "bottom");
629 gtk_grid_attach (grid
, widget
, 1, 2, 1, 1);
630 g_signal_connect_swapped (
632 G_CALLBACK (html_editor_image_dialog_set_alignment
), dialog
);
633 dialog
->priv
->alignment
= widget
;
635 widget
= gtk_label_new_with_mnemonic (_("_Alignment"));
636 gtk_label_set_justify (GTK_LABEL (widget
), GTK_JUSTIFY_RIGHT
);
637 gtk_label_set_mnemonic_widget (GTK_LABEL (widget
), dialog
->priv
->alignment
);
638 gtk_grid_attach (grid
, widget
, 0, 2, 1, 1);
641 widget
= gtk_spin_button_new_with_range (0, G_MAXUINT
, 1);
642 gtk_grid_attach (grid
, widget
, 5, 0, 1, 1);
643 g_signal_connect_swapped (
644 widget
, "value-changed",
645 G_CALLBACK (html_editor_image_dialog_set_x_padding
), dialog
);
646 dialog
->priv
->x_padding_edit
= widget
;
648 widget
= gtk_label_new_with_mnemonic (_("_X-Padding:"));
649 gtk_label_set_justify (GTK_LABEL (widget
), GTK_JUSTIFY_RIGHT
);
650 gtk_label_set_mnemonic_widget (GTK_LABEL (widget
), dialog
->priv
->x_padding_edit
);
651 gtk_grid_attach (grid
, widget
, 4, 0, 1, 1);
653 widget
= gtk_label_new ("px");
654 gtk_grid_attach (grid
, widget
, 6, 0, 1, 1);
657 widget
= gtk_spin_button_new_with_range (0, G_MAXUINT
, 1);
658 gtk_grid_attach (grid
, widget
, 5, 1, 1, 1);
659 g_signal_connect_swapped (
660 widget
, "value-changed",
661 G_CALLBACK (html_editor_image_dialog_set_y_padding
), dialog
);
662 dialog
->priv
->y_padding_edit
= widget
;
664 widget
= gtk_label_new_with_mnemonic (_("_Y-Padding:"));
665 gtk_label_set_justify (GTK_LABEL (widget
), GTK_JUSTIFY_RIGHT
);
666 gtk_label_set_mnemonic_widget (GTK_LABEL (widget
), dialog
->priv
->y_padding_edit
);
667 gtk_grid_attach (grid
, widget
, 4, 1, 1, 1);
669 widget
= gtk_label_new ("px");
670 gtk_grid_attach (grid
, widget
, 6, 1, 1, 1);
673 widget
= gtk_spin_button_new_with_range (0, G_MAXUINT
, 1);
674 gtk_grid_attach (grid
, widget
, 5, 2, 1, 1);
675 g_signal_connect_swapped (
676 widget
, "value-changed",
677 G_CALLBACK (html_editor_image_dialog_set_border
), dialog
);
678 dialog
->priv
->border_edit
= widget
;
680 widget
= gtk_label_new_with_mnemonic (_("_Border:"));
681 gtk_label_set_justify (GTK_LABEL (widget
), GTK_JUSTIFY_RIGHT
);
682 gtk_label_set_mnemonic_widget (GTK_LABEL (widget
), dialog
->priv
->border_edit
);
683 gtk_grid_attach (grid
, widget
, 4, 2, 1, 1);
685 widget
= gtk_label_new ("px");
686 gtk_grid_attach (grid
, widget
, 6, 2, 1, 1);
689 widget
= gtk_label_new ("");
690 gtk_label_set_markup (GTK_LABEL (widget
), _("<b>Link</b>"));
691 gtk_misc_set_alignment (GTK_MISC (widget
), 0, 0.5);
692 gtk_grid_attach (main_layout
, widget
, 0, 4, 1, 1);
694 grid
= GTK_GRID (gtk_grid_new ());
695 gtk_grid_set_row_spacing (grid
, 5);
696 gtk_grid_set_column_spacing (grid
, 5);
697 gtk_grid_attach (main_layout
, GTK_WIDGET (grid
), 0, 5, 1, 1);
698 gtk_widget_set_margin_left (GTK_WIDGET (grid
), 10);
700 widget
= gtk_entry_new ();
701 gtk_grid_attach (grid
, widget
, 1 ,0, 1, 1);
702 gtk_widget_set_hexpand (widget
, TRUE
);
703 g_signal_connect_swapped (
704 widget
, "notify::text",
705 G_CALLBACK (html_editor_image_dialog_set_url
), dialog
);
706 dialog
->priv
->url_edit
= widget
;
708 widget
= gtk_label_new_with_mnemonic (_("_URL:"));
709 gtk_label_set_justify (GTK_LABEL (widget
), GTK_JUSTIFY_RIGHT
);
710 gtk_label_set_mnemonic_widget (GTK_LABEL (widget
), dialog
->priv
->url_edit
);
711 gtk_grid_attach (grid
, widget
, 0, 0, 1, 1);
713 widget
= gtk_button_new_with_mnemonic (_("_Test URL..."));
714 gtk_grid_attach (grid
, widget
, 2, 0, 1, 1);
715 g_signal_connect_swapped (
717 G_CALLBACK (html_editor_image_dialog_test_url
), dialog
);
718 dialog
->priv
->test_url_button
= widget
;
720 gtk_widget_show_all (GTK_WIDGET (main_layout
));
724 e_html_editor_image_dialog_new (EHTMLEditor
*editor
)
728 E_TYPE_HTML_EDITOR_IMAGE_DIALOG
,
730 "title", _("Image Properties"),
735 e_html_editor_image_dialog_show (EHTMLEditorImageDialog
*dialog
,
736 WebKitDOMNode
*image
)
738 EHTMLEditorImageDialogClass
*class;
740 g_return_if_fail (E_IS_HTML_EDITOR_IMAGE_DIALOG (dialog
));
743 dialog
->priv
->image
= WEBKIT_DOM_HTML_IMAGE_ELEMENT (image
);
745 dialog
->priv
->image
= NULL
;
748 class = E_HTML_EDITOR_IMAGE_DIALOG_GET_CLASS (dialog
);
749 GTK_WIDGET_CLASS (class)->show (GTK_WIDGET (dialog
));