qulogic/pidgin

propagate from branch 'im.pidgin.pidgin' (head 83f9edc4c976eefa029bc8591603c404e7c6a53a)
cpw.qulogic.gtk3-required
2012-06-02, Elliott Sales de Andrade
1f729ff8cab4
propagate from branch 'im.pidgin.pidgin' (head 83f9edc4c976eefa029bc8591603c404e7c6a53a)
to branch 'im.pidgin.cpw.qulogic.gtk3-required' (head eca262aa23ff2b14a4046c90e18449999cfa7202)
--- a/COPYRIGHT Wed May 30 22:05:28 2012 +0000
+++ b/COPYRIGHT Sat Jun 02 02:39:29 2012 +0000
@@ -478,6 +478,7 @@
Torrey Searle
Peter Seebach
Don Seiler
+Mihai Serban
Leonardo Serra
Matteo Settenvini
Colin Seymour
--- a/ChangeLog Wed May 30 22:05:28 2012 +0000
+++ b/ChangeLog Sat Jun 02 02:39:29 2012 +0000
@@ -48,7 +48,12 @@
was an offline message. (Flavius Anton) (#2497)
version 2.10.5:
- No changes
+ libpurple:
+ * Add support for GNOME3 proxy settings. (Mihai Serban) (#15054)
+
+ Pidgin:
+ * Fix a crash that may occur when trying to ignore a user who is
+ not in the current chat room. (#15139)
version 2.10.4 (05/06/2012):
General:
--- a/libpurple/proxy.c Wed May 30 22:05:28 2012 +0000
+++ b/libpurple/proxy.c Sat Jun 02 02:39:29 2012 +0000
@@ -232,41 +232,105 @@
global_proxy_info = info;
}
+
+/* index in gproxycmds below, keep them in sync */
+#define GNOME_PROXY_MODE 0
+#define GNOME_PROXY_USE_SAME_PROXY 1
+#define GNOME_PROXY_SOCKS_HOST 2
+#define GNOME_PROXY_SOCKS_PORT 3
+#define GNOME_PROXY_HTTP_HOST 4
+#define GNOME_PROXY_HTTP_PORT 5
+#define GNOME_PROXY_HTTP_USER 6
+#define GNOME_PROXY_HTTP_PASS 7
+#define GNOME2_CMDS 0
+#define GNOME3_CMDS 1
+
+/* detect proxy settings for gnome2/gnome3 */
+static const char* gproxycmds[][2] = {
+ { "gconftool-2 -g /system/proxy/mode" , "gsettings get org.gnome.system.proxy mode" },
+ { "gconftool-2 -g /system/http_proxy/use_same_proxy", "gsettings get org.gnome.system.proxy use-same-proxy" },
+ { "gconftool-2 -g /system/proxy/socks_host", "gsettings get org.gnome.system.proxy.socks host" },
+ { "gconftool-2 -g /system/proxy/socks_port", "gsettings get org.gnome.system.proxy.socks port" },
+ { "gconftool-2 -g /system/http_proxy/host", "gsettings get org.gnome.system.proxy.http host" },
+ { "gconftool-2 -g /system/http_proxy/port", "gsettings get org.gnome.system.proxy.http port"},
+ { "gconftool-2 -g /system/http_proxy/authentication_user", "gsettings get org.gnome.system.proxy.http authentication-user" },
+ { "gconftool-2 -g /system/http_proxy/authentication_password", "gsettings get org.gnome.system.proxy.http authentication-password" },
+};
+
+/**
+ * This is a utility function used to retrieve proxy parameter values from
+ * GNOME 2/3 environment.
+ *
+ * @param parameter One of the GNOME_PROXY_x constants defined above
+ * @param gnome_version GNOME2_CMDS or GNOME3_CMDS
+ *
+ * @return The value of requested proxy parameter
+ */
+static char *
+purple_gnome_proxy_get_parameter(guint8 parameter, guint8 gnome_version)
+{
+ gchar *param, *err;
+ size_t param_len;
+
+ if (parameter > GNOME_PROXY_HTTP_PASS)
+ return NULL;
+ if (gnome_version > GNOME3_CMDS)
+ return NULL;
+
+ if (!g_spawn_command_line_sync(gproxycmds[parameter][gnome_version],
+ &param, &err, NULL, NULL))
+ return NULL;
+ g_free(err);
+
+ g_strstrip(param);
+ if (param[0] == '\'' || param[0] == '\"') {
+ param_len = strlen(param);
+ memmove(param, param + 1, param_len); /* copy last \0 too */
+ --param_len;
+ if (param_len > 0 && (param[param_len - 1] == '\'' || param[param_len - 1] == '\"'))
+ param[param_len - 1] = '\0';
+ g_strstrip(param);
+ }
+
+ return param;
+}
+
static PurpleProxyInfo *
purple_gnome_proxy_get_info(void)
{
static PurpleProxyInfo info = {0, NULL, 0, NULL, NULL};
gboolean use_same_proxy = FALSE;
- gchar *tmp, *err = NULL;
-
- tmp = g_find_program_in_path("gconftool-2");
+ gchar *tmp;
+ guint8 gnome_version = GNOME3_CMDS;
+
+ tmp = g_find_program_in_path("gsettings");
+ if (tmp == NULL) {
+ tmp = g_find_program_in_path("gconftool-2");
+ gnome_version = GNOME2_CMDS;
+ }
if (tmp == NULL)
return purple_global_proxy_get_info();
g_free(tmp);
- tmp = NULL;
/* Check whether to use a proxy. */
- if (!g_spawn_command_line_sync("gconftool-2 -g /system/proxy/mode",
- &tmp, &err, NULL, NULL))
+ tmp = purple_gnome_proxy_get_parameter(GNOME_PROXY_MODE, gnome_version);
+ if (!tmp)
return purple_global_proxy_get_info();
- g_free(err);
- err = NULL;
-
- if (purple_strequal(tmp, "none\n")) {
+
+ if (purple_strequal(tmp, "none")) {
info.type = PURPLE_PROXY_NONE;
g_free(tmp);
return &info;
}
- if (!purple_strequal(tmp, "manual\n")) {
+ if (!purple_strequal(tmp, "manual")) {
/* Unknown setting. Fallback to using our global proxy settings. */
g_free(tmp);
return purple_global_proxy_get_info();
}
g_free(tmp);
- tmp = NULL;
/* Free the old fields */
if (info.host) {
@@ -282,52 +346,40 @@
info.password = NULL;
}
- if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/use_same_proxy",
- &tmp, &err, NULL, NULL))
+ tmp = purple_gnome_proxy_get_parameter(GNOME_PROXY_USE_SAME_PROXY, gnome_version);
+ if (!tmp)
return purple_global_proxy_get_info();
- g_free(err);
- err = NULL;
-
- if (purple_strequal(tmp, "true\n"))
+
+ if (purple_strequal(tmp, "true"))
use_same_proxy = TRUE;
+
g_free(tmp);
- tmp = NULL;
if (!use_same_proxy) {
- if (!g_spawn_command_line_sync("gconftool-2 -g /system/proxy/socks_host",
- &info.host, &err, NULL, NULL))
+ info.host = purple_gnome_proxy_get_parameter(GNOME_PROXY_SOCKS_HOST, gnome_version);
+ if (!info.host)
return purple_global_proxy_get_info();
- g_free(err);
- err = NULL;
}
- if(info.host != NULL)
- g_strchomp(info.host);
-
if (!use_same_proxy && (info.host != NULL) && (*info.host != '\0')) {
info.type = PURPLE_PROXY_SOCKS5;
- if (!g_spawn_command_line_sync("gconftool-2 -g /system/proxy/socks_port",
- &tmp, &err, NULL, NULL))
- {
+ tmp = purple_gnome_proxy_get_parameter(GNOME_PROXY_SOCKS_PORT, gnome_version);
+ if (!tmp) {
g_free(info.host);
info.host = NULL;
return purple_global_proxy_get_info();
}
- g_free(err);
info.port = atoi(tmp);
g_free(tmp);
} else {
g_free(info.host);
- if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/host",
- &info.host, &err, NULL, NULL))
+ info.host = purple_gnome_proxy_get_parameter(GNOME_PROXY_HTTP_HOST, gnome_version);
+ if (!info.host)
return purple_global_proxy_get_info();
- g_free(err);
- err = NULL;
/* If we get this far then we know we're using an HTTP proxy */
info.type = PURPLE_PROXY_HTTP;
- g_strchomp(info.host);
if (*info.host == '\0')
{
purple_debug_info("proxy", "Gnome proxy settings are set to "
@@ -338,19 +390,16 @@
return purple_global_proxy_get_info();
}
- if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/authentication_user",
- &info.username, &err, NULL, NULL))
+ info.username = purple_gnome_proxy_get_parameter(GNOME_PROXY_HTTP_USER, gnome_version);
+ if (!info.username)
{
g_free(info.host);
info.host = NULL;
return purple_global_proxy_get_info();
}
- g_free(err);
- err = NULL;
- g_strchomp(info.username);
-
- if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/authentication_password",
- &info.password, &err, NULL, NULL))
+
+ info.password = purple_gnome_proxy_get_parameter(GNOME_PROXY_HTTP_PASS, gnome_version);
+ if (!info.password)
{
g_free(info.host);
info.host = NULL;
@@ -358,12 +407,9 @@
info.username = NULL;
return purple_global_proxy_get_info();
}
- g_free(err);
- err = NULL;
- g_strchomp(info.password);
-
- if (!g_spawn_command_line_sync("gconftool-2 -g /system/http_proxy/port",
- &tmp, &err, NULL, NULL))
+
+ tmp = purple_gnome_proxy_get_parameter(GNOME_PROXY_HTTP_PORT, gnome_version);
+ if (!tmp)
{
g_free(info.host);
info.host = NULL;
@@ -373,7 +419,6 @@
info.password = NULL;
return purple_global_proxy_get_info();
}
- g_free(err);
info.port = atoi(tmp);
g_free(tmp);
}
--- a/pidgin/gtkblist.c Wed May 30 22:05:28 2012 +0000
+++ b/pidgin/gtkblist.c Sat Jun 02 02:39:29 2012 +0000
@@ -5958,8 +5958,6 @@
NULL);
gtk_widget_set_name(gtkblist->headline_hbox, "gtk-tooltips");
- gtkblist->headline_close = gtk_widget_render_icon(ebox, GTK_STOCK_CLOSE,
- gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_MICROSCOPIC), NULL);
gtkblist->hand_cursor = gdk_cursor_new (GDK_HAND2);
gtkblist->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR);
@@ -6066,19 +6064,10 @@
gtkblist->scrollbook = pidgin_scroll_book_new();
gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->scrollbook, FALSE, FALSE, 0);
- /* Create an vbox which holds the scrollbook which is actually used to
- * display connection errors. The vbox needs to still exist for
- * backwards compatibility.
- */
- gtkblist->error_buttons = gtk_vbox_new(FALSE, 0);
- gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->error_buttons, FALSE, FALSE, 0);
- gtk_container_set_border_width(GTK_CONTAINER(gtkblist->error_buttons), 0);
-
priv->error_scrollbook = PIDGIN_SCROLL_BOOK(pidgin_scroll_book_new());
- gtk_box_pack_start(GTK_BOX(gtkblist->error_buttons),
+ gtk_box_pack_start(GTK_BOX(gtkblist->vbox),
GTK_WIDGET(priv->error_scrollbook), FALSE, FALSE, 0);
-
/* Add the statusbox */
gtkblist->statusbox = pidgin_status_box_new();
gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->statusbox, FALSE, TRUE, 0);
@@ -6963,9 +6952,6 @@
purple_signals_disconnect_by_handle(gtkblist);
- if (gtkblist->headline_close)
- g_object_unref(G_OBJECT(gtkblist->headline_close));
-
gtk_widget_destroy(gtkblist->window);
pidgin_blist_tooltip_destroy();
--- a/pidgin/gtkblist.h Wed May 30 22:05:28 2012 +0000
+++ b/pidgin/gtkblist.h Sat Jun 02 02:39:29 2012 +0000
@@ -110,13 +110,11 @@
GtkWidget *headline_hbox; /**< Hbox for headline notification */
GtkWidget *headline_label; /**< Label for headline notifications */
GtkWidget *headline_image; /**< Image for headline notifications */
- GdkPixbuf *headline_close; /**< @deprecated: Close image for closing the headline without triggering the callback */
GCallback headline_callback; /**< Callback for headline notifications */
gpointer headline_data; /**< User data for headline notifications */
GDestroyNotify headline_destroy; /**< Callback to use for destroying the headline-data */
gboolean changing_style; /**< True when changing GTK+ theme style */
- GtkWidget *error_buttons; /**< Box containing the connection error buttons */
GtkWidget *statusbox; /**< The status selector dropdown */
GdkPixbuf *empty_avatar; /**< A 32x32 transparent pixbuf */
--- a/pidgin/gtkconv.c Wed May 30 22:05:28 2012 +0000
+++ b/pidgin/gtkconv.c Sat Jun 02 02:39:29 2012 +0000
@@ -1500,13 +1500,6 @@
}
static void
-menu_timestamps_cb(GtkAction *action, gpointer data)
-{
- purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/conversations/show_timestamps",
- gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)));
-}
-
-static void
chat_do_im(PidginConversation *gtkconv, const char *who)
{
PurpleConversation *conv = gtkconv->active_conv;
@@ -3160,7 +3153,6 @@
{ "EnableLogging", NULL, N_("Enable _Logging"), NULL, NULL, G_CALLBACK(menu_logging_cb), FALSE },
{ "EnableSounds", NULL, N_("Enable _Sounds"), NULL, NULL, G_CALLBACK(menu_sounds_cb), FALSE },
{ "ShowFormattingToolbars", NULL, N_("Show Formatting _Toolbars"), NULL, NULL, G_CALLBACK(menu_toolbar_cb), FALSE },
- { "ShowTimestamps", NULL, N_("Show Ti_mestamps"), NULL, NULL, G_CALLBACK(menu_timestamps_cb), FALSE },
};
static const char *conversation_menu =
@@ -3205,7 +3197,6 @@
"<menuitem action='EnableSounds'/>"
"<separator/>"
"<menuitem action='ShowFormattingToolbars'/>"
- "<menuitem action='ShowTimestamps'/>"
"</menu>"
"</menubar>"
"</ui>";
@@ -3694,9 +3685,6 @@
win->menu.show_formatting_toolbar =
gtk_ui_manager_get_action(win->menu.ui,
"/Conversation/OptionsMenu/ShowFormattingToolbars");
- win->menu.show_timestamps =
- gtk_ui_manager_get_action(win->menu.ui,
- "/Conversation/OptionsMenu/ShowTimestamps");
win->menu.tray = pidgin_menu_tray_new();
gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar),
@@ -6671,10 +6659,13 @@
static gboolean get_iter_from_chatbuddy(PurpleConvChatBuddy *cb, GtkTreeIter *iter)
{
- GtkTreeRowReference *ref = purple_conv_chat_cb_get_ui_data(cb);
+ GtkTreeRowReference *ref;
GtkTreePath *path;
GtkTreeModel *model;
+ g_return_val_if_fail(cb != NULL, FALSE);
+
+ ref = purple_conv_chat_cb_get_ui_data(cb);
if (!ref)
return FALSE;
@@ -6854,6 +6845,9 @@
return;
cbuddy = purple_conv_chat_cb_find(chat, user);
+ if (!cbuddy)
+ return;
+
if (get_iter_from_chatbuddy(cbuddy, &iter)) {
GtkTreeRowReference *ref = purple_conv_chat_cb_get_ui_data(cbuddy);
gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
@@ -7878,37 +7872,6 @@
}
static void
-show_timestamps_pref_cb(const char *name, PurplePrefType type,
- gconstpointer value, gpointer data)
-{
- GList *l;
- PurpleConversation *conv;
- PidginConversation *gtkconv;
- PidginWindow *win;
-
- for (l = purple_get_conversations(); l != NULL; l = l->next)
- {
- conv = (PurpleConversation *)l->data;
-
- if (!PIDGIN_IS_PIDGIN_CONVERSATION(conv))
- continue;
-
- gtkconv = PIDGIN_CONVERSATION(conv);
- win = gtkconv->win;
-
- gtk_toggle_action_set_active(
- GTK_TOGGLE_ACTION(win->menu.show_timestamps),
- (gboolean)GPOINTER_TO_INT(value));
-
-/* TODO WEBKIT: Use WebKit version of this. */
-#if 0
- gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),
- (gboolean)GPOINTER_TO_INT(value));
-#endif /* if 0 */
- }
-}
-
-static void
show_formatting_toolbar_pref_cb(const char *name, PurplePrefType type,
gconstpointer value, gpointer data)
{
@@ -8448,6 +8411,12 @@
return TRUE;
}
+PurpleTheme *
+pidgin_conversations_get_default_theme(void)
+{
+ return default_conv_theme;
+}
+
void *
pidgin_conversations_get_handle(void)
{
@@ -8478,7 +8447,6 @@
purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/custom_smileys_size", 96);
purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/minimum_entry_lines", 2);
- purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_timestamps", TRUE);
purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar", TRUE);
purple_prefs_add_string(PIDGIN_PREFS_ROOT "/conversations/placement", "last");
@@ -8527,8 +8495,6 @@
/* Connect callbacks. */
purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/close_on_tabs",
close_on_tabs_pref_cb, NULL);
- purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/show_timestamps",
- show_timestamps_pref_cb, NULL);
purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar",
show_formatting_toolbar_pref_cb, NULL);
purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/conversations/spellcheck",
@@ -9747,9 +9713,6 @@
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(win->menu.show_formatting_toolbar),
purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar"));
- gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(win->menu.show_timestamps),
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_timestamps"));
-
/*
* We pause icons when they are not visible. If this icon should
* be animated then start it back up again.
--- a/pidgin/gtkconv.h Wed May 30 22:05:28 2012 +0000
+++ b/pidgin/gtkconv.h Sat Jun 02 02:39:29 2012 +0000
@@ -172,6 +172,13 @@
PurpleConversationUiOps *pidgin_conversations_get_conv_ui_ops(void);
/**
+ * Returns the default theme for GTK+ conversations.
+ *
+ * @return The default GTK+ conversation theme.
+ */
+PurpleTheme *pidgin_conversations_get_default_theme(void);
+
+/**
* Updates the buddy icon on a conversation.
*
* @param conv The conversation.
--- a/pidgin/gtkconvwin.h Wed May 30 22:05:28 2012 +0000
+++ b/pidgin/gtkconvwin.h Sat Jun 02 02:39:29 2012 +0000
@@ -68,7 +68,6 @@
GtkAction *logging;
GtkAction *sounds;
GtkAction *show_formatting_toolbar;
- GtkAction *show_timestamps;
GtkWidget *send_to;
--- a/pidgin/gtknotify.c Wed May 30 22:05:28 2012 +0000
+++ b/pidgin/gtknotify.c Sat Jun 02 02:39:29 2012 +0000
@@ -882,7 +882,7 @@
/* Make sure URLs are clickable */
linked_text = purple_markup_linkify(text);
- webkit_web_view_load_html_string(WEBKIT_WEB_VIEW(web_view), linked_text, "");
+ gtk_webview_load_html_string(GTK_WEBVIEW(web_view), linked_text);
g_free(linked_text);
g_object_set_data(G_OBJECT(window), "webview-widget", web_view);
@@ -1142,7 +1142,7 @@
if (pinfo != NULL) {
GtkWidget *webview = g_object_get_data(G_OBJECT(pinfo->window), "webview-widget");
char *linked_text = purple_markup_linkify(info);
- gtk_webview_load_html_string_with_imgstore(GTK_WEBVIEW(webview), linked_text);
+ gtk_webview_load_html_string(GTK_WEBVIEW(webview), linked_text);
g_free(linked_text);
g_free(key);
ui_handle = pinfo->window;
--- a/pidgin/gtkprefs.c Wed May 30 22:05:28 2012 +0000
+++ b/pidgin/gtkprefs.c Sat Jun 02 02:39:29 2012 +0000
@@ -1108,7 +1108,10 @@
if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(prefs_conv_themes_combo_box), &iter)) {
gtk_tree_model_get(GTK_TREE_MODEL(prefs_conv_themes), &iter, 2, &name, -1);
- theme = PIDGIN_CONV_THEME(purple_theme_manager_find_theme(name, "conversation"));
+ if (name && *name)
+ theme = PIDGIN_CONV_THEME(purple_theme_manager_find_theme(name, "conversation"));
+ else
+ theme = PIDGIN_CONV_THEME(pidgin_conversations_get_default_theme());
g_free(name);
if (gtk_combo_box_get_active_iter(combo_box, &iter)) {
@@ -1127,6 +1130,10 @@
if (gtk_combo_box_get_active_iter(combo_box, &iter)) {
gchar *name = NULL;
+ PidginConvTheme *theme;
+ const char *current_variant;
+ const GList *variants;
+ gboolean unset = TRUE;
gtk_tree_model_get(GTK_TREE_MODEL(prefs_conv_themes), &iter, 2, &name, -1);
@@ -1138,30 +1145,27 @@
/* Update list of variants */
gtk_list_store_clear(prefs_conv_variants);
- if (name && *name) {
- PidginConvTheme *theme;
- const char *current_variant;
- const GList *variants;
- gboolean unset = TRUE;
-
+ if (name && *name)
theme = PIDGIN_CONV_THEME(purple_theme_manager_find_theme(name, "conversation"));
- current_variant = pidgin_conversation_theme_get_variant(theme);
-
- variants = pidgin_conversation_theme_get_variants(theme);
- for (; variants && current_variant; variants = g_list_next(variants)) {
- gtk_list_store_append(prefs_conv_variants, &iter);
- gtk_list_store_set(prefs_conv_variants, &iter, 0, variants->data, -1);
+ else
+ theme = PIDGIN_CONV_THEME(pidgin_conversations_get_default_theme());
+
+ current_variant = pidgin_conversation_theme_get_variant(theme);
+
+ variants = pidgin_conversation_theme_get_variants(theme);
+ for (; variants && current_variant; variants = g_list_next(variants)) {
+ gtk_list_store_append(prefs_conv_variants, &iter);
+ gtk_list_store_set(prefs_conv_variants, &iter, 0, variants->data, -1);
- if (g_str_equal(variants->data, current_variant)) {
- gtk_combo_box_set_active_iter(GTK_COMBO_BOX(prefs_conv_variants_combo_box), &iter);
- unset = FALSE;
- }
+ if (g_str_equal(variants->data, current_variant)) {
+ gtk_combo_box_set_active_iter(GTK_COMBO_BOX(prefs_conv_variants_combo_box), &iter);
+ unset = FALSE;
}
-
- if (unset)
- gtk_combo_box_set_active(GTK_COMBO_BOX(prefs_conv_variants_combo_box), 0);
}
+ if (unset)
+ gtk_combo_box_set_active(GTK_COMBO_BOX(prefs_conv_variants_combo_box), 0);
+
g_signal_handlers_unblock_by_func(prefs_conv_variants_combo_box,
prefs_set_conv_variant_cb, NULL);
g_free(name);
--- a/pidgin/gtkwebview.c Wed May 30 22:05:28 2012 +0000
+++ b/pidgin/gtkwebview.c Sat Jun 02 02:39:29 2012 +0000
@@ -518,7 +518,7 @@
}
void
-gtk_webview_load_html_string_with_imgstore(GtkWebView *webview, const char *html)
+gtk_webview_load_html_string(GtkWebView *webview, const char *html)
{
GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
char *html_imged;
@@ -543,12 +543,12 @@
gtk_webview_append_html(GtkWebView *webview, const char *html)
{
GtkWebViewPriv *priv = GTK_WEBVIEW_GET_PRIVATE(webview);
- char *escaped = gtk_webview_quote_js_string(html);
- char *script = g_strdup_printf("document.write(%s)", escaped);
- webkit_web_view_execute_script(WEBKIT_WEB_VIEW(webview), script);
+ WebKitDOMDocument *doc;
+ WebKitDOMHTMLElement *body;
+ doc = webkit_web_view_get_dom_document(WEBKIT_WEB_VIEW(webview));
+ body = webkit_dom_document_get_body(doc);
+ webkit_dom_html_element_insert_adjacent_html(body, "beforeend", html, NULL);
priv->empty = FALSE;
- g_free(script);
- g_free(escaped);
}
void
--- a/pidgin/gtkwebview.h Wed May 30 22:05:28 2012 +0000
+++ b/pidgin/gtkwebview.h Sat Jun 02 02:39:29 2012 +0000
@@ -120,7 +120,7 @@
* @param webview The GtkWebView object
* @param html The HTML content to load
*/
-void gtk_webview_load_html_string_with_imgstore(GtkWebView *webview, const char *html);
+void gtk_webview_load_html_string(GtkWebView *webview, const char *html);
/**
* Execute the JavaScript only after the webkit_webview_load_string
--- a/pidgin/plugins/xmppconsole.c Wed May 30 22:05:28 2012 +0000
+++ b/pidgin/plugins/xmppconsole.c Sat Jun 02 02:39:29 2012 +0000
@@ -26,6 +26,7 @@
#include "xmlnode.h"
#include "gtkimhtml.h"
+#include "gtkwebview.h"
#include "gtkutils.h"
typedef struct {
@@ -33,7 +34,7 @@
GtkWidget *window;
GtkWidget *hbox;
GtkWidget *dropdown;
- GtkWidget *imhtml;
+ GtkWidget *webview;
GtkWidget *entry;
GtkWidget *sw;
int count;
@@ -43,31 +44,34 @@
XmppConsole *console = NULL;
static void *xmpp_console_handle = NULL;
-#define BRACKET_COLOR "#940f8c"
-#define TAG_COLOR "#8b1dab"
-#define ATTR_NAME_COLOR "#a02961"
-#define ATTR_VALUE_COLOR "#324aa4"
-#define XMLNS_COLOR "#2cb12f"
+#define EMPTY_HTML \
+"<html><head><style type='text/css'>" \
+ "body { word-wrap: break-word; margin: 0; }" \
+ "div.tab { padding-left: 1em; }" \
+ "div.info { color: #777777; }" \
+ "div.incoming { background-color: #ffcece; }" \
+ "div.outgoing { background-color: #dcecc4; }" \
+ "span.bracket { color: #940f8c; }" \
+ "span.tag { color: #8b1dab; font-weight: bold; }" \
+ "span.attr { color: #a02961; font-weight: bold; }" \
+ "span.value { color: #324aa4; }" \
+ "span.xmlns { color: #2cb12f; font-weight: bold;}" \
+"</style></head></html>"
static char *
-xmlnode_to_pretty_str(xmlnode *node, int *len, int depth)
+xmlnode_to_pretty_str(xmlnode *node, int *len)
{
GString *text = g_string_new("");
xmlnode *c;
- char *node_name, *esc, *esc2, *tab = NULL;
+ char *node_name, *esc, *esc2;
gboolean need_end = FALSE, pretty = TRUE;
g_return_val_if_fail(node != NULL, NULL);
- if (pretty && depth) {
- tab = g_strnfill(depth, '\t');
- text = g_string_append(text, tab);
- }
-
node_name = g_markup_escape_text(node->name, -1);
g_string_append_printf(text,
- "<font color='" BRACKET_COLOR "'>&lt;</font>"
- "<font color='" TAG_COLOR "'><b>%s</b></font>",
+ "<span class=bracket>&lt;</span>"
+ "<span class=tag>%s</span>",
node_name);
if (node->xmlns) {
@@ -78,8 +82,8 @@
{
char *xmlns = g_markup_escape_text(node->xmlns, -1);
g_string_append_printf(text,
- " <font color='" ATTR_NAME_COLOR "'><b>xmlns</b></font>="
- "'<font color='" XMLNS_COLOR "'><b>%s</b></font>'",
+ " <span class=attr>xmlns</span>="
+ "'<span class=xmlns>%s</span>'",
xmlns);
g_free(xmlns);
}
@@ -90,8 +94,8 @@
esc = g_markup_escape_text(c->name, -1);
esc2 = g_markup_escape_text(c->data, -1);
g_string_append_printf(text,
- " <font color='" ATTR_NAME_COLOR "'><b>%s</b></font>="
- "'<font color='" ATTR_VALUE_COLOR "'>%s</font>'",
+ " <span class=attr>%s</span>="
+ "'<span class=value>%s</span>'",
esc, esc2);
g_free(esc);
g_free(esc2);
@@ -104,14 +108,19 @@
if (need_end) {
g_string_append_printf(text,
- "<font color='"BRACKET_COLOR"'>&gt;</font>%s",
+ "<span class=bracket>&gt;</span>%s",
pretty ? "<br>" : "");
+ need_end = FALSE;
for (c = node->child; c; c = c->next)
{
if (c->type == XMLNODE_TYPE_TAG) {
int esc_len;
- esc = xmlnode_to_pretty_str(c, &esc_len, depth+1);
+ esc = xmlnode_to_pretty_str(c, &esc_len);
+ if (!need_end) {
+ g_string_append(text, "<div class=tab>");
+ need_end = TRUE;
+ }
text = g_string_append_len(text, esc, esc_len);
g_free(esc);
} else if (c->type == XMLNODE_TYPE_DATA && c->data_sz > 0) {
@@ -121,23 +130,22 @@
}
}
- if(tab && pretty)
- text = g_string_append(text, tab);
+ if (need_end)
+ g_string_append(text, "</div>");
+
g_string_append_printf(text,
- "<font color='" BRACKET_COLOR "'>&lt;</font>/"
- "<font color='" TAG_COLOR "'><b>%s</b></font>"
- "<font color='" BRACKET_COLOR "'>&gt;</font><br>",
+ "<span class=bracket>&lt;</span>/"
+ "<span class=tag>%s</span>"
+ "<span class=bracket>&gt;</span><br>",
node_name);
} else {
g_string_append_printf(text,
- "/<font color='" BRACKET_COLOR "'>&gt;</font><br>");
+ "/<span class=bracket>&gt;</span><br>");
}
g_free(node_name);
- g_free(tab);
-
- if(len)
+ if (len)
*len = text->len;
return g_string_free(text, FALSE);
@@ -150,9 +158,9 @@
if (!console || console->gc != gc)
return;
- str = xmlnode_to_pretty_str(*packet, NULL, 0);
- formatted = g_strdup_printf("<body bgcolor='#ffcece'><pre>%s</pre></body>", str);
- gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), formatted, 0);
+ str = xmlnode_to_pretty_str(*packet, NULL);
+ formatted = g_strdup_printf("<div class=incoming>%s</div>", str);
+ gtk_webview_append_html(GTK_WEBVIEW(console->webview), formatted);
g_free(formatted);
g_free(str);
}
@@ -171,9 +179,9 @@
if (!node)
return;
- str = xmlnode_to_pretty_str(node, NULL, 0);
- formatted = g_strdup_printf("<body bgcolor='#dcecc4'><pre>%s</pre></body>", str);
- gtk_imhtml_append_text(GTK_IMHTML(console->imhtml), formatted, 0);
+ str = xmlnode_to_pretty_str(node, NULL);
+ formatted = g_strdup_printf("<div class=outgoing>%s</div>", str);
+ gtk_webview_append_html(GTK_WEBVIEW(console->webview), formatted);
g_free(formatted);
g_free(str);
xmlnode_free(node);
@@ -274,7 +282,9 @@
GTK_STOCK_OK,
GTK_RESPONSE_ACCEPT,
NULL);
- /* TODO: how to set no separator for GtkDialog in gtk+ 3.0... */
+#if !GTK_CHECK_VERSION(2,22,0)
+ gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
+#endif
gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
gtk_container_set_border_width(GTK_CONTAINER(dialog), 12);
#if GTK_CHECK_VERSION(2,14,0)
@@ -362,9 +372,9 @@
GTK_STOCK_OK,
GTK_RESPONSE_ACCEPT,
NULL);
-
- /* TODO: find a way to specify no separator for a dialog in gtk+ 3 */
- /*gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);*/
+#if !GTK_CHECK_VERSION(2,22,0)
+ gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
+#endif
gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
gtk_container_set_border_width(GTK_CONTAINER(dialog), 12);
#if GTK_CHECK_VERSION(2,14,0)
@@ -522,8 +532,9 @@
GTK_STOCK_OK,
GTK_RESPONSE_ACCEPT,
NULL);
- /* TODO: find a way to create a dialog without separtor in gtk+ 3 */
- /*gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);*/
+#if !GTK_CHECK_VERSION(2,22,0)
+ gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
+#endif
gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
gtk_container_set_border_width(GTK_CONTAINER(dialog), 12);
#if GTK_CHECK_VERSION(2,14,0)
@@ -644,17 +655,25 @@
static void
signing_on_cb(PurpleConnection *gc)
{
+ PurpleAccount *account;
+
if (!console)
return;
+ account = purple_connection_get_account(gc);
+ if (strcmp(purple_account_get_protocol_id(account), "prpl-jabber"))
+ return;
+
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(console->dropdown),
- purple_account_get_username(purple_connection_get_account(gc)));
+ purple_account_get_username(account));
console->accounts = g_list_append(console->accounts, gc);
console->count++;
- if (console->count == 1)
+ if (console->count == 1) {
console->gc = gc;
- else
+ gtk_webview_load_html_string(GTK_WEBVIEW(console->webview), EMPTY_HTML);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(console->dropdown), 0);
+ } else
gtk_widget_show_all(console->hbox);
}
@@ -684,9 +703,11 @@
console->count--;
if (gc == console->gc) {
+ char *tmp = g_strdup_printf("<div class=info>%s</div>",
+ _("Logged out."));
+ gtk_webview_append_html(GTK_WEBVIEW(console->webview), tmp);
+ g_free(tmp);
console->gc = NULL;
- gtk_imhtml_append_text(GTK_IMHTML(console->imhtml),
- _("<font color='#777777'>Logged out.</font>"), 0);
}
}
@@ -731,19 +752,11 @@
static void
dropdown_changed_cb(GtkComboBox *widget, gpointer nul)
{
- PurpleAccount *account;
-
if (!console)
return;
- account =
- purple_accounts_find(gtk_combo_box_text_get_active_text(
- GTK_COMBO_BOX_TEXT(console->dropdown)), "prpl-jabber");
- if (!account || !purple_account_get_connection(account))
- return;
-
- console->gc = purple_account_get_connection(account);
- gtk_imhtml_clear(GTK_IMHTML(console->imhtml));
+ console->gc = g_list_nth_data(console->accounts, gtk_combo_box_get_active(GTK_COMBO_BOX(console->dropdown)));
+ gtk_webview_load_html_string(GTK_WEBVIEW(console->webview), EMPTY_HTML);
}
static void
@@ -785,16 +798,20 @@
console->gc = gc;
}
}
- gtk_combo_box_set_active(GTK_COMBO_BOX(console->dropdown),0);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(console->dropdown), 0);
gtk_box_pack_start(GTK_BOX(console->hbox), console->dropdown, TRUE, TRUE, 0);
g_signal_connect(G_OBJECT(console->dropdown), "changed", G_CALLBACK(dropdown_changed_cb), NULL);
- console->imhtml = gtk_imhtml_new(NULL, NULL);
- if (console->count == 0)
- gtk_imhtml_append_text(GTK_IMHTML(console->imhtml),
- _("<font color='#777777'>Not connected to XMPP</font>"), 0);
+ console->webview = gtk_webview_new();
+ gtk_webview_load_html_string(GTK_WEBVIEW(console->webview), EMPTY_HTML);
+ if (console->count == 0) {
+ char *tmp = g_strdup_printf("<div class=info>%s</div>",
+ _("Not connected to XMPP"));
+ gtk_webview_append_html(GTK_WEBVIEW(console->webview), tmp);
+ g_free(tmp);
+ }
gtk_box_pack_start(GTK_BOX(vbox),
- pidgin_make_scrollable(console->imhtml, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, GTK_SHADOW_ETCHED_IN, -1, -1),
+ pidgin_make_scrollable(console->webview, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, GTK_SHADOW_ETCHED_IN, -1, -1),
TRUE, TRUE, 0);
toolbar = gtk_toolbar_new();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/themes/Contents/Resources/Variants/Default.css Sat Jun 02 02:39:29 2012 +0000
@@ -0,0 +1,2 @@
+@import ../main.css;
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/themes/Contents/Resources/Variants/No-Timestamps.css Sat Jun 02 02:39:29 2012 +0000
@@ -0,0 +1,8 @@
+@import ../main.css;
+
+.x-container .x-time,
+.x-status_container .x-time
+{
+ display: none;
+}
+
--- a/pidgin/themes/Makefile.am Wed May 30 22:05:28 2012 +0000
+++ b/pidgin/themes/Makefile.am Sat Jun 02 02:39:29 2012 +0000
@@ -8,7 +8,8 @@
Contents/Resources/Status.html \
Contents/Resources/main.css
themevariantsdir = $(themeresourcesdir)/Variants
-themevariants_DATA =
+themevariants_DATA = Contents/Resources/Variants/Default.css \
+ Contents/Resources/Variants/No-Timestamps.css
EXTRA_DIST = \
$(themetemplate_DATA) \