pidgin.custom_smiley: 393ce803: Patch from Giulio 'Twain28' Pascali to m...

sadrul at pidgin.im sadrul at pidgin.im
Sun May 11 18:05:44 EDT 2008


-----------------------------------------------------------------
Revision: 393ce80388ba43499456e460fbd4d1cd6f5f74f1
Ancestor: 6e7c4dd26da75349ba06490409bce8a1ccfbcb2a
Author: sadrul at pidgin.im
Date: 2008-05-11T22:02:37
Branch: im.pidgin.pidgin.custom_smiley
URL: http://d.pidgin.im/viewmtn/revision/info/393ce80388ba43499456e460fbd4d1cd6f5f74f1

Modified files:
        COPYRIGHT pidgin/gtkimhtmltoolbar.c

ChangeLog: 

Patch from Giulio 'Twain28' Pascali to make the smiley window scrollable.
This can come in handy if you have a lot of custom smileys. Closes #4017.
Thanks, Twain28!

-------------- next part --------------
============================================================
--- COPYRIGHT	346b900169ce7f59809c8d73d79502e35544a52c
+++ COPYRIGHT	bfb5fa2c52f4ffdb95a492a9a0a6dba5171fe3c8
@@ -286,6 +286,7 @@ Laszlo Pandy
 John Oyler
 Matt Pandina
 Laszlo Pandy
+Giulio 'Twain28' Pascali
 Ricardo Fernandez Pascual
 Riley Patterson
 Havoc Pennington
============================================================
--- pidgin/gtkimhtmltoolbar.c	64483874a30e438c6fc27d74236cee5b6ac4aeaa
+++ pidgin/gtkimhtmltoolbar.c	07b8465fec563f0f2f3136af503ede8204c5b85e
@@ -769,6 +769,8 @@ insert_smiley_cb(GtkWidget *smiley, GtkI
 	GSList *smileys, *unique_smileys = NULL;
 	const GSList *custom_smileys = NULL;
 	gboolean supports_custom = FALSE;
+	GtkRequisition req;
+	GtkWidget *scrolled, *viewport;
 
 	if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(smiley))) {
 		destroy_smiley_dialog(toolbar);
@@ -803,7 +805,6 @@ insert_smiley_cb(GtkWidget *smiley, GtkI
 	}
 
 	dialog = pidgin_create_dialog(_("Smile!"), 0, "smiley_dialog", FALSE);
-
 	gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
 
 	if (unique_smileys != NULL) {
@@ -859,18 +860,41 @@ insert_smiley_cb(GtkWidget *smiley, GtkI
 		g_signal_connect(G_OBJECT(dialog), "button-press-event", (GCallback)smiley_dialog_input_cb, toolbar);
 	}
 
-	g_signal_connect(G_OBJECT(dialog), "key-press-event", (GCallback)smiley_dialog_input_cb, toolbar);
-	gtk_container_add(GTK_CONTAINER(pidgin_dialog_get_vbox(GTK_DIALOG(dialog))), smiley_table);
+	scrolled = gtk_scrolled_window_new (NULL, NULL);
+	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW (scrolled), GTK_SHADOW_NONE);
+	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled),
+			GTK_POLICY_NEVER, GTK_POLICY_NEVER);
+	gtk_container_add(GTK_CONTAINER(pidgin_dialog_get_vbox(GTK_DIALOG(dialog))), scrolled);
+	gtk_widget_show(scrolled);
 
+	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), smiley_table);
 	gtk_widget_show(smiley_table);
 
+	viewport = gtk_widget_get_parent(smiley_table);
+	gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE);
+
 	/* connect signals */
 	g_signal_connect_swapped(G_OBJECT(dialog), "destroy", G_CALLBACK(close_smiley_dialog), toolbar);
+	g_signal_connect(G_OBJECT(dialog), "key-press-event", G_CALLBACK(smiley_dialog_input_cb), toolbar);
 
+	gtk_window_set_transient_for(GTK_WINDOW(dialog),
+			GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(toolbar))));
+
 	/* show everything */
 	gtk_widget_show_all(dialog);
-	gtk_window_set_transient_for(GTK_WINDOW(dialog),
-			GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(toolbar))));
+
+	gtk_widget_size_request(viewport, &req);
+	gtk_widget_set_size_request(scrolled, req.width, req.height);
+
+	/* The window has to be made resizable, and the scrollbars in the scrolled window
+	 * enabled only after setting the desired size of the window. If we do either of
+	 * these tasks before now, GTK+ miscalculates the required size, and erronously
+	 * makes one or both scrollbars visible (sometimes).
+	 * I too think this hack is gross. But I couldn't find a better way -- sadrul */
+	gtk_window_set_resizable(GTK_WINDOW(dialog), TRUE);
+	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled),
+			GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
 #ifdef _WIN32
 	winpidgin_ensure_onscreen(dialog);
 #endif


More information about the Commits mailing list