changeset 32566:e84bdaa9d227

Replace GtkTooltips code with GtkTooltip on GTK+ 2.12+.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Wed, 08 Apr 2009 05:46:20 +0000
parents 865ed80b17e1
children f08acd4299d5
files pidgin/gtkblist.c pidgin/gtkconv.c pidgin/gtkconv.h pidgin/gtkdocklet-x11.c pidgin/gtkimhtmltoolbar.c pidgin/gtkimhtmltoolbar.h pidgin/gtkmenutray.c pidgin/gtkmenutray.h
diffstat 8 files changed, 64 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkblist.c	Wed Apr 08 01:40:39 2009 +0000
+++ b/pidgin/gtkblist.c	Wed Apr 08 05:46:20 2009 +0000
@@ -5269,6 +5269,9 @@
 headline_style_set (GtkWidget *widget,
 		    GtkStyle  *prev_style)
 {
+#if GTK_CHECK_VERSION(2,12,0)
+	/* TODO: Need to figure out how to do this in 2.12+ */
+#else
 	GtkTooltips *tooltips;
 	GtkStyle *style;
 
@@ -5295,6 +5298,7 @@
 	gtkblist->changing_style = FALSE;
 
 	g_object_unref (tooltips);
+#endif
 }
 
 /******************************************/
--- a/pidgin/gtkconv.c	Wed Apr 08 01:40:39 2009 +0000
+++ b/pidgin/gtkconv.c	Wed Apr 08 05:46:20 2009 +0000
@@ -5195,7 +5195,9 @@
 	gtkconv->send_history = g_list_append(NULL, NULL);
 
 	/* Setup some initial variables. */
+#if !GTK_CHECK_VERSION(2,12,0)
 	gtkconv->tooltips = gtk_tooltips_new();
+#endif
 	gtkconv->unseen_state = PIDGIN_UNSEEN_NONE;
 	gtkconv->unseen_count = 0;
 
@@ -5388,7 +5390,9 @@
 		g_free(gtkconv->u.chat);
 	}
 
+#if !GTK_CHECK_VERSION(2,12,0)
 	gtk_object_sink(GTK_OBJECT(gtkconv->tooltips));
+#endif
 
 	gtkconv->send_history = g_list_first(gtkconv->send_history);
 	g_list_foreach(gtkconv->send_history, (GFunc)g_free, NULL);
@@ -6603,8 +6607,13 @@
 			topic = purple_conv_chat_get_topic(chat);
 
 			gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : "");
+#if GTK_CHECK_VERSION(2,12,0)
+			gtk_widget_set_tooltip_text(gtkchat->topic_text,
+			                            topic ? topic : "");
+#else
 			gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text,
 			                     topic ? topic : "", NULL);
+#endif
 		}
 	}
 
@@ -9372,8 +9381,12 @@
 	g_signal_connect(G_OBJECT(gtkconv->close), "leave-notify-event", G_CALLBACK(close_button_left_cb), close_image);
 	gtk_widget_show(close_image);
 	gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image);
+#if GTK_CHECK_VERSION(2,12,0)
+	gtk_widget_set_tooltip_text(gtkconv->close, _("Close conversation"));
+#else
 	gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close,
 	                     _("Close conversation"), NULL);
+#endif
 
 	g_signal_connect(G_OBJECT(gtkconv->close), "button-press-event",
 			 G_CALLBACK(close_conv_cb), gtkconv);
--- a/pidgin/gtkconv.h	Wed Apr 08 01:40:39 2009 +0000
+++ b/pidgin/gtkconv.h	Wed Apr 08 05:46:20 2009 +0000
@@ -121,7 +121,11 @@
 
 	gboolean make_sound;
 
+#if GTK_CHECK_VERSION(2,12,0)
+	gpointer depr2;
+#else
 	GtkTooltips *tooltips;
+#endif
 
 	GtkWidget *tab_cont;
 	GtkWidget *tabby;
--- a/pidgin/gtkdocklet-x11.c	Wed Apr 08 01:40:39 2009 +0000
+++ b/pidgin/gtkdocklet-x11.c	Wed Apr 08 05:46:20 2009 +0000
@@ -39,7 +39,9 @@
 /* globals */
 static EggTrayIcon *docklet = NULL;
 static GtkWidget *image = NULL;
+#if !GTK_CHECK_VERSION(2,12,0)
 static GtkTooltips *tooltips = NULL;
+#endif
 static GdkPixbuf *blank_icon = NULL;
 static int embed_timeout = 0;
 static int docklet_height = 0;
@@ -164,6 +166,13 @@
 static void
 docklet_x11_set_tooltip(gchar *tooltip)
 {
+#if GTK_CHECK_VERSION(2,12,0)
+	if (tooltip) {
+		gtk_widget_set_tooltip_text(image->parent, tooltip);
+	} else {
+		gtk_widget_set_tooltip_text(image->parent, ""); /* NULL? */
+	}
+#else
 	if (!tooltips)
 		tooltips = gtk_tooltips_new();
 
@@ -175,6 +184,7 @@
 		gtk_tooltips_set_tip(tooltips, image->parent, "", NULL);
 		gtk_tooltips_disable(tooltips);
 	}
+#endif
 }
 
 #if GTK_CHECK_VERSION(2,2,0)
--- a/pidgin/gtkimhtmltoolbar.c	Wed Apr 08 01:40:39 2009 +0000
+++ b/pidgin/gtkimhtmltoolbar.c	Wed Apr 08 05:46:20 2009 +0000
@@ -669,7 +669,11 @@
 	g_object_set_data(G_OBJECT(button), "smiley_text", face);
 	g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(insert_smiley_text), toolbar);
 
+#if GTK_CHECK_VERSION(2,12,0)
+	gtk_widget_set_tooltip_text(button, face);
+#else
 	gtk_tooltips_set_tip(toolbar->tooltips, button, face, NULL);
+#endif
 
 	/* these look really weird with borders */
 	gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
@@ -683,7 +687,11 @@
 		g_snprintf(tip, sizeof(tip),
 			_("This smiley is disabled because a custom smiley exists for this shortcut:\n %s"),
 			face);
+#if GTK_CHECK_VERSION(2,12,0)
+		gtk_widget_set_tooltip_text(button, tip);
+#else
 		gtk_tooltips_set_tip(toolbar->tooltips, button, tip, NULL);
+#endif
 		gtk_widget_set_sensitive(button, FALSE);
 	} else if (psmiley) {
 		/* Remove the button if the smiley is destroyed */
@@ -1147,7 +1155,9 @@
 	}
 
 	g_free(toolbar->sml);
+#if !GTK_CHECK_VERSION(2,12,0)
 	gtk_object_sink(GTK_OBJECT(toolbar->tooltips));
+#endif
 
 	menu = g_object_get_data(object, "font_menu");
 	if (menu)
@@ -1244,7 +1254,11 @@
 			g_signal_connect(G_OBJECT(button), "clicked",
 					 G_CALLBACK(buttons[iter].callback), toolbar);
 			*(buttons[iter].button) = button;
+#if GTK_CHECK_VERSION(2,12,0)
+			gtk_widget_set_tooltip_text(button, buttons[iter].tooltip);
+#else
 			gtk_tooltips_set_tip(toolbar->tooltips, button, buttons[iter].tooltip, NULL);
+#endif
 		} else
 			button = gtk_vseparator_new();
 		gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
@@ -1334,7 +1348,9 @@
 	toolbar->smiley_dialog = NULL;
 	toolbar->image_dialog = NULL;
 
+#if !GTK_CHECK_VERSION(2,12,0)
 	toolbar->tooltips = gtk_tooltips_new();
+#endif
 
 	gtk_box_set_spacing(GTK_BOX(toolbar), 3);
 
--- a/pidgin/gtkimhtmltoolbar.h	Wed Apr 08 01:40:39 2009 +0000
+++ b/pidgin/gtkimhtmltoolbar.h	Wed Apr 08 05:46:20 2009 +0000
@@ -46,7 +46,11 @@
 
 	GtkWidget *imhtml;
 
+#if GTK_CHECK_VERSION(2,12,0)
+	gpointer depr1;
+#else
 	GtkTooltips *tooltips;
+#endif
 
 	GtkWidget *bold;
 	GtkWidget *italic;
--- a/pidgin/gtkmenutray.c	Wed Apr 08 01:40:39 2009 +0000
+++ b/pidgin/gtkmenutray.c	Wed Apr 08 05:46:20 2009 +0000
@@ -104,9 +104,11 @@
 		gtk_widget_destroy(GTK_WIDGET(tray->tray));
 #endif
 
+#if !GTK_CHECK_VERSION(2,12,0)
 	if (tray->tooltips) {
 		gtk_object_sink(GTK_OBJECT(tray->tooltips));
 	}
+#endif
 
 	G_OBJECT_CLASS(parent_class)->finalize(obj);
 }
@@ -244,13 +246,15 @@
 void
 pidgin_menu_tray_set_tooltip(PidginMenuTray *menu_tray, GtkWidget *widget, const char *tooltip)
 {
+#if !GTK_CHECK_VERSION(2,12,0)
 	if (!menu_tray->tooltips)
 		menu_tray->tooltips = gtk_tooltips_new();
+#endif
 
 	/* Should we check whether widget is a child of menu_tray? */
 
 	/*
-	 * If the widget does not have it's own window, then it
+	 * If the widget does not have its own window, then it
 	 * must have automatically been added to an event box
 	 * when it was added to the menu tray.  If this is the
 	 * case, we want to set the tooltip on the widget's parent,
@@ -259,6 +263,10 @@
 	if (GTK_WIDGET_NO_WINDOW(widget))
 		widget = widget->parent;
 
+#if GTK_CHECK_VERSION(2,12,0)
+	gtk_widget_set_tooltip_text(widget, tooltip);
+#else
 	gtk_tooltips_set_tip(menu_tray->tooltips, widget, tooltip, NULL);
+#endif
 }
 
--- a/pidgin/gtkmenutray.h	Wed Apr 08 01:40:39 2009 +0000
+++ b/pidgin/gtkmenutray.h	Wed Apr 08 05:46:20 2009 +0000
@@ -40,7 +40,11 @@
 struct _PidginMenuTray {
 	GtkMenuItem gparent;					/**< The parent instance */
 	GtkWidget *tray;						/**< The tray */
+#if GTK_CHECK_VERSION(2,12,0)
+	gpointer depr1;
+#else
 	GtkTooltips *tooltips;					/**< Tooltips */
+#endif
 };
 
 /** A PidginMenuTrayClass */