[evolution/webkit-composer: 29/231] Make the 'Table properties' dialog work
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit-composer: 29/231] Make the 'Table properties' dialog work
- Date: Fri, 13 Sep 2013 14:08:26 +0000 (UTC)
commit 1e33be0ed0204f1b9835eda24bf54ba37eac5515
Author: Dan Vrátil <dvratil redhat com>
Date: Wed Aug 8 21:15:04 2012 +0200
Make the 'Table properties' dialog work
The dialog is implemented in EEditorTableDialog class where
all the functionality is implemented.
e-util/Makefile.am | 2 +
e-util/e-editor-actions.c | 45 +--
e-util/e-editor-builder.ui | 570 ---------------------------
e-util/e-editor-private.h | 2 +
e-util/e-editor-table-dialog.c | 837 ++++++++++++++++++++++++++++++++++++++++
e-util/e-editor-table-dialog.h | 69 ++++
e-util/e-editor-utils.c | 1 -
e-util/e-editor-widgets.h | 26 --
e-util/e-util.h | 1 +
9 files changed, 921 insertions(+), 632 deletions(-)
---
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index 6013fe0..5b3c096 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -182,6 +182,7 @@ evolution_util_include_HEADERS = \
e-editor-link-dialog.h \
e-editor-replace-dialog.h \
e-editor-selection.h \
+ e-editor-table-dialog.h \
e-editor-utils.h \
e-editor-widget.h \
e-editor-widgets.h \
@@ -440,6 +441,7 @@ libevolution_util_la_SOURCES = \
e-editor-private.h \
e-editor-replace-dialog.c \
e-editor-selection.c \
+ e-editor-table-dialog.c \
e-editor-utils.c \
e-editor-widget.c \
e-editor.c \
diff --git a/e-util/e-editor-actions.c b/e-util/e-editor-actions.c
index b6f6c2f..0e6fdee 100644
--- a/e-util/e-editor-actions.c
+++ b/e-util/e-editor-actions.c
@@ -697,42 +697,12 @@ static void
action_insert_table_cb (GtkAction *action,
EEditor *editor)
{
- WebKitDOMDocument *document;
- WebKitDOMElement *table;
- WebKitDOMDOMWindow *window;
- WebKitDOMDOMSelection *selection;
- WebKitDOMRange *range;
- gint i;
-
- document = webkit_web_view_get_dom_document (
- WEBKIT_WEB_VIEW (e_editor_get_editor_widget (editor)));
- window = webkit_dom_document_get_default_view (document);
- selection = webkit_dom_dom_window_get_selection (window);
- if (webkit_dom_dom_selection_get_range_count (selection) < 1)
- return;
-
- range = webkit_dom_dom_selection_get_range_at (selection, 0, NULL);
-
- /* Default 3x3 table */
- table = webkit_dom_document_create_element (document, "TABLE", NULL);
- for (i = 0; i < 3; i++) {
- WebKitDOMHTMLElement *row;
- gint j;
-
- row = webkit_dom_html_table_element_insert_row (
- WEBKIT_DOM_HTML_TABLE_ELEMENT (table), -1, NULL);
-
- for (j = 0; j < 3; j++) {
- webkit_dom_html_table_row_element_insert_cell (
- WEBKIT_DOM_HTML_TABLE_ROW_ELEMENT (row),
- -1, NULL);
- }
+ if (editor->priv->table_dialog == NULL) {
+ editor->priv->table_dialog =
+ e_editor_table_dialog_new (editor);
}
- webkit_dom_range_insert_node (range, WEBKIT_DOM_NODE (table), NULL);
-
- /* FIXME WEBKIT - does the action work? */
- gtk_action_activate (ACTION (PROPERTIES_TABLE));
+ gtk_window_present (GTK_WINDOW (editor->priv->table_dialog));
}
static void
@@ -1004,7 +974,12 @@ static void
action_properties_table_cb (GtkAction *action,
EEditor *editor)
{
- gtk_window_present (GTK_WINDOW (WIDGET (TABLE_PROPERTIES_WINDOW)));
+ if (editor->priv->table_dialog == NULL) {
+ editor->priv->table_dialog =
+ e_editor_table_dialog_new (editor);
+ }
+
+ gtk_window_present (GTK_WINDOW (editor->priv->table_dialog));
}
static void
diff --git a/e-util/e-editor-builder.ui b/e-util/e-editor-builder.ui
index c81bdde..cb58225 100644
--- a/e-util/e-editor-builder.ui
+++ b/e-util/e-editor-builder.ui
@@ -731,576 +731,6 @@
</object>
</child>
</object>
- <object class="GtkWindow" id="table-properties-window">
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK</property>
- <property name="border_width">12</property>
- <property name="title" translatable="yes">Table Properties</property>
- <property name="resizable">False</property>
- <property name="modal">True</property>
- <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
- <property name="destroy_with_parent">True</property>
- <signal handler="gtk_widget_hide_on_delete" name="delete_event"/>
- <signal handler="gtkhtml_editor_table_properties_show_window_cb" name="show"/>
- <child>
- <object class="GtkVBox" id="table-properties-vbox">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkVBox" id="table-properties-general-vbox">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="table-properties-general-header">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">General</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- <child>
- <object class="GtkAlignment" id="table-properties-general-alignment">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="left_padding">12</property>
- <child>
- <object class="GtkHBox" id="table-properties-general-hbox">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkHBox" id="table-properties-rows-hbox">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkImage" id="table-properties-rows-image">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="icon_name">stock_select-row</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="table-properties-rows-label">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="yes">_Rows:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">table-properties-rows-spin-button</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="table-properties-rows-spin-button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="adjustment">adjustment3</property>
- <signal handler="gtkhtml_editor_table_properties_rows_changed_cb"
name="value_changed" object="table-properties-window"/>
- </object>
- <packing>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkHBox" id="table-properties-cols-hbox">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkImage" id="table-properties-cols-image">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="icon_name">stock_select-column</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="table-properties-cols-label">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="yes">C_olumns:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">table-properties-cols-spin-button</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="table-properties-cols-spin-button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="adjustment">adjustment4</property>
- <signal handler="gtkhtml_editor_table_properties_cols_changed_cb"
name="value_changed" object="table-properties-window"/>
- </object>
- <packing>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="table-properties-layout-vbox">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="table-properties-layout-header">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Layout</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- <child>
- <object class="GtkAlignment" id="table-properties-layout-alignment">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="left_padding">12</property>
- <child>
- <object class="GtkTable" id="table-properties-layout-left-table">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="n_rows">3</property>
- <property name="n_columns">7</property>
- <property name="column_spacing">6</property>
- <property name="row_spacing">6</property>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <object class="GtkLabel" id="table-properties-border-units-label">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">px</property>
- </object>
- <packing>
- <property name="left_attach">6</property>
- <property name="right_attach">7</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options"/>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="table-properties-padding-units-label">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">px</property>
- </object>
- <packing>
- <property name="left_attach">6</property>
- <property name="right_attach">7</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options"/>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="table-properties-spacing-units-label">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">px</property>
- </object>
- <packing>
- <property name="left_attach">6</property>
- <property name="right_attach">7</property>
- <property name="x_options"/>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="table-properties-width-combo-box">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <signal handler="gtkhtml_editor_table_properties_width_changed_cb" name="changed"
object="table-properties-window"/>
- <property name="model">model3</property>
- <child>
- <object class="GtkCellRendererText" id="renderer3"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="x_options"/>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="table-properties-width-spin-button">
- <property name="width_request">100</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="adjustment">adjustment5</property>
- <signal handler="gtkhtml_editor_table_properties_width_changed_cb"
name="value_changed" object="table-properties-window"/>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="table-properties-width-check-button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label" translatable="yes">_Width:</property>
- <property name="use_underline">True</property>
- <property name="xalign">1</property>
- <property name="draw_indicator">True</property>
- <signal handler="gtkhtml_editor_table_properties_width_changed_cb" name="toggled"
object="table-properties-window"/>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="table-properties-alignment-combo-box">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <signal handler="gtkhtml_editor_table_properties_alignment_changed_cb"
name="changed" object="table-properties-window"/>
- <property name="model">model4</property>
- <child>
- <object class="GtkCellRendererText" id="renderer4"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">3</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="table-properties-alignment-label">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">_Alignment:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">table-properties-alignment-combo-box</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="table-properties-spacing-label">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">_Spacing:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">table-properties-spacing-spin-button</property>
- </object>
- <packing>
- <property name="left_attach">4</property>
- <property name="right_attach">5</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="table-properties-padding-label">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">_Padding:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">table-properties-padding-spin-button</property>
- </object>
- <packing>
- <property name="left_attach">4</property>
- <property name="right_attach">5</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="table-properties-border-label">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">_Border:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">table-properties-border-spin-button</property>
- </object>
- <packing>
- <property name="left_attach">4</property>
- <property name="right_attach">5</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="table-properties-spacing-spin-button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="adjustment">adjustment6</property>
- <signal handler="gtkhtml_editor_table_properties_spacing_changed_cb"
name="value_changed" object="table-properties-window"/>
- </object>
- <packing>
- <property name="left_attach">5</property>
- <property name="right_attach">6</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="table-properties-padding-spin-button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="adjustment">adjustment7</property>
- <signal handler="gtkhtml_editor_table_properties_padding_changed_cb"
name="value_changed" object="table-properties-window"/>
- </object>
- <packing>
- <property name="left_attach">5</property>
- <property name="right_attach">6</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="table-properties-border-spin-button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="adjustment">adjustment8</property>
- <signal handler="gtkhtml_editor_table_properties_border_changed_cb"
name="value_changed" object="table-properties-window"/>
- </object>
- <packing>
- <property name="left_attach">5</property>
- <property name="right_attach">6</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="y_options"/>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="table-properties-background-vbox">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="table-properties-background-header">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Background</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- </child>
- <child>
- <object class="GtkAlignment" id="table-properties-background-alignment">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="left_padding">12</property>
- <child>
- <object class="GtkTable" id="table-properties-background-table">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="n_rows">2</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">6</property>
- <property name="row_spacing">6</property>
- <child>
- <object class="GtkLabel" id="table-properties-color-label">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">Co_lor:</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="table-properties-image-label">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">_Image:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">table-properties-image-button</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkFileChooserButton" id="table-properties-image-button">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <signal handler="gtkhtml_editor_table_properties_image_changed_cb"
name="selection_changed" object="table-properties-window"/>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="EColorCombo" id="table-properties-color-combo"
type-func="e_color_combo_get_type">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="default_color">#000000000000</property>
- <property name="default_label">Transparent</property>
- <property name="default_transparent">True</property>
- <signal handler="gtkhtml_editor_table_properties_color_changed_cb" name="changed"
object="table-properties-window"/>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkHButtonBox" id="table-properties-button-box">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="spacing">12</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
- <child>
- <object class="GtkButton" id="table-properties-close-button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label">gtk-close</property>
- <property name="use_stock">True</property>
- <signal handler="gtk_widget_hide" name="clicked" object="table-properties-window"/>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="pack_type">GTK_PACK_END</property>
- <property name="position">3</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
<object class="GtkWindow" id="page-properties-window">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">12</property>
diff --git a/e-util/e-editor-private.h b/e-util/e-editor-private.h
index 0eabc08..2c5b476 100644
--- a/e-util/e-editor-private.h
+++ b/e-util/e-editor-private.h
@@ -28,6 +28,7 @@
#include <e-editor-replace-dialog.h>
#include <e-editor-link-dialog.h>
#include <e-editor-hrule-dialog.h>
+#include <e-editor-table-dialog.h>
#ifdef HAVE_XFREE
#include <X11/XF86keysym.h>
@@ -60,6 +61,7 @@ struct _EEditorPrivate {
GtkWidget *replace_dialog;
GtkWidget *link_dialog;
GtkWidget *hrule_dialog;
+ GtkWidget *table_dialog;
GtkWidget *color_combo_box;
GtkWidget *mode_combo_box;
diff --git a/e-util/e-editor-table-dialog.c b/e-util/e-editor-table-dialog.c
new file mode 100644
index 0000000..6016aaf
--- /dev/null
+++ b/e-util/e-editor-table-dialog.c
@@ -0,0 +1,837 @@
+/*
+ * e-editor-table-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-table-dialog.h"
+
+#include <glib/gi18n-lib.h>
+
+#include "e-color-combo.h"
+#include "e-editor-utils.h"
+#include "e-image-chooser-dialog.h"
+#include "e-misc-utils.h"
+
+G_DEFINE_TYPE (
+ EEditorTableDialog,
+ e_editor_table_dialog,
+ E_TYPE_EDITOR_DIALOG);
+
+struct _EEditorTableDialogPrivate {
+ GtkWidget *rows_edit;
+ GtkWidget *columns_edit;
+
+ GtkWidget *width_edit;
+ GtkWidget *width_units;
+ GtkWidget *width_check;
+
+ GtkWidget *spacing_edit;
+ GtkWidget *padding_edit;
+ GtkWidget *border_edit;
+
+ GtkWidget *alignment_combo;
+
+ GtkWidget *background_color_button;
+ GtkWidget *background_image_button;
+ GtkWidget *image_chooser_dialog;
+
+ GtkWidget *close_button;
+
+ WebKitDOMHTMLTableElement *table_element;
+};
+
+static GdkRGBA white = { 1, 1, 1, 1 };
+
+static WebKitDOMElement *
+editor_table_dialog_create_table (EEditorTableDialog *dialog)
+{
+ EEditor *editor;
+ WebKitDOMDocument *document;
+ WebKitDOMElement *table;
+ WebKitDOMDOMWindow *window;
+ WebKitDOMDOMSelection *selection;
+ WebKitDOMRange *range;
+ gint i;
+
+ editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
+ document = webkit_web_view_get_dom_document (
+ WEBKIT_WEB_VIEW (e_editor_get_editor_widget (editor)));
+ window = webkit_dom_document_get_default_view (document);
+ selection = webkit_dom_dom_window_get_selection (window);
+ range = webkit_dom_dom_selection_get_range_at (selection, 0, NULL);
+
+ /* Default 3x3 table */
+ table = webkit_dom_document_create_element (document, "TABLE", NULL);
+ for (i = 0; i < 3; i++) {
+ WebKitDOMHTMLElement *row;
+ gint j;
+
+ row = webkit_dom_html_table_element_insert_row (
+ (WebKitDOMHTMLTableElement *) table, -1, NULL);
+
+ for (j = 0; j < 3; j++) {
+ webkit_dom_html_table_row_element_insert_cell (
+ (WebKitDOMHTMLTableRowElement *) row, -1, NULL);
+ }
+ }
+
+ webkit_dom_range_insert_node (range, WEBKIT_DOM_NODE (table), NULL);
+
+ return table;
+}
+
+static void
+editor_table_dialog_set_row_count (EEditorTableDialog *dialog)
+{
+ WebKitDOMHTMLCollection *rows;
+ gulong ii, current_count, expected_count;
+
+ g_return_if_fail (dialog->priv->table_element);
+
+ rows = webkit_dom_html_table_element_get_rows (dialog->priv->table_element);
+ current_count = webkit_dom_html_collection_get_length (rows);
+ expected_count = gtk_spin_button_get_value (
+ GTK_SPIN_BUTTON (dialog->priv->rows_edit));
+
+ if (current_count < expected_count) {
+ for (ii = 0; ii < expected_count - current_count; ii++) {
+ webkit_dom_html_table_element_insert_row (
+ dialog->priv->table_element, -1, NULL);
+ }
+ } else if (current_count > expected_count) {
+ for (ii = 0; ii < current_count - expected_count; ii++) {
+ webkit_dom_html_table_element_delete_row (
+ dialog->priv->table_element, -1, NULL);
+ }
+ }
+}
+
+static void
+editor_table_dialog_get_row_count (EEditorTableDialog *dialog)
+{
+ WebKitDOMHTMLCollection *rows;
+
+ g_return_if_fail (dialog->priv->table_element);
+
+ rows = webkit_dom_html_table_element_get_rows (dialog->priv->table_element);
+
+ gtk_spin_button_set_value (
+ GTK_SPIN_BUTTON (dialog->priv->rows_edit),
+ webkit_dom_html_collection_get_length (rows));
+}
+
+static void
+editor_table_dialog_set_column_count (EEditorTableDialog *dialog)
+{
+ WebKitDOMHTMLCollection *rows;
+ gulong ii, row_count, expected_columns;
+
+ g_return_if_fail (dialog->priv->table_element);
+
+ rows = webkit_dom_html_table_element_get_rows (dialog->priv->table_element);
+ row_count = webkit_dom_html_collection_get_length (rows);
+ expected_columns = gtk_spin_button_get_value (
+ GTK_SPIN_BUTTON (dialog->priv->columns_edit));
+
+ for (ii = 0; ii < row_count; ii++) {
+ WebKitDOMHTMLTableRowElement *row;
+ WebKitDOMHTMLCollection *cells;
+ gulong jj, current_columns;
+
+ row = (WebKitDOMHTMLTableRowElement *) (
+ webkit_dom_html_collection_item (rows, ii));
+
+ cells = webkit_dom_html_table_row_element_get_cells (row);
+ current_columns = webkit_dom_html_collection_get_length (cells);
+
+ if (current_columns < expected_columns) {
+ for (jj = 0; jj < expected_columns - current_columns; jj++) {
+ webkit_dom_html_table_row_element_insert_cell (
+ row, -1, NULL);
+ }
+ } else if (expected_columns < current_columns) {
+ for (jj = 0; jj < current_columns - expected_columns; jj++) {
+ webkit_dom_html_table_row_element_delete_cell (
+ row, -1, NULL);
+ }
+ }
+ }
+}
+
+static void
+editor_table_dialog_get_column_count (EEditorTableDialog *dialog)
+{
+ WebKitDOMHTMLCollection *rows, *columns;
+ WebKitDOMNode *row;
+
+ g_return_if_fail (dialog->priv->table_element);
+
+ rows = webkit_dom_html_table_element_get_rows (dialog->priv->table_element);
+ row = webkit_dom_html_collection_item (rows, 0);
+
+ columns = webkit_dom_html_table_row_element_get_cells (
+ (WebKitDOMHTMLTableRowElement *) row);
+
+ gtk_spin_button_set_value (
+ GTK_SPIN_BUTTON (dialog->priv->columns_edit),
+ webkit_dom_html_collection_get_length (columns));
+}
+
+static void
+editor_table_dialog_set_width (EEditorTableDialog *dialog)
+{
+ gchar *width;
+
+ g_return_if_fail (dialog->priv->table_element);
+
+ if (gtk_toggle_button_get_active (
+ GTK_TOGGLE_BUTTON (dialog->priv->width_check))) {
+
+ width = g_strdup_printf (
+ "%d%s",
+ gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (dialog->priv->width_edit)),
+ gtk_combo_box_text_get_active_text (
+ GTK_COMBO_BOX_TEXT (dialog->priv->width_units)));
+
+ gtk_widget_set_sensitive (dialog->priv->width_edit, TRUE);
+ gtk_widget_set_sensitive (dialog->priv->width_units, TRUE);
+ } else {
+ width = g_strdup ("auto");
+
+ gtk_widget_set_sensitive (dialog->priv->width_edit, FALSE);
+ gtk_widget_set_sensitive (dialog->priv->width_units, FALSE);
+ }
+
+ webkit_dom_html_table_element_set_width (
+ dialog->priv->table_element, width);
+ g_free (width);
+}
+
+static void
+editor_table_dialog_get_width (EEditorTableDialog *dialog)
+{
+ gchar *width;
+
+ width = webkit_dom_html_table_element_get_width (dialog->priv->table_element);
+ if (!width || !*width || g_ascii_strncasecmp (width, "auto", 4) == 0) {
+ gtk_toggle_button_set_active (
+ GTK_TOGGLE_BUTTON (dialog->priv->width_check), FALSE);
+ gtk_spin_button_set_value (
+ GTK_SPIN_BUTTON (dialog->priv->width_edit), 100);
+ gtk_combo_box_set_active_id (
+ GTK_COMBO_BOX (dialog->priv->width_units), "units-percent");
+ } else {
+ gint width_int = atoi (width);
+
+ gtk_toggle_button_set_active (
+ GTK_TOGGLE_BUTTON (dialog->priv->width_check), TRUE);
+ gtk_spin_button_set_value (
+ GTK_SPIN_BUTTON (dialog->priv->width_edit), width_int);
+ gtk_combo_box_set_active_id (
+ GTK_COMBO_BOX (dialog->priv->width_units),
+ ((strstr (width, "%") == NULL) ?
+ "units-px" : "units-percent"));
+ }
+}
+
+static void
+editor_table_dialog_set_alignment (EEditorTableDialog *dialog)
+{
+ g_return_if_fail (dialog->priv->table_element);
+
+ webkit_dom_html_table_element_set_align (
+ dialog->priv->table_element,
+ gtk_combo_box_get_active_id (
+ GTK_COMBO_BOX (dialog->priv->alignment_combo)));
+}
+
+static void
+editor_table_dialog_get_alignment (EEditorTableDialog *dialog)
+{
+ gchar *alignment;
+
+ g_return_if_fail (dialog->priv->table_element);
+
+ alignment = webkit_dom_html_table_element_get_align (
+ dialog->priv->table_element);
+
+ gtk_combo_box_set_active_id (
+ GTK_COMBO_BOX (dialog->priv->alignment_combo), alignment);
+
+ g_free (alignment);
+}
+
+static void
+editor_table_dialog_set_padding (EEditorTableDialog *dialog)
+{
+ gchar *padding;
+
+ g_return_if_fail (dialog->priv->table_element);
+
+ padding = g_strdup_printf ("%d",
+ gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (dialog->priv->padding_edit)));
+
+ webkit_dom_html_table_element_set_cell_padding (
+ dialog->priv->table_element, padding);
+
+ g_free (padding);
+}
+
+static void
+editor_table_dialog_get_padding (EEditorTableDialog *dialog)
+{
+ gchar *padding;
+ gint padding_int;
+
+ g_return_if_fail (dialog->priv->table_element);
+
+ padding = webkit_dom_html_table_element_get_cell_padding (
+ dialog->priv->table_element);
+ if (!padding || !*padding) {
+ padding_int = 0;
+ } else {
+ padding_int = atoi (padding);
+ }
+
+ gtk_spin_button_set_value (
+ GTK_SPIN_BUTTON (dialog->priv->padding_edit), padding_int);
+
+ g_free (padding);
+}
+
+static void
+editor_table_dialog_set_spacing (EEditorTableDialog *dialog)
+{
+ gchar *spacing;
+
+ g_return_if_fail (dialog->priv->table_element);
+
+ spacing = g_strdup_printf ("%d",
+ gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (dialog->priv->spacing_edit)));
+
+ webkit_dom_html_table_element_set_cell_spacing (
+ dialog->priv->table_element, spacing);
+
+ g_free (spacing);
+}
+
+static void
+editor_table_dialog_get_spacing (EEditorTableDialog *dialog)
+{
+ gchar *spacing;
+ gint spacing_int;
+
+ g_return_if_fail (dialog->priv->table_element);
+
+ spacing = webkit_dom_html_table_element_get_cell_spacing (
+ dialog->priv->table_element);
+ if (!spacing || !*spacing) {
+ spacing_int = 0;
+ } else {
+ spacing_int = atoi (spacing);
+ }
+
+ gtk_spin_button_set_value (
+ GTK_SPIN_BUTTON (dialog->priv->spacing_edit), spacing_int);
+
+ g_free (spacing);
+}
+
+static void
+editor_table_dialog_set_border (EEditorTableDialog *dialog)
+{
+ gchar *border;
+
+ g_return_if_fail (dialog->priv->table_element);
+
+ border = g_strdup_printf ("%d",
+ gtk_spin_button_get_value_as_int (
+ GTK_SPIN_BUTTON (dialog->priv->border_edit)));
+
+ webkit_dom_html_table_element_set_border (
+ dialog->priv->table_element, border);
+
+ g_free (border);
+}
+
+static void
+editor_table_dialog_get_border (EEditorTableDialog *dialog)
+{
+ gchar *border;
+ gint border_int;
+
+ g_return_if_fail (dialog->priv->table_element);
+
+ border = webkit_dom_html_table_element_get_border (
+ dialog->priv->table_element);
+ if (!border || !*border) {
+ border_int = 0;
+ } else {
+ border_int = atoi (border);
+ }
+
+ gtk_spin_button_set_value (
+ GTK_SPIN_BUTTON (dialog->priv->border_edit), border_int);
+
+ g_free (border);
+}
+
+static void
+editor_table_dialog_set_background_color (EEditorTableDialog *dialog)
+{
+ gchar *color;
+ GdkRGBA rgba;
+
+ g_return_if_fail (dialog->priv->table_element);
+
+ e_color_combo_get_current_color (
+ E_COLOR_COMBO (dialog->priv->background_color_button), &rgba);
+ color = g_strdup_printf (
+ "#%06x", e_rgba_to_value (&rgba));
+
+ webkit_dom_html_table_element_set_bg_color (
+ dialog->priv->table_element, color);
+
+ g_free (color);
+}
+
+static void
+editor_table_dialog_get_background_color (EEditorTableDialog *dialog)
+{
+ gchar *color;
+ GdkRGBA rgba;
+
+ g_return_if_fail (dialog->priv->table_element);
+
+ color = webkit_dom_html_table_element_get_bg_color (
+ dialog->priv->table_element);
+
+ gdk_rgba_parse (&rgba, color);
+
+ e_color_combo_set_current_color (
+ E_COLOR_COMBO (dialog->priv->background_color_button), &rgba);
+
+ g_free (color);
+}
+
+static void
+editor_table_dialog_set_background_image (EEditorTableDialog *dialog)
+{
+ const gchar *filename;
+
+ g_return_if_fail (dialog->priv->table_element);
+
+ filename = gtk_file_chooser_get_filename (
+ GTK_FILE_CHOOSER (dialog->priv->background_image_button));
+
+ if (filename) {
+ webkit_dom_element_set_attribute (
+ WEBKIT_DOM_ELEMENT (dialog->priv->table_element),
+ "background", filename, NULL);
+ } else {
+ webkit_dom_element_remove_attribute (
+ WEBKIT_DOM_ELEMENT (dialog->priv->table_element),
+ "background");
+ }
+}
+
+static void
+editor_table_dialog_get_background_image (EEditorTableDialog *dialog)
+{
+ g_return_if_fail (dialog->priv->table_element);
+
+ if (!webkit_dom_element_has_attribute (
+ WEBKIT_DOM_ELEMENT (dialog->priv->table_element), "background")) {
+
+ gtk_file_chooser_unselect_all(
+ GTK_FILE_CHOOSER (dialog->priv->background_image_button));
+ return;
+ } else {
+ gchar *background;
+
+ background = webkit_dom_element_get_attribute (
+ WEBKIT_DOM_ELEMENT (dialog->priv->table_element), "background");
+
+ gtk_file_chooser_set_filename (
+ GTK_FILE_CHOOSER (dialog->priv->background_image_button),
+ background);
+
+ g_free (background);
+ }
+}
+
+static void
+editor_table_dialog_close (EEditorTableDialog *dialog)
+{
+ gtk_widget_hide (GTK_WIDGET (dialog));
+
+ dialog->priv->table_element = NULL;
+}
+
+static void
+editor_table_dialog_get_values (EEditorTableDialog *dialog)
+{
+ editor_table_dialog_get_row_count (dialog);
+ editor_table_dialog_get_column_count (dialog);
+ editor_table_dialog_get_width (dialog);
+ editor_table_dialog_get_alignment (dialog);
+ editor_table_dialog_get_spacing (dialog);
+ editor_table_dialog_get_padding (dialog);
+ editor_table_dialog_get_border (dialog);
+ editor_table_dialog_get_background_color (dialog);
+ editor_table_dialog_get_background_image (dialog);
+}
+
+static void
+editor_table_dialog_reset_values (EEditorTableDialog *dialog)
+{
+ gtk_spin_button_set_value (
+ GTK_SPIN_BUTTON (dialog->priv->rows_edit), 3);
+ gtk_spin_button_set_value (
+ GTK_SPIN_BUTTON (dialog->priv->columns_edit), 3);
+ gtk_combo_box_set_active_id (
+ GTK_COMBO_BOX (dialog->priv->alignment_combo), "left");
+
+ gtk_toggle_button_set_active (
+ GTK_TOGGLE_BUTTON (dialog->priv->width_check), TRUE);
+ gtk_spin_button_set_value (
+ GTK_SPIN_BUTTON (dialog->priv->width_edit), 100);
+ gtk_combo_box_set_active_id (
+ GTK_COMBO_BOX (dialog->priv->width_units), "units-percent");
+
+ gtk_spin_button_set_value (
+ GTK_SPIN_BUTTON (dialog->priv->spacing_edit), 2);
+ gtk_spin_button_set_value (
+ GTK_SPIN_BUTTON (dialog->priv->padding_edit), 1);
+ gtk_spin_button_set_value (
+ GTK_SPIN_BUTTON (dialog->priv->border_edit), 1);
+
+ e_color_combo_set_current_color (
+ E_COLOR_COMBO (dialog->priv->background_color_button), &white);
+ gtk_file_chooser_unselect_all (
+ GTK_FILE_CHOOSER (dialog->priv->background_image_button));
+
+ editor_table_dialog_set_row_count (dialog);
+ editor_table_dialog_set_column_count (dialog);
+ editor_table_dialog_set_width (dialog);
+ editor_table_dialog_set_alignment (dialog);
+ editor_table_dialog_set_spacing (dialog);
+ editor_table_dialog_set_padding (dialog);
+ editor_table_dialog_set_border (dialog);
+ editor_table_dialog_set_background_color (dialog);
+ editor_table_dialog_set_background_image (dialog);
+}
+
+
+static void
+editor_table_dialog_show (GtkWidget *widget)
+{
+ EEditorTableDialog *dialog;
+ EEditor *editor;
+ EEditorWidget *editor_widget;
+ WebKitDOMDocument *document;
+ WebKitDOMDOMWindow *window;
+ WebKitDOMDOMSelection *selection;
+
+ dialog = E_EDITOR_TABLE_DIALOG (widget);
+ editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
+ editor_widget = e_editor_get_editor_widget (editor);
+
+ document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (editor_widget));
+ window = webkit_dom_document_get_default_view (document);
+ selection = webkit_dom_dom_window_get_selection (window);
+ if (selection && (webkit_dom_dom_selection_get_range_count (selection) > 0)) {
+ WebKitDOMElement *table;
+ WebKitDOMRange *range;
+
+ range = webkit_dom_dom_selection_get_range_at (selection, 0, NULL);
+ table = e_editor_dom_node_get_parent_element (
+ webkit_dom_range_get_start_container (range, NULL),
+ WEBKIT_TYPE_DOM_HTML_TABLE_ELEMENT);
+
+ if (!table) {
+ dialog->priv->table_element = (WebKitDOMHTMLTableElement *)
+ editor_table_dialog_create_table (dialog);
+ editor_table_dialog_reset_values (dialog);
+ } else {
+ dialog->priv->table_element =
+ (WebKitDOMHTMLTableElement *) table;
+ editor_table_dialog_get_values (dialog);
+ }
+ }
+
+ /* Chain up to parent implementation */
+ GTK_WIDGET_CLASS (e_editor_table_dialog_parent_class)->show (widget);
+}
+
+static void
+e_editor_table_dialog_class_init (EEditorTableDialogClass *klass)
+{
+ GtkWidgetClass *widget_class;
+
+ g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (EEditorTableDialogPrivate));
+
+ widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class->show = editor_table_dialog_show;
+}
+
+static void
+e_editor_table_dialog_init (EEditorTableDialog *dialog)
+{
+ GtkBox *main_layout, *box;
+ GtkGrid *grid;
+ GtkWidget *widget;
+ GtkFileFilter *file_filter;
+
+ dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
+ dialog, E_TYPE_EDITOR_TABLE_DIALOG, EEditorTableDialogPrivate);
+
+ 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);
+
+ /* Rows */
+ widget = gtk_image_new_from_icon_name ("stock_select-row", GTK_ICON_SIZE_BUTTON);
+ gtk_grid_attach (grid, widget, 0, 0, 1, 1);
+
+ widget = gtk_spin_button_new_with_range (1, G_MAXINT, 1);
+ gtk_spin_button_set_digits (GTK_SPIN_BUTTON (widget), 0);
+ gtk_grid_attach (grid, widget, 2, 0, 1, 1);
+ g_signal_connect_swapped (
+ widget, "value-changed",
+ G_CALLBACK (editor_table_dialog_set_row_count), dialog);
+ dialog->priv->rows_edit = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("_Rows:"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->rows_edit);
+ gtk_grid_attach (grid, widget, 1, 0, 1, 1);
+
+ /* Columns */
+ widget = gtk_image_new_from_icon_name ("stock_select-column", GTK_ICON_SIZE_BUTTON);
+ gtk_grid_attach (grid, widget, 3, 0, 1, 1);
+
+ widget = gtk_spin_button_new_with_range (1, G_MAXINT, 1);
+ gtk_spin_button_set_digits (GTK_SPIN_BUTTON (widget), 0);
+ gtk_grid_attach (grid, widget, 5, 0, 1, 1);
+ g_signal_connect_swapped (
+ widget, "value-changed",
+ G_CALLBACK (editor_table_dialog_set_column_count), dialog);
+ dialog->priv->columns_edit = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("C_olumns:"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->columns_edit);
+ gtk_grid_attach (grid, widget, 4, 0, 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_check_button_new_with_mnemonic (_("Width:"));
+ gtk_grid_attach (grid, widget, 0, 0, 1, 1);
+ g_signal_connect_swapped (
+ widget, "toggled",
+ G_CALLBACK (editor_table_dialog_set_width), dialog);
+ dialog->priv->width_check = widget;
+
+ widget = gtk_spin_button_new_with_range (1, 100, 1);
+ gtk_spin_button_set_digits (GTK_SPIN_BUTTON (widget), 0);
+ gtk_grid_attach (grid, widget, 1, 0, 1, 1);
+ g_signal_connect_swapped (
+ widget, "value-changed",
+ G_CALLBACK (editor_table_dialog_set_width), dialog);
+ dialog->priv->width_edit = widget;
+
+ 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_grid_attach (grid, widget, 2, 0, 1, 1);
+ g_signal_connect_swapped (
+ widget, "changed",
+ G_CALLBACK (editor_table_dialog_set_width), dialog);
+ dialog->priv->width_units = widget;
+
+ /* Spacing */
+ widget = gtk_spin_button_new_with_range (0, G_MAXINT, 1);
+ gtk_spin_button_set_digits (GTK_SPIN_BUTTON (widget), 0);
+ gtk_grid_attach (grid, widget, 5, 0, 1, 1);
+ g_signal_connect_swapped (
+ widget, "value-changed",
+ G_CALLBACK (editor_table_dialog_set_spacing), dialog);
+ dialog->priv->spacing_edit = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("_Spacing:"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->spacing_edit);
+ gtk_grid_attach (grid, widget, 4, 0, 1, 1);
+
+ widget = gtk_label_new ("px");
+ gtk_grid_attach (grid, widget, 6, 0, 1, 1);
+
+ /* Padding */
+ widget = gtk_spin_button_new_with_range (0, G_MAXINT, 1);
+ gtk_spin_button_set_digits (GTK_SPIN_BUTTON (widget), 0);
+ gtk_grid_attach (grid, widget, 5, 1, 1, 1);
+ g_signal_connect_swapped (
+ widget, "value-changed",
+ G_CALLBACK (editor_table_dialog_set_padding), dialog);
+ dialog->priv->padding_edit = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("_Padding:"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->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_MAXINT, 1);
+ gtk_spin_button_set_digits (GTK_SPIN_BUTTON (widget), 0);
+ gtk_grid_attach (grid, widget, 5, 2, 1, 1);
+ g_signal_connect_swapped (
+ widget, "value-changed",
+ G_CALLBACK (editor_table_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);
+
+ /* Alignment */
+ widget = gtk_combo_box_text_new ();
+ gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), "left", _("Left"));
+ gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), "center", _("Center"));
+ gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), "right", _("Right"));
+ gtk_grid_attach (grid, widget, 1, 1, 2, 1);
+ g_signal_connect_swapped (
+ widget, "changed",
+ G_CALLBACK (editor_table_dialog_set_alignment), dialog);
+ dialog->priv->alignment_combo = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("_Alignment:"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->alignment_combo);
+ gtk_grid_attach (grid, widget, 0, 1, 1, 1);
+
+ /* == Background == */
+ widget = gtk_label_new ("");
+ gtk_label_set_markup (GTK_LABEL (widget), _("<b>Background</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);
+
+ /* Color */
+ widget = e_color_combo_new ();
+ e_color_combo_set_default_color (E_COLOR_COMBO (widget), &white);
+ gtk_widget_set_hexpand (widget, TRUE);
+ gtk_grid_attach (grid, widget, 1, 0, 1, 1);
+ g_signal_connect_swapped (
+ widget, "notify::current-color",
+ G_CALLBACK (editor_table_dialog_set_background_color), dialog);
+ dialog->priv->background_color_button = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("_Color:"));
+ gtk_label_set_mnemonic_widget (
+ GTK_LABEL (widget), dialog->priv->background_color_button);
+ gtk_grid_attach (grid, widget, 0, 0, 1, 1);
+
+ /* Image */
+ widget = e_image_chooser_dialog_new (
+ _("Choose Background Image"),
+ GTK_WINDOW (dialog));
+ dialog->priv->image_chooser_dialog = widget;
+
+ 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 (
+ dialog->priv->image_chooser_dialog);
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (widget), file_filter);
+ gtk_widget_set_hexpand (widget, TRUE);
+ gtk_grid_attach (grid, widget, 1, 1, 1, 1);
+ g_signal_connect_swapped (
+ widget, "file-set",
+ G_CALLBACK (editor_table_dialog_set_background_image), dialog);
+ dialog->priv->background_image_button = widget;
+
+
+ widget =gtk_label_new_with_mnemonic (_("Image:"));
+ gtk_label_set_mnemonic_widget (
+ GTK_LABEL (widget), dialog->priv->background_image_button);
+ gtk_grid_attach (grid, widget, 0, 1, 1, 1);
+
+ /* == Button box == */
+ box = GTK_BOX (gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL));
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (box), GTK_BUTTONBOX_END);
+ gtk_box_pack_start (main_layout, GTK_WIDGET (box), TRUE, TRUE, 0);
+
+ widget = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
+ gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
+ g_signal_connect_swapped (
+ widget, "clicked",
+ G_CALLBACK (editor_table_dialog_close), dialog);
+ dialog->priv->close_button = widget;
+
+ gtk_widget_show_all (GTK_WIDGET (main_layout));
+}
+
+GtkWidget *
+e_editor_table_dialog_new (EEditor *editor)
+{
+ return GTK_WIDGET (
+ g_object_new (
+ E_TYPE_EDITOR_TABLE_DIALOG,
+ "editor", editor,
+ "title", N_("Table Properties"),
+ NULL));
+}
+
diff --git a/e-util/e-editor-table-dialog.h b/e-util/e-editor-table-dialog.h
new file mode 100644
index 0000000..8bcca33
--- /dev/null
+++ b/e-util/e-editor-table-dialog.h
@@ -0,0 +1,69 @@
+/*
+ * e-editor-table-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_TABLE_DIALOG_H
+#define E_EDITOR_TABLE_DIALOG_H
+
+#include <e-util/e-editor-dialog.h>
+
+/* Standard GObject macros */
+#define E_TYPE_EDITOR_TABLE_DIALOG \
+ (e_editor_table_dialog_get_type ())
+#define E_EDITOR_TABLE_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_EDITOR_TABLE_DIALOG, EEditorTableDialog))
+#define E_EDITOR_TABLE_DIALOG_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_EDITOR_TABLE_DIALOG, EEditorTableDialogClass))
+#define E_IS_EDITOR_TABLE_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_EDITOR_TABLE_DIALOG))
+#define E_IS_EDITOR_TABLE_DIALOG_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_EDITOR_TABLE_DIALOG))
+#define E_EDITOR_TABLE_DIALOG_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_EDITOR_TABLE_DIALOG, EEditorTableDialogClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EEditorTableDialog EEditorTableDialog;
+typedef struct _EEditorTableDialogClass EEditorTableDialogClass;
+typedef struct _EEditorTableDialogPrivate EEditorTableDialogPrivate;
+
+struct _EEditorTableDialog {
+ EEditorDialog parent;
+
+ EEditorTableDialogPrivate *priv;
+};
+
+struct _EEditorTableDialogClass {
+ EEditorDialogClass parent_class;
+};
+
+GType e_editor_table_dialog_get_type (void);
+
+GtkWidget* e_editor_table_dialog_new (EEditor *editor);
+
+G_END_DECLS
+
+#endif /* E_EDITOR_TABLE_DIALOG_H */
diff --git a/e-util/e-editor-utils.c b/e-util/e-editor-utils.c
index efac42b..29ca04c 100644
--- a/e-util/e-editor-utils.c
+++ b/e-util/e-editor-utils.c
@@ -42,7 +42,6 @@ WebKitDOMElement *
e_editor_dom_node_find_child_element (WebKitDOMNode *node,
GType child_type)
{
- WebKitDOMElement *link;
WebKitDOMNode *start_node = node;
do {
diff --git a/e-util/e-editor-widgets.h b/e-util/e-editor-widgets.h
index 5901c4e..ee8f818 100644
--- a/e-util/e-editor-widgets.h
+++ b/e-util/e-editor-widgets.h
@@ -117,32 +117,6 @@
#define E_EDITOR_WIDGETS_SPELL_WINDOW(editor) \
E_EDITOR_WIDGETS ((editor), "spell-window")
-/* Table Properties Window */
-#define E_EDITOR_WIDGETS_TABLE_PROPERTIES_ALIGNMENT_COMBO_BOX(editor) \
- E_EDITOR_WIDGETS ((editor), "table-properties-alignment-combo-box")
-#define E_EDITOR_WIDGETS_TABLE_PROPERTIES_BORDER_SPIN_BUTTON(editor) \
- E_EDITOR_WIDGETS ((editor), "table-properties-border-spin-button")
-#define E_EDITOR_WIDGETS_TABLE_PROPERTIES_COLOR_COMBO(editor) \
- E_EDITOR_WIDGETS ((editor), "table-properties-color-combo")
-#define E_EDITOR_WIDGETS_TABLE_PROPERTIES_COLS_SPIN_BUTTON(editor) \
- E_EDITOR_WIDGETS ((editor), "table-properties-cols-spin-button")
-#define E_EDITOR_WIDGETS_TABLE_PROPERTIES_IMAGE_BUTTON(editor) \
- E_EDITOR_WIDGETS ((editor), "table-properties-image-button")
-#define E_EDITOR_WIDGETS_TABLE_PROPERTIES_PADDING_SPIN_BUTTON(editor) \
- E_EDITOR_WIDGETS ((editor), "table-properties-padding-spin-button")
-#define E_EDITOR_WIDGETS_TABLE_PROPERTIES_ROWS_SPIN_BUTTON(editor) \
- E_EDITOR_WIDGETS ((editor), "table-properties-rows-spin-button")
-#define E_EDITOR_WIDGETS_TABLE_PROPERTIES_SPACING_SPIN_BUTTON(editor) \
- E_EDITOR_WIDGETS ((editor), "table-properties-spacing-spin-button")
-#define E_EDITOR_WIDGETS_TABLE_PROPERTIES_WIDTH_CHECK_BUTTON(editor) \
- E_EDITOR_WIDGETS ((editor), "table-properties-width-check-button")
-#define E_EDITOR_WIDGETS_TABLE_PROPERTIES_WIDTH_COMBO_BOX(editor) \
- E_EDITOR_WIDGETS ((editor), "table-properties-width-combo-box")
-#define E_EDITOR_WIDGETS_TABLE_PROPERTIES_WIDTH_SPIN_BUTTON(editor) \
- E_EDITOR_WIDGETS ((editor), "table-properties-width-spin-button")
-#define E_EDITOR_WIDGETS_TABLE_PROPERTIES_WINDOW(editor) \
- E_EDITOR_WIDGETS ((editor), "table-properties-window")
-
/* Text Properties Window */
#define E_EDITOR_WIDGETS_TEXT_PROPERTIES_BOLD_BUTTON(editor) \
E_EDITOR_WIDGETS ((editor), "text-properties-bold-button")
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 5b8bb90..9a8ac3a 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -99,6 +99,7 @@
#include <e-util/e-editor-link-dialog.h>
#include <e-util/e-editor-replace-dialog.h>
#include <e-util/e-editor-selection.h>
+#include <e-util/e-editor-table-dialog.h>
#include <e-util/e-editor-utils.h>
#include <e-util/e-editor-widget.h>
#include <e-util/e-editor-widgets.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]