pidgin: d63e24f0: Convert the Webview toolbar to a real Gt...

qulogic at pidgin.im qulogic at pidgin.im
Tue Jun 5 03:33:47 EDT 2012


----------------------------------------------------------------------
Revision: d63e24f0c90786170cd999b0a0c0d8fad9447cc5
Parent:   3afba1bd369579ccea4aa5c18b8d392f1d834fbd
Author:   qulogic at pidgin.im
Date:     06/05/12 01:35:29
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/d63e24f0c90786170cd999b0a0c0d8fad9447cc5

Changelog: 

Convert the Webview toolbar to a real GtkToolbar with GtkActions.

With GtkActions, we can let GTK take care of keeping sensitivity
in sync. And hopefully, a real toolbar will look better in GTK3.

Changes against parent 3afba1bd369579ccea4aa5c18b8d392f1d834fbd

  patched  pidgin/gtkwebviewtoolbar.c

-------------- next part --------------
============================================================
--- pidgin/gtkwebviewtoolbar.c	3a7e33c71284d866a82625009ecdc7d957366682
+++ pidgin/gtkwebviewtoolbar.c	e3bbb326145a4113151d356ccbfc933302521eb2
@@ -43,15 +43,6 @@
 
 #include <gdk/gdkkeysyms.h>
 
-#if !GTK_CHECK_VERSION(2,18,0)
-#define gtk_widget_get_visible(x) GTK_WIDGET_VISIBLE((x))
-#define gtk_widget_is_sensitive(x) GTK_WIDGET_IS_SENSITIVE((x))
-#if !GTK_CHECK_VERSION(2,12,0)
-#define gtk_widget_set_tooltip_text(w, t) \
-	gtk_tooltips_set_tip(priv->tooltips, (w), (t), NULL)
-#endif
-#endif
-
 #define GTK_WEBVIEWTOOLBAR_GET_PRIVATE(obj) \
 	(G_TYPE_INSTANCE_GET_PRIVATE((obj), GTK_TYPE_WEBVIEWTOOLBAR, GtkWebViewToolbarPriv))
 
@@ -65,36 +56,33 @@ typedef struct _GtkWebViewToolbarPriv {
 	GtkWidget *wide_view;
 	GtkWidget *lean_view;
 
-#if !GTK_CHECK_VERSION(2,12,0)
-	GtkTooltips *tooltips;
-#endif
-
 	GtkWidget *font_label;
 	GtkWidget *font_menu;
 
-	GtkWidget *bold;
-	GtkWidget *italic;
-	GtkWidget *underline;
-	GtkWidget *strike;
+	GtkAction *bold;
+	GtkAction *italic;
+	GtkAction *underline;
+	GtkAction *strike;
 
-	GtkWidget *larger_size;
-	GtkWidget *normal_size;
-	GtkWidget *smaller_size;
+	GtkAction *larger_size;
+#if 0
+	GtkAction *normal_size;
+#endif
+	GtkAction *smaller_size;
 
-	GtkWidget *font;
-	GtkWidget *fgcolor;
-	GtkWidget *bgcolor;
+	GtkAction *font;
+	GtkAction *fgcolor;
+	GtkAction *bgcolor;
 
-	GtkWidget *clear;
+	GtkAction *clear;
 
 	GtkWidget *insert_menu;
-	GtkWidget *image;
-	GtkWidget *link;
-	GtkWidget *insert_hr;
+	GtkAction *image;
+	GtkAction *link;
+	GtkAction *hr;
 
-	GtkWidget *smiley;
-	GtkWidget *attention;
-	GtkWidget *call;
+	GtkAction *smiley;
+	GtkAction *attention;
 
 	GtkWidget *font_dialog;
 	GtkWidget *fgcolor_dialog;
@@ -117,19 +105,15 @@ static void
  *****************************************************************************/
 
 static void
-toggle_button_set_active_block(GtkToggleButton *button, gboolean is_active,
+toggle_action_set_active_block(GtkToggleAction *action, gboolean is_active,
                                GtkWebViewToolbar *toolbar);
 
-static gboolean
-gtk_webviewtoolbar_popup_menu(GtkWidget *widget, GdkEventButton *event,
-                              GtkWebViewToolbar *toolbar);
-
 /******************************************************************************
  * Helpers
  *****************************************************************************/
 
 static void
-do_bold(GtkWidget *bold, GtkWebViewToolbar *toolbar)
+do_bold(GtkAction *bold, GtkWebViewToolbar *toolbar)
 {
 	g_return_if_fail(toolbar != NULL);
 	gtk_webview_toggle_bold(GTK_WEBVIEW(toolbar->webview));
@@ -137,7 +121,7 @@ static void
 }
 
 static void
-do_italic(GtkWidget *italic, GtkWebViewToolbar *toolbar)
+do_italic(GtkAction *italic, GtkWebViewToolbar *toolbar)
 {
 	g_return_if_fail(toolbar != NULL);
 	gtk_webview_toggle_italic(GTK_WEBVIEW(toolbar->webview));
@@ -145,7 +129,7 @@ static void
 }
 
 static void
-do_underline(GtkWidget *underline, GtkWebViewToolbar *toolbar)
+do_underline(GtkAction *underline, GtkWebViewToolbar *toolbar)
 {
 	g_return_if_fail(toolbar != NULL);
 	gtk_webview_toggle_underline(GTK_WEBVIEW(toolbar->webview));
@@ -153,7 +137,7 @@ static void
 }
 
 static void
-do_strikethrough(GtkWidget *strikethrough, GtkWebViewToolbar *toolbar)
+do_strikethrough(GtkAction *strikethrough, GtkWebViewToolbar *toolbar)
 {
 	g_return_if_fail(toolbar != NULL);
 	gtk_webview_toggle_strike(GTK_WEBVIEW(toolbar->webview));
@@ -161,22 +145,18 @@ static void
 }
 
 static void
-do_small(GtkWidget *smalltb, GtkWebViewToolbar *toolbar)
+do_small(GtkAction *small, GtkWebViewToolbar *toolbar)
 {
 	g_return_if_fail(toolbar != NULL);
-	/* Only shrink the font on activation, not deactivation as well */
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(smalltb)))
-		gtk_webview_font_shrink(GTK_WEBVIEW(toolbar->webview));
+	gtk_webview_font_shrink(GTK_WEBVIEW(toolbar->webview));
 	gtk_widget_grab_focus(toolbar->webview);
 }
 
 static void
-do_big(GtkWidget *large, GtkWebViewToolbar *toolbar)
+do_big(GtkAction *large, GtkWebViewToolbar *toolbar)
 {
 	g_return_if_fail(toolbar);
-	/* Only grow the font on activation, not deactivation as well */
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(large)))
-		gtk_webview_font_grow(GTK_WEBVIEW(toolbar->webview));
+	gtk_webview_font_grow(GTK_WEBVIEW(toolbar->webview));
 	gtk_widget_grab_focus(toolbar->webview);
 }
 
@@ -246,13 +226,11 @@ static void
 }
 
 static void
-toggle_font(GtkWidget *font, GtkWebViewToolbar *toolbar)
+toggle_font(GtkAction *font, GtkWebViewToolbar *toolbar)
 {
-	GtkWebViewToolbarPriv *priv;
-	g_return_if_fail(toolbar);
-	priv = GTK_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
+	GtkWebViewToolbarPriv *priv = GTK_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
 
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(font))) {
+	if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(font))) {
 		char *fontname = gtk_webview_get_current_fontface(GTK_WEBVIEW(toolbar->webview));
 
 		if (!priv->font_dialog) {
@@ -282,7 +260,7 @@ toggle_font(GtkWidget *font, GtkWebViewT
 
 		g_free(fontname);
 	} else {
-		cancel_toolbar_font(font, toolbar);
+		cancel_toolbar_font(GTK_WIDGET(toolbar), toolbar);
 	}
 
 	gtk_widget_grab_focus(toolbar->webview);
@@ -337,10 +315,11 @@ static void
 }
 
 static void
-toggle_fg_color(GtkWidget *color, GtkWebViewToolbar *toolbar)
+toggle_fg_color(GtkAction *color, GtkWebViewToolbar *toolbar)
 {
 	GtkWebViewToolbarPriv *priv = GTK_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(color))) {
+
+	if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(color))) {
 		GtkWidget *colorsel;
 		GdkColor fgcolor;
 		char *color = gtk_webview_get_current_forecolor(GTK_WEBVIEW(toolbar->webview));
@@ -365,7 +344,7 @@ toggle_fg_color(GtkWidget *color, GtkWeb
 
 		g_free(color);
 	} else {
-		cancel_toolbar_fgcolor(color, toolbar);
+		cancel_toolbar_fgcolor(GTK_WIDGET(toolbar), toolbar);
 	}
 
 	gtk_widget_grab_focus(toolbar->webview);
@@ -420,10 +399,11 @@ static void
 }
 
 static void
-toggle_bg_color(GtkWidget *color, GtkWebViewToolbar *toolbar)
+toggle_bg_color(GtkAction *color, GtkWebViewToolbar *toolbar)
 {
 	GtkWebViewToolbarPriv *priv = GTK_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(color))) {
+
+	if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(color))) {
 		GtkWidget *colorsel;
 		GdkColor bgcolor;
 		char *color = gtk_webview_get_current_backcolor(GTK_WEBVIEW(toolbar->webview));
@@ -448,17 +428,15 @@ toggle_bg_color(GtkWidget *color, GtkWeb
 
 		g_free(color);
 	} else {
-		cancel_toolbar_bgcolor(color, toolbar);
+		cancel_toolbar_bgcolor(GTK_WIDGET(toolbar), toolbar);
 	}
 
 	gtk_widget_grab_focus(toolbar->webview);
 }
 
 static void
-clear_formatting_cb(GtkWidget *clear, GtkWebViewToolbar *toolbar)
+clear_formatting_cb(GtkAction *clear, GtkWebViewToolbar *toolbar)
 {
-	GtkWebViewToolbarPriv *priv = GTK_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
-	toggle_button_set_active_block(GTK_TOGGLE_BUTTON(priv->clear), FALSE, toolbar);
 	gtk_webview_clear_formatting(GTK_WEBVIEW(toolbar->webview));
 }
 
@@ -466,7 +444,7 @@ cancel_link_cb(GtkWebViewToolbar *toolba
 cancel_link_cb(GtkWebViewToolbar *toolbar, PurpleRequestFields *fields)
 {
 	GtkWebViewToolbarPriv *priv = GTK_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
-	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->link), FALSE);
+	gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(priv->link), FALSE);
 
 	priv->link_dialog = NULL;
 }
@@ -502,10 +480,11 @@ static void
 }
 
 static void
-insert_link_cb(GtkWidget *w, GtkWebViewToolbar *toolbar)
+insert_link_cb(GtkAction *action, GtkWebViewToolbar *toolbar)
 {
 	GtkWebViewToolbarPriv *priv = GTK_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->link))) {
+
+	if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(priv->link))) {
 		PurpleRequestFields *fields;
 		PurpleRequestFieldGroup *group;
 		PurpleRequestField *field;
@@ -553,7 +532,7 @@ static void
 }
 
 static void
-insert_hr_cb(GtkWidget *widget, GtkWebViewToolbar *toolbar)
+insert_hr_cb(GtkAction *action, GtkWebViewToolbar *toolbar)
 {
 	gtk_webview_insert_hr(GTK_WEBVIEW(toolbar->webview));
 }
@@ -561,9 +540,8 @@ do_insert_image_cb(GtkWidget *widget, in
 static void
 do_insert_image_cb(GtkWidget *widget, int response, GtkWebViewToolbar *toolbar)
 {
+#if 0
 	GtkWebViewToolbarPriv *priv = GTK_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
-	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->image), FALSE);
-#if 0
 	gchar *filename, *name, *buf;
 	char *filedata;
 	size_t size;
@@ -573,20 +551,15 @@ do_insert_image_cb(GtkWidget *widget, in
 	GtkTextMark *ins;
 
 	if (response != GTK_RESPONSE_ACCEPT)
-	{
-		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->image), FALSE);
 		return;
-	}
 
 	filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
 
-	if (filename == NULL) {
-		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->image), FALSE);
+	if (filename == NULL)
 		return;
-	}
 
 	/* The following triggers a callback that closes the widget */
-	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->image), FALSE);
+	gtk_action_activate(priv->image);
 
 	if (!g_file_get_contents(filename, &filedata, &size, &error)) {
 		purple_notify_error(NULL, NULL, error->message, NULL);
@@ -622,21 +595,20 @@ static void
 }
 
 static void
-insert_image_cb(GtkWidget *save, GtkWebViewToolbar *toolbar)
+insert_image_cb(GtkAction *action, GtkWebViewToolbar *toolbar)
 {
 	GtkWebViewToolbarPriv *priv = GTK_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
 	GtkWidget *window;
 
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->image))) {
-		window = gtk_file_chooser_dialog_new(_("Insert Image"),
-						NULL,
-						GTK_FILE_CHOOSER_ACTION_OPEN,
-						GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-						GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
-						NULL);
+	if (priv->image_dialog) {
+		window = gtk_file_chooser_dialog_new(_("Insert Image"), NULL,
+		                                     GTK_FILE_CHOOSER_ACTION_OPEN,
+		                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+		                                     GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+		                                     NULL);
 		gtk_dialog_set_default_response(GTK_DIALOG(window), GTK_RESPONSE_ACCEPT);
-		g_signal_connect(G_OBJECT(GTK_FILE_CHOOSER(window)),
-				"response", G_CALLBACK(do_insert_image_cb), toolbar);
+		g_signal_connect(G_OBJECT(GTK_FILE_CHOOSER(window)), "response",
+		                 G_CALLBACK(do_insert_image_cb), toolbar);
 
 		gtk_widget_show(window);
 		priv->image_dialog = window;
@@ -851,7 +823,7 @@ static void
 #endif
 
 static void
-insert_smiley_cb(GtkWidget *smiley, GtkWebViewToolbar *toolbar)
+insert_smiley_cb(GtkAction *smiley, GtkWebViewToolbar *toolbar)
 {
 #if 0
 	GtkWebViewToolbarPriv *priv = GTK_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
@@ -863,7 +835,7 @@ insert_smiley_cb(GtkWidget *smiley, GtkW
 	GtkRequisition req;
 	GtkWidget *scrolled, *viewport;
 
-	if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(smiley))) {
+	if (!gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(smiley))) {
 		destroy_smiley_dialog(toolbar);
 		gtk_widget_grab_focus(toolbar->webview);
 		return;
@@ -1001,14 +973,13 @@ static void
 }
 
 static void
-send_attention_cb(GtkWidget *attention, GtkWebViewToolbar *toolbar)
+send_attention_cb(GtkAction *attention, GtkWebViewToolbar *toolbar)
 {
 	GtkWebViewToolbarPriv *priv = GTK_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
 	PurpleConversation *conv = priv->active_conv;
 	const gchar *who = purple_conversation_get_name(conv);
 	PurpleConnection *gc = purple_conversation_get_connection(conv);
 
-	toggle_button_set_active_block(GTK_TOGGLE_BUTTON(attention), FALSE, toolbar);
 	purple_prpl_send_attention(gc, who, 0);
 	gtk_widget_grab_focus(toolbar->webview);
 }
@@ -1018,51 +989,52 @@ update_buttons_cb(GtkWebView *webview, G
                   GtkWebViewToolbar *toolbar)
 {
 	GtkWebViewToolbarPriv *priv = GTK_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
-	gtk_widget_set_sensitive(GTK_WIDGET(priv->bold), buttons & GTK_WEBVIEW_BOLD);
-	gtk_widget_set_sensitive(GTK_WIDGET(priv->italic), buttons & GTK_WEBVIEW_ITALIC);
-	gtk_widget_set_sensitive(GTK_WIDGET(priv->underline), buttons & GTK_WEBVIEW_UNDERLINE);
-	gtk_widget_set_sensitive(GTK_WIDGET(priv->strike), buttons & GTK_WEBVIEW_STRIKE);
 
-	gtk_widget_set_sensitive(GTK_WIDGET(priv->larger_size), buttons & GTK_WEBVIEW_GROW);
-	gtk_widget_set_sensitive(GTK_WIDGET(priv->smaller_size), buttons & GTK_WEBVIEW_SHRINK);
+	gtk_action_set_sensitive(priv->bold, buttons & GTK_WEBVIEW_BOLD);
+	gtk_action_set_sensitive(priv->italic, buttons & GTK_WEBVIEW_ITALIC);
+	gtk_action_set_sensitive(priv->underline, buttons & GTK_WEBVIEW_UNDERLINE);
+	gtk_action_set_sensitive(priv->strike, buttons & GTK_WEBVIEW_STRIKE);
 
-	gtk_widget_set_sensitive(GTK_WIDGET(priv->font), buttons & GTK_WEBVIEW_FACE);
-	gtk_widget_set_sensitive(GTK_WIDGET(priv->fgcolor), buttons & GTK_WEBVIEW_FORECOLOR);
-	gtk_widget_set_sensitive(GTK_WIDGET(priv->bgcolor), buttons & GTK_WEBVIEW_BACKCOLOR);
+	gtk_action_set_sensitive(priv->larger_size, buttons & GTK_WEBVIEW_GROW);
+	gtk_action_set_sensitive(priv->smaller_size, buttons & GTK_WEBVIEW_SHRINK);
 
-	gtk_widget_set_sensitive(GTK_WIDGET(priv->clear),
-							 (buttons & GTK_WEBVIEW_BOLD ||
-							  buttons & GTK_WEBVIEW_ITALIC ||
-							  buttons & GTK_WEBVIEW_UNDERLINE ||
-							  buttons & GTK_WEBVIEW_STRIKE ||
-							  buttons & GTK_WEBVIEW_GROW ||
-							  buttons & GTK_WEBVIEW_SHRINK ||
-							  buttons & GTK_WEBVIEW_FACE ||
-							  buttons & GTK_WEBVIEW_FORECOLOR ||
-							  buttons & GTK_WEBVIEW_BACKCOLOR));
+	gtk_action_set_sensitive(priv->font, buttons & GTK_WEBVIEW_FACE);
+	gtk_action_set_sensitive(priv->fgcolor, buttons & GTK_WEBVIEW_FORECOLOR);
+	gtk_action_set_sensitive(priv->bgcolor, buttons & GTK_WEBVIEW_BACKCOLOR);
 
-	gtk_widget_set_sensitive(GTK_WIDGET(priv->image), buttons & GTK_WEBVIEW_IMAGE);
-	gtk_widget_set_sensitive(GTK_WIDGET(priv->link), buttons & GTK_WEBVIEW_LINK);
-	gtk_widget_set_sensitive(GTK_WIDGET(priv->smiley), buttons & GTK_WEBVIEW_SMILEY);
+	gtk_action_set_sensitive(priv->clear,
+	                         (buttons & GTK_WEBVIEW_BOLD ||
+	                          buttons & GTK_WEBVIEW_ITALIC ||
+	                          buttons & GTK_WEBVIEW_UNDERLINE ||
+	                          buttons & GTK_WEBVIEW_STRIKE ||
+	                          buttons & GTK_WEBVIEW_GROW ||
+	                          buttons & GTK_WEBVIEW_SHRINK ||
+	                          buttons & GTK_WEBVIEW_FACE ||
+	                          buttons & GTK_WEBVIEW_FORECOLOR ||
+	                          buttons & GTK_WEBVIEW_BACKCOLOR));
+
+	gtk_action_set_sensitive(priv->image, buttons & GTK_WEBVIEW_IMAGE);
+	gtk_action_set_sensitive(priv->link, buttons & GTK_WEBVIEW_LINK);
+	gtk_action_set_sensitive(priv->smiley, buttons & GTK_WEBVIEW_SMILEY);
 }
 
 /* we call this when we want to _set_active the toggle button, it'll
- * block the callback thats connected to the button so we don't have to
+ * block the callback that's connected to the button so we don't have to
  * do the double toggling hack
  */
 static void
-toggle_button_set_active_block(GtkToggleButton *button, gboolean is_active,
+toggle_action_set_active_block(GtkToggleAction *action, gboolean is_active,
                                GtkWebViewToolbar *toolbar)
 {
 	GObject *object;
 	g_return_if_fail(toolbar);
 
-	object = g_object_ref(button);
+	object = g_object_ref(action);
 	g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA,
-									0, 0, NULL, NULL, toolbar);
-	gtk_toggle_button_set_active(button, is_active);
+	                                0, 0, NULL, NULL, toolbar);
+	gtk_toggle_action_set_active(action, is_active);
 	g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA,
-									  0, 0, NULL, NULL, toolbar);
+	                                  0, 0, NULL, NULL, toolbar);
 	g_object_unref(object);
 }
 
@@ -1072,87 +1044,81 @@ update_buttons(GtkWebViewToolbar *toolba
 	GtkWebViewToolbarPriv *priv = GTK_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
 	gboolean bold, italic, underline, strike;
 	char *tmp;
-	GtkLabel *label = GTK_LABEL(priv->font_label);
+	char *label;
 
-	gtk_label_set_label(label, _("_Font"));
+	label = g_strdup(_("_Font"));
 
 	gtk_webview_get_current_format(GTK_WEBVIEW(toolbar->webview),
 	                               &bold, &italic, &underline, &strike);
 
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->bold)) != bold)
-		toggle_button_set_active_block(GTK_TOGGLE_BUTTON(priv->bold), bold,
-									   toolbar);
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->italic)) != italic)
-		toggle_button_set_active_block(GTK_TOGGLE_BUTTON(priv->italic), italic,
-									   toolbar);
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->underline)) != underline)
-		toggle_button_set_active_block(GTK_TOGGLE_BUTTON(priv->underline),
-									   underline, toolbar);
-	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->strike)) != strike)
-		toggle_button_set_active_block(GTK_TOGGLE_BUTTON(priv->strike),
-									   strike, toolbar);
+	if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(priv->bold)) != bold)
+		toggle_action_set_active_block(GTK_TOGGLE_ACTION(priv->bold), bold,
+		                               toolbar);
+	if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(priv->italic)) != italic)
+		toggle_action_set_active_block(GTK_TOGGLE_ACTION(priv->italic), italic,
+		                               toolbar);
+	if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(priv->underline)) != underline)
+		toggle_action_set_active_block(GTK_TOGGLE_ACTION(priv->underline),
+		                               underline, toolbar);
+	if (gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(priv->strike)) != strike)
+		toggle_action_set_active_block(GTK_TOGGLE_ACTION(priv->strike), strike,
+		                               toolbar);
 
-	/* These buttons aren't ever "active". */
-	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->smaller_size), FALSE);
-	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->larger_size), FALSE);
-
 	if (bold) {
-		gchar *markup = g_strdup_printf("<b>%s</b>",
-				gtk_label_get_label(label));
-		gtk_label_set_markup_with_mnemonic(label, markup);
-		g_free(markup);
+		gchar *markup = g_strdup_printf("<b>%s</b>", label);
+		g_free(label);
+		label = markup;
 	}
 	if (italic) {
-		gchar *markup = g_strdup_printf("<i>%s</i>",
-				gtk_label_get_label(label));
-		gtk_label_set_markup_with_mnemonic(label, markup);
-		g_free(markup);
+		gchar *markup = g_strdup_printf("<i>%s</i>", label);
+		g_free(label);
+		label = markup;
 	}
 	if (underline) {
-		gchar *markup = g_strdup_printf("<u>%s</u>",
-				gtk_label_get_label(label));
-		gtk_label_set_markup_with_mnemonic(label, markup);
-		g_free(markup);
+		gchar *markup = g_strdup_printf("<u>%s</u>", label);
+		g_free(label);
+		label = markup;
 	}
 	if (strike) {
-		gchar *markup = g_strdup_printf("<s>%s</s>",
-				gtk_label_get_label(label));
-		gtk_label_set_markup_with_mnemonic(label, markup);
-		g_free(markup);
+		gchar *markup = g_strdup_printf("<s>%s</s>", label);
+		g_free(label);
+		label = markup;
 	}
 
 	tmp = gtk_webview_get_current_fontface(GTK_WEBVIEW(toolbar->webview));
-	toggle_button_set_active_block(GTK_TOGGLE_BUTTON(priv->font),
-								   (tmp != NULL), toolbar);
-	if (tmp != NULL) {
+	toggle_action_set_active_block(GTK_TOGGLE_ACTION(priv->font),
+	                               (tmp && *tmp), toolbar);
+	if (tmp && *tmp) {
 		gchar *markup = g_strdup_printf("<span font_desc=\"%s\">%s</span>",
-				tmp, gtk_label_get_label(label));
-		gtk_label_set_markup_with_mnemonic(label, markup);
-		g_free(markup);
+		                                tmp, label);
+		g_free(label);
+		label = markup;
 	}
 	g_free(tmp);
 
 	tmp = gtk_webview_get_current_forecolor(GTK_WEBVIEW(toolbar->webview));
-	toggle_button_set_active_block(GTK_TOGGLE_BUTTON(priv->fgcolor),
-								   (tmp != NULL), toolbar);
-	if (tmp != NULL) {
+	toggle_action_set_active_block(GTK_TOGGLE_ACTION(priv->fgcolor),
+	                               (tmp && *tmp), toolbar);
+	if (tmp && *tmp) {
 		gchar *markup = g_strdup_printf("<span foreground=\"%s\">%s</span>",
-				tmp, gtk_label_get_label(label));
-		gtk_label_set_markup_with_mnemonic(label, markup);
-		g_free(markup);
+		                                tmp, label);
+		g_free(label);
+		label = markup;
 	}
 	g_free(tmp);
 
 	tmp = gtk_webview_get_current_backcolor(GTK_WEBVIEW(toolbar->webview));
-	toggle_button_set_active_block(GTK_TOGGLE_BUTTON(priv->bgcolor),
-								   (tmp != NULL), toolbar);
-	if (tmp != NULL) {
+	toggle_action_set_active_block(GTK_TOGGLE_ACTION(priv->bgcolor),
+	                               (tmp && *tmp), toolbar);
+	if (tmp && *tmp) {
 		gchar *markup = g_strdup_printf("<span background=\"%s\">%s</span>",
-				tmp, gtk_label_get_label(label));
-		gtk_label_set_markup_with_mnemonic(label, markup);
-		g_free(markup);
+		                                tmp, label);
+		g_free(label);
+		label = markup;
 	}
 	g_free(tmp);
+
+	gtk_label_set_markup_with_mnemonic(GTK_LABEL(priv->font_label), label);
 }
 
 static void
@@ -1185,18 +1151,18 @@ static void
  * Copyright (C) 2004 Paolo Borelli
  */
 static void
-menu_position_func(GtkMenu           *menu,
-                   int               *x,
-                   int               *y,
-                   gboolean          *push_in,
-                   gpointer          data)
+menu_position_func(GtkMenu  *menu,
+                   int      *x,
+                   int      *y,
+                   gboolean *push_in,
+                   gpointer data)
 {
 	GtkWidget *widget = GTK_WIDGET(data);
 	GtkRequisition menu_req;
 	gint ythickness = widget->style->ythickness;
 	int savy;
 
-	gtk_widget_size_request(GTK_WIDGET (menu), &menu_req);
+	gtk_widget_size_request(GTK_WIDGET(menu), &menu_req);
 	gdk_window_get_origin(widget->window, x, y);
 	*x += widget->allocation.x;
 	*y += widget->allocation.y + widget->allocation.height;
@@ -1208,28 +1174,19 @@ menu_position_func(GtkMenu           *me
 		*y -= widget->allocation.height;
 }
 
-static gboolean
-button_activate_on_click(GtkWidget *button, GdkEventButton *event,
-                         GtkWebViewToolbar *toolbar)
-{
-	if (event->button == 1 && GTK_IS_TOGGLE_BUTTON(button))
-		gtk_widget_activate(button);
-	else if (event->button == 3)
-		return gtk_webviewtoolbar_popup_menu(button, event, toolbar);
-	return FALSE;
-}
-
 static void
 pidgin_menu_clicked(GtkWidget *button, GtkMenu *menu)
 {
-	gtk_widget_show_all(GTK_WIDGET(menu));
-	gtk_menu_popup(menu, NULL, NULL, menu_position_func, button, 0, gtk_get_current_event_time());
+	if (gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(button))) {
+		gtk_widget_show_all(GTK_WIDGET(menu));
+		gtk_menu_popup(menu, NULL, NULL, menu_position_func, button, 0, gtk_get_current_event_time());
+	}
 }
 
 static void
 pidgin_menu_deactivate(GtkWidget *menu, GtkToggleButton *button)
 {
-	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
+	gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(button), FALSE);
 }
 
 static void
@@ -1251,7 +1208,7 @@ gtk_webviewtoolbar_popup_menu(GtkWidget 
 	if (event->button != 3)
 		return FALSE;
 
-	wide = gtk_widget_get_visible(priv->bold);
+	wide = gtk_widget_get_visible(priv->wide_view);
 
 	menu = gtk_menu_new();
 	item = gtk_menu_item_new_with_mnemonic(wide ? _("Group Items") : _("Ungroup Items"));
@@ -1260,38 +1217,18 @@ gtk_webviewtoolbar_popup_menu(GtkWidget 
 	gtk_widget_show(item);
 
 	gtk_menu_popup(GTK_MENU(menu), NULL, NULL, pidgin_menu_position_func_helper,
-				widget, event->button, event->time);
-	return TRUE;
-}
+	               widget, event->button, event->time);
 
-static void
-button_visibility_changed(GtkWidget *button, gpointer dontcare, GtkWidget *item)
-{
-	if (gtk_widget_get_visible(button))
-		gtk_widget_hide(item);
-	else
-		gtk_widget_show(item);
+	return TRUE;
 }
 
 static void
-button_sensitiveness_changed(GtkWidget *button, gpointer dontcare, GtkWidget *item)
-{
-	gtk_widget_set_sensitive(item, gtk_widget_is_sensitive(button));
-}
-
-static void
-update_menuitem(GtkToggleButton *button, GtkCheckMenuItem *item)
-{
-	g_signal_handlers_block_by_func(G_OBJECT(item), G_CALLBACK(gtk_button_clicked), button);
-	gtk_check_menu_item_set_active(item, gtk_toggle_button_get_active(button));
-	g_signal_handlers_unblock_by_func(G_OBJECT(item), G_CALLBACK(gtk_button_clicked), button);
-}
-
-static void
 enable_markup(GtkWidget *widget, gpointer null)
 {
-	if (GTK_IS_LABEL(widget))
-		g_object_set(G_OBJECT(widget), "use-markup", TRUE, NULL);
+	GtkWidget *label;
+	label = gtk_bin_get_child(GTK_BIN(widget));
+	if (GTK_IS_LABEL(label))
+		g_object_set(G_OBJECT(label), "use-markup", TRUE, NULL);
 }
 
 static void
@@ -1347,10 +1284,6 @@ gtk_webviewtoolbar_finalize(GObject *obj
 
 	g_free(priv->sml);
 
-#if !GTK_CHECK_VERSION(2,12,0)
-	gtk_object_sink(GTK_OBJECT(priv->tooltips));
-#endif
-
 	if (priv->font_menu)
 		gtk_widget_destroy(priv->font_menu);
 	if (priv->insert_menu)
@@ -1358,7 +1291,7 @@ gtk_webviewtoolbar_finalize(GObject *obj
 
 	purple_prefs_disconnect_by_handle(object);
 
-	G_OBJECT_CLASS(parent_class)->finalize (object);
+	G_OBJECT_CLASS(parent_class)->finalize(object);
 }
 
 static void
@@ -1376,262 +1309,235 @@ static void
 }
 
 static void
-gtk_webviewtoolbar_create_old_buttons(GtkWebViewToolbar *toolbar)
+gtk_webviewtoolbar_create_actions(GtkWebViewToolbar *toolbar)
 {
 	GtkWebViewToolbarPriv *priv = GTK_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
-	GtkWidget *hbox;
-	GtkWidget *button;
+	GtkActionGroup *action_group;
+	int i;
 	struct {
+		GtkAction **action;
+		char *name;
 		char *stock;
-		gpointer callback;
-		GtkWidget **button;
-		const char *tooltip;
-	} buttons[] = {
-		{GTK_STOCK_BOLD, G_CALLBACK(do_bold), &priv->bold, _("Bold")},
-		{GTK_STOCK_ITALIC, do_italic, &priv->italic, _("Italic")},
-		{GTK_STOCK_UNDERLINE, do_underline, &priv->underline, _("Underline")},
-		{GTK_STOCK_STRIKETHROUGH, do_strikethrough, &priv->strike, _("Strikethrough")},
-		{"", NULL, NULL, NULL},
-		{PIDGIN_STOCK_TOOLBAR_TEXT_LARGER, do_big, &priv->larger_size, _("Increase Font Size")},
-		{PIDGIN_STOCK_TOOLBAR_TEXT_SMALLER, do_small, &priv->smaller_size, _("Decrease Font Size")},
-		{"", NULL, NULL, NULL},
-		{PIDGIN_STOCK_TOOLBAR_FONT_FACE, toggle_font, &priv->font, _("Font Face")},
-		{PIDGIN_STOCK_TOOLBAR_FGCOLOR, toggle_fg_color, &priv->fgcolor, _("Foreground Color")},
-		{PIDGIN_STOCK_TOOLBAR_BGCOLOR, toggle_bg_color, &priv->bgcolor, _("Background Color")},
-		{"", NULL, NULL, NULL},
-		{PIDGIN_STOCK_CLEAR, clear_formatting_cb, &priv->clear, _("Reset Formatting")},
-		{"", NULL, NULL, NULL},
-		{PIDGIN_STOCK_TOOLBAR_INSERT_IMAGE, insert_image_cb, &priv->image, _("Insert IM Image")},
-		{PIDGIN_STOCK_TOOLBAR_INSERT_LINK, insert_link_cb, &priv->link, _("Insert Link")},
-		{"", NULL, NULL, NULL},
-		{PIDGIN_STOCK_TOOLBAR_SMILEY, insert_smiley_cb, &priv->smiley, _("Insert Smiley")},
-		{PIDGIN_STOCK_TOOLBAR_SEND_ATTENTION, send_attention_cb, &priv->attention, _("Send Attention")},
-		{NULL, NULL, NULL, NULL}
+		char *label;
+		char *tooltip;
+		void (*cb)();
+		gboolean toggle;
+	} actions[] = {
+		{&priv->bold, "ToggleBold", GTK_STOCK_BOLD, N_("<b>_Bold</b>"), N_("Bold"), do_bold, TRUE},
+		{&priv->italic, "ToggleItalic", GTK_STOCK_ITALIC, N_("<i>_Italic</i>"), N_("Italic"), do_italic, TRUE},
+		{&priv->underline, "ToggleUnderline", GTK_STOCK_UNDERLINE, N_("<u>_Underline</u>"), N_("Underline"), do_underline, TRUE},
+		{&priv->strike, "ToggleStrike", GTK_STOCK_STRIKETHROUGH, N_("<span strikethrough='true'>Strikethrough</span>"), N_("Strikethrough"), do_strikethrough, TRUE},
+		{&priv->larger_size, "ToggleLarger", PIDGIN_STOCK_TOOLBAR_TEXT_LARGER, N_("<span size='larger'>Larger</span>"), N_("Increase Font Size"), do_big, FALSE},
+#if 0
+		{&priv->normal_size, "ToggleNormal", NULL, N_("Normal"), N_("Normal Font Size"), NULL, FALSE},
+#endif
+		{&priv->smaller_size, "ToggleSmaller", PIDGIN_STOCK_TOOLBAR_TEXT_SMALLER, N_("<span size='smaller'>Smaller</span>"), N_("Decrease Font Size"), do_small, FALSE},
+		{&priv->font, "ToggleFontFace", PIDGIN_STOCK_TOOLBAR_FONT_FACE, N_("_Font face"), N_("Font Face"), toggle_font, TRUE},
+		{&priv->fgcolor, "ToggleFG", PIDGIN_STOCK_TOOLBAR_FGCOLOR, N_("Foreground _color"), N_("Foreground Color"), toggle_fg_color, TRUE},
+		{&priv->bgcolor, "ToggleBG", PIDGIN_STOCK_TOOLBAR_BGCOLOR, N_("Bac_kground color"), N_("Background Color"), toggle_bg_color, TRUE},
+		{&priv->clear, "ResetFormat", PIDGIN_STOCK_CLEAR, N_("_Reset formatting"), N_("Reset Formatting"), clear_formatting_cb, FALSE},
+		{&priv->image, "InsertImage", PIDGIN_STOCK_TOOLBAR_INSERT_IMAGE, N_("_Image"), N_("Insert IM Image"), insert_image_cb, FALSE},
+		{&priv->link, "InsertLink", PIDGIN_STOCK_TOOLBAR_INSERT_LINK, N_("_Link"), N_("Insert Link"), insert_link_cb, TRUE},
+		{&priv->hr, "InsertHR", NULL, N_("_Horizontal rule"), N_("Insert Horizontal rule"), insert_hr_cb, FALSE},
+		{&priv->smiley, "InsertSmiley", PIDGIN_STOCK_TOOLBAR_SMILEY, N_("_Smile!"), N_("Insert Smiley"), insert_smiley_cb, FALSE},
+		{&priv->attention, "SendAttention", PIDGIN_STOCK_TOOLBAR_SEND_ATTENTION, N_("_Attention!"), N_("Send Attention"), send_attention_cb, FALSE},
 	};
-	int iter;
 
-	hbox = gtk_hbox_new(FALSE, 0);
+	action_group = gtk_action_group_new("GtkWebViewToolbar");
+#ifdef ENABLE_NLS
+	gtk_action_group_set_translation_domain(action_group, PACKAGE);
+#endif
 
-	for (iter = 0; buttons[iter].stock; iter++) {
-		if (buttons[iter].stock[0]) {
-			button = pidgin_pixbuf_toolbar_button_from_stock(buttons[iter].stock);
-			g_signal_connect(G_OBJECT(button), "button-press-event", G_CALLBACK(gtk_webviewtoolbar_popup_menu), toolbar);
-			g_signal_connect(G_OBJECT(button), "clicked",
-					 G_CALLBACK(buttons[iter].callback), toolbar);
-			*(buttons[iter].button) = button;
-			gtk_widget_set_tooltip_text(button, buttons[iter].tooltip);
-		} else
-			button = gtk_vseparator_new();
-		gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
+	for (i = 0; i < G_N_ELEMENTS(actions); i++) {
+		GtkAction *action;
+		if (actions[i].toggle)
+			action = GTK_ACTION(gtk_toggle_action_new(actions[i].name,
+			                                          actions[i].label,
+			                                          actions[i].tooltip,
+			                                          actions[i].stock));
+		else
+			action = gtk_action_new(actions[i].name, actions[i].label,
+			                        actions[i].tooltip, actions[i].stock);
+		gtk_action_set_is_important(action, TRUE);
+		gtk_action_group_add_action(action_group, action);
+		g_signal_connect(G_OBJECT(action), "activate", actions[i].cb, toolbar);
+		*(actions[i].action) = action;
 	}
-
-	gtk_box_pack_start(GTK_BOX(toolbar), hbox, FALSE, FALSE, 0);
-	priv->wide_view = hbox;
 }
 
 static void
-gtk_webviewtoolbar_init(GtkWebViewToolbar *toolbar)
+gtk_webviewtoolbar_create_wide_view(GtkWebViewToolbar *toolbar)
 {
 	GtkWebViewToolbarPriv *priv = GTK_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
-	GtkWidget *hbox = GTK_WIDGET(toolbar), *event = gtk_event_box_new();
-	GtkWidget *bbox, *box = gtk_hbox_new(FALSE, 0);
-	GtkWidget *image;
-	GtkWidget *label;
-	GtkWidget *insert_button;
-	GtkWidget *font_button;
-	GtkWidget *smiley_button;
-	GtkWidget *attention_button;
-	GtkWidget *font_menu;
-	GtkWidget *insert_menu;
-	GtkWidget *menuitem;
-	GtkWidget *sep;
-	int i;
-	struct {
-		const char *label;
-		GtkWidget **button;
-		gboolean check;
-	} buttons[] = {
-		{_("<b>_Bold</b>"), &priv->bold, TRUE},
-		{_("<i>_Italic</i>"), &priv->italic, TRUE},
-		{_("<u>_Underline</u>"), &priv->underline, TRUE},
-		{_("<span strikethrough='true'>Strikethrough</span>"), &priv->strike, TRUE},
-		{_("<span size='larger'>_Larger</span>"), &priv->larger_size, TRUE},
+	GtkAction *layout[] = {
+		priv->bold,
+		priv->italic,
+		priv->underline,
+		priv->strike,
+		NULL,
+		priv->larger_size,
 #if 0
-		{_("_Normal"), &priv->normal_size, TRUE},
+		priv->normal_size,
 #endif
-		{_("<span size='smaller'>_Smaller</span>"), &priv->smaller_size, TRUE},
-		/* If we want to show the formatting for the following items, we would
-		 * need to update them when formatting changes. The above items don't need
-		 * no updating nor nothin' */
-		{_("_Font face"), &priv->font, TRUE},
-		{_("Foreground _color"), &priv->fgcolor, TRUE},
-		{_("Bac_kground color"), &priv->bgcolor, TRUE},
-		{_("_Reset formatting"), &priv->clear, FALSE},
-		{NULL, NULL, FALSE}
+		priv->smaller_size,
+		NULL,
+		priv->font,
+		priv->fgcolor,
+		priv->bgcolor,
+		NULL,
+		priv->clear,
+		NULL,
+		priv->image,
+		priv->link,
+		NULL,
+		priv->smiley,
+		priv->attention
 	};
+	int i;
+	GtkToolItem *item;
 
-	toolbar->webview = NULL;
-	priv->font_dialog = NULL;
-	priv->fgcolor_dialog = NULL;
-	priv->bgcolor_dialog = NULL;
-	priv->link_dialog = NULL;
-	priv->smiley_dialog = NULL;
-	priv->image_dialog = NULL;
+	priv->wide_view = gtk_toolbar_new();
+	gtk_toolbar_set_icon_size(GTK_TOOLBAR(priv->wide_view),
+			gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL));
+	gtk_toolbar_set_style(GTK_TOOLBAR(priv->wide_view), GTK_TOOLBAR_ICONS);
 
-#if !GTK_CHECK_VERSION(2,12,0)
-	priv->tooltips = gtk_tooltips_new();
-#endif
+	for (i = 0; i < G_N_ELEMENTS(layout); i++) {
+		if (layout[i])
+			item = GTK_TOOL_ITEM(gtk_action_create_tool_item(layout[i]));
+		else
+			item = gtk_separator_tool_item_new();
+		gtk_toolbar_insert(GTK_TOOLBAR(priv->wide_view), item, -1);
+	}
+}
 
-	gtk_box_set_spacing(GTK_BOX(toolbar), 3);
+static void
+gtk_webviewtoolbar_create_lean_view(GtkWebViewToolbar *toolbar)
+{
+	GtkWebViewToolbarPriv *priv = GTK_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
+	GtkWidget *label;
+	GtkWidget *menuitem;
+	GtkToolItem *sep;
+	GtkToolItem *font_button;
+	GtkWidget *font_menu;
+	GtkToolItem *insert_button;
+	GtkWidget *insert_menu;
+	GtkWidget *smiley_button;
+	GtkWidget *attention_button;
 
-	gtk_webviewtoolbar_create_old_buttons(toolbar);
+	priv->lean_view = gtk_toolbar_new();
+	gtk_toolbar_set_icon_size(GTK_TOOLBAR(priv->lean_view),
+			gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL));
+	gtk_toolbar_set_style(GTK_TOOLBAR(priv->lean_view), GTK_TOOLBAR_BOTH_HORIZ);
 
+#define ADD_MENU_ITEM(menu, item) \
+	menuitem = gtk_action_create_menu_item((item)); \
+	gtk_menu_shell_append(GTK_MENU_SHELL((menu)), menuitem);
+
 	/* Fonts */
-	font_button = gtk_toggle_button_new();
-	gtk_button_set_relief(GTK_BUTTON(font_button), GTK_RELIEF_NONE);
-	bbox = gtk_hbox_new(FALSE, 3);
-	gtk_container_add(GTK_CONTAINER(font_button), bbox);
-	image = gtk_image_new_from_stock(GTK_STOCK_BOLD, gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL));
-	gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0);
+	font_button = gtk_toggle_tool_button_new();
+	gtk_toolbar_insert(GTK_TOOLBAR(priv->lean_view), font_button, -1);
+	gtk_tool_item_set_is_important(font_button, TRUE);
+	gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(font_button), GTK_STOCK_BOLD);
 	priv->font_label = label = gtk_label_new_with_mnemonic(_("_Font"));
 	gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
-	gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0);
-	gtk_box_pack_start(GTK_BOX(box), font_button, FALSE, FALSE, 0);
-	gtk_widget_show_all(font_button);
+	gtk_tool_button_set_label_widget(GTK_TOOL_BUTTON(font_button), label);
 
 	priv->font_menu = font_menu = gtk_menu_new();
 
-	for (i = 0; buttons[i].label; i++) {
-		GtkWidget *old = *buttons[i].button;
-		if (buttons[i].check) {
-			menuitem = gtk_check_menu_item_new_with_mnemonic(buttons[i].label);
-			g_signal_connect_after(G_OBJECT(old), "toggled",
-						G_CALLBACK(update_menuitem), menuitem);
-		} else {
-			menuitem = gtk_menu_item_new_with_mnemonic(buttons[i].label);
-		}
-		g_signal_connect_swapped(G_OBJECT(menuitem), "activate",
-				G_CALLBACK(gtk_button_clicked), old);
-		gtk_menu_shell_append(GTK_MENU_SHELL(font_menu), menuitem);
-		g_signal_connect(G_OBJECT(old), "notify::sensitive",
-				G_CALLBACK(button_sensitiveness_changed), menuitem);
-		g_signal_connect(G_OBJECT(old), "notify::visible",
-				G_CALLBACK(button_visibility_changed), menuitem);
-		gtk_container_foreach(GTK_CONTAINER(menuitem), (GtkCallback)enable_markup, NULL);
-	}
+	ADD_MENU_ITEM(font_menu, priv->bold);
+	ADD_MENU_ITEM(font_menu, priv->italic);
+	ADD_MENU_ITEM(font_menu, priv->underline);
+	ADD_MENU_ITEM(font_menu, priv->strike);
+	ADD_MENU_ITEM(font_menu, priv->larger_size);
+#if 0
+	ADD_MENU_ITEM(font_menu, priv->normal_size);
+#endif
+	ADD_MENU_ITEM(font_menu, priv->smaller_size);
+	ADD_MENU_ITEM(font_menu, priv->font);
+	ADD_MENU_ITEM(font_menu, priv->fgcolor);
+	ADD_MENU_ITEM(font_menu, priv->bgcolor);
+	ADD_MENU_ITEM(font_menu, priv->clear);
 
-	g_signal_connect(G_OBJECT(font_button), "button-press-event", G_CALLBACK(button_activate_on_click), toolbar);
-	g_signal_connect(G_OBJECT(font_button), "activate", G_CALLBACK(pidgin_menu_clicked), font_menu);
-	g_signal_connect(G_OBJECT(font_menu), "deactivate", G_CALLBACK(pidgin_menu_deactivate), font_button);
+	g_signal_connect(G_OBJECT(font_button), "toggled",
+	                 G_CALLBACK(pidgin_menu_clicked), font_menu);
+	g_signal_connect(G_OBJECT(font_menu), "deactivate",
+	                 G_CALLBACK(pidgin_menu_deactivate), font_button);
 
+	gtk_container_foreach(GTK_CONTAINER(font_menu), enable_markup, NULL);
+
 	/* Sep */
-	sep = gtk_vseparator_new();
-	gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 0);
-	gtk_widget_show_all(sep);
+	sep = gtk_separator_tool_item_new();
+	gtk_toolbar_insert(GTK_TOOLBAR(priv->lean_view), sep, -1);
 
 	/* Insert */
-	insert_button = gtk_toggle_button_new();
-	gtk_button_set_relief(GTK_BUTTON(insert_button), GTK_RELIEF_NONE);
-	bbox = gtk_hbox_new(FALSE, 3);
-	gtk_container_add(GTK_CONTAINER(insert_button), bbox);
-	image = gtk_image_new_from_stock(PIDGIN_STOCK_TOOLBAR_INSERT, gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL));
-	gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0);
+	insert_button = gtk_toggle_tool_button_new();
+	gtk_toolbar_insert(GTK_TOOLBAR(priv->lean_view), insert_button, -1);
+	gtk_tool_item_set_is_important(insert_button, TRUE);
+	gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(insert_button),
+	                             PIDGIN_STOCK_TOOLBAR_INSERT);
 	label = gtk_label_new_with_mnemonic(_("_Insert"));
-	gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0);
-	gtk_box_pack_start(GTK_BOX(box), insert_button, FALSE, FALSE, 0);
-	gtk_widget_show_all(insert_button);
+	gtk_tool_button_set_label_widget(GTK_TOOL_BUTTON(insert_button), label);
 
 	priv->insert_menu = insert_menu = gtk_menu_new();
 
-	menuitem = gtk_menu_item_new_with_mnemonic(_("_Image"));
-	g_signal_connect_swapped(G_OBJECT(menuitem), "activate", G_CALLBACK(gtk_button_clicked), priv->image);
-	gtk_menu_shell_append(GTK_MENU_SHELL(insert_menu), menuitem);
-	g_signal_connect(G_OBJECT(priv->image), "notify::sensitive",
-			G_CALLBACK(button_sensitiveness_changed), menuitem);
-	g_signal_connect(G_OBJECT(priv->image), "notify::visible",
-			G_CALLBACK(button_visibility_changed), menuitem);
+	ADD_MENU_ITEM(insert_menu, priv->image);
+	ADD_MENU_ITEM(insert_menu, priv->link);
+	ADD_MENU_ITEM(insert_menu, priv->hr);
 
-	menuitem = gtk_menu_item_new_with_mnemonic(_("_Link"));
-	g_signal_connect_swapped(G_OBJECT(menuitem), "activate", G_CALLBACK(gtk_button_clicked), priv->link);
-	gtk_menu_shell_append(GTK_MENU_SHELL(insert_menu), menuitem);
-	g_signal_connect(G_OBJECT(priv->link), "notify::sensitive",
-			G_CALLBACK(button_sensitiveness_changed), menuitem);
-	g_signal_connect(G_OBJECT(priv->link), "notify::visible",
-			G_CALLBACK(button_visibility_changed), menuitem);
+	g_signal_connect(G_OBJECT(insert_button), "toggled",
+	                 G_CALLBACK(pidgin_menu_clicked), insert_menu);
+	g_signal_connect(G_OBJECT(insert_menu), "deactivate",
+	                 G_CALLBACK(pidgin_menu_deactivate), insert_button);
 
-	menuitem = gtk_menu_item_new_with_mnemonic(_("_Horizontal rule"));
-	g_signal_connect(G_OBJECT(menuitem), "activate"	, G_CALLBACK(insert_hr_cb), toolbar);
-	gtk_menu_shell_append(GTK_MENU_SHELL(insert_menu), menuitem);
-	priv->insert_hr = menuitem;
-
-	g_signal_connect(G_OBJECT(insert_button), "button-press-event", G_CALLBACK(button_activate_on_click), toolbar);
-	g_signal_connect(G_OBJECT(insert_button), "activate", G_CALLBACK(pidgin_menu_clicked), insert_menu);
-	g_signal_connect(G_OBJECT(insert_menu), "deactivate", G_CALLBACK(pidgin_menu_deactivate), insert_button);
-	priv->sml = NULL;
-
 	/* Sep */
-	sep = gtk_vseparator_new();
-	gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 0);
-	gtk_widget_show_all(sep);
+	sep = gtk_separator_tool_item_new();
+	gtk_toolbar_insert(GTK_TOOLBAR(priv->lean_view), sep, -1);
 
 	/* Smiley */
-	smiley_button = gtk_button_new();
-	gtk_button_set_relief(GTK_BUTTON(smiley_button), GTK_RELIEF_NONE);
-	bbox = gtk_hbox_new(FALSE, 3);
-	gtk_container_add(GTK_CONTAINER(smiley_button), bbox);
-	image = gtk_image_new_from_stock(PIDGIN_STOCK_TOOLBAR_SMILEY, gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL));
-	gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0);
-	label = gtk_label_new_with_mnemonic(_("_Smile!"));
-	gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0);
-	gtk_box_pack_start(GTK_BOX(box), smiley_button, FALSE, FALSE, 0);
-	g_signal_connect(G_OBJECT(smiley_button), "button-press-event", G_CALLBACK(gtk_webviewtoolbar_popup_menu), toolbar);
-	g_signal_connect_swapped(G_OBJECT(smiley_button), "clicked", G_CALLBACK(gtk_button_clicked), priv->smiley);
-	gtk_widget_show_all(smiley_button);
+	smiley_button = gtk_action_create_tool_item(priv->smiley);
+	gtk_toolbar_insert(GTK_TOOLBAR(priv->lean_view),
+	                   GTK_TOOL_ITEM(smiley_button), -1);
 
 	/* Sep */
-	sep = gtk_vseparator_new();
-	gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 0);
-	gtk_widget_show_all(sep);
+	sep = gtk_separator_tool_item_new();
+	gtk_toolbar_insert(GTK_TOOLBAR(priv->lean_view), sep, -1);
 
 	/* Attention */
-	attention_button = gtk_button_new();
-	gtk_button_set_relief(GTK_BUTTON(attention_button), GTK_RELIEF_NONE);
-	bbox = gtk_hbox_new(FALSE, 3);
-	gtk_container_add(GTK_CONTAINER(attention_button), bbox);
-	image = gtk_image_new_from_stock(PIDGIN_STOCK_TOOLBAR_SEND_ATTENTION,
-		gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL));
-	gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 0);
-	label = gtk_label_new_with_mnemonic(_("_Attention!"));
-	gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0);
-	gtk_box_pack_start(GTK_BOX(box), attention_button, FALSE, FALSE, 0);
-	g_signal_connect_swapped(G_OBJECT(attention_button), "clicked",
-		G_CALLBACK(gtk_button_clicked), priv->attention);
-	gtk_widget_show_all(attention_button);
+	attention_button = gtk_action_create_tool_item(priv->attention);
+	gtk_toolbar_insert(GTK_TOOLBAR(priv->lean_view),
+	                   GTK_TOOL_ITEM(attention_button), -1);
 
-	g_signal_connect(G_OBJECT(priv->attention), "notify::sensitive",
-			G_CALLBACK(button_sensitiveness_changed), attention_button);
-	g_signal_connect(G_OBJECT(priv->attention), "notify::visible",
-			G_CALLBACK(button_visibility_changed), attention_button);
+#undef ADD_MENU_ITEM
+}
 
-	/* set attention button to be greyed out until we get a conversation */
-	gtk_widget_set_sensitive(priv->attention, FALSE);
+static void
+gtk_webviewtoolbar_init(GtkWebViewToolbar *toolbar)
+{
+	GtkWebViewToolbarPriv *priv = GTK_WEBVIEWTOOLBAR_GET_PRIVATE(toolbar);
+	GtkWidget *hbox = GTK_WIDGET(toolbar);
 
-	gtk_box_pack_start(GTK_BOX(hbox), box, FALSE, FALSE, 0);
-	priv->lean_view = box;
-	gtk_widget_show(box);
+	gtk_webviewtoolbar_create_actions(toolbar);
+	gtk_webviewtoolbar_create_wide_view(toolbar);
+	gtk_webviewtoolbar_create_lean_view(toolbar);
 
-	purple_prefs_connect_callback(toolbar, PIDGIN_PREFS_ROOT "/conversations/toolbar/wide",
-			webviewtoolbar_view_pref_changed, toolbar);
+	gtk_box_pack_start(GTK_BOX(hbox), priv->wide_view, TRUE, TRUE, 0);
+	gtk_box_pack_start(GTK_BOX(hbox), priv->lean_view, TRUE, TRUE, 0);
+
+	priv->sml = NULL;
+
+	/* set attention button to be greyed out until we get a conversation */
+	gtk_action_set_sensitive(priv->attention, FALSE);
+
+	purple_prefs_connect_callback(toolbar,
+	                              PIDGIN_PREFS_ROOT "/conversations/toolbar/wide",
+	                              webviewtoolbar_view_pref_changed, toolbar);
 	g_signal_connect_data(G_OBJECT(toolbar), "realize",
-			G_CALLBACK(purple_prefs_trigger_callback), PIDGIN_PREFS_ROOT "/conversations/toolbar/wide",
-			NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
+	                      G_CALLBACK(purple_prefs_trigger_callback),
+	                      PIDGIN_PREFS_ROOT "/conversations/toolbar/wide",
+	                      NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
 
-	gtk_event_box_set_visible_window(GTK_EVENT_BOX(event), FALSE);
-
-	gtk_widget_add_events(event, GDK_BUTTON_PRESS_MASK);
-	gtk_box_pack_start(GTK_BOX(hbox), event, TRUE, TRUE, 0);
-	g_signal_connect(G_OBJECT(event), "button-press-event", G_CALLBACK(gtk_webviewtoolbar_popup_menu), toolbar);
-	gtk_widget_show(event);
+	g_signal_connect(G_OBJECT(hbox), "button-press-event",
+	                 G_CALLBACK(gtk_webviewtoolbar_popup_menu), toolbar);
 }
 
 /******************************************************************************
@@ -1719,7 +1625,7 @@ gtk_webviewtoolbar_switch_active_convers
 
 	/* gray out attention button on protocols that don't support it
 	 for the time being it is always disabled for chats */
-	gtk_widget_set_sensitive(priv->attention,
+	gtk_action_set_sensitive(priv->attention,
 		conv && prpl && purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM &&
 		PURPLE_PLUGIN_PROTOCOL_INFO(prpl)->send_attention != NULL);
 }


More information about the Commits mailing list