/pidgin/main: 1ea2edfac5e9: Convert some more util stuff to a we...
Elliott Sales de Andrade
qulogic at pidgin.im
Wed Aug 15 00:51:52 EDT 2012
Changeset: 1ea2edfac5e9933913655b96ee78b0954f1f577c
Author: Elliott Sales de Andrade <qulogic at pidgin.im>
Date: 2012-08-14 23:30 -0400
Branch: default
URL: http://hg.pidgin.im/pidgin/main/rev/1ea2edfac5e9
Description:
Convert some more util stuff to a webview.
diffstat:
pidgin/gtkutils.c | 113 ++---------------------------------------------------
pidgin/gtkutils.h | 30 +-------------
2 files changed, 7 insertions(+), 136 deletions(-)
diffs (223 lines):
diff --git a/pidgin/gtkutils.c b/pidgin/gtkutils.c
--- a/pidgin/gtkutils.c
+++ b/pidgin/gtkutils.c
@@ -62,8 +62,6 @@
#include "gtkconv.h"
#include "gtkdialogs.h"
-#include "gtkimhtml.h"
-#include "gtkimhtmltoolbar.h"
#include "pidginstock.h"
#include "gtkthemes.h"
#include "gtkutils.h"
@@ -103,49 +101,13 @@ url_clicked_cb(GtkWebView *unused, const
return TRUE;
}
-static GtkIMHtmlFuncs gtkimhtml_cbs = {
- (GtkIMHtmlGetImageFunc)purple_imgstore_find_by_id,
- (GtkIMHtmlGetImageDataFunc)purple_imgstore_get_data,
- (GtkIMHtmlGetImageSizeFunc)purple_imgstore_get_size,
- (GtkIMHtmlGetImageFilenameFunc)purple_imgstore_get_filename,
- purple_imgstore_ref_by_id,
- purple_imgstore_unref_by_id,
-};
-
-void
-pidgin_setup_imhtml(GtkWidget *imhtml)
-{
- g_return_if_fail(imhtml != NULL);
- g_return_if_fail(GTK_IS_IMHTML(imhtml));
-
- pidgin_themes_smiley_themeize(imhtml);
-
- gtk_imhtml_set_funcs(GTK_IMHTML(imhtml), >kimhtml_cbs);
-
-#ifdef _WIN32
- if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/use_theme_font")) {
- PangoFontDescription *desc;
- const char *font = purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/custom_font");
- desc = pango_font_description_from_string(font);
- if (desc) {
- gtk_widget_modify_font(imhtml, desc);
- pango_font_description_free(desc);
- }
- }
-#endif
-
-}
-
void
pidgin_setup_webview(GtkWidget *webview)
{
g_return_if_fail(webview != NULL);
g_return_if_fail(GTK_IS_WEBVIEW(webview));
-#if 0
-/* TODO: WebKit this stuff... */
pidgin_themes_smiley_themeize(webview);
-#endif
#ifdef _WIN32
if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/use_theme_font")) {
@@ -252,66 +214,6 @@ GtkWidget *pidgin_dialog_add_button(GtkD
}
GtkWidget *
-pidgin_create_imhtml(gboolean editable, GtkWidget **imhtml_ret, GtkWidget **toolbar_ret, GtkWidget **sw_ret)
-{
- GtkWidget *frame;
- GtkWidget *imhtml;
- GtkWidget *sep;
- GtkWidget *sw;
- GtkWidget *toolbar = NULL;
- GtkWidget *vbox;
-
- frame = gtk_frame_new(NULL);
- gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN);
-
- vbox = gtk_vbox_new(FALSE, 0);
- gtk_container_add(GTK_CONTAINER(frame), vbox);
- gtk_widget_show(vbox);
-
- if (editable) {
- toolbar = gtk_imhtmltoolbar_new();
- gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
- gtk_widget_show(toolbar);
-
- sep = gtk_hseparator_new();
- gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
- g_signal_connect_swapped(G_OBJECT(toolbar), "show", G_CALLBACK(gtk_widget_show), sep);
- g_signal_connect_swapped(G_OBJECT(toolbar), "hide", G_CALLBACK(gtk_widget_hide), sep);
- gtk_widget_show(sep);
- }
-
- imhtml = gtk_imhtml_new(NULL, NULL);
- gtk_imhtml_set_editable(GTK_IMHTML(imhtml), editable);
- gtk_imhtml_set_format_functions(GTK_IMHTML(imhtml), GTK_IMHTML_ALL ^ GTK_IMHTML_IMAGE);
- gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD_CHAR);
-#ifdef USE_GTKSPELL
- if (editable && purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/spellcheck"))
- pidgin_setup_gtkspell(GTK_TEXT_VIEW(imhtml));
-#endif
- gtk_widget_show(imhtml);
-
- if (editable) {
- gtk_imhtmltoolbar_attach(GTK_IMHTMLTOOLBAR(toolbar), imhtml);
- gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(toolbar), "default");
- }
- pidgin_setup_imhtml(imhtml);
-
- sw = pidgin_make_scrollable(imhtml, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, GTK_SHADOW_NONE, -1, -1);
- gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0);
-
- if (imhtml_ret != NULL)
- *imhtml_ret = imhtml;
-
- if (editable && (toolbar_ret != NULL))
- *toolbar_ret = toolbar;
-
- if (sw_ret != NULL)
- *sw_ret = sw;
-
- return frame;
-}
-
-GtkWidget *
pidgin_create_webview(gboolean editable, GtkWidget **webview_ret, GtkWidget **toolbar_ret, GtkWidget **sw_ret)
{
GtkWidget *frame;
@@ -1460,7 +1362,6 @@ static void dnd_image_ok_callback(_DndDa
GError *err = NULL;
PurpleConversation *conv;
PidginConversation *gtkconv;
- GtkTextIter iter;
int id;
PurpleBuddy *buddy;
PurpleContact *contact;
@@ -1512,9 +1413,7 @@ static void dnd_image_ok_callback(_DndDa
shortname = shortname ? shortname + 1 : data->filename;
id = purple_imgstore_add_with_id(filedata, size, shortname);
- gtk_text_buffer_get_iter_at_mark(GTK_IMHTML(gtkconv->entry)->text_buffer, &iter,
- gtk_text_buffer_get_insert(GTK_IMHTML(gtkconv->entry)->text_buffer));
- gtk_imhtml_insert_image_at_iter(GTK_IMHTML(gtkconv->entry), id, &iter);
+ gtk_webview_insert_image(GTK_WEBVIEW(gtkconv->entry), id);
purple_imgstore_unref_by_id(id);
break;
@@ -1677,9 +1576,9 @@ pidgin_dnd_file_manage(GtkSelectionData
case PURPLE_DESKTOP_ITEM_TYPE_LINK:
conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, who);
gtkconv = PIDGIN_CONVERSATION(conv);
- gtk_imhtml_insert_link(GTK_IMHTML(gtkconv->entry),
- gtk_text_buffer_get_insert(GTK_IMHTML(gtkconv->entry)->text_buffer),
- purple_desktop_item_get_string(item, "URL"), itemname);
+ gtk_webview_insert_link(GTK_WEBVIEW(gtkconv->entry),
+ purple_desktop_item_get_string(item, "URL"),
+ itemname);
break;
default:
/* I don't know if we really want to do anything here. Most of
@@ -3312,12 +3211,12 @@ file_open_uri(GtkWebView *webview, const
if (code == SE_ERR_ASSOCINCOMPLETE || code == SE_ERR_NOASSOC)
{
- purple_notify_error(imhtml, NULL,
+ purple_notify_error(webview, NULL,
_("There is no application configured to open this type of file."), NULL);
}
else if (code < 32)
{
- purple_notify_error(imhtml, NULL,
+ purple_notify_error(webview, NULL,
_("An error occurred while opening the file."), NULL);
purple_debug_warning("gtkutils", "filename: %s; code: %d\n", uri, code);
}
diff --git a/pidgin/gtkutils.h b/pidgin/gtkutils.h
--- a/pidgin/gtkutils.h
+++ b/pidgin/gtkutils.h
@@ -79,34 +79,6 @@ typedef gboolean (*PidginFilterBuddyComp
G_BEGIN_DECLS
/**
- * Sets up a gtkimhtml widget, loads it with smileys, and sets the
- * default signal handlers.
- *
- * @param imhtml The gtkimhtml widget to setup.
- */
-void pidgin_setup_imhtml(GtkWidget *imhtml);
-
-/**
- * Create an GtkIMHtml widget and associated GtkIMHtmlToolbar widget. This
- * functions puts both widgets in a nice GtkFrame. They're separate by an
- * attractive GtkSeparator.
- *
- * @param editable @c TRUE if this imhtml should be editable. If this is @c FALSE,
- * then the toolbar will NOT be created. If this imthml should be
- * read-only at first, but may become editable later, then pass in
- * @c TRUE here and then manually call gtk_imhtml_set_editable() later.
- * @param imhtml_ret A pointer to a pointer to a GtkWidget. This pointer
- * will be set to the imhtml when this function exits.
- * @param toolbar_ret A pointer to a pointer to a GtkWidget. If editable is
- * TRUE then this will be set to the toolbar when this function exits.
- * Otherwise this will be set to @c NULL.
- * @param sw_ret This will be filled with a pointer to the scrolled window
- * widget which contains the imhtml.
- * @return The GtkFrame containing the toolbar and imhtml.
- */
-GtkWidget *pidgin_create_imhtml(gboolean editable, GtkWidget **imhtml_ret, GtkWidget **toolbar_ret, GtkWidget **sw_ret);
-
-/**
* Sets up a gtkwebview widget, loads it with smileys, and sets the
* default signal handlers.
*
@@ -115,7 +87,7 @@ GtkWidget *pidgin_create_imhtml(gboolean
void pidgin_setup_webview(GtkWidget *webview);
/**
- * Create an GtkWebView widget and associated GtkIMHtmlToolbar widget. This
+ * Create an GtkWebView widget and associated GtkWebViewToolbar widget. This
* function puts both widgets in a nice GtkFrame. They're separated by an
* attractive GtkSeparator.
*
More information about the Commits
mailing list