/pidgin/main: ce4447562d64: Add checks for old GTK+2 stuff.

Elliott Sales de Andrade qulogic at pidgin.im
Tue Jul 24 04:03:53 EDT 2012


Changeset: ce4447562d64f3a463c4ab47bc6e4234062fb809
Author:	 Elliott Sales de Andrade <qulogic at pidgin.im>
Date:	 2012-07-23 22:52 -0400
Branch:	 cpw.qulogic.gtk3-required
URL: http://hg.pidgin.im/pidgin/main/rev/ce4447562d64

Description:

Add checks for old GTK+2 stuff.

diffstat:

 pidgin/gtk3compat.h                   |  172 ++++++++++++++++++++
 pidgin/gtkaccount.c                   |   18 +-
 pidgin/gtkblist-theme-loader.c        |    3 +
 pidgin/gtkblist.c                     |  284 ++++++++++++++++++++++++++++++---
 pidgin/gtkcellrendererexpander.c      |   72 ++++++-
 pidgin/gtkcertmgr.c                   |    4 +
 pidgin/gtkconv.c                      |   32 +--
 pidgin/gtkdebug.c                     |   22 +--
 pidgin/gtkdialogs.c                   |    7 +
 pidgin/gtkdnd-hints.c                 |   39 ++++
 pidgin/gtkdocklet.c                   |   28 +++-
 pidgin/gtkft.c                        |    6 +-
 pidgin/gtkimhtml.c                    |   19 +-
 pidgin/gtkimhtmltoolbar.c             |    2 +
 pidgin/gtklog.c                       |    2 +
 pidgin/gtkmedia.c                     |   10 +-
 pidgin/gtkmenutray.c                  |   30 +++
 pidgin/gtknotify.c                    |   15 +-
 pidgin/gtkplugin.c                    |   15 +-
 pidgin/gtkpluginpref.c                |    3 +
 pidgin/gtkpounce.c                    |   11 +-
 pidgin/gtkprefs.c                     |   12 +-
 pidgin/gtkprivacy.c                   |    2 +
 pidgin/gtkrequest.c                   |   26 +-
 pidgin/gtkroomlist.c                  |   64 ++++++-
 pidgin/gtksavedstatuses.c             |    2 +
 pidgin/gtksession.c                   |    2 +
 pidgin/gtksmiley.c                    |    9 +
 pidgin/gtksourceundomanager.c         |    5 +-
 pidgin/gtkstatusbox.c                 |   58 ++++++-
 pidgin/gtkutils.c                     |   11 +
 pidgin/gtkwebview.c                   |   13 +-
 pidgin/gtkwhiteboard.c                |   85 +++++++--
 pidgin/minidialog.c                   |    7 +-
 pidgin/pidgintooltip.c                |   25 ++-
 pidgin/plugins/disco/gtkdisco.c       |   16 +-
 pidgin/plugins/gestures/stroke-draw.c |    2 +
 pidgin/plugins/ticker/gtkticker.c     |   64 +++++++-
 pidgin/plugins/timestamp_format.c     |    1 -
 pidgin/plugins/xmppconsole.c          |    2 +
 40 files changed, 987 insertions(+), 213 deletions(-)

diffs (truncated from 2455 to 300 lines):

diff --git a/pidgin/gtk3compat.h b/pidgin/gtk3compat.h
new file mode 100644
--- /dev/null
+++ b/pidgin/gtk3compat.h
@@ -0,0 +1,172 @@
+/* pidgin
+ *
+ * Pidgin is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ */
+#ifndef _PIDGINGTK3COMPAT_H_
+#define _PIDGINGTK3COMPAT_H_
+
+/* This file is internal to Pidgin. Do not use! 
+ * Also, any public API should not depend on this file.
+ */
+
+#if !GTK_CHECK_VERSION(3,0,0)
+
+#define gdk_x11_window_get_xid GDK_WINDOW_XWINDOW
+
+#if !GTK_CHECK_VERSION(2,24,0)
+
+#define gdk_x11_set_sm_client_id gdk_set_sm_client_id
+#define gdk_window_get_display gdk_drawable_get_display
+#define GtkComboBoxText GtkComboBox
+#define GTK_COMBO_BOX_TEXT GTK_COMBO_BOX
+#define gtk_combo_box_text_new gtk_combo_box_new_text
+#define gtk_combo_box_text_append_text gtk_combo_box_append_text
+#define gtk_combo_box_text_get_active_text gtk_combo_box_get_active_text
+#define gtk_combo_box_text_remove gtk_combo_box_remove_text
+
+gint inline gdk_window_get_width(GdkWindow *x)
+{
+	gint w;
+	gdk_drawable_get_size(GDK_DRAWABLE(x), &w, NULL);
+	return w;
+}	
+
+gint inline gdk_window_get_height(GdkWindow *x)
+{
+	gint h;
+	gdk_drawable_get_size(GDK_DRAWABLE(x), NULL, &h);
+	return h;
+}	
+
+#if !GTK_CHECK_VERSION(2,22,0)
+
+#define gdk_drag_context_get_actions(x) (x)->action
+#define gdk_drag_context_get_suggested_action(x) (x)->suggested_action
+#define gtk_text_view_get_vadjustment(x) (x)->vadjustment
+#define gtk_font_selection_dialog_get_font_selection(x) (x)->fontsel
+
+#if !GTK_CHECK_VERSION(2,20,0)
+
+#define gtk_widget_get_mapped GTK_WIDGET_MAPPED
+#define gtk_widget_set_mapped(x,y) do { \
+	if (y) \
+		GTK_WIDGET_SET_FLAGS(x, GTK_MAPPED); \
+	else \
+		GTK_WIDGET_UNSET_FLAGS(x, GTK_MAPPED); \
+} while(0)
+#define gtk_widget_get_realized GTK_WIDGET_REALIZED
+#define gtk_widget_set_realized(x,y) do { \
+	if (y) \
+		GTK_WIDGET_SET_FLAGS(x, GTK_REALIZED); \
+	else \
+		GTK_WIDGET_UNSET_FLAGS(x, GTK_REALIZED); \
+} while(0)
+
+#if !GTK_CHECK_VERSION(2,18,0)
+
+#define gtk_widget_get_state GTK_WIDGET_STATE
+#define gtk_widget_is_drawable GTK_WIDGET_DRAWABLE
+#define gtk_widget_get_visible GTK_WIDGET_VISIBLE
+#define gtk_widget_has_focus GTK_WIDGET_HAS_FOCUS
+#define gtk_widget_is_sensitive GTK_WIDGET_IS_SENSITIVE
+#define gtk_widget_get_has_window(x) !GTK_WIDGET_NO_WINDOW(x)
+#define gtk_widget_set_has_window(x,y) do { \
+	if (!y) \
+		GTK_WIDGET_SET_FLAGS(x, GTK_NO_WINDOW); \
+	else \
+		GTK_WIDGET_UNSET_FLAGS(x, GTK_NO_WINDOW); \
+} while(0)
+#define gtk_widget_get_allocation(x,y) *(y) = (x)->allocation
+#define gtk_widget_set_allocation(x,y) (x)->allocation = *(y)
+#define gtk_widget_set_window(x,y) ((x)->window = (y))
+#define gtk_widget_set_can_default(w,y) do { \
+	if (y) \
+		GTK_WIDGET_SET_FLAGS((w), GTK_CAN_DEFAULT); \
+	else \
+		GTK_WIDGET_UNSET_FLAGS((w), GTK_CAN_DEFAULT); \
+} while (0)
+#define gtk_widget_set_can_focus(x,y) do {\
+	if (y) \
+		GTK_WIDGET_SET_FLAGS(x, GTK_CAN_FOCUS); \
+	else \
+		GTK_WIDGET_UNSET_FLAGS(x, GTK_CAN_FOCUS); \
+} while(0)
+#define gtk_cell_renderer_set_padding(x,y,z) do { \
+	(x)->xpad = (y); \
+	(x)->ypad = (z); \
+} while (0)
+#define gtk_cell_renderer_get_padding(x,y,z) do { \
+	*(y) = (x)->xpad; \
+	*(z) = (x)->ypad; \
+} while (0)
+#define gtk_cell_renderer_get_alignment(x,y,z) do { \
+	*(y) = (x)->xalign; \
+	*(z) = (x)->yalign; \
+} while (0)
+	
+#if !GTK_CHECK_VERSION(2,16,0)
+
+#define gtk_status_icon_set_tooltip_text gtk_status_icon_set_tooltip
+
+#if !GTK_CHECK_VERSION(2,14,0)
+
+#define gtk_widget_get_window(x) (x)->window
+#define gtk_widget_set_style(x,y) (x)->style = (y)
+#define gtk_selection_data_get_data(x) (x)->data
+#define gtk_selection_data_get_length(x) (x)->length
+#define gtk_selection_data_get_format(x) (x)->format
+#define gtk_selection_data_get_target(x) (x)->target
+#define gtk_dialog_get_content_area(x) GTK_DIALOG(x)->vbox
+#define gtk_dialog_get_action_area(x) GTK_DIALOG(x)->action_area
+#define gtk_adjustment_get_page_size(x) (x)->page_size
+#define gtk_adjustment_get_lower(x) (x)->lower
+#define gtk_adjustment_get_upper(x) (x)->upper
+#define gtk_font_selection_get_size_entry (x)->size_entry
+#define gtk_font_selection_get_family_list (x)->family_list
+#define gtk_font_selection_dialog_get_ok_button(x) (x)->ok_button
+#define gtk_font_selection_dialog_get_cancel_button(x) (x)->cancel_button
+#define gtk_color_selection_dialog_get_color_selection(x) (x)->colorsel
+#define gtk_menu_item_get_accel_path(x) (x)->accel_path
+
+#if !GTK_CHECK_VERSION(2,12,0)
+
+#ifdef GTK_TOOLTIPS_VAR
+#define gtk_widget_set_tooltip_text(w, t) gtk_tooltips_set_tip(GTK_TOOLTIPS_VAR, (w), (t), NULL)
+#else
+#define gtk_widget_set_tooltip_text(w, t) gtk_tooltips_set_tip(tooltips, (w), (t), NULL)
+#endif
+
+#endif /* 2.12.0 */
+
+#endif /* 2.14.0 */
+
+#endif /* 2.16.0 */
+
+#endif /* 2.18.0 */
+
+#endif /* 2.20.0 */
+
+#endif /* 2.22.0 */
+
+#endif /* 2.24.0 */
+
+#endif /* 3.0.0 */
+
+#endif /* _PIDGINGTK3COMPAT_H_ */
+
diff --git a/pidgin/gtkaccount.c b/pidgin/gtkaccount.c
--- a/pidgin/gtkaccount.c
+++ b/pidgin/gtkaccount.c
@@ -48,6 +48,8 @@
 #include "pidginstock.h"
 #include "minidialog.h"
 
+#include "gtk3compat.h"
+
 enum
 {
 	COLUMN_ICON,
@@ -483,11 +485,7 @@
 
 	if (dialog->protocol_menu != NULL)
 	{
-#if GTK_CHECK_VERSION(2,12,0)
 		g_object_ref(G_OBJECT(dialog->protocol_menu));
-#else
-		gtk_widget_ref(dialog->protocol_menu);
-#endif
 		hbox = g_object_get_data(G_OBJECT(dialog->protocol_menu), "container");
 		gtk_container_remove(GTK_CONTAINER(hbox), dialog->protocol_menu);
 	}
@@ -514,21 +512,13 @@
 	{
 		dialog->protocol_menu = pidgin_protocol_option_menu_new(
 				dialog->protocol_id, G_CALLBACK(set_account_protocol_cb), dialog);
-#if GTK_CHECK_VERSION(2,12,0)
 		g_object_ref(G_OBJECT(dialog->protocol_menu));
-#else
-		gtk_widget_ref(dialog->protocol_menu);
-#endif
 	}
 
 	hbox = add_pref_box(dialog, vbox, _("Pro_tocol:"), dialog->protocol_menu);
 	g_object_set_data(G_OBJECT(dialog->protocol_menu), "container", hbox);
 
-#if GTK_CHECK_VERSION(2,12,0)
 	g_object_unref(G_OBJECT(dialog->protocol_menu));
-#else
-	gtk_widget_unref(dialog->protocol_menu);
-#endif
 
 	/* Username */
 	dialog->username_entry = gtk_entry_new();
@@ -2399,7 +2389,11 @@
 	width  = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/accounts/dialog/width");
 	height = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/accounts/dialog/height");
 
+#if GTK_CHECK_VERSION(3,0,0)
 	dialog->window = win = pidgin_create_dialog(_("Accounts"), 0, "accounts", TRUE);
+#else
+	dialog->window = win = pidgin_create_dialog(_("Accounts"), PIDGIN_HIG_BORDER, "accounts", TRUE);
+#endif
 	gtk_window_set_default_size(GTK_WINDOW(win), width, height);
 
 	g_signal_connect(G_OBJECT(win), "delete_event",
diff --git a/pidgin/gtkblist-theme-loader.c b/pidgin/gtkblist-theme-loader.c
--- a/pidgin/gtkblist-theme-loader.c
+++ b/pidgin/gtkblist-theme-loader.c
@@ -65,6 +65,9 @@
 	GdkColor color;
 
 	if (temp && gdk_color_parse(temp, &color)) {
+#if !GTK_CHECK_VERSION(3,0,0)
+		gdk_colormap_alloc_color(gdk_colormap_get_system(), &color, FALSE, TRUE);
+#endif
 		return gdk_color_copy(&color);
 	} else {
 		return NULL;
diff --git a/pidgin/gtkblist.c b/pidgin/gtkblist.c
--- a/pidgin/gtkblist.c
+++ b/pidgin/gtkblist.c
@@ -71,6 +71,8 @@
 #include <gtk/gtk.h>
 #include <gdk/gdk.h>
 
+#include "gtk3compat.h"
+
 typedef struct
 {
 	PurpleAccount *account;
@@ -120,6 +122,13 @@
 	PidginMiniDialog *signed_on_elsewhere;
 
 	PidginBlistTheme *current_theme;
+
+#if !GTK_CHECK_VERSION(3,0,0)
+	GdkCursor *hand_cursor;         /**< Hand cursor */
+	GdkCursor *arrow_cursor;        /**< Arrow cursor */
+	gboolean changing_style;        /**< True when changing GTK+ theme style */
+#endif
+
 } PidginBuddyListPrivate;
 
 #define PIDGIN_BUDDY_LIST_GET_PRIVATE(list) \
@@ -2548,7 +2557,7 @@
 			}
 		}
 
-		if (pidgin_parse_x_im_contact((const char *) data, FALSE, &account,
+		if (pidgin_parse_x_im_contact((const char *)data, FALSE, &account,
 										&protocol, &username, &alias))
 		{
 			if (account == NULL)
@@ -2608,7 +2617,7 @@
 			}
 		}
 
-		result = parse_vcard((const gchar *) data, group);
+		result = parse_vcard((const gchar *)data, group);
 
 		gtk_drag_finish(dc, result,
 		                gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE, t);
@@ -2996,17 +3005,29 @@
 
 		if (td->avatar && pidgin_gdk_pixbuf_is_opaque(td->avatar))
 		{
+#if GTK_CHECK_VERSION(3,0,0)
 			if (dir == GTK_TEXT_DIR_RTL)
 				gtk_paint_flat_box(style, cr, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
-						gtkblist->tipwindow, "tooltip",



More information about the Commits mailing list