[evolution/webkit-composer: 39/130] Make 'Text Properties' dialog work



commit d9e9618ce7220a857076dd7b6d3ee13cbeca90e9
Author: Dan VrÃtil <dvratil redhat com>
Date:   Tue Aug 14 13:24:53 2012 +0200

    Make 'Text Properties' dialog work
    
    Implement Text Properties dialog as EEditorTextDialog class.

 e-util/Makefile.am            |    2 +
 e-util/e-editor-actions.c     |    7 +-
 e-util/e-editor-builder.ui    |  256 ---------------------------------
 e-util/e-editor-private.h     |    2 +
 e-util/e-editor-text-dialog.c |  313 +++++++++++++++++++++++++++++++++++++++++
 e-util/e-editor-text-dialog.h |   69 +++++++++
 e-util/e-util.h               |    1 +
 7 files changed, 393 insertions(+), 257 deletions(-)
---
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index f3295ff..7e5dd84 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -181,6 +181,7 @@ eutilinclude_HEADERS =  \
 	e-editor-replace-dialog.h \
 	e-editor-selection.h \
 	e-editor-table-dialog.h \
+	e-editor-text-dialog.h \
 	e-editor-utils.h \
 	e-editor-widget.h \
 	e-editor-widgets.h \
@@ -449,6 +450,7 @@ libeutil_la_SOURCES = \
 	e-editor-replace-dialog.c \
 	e-editor-selection.c \
 	e-editor-table-dialog.c \
+	e-editor-text-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 f61be4a..05bfef0 100644
--- a/e-util/e-editor-actions.c
+++ b/e-util/e-editor-actions.c
@@ -975,7 +975,12 @@ static void
 action_properties_text_cb (GtkAction *action,
                            EEditor *editor)
 {
-	gtk_window_present (GTK_WINDOW (WIDGET (TEXT_PROPERTIES_WINDOW)));
+	if (editor->priv->text_dialog == NULL) {
+		editor->priv->text_dialog =
+			e_editor_text_dialog_new (editor);
+	}
+
+	gtk_window_present (GTK_WINDOW (editor->priv->text_dialog));
 }
 
 static void
diff --git a/e-util/e-editor-builder.ui b/e-util/e-editor-builder.ui
index 50e220f..1e4aa1e 100644
--- a/e-util/e-editor-builder.ui
+++ b/e-util/e-editor-builder.ui
@@ -285,262 +285,6 @@
       </row>
     </data>
   </object>
-  <object class="GtkWindow" id="text-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="title" translatable="yes">Text 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"/>
-    <child>
-      <object class="GtkVBox" id="text-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="border_width">12</property>
-        <property name="spacing">12</property>
-        <child>
-          <object class="GtkHBox" id="text-properties-inner-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="border_width">6</property>
-            <property name="spacing">12</property>
-            <child>
-              <object class="GtkTable" id="text-properties-table-left">
-                <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">4</property>
-                <property name="n_columns">2</property>
-                <property name="column_spacing">6</property>
-                <property name="row_spacing">6</property>
-                <child>
-                  <object class="GtkCheckButton" id="text-properties-strikethrough-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">_Strikethrough</property>
-                    <property name="use_underline">True</property>
-                    <property name="draw_indicator">True</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                    <property name="y_options"/>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkCheckButton" id="text-properties-underline-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">_Underline</property>
-                    <property name="use_underline">True</property>
-                    <property name="draw_indicator">True</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                    <property name="y_options"/>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkCheckButton" id="text-properties-italic-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">_Italic</property>
-                    <property name="use_underline">True</property>
-                    <property name="draw_indicator">True</property>
-                  </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="GtkCheckButton" id="text-properties-bold-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">_Bold</property>
-                    <property name="use_underline">True</property>
-                    <property name="draw_indicator">True</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="y_options"/>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkImage" id="text-properties-strikethrough-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="stock">gtk-strikethrough</property>
-                  </object>
-                  <packing>
-                    <property name="top_attach">3</property>
-                    <property name="bottom_attach">4</property>
-                    <property name="x_options"/>
-                    <property name="y_options"/>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkImage" id="text-properties-underline-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="stock">gtk-underline</property>
-                  </object>
-                  <packing>
-                    <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="GtkImage" id="text-properties-italic-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="stock">gtk-italic</property>
-                  </object>
-                  <packing>
-                    <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="GtkImage" id="text-properties-bold-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="stock">gtk-bold</property>
-                  </object>
-                  <packing>
-                    <property name="x_options"/>
-                    <property name="y_options"/>
-                  </packing>
-                </child>
-              </object>
-            </child>
-            <child>
-              <object class="GtkTable" id="text-properties-table-right">
-                <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">2</property>
-                <property name="column_spacing">6</property>
-                <property name="row_spacing">6</property>
-                <child>
-                  <object class="EColorCombo" id="text-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_label">Automatic</property>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="y_options">GTK_FILL</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkLabel" id="text-properties-size-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">Si_ze:</property>
-                    <property name="use_underline">True</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="text-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="label" translatable="yes">_Color:</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="GtkAlignment" id="text-properties-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>
-                    <child>
-                      <placeholder/>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="right_attach">2</property>
-                    <property name="top_attach">2</property>
-                    <property name="bottom_attach">3</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="EActionComboBox" id="text-properties-size-combo-box" type-func="e_action_combo_box_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>
-                  </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>
-              </object>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-        </child>
-        <child>
-          <object class="GtkHButtonBox" id="text-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="layout_style">GTK_BUTTONBOX_END</property>
-            <child>
-              <object class="GtkButton" id="text-properties-ok-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-ok</property>
-                <property name="use_stock">True</property>
-                <signal handler="gtk_widget_hide" name="clicked" object="text-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">1</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-  </object>
   <object class="GtkWindow" id="paragraph-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="title" translatable="yes">Paragraph Properties</property>
diff --git a/e-util/e-editor-private.h b/e-util/e-editor-private.h
index 77bb54e..d5dae99 100644
--- a/e-util/e-editor-private.h
+++ b/e-util/e-editor-private.h
@@ -31,6 +31,7 @@
 #include <e-editor-table-dialog.h>
 #include <e-editor-page-dialog.h>
 #include <e-editor-image-dialog.h>
+#include <e-editor-text-dialog.h>
 
 #ifdef HAVE_XFREE
 #include <X11/XF86keysym.h>
@@ -66,6 +67,7 @@ struct _EEditorPrivate {
 	GtkWidget *table_dialog;
 	GtkWidget *page_dialog;
 	GtkWidget *image_dialog;
+	GtkWidget *text_dialog;
 
 	GtkWidget *color_combo_box;
 	GtkWidget *mode_combo_box;
diff --git a/e-util/e-editor-text-dialog.c b/e-util/e-editor-text-dialog.c
new file mode 100644
index 0000000..0563256
--- /dev/null
+++ b/e-util/e-editor-text-dialog.c
@@ -0,0 +1,313 @@
+/*
+ * e-editor-text-dialog.c
+ *
+ * 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-text-dialog.h"
+
+#include <glib/gi18n-lib.h>
+
+#include "e-color-combo.h"
+
+G_DEFINE_TYPE (
+	EEditorTextDialog,
+	e_editor_text_dialog,
+	E_TYPE_EDITOR_DIALOG);
+
+struct _EEditorTextDialogPrivate {
+	GtkWidget *bold_check;
+	GtkWidget *italic_check;
+	GtkWidget *underline_check;
+	GtkWidget *strikethrough_check;
+
+	GtkWidget *color_check;
+	GtkWidget *size_check;
+
+	GtkWidget *close_button;
+};
+
+
+static void
+editor_text_dialog_set_bold (EEditorTextDialog *dialog)
+{
+	EEditor *editor;
+	EEditorWidget *widget;
+	EEditorSelection *selection;
+
+	editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
+	widget = e_editor_get_editor_widget (editor);
+	selection = e_editor_widget_get_selection (widget);
+
+	e_editor_selection_set_bold (
+		selection,
+		gtk_toggle_button_get_active (
+			GTK_TOGGLE_BUTTON (dialog->priv->bold_check)));
+}
+
+static void
+editor_text_dialog_set_italic (EEditorTextDialog *dialog)
+{
+	EEditor *editor;
+	EEditorWidget *widget;
+	EEditorSelection *selection;
+
+	editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
+	widget = e_editor_get_editor_widget (editor);
+	selection = e_editor_widget_get_selection (widget);
+
+	e_editor_selection_set_italic (
+		selection,
+		gtk_toggle_button_get_active (
+			GTK_TOGGLE_BUTTON (dialog->priv->italic_check)));
+}
+
+static void
+editor_text_dialog_set_underline (EEditorTextDialog *dialog)
+{
+	EEditor *editor;
+	EEditorWidget *widget;
+	EEditorSelection *selection;
+
+	editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
+	widget = e_editor_get_editor_widget (editor);
+	selection = e_editor_widget_get_selection (widget);
+
+	e_editor_selection_set_underline (
+		selection,
+		gtk_toggle_button_get_active (
+			GTK_TOGGLE_BUTTON (dialog->priv->underline_check)));
+}
+
+static void
+editor_text_dialog_set_strikethrough (EEditorTextDialog *dialog)
+{
+	EEditor *editor;
+	EEditorWidget *widget;
+	EEditorSelection *selection;
+
+	editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
+	widget = e_editor_get_editor_widget (editor);
+	selection = e_editor_widget_get_selection (widget);
+
+	e_editor_selection_set_strike_through (
+		selection,
+		gtk_toggle_button_get_active (
+			GTK_TOGGLE_BUTTON (dialog->priv->strikethrough_check)));
+}
+
+static void
+editor_text_dialog_set_color (EEditorTextDialog *dialog)
+{
+	EEditor *editor;
+	EEditorWidget *widget;
+	EEditorSelection *selection;
+	GdkRGBA rgba;
+
+	editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
+	widget = e_editor_get_editor_widget (editor);
+	selection = e_editor_widget_get_selection (widget);
+
+	e_color_combo_get_current_color (
+		E_COLOR_COMBO (dialog->priv->color_check), &rgba);
+	e_editor_selection_set_font_color (selection, &rgba);
+}
+
+static void
+editor_text_dialog_set_size (EEditorTextDialog *dialog)
+{
+	EEditor *editor;
+	EEditorWidget *widget;
+	EEditorSelection *selection;
+	gint size;
+
+	editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
+	widget = e_editor_get_editor_widget (editor);
+	selection = e_editor_widget_get_selection (widget);
+	size = gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->priv->size_check));
+
+	e_editor_selection_set_font_size (selection, size + 1);
+}
+
+static void
+editor_text_dialog_show (GtkWidget *gtk_widget)
+{
+	EEditorTextDialog *dialog;
+	EEditor *editor;
+	EEditorWidget *widget;
+	EEditorSelection *selection;
+	GdkRGBA rgba;
+
+	dialog = E_EDITOR_TEXT_DIALOG (gtk_widget);
+	editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
+	widget = e_editor_get_editor_widget (editor);
+	selection = e_editor_widget_get_selection (widget);
+
+	gtk_toggle_button_set_active (
+		GTK_TOGGLE_BUTTON (dialog->priv->bold_check),
+		e_editor_selection_get_bold (selection));
+	gtk_toggle_button_set_active (
+		GTK_TOGGLE_BUTTON (dialog->priv->italic_check),
+		e_editor_selection_get_italic (selection));
+	gtk_toggle_button_set_active (
+		GTK_TOGGLE_BUTTON (dialog->priv->underline_check),
+		e_editor_selection_get_underline (selection));
+	gtk_toggle_button_set_active (
+		GTK_TOGGLE_BUTTON (dialog->priv->strikethrough_check),
+		e_editor_selection_get_strike_through (selection));
+
+	gtk_combo_box_set_active (
+		GTK_COMBO_BOX (dialog->priv->size_check),
+		e_editor_selection_get_font_size (selection));
+
+	e_editor_selection_get_font_color (selection, &rgba);
+	e_color_combo_set_current_color (
+		E_COLOR_COMBO (dialog->priv->color_check), &rgba);
+
+	GTK_WIDGET_CLASS (e_editor_text_dialog_parent_class)->show (gtk_widget);
+}
+
+static void
+e_editor_text_dialog_class_init (EEditorTextDialogClass *klass)
+{
+	GtkWidgetClass *widget_class;
+
+	e_editor_text_dialog_parent_class = g_type_class_peek_parent (klass);
+	g_type_class_add_private (klass, sizeof (EEditorTextDialogPrivate));
+
+	widget_class = GTK_WIDGET_CLASS (klass);
+	widget_class->show = editor_text_dialog_show;
+}
+
+static void
+e_editor_text_dialog_init (EEditorTextDialog *dialog)
+{
+	GtkGrid *main_layout;
+	GtkWidget *widget;
+
+	dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
+		dialog, E_TYPE_EDITOR_TEXT_DIALOG, EEditorTextDialogPrivate);
+
+	main_layout = GTK_GRID (gtk_grid_new ());
+	gtk_grid_set_row_spacing (main_layout, 5);
+	gtk_grid_set_column_spacing (main_layout, 5);
+	gtk_container_add (GTK_CONTAINER (dialog), GTK_WIDGET (main_layout));
+	gtk_container_set_border_width (GTK_CONTAINER (dialog), 10);
+
+	/* Bold */
+	widget = gtk_image_new_from_stock (GTK_STOCK_BOLD, GTK_ICON_SIZE_BUTTON);
+	gtk_grid_attach (main_layout, widget, 0, 0, 1, 1);
+
+	widget = gtk_check_button_new_with_mnemonic (_("Bold"));
+	gtk_grid_attach (main_layout, widget, 1, 0, 1, 1);
+	g_signal_connect_swapped (
+		widget, "toggled",
+		G_CALLBACK (editor_text_dialog_set_bold), dialog);
+	dialog->priv->bold_check = widget;
+
+	/* Italic */
+	widget = gtk_image_new_from_stock (GTK_STOCK_ITALIC, GTK_ICON_SIZE_BUTTON);
+	gtk_grid_attach (main_layout, widget, 0, 1, 1, 1);
+
+	widget = gtk_check_button_new_with_mnemonic (_("Italic"));
+	gtk_grid_attach (main_layout, widget, 1, 1, 1, 1);
+	g_signal_connect_swapped (
+		widget, "toggled",
+		G_CALLBACK (editor_text_dialog_set_italic), dialog);
+	dialog->priv->italic_check = widget;
+
+	/* Underline */
+	widget = gtk_image_new_from_stock (GTK_STOCK_UNDERLINE, GTK_ICON_SIZE_BUTTON);
+	gtk_grid_attach (main_layout, widget, 0, 2, 1, 1);
+
+	widget = gtk_check_button_new_with_mnemonic (_("Underline"));
+	gtk_grid_attach (main_layout, widget, 1, 2, 1, 1);
+	g_signal_connect_swapped (
+		widget, "toggled",
+		G_CALLBACK (editor_text_dialog_set_underline), dialog);
+	dialog->priv->underline_check = widget;
+
+	widget = gtk_image_new_from_stock (GTK_STOCK_STRIKETHROUGH, GTK_ICON_SIZE_BUTTON);
+	gtk_grid_attach (main_layout, widget, 0, 3, 1, 1);
+
+	widget = gtk_check_button_new_with_mnemonic (_("Strikethrough"));
+	gtk_grid_attach (main_layout, widget, 1, 3, 1, 1);
+	g_signal_connect_swapped (
+		widget, "toggled",
+		G_CALLBACK (editor_text_dialog_set_strikethrough), dialog);
+	dialog->priv->strikethrough_check = widget;
+
+	/* Color */
+	widget = e_color_combo_new ();
+	gtk_grid_attach (main_layout, widget, 3, 0, 1, 1);
+	g_signal_connect_swapped (
+		widget, "notify::current-color",
+		G_CALLBACK (editor_text_dialog_set_color), dialog);
+	dialog->priv->color_check = widget;
+
+	widget = gtk_label_new_with_mnemonic (_("Color:"));
+	gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->color_check);
+	gtk_grid_attach (main_layout, widget, 2, 0, 1, 1);
+
+	/* Size */
+	widget = gtk_combo_box_text_new ();
+	gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), "minus-two", "-2");
+	gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), "minus-one", "-1");
+	gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), "minus-zero", "0");
+	gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), "plus-one", "+1");
+	gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), "plus-two", "+2");
+	gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), "plus-three", "+3");
+	gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (widget), "plus-four", "+4");
+	gtk_grid_attach (main_layout, widget, 3, 1, 1, 1);
+	g_signal_connect_swapped (
+		widget, "changed",
+		G_CALLBACK (editor_text_dialog_set_size), dialog);
+	dialog->priv->size_check = widget;
+
+	widget = gtk_label_new_with_mnemonic (_("Size:"));
+	gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->size_check);
+	gtk_grid_attach (main_layout, widget, 2, 1, 1, 1);
+
+	/* Close button */
+	widget = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
+	g_signal_connect_swapped (
+		widget, "clicked",
+		G_CALLBACK (gtk_widget_hide), 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_container_set_border_width (GTK_CONTAINER (widget), 5);
+	gtk_grid_attach (main_layout, widget, 0, 4, 4, 1);
+	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_text_dialog_new (EEditor *editor)
+{
+	return GTK_WIDGET (
+		g_object_new (
+			E_TYPE_EDITOR_TEXT_DIALOG,
+			"editor", editor,
+			"title", N_("Text Properties"),
+			NULL));
+}
diff --git a/e-util/e-editor-text-dialog.h b/e-util/e-editor-text-dialog.h
new file mode 100644
index 0000000..f660f4e
--- /dev/null
+++ b/e-util/e-editor-text-dialog.h
@@ -0,0 +1,69 @@
+/*
+ * e-editor-text-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_TEXT_DIALOG_H
+#define E_EDITOR_TEXT_DIALOG_H
+
+#include <e-util/e-editor-dialog.h>
+
+/* Standard GObject macros */
+#define E_TYPE_EDITOR_TEXT_DIALOG \
+	(e_editor_text_dialog_get_type ())
+#define E_EDITOR_TEXT_DIALOG(obj) \
+	(G_TYPE_CHECK_INSTANCE_CAST \
+	((obj), E_TYPE_EDITOR_TEXT_DIALOG, EEditorTextDialog))
+#define E_EDITOR_TEXT_DIALOG_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_CAST \
+	((cls), E_TYPE_EDITOR_TEXT_DIALOG, EEditorTextDialogClass))
+#define E_IS_EDITOR_TEXT_DIALOG(obj) \
+	(G_TYPE_CHECK_INSTANCE_TYPE \
+	((obj), E_TYPE_EDITOR_TEXT_DIALOG))
+#define E_IS_EDITOR_TEXT_DIALOG_CLASS(cls) \
+	(G_TYPE_CHECK_CLASS_TYPE \
+	((cls), E_TYPE_EDITOR_TEXT_DIALOG))
+#define E_EDITOR_TEXT_DIALOG_GET_CLASS(obj) \
+	(G_TYPE_INSTANCE_GET_CLASS \
+	((obj), E_TYPE_EDITOR_TEXT_DIALOG, EEditorTextDialogClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EEditorTextDialog EEditorTextDialog;
+typedef struct _EEditorTextDialogClass EEditorTextDialogClass;
+typedef struct _EEditorTextDialogPrivate EEditorTextDialogPrivate;
+
+struct _EEditorTextDialog {
+	EEditorDialog parent;
+
+	EEditorTextDialogPrivate *priv;
+};
+
+struct _EEditorTextDialogClass {
+	EEditorDialogClass parent_class;
+};
+
+GType		e_editor_text_dialog_get_type	(void);
+
+GtkWidget*	e_editor_text_dialog_new	(EEditor *editor);
+
+G_END_DECLS
+
+#endif /* E_EDITOR_TEXT_DIALOG_H */
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 445c7bb..bf19c1d 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -100,6 +100,7 @@
 #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-text-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]