im.pidgin.pidgin: e7dd3b30ece9f95dd95249583812659312c457e6

sadrul at pidgin.im sadrul at pidgin.im
Thu Dec 27 20:55:55 EST 2007


-----------------------------------------------------------------
Revision: e7dd3b30ece9f95dd95249583812659312c457e6
Ancestor: b7ae28ad92ca5e196b41a7357f4a185b3dd99bd6
Author: sadrul at pidgin.im
Date: 2007-12-28T01:57:17
Branch: im.pidgin.pidgin

Modified files:
        pidgin/gtkplugin.c

ChangeLog: 

Add tooltips to the plugin window. I did it mostly to test the new tooltip
functions. They seem to be working OK, and pretty simple to use. But I will
be happy to listen to comments/suggestions etc.
I am thrusting this tooltip in the plugin window down everyone's throat.
But feel totally free to vomit it out ;)

-------------- next part --------------
============================================================
--- pidgin/gtkplugin.c	052e3b207c28085ff004f21ea4ecb3f433fa632c
+++ pidgin/gtkplugin.c	e85b1fc6a511e98d638c261205dc43268cb43e57
@@ -31,6 +31,7 @@
 #include "debug.h"
 #include "prefs.h"
 #include "request.h"
+#include "pidgintooltip.h"
 
 #include <string.h>
 
@@ -531,6 +532,58 @@ show_plugin_prefs_cb(GtkTreeView *view, 
 	plugin_dialog_response_cb(dialog, PIDGIN_RESPONSE_CONFIGURE, sel);
 }
 
+static gboolean
+pidgin_plugins_paint_tooltip(GtkWidget *tipwindow, gpointer data)
+{
+	PangoLayout *layout = g_object_get_data(G_OBJECT(tipwindow), "tooltip-plugin");
+	gtk_paint_layout(tipwindow->style, tipwindow->window, GTK_STATE_NORMAL, FALSE,
+			NULL, tipwindow, "tooltip",
+			6, 6, layout);
+	return TRUE;
+}
+
+static gboolean
+pidgin_plugins_create_tooltip(GtkWidget *tipwindow, GtkTreePath *path,
+		gpointer data, int *w, int *h)
+{
+	GtkTreeIter iter;
+	GtkTreeView *treeview = GTK_TREE_VIEW(data);
+	PurplePlugin *plugin = NULL;
+	GtkTreeModel *model = gtk_tree_view_get_model(treeview);
+	PangoLayout *layout;
+	int width, height;
+	char *markup, *name, *desc, *author;
+
+	if (!gtk_tree_model_get_iter(model, &iter, path))
+		return FALSE;
+
+	gtk_tree_model_get(model, &iter, 2, &plugin, -1);
+
+	markup = g_strdup_printf("<span size='x-large' weight='bold'>%s</span>\n<b>Description:</b> %s\n<b>Author:</b> %s",
+			name = g_markup_escape_text(purple_plugin_get_name(plugin), -1),
+			desc = g_markup_escape_text(purple_plugin_get_description(plugin), -1),
+			author = g_markup_escape_text(purple_plugin_get_author(plugin), -1));
+
+	layout = gtk_widget_create_pango_layout(tipwindow, NULL);
+	pango_layout_set_markup(layout, markup, -1);
+	pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
+	pango_layout_set_width(layout, 600000);
+	pango_layout_get_size(layout, &width, &height);
+	g_object_set_data_full(G_OBJECT(tipwindow), "tooltip-plugin", layout, g_object_unref);
+
+	if (w)
+		*w = PANGO_PIXELS(width) + 12;
+	if (h)
+		*h = PANGO_PIXELS(height) + 12;
+
+	g_free(markup);
+	g_free(name);
+	g_free(desc);
+	g_free(author);
+
+	return TRUE;
+}
+
 void pidgin_plugin_dialog_show()
 {
 	GtkWidget *sw;
@@ -613,6 +666,10 @@ void pidgin_plugin_dialog_show()
 	gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(event_view),
 				pidgin_tree_view_search_equal_func, NULL, NULL);
 
+	pidgin_tooltip_setup_for_treeview(event_view, event_view,
+			pidgin_plugins_create_tooltip,
+			pidgin_plugins_paint_tooltip);
+
 	expander = gtk_expander_new(_("<b>Plugin Details</b>"));
 	gtk_expander_set_use_markup(GTK_EXPANDER(expander), TRUE);
 	plugin_details = gtk_label_new(NULL);


More information about the Commits mailing list