[evolution/wip/webkit-composer: 541/966] Make inserting a auto-replacing emoticons work
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit-composer: 541/966] Make inserting a auto-replacing emoticons work
- Date: Wed, 23 Apr 2014 10:38:54 +0000 (UTC)
commit cb2c442e0aa73357858b593b72244ef2b8b2d5d9
Author: Dan Vrátil <dvratil redhat com>
Date: Thu Aug 9 10:28:59 2012 +0200
Make inserting a auto-replacing emoticons work
The algorithm for magic smileys is taken from GtkHTML
(I admit I don't 100% understand how it works), because
it's quick and known to work quite well.
TODO: It would be nice to automagically replace emoticons
in pasted and inserted text as well.
e-util/e-editor-actions.c | 46 +++-------
e-util/e-editor-widget.c | 175 +++++++++++++++++++++++++++++++++++++-
e-util/e-emoticon-chooser-menu.c | 81 ------------------
e-util/e-emoticon-chooser.c | 78 -----------------
e-util/e-emoticon-chooser.h | 33 +-------
e-util/e-emoticon-tool-button.c | 141 ------------------------------
e-util/e-emoticon.c | 41 ---------
e-util/e-emoticon.h | 2 +
8 files changed, 189 insertions(+), 408 deletions(-)
---
diff --git a/e-util/e-editor-actions.c b/e-util/e-editor-actions.c
index 0e6fdee..c09c63d 100644
--- a/e-util/e-editor-actions.c
+++ b/e-util/e-editor-actions.c
@@ -30,6 +30,7 @@
#include "e-editor-private.h"
#include "e-editor-widgets.h"
#include "e-emoticon-action.h"
+#include "e-emoticon-chooser.h"
#include "e-image-chooser-dialog.h"
static void
@@ -569,45 +570,24 @@ action_indent_cb (GtkAction *action,
static void
action_insert_emoticon_cb (GtkAction *action,
- EEditor *editor)
+ EEditor *editor)
{
- /* FIXME WEBKIT
- GtkHTML *html;
- HTMLObject *image;
- GtkIconInfo *icon_info;
- GtkIconTheme *icon_theme;
- GtkhtmlFaceChooser *chooser;
- GtkhtmlFace *face;
- const gchar *filename;
+ EEditorWidget *widget;
+ EEditorSelection *selection;
+ EEmoticonChooser *chooser;
+ EEmoticon *emoticon;
gchar *uri = NULL;
- html = gtkhtml_editor_get_html (editor);
+ chooser = E_EMOTICON_CHOOSER (action);
+ emoticon = e_emoticon_chooser_get_current_emoticon (chooser);
+ g_return_if_fail (emoticon != NULL);
- chooser = GTKHTML_FACE_CHOOSER (action);
- face = gtkhtml_face_chooser_get_current_face (chooser);
- g_return_if_fail (face != NULL);
-
- icon_theme = gtk_icon_theme_get_default ();
- icon_info = gtk_icon_theme_lookup_icon (
- icon_theme, face->icon_name, 16, 0);
- g_return_if_fail (icon_info != NULL);
-
- filename = gtk_icon_info_get_filename (icon_info);
- if (filename != NULL)
- uri = g_filename_to_uri (filename, NULL, NULL);
- gtk_icon_info_free (icon_info);
- g_return_if_fail (uri != NULL);
-
- image = html_image_new (
- html_engine_get_image_factory (html->engine),
- uri, NULL, NULL, -1, -1, FALSE, FALSE, 0, NULL,
- HTML_VALIGN_MIDDLE, FALSE);
- html_image_set_alt (HTML_IMAGE (image), face->text_face);
- html_engine_paste_object (
- html->engine, image, html_object_get_length (image));
+ uri = e_emoticon_get_uri (emoticon);
+ widget = e_editor_get_editor_widget (editor);
+ selection = e_editor_widget_get_selection (widget);
+ e_editor_selection_insert_image (selection, uri);
g_free (uri);
- */
}
static void
diff --git a/e-util/e-editor-widget.c b/e-util/e-editor-widget.c
index 4b55200..f5fed8c 100644
--- a/e-util/e-editor-widget.c
+++ b/e-util/e-editor-widget.c
@@ -22,8 +22,10 @@
#include "e-editor-widget.h"
#include "e-editor.h"
+#include "e-emoticon-chooser.h"
#include <glib/gi18n-lib.h>
+#include <gdk/gdkkeysyms.h>
struct _EEditorWidgetPrivate {
gint changed : 1;
@@ -47,8 +49,7 @@ struct _EEditorWidgetPrivate {
G_DEFINE_TYPE (
EEditorWidget,
e_editor_widget,
- WEBKIT_TYPE_WEB_VIEW
-);
+ WEBKIT_TYPE_WEB_VIEW);
enum {
PROP_0,
@@ -65,6 +66,24 @@ enum {
PROP_CAN_UNDO
};
+static WebKitDOMRange *
+editor_widget_get_dom_range (EEditorWidget *widget)
+{
+ WebKitDOMDocument *document;
+ WebKitDOMDOMWindow *window;
+ WebKitDOMDOMSelection *selection;
+
+ document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (widget));
+ 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 NULL;
+ }
+
+ return webkit_dom_dom_selection_get_range_at (selection, 0, NULL);
+}
+
static void
editor_widget_strip_formatting (EEditorWidget *widget)
{
@@ -129,6 +148,154 @@ editor_widget_selection_changed_cb (EEditorWidget *widget,
}
}
+/* Based on original use_pictograms() from GtkHTML */
+static const gchar *emoticons_chars =
+ /* 0 */ "DO)(|/PQ*!"
+ /* 10 */ "S\0:-\0:\0:-\0"
+ /* 20 */ ":\0:;=-\"\0:;"
+ /* 30 */ "B\"|\0:-'\0:X"
+ /* 40 */ "\0:\0:-\0:\0:-"
+ /* 50 */ "\0:\0:-\0:\0:-"
+ /* 60 */ "\0:\0:\0:-\0:\0"
+ /* 70 */ ":-\0:\0:-\0:\0";
+static gint emoticons_states[] = {
+ /* 0 */ 12, 17, 22, 34, 43, 48, 53, 58, 65, 70,
+ /* 10 */ 75, 0, -15, 15, 0, -15, 0, -17, 20, 0,
+ /* 20 */ -17, 0, -14, -20, -14, 28, 63, 0, -14, -20,
+ /* 30 */ -3, 63, -18, 0, -12, 38, 41, 0, -12, -2,
+ /* 40 */ 0, -4, 0, -10, 46, 0, -10, 0, -19, 51,
+ /* 50 */ 0, -19, 0, -11, 56, 0, -11, 0, -13, 61,
+ /* 60 */ 0, -13, 0, -6, 0, 68, -7, 0, -7, 0,
+ /* 70 */ -16, 73, 0, -16, 0, -21, 78, 0, -21, 0 };
+static const gchar *emoticons_icon_names[] = {
+ "face-angel",
+ "face-angry",
+ "face-cool",
+ "face-crying",
+ "face-devilish",
+ "face-embarrassed",
+ "face-kiss",
+ "face-laugh", /* not used */
+ "face-monkey", /* not used */
+ "face-plain",
+ "face-raspberry",
+ "face-sad",
+ "face-sick",
+ "face-smile",
+ "face-smile-big",
+ "face-smirk",
+ "face-surprise",
+ "face-tired",
+ "face-uncertain",
+ "face-wink",
+ "face-worried"
+};
+
+static void
+editor_widget_check_magic_smileys (EEditorWidget *widget,
+ WebKitDOMRange *range)
+{
+ gint pos;
+ gint state;
+ gint relative;
+ gint start;
+ gchar *node_text;
+ gunichar uc;
+ WebKitDOMNode *node;
+
+ node = webkit_dom_range_get_end_container (range, NULL);
+ if (!webkit_dom_node_get_node_type (node) == 3) {
+ return;
+ }
+
+ node_text = webkit_dom_text_get_whole_text ((WebKitDOMText *) node);
+ start = webkit_dom_range_get_end_offset (range, NULL) - 1;
+ pos = start;
+ state = 0;
+ while (pos >= 0) {
+ uc = g_utf8_get_char (g_utf8_offset_to_pointer (node_text, pos));
+ relative = 0;
+ while (emoticons_chars[state + relative]) {
+ if (emoticons_chars[state + relative] == uc)
+ break;
+ relative++;
+ }
+ state = emoticons_states[state + relative];
+ /* 0 .. not found, -n .. found n-th */
+ if (state <= 0)
+ break;
+ pos--;
+ }
+
+ /* Special case needed to recognize angel and devilish. */
+ if (pos > 0 && state == -14) {
+ uc = g_utf8_get_char (g_utf8_offset_to_pointer (node_text, pos - 1));
+ if (uc == 'O') {
+ state = -1;
+ pos--;
+ } else if (uc == '>') {
+ state = -5;
+ pos--;
+ }
+ }
+
+ if (state < 0) {
+ GtkIconInfo *icon_info;
+ const gchar *filename;
+ gchar *filename_uri;
+ WebKitDOMDocument *document;
+ WebKitDOMDOMWindow *window;
+ WebKitDOMDOMSelection *selection;
+
+ if (pos > 0) {
+ uc = g_utf8_get_char (g_utf8_offset_to_pointer (node_text, pos - 1));
+ if (uc != ' ' && uc != '\t')
+ return;
+ }
+
+ /* Select the text-smiley and replace it by <img> */
+ document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (widget));
+ window = webkit_dom_document_get_default_view (document);
+ selection = webkit_dom_dom_window_get_selection (window);
+ webkit_dom_dom_selection_set_base_and_extent (
+ selection, webkit_dom_range_get_end_container (range, NULL),
+ pos, webkit_dom_range_get_end_container (range, NULL),
+ start + 1, NULL);
+
+ /* Convert a named icon to a file URI. */
+ icon_info = gtk_icon_theme_lookup_icon (
+ gtk_icon_theme_get_default (),
+ emoticons_icon_names[-state - 1], 16, 0);
+ g_return_if_fail (icon_info != NULL);
+ filename = gtk_icon_info_get_filename (icon_info);
+ g_return_if_fail (filename != NULL);
+ filename_uri = g_filename_to_uri (filename, NULL, NULL);
+
+ e_editor_selection_insert_image (
+ widget->priv->selection, filename_uri);
+
+ g_free (filename_uri);
+ gtk_icon_info_free (icon_info);
+ }
+}
+
+static gboolean
+editor_widget_key_release_event (GtkWidget *gtk_widget,
+ GdkEventKey *event)
+{
+ WebKitDOMRange *range;
+ EEditorWidget *widget = E_EDITOR_WIDGET (gtk_widget);
+
+ range = editor_widget_get_dom_range (widget);
+
+ if (widget->priv->magic_smileys) {
+ editor_widget_check_magic_smileys (widget, range);
+ }
+
+ /* Propagate the event to WebKit */
+ return FALSE;
+}
+
static void
e_editor_widget_get_property (GObject *object,
guint property_id,
@@ -251,6 +418,7 @@ static void
e_editor_widget_class_init (EEditorWidgetClass *klass)
{
GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
g_type_class_add_private (klass, sizeof (EEditorWidgetPrivate));
@@ -259,6 +427,9 @@ e_editor_widget_class_init (EEditorWidgetClass *klass)
object_class->set_property = e_editor_widget_set_property;
object_class->finalize = e_editor_widget_finalize;
+ widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class->key_release_event = editor_widget_key_release_event;
+
g_object_class_install_property (
object_class,
PROP_MODE,
diff --git a/e-util/e-emoticon-chooser-menu.c b/e-util/e-emoticon-chooser-menu.c
index d51a774..7bf6184 100644
--- a/e-util/e-emoticon-chooser-menu.c
+++ b/e-util/e-emoticon-chooser-menu.c
@@ -1,12 +1,4 @@
-<<<<<<< HEAD
-/*
- * e-emoticon-chooser-menu.c
- *
- * Copyright (C) 2008 Novell, Inc.
- * Copyright (C) 2012 Dan Vrátil <dvratil redhat com>
-=======
/* e-emoticon-chooser-menu.c
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU Lesser General Public
@@ -37,25 +29,6 @@ enum {
PROP_CURRENT_FACE
};
-<<<<<<< HEAD
-/* Forward Declarations */
-static void e_emoticon_chooser_menu_interface_init
- (EEmoticonChooserInterface *interface);
-
-G_DEFINE_TYPE_WITH_CODE (
- EEmoticonChooserMenu,
- e_emoticon_chooser_menu,
- GTK_TYPE_MENU,
- G_IMPLEMENT_INTERFACE (
- E_TYPE_EMOTICON_CHOOSER,
- e_emoticon_chooser_menu_interface_init))
-
-static void
-emoticon_chooser_menu_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-=======
static gpointer parent_class;
static void
@@ -63,7 +36,6 @@ emoticon_chooser_menu_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
{
switch (property_id) {
case PROP_CURRENT_FACE:
@@ -78,15 +50,9 @@ emoticon_chooser_menu_set_property (GObject *object,
static void
emoticon_chooser_menu_get_property (GObject *object,
-<<<<<<< HEAD
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-=======
guint property_id,
GValue *value,
GParamSpec *pspec)
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
{
switch (property_id) {
case PROP_CURRENT_FACE:
@@ -114,11 +80,7 @@ emoticon_chooser_menu_get_current_emoticon (EEmoticonChooser *chooser)
static void
emoticon_chooser_menu_set_current_emoticon (EEmoticonChooser *chooser,
-<<<<<<< HEAD
- EEmoticon *emoticon)
-=======
EEmoticon *emoticon)
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
{
GList *list, *iter;
@@ -143,19 +105,12 @@ emoticon_chooser_menu_set_current_emoticon (EEmoticonChooser *chooser,
}
static void
-<<<<<<< HEAD
-e_emoticon_chooser_menu_class_init (EEmoticonChooserMenuClass *class)
-{
- GObjectClass *object_class;
-
-=======
emoticon_chooser_menu_class_init (EEmoticonChooserMenuClass *class)
{
GObjectClass *object_class;
parent_class = g_type_class_peek_parent (class);
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
object_class = G_OBJECT_CLASS (class);
object_class->set_property = emoticon_chooser_menu_set_property;
object_class->get_property = emoticon_chooser_menu_get_property;
@@ -165,18 +120,6 @@ emoticon_chooser_menu_class_init (EEmoticonChooserMenuClass *class)
}
static void
-<<<<<<< HEAD
-e_emoticon_chooser_menu_interface_init (EEmoticonChooserInterface *interface)
-{
- interface->get_current_emoticon =
- emoticon_chooser_menu_get_current_emoticon;
- interface->set_current_emoticon =
- emoticon_chooser_menu_set_current_emoticon;
-}
-
-static void
-e_emoticon_chooser_menu_init (EEmoticonChooserMenu *chooser_menu)
-=======
emoticon_chooser_menu_iface_init (EEmoticonChooserIface *iface)
{
iface->get_current_emoticon = emoticon_chooser_menu_get_current_emoticon;
@@ -185,34 +128,14 @@ emoticon_chooser_menu_iface_init (EEmoticonChooserIface *iface)
static void
emoticon_chooser_menu_init (EEmoticonChooserMenu *chooser_menu)
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
{
EEmoticonChooser *chooser;
GList *list, *iter;
chooser = E_EMOTICON_CHOOSER (chooser_menu);
-<<<<<<< HEAD
list = e_emoticon_chooser_get_items ();
for (iter = list; iter != NULL; iter = iter->next) {
- EEmoticon *emoticon = iter->data;
- GtkWidget *item;
-
- /* To keep translated strings in subclasses */
- item = gtk_image_menu_item_new_with_mnemonic (_(emoticon->label));
- gtk_image_menu_item_set_image (
- GTK_IMAGE_MENU_ITEM (item),
- gtk_image_new_from_icon_name (
- emoticon->icon_name, GTK_ICON_SIZE_MENU));
- gtk_widget_show (item);
-
- g_object_set_data_full (
- G_OBJECT (item), "emoticon",
- e_emoticon_copy (emoticon),
-=======
- list = e_emoticon_chooser_get_items (chooser);
-
- for (iter = list; iter != NULL; iter = iter->next) {
EEmoticon *face = iter->data;
GtkWidget *item;
@@ -227,7 +150,6 @@ emoticon_chooser_menu_init (EEmoticonChooserMenu *chooser_menu)
g_object_set_data_full (
G_OBJECT (item), "face",
e_emoticon_copy (face),
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
(GDestroyNotify) e_emoticon_free);
g_signal_connect_swapped (
@@ -241,8 +163,6 @@ emoticon_chooser_menu_init (EEmoticonChooserMenu *chooser_menu)
g_list_free (list);
}
-<<<<<<< HEAD
-=======
GType
e_emoticon_chooser_menu_get_type (void)
{
@@ -279,7 +199,6 @@ e_emoticon_chooser_menu_get_type (void)
return type;
}
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
GtkWidget *
e_emoticon_chooser_menu_new (void)
{
diff --git a/e-util/e-emoticon-chooser.c b/e-util/e-emoticon-chooser.c
index 7bcaf57..8136f2c 100644
--- a/e-util/e-emoticon-chooser.c
+++ b/e-util/e-emoticon-chooser.c
@@ -1,12 +1,4 @@
-<<<<<<< HEAD
-/*
- * e-emoticon-chooser.c
- *
- * Copyright (C) 2008 Novell, Inc.
- * Copyright (C) 2012 Dan Vrátil <dvratil redhat com>
-=======
/* e-emoticon-chooser.c
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU Lesser General Public
@@ -90,24 +82,11 @@ enum {
static guint signals[LAST_SIGNAL];
-<<<<<<< HEAD
-G_DEFINE_INTERFACE (
- EEmoticonChooser,
- e_emoticon_chooser,
- G_TYPE_OBJECT)
-
-static void
-e_emoticon_chooser_default_init (EEmoticonChooserInterface *interface)
-{
- g_object_interface_install_property (
- interface,
-=======
static void
emoticon_chooser_class_init (EEmoticonChooserIface *iface)
{
g_object_interface_install_property (
iface,
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
g_param_spec_boxed (
"current-emoticon",
"Current Emoticon",
@@ -117,33 +96,14 @@ emoticon_chooser_class_init (EEmoticonChooserIface *iface)
signals[ITEM_ACTIVATED] = g_signal_new (
"item-activated",
-<<<<<<< HEAD
- G_TYPE_FROM_INTERFACE (interface),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EEmoticonChooserInterface, item_activated),
-=======
G_TYPE_FROM_INTERFACE (iface),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EEmoticonChooserIface, item_activated),
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}
-<<<<<<< HEAD
-EEmoticon *
-e_emoticon_chooser_get_current_emoticon (EEmoticonChooser *chooser)
-{
- EEmoticonChooserInterface *interface;
-
- g_return_val_if_fail (E_IS_EMOTICON_CHOOSER (chooser), NULL);
-
- interface = E_EMOTICON_CHOOSER_GET_INTERFACE (chooser);
- g_return_val_if_fail (interface->get_current_emoticon != NULL, NULL);
-
- return interface->get_current_emoticon (chooser);
-=======
GType
e_emoticon_chooser_get_type (void)
{
@@ -183,23 +143,10 @@ e_emoticon_chooser_get_current_emoticon (EEmoticonChooser *chooser)
g_return_val_if_fail (iface->get_current_emoticon != NULL, NULL);
return iface->get_current_emoticon (chooser);
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
}
void
e_emoticon_chooser_set_current_emoticon (EEmoticonChooser *chooser,
-<<<<<<< HEAD
- EEmoticon *emoticon)
-{
- EEmoticonChooserInterface *interface;
-
- g_return_if_fail (E_IS_EMOTICON_CHOOSER (chooser));
-
- interface = E_EMOTICON_CHOOSER_GET_INTERFACE (chooser);
- g_return_if_fail (interface->set_current_emoticon != NULL);
-
- interface->set_current_emoticon (chooser, emoticon);
-=======
EEmoticon *emoticon)
{
EEmoticonChooserIface *iface;
@@ -210,7 +157,6 @@ e_emoticon_chooser_set_current_emoticon (EEmoticonChooser *chooser,
g_return_if_fail (iface->set_current_emoticon != NULL);
iface->set_current_emoticon (chooser, emoticon);
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
}
void
@@ -222,11 +168,7 @@ e_emoticon_chooser_item_activated (EEmoticonChooser *chooser)
}
GList *
-<<<<<<< HEAD
e_emoticon_chooser_get_items (void)
-=======
-e_emoticon_chooser_get_items (EEmoticonChooser *chooser)
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
{
GList *list = NULL;
gint ii;
@@ -236,23 +178,3 @@ e_emoticon_chooser_get_items (EEmoticonChooser *chooser)
return g_list_reverse (list);
}
-<<<<<<< HEAD
-
-const EEmoticon *
-e_emoticon_chooser_lookup_emoticon (const gchar *icon_name)
-{
- gint ii;
-
- g_return_val_if_fail (icon_name && *icon_name, NULL);
-
- for (ii = 0; ii < G_N_ELEMENTS (available_emoticons); ii++) {
- if (strcmp (available_emoticons[ii].icon_name, icon_name) == 0) {
- return (const EEmoticon *) &available_emoticons[ii];
- }
- }
-
- return NULL;
-}
-
-=======
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
diff --git a/e-util/e-emoticon-chooser.h b/e-util/e-emoticon-chooser.h
index a7b0e1d..a134c7e 100644
--- a/e-util/e-emoticon-chooser.h
+++ b/e-util/e-emoticon-chooser.h
@@ -1,12 +1,4 @@
-<<<<<<< HEAD
-/*
- * e-emoticon-chooser.h
- *
- * Copyright (C) 2008 Novell, Inc.
- * Copyright (C) 2012 Dan Vrátil <dvratil redhat com>
-=======
/* e-emoticon-chooser.h
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU Lesser General Public
@@ -41,30 +33,17 @@
#define E_IS_EMOTICON_CHOOSER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE \
((obj), E_TYPE_EMOTICON_CHOOSER))
-<<<<<<< HEAD
-#define E_EMOTICON_CHOOSER_GET_INTERFACE(obj) \
- (G_TYPE_INSTANCE_GET_INTERFACE \
- ((obj), E_TYPE_EMOTICON_CHOOSER, EEmoticonChooserInterface))
-=======
#define E_EMOTICON_CHOOSER_GET_IFACE(obj) \
(G_TYPE_INSTANCE_GET_INTERFACE \
((obj), E_TYPE_EMOTICON_CHOOSER, EEmoticonChooserIface))
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
G_BEGIN_DECLS
typedef struct _EEmoticonChooser EEmoticonChooser;
-<<<<<<< HEAD
-typedef struct _EEmoticonChooserInterface EEmoticonChooserInterface;
-
-struct _EEmoticonChooserInterface {
- GTypeInterface parent_interface;
-=======
typedef struct _EEmoticonChooserIface EEmoticonChooserIface;
struct _EEmoticonChooserIface {
GTypeInterface parent_iface;
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
/* Methods */
EEmoticon * (*get_current_emoticon) (EEmoticonChooser *chooser);
@@ -75,11 +54,8 @@ struct _EEmoticonChooserIface {
void (*item_activated) (EEmoticonChooser *chooser);
};
-<<<<<<< HEAD
-GType e_emoticon_chooser_get_type (void) G_GNUC_CONST;
-=======
GType e_emoticon_chooser_get_type (void);
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
+
EEmoticon * e_emoticon_chooser_get_current_emoticon
(EEmoticonChooser *chooser);
void e_emoticon_chooser_set_current_emoticon
@@ -87,15 +63,8 @@ void e_emoticon_chooser_set_current_emoticon
EEmoticon *emoticon);
void e_emoticon_chooser_item_activated
(EEmoticonChooser *chooser);
-<<<<<<< HEAD
GList * e_emoticon_chooser_get_items (void);
-const EEmoticon *
- e_emoticon_chooser_lookup_emoticon
- (const gchar *icon_name);
-=======
-GList * e_emoticon_chooser_get_items (EEmoticonChooser *chooser);
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
G_END_DECLS
diff --git a/e-util/e-emoticon-tool-button.c b/e-util/e-emoticon-tool-button.c
index 3c3dd49..eaf2105 100644
--- a/e-util/e-emoticon-tool-button.c
+++ b/e-util/e-emoticon-tool-button.c
@@ -1,12 +1,4 @@
-<<<<<<< HEAD
-/*
- * e-emoticon-tool-button.c
- *
- * Copyright (C) 2008 Novell, Inc.
- * Copyright (C) 2012 Dan Vrátil <dvratil redhat com>
-=======
/* e-emoticon-tool-button.c
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU Lesser General Public
@@ -39,13 +31,6 @@
#include "e-emoticon-chooser.h"
-<<<<<<< HEAD
-#define E_EMOTICON_TOOL_BUTTON_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_EMOTICON_TOOL_BUTTON, EEmoticonToolButtonPrivate))
-
-=======
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
/* XXX Should calculate this dynamically. */
#define NUM_ROWS 7
#define NUM_COLS 3
@@ -73,26 +58,9 @@ struct _EEmoticonToolButtonPrivate {
GdkDevice *grab_mouse;
};
-<<<<<<< HEAD
-static guint signals[LAST_SIGNAL];
-
-/* Forward Declarations */
-static void e_emoticon_tool_button_interface_init
- (EEmoticonChooserInterface *interface);
-
-G_DEFINE_TYPE_WITH_CODE (
- EEmoticonToolButton,
- e_emoticon_tool_button,
- GTK_TYPE_TOGGLE_TOOL_BUTTON,
- G_IMPLEMENT_INTERFACE (
- E_TYPE_EMOTICON_CHOOSER,
- e_emoticon_tool_button_interface_init))
-
-=======
static gpointer parent_class;
static guint signals[LAST_SIGNAL];
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
/* XXX Copied from _gtk_toolbar_elide_underscores() */
static gchar *
emoticon_tool_button_elide_underscores (const gchar *original)
@@ -169,11 +137,7 @@ emoticon_tool_button_reposition_window (EEmoticonToolButton *button)
static void
emoticon_tool_button_emoticon_clicked_cb (EEmoticonToolButton *button,
-<<<<<<< HEAD
- GtkWidget *emoticon_button)
-=======
GtkWidget *emoticon_button)
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
{
button->priv->active_button = emoticon_button;
e_emoticon_tool_button_popdown (button);
@@ -181,13 +145,8 @@ emoticon_tool_button_emoticon_clicked_cb (EEmoticonToolButton *button,
static gboolean
emoticon_tool_button_emoticon_release_event_cb (EEmoticonToolButton *button,
-<<<<<<< HEAD
- GdkEventButton *event,
- GtkButton *emoticon_button)
-=======
GdkEventButton *event,
GtkButton *emoticon_button)
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
{
GtkStateType state;
@@ -201,11 +160,7 @@ emoticon_tool_button_emoticon_release_event_cb (EEmoticonToolButton *button,
static gboolean
emoticon_tool_button_button_release_event_cb (EEmoticonToolButton *button,
-<<<<<<< HEAD
- GdkEventButton *event)
-=======
GdkEventButton *event)
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
{
GtkToggleToolButton *tool_button;
GtkWidget *event_widget;
@@ -250,11 +205,7 @@ emoticon_tool_button_child_hide_cb (EEmoticonToolButton *button)
static gboolean
emoticon_tool_button_child_key_press_event_cb (EEmoticonToolButton *button,
-<<<<<<< HEAD
- GdkEventKey *event)
-=======
GdkEventKey *event)
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
{
GtkWidget *window = button->priv->window;
@@ -266,15 +217,9 @@ emoticon_tool_button_child_key_press_event_cb (EEmoticonToolButton *button,
static void
emoticon_tool_button_set_property (GObject *object,
-<<<<<<< HEAD
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-=======
guint property_id,
const GValue *value,
GParamSpec *pspec)
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
{
switch (property_id) {
case PROP_CURRENT_EMOTICON:
@@ -298,15 +243,6 @@ emoticon_tool_button_set_property (GObject *object,
static void
emoticon_tool_button_get_property (GObject *object,
-<<<<<<< HEAD
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EEmoticonToolButtonPrivate *priv;
-
- priv = E_EMOTICON_TOOL_BUTTON_GET_PRIVATE (object);
-=======
guint property_id,
GValue *value,
GParamSpec *pspec)
@@ -314,7 +250,6 @@ emoticon_tool_button_get_property (GObject *object,
EEmoticonToolButtonPrivate *priv;
priv = E_EMOTICON_TOOL_BUTTON (object)->priv;
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
switch (property_id) {
case PROP_CURRENT_EMOTICON:
@@ -337,35 +272,20 @@ emoticon_tool_button_dispose (GObject *object)
{
EEmoticonToolButtonPrivate *priv;
-<<<<<<< HEAD
- priv = E_EMOTICON_TOOL_BUTTON_GET_PRIVATE (object);
-
- if (priv->window != NULL) {
- gtk_widget_destroy (priv->window);
-=======
priv = E_EMOTICON_TOOL_BUTTON (object)->priv;
if (priv->window != NULL) {
g_object_unref (priv->window);
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
priv->window = NULL;
}
/* Chain up to parent's dispose() method. */
-<<<<<<< HEAD
- G_OBJECT_CLASS (e_emoticon_tool_button_parent_class)->dispose (object);
-=======
G_OBJECT_CLASS (parent_class)->dispose (object);
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
}
static gboolean
emoticon_tool_button_press_event (GtkWidget *widget,
-<<<<<<< HEAD
- GdkEventButton *event)
-=======
GdkEventButton *event)
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
{
EEmoticonToolButton *button;
GtkToggleToolButton *toggle_button;
@@ -444,12 +364,7 @@ emoticon_tool_button_popup (EEmoticonToolButton *button)
/* Try to grab the pointer and keyboard. */
window = gtk_widget_get_window (button->priv->window);
grab_status = !keyboard ||
-<<<<<<< HEAD
- gdk_device_grab (
- keyboard, window,
-=======
gdk_device_grab (keyboard, window,
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
GDK_OWNERSHIP_WINDOW, TRUE,
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
NULL, activate_time) == GDK_GRAB_SUCCESS;
@@ -505,11 +420,7 @@ emoticon_tool_button_get_current_emoticon (EEmoticonChooser *chooser)
{
EEmoticonToolButtonPrivate *priv;
-<<<<<<< HEAD
- priv = E_EMOTICON_TOOL_BUTTON_GET_PRIVATE (chooser);
-=======
priv = E_EMOTICON_TOOL_BUTTON (chooser)->priv;
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
if (priv->active_button == NULL)
return NULL;
@@ -519,20 +430,12 @@ emoticon_tool_button_get_current_emoticon (EEmoticonChooser *chooser)
static void
emoticon_tool_button_set_current_emoticon (EEmoticonChooser *chooser,
-<<<<<<< HEAD
- EEmoticon *emoticon)
-=======
EEmoticon *emoticon)
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
{
EEmoticonToolButtonPrivate *priv;
GList *list, *iter;
-<<<<<<< HEAD
- priv = E_EMOTICON_TOOL_BUTTON_GET_PRIVATE (chooser);
-=======
priv = E_EMOTICON_TOOL_BUTTON (chooser)->priv;
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
list = gtk_container_get_children (GTK_CONTAINER (priv->table));
@@ -554,20 +457,13 @@ emoticon_tool_button_set_current_emoticon (EEmoticonChooser *chooser,
}
static void
-<<<<<<< HEAD
-e_emoticon_tool_button_class_init (EEmoticonToolButtonClass *class)
-=======
emoticon_tool_button_class_init (EEmoticonToolButtonClass *class)
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkToggleToolButtonClass *toggle_tool_button_class;
-<<<<<<< HEAD
-=======
parent_class = g_type_class_peek_parent (class);
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
g_type_class_add_private (class, sizeof (EEmoticonToolButtonPrivate));
object_class = G_OBJECT_CLASS (class);
@@ -634,18 +530,6 @@ emoticon_tool_button_class_init (EEmoticonToolButtonClass *class)
}
static void
-<<<<<<< HEAD
-e_emoticon_tool_button_interface_init (EEmoticonChooserInterface *interface)
-{
- interface->get_current_emoticon =
- emoticon_tool_button_get_current_emoticon;
- interface->set_current_emoticon =
- emoticon_tool_button_set_current_emoticon;
-}
-
-static void
-e_emoticon_tool_button_init (EEmoticonToolButton *button)
-=======
emoticon_tool_button_iemoticon_init (EEmoticonChooserIface *iemoticon)
{
iemoticon->get_current_emoticon = emoticon_tool_button_get_current_emoticon;
@@ -654,7 +538,6 @@ emoticon_tool_button_iemoticon_init (EEmoticonChooserIface *iemoticon)
static void
emoticon_tool_button_init (EEmoticonToolButton *button)
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
{
EEmoticonChooser *chooser;
GtkWidget *toplevel;
@@ -664,42 +547,25 @@ emoticon_tool_button_init (EEmoticonToolButton *button)
GList *list, *iter;
gint ii;
-<<<<<<< HEAD
- button->priv = E_EMOTICON_TOOL_BUTTON_GET_PRIVATE (button);
-=======
button->priv = G_TYPE_INSTANCE_GET_PRIVATE (
button, E_TYPE_EMOTICON_TOOL_BUTTON,
EEmoticonToolButtonPrivate);
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
/* Build the pop-up window. */
window = gtk_window_new (GTK_WINDOW_POPUP);
-<<<<<<< HEAD
- gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
- gtk_window_set_type_hint (
- GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_COMBO);
- button->priv->window = g_object_ref_sink (window);
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button));
- if (GTK_IS_WINDOW (toplevel)) {
-=======
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button));
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
gtk_window_set_type_hint (
GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_COMBO);
if (gtk_widget_is_toplevel (toplevel)) {
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
gtk_window_group_add_window (
gtk_window_get_group (GTK_WINDOW (toplevel)),
GTK_WINDOW (window));
gtk_window_set_transient_for (
GTK_WINDOW (window), GTK_WINDOW (toplevel));
}
-<<<<<<< HEAD
-=======
button->priv->window = g_object_ref (window);
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
g_signal_connect_swapped (
window, "show",
@@ -735,11 +601,7 @@ emoticon_tool_button_init (EEmoticonToolButton *button)
container = widget;
chooser = E_EMOTICON_CHOOSER (button);
-<<<<<<< HEAD
list = e_emoticon_chooser_get_items ();
-=======
- list = e_emoticon_chooser_get_items (chooser);
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
g_assert (g_list_length (list) <= NUM_ROWS * NUM_COLS);
for (iter = list, ii = 0; iter != NULL; iter = iter->next, ii++) {
@@ -790,8 +652,6 @@ emoticon_tool_button_init (EEmoticonToolButton *button)
g_list_free (list);
}
-<<<<<<< HEAD
-=======
GType
e_emoticon_tool_button_get_type (void)
{
@@ -828,7 +688,6 @@ e_emoticon_tool_button_get_type (void)
return type;
}
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
GtkToolItem *
e_emoticon_tool_button_new (void)
{
diff --git a/e-util/e-emoticon.c b/e-util/e-emoticon.c
index 46f32c6..a9fcfb8 100644
--- a/e-util/e-emoticon.c
+++ b/e-util/e-emoticon.c
@@ -1,12 +1,4 @@
-<<<<<<< HEAD
-/*
- * e-emoticon.c
- *
- * Copyright (C) 2008 Novell, Inc.
- * Copyright (C) 2012 Dan Vrátil <dvratil redhat com>
-=======
/* e-emoticon.c
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU Lesser General Public
@@ -25,11 +17,8 @@
#include "e-emoticon.h"
-<<<<<<< HEAD
#include <gtk/gtk.h>
-=======
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
static EEmoticon *
emoticon_copy (EEmoticon *emoticon)
{
@@ -68,11 +57,7 @@ e_emoticon_get_type (void)
gboolean
e_emoticon_equal (EEmoticon *emoticon_a,
-<<<<<<< HEAD
- EEmoticon *emoticon_b)
-=======
EEmoticon *emoticon_b)
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
{
if (((emoticon_a == NULL) && (emoticon_b != NULL)) ||
((emoticon_a != NULL) && (emoticon_b == NULL)))
@@ -104,29 +89,3 @@ e_emoticon_free (EEmoticon *emoticon)
{
g_boxed_free (E_TYPE_EMOTICON, emoticon);
}
-<<<<<<< HEAD
-
-gchar *
-e_emoticon_get_uri (EEmoticon *emoticon)
-{
- GtkIconInfo *icon_info;
- GtkIconTheme *icon_theme;
- const gchar *filename;
- gchar *uri = NULL;
-
- icon_theme = gtk_icon_theme_get_default ();
- icon_info = gtk_icon_theme_lookup_icon (
- icon_theme, emoticon->icon_name, 16, 0);
- g_return_val_if_fail (icon_info != NULL, NULL);
-
- filename = gtk_icon_info_get_filename (icon_info);
- if (filename != NULL) {
- uri = g_filename_to_uri (filename, NULL, NULL);
- }
- gtk_icon_info_free (icon_info);
- g_return_val_if_fail (uri != NULL, NULL);
-
- return uri;
-}
-=======
->>>>>>> Import GtkhtmlFace* classes as EEmoticon*
diff --git a/e-util/e-emoticon.h b/e-util/e-emoticon.h
index cf1a2f7..53a5ec3 100644
--- a/e-util/e-emoticon.h
+++ b/e-util/e-emoticon.h
@@ -59,6 +59,8 @@ gchar * e_emoticon_get_uri (EEmoticon *emoticon);
=======
Import GtkhtmlFace* classes as EEmoticon*
+gchar * e_emoticon_get_uri (EEmoticon *emoticon);
+
G_END_DECLS
#endif /* E_EMOTICON_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]