diff options
author | Elliott Sales de Andrade <qulogic@pidgin.im> | 2012-07-23 22:52:00 -0400 |
---|---|---|
committer | Elliott Sales de Andrade <qulogic@pidgin.im> | 2012-07-23 22:52:00 -0400 |
commit | e7b1bde5358aab00f0610005cc210afb929301a6 (patch) | |
tree | a4dc9b64d3ec6b26fdcf814ea2c76af645052a9a | |
parent | ada7704454edf49b8617c8a4689106c212049474 (diff) | |
download | pidgin-e7b1bde5358aab00f0610005cc210afb929301a6.tar.gz |
Add checks for old GTK+2 stuff.
40 files changed, 981 insertions, 207 deletions
diff --git a/pidgin/gtk3compat.h b/pidgin/gtk3compat.h new file mode 100644 index 0000000000..b1d68d308c --- /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 index 0ff2602ebb..21dc1e9692 100644 --- 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 @@ add_login_options(AccountPrefsDialog *dialog, GtkWidget *parent) 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 @@ add_login_options(AccountPrefsDialog *dialog, GtkWidget *parent) { 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 @@ pidgin_accounts_window_show(void) 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 index ca1cf65771..47dddee588 100644 --- a/pidgin/gtkblist-theme-loader.c +++ b/pidgin/gtkblist-theme-loader.c @@ -65,6 +65,9 @@ parse_color(xmlnode *node, const char *tag) 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 index e953eb4488..c0b94f8e0c 100644 --- 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 @@ typedef struct 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 @@ static void pidgin_blist_drag_data_rcv_cb(GtkWidget *widget, GdkDragContext *dc, } } - 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 @@ static void pidgin_blist_drag_data_rcv_cb(GtkWidget *widget, GdkDragContext *dc, } } - 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 @@ pidgin_blist_paint_tip(GtkWidget *widget, cairo_t *cr, gpointer null) 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", - TOOLTIP_BORDER - 1, current_height - 1, - td->avatar_width + 2, td->avatar_height + 2); + gtkblist->tipwindow, "tooltip", + TOOLTIP_BORDER - 1, current_height - 1, + td->avatar_width + 2, td->avatar_height + 2); else gtk_paint_flat_box(style, cr, GTK_STATE_NORMAL, GTK_SHADOW_OUT, - gtkblist->tipwindow, "tooltip", - max_width - (td->avatar_width + TOOLTIP_BORDER) - 1, - current_height - 1, - td->avatar_width + 2, td->avatar_height + 2); + gtkblist->tipwindow, "tooltip", + max_width - (td->avatar_width + TOOLTIP_BORDER) - 1, + current_height - 1, + td->avatar_width + 2, td->avatar_height + 2); +#else + if (dir == GTK_TEXT_DIR_RTL) + gtk_paint_flat_box(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, + NULL, gtkblist->tipwindow, "tooltip", + TOOLTIP_BORDER -1, current_height -1, td->avatar_width +2, td->avatar_height + 2); + else + gtk_paint_flat_box(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, + NULL, gtkblist->tipwindow, "tooltip", + max_width - (td->avatar_width+ TOOLTIP_BORDER)-1, + current_height-1,td->avatar_width+2, td->avatar_height+2); +#endif } if (td->status_icon) { @@ -3043,30 +3064,57 @@ pidgin_blist_paint_tip(GtkWidget *widget, cairo_t *cr, gpointer null) } if (td->name_layout) { +#if GTK_CHECK_VERSION(3,0,0) if (dir == GTK_TEXT_DIR_RTL) { gtk_paint_layout(style, cr, GTK_STATE_NORMAL, FALSE, - gtkblist->tipwindow, "tooltip", - max_width - (TOOLTIP_BORDER + status_size + SMALL_SPACE) - PANGO_PIXELS(300000), - current_height, td->name_layout); + gtkblist->tipwindow, "tooltip", + max_width - (TOOLTIP_BORDER + status_size + SMALL_SPACE) - PANGO_PIXELS(300000), + current_height, td->name_layout); + } else { + gtk_paint_layout(style, cr, GTK_STATE_NORMAL, FALSE, + gtkblist->tipwindow, "tooltip", + TOOLTIP_BORDER + status_size + SMALL_SPACE, current_height, td->name_layout); + } +#else + if (dir == GTK_TEXT_DIR_RTL) { + gtk_paint_layout(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, FALSE, + NULL, gtkblist->tipwindow, "tooltip", + max_width -(TOOLTIP_BORDER + status_size + SMALL_SPACE) - PANGO_PIXELS(300000), + current_height, td->name_layout); } else { - gtk_paint_layout (style, cr, GTK_STATE_NORMAL, FALSE, - gtkblist->tipwindow, "tooltip", - TOOLTIP_BORDER + status_size + SMALL_SPACE, current_height, td->name_layout); + gtk_paint_layout(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, FALSE, + NULL, gtkblist->tipwindow, "tooltip", + TOOLTIP_BORDER + status_size + SMALL_SPACE, current_height, td->name_layout); } +#endif } if (td->layout) { +#if GTK_CHECK_VERSION(3,0,0) if (dir != GTK_TEXT_DIR_RTL) { - gtk_paint_layout (style, cr, GTK_STATE_NORMAL, FALSE, - gtkblist->tipwindow, "tooltip", - TOOLTIP_BORDER + status_size + SMALL_SPACE, current_height + td->name_height, td->layout); + gtk_paint_layout(style, cr, GTK_STATE_NORMAL, FALSE, + gtkblist->tipwindow, "tooltip", + TOOLTIP_BORDER + status_size + SMALL_SPACE, current_height + td->name_height, td->layout); } else { gtk_paint_layout(style, cr, GTK_STATE_NORMAL, FALSE, - gtkblist->tipwindow, "tooltip", - max_width - (TOOLTIP_BORDER + status_size + SMALL_SPACE) - PANGO_PIXELS(300000), - current_height + td->name_height, - td->layout); + gtkblist->tipwindow, "tooltip", + max_width - (TOOLTIP_BORDER + status_size + SMALL_SPACE) - PANGO_PIXELS(300000), + current_height + td->name_height, + td->layout); + } +#else + if (dir != GTK_TEXT_DIR_RTL) { + gtk_paint_layout(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, FALSE, + NULL, gtkblist->tipwindow, "tooltip", + TOOLTIP_BORDER + status_size + SMALL_SPACE, current_height + td->name_height, td->layout); + } else { + gtk_paint_layout(style, gtkblist->tipwindow->window, GTK_STATE_NORMAL, FALSE, + NULL, gtkblist->tipwindow, "tooltip", + max_width - (TOOLTIP_BORDER + status_size + SMALL_SPACE) - PANGO_PIXELS(300000), + current_height + td->name_height, + td->layout); } +#endif } current_height += MAX(td->name_height + td->height, td->avatar_height) + td->padding; @@ -5022,6 +5070,24 @@ gtk_blist_window_key_press_cb(GtkWidget *w, GdkEventKey *event, PidginBuddyList return FALSE; } +#if !GTK_CHECK_VERSION(3,0,0) +static gboolean +headline_box_enter_cb(GtkWidget *widget, GdkEventCrossing *event, + PidginBuddyListPrivate *priv) +{ + gdk_window_set_cursor(widget->window, priv->hand_cursor); + return FALSE; +} + +static gboolean +headline_box_leave_cb(GtkWidget *widget, GdkEventCrossing *event, + PidginBuddyListPrivate *priv) +{ + gdk_window_set_cursor(widget->window, priv->arrow_cursor); + return FALSE; +} +#endif + static void reset_headline(PidginBuddyList *gtkblist) { @@ -5040,6 +5106,8 @@ headline_click_callback(gpointer unused) return FALSE; } +#if GTK_CHECK_VERSION(3,0,0) + static gboolean headline_response_cb(GtkInfoBar *infobar, int resp, PidginBuddyList *gtkblist) { @@ -5073,6 +5141,31 @@ headline_press_cb(GtkWidget *widget, GdkEventButton *event, GtkInfoBar *infobar) return TRUE; } +#else + +static gboolean +headline_close_press_cb(GtkButton *button, PidginBuddyList *gtkblist) +{ + gtk_widget_hide(gtkblist->headline); + return FALSE; +} + +static gboolean +headline_box_press_cb(GtkWidget *widget, GdkEventButton *event, PidginBuddyList *gtkblist) +{ + gtk_widget_hide(gtkblist->headline); + if (gtkblist->headline_callback) + g_idle_add(headline_click_callback, NULL); + else { + if (gtkblist->headline_destroy) + gtkblist->headline_destroy(gtkblist->headline_data); + reset_headline(gtkblist); + } + return TRUE; +} + +#endif + /***********************************/ /* Connection error handling stuff */ /***********************************/ @@ -5502,6 +5595,27 @@ show_initial_account_errors(PidginBuddyList *gtkblist) } } +#if !GTK_CHECK_VERSION(3,0,0) +static gboolean +paint_headline_hbox (GtkWidget *widget, + GdkEventExpose *event, + gpointer user_data) +{ + gtk_paint_flat_box (widget->style, + widget->window, + GTK_STATE_NORMAL, + GTK_SHADOW_OUT, + NULL, + widget, + "tooltip", + widget->allocation.x + 1, + widget->allocation.y + 1, + widget->allocation.width - 2, + widget->allocation.height - 2); + return FALSE; +} +#endif + /* This assumes there are not things like groupless buddies or multi-leveled groups. * I'm sure other things in this code assumes that also. */ @@ -5518,6 +5632,54 @@ treeview_style_set (GtkWidget *widget, } } +#if !GTK_CHECK_VERSION(3,0,0) +static void +headline_style_set (GtkWidget *widget, + GtkStyle *prev_style) +{ + PidginBuddyListPrivate *priv = PIDGIN_BUDDY_LIST_GET_PRIVATE(gtkblist); + GtkStyle *style; +#if GTK_CHECK_VERSION(2,12,0) + GtkWidget *window; + + if (priv->changing_style) + return; + + /* This is a hack needed to use the tooltip background colour */ + window = gtk_window_new(GTK_WINDOW_POPUP); + gtk_widget_set_name(window, "gtk-tooltip"); + gtk_widget_ensure_style(window); + style = gtk_widget_get_style(window); + + priv->changing_style = TRUE; + gtk_widget_set_style(gtkblist->headline, style); + priv->changing_style = FALSE; + + gtk_widget_destroy(window); + + gtk_widget_queue_draw(gtkblist->headline); +#else + GtkTooltips *tooltips; + + if (gtkblist->changing_style) + return; + + tooltips = gtk_tooltips_new (); + g_object_ref_sink (tooltips); + + gtk_tooltips_force_window (tooltips); + gtk_widget_ensure_style (tooltips->tip_window); + style = gtk_widget_get_style (tooltips->tip_window); + + priv->changing_style = TRUE; + gtk_widget_set_style (gtkblist->headline, style); + priv->changing_style = FALSE; + + g_object_unref (tooltips); +#endif +} +#endif + /******************************************/ /* End of connection error handling stuff */ /******************************************/ @@ -5747,8 +5909,12 @@ static void pidgin_blist_show(PurpleBuddyList *list) GtkTreeViewColumn *column; GtkWidget *menu; GtkWidget *sep; +#if GTK_CHECK_VERSION(3,0,0) GtkWidget *infobar; GtkWidget *content_area; +#else + GtkWidget *ebox; +#endif GtkWidget *label; GtkWidget *close; char *pretty, *tmp; @@ -5792,7 +5958,9 @@ static void pidgin_blist_show(PurpleBuddyList *list) G_CALLBACK(blist_focus_cb), gtkblist); /* TODO: how is this done in gtk+ 3.0? */ - /*GTK_WINDOW(gtkblist->window)->allow_shrink = TRUE;*/ +#if !GTK_CHECK_VERSION(3,0,0) + GTK_WINDOW(gtkblist->window)->allow_shrink = TRUE; +#endif gtkblist->main_vbox = gtk_vbox_new(FALSE, 0); gtk_widget_show(gtkblist->main_vbox); @@ -5876,6 +6044,9 @@ static void pidgin_blist_show(PurpleBuddyList *list) gtk_widget_show_all(gtkblist->notebook); pidgin_blist_select_notebook_page(gtkblist); + /****************************** Headline **********************************/ +#if GTK_CHECK_VERSION(3,0,0) + gtkblist->headline = gtk_event_box_new(); gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->headline, FALSE, FALSE, 0); @@ -5909,6 +6080,50 @@ static void pidgin_blist_show(PurpleBuddyList *list) g_signal_connect(gtkblist->headline, "button-press-event", G_CALLBACK(headline_press_cb), infobar); +#else + + ebox = gtk_event_box_new(); + gtk_box_pack_start(GTK_BOX(gtkblist->vbox), ebox, FALSE, FALSE, 0); + gtkblist->headline = gtk_hbox_new(FALSE, 3); + gtk_container_set_border_width(GTK_CONTAINER(gtkblist->headline), 6); + gtk_container_add(GTK_CONTAINER(ebox), gtkblist->headline); + gtkblist->headline_image = gtk_image_new_from_pixbuf(NULL); + gtk_misc_set_alignment(GTK_MISC(gtkblist->headline_image), 0.0, 0); + gtkblist->headline_label = gtk_label_new(NULL); + gtk_widget_set_size_request(gtkblist->headline_label, + purple_prefs_get_int(PIDGIN_PREFS_ROOT "/blist/width")-25,-1); + gtk_label_set_line_wrap(GTK_LABEL(gtkblist->headline_label), TRUE); + gtk_box_pack_start(GTK_BOX(gtkblist->headline), gtkblist->headline_image, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(gtkblist->headline), gtkblist->headline_label, TRUE, TRUE, 0); + g_signal_connect(gtkblist->headline_label, /* connecting on headline doesn't work, because + the signal is not emitted when theme is changed */ + "style-set", + G_CALLBACK(headline_style_set), + NULL); + g_signal_connect (gtkblist->headline, + "expose_event", + G_CALLBACK (paint_headline_hbox), + NULL); + gtk_widget_set_name(gtkblist->headline, "gtk-tooltips"); + + priv->hand_cursor = gdk_cursor_new (GDK_HAND2); + priv->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); + + /* Close button. */ + close = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); + close = pidgin_create_small_button(close); + gtk_box_pack_start(GTK_BOX(gtkblist->headline), close, FALSE, FALSE, 0); +#if GTK_CHECK_VERSION(2,12,0) + gtk_widget_set_tooltip_text(close, _("Close")); +#endif + g_signal_connect(close, "clicked", G_CALLBACK(headline_close_press_cb), gtkblist); + + g_signal_connect(G_OBJECT(ebox), "enter-notify-event", G_CALLBACK(headline_box_enter_cb), priv); + g_signal_connect(G_OBJECT(ebox), "leave-notify-event", G_CALLBACK(headline_box_leave_cb), priv); + g_signal_connect(G_OBJECT(ebox), "button-press-event", G_CALLBACK(headline_box_press_cb), gtkblist); + +#endif + /****************************** GtkTreeView **********************************/ gtkblist->treemodel = gtk_tree_store_new(BLIST_COLUMNS, GDK_TYPE_PIXBUF, /* Status icon */ @@ -6007,6 +6222,9 @@ static void pidgin_blist_show(PurpleBuddyList *list) gtkblist->statusbox = pidgin_status_box_new(); gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->statusbox, FALSE, TRUE, 0); gtk_widget_set_name(gtkblist->statusbox, "pidgin_blist_statusbox"); +#if !GTK_CHECK_VERSION(3,0,0) + gtk_container_set_border_width(GTK_CONTAINER(gtkblist->statusbox), 3); +#endif gtk_widget_show(gtkblist->statusbox); /* set the Show Offline Buddies option. must be done @@ -6908,6 +7126,14 @@ static void pidgin_blist_destroy(PurpleBuddyList *list) g_object_unref(G_OBJECT(gtkblist->empty_avatar)); priv = PIDGIN_BUDDY_LIST_GET_PRIVATE(gtkblist); + +#if !GTK_CHECK_VERSION(3,0,0) + gdk_cursor_unref(priv->hand_cursor); + gdk_cursor_unref(priv->arrow_cursor); + priv->hand_cursor = NULL; + priv->arrow_cursor = NULL; +#endif + if (priv->current_theme) g_object_unref(priv->current_theme); g_free(priv); diff --git a/pidgin/gtkcellrendererexpander.c b/pidgin/gtkcellrendererexpander.c index a8529293d4..d4c7b15356 100644 --- a/pidgin/gtkcellrendererexpander.c +++ b/pidgin/gtkcellrendererexpander.c @@ -32,6 +32,14 @@ #include <gtk/gtk.h> #include "gtkcellrendererexpander.h" +#include "gtk3compat.h" + +#if GTK_CHECK_VERSION(3,0,0) +#define GTK3_CONST const +#else +#define GTK3_CONST +#endif + static void pidgin_cell_renderer_expander_get_property (GObject *object, guint param_id, GValue *value, @@ -44,23 +52,30 @@ static void pidgin_cell_renderer_expander_init (PidginCellRendererExpander static void pidgin_cell_renderer_expander_class_init (PidginCellRendererExpanderClass *class); static void pidgin_cell_renderer_expander_get_size (GtkCellRenderer *cell, GtkWidget *widget, - const GdkRectangle *cell_area, + GTK3_CONST GdkRectangle *cell_area, gint *x_offset, gint *y_offset, gint *width, gint *height); static void pidgin_cell_renderer_expander_render (GtkCellRenderer *cell, +#if GTK_CHECK_VERSION(3,0,0) cairo_t *cr, +#else + GdkWindow *window, +#endif GtkWidget *widget, - const GdkRectangle *background_area, - const GdkRectangle *cell_area, + GTK3_CONST GdkRectangle *background_area, + GTK3_CONST GdkRectangle *cell_area, +#if !GTK_CHECK_VERSION(3,0,0) + GdkRectangle *export_area, +#endif GtkCellRendererState flags); static gboolean pidgin_cell_renderer_expander_activate (GtkCellRenderer *r, GdkEvent *event, GtkWidget *widget, const gchar *p, - const GdkRectangle *bg, - const GdkRectangle *cell, + GTK3_CONST GdkRectangle *bg, + GTK3_CONST GdkRectangle *cell, GtkCellRendererState flags); static void pidgin_cell_renderer_expander_finalize (GObject *gobject); @@ -187,9 +202,10 @@ GtkCellRenderer *pidgin_cell_renderer_expander_new(void) return g_object_new(PIDGIN_TYPE_GTK_CELL_RENDERER_EXPANDER, NULL); } -static void pidgin_cell_renderer_expander_get_size (GtkCellRenderer *cell, +static void +pidgin_cell_renderer_expander_get_size (GtkCellRenderer *cell, GtkWidget *widget, - const GdkRectangle *cell_area, + GTK3_CONST GdkRectangle *cell_area, gint *x_offset, gint *y_offset, gint *width, @@ -232,12 +248,20 @@ static void pidgin_cell_renderer_expander_get_size (GtkCellRenderer *cell, } -static void pidgin_cell_renderer_expander_render(GtkCellRenderer *cell, - cairo_t *cr, - GtkWidget *widget, - const GdkRectangle *background_area, - const GdkRectangle *cell_area, - GtkCellRendererState flags) +static void +pidgin_cell_renderer_expander_render(GtkCellRenderer *cell, +#if GTK_CHECK_VERSION(3,0,0) + cairo_t *cr, +#else + GdkWindow *window, +#endif + GtkWidget *widget, + GTK3_CONST GdkRectangle *background_area, + GTK3_CONST GdkRectangle *cell_area, +#if !GTK_CHECK_VERSION(3,0,0) + GdkRectangle *expose_area, +#endif + GtkCellRendererState flags) { PidginCellRendererExpander *cellexpander = (PidginCellRendererExpander *) cell; gboolean set; @@ -269,28 +293,44 @@ static void pidgin_cell_renderer_expander_render(GtkCellRenderer *cell, width -= xpad*2; height -= ypad*2; +#if GTK_CHECK_VERSION(3,0,0) gtk_paint_expander(gtk_widget_get_style(widget), cr, state, widget, "treeview", cell_area->x + xpad + (width / 2), cell_area->y + ypad + (height / 2), is_expanded ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED); +#else + gtk_paint_expander(gtk_widget_get_style(widget), + window, state, + NULL, widget, "treeview", + cell_area->x + cell->xpad + (width / 2), + cell_area->y + cell->ypad + (height / 2), + is_expanded ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED); +#endif /* only draw the line if the color isn't set - this prevents a bug where the hline appears only under the expander */ g_object_get(cellexpander, "cell-background-set", &set, NULL); gtk_widget_get_allocation(widget, &allocation); +#if GTK_CHECK_VERSION(3,0,0) if (is_expanded && !set) gtk_paint_hline(gtk_widget_get_style(widget), cr, state, widget, NULL, 0, allocation.width, cell_area->y + cell_area->height); +#else + if (is_expanded && !set) + gtk_paint_hline(gtk_widget_get_style(widget), window, state, NULL, widget, NULL, 0, + allocation.width, cell_area->y + cell_area->height); +#endif } -static gboolean pidgin_cell_renderer_expander_activate(GtkCellRenderer *r, +static gboolean +pidgin_cell_renderer_expander_activate(GtkCellRenderer *r, GdkEvent *event, GtkWidget *widget, const gchar *p, - const GdkRectangle *bg, - const GdkRectangle *cell, + GTK3_CONST GdkRectangle *bg, + GTK3_CONST GdkRectangle *cell, GtkCellRendererState flags) { GtkTreePath *path = gtk_tree_path_new_from_string(p); diff --git a/pidgin/gtkcertmgr.c b/pidgin/gtkcertmgr.c index 2d01245567..9c8b81ffcd 100644 --- a/pidgin/gtkcertmgr.c +++ b/pidgin/gtkcertmgr.c @@ -613,7 +613,11 @@ pidgin_certmgr_show(void) win = dlg->window = pidgin_create_dialog(_("Certificate Manager"),/* Title */ +#if GTK_CHECK_VERSION(3,0,0) 0, /*Window border*/ +#else + PIDGIN_HIG_BORDER, /*Window border*/ +#endif "certmgr", /* Role */ TRUE); /* Allow resizing */ g_signal_connect(G_OBJECT(win), "delete_event", diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c index eec851cf2c..a94da30020 100644 --- a/pidgin/gtkconv.c +++ b/pidgin/gtkconv.c @@ -80,6 +80,9 @@ #include "gtknickcolors.h" +#define GTK_TOOLTIPS_VAR gtkconv->tooltips +#include "gtk3compat.h" + /** * A GTK+ Instant Message pane. */ @@ -5049,12 +5052,7 @@ pidgin_conv_setup_quickfind(PidginConversation *gtkconv, GtkWidget *container) close = pidgin_create_small_button(gtk_label_new("×")); gtk_box_pack_start(GTK_BOX(widget), close, FALSE, FALSE, 0); -#if GTK_CHECK_VERSION(2,12,0) gtk_widget_set_tooltip_text(close, _("Close Find bar")); -#else - gtk_tooltips_set_tip(gtkconv->tooltips, close, - _("Close Find bar"), NULL); -#endif label = gtk_label_new(_("Find:")); gtk_box_pack_start(GTK_BOX(widget), label, FALSE, FALSE, 10); @@ -7303,13 +7301,8 @@ pidgin_conv_update_fields(PurpleConversation *conv, PidginConvFields fields) 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 } } @@ -10081,9 +10074,6 @@ pidgin_conv_window_switch_gtkconv(PidginWindow *win, PidginConversation *gtkconv static gboolean gtkconv_tab_set_tip(GtkWidget *widget, GdkEventCrossing *event, PidginConversation *gtkconv) { -#if GTK_CHECK_VERSION(2, 12, 0) -#define gtk_tooltips_set_tip(tips, w, l, p) gtk_widget_set_tooltip_text(w, l) -#endif /* PANGO_VERSION_CHECK macro was introduced in 1.15. So we need this double check. */ #ifndef PANGO_VERSION_CHECK #define pango_layout_is_ellipsized(l) TRUE @@ -10093,13 +10083,12 @@ gtkconv_tab_set_tip(GtkWidget *widget, GdkEventCrossing *event, PidginConversati PangoLayout *layout; layout = gtk_label_get_layout(GTK_LABEL(gtkconv->tab_label)); - gtk_tooltips_set_tip(gtkconv->tooltips, widget, - pango_layout_is_ellipsized(layout) ? gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)) : NULL, - NULL); + if (pango_layout_is_ellipsized(layout)) + gtk_widget_set_tooltip_text(widget, gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); + else + gtk_widget_set_tooltip_text(widget, NULL); + return FALSE; -#if GTK_CHECK_VERSION(2, 12, 0) -#undef gtk_tooltips_set_tip -#endif } void @@ -10122,12 +10111,7 @@ pidgin_conv_window_add_gtkconv(PidginWindow *win, PidginConversation *gtkconv) /* Close button. */ gtkconv->close = pidgin_create_small_button(gtk_label_new("×")); -#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(gtkconv->close, "clicked", G_CALLBACK (close_conv_cb), gtkconv); diff --git a/pidgin/gtkdebug.c b/pidgin/gtkdebug.c index d668c98519..ea6c92fec9 100644 --- a/pidgin/gtkdebug.c +++ b/pidgin/gtkdebug.c @@ -39,6 +39,8 @@ #include <gdk/gdkkeysyms.h> +#include "gtk3compat.h" + typedef struct { GtkWidget *window; @@ -681,22 +683,14 @@ debug_window_new(void) /* Save */ item = gtk_tool_button_new_from_stock(GTK_STOCK_SAVE); gtk_tool_item_set_is_important(item, TRUE); -#if GTK_CHECK_VERSION(2,12,0) gtk_tool_item_set_tooltip_text(item, _("Save")); -#else - gtk_tool_item_set_tooltip(item, tooltips, _("Save"), NULL); -#endif g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(save_cb), win); gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item)); /* Clear button */ item = gtk_tool_button_new_from_stock(GTK_STOCK_CLEAR); gtk_tool_item_set_is_important(item, TRUE); -#if GTK_CHECK_VERSION(2,12,0) gtk_tool_item_set_tooltip_text(item, _("Clear")); -#else - gtk_tool_item_set_tooltip(item, tooltips, _("Clear"), NULL); -#endif g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(clear_cb), win); gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item)); @@ -706,11 +700,7 @@ debug_window_new(void) /* Pause */ item = gtk_toggle_tool_button_new_from_stock(PIDGIN_STOCK_PAUSE); gtk_tool_item_set_is_important(item, TRUE); -#if GTK_CHECK_VERSION(2,12,0) gtk_tool_item_set_tooltip_text(item, _("Pause")); -#else - gtk_tool_item_set_tooltip(item, tooltips, _("Pause"), NULL); -#endif g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(pause_cb), win); gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item)); @@ -723,11 +713,7 @@ debug_window_new(void) gtk_tool_item_set_is_important(item, TRUE); win->filter = GTK_WIDGET(item); gtk_tool_button_set_label(GTK_TOOL_BUTTON(win->filter), _("Filter")); -#if GTK_CHECK_VERSION(2,12,0) gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(win->filter), _("Filter")); -#else - gtk_tooltips_set_tip(tooltips, win->filter, _("Filter"), NULL); -#endif g_signal_connect(G_OBJECT(win->filter), "clicked", G_CALLBACK(regex_filter_toggled_cb), win); gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(win->filter)); @@ -745,11 +731,7 @@ debug_window_new(void) /* regex entry */ win->expression = gtk_entry_new(); item = gtk_tool_item_new(); -#if GTK_CHECK_VERSION(2,12,0) gtk_widget_set_tooltip_text(win->expression, _("Right click for more options.")); -#else - gtk_tooltips_set_tip(tooltips, win->expression, _("Right click for more options."), NULL); -#endif gtk_container_add(GTK_CONTAINER(item), GTK_WIDGET(win->expression)); gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item)); diff --git a/pidgin/gtkdialogs.c b/pidgin/gtkdialogs.c index de12389aa8..71b481dd9d 100644 --- a/pidgin/gtkdialogs.c +++ b/pidgin/gtkdialogs.c @@ -44,6 +44,8 @@ #include "gtkwebview.h" #include "pidginstock.h" +#include "gtk3compat.h" + static GList *dialogwindows = NULL; struct _PidginGroupMergeObject { @@ -435,8 +437,13 @@ pidgin_build_help_dialog(const char *title, const char *role, GString *string) AtkObject *obj; char *filename, *tmp; +#if GTK_CHECK_VERSION(3,0,0) win = pidgin_create_dialog(title, 0, role, TRUE); vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(win), FALSE, 0); +#else + win = pidgin_create_dialog(title, PIDGIN_HIG_BORDER, role, TRUE); + vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(win), FALSE, PIDGIN_HIG_BORDER); +#endif gtk_window_set_default_size(GTK_WINDOW(win), 475, 450); /* Generate a logo with a version number */ diff --git a/pidgin/gtkdnd-hints.c b/pidgin/gtkdnd-hints.c index 9ff74bdc99..77363331b2 100644 --- a/pidgin/gtkdnd-hints.c +++ b/pidgin/gtkdnd-hints.c @@ -34,6 +34,8 @@ #include "win32dep.h" #endif +#include "gtk3compat.h" + typedef struct { GtkWidget *widget; @@ -54,6 +56,8 @@ static HintWindowInfo hint_windows[] = { { NULL, NULL, 0, 0 } }; +#if GTK_CHECK_VERSION(3,0,0) + static void dnd_hints_realized_cb(GtkWidget *window, GtkWidget *pix) { @@ -103,6 +107,41 @@ dnd_hints_init_window(const gchar *fname) return win; } +#else + +static GtkWidget * +dnd_hints_init_window(const gchar *fname) +{ + GdkPixbuf *pixbuf; + GdkPixmap *pixmap; + GdkBitmap *bitmap; + GtkWidget *pix; + GtkWidget *win; + GdkColormap *colormap; + + pixbuf = gdk_pixbuf_new_from_file(fname, NULL); + g_return_val_if_fail(pixbuf, NULL); + + win = gtk_window_new(GTK_WINDOW_POPUP); + colormap = gtk_widget_get_colormap(win); + gdk_pixbuf_render_pixmap_and_mask_for_colormap(pixbuf, colormap, + &pixmap, &bitmap, 128); + g_object_unref(G_OBJECT(pixbuf)); + + pix = gtk_image_new_from_pixmap(pixmap, bitmap); + gtk_container_add(GTK_CONTAINER(win), pix); + gtk_widget_shape_combine_mask(win, bitmap, 0, 0); + + g_object_unref(G_OBJECT(pixmap)); + g_object_unref(G_OBJECT(bitmap)); + + gtk_widget_show_all(pix); + + return win; +} + +#endif + static void get_widget_coords(GtkWidget *w, gint *x1, gint *y1, gint *x2, gint *y2) { diff --git a/pidgin/gtkdocklet.c b/pidgin/gtkdocklet.c index 6975079e05..23a8a92303 100644 --- a/pidgin/gtkdocklet.c +++ b/pidgin/gtkdocklet.c @@ -45,6 +45,8 @@ #include "gtkdocklet.h" #include "gtkdialogs.h" +#include "gtk3compat.h" + #ifndef DOCKLET_TOOLTIP_LINE_LIMIT #define DOCKLET_TOOLTIP_LINE_LIMIT 5 #endif @@ -103,6 +105,14 @@ docklet_gtk_status_update_icon(PurpleStatusPrimitive status, gboolean connecting if (icon_name) { gtk_status_icon_set_from_icon_name(docklet, icon_name); } + +#if !GTK_CHECK_VERSION(3,0,0) + if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/docklet/blink")) { + gtk_status_icon_set_blinking(docklet, (pending && !connecting)); + } else if (gtk_status_icon_get_blinking(docklet)) { + gtk_status_icon_set_blinking(docklet, FALSE); + } +#endif } static GList * @@ -323,8 +333,17 @@ static void docklet_toggle_mute(GtkWidget *toggle, void *data) { purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/sound/mute", - gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(toggle))); + gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(toggle))); +} + +#if !GTK_CHECK_VERSION(3,0,0) +static void +docklet_toggle_blink(GtkWidget *toggle, void *data) +{ + purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/docklet/blink", + gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(toggle))); } +#endif static void docklet_toggle_blist(GtkWidget *toggle, void *data) @@ -737,6 +756,13 @@ docklet_menu(void) g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_mute), NULL); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); +#if !GTK_CHECK_VERSION(3,0,0) + menuitem = gtk_check_menu_item_new_with_mnemonic(_("_Blink on New Message")); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/docklet/blink")); + g_signal_connect(G_OBJECT(menuitem), "toggled", G_CALLBACK(docklet_toggle_blink), NULL); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); +#endif + pidgin_separator(menu); /* add plugin actions */ diff --git a/pidgin/gtkft.c b/pidgin/gtkft.c index 3c221c0b0d..f1ab3dfd13 100644 --- a/pidgin/gtkft.c +++ b/pidgin/gtkft.c @@ -715,7 +715,11 @@ pidgin_xfer_dialog_new(void) purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/filetransfer/clear_finished"); /* Create the window. */ +#if GTK_CHECK_VERSION(3,0,0) dialog->window = window = pidgin_create_dialog(_("File Transfers"), 0, "file transfer", TRUE); +#else + dialog->window = window = pidgin_create_dialog(_("File Transfers"), PIDGIN_HIG_BORDER, "file transfer", TRUE); +#endif gtk_window_set_default_size(GTK_WINDOW(window), 450, 250); g_signal_connect(G_OBJECT(window), "delete_event", @@ -768,7 +772,7 @@ pidgin_xfer_dialog_new(void) gtk_container_add(GTK_CONTAINER(alignment), table); gtk_widget_show(table); - bbox = gtk_dialog_get_action_area(GTK_DIALOG(window)); + bbox = pidgin_dialog_get_action_area(GTK_DIALOG(window)); #define ADD_BUTTON(b, label, callback, callbackdata) do { \ GtkWidget *button = gtk_button_new_from_stock(label); \ diff --git a/pidgin/gtkimhtml.c b/pidgin/gtkimhtml.c index 27c149265e..1df425c022 100644 --- a/pidgin/gtkimhtml.c +++ b/pidgin/gtkimhtml.c @@ -65,6 +65,8 @@ #define TOOLTIP_TIMEOUT 500 +#include "gtk3compat.h" + static GtkTextViewClass *parent_class = NULL; struct scalable_data { @@ -802,7 +804,7 @@ gtk_leave_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data } /* TODO: I think this can be removed for GTK+ 3.0... */ -#if 0 +#if !GTK_CHECK_VERSION(3,0,0) static gint gtk_imhtml_expose_event (GtkWidget *widget, GdkEventExpose *event) @@ -1625,7 +1627,9 @@ static void gtk_imhtml_class_init (GtkIMHtmlClass *klass) gobject_class->finalize = gtk_imhtml_finalize; widget_class->drag_motion = gtk_text_view_drag_motion; /* TODO: I _think_ this should be removed for GTK+ 3.0 */ - /*widget_class->expose_event = gtk_imhtml_expose_event;*/ +#if !GTK_CHECK_VERSION(3,0,0) + widget_class->expose_event = gtk_imhtml_expose_event; +#endif parent_size_allocate = widget_class->size_allocate; widget_class->size_allocate = gtk_imhtml_size_allocate; parent_style_set = widget_class->style_set; @@ -4988,7 +4992,7 @@ void gtk_imhtml_insert_smiley(GtkIMHtml *imhtml, const char *sml, char *smiley) } /* TODO: I think this can be removed for GTK+ 3.0... */ -#if 0 +#if !GTK_CHECK_VERSION(3,0,0) static gboolean image_expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data) { @@ -5118,9 +5122,10 @@ void gtk_imhtml_insert_smiley_at_iter(GtkIMHtml *imhtml, const char *sml, char * * images, and ensures that they are handled by the image * itself, without propagating to the textview and causing * a complete refresh */ - /* TODO: I think this should be removed for GTK+ 3.0? + /* TODO: I think this should be removed for GTK+ 3.0? */ +#if !GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(icon), "expose-event", G_CALLBACK(image_expose), NULL); - */ +#endif gtk_widget_show(icon); if (ebox) @@ -5217,8 +5222,8 @@ static const gchar *tag_to_html_start(GtkTextTag *tag) static gchar buf[1024]; gchar *name = NULL; - g_return_val_if_fail(name != NULL, ""); g_object_get(G_OBJECT(tag), "name", &name, NULL); + g_return_val_if_fail(name != NULL, ""); if (strcmp(name, "BOLD") == 0) { g_free(name); @@ -5341,8 +5346,8 @@ static const gchar *tag_to_html_end(GtkTextTag *tag) { gchar *name; - g_return_val_if_fail(name != NULL, ""); g_object_get(G_OBJECT(tag), "name", &name, NULL); + g_return_val_if_fail(name != NULL, ""); if (strcmp(name, "BOLD") == 0) { g_free(name); diff --git a/pidgin/gtkimhtmltoolbar.c b/pidgin/gtkimhtmltoolbar.c index dcc0f052df..065cfee194 100644 --- a/pidgin/gtkimhtmltoolbar.c +++ b/pidgin/gtkimhtmltoolbar.c @@ -43,6 +43,8 @@ #include <gdk/gdkkeysyms.h> +#include "gtk3compat.h" + static GtkHBoxClass *parent_class = NULL; static void toggle_button_set_active_block(GtkToggleButton *button, diff --git a/pidgin/gtklog.c b/pidgin/gtklog.c index 4ffde2e33e..b75cf674f5 100644 --- a/pidgin/gtklog.c +++ b/pidgin/gtklog.c @@ -39,6 +39,8 @@ #include "gtkutils.h" #include "gtkwebview.h" +#include "gtk3compat.h" + static GHashTable *log_viewers = NULL; static void populate_log_tree(PidginLogViewer *lv); static PidginLogViewer *syslog_viewer = NULL; diff --git a/pidgin/gtkmedia.c b/pidgin/gtkmedia.c index 89a80ee13d..8667ead934 100644 --- a/pidgin/gtkmedia.c +++ b/pidgin/gtkmedia.c @@ -46,6 +46,8 @@ #include <gst/interfaces/xoverlay.h> +#include "gtk3compat.h" + #define PIDGIN_TYPE_MEDIA (pidgin_media_get_type()) #define PIDGIN_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PIDGIN_TYPE_MEDIA, PidginMedia)) #define PIDGIN_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PIDGIN_TYPE_MEDIA, PidginMediaClass)) @@ -540,20 +542,12 @@ realize_cb_cb(PidginMediaRealizeData *data) GdkWindow *window = NULL; if (data->participant == NULL) -#if GTK_CHECK_VERSION(2, 14, 0) window = gtk_widget_get_window(priv->local_video); -#else - window = (priv->local_video)->window; -#endif else { GtkWidget *widget = pidgin_media_get_widget(data->gtkmedia, data->session_id, data->participant); if (widget) -#if GTK_CHECK_VERSION(2, 14, 0) window = gtk_widget_get_window(widget); -#else - window = widget->window; -#endif } if (window) { diff --git a/pidgin/gtkmenutray.c b/pidgin/gtkmenutray.c index 3fa8af1f2e..900a1cacb7 100644 --- a/pidgin/gtkmenutray.c +++ b/pidgin/gtkmenutray.c @@ -23,6 +23,8 @@ #include <gtk/gtk.h> +#include "gtk3compat.h" + /****************************************************************************** * Enums *****************************************************************************/ @@ -35,6 +37,9 @@ enum { * Globals *****************************************************************************/ static GObjectClass *parent_class = NULL; +#if !GTK_CHECK_VERSION(2,12,0) +static GtkTooltips *tooltips = NULL; +#endif /****************************************************************************** * Internal Stuff @@ -61,6 +66,16 @@ pidgin_menu_tray_deselect(GtkMenuItem *widget) { /****************************************************************************** * Widget Stuff *****************************************************************************/ +#if !GTK_CHECK_VERSION(2,12,0) +static void +tooltips_unref_cb(gpointer data, GObject *object, gboolean is_last_ref) +{ + if (is_last_ref) { + g_object_unref(tooltips); + tooltips = NULL; + } +} +#endif /****************************************************************************** * Object Stuff @@ -235,6 +250,14 @@ pidgin_menu_tray_prepend(PidginMenuTray *menu_tray, GtkWidget *widget, const cha void pidgin_menu_tray_set_tooltip(PidginMenuTray *menu_tray, GtkWidget *widget, const char *tooltip) { +#if !GTK_CHECK_VERSION(2,12,0) + gboolean notify_tooltips = FALSE; + if (!tooltips) { + tooltips = gtk_tooltips_new(); + notify_tooltips = TRUE; + } +#endif + /* Should we check whether widget is a child of menu_tray? */ /* @@ -247,6 +270,13 @@ pidgin_menu_tray_set_tooltip(PidginMenuTray *menu_tray, GtkWidget *widget, const if (!gtk_widget_get_has_window(widget)) widget = gtk_widget_get_parent(widget); +#if GTK_CHECK_VERSION(2,12,0) gtk_widget_set_tooltip_text(widget, tooltip); +#else + gtk_tooltips_set_tip(tooltips, widget, tooltip, NULL); + + if (notify_tooltips) + g_object_add_toggle_ref(G_OBJECT(tooltips), tooltips_unref_cb, NULL); +#endif } diff --git a/pidgin/gtknotify.c b/pidgin/gtknotify.c index 898798f992..1035b3e6c0 100644 --- a/pidgin/gtknotify.c +++ b/pidgin/gtknotify.c @@ -836,6 +836,9 @@ pidgin_notify_formatted(const char *title, const char *primary, window = gtk_dialog_new(); gtk_window_set_title(GTK_WINDOW(window), title); +#if !GTK_CHECK_VERSION(3,0,0) + gtk_container_set_border_width(GTK_CONTAINER(window), PIDGIN_HIG_BORDER); +#endif gtk_window_set_resizable(GTK_WINDOW(window), TRUE); g_signal_connect(G_OBJECT(window), "delete_event", @@ -1501,16 +1504,14 @@ pidgin_create_notification_dialog(PidginNotifyType type) dialog = gtk_dialog_new(); - /* Setup the dialog */ - gtk_container_set_border_width(GTK_CONTAINER(dialog), PIDGIN_HIG_BOX_SPACE); - gtk_container_set_border_width(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), - PIDGIN_HIG_BOX_SPACE); - gtk_box_set_spacing(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), - PIDGIN_HIG_BORDER); - /* Vertical box */ vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); + /* Setup the dialog */ + gtk_container_set_border_width(GTK_CONTAINER(dialog), PIDGIN_HIG_BOX_SPACE); + gtk_container_set_border_width(GTK_CONTAINER(vbox), PIDGIN_HIG_BOX_SPACE); + gtk_box_set_spacing(GTK_BOX(vbox), PIDGIN_HIG_BORDER); + /* Golden ratio it up! */ gtk_widget_set_size_request(dialog, 550, 400); diff --git a/pidgin/gtkplugin.c b/pidgin/gtkplugin.c index bec339b9e6..045ba7704e 100644 --- a/pidgin/gtkplugin.c +++ b/pidgin/gtkplugin.c @@ -35,6 +35,8 @@ #include <string.h> +#include "gtk3compat.h" + #define PIDGIN_RESPONSE_CONFIGURE 98121 static void plugin_toggled_stage_two(PurplePlugin *plug, GtkTreeModel *model, @@ -562,10 +564,15 @@ static gboolean pidgin_plugins_paint_tooltip(GtkWidget *tipwindow, cairo_t *cr, gpointer data) { PangoLayout *layout = g_object_get_data(G_OBJECT(tipwindow), "tooltip-plugin"); +#if GTK_CHECK_VERSION(3,0,0) gtk_paint_layout(gtk_widget_get_style(tipwindow), cr, GTK_STATE_NORMAL, FALSE, - tipwindow, "tooltip", - 6, 6, layout); - + tipwindow, "tooltip", + 6, 6, layout); +#else + gtk_paint_layout(tipwindow->style, tipwindow->window, GTK_STATE_NORMAL, FALSE, + NULL, tipwindow, "tooltip", + 6, 6, layout); +#endif return TRUE; } @@ -788,7 +795,7 @@ void pidgin_plugin_dialog_show() gtk_widget_set_sensitive(expander, FALSE); gtk_container_add(GTK_CONTAINER(expander), create_details()); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(plugin_dialog))), - expander, FALSE, FALSE, 0); + expander, FALSE, FALSE, 0); g_signal_connect (G_OBJECT (sel), "changed", G_CALLBACK (prefs_plugin_sel), NULL); diff --git a/pidgin/gtkpluginpref.c b/pidgin/gtkpluginpref.c index ab97e75d5a..29273350bf 100644 --- a/pidgin/gtkpluginpref.c +++ b/pidgin/gtkpluginpref.c @@ -211,6 +211,9 @@ pidgin_plugin_pref_create_frame(PurplePluginPrefFrame *frame) { sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); parent = ret = gtk_vbox_new(FALSE, 16); +#if !GTK_CHECK_VERSION(3,0,0) + gtk_container_set_border_width(GTK_CONTAINER(ret), PIDGIN_HIG_BORDER); +#endif gtk_widget_show(ret); for(pp = purple_plugin_pref_frame_get_prefs(frame); diff --git a/pidgin/gtkpounce.c b/pidgin/gtkpounce.c index e9ec8ada07..2bd6c77cb8 100644 --- a/pidgin/gtkpounce.c +++ b/pidgin/gtkpounce.c @@ -441,7 +441,7 @@ pounce_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, char *username = NULL; PurpleAccount *account; - if (pidgin_parse_x_im_contact((const char *) sd_data, FALSE, &account, + if (pidgin_parse_x_im_contact((const char *)sd_data, FALSE, &account, &protocol, &username, NULL)) { if (account == NULL) @@ -536,11 +536,14 @@ pidgin_pounce_editor_show(PurpleAccount *account, const char *name, dialog->window = window = gtk_dialog_new(); gtk_window_set_title(GTK_WINDOW(window), (cur_pounce == NULL ? _("Add Buddy Pounce") : _("Modify Buddy Pounce"))); gtk_window_set_role(GTK_WINDOW(window), "buddy_pounce"); +#if !GTK_CHECK_VERSION(3,0,0) + gtk_container_set_border_width(GTK_CONTAINER(dialog->window), PIDGIN_HIG_BORDER); +#endif g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_win_cb), dialog); - /* Create the parent vbox for everything. */ + /* Get the parent vbox for everything. */ vbox1 = gtk_dialog_get_content_area(GTK_DIALOG(window)); /* Create the vbox that will contain all the prefs stuff. */ @@ -1332,7 +1335,11 @@ pidgin_pounces_manager_show(void) width = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/pounces/dialog/width"); height = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/pounces/dialog/height"); +#if GTK_CHECK_VERSION(3,0,0) dialog->window = win = pidgin_create_dialog(_("Buddy Pounces"), 0, "pounces", TRUE); +#else + dialog->window = win = pidgin_create_dialog(_("Buddy Pounces"), PIDGIN_HIG_BORDER, "pounces", TRUE); +#endif gtk_window_set_default_size(GTK_WINDOW(win), width, height); g_signal_connect(G_OBJECT(win), "delete_event", diff --git a/pidgin/gtkprefs.c b/pidgin/gtkprefs.c index c73bfcf95e..9cb465e4cc 100644 --- a/pidgin/gtkprefs.c +++ b/pidgin/gtkprefs.c @@ -58,6 +58,8 @@ #include "gtkwebviewtoolbar.h" #include "pidginstock.h" +#include "gtk3compat.h" + #define PROXYHOST 0 #define PROXYPORT 1 #define PROXYUSER 2 @@ -2737,12 +2739,12 @@ sound_page(void) sound_changed2_cb, vbox); #endif vbox = pidgin_make_frame(ret, _("Sound Events")); - parent = gtk_widget_get_parent(vbox); - parent_parent = gtk_widget_get_parent(parent); - parent_parent_parent = gtk_widget_get_parent(parent_parent); /* The following is an ugly hack to make the frame expand so the * sound events list is big enough to be usable */ + parent = gtk_widget_get_parent(vbox); + parent_parent = gtk_widget_get_parent(parent); + parent_parent_parent = gtk_widget_get_parent(parent_parent); gtk_box_set_child_packing(GTK_BOX(parent), vbox, TRUE, TRUE, 0, GTK_PACK_START); gtk_box_set_child_packing(GTK_BOX(parent_parent), @@ -2985,7 +2987,11 @@ pidgin_prefs_show(void) /* Back to instant-apply! I win! BU-HAHAHA! */ /* Create the window */ +#if GTK_CHECK_VERSION(3,0,0) prefs = pidgin_create_dialog(_("Preferences"), 0, "preferences", FALSE); +#else + prefs = pidgin_create_dialog(_("Preferences"), PIDGIN_HIG_BORDER, "preferences", FALSE); +#endif g_signal_connect(G_OBJECT(prefs), "destroy", G_CALLBACK(delete_prefs), NULL); diff --git a/pidgin/gtkprivacy.c b/pidgin/gtkprivacy.c index 5eb270e0ac..9455b4a7f9 100644 --- a/pidgin/gtkprivacy.c +++ b/pidgin/gtkprivacy.c @@ -36,6 +36,8 @@ #include "gtkprivacy.h" #include "gtkutils.h" +#include "gtk3compat.h" + typedef struct { GtkWidget *win; diff --git a/pidgin/gtkrequest.c b/pidgin/gtkrequest.c index dafdd6564f..472da1573c 100644 --- a/pidgin/gtkrequest.c +++ b/pidgin/gtkrequest.c @@ -42,6 +42,16 @@ #ifdef ENABLE_GCR #define GCR_API_SUBJECT_TO_CHANGE #include <gcr/gcr.h> +#if !GTK_CHECK_VERSION(3,0,0) +#include <gcr/gcr-simple-certificate.h> +#endif +#endif + +#include "gtk3compat.h" + +#if !GTK_CHECK_VERSION(2,12,0) +#undef gtk_widget_set_tooltip_text +#define gtk_widget_set_tooltip_text(x,y) #endif static GtkWidget * create_account_field(PurpleRequestField *field); @@ -870,9 +880,7 @@ create_string_field(PurpleRequestField *field) gtk_text_buffer_set_text(buffer, value, -1); } -#if GTK_CHECK_VERSION(2,12,0) gtk_widget_set_tooltip_text(textview, purple_request_field_get_tooltip(field)); -#endif gtk_text_view_set_editable(GTK_TEXT_VIEW(textview), purple_request_field_string_is_editable(field)); @@ -898,9 +906,7 @@ create_string_field(PurpleRequestField *field) if (value != NULL) gtk_entry_set_text(GTK_ENTRY(widget), value); -#if GTK_CHECK_VERSION(2,12,0) gtk_widget_set_tooltip_text(widget, purple_request_field_get_tooltip(field)); -#endif if (purple_request_field_string_is_masked(field)) { @@ -942,9 +948,7 @@ create_int_field(PurpleRequestField *field) gtk_entry_set_text(GTK_ENTRY(widget), buf); } -#if GTK_CHECK_VERSION(2,12,0) gtk_widget_set_tooltip_text(widget, purple_request_field_get_tooltip(field)); -#endif g_signal_connect(G_OBJECT(widget), "focus-out-event", G_CALLBACK(field_int_focus_out_cb), field); @@ -960,9 +964,7 @@ create_bool_field(PurpleRequestField *field) widget = gtk_check_button_new_with_label( purple_request_field_get_label(field)); -#if GTK_CHECK_VERSION(2,12,0) gtk_widget_set_tooltip_text(widget, purple_request_field_get_tooltip(field)); -#endif gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), purple_request_field_bool_get_default_value(field)); @@ -994,9 +996,7 @@ create_choice_field(PurpleRequestField *field) gtk_combo_box_set_active(GTK_COMBO_BOX(widget), purple_request_field_choice_get_default_value(field)); -#if GTK_CHECK_VERSION(2,12,0) gtk_widget_set_tooltip_text(widget, purple_request_field_get_tooltip(field)); -#endif g_signal_connect(G_OBJECT(widget), "changed", G_CALLBACK(field_choice_menu_cb), field); @@ -1015,9 +1015,7 @@ create_choice_field(PurpleRequestField *field) widget = box; -#if GTK_CHECK_VERSION(2,12,0) gtk_widget_set_tooltip_text(widget, purple_request_field_get_tooltip(field)); -#endif for (l = labels, i = 0; l != NULL; l = l->next, i++) { @@ -1061,9 +1059,7 @@ create_image_field(PurpleRequestField *field) g_object_unref(G_OBJECT(buf)); g_object_unref(G_OBJECT(scale)); -#if GTK_CHECK_VERSION(2,12,0) gtk_widget_set_tooltip_text(widget, purple_request_field_get_tooltip(field)); -#endif return widget; } @@ -1080,9 +1076,7 @@ create_account_field(PurpleRequestField *field) purple_request_field_account_get_filter(field), field); -#if GTK_CHECK_VERSION(2,12,0) gtk_widget_set_tooltip_text(widget, purple_request_field_get_tooltip(field)); -#endif return widget; } diff --git a/pidgin/gtkroomlist.c b/pidgin/gtkroomlist.c index ee357e1c00..2412028fd6 100644 --- a/pidgin/gtkroomlist.c +++ b/pidgin/gtkroomlist.c @@ -368,27 +368,61 @@ pidgin_roomlist_paint_tooltip(GtkWidget *widget, cairo_t *cr, gpointer user_data current_height = 12; +#if GTK_CHECK_VERSION(3,0,0) if (dir == GTK_TEXT_DIR_RTL) { gtk_paint_layout(style, cr, GTK_STATE_NORMAL, FALSE, - grl->tipwindow, "tooltip", - max_width - (TOOLTIP_BORDER + SMALL_SPACE) - PANGO_PIXELS(600000), - current_height, grl->tip_name_layout); + grl->tipwindow, "tooltip", + max_width - (TOOLTIP_BORDER + SMALL_SPACE) - PANGO_PIXELS(600000), + current_height, + grl->tip_name_layout); } else { - gtk_paint_layout (style, cr, GTK_STATE_NORMAL, FALSE, - grl->tipwindow, "tooltip", - TOOLTIP_BORDER + SMALL_SPACE, current_height, grl->tip_name_layout); + gtk_paint_layout(style, cr, GTK_STATE_NORMAL, FALSE, + grl->tipwindow, "tooltip", + TOOLTIP_BORDER + SMALL_SPACE, + current_height, + grl->tip_name_layout); } if (dir != GTK_TEXT_DIR_RTL) { - gtk_paint_layout (style, cr, GTK_STATE_NORMAL, FALSE, - grl->tipwindow, "tooltip", - TOOLTIP_BORDER + SMALL_SPACE, current_height + grl->tip_name_height, grl->tip_layout); + gtk_paint_layout(style, cr, GTK_STATE_NORMAL, FALSE, + grl->tipwindow, "tooltip", + TOOLTIP_BORDER + SMALL_SPACE, + current_height + grl->tip_name_height, + grl->tip_layout); } else { gtk_paint_layout(style, cr, GTK_STATE_NORMAL, FALSE, - grl->tipwindow, "tooltip", - max_width - (TOOLTIP_BORDER + SMALL_SPACE) - PANGO_PIXELS(600000), - current_height + grl->tip_name_height, - grl->tip_layout); + grl->tipwindow, "tooltip", + max_width - (TOOLTIP_BORDER + SMALL_SPACE) - PANGO_PIXELS(600000), + current_height + grl->tip_name_height, + grl->tip_layout); + } +#else + if (dir == GTK_TEXT_DIR_RTL) { + gtk_paint_layout(style, grl->tipwindow->window, GTK_STATE_NORMAL, FALSE, + NULL, grl->tipwindow, "tooltip", + max_width - (TOOLTIP_BORDER + SMALL_SPACE) - PANGO_PIXELS(600000), + current_height, + grl->tip_name_layout); + } else { + gtk_paint_layout(style, grl->tipwindow->window, GTK_STATE_NORMAL, FALSE, + NULL, grl->tipwindow, "tooltip", + TOOLTIP_BORDER + SMALL_SPACE, + current_height, + grl->tip_name_layout); } + if (dir != GTK_TEXT_DIR_RTL) { + gtk_paint_layout(style, grl->tipwindow->window, GTK_STATE_NORMAL, FALSE, + NULL, grl->tipwindow, "tooltip", + TOOLTIP_BORDER + SMALL_SPACE, + current_height + grl->tip_name_height, + grl->tip_layout); + } else { + gtk_paint_layout(style, grl->tipwindow->window, GTK_STATE_NORMAL, FALSE, + NULL, grl->tipwindow, "tooltip", + max_width - (TOOLTIP_BORDER + SMALL_SPACE) - PANGO_PIXELS(600000), + current_height + grl->tip_name_height, + grl->tip_layout); + } +#endif return FALSE; } @@ -534,7 +568,11 @@ pidgin_roomlist_dialog_new_with_account(PurpleAccount *account) dialog->account = account; /* Create the window. */ +#if GTK_CHECK_VERSION(3,0,0) dialog->window = window = pidgin_create_dialog(_("Room List"), 0, "room list", TRUE); +#else + dialog->window = window = pidgin_create_dialog(_("Room List"), PIDGIN_HIG_BORDER, "room list", TRUE); +#endif g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_win_cb), dialog); diff --git a/pidgin/gtksavedstatuses.c b/pidgin/gtksavedstatuses.c index 8c40215274..f9295498d9 100644 --- a/pidgin/gtksavedstatuses.c +++ b/pidgin/gtksavedstatuses.c @@ -41,6 +41,8 @@ #include "pidginstock.h" #include "gtkutils.h" +#include "gtk3compat.h" + /* * TODO: Should attach to the account-deleted and account-added signals * and update the GtkListStores in any StatusEditor windows that diff --git a/pidgin/gtksession.c b/pidgin/gtksession.c index adaacd0b73..20b979165b 100644 --- a/pidgin/gtksession.c +++ b/pidgin/gtksession.c @@ -39,6 +39,8 @@ #include <gdk/gdk.h> #include <gtk/gtk.h> +#include "gtk3compat.h" + #define ERROR_LENGTH 512 static IceIOErrorHandler ice_installed_io_error_handler; diff --git a/pidgin/gtksmiley.c b/pidgin/gtksmiley.c index 5656292066..c77c0fc5f9 100644 --- a/pidgin/gtksmiley.c +++ b/pidgin/gtksmiley.c @@ -37,6 +37,8 @@ #include "gtkutils.h" #include "pidginstock.h" +#include "gtk3compat.h" + #define PIDGIN_RESPONSE_MODIFY 1000 struct _PidginSmiley @@ -407,6 +409,10 @@ pidgin_smiley_edit(GtkWidget *widget, PurpleSmiley *smiley) if (smiley) g_object_set_data(G_OBJECT(smiley), "edit-dialog", window); +#if !GTK_CHECK_VERSION(3,0,0) + gtk_container_set_border_width(GTK_CONTAINER(window), PIDGIN_HIG_BORDER); +#endif + gtk_dialog_set_default_response(GTK_DIALOG(window), GTK_RESPONSE_ACCEPT); g_signal_connect(window, "response", G_CALLBACK(do_add_select_cb), s); @@ -872,6 +878,9 @@ void pidgin_smiley_manager_show(void) gtk_window_set_default_size(GTK_WINDOW(win), 50, 400); gtk_window_set_role(GTK_WINDOW(win), "custom_smiley_manager"); +#if !GTK_CHECK_VERSION(3,0,0) + gtk_container_set_border_width(GTK_CONTAINER(win),PIDGIN_HIG_BORDER); +#endif gtk_dialog_set_response_sensitive(GTK_DIALOG(win), GTK_RESPONSE_NO, FALSE); gtk_dialog_set_response_sensitive(GTK_DIALOG(win), PIDGIN_RESPONSE_MODIFY, FALSE); diff --git a/pidgin/gtksourceundomanager.c b/pidgin/gtksourceundomanager.c index 085471e7d1..a4cbc9a9fb 100644 --- a/pidgin/gtksourceundomanager.c +++ b/pidgin/gtksourceundomanager.c @@ -532,8 +532,9 @@ gtk_source_undo_manager_undo (GtkSourceUndoManager *um) um->priv->document, undo_action->action.insert_anchor.pos, undo_action->action.insert_anchor.pos + 1); - /* TODO: is this needed in GTK+3? */ - /*gtk_text_child_anchor_set_segment(undo_action->action.insert_anchor.anchor, NULL); XXX: This may be a bug in GTK+ */ +#if !GTK_CHECK_VERSION(3,0,0) + undo_action->action.insert_anchor.anchor->segment = NULL; /* XXX: This may be a bug in GTK+ */ +#endif break; default: /* Unknown action type. */ diff --git a/pidgin/gtkstatusbox.c b/pidgin/gtkstatusbox.c index e5adb31ddf..bea9523eb7 100644 --- a/pidgin/gtkstatusbox.c +++ b/pidgin/gtkstatusbox.c @@ -67,6 +67,8 @@ # endif #endif +#include "gtk3compat.h" + /* Timeout for typing notifications in seconds */ #define TYPING_TIMEOUT 4 @@ -82,10 +84,15 @@ static void pidgin_status_box_refresh(PidginStatusBox *status_box); static void status_menu_refresh_iter(PidginStatusBox *status_box, gboolean status_changed); static void pidgin_status_box_regenerate(PidginStatusBox *status_box, gboolean status_changed); static void pidgin_status_box_changed(PidginStatusBox *box); +#if GTK_CHECK_VERSION(3,0,0) static void pidgin_status_box_get_preferred_height (GtkWidget *widget, gint *minimum_height, gint *natural_height); -static void pidgin_status_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static gboolean pidgin_status_box_draw (GtkWidget *widget, cairo_t *cr); +#else +static void pidgin_status_box_size_request (GtkWidget *widget, GtkRequisition *requisition); +static gboolean pidgin_status_box_expose_event (GtkWidget *widget, GdkEventExpose *event); +#endif +static void pidgin_status_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static void pidgin_status_box_redisplay_buddy_icon(PidginStatusBox *status_box); static void pidgin_status_box_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); static void pidgin_status_box_popup(PidginStatusBox *box); @@ -617,9 +624,14 @@ pidgin_status_box_class_init (PidginStatusBoxClass *klass) parent_class = g_type_class_peek_parent(klass); widget_class = (GtkWidgetClass*)klass; +#if GTK_CHECK_VERSION(3,0,0) widget_class->get_preferred_height = pidgin_status_box_get_preferred_height; + widget_class->draw = pidgin_status_box_draw; +#else + widget_class->size_request = pidgin_status_box_size_request; + widget_class->expose_event = pidgin_status_box_expose_event; +#endif widget_class->size_allocate = pidgin_status_box_size_allocate; - widget_class->draw = pidgin_status_box_draw; container_class->child_type = pidgin_status_box_child_type; container_class->forall = pidgin_status_box_forall; @@ -1928,6 +1940,7 @@ pidgin_status_box_init (PidginStatusBox *status_box) } +#if GTK_CHECK_VERSION(3,0,0) static void pidgin_status_box_get_preferred_height(GtkWidget *widget, gint *minimum_height, gint *natural_height) @@ -1953,6 +1966,28 @@ pidgin_status_box_get_preferred_height(GtkWidget *widget, gint *minimum_height, *natural_height += box_nat_height + border_width * 2; } } +#else +static void +pidgin_status_box_size_request(GtkWidget *widget, + GtkRequisition *requisition) +{ + GtkRequisition box_req; + gint border_width = GTK_CONTAINER (widget)->border_width; + + gtk_widget_size_request(PIDGIN_STATUS_BOX(widget)->toggle_button, requisition); + + /* Make this icon the same size as other buddy icons in the list; unless it already wants to be bigger */ + requisition->height = MAX(requisition->height, 34); + requisition->height += border_width * 2; + + /* If the gtkimhtml is visible, then add some additional padding */ + gtk_widget_size_request(PIDGIN_STATUS_BOX(widget)->vbox, &box_req); + if (box_req.height > 1) + requisition->height += box_req.height + border_width * 2; + + requisition->width = 1; +} +#endif /* From gnome-panel */ static void @@ -1999,7 +2034,7 @@ pidgin_status_box_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { PidginStatusBox *status_box = PIDGIN_STATUS_BOX(widget); - GtkRequisition req = {0,40}; + GtkRequisition req = {0,40/*FIXME: Why not 0?*/}; GtkAllocation parent_alc, box_alc, icon_alc; gint border_width = gtk_container_get_border_width(GTK_CONTAINER (widget)); @@ -2043,6 +2078,7 @@ pidgin_status_box_size_allocate(GtkWidget *widget, gtk_widget_set_allocation(GTK_WIDGET(status_box), allocation); } +#if GTK_CHECK_VERSION(3,0,0) static gboolean pidgin_status_box_draw(GtkWidget *widget, cairo_t *cr) { @@ -2059,6 +2095,22 @@ pidgin_status_box_draw(GtkWidget *widget, cairo_t *cr) } return FALSE; } +#else +static gboolean +pidgin_status_box_expose_event(GtkWidget *widget, + GdkEventExpose *event) +{ + PidginStatusBox *status_box = PIDGIN_STATUS_BOX(widget); + gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->vbox, event); + gtk_container_propagate_expose(GTK_CONTAINER(widget), status_box->toggle_button, event); + if (status_box->icon_box && status_box->icon_opaque) { + gtk_paint_box(widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, + status_box->icon_box, "button", status_box->icon_box->allocation.x-1, status_box->icon_box->allocation.y-1, + 34, 34); + } + return FALSE; +} +#endif static void pidgin_status_box_forall(GtkContainer *container, diff --git a/pidgin/gtkutils.c b/pidgin/gtkutils.c index e127049b5e..b31d6cdc9b 100644 --- a/pidgin/gtkutils.c +++ b/pidgin/gtkutils.c @@ -71,6 +71,8 @@ #include "gtkwebviewtoolbar.h" #include "pidgin/minidialog.h" +#include "gtk3compat.h" + enum { AOP_ICON_COLUMN, AOP_NAME_COLUMN, @@ -2910,9 +2912,14 @@ pidgin_text_combo_box_entry_new(const char *default_item, GList *items) GtkComboBoxText *ret = NULL; GtkWidget *the_entry = NULL; +#if GTK_CHECK_VERSION(2,24,0) ret = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new_with_entry()); + the_entry = gtk_bin_get_child(GTK_BIN(ret)); +#else + ret = GTK_COMBO_BOX(gtk_combo_box_entry_new_text()); the_entry = gtk_entry_new(); gtk_container_add(GTK_CONTAINER(ret), the_entry); +#endif if (default_item) gtk_entry_set_text(GTK_ENTRY(the_entry), default_item); @@ -3623,7 +3630,11 @@ pidgin_make_scrollable(GtkWidget *child, GtkPolicyType hscrollbar_policy, GtkPol if (width != -1 || height != -1) gtk_widget_set_size_request(sw, width, height); if (child) { +#if GTK_CHECK_VERSION(3,0,0) if (GTK_IS_SCROLLABLE(child)) +#else + if (GTK_WIDGET_GET_CLASS(child)->set_scroll_adjustments_signal) +#endif gtk_container_add(GTK_CONTAINER(sw), child); else gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), child); diff --git a/pidgin/gtkwebview.c b/pidgin/gtkwebview.c index a6e91de53f..50b9079185 100644 --- a/pidgin/gtkwebview.c +++ b/pidgin/gtkwebview.c @@ -31,6 +31,8 @@ #include <gdk/gdkkeysyms.h> #include "gtkwebview.h" +#include "gtk3compat.h" + #define MAX_FONT_SIZE 7 #define MAX_SCROLL_TIME 0.4 /* seconds */ #define SCROLL_DELAY 33 /* milliseconds */ @@ -667,13 +669,8 @@ gtk_webview_page_up(GtkWebView *webview) priv = GTK_WEBVIEW_GET_PRIVATE(webview); vadj = priv->vadj; -#if GTK_CHECK_VERSION(2,14,0) scroll_val = gtk_adjustment_get_value(vadj) - gtk_adjustment_get_page_size(vadj); scroll_val = MAX(scroll_val, gtk_adjustment_get_lower(vadj)); -#else - scroll_val = gtk_adjustment_get_value(vadj) - vadj->page_size; - scroll_val = MAX(scroll_val, vadj->lower); -#endif gtk_adjustment_set_value(vadj, scroll_val); } @@ -690,15 +687,9 @@ gtk_webview_page_down(GtkWebView *webview) priv = GTK_WEBVIEW_GET_PRIVATE(webview); vadj = priv->vadj; -#if GTK_CHECK_VERSION(2,14,0) page_size = gtk_adjustment_get_page_size(vadj); scroll_val = gtk_adjustment_get_value(vadj) + page_size; scroll_val = MIN(scroll_val, gtk_adjustment_get_upper(vadj) - page_size); -#else - page_size = vadj->page_size; - scroll_val = gtk_adjustment_get_value(vadj) + page_size; - scroll_val = MIN(scroll_val, vadj->upper - page_size); -#endif gtk_adjustment_set_value(vadj, scroll_val); } diff --git a/pidgin/gtkwhiteboard.c b/pidgin/gtkwhiteboard.c index 1ef9a8e230..293b85c769 100644 --- a/pidgin/gtkwhiteboard.c +++ b/pidgin/gtkwhiteboard.c @@ -28,8 +28,13 @@ #include "gtkwhiteboard.h" #include "gtkutils.h" +#if GTK_CHECK_VERSION(3,0,0) +#define GdkPixType GdkPixbuf +#else +#define GdkPixType GdkPixmap +#endif struct _PidginWhiteboardPrivate { - GdkPixbuf *pixbuf; + GdkPixType *pix; cairo_t *cr; }; @@ -286,11 +291,11 @@ static void pidgin_whiteboard_destroy(PurpleWhiteboard *wb) /* TODO Ask if user wants to save picture before the session is closed */ /* Clear graphical memory */ - if (gtkwb->priv->pixbuf) { + if (gtkwb->priv->pix) { cairo_t *cr = gtkwb->priv->cr; if (cr) cairo_destroy(cr); - g_object_unref(gtkwb->priv->pixbuf); + g_object_unref(gtkwb->priv->pix); } colour_dialog = g_object_get_data(G_OBJECT(gtkwb->window), "colour-dialog"); @@ -362,27 +367,38 @@ static void pidginwhiteboard_button_start_press(GtkButton *button, gpointer data static gboolean pidgin_whiteboard_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) { PidginWhiteboard *gtkwb = (PidginWhiteboard*)data; - GdkPixbuf *pixbuf = gtkwb->priv->pixbuf; + GdkPixType *pix = gtkwb->priv->pix; cairo_t *cr; GdkWindow *window = gtk_widget_get_window(widget); GtkAllocation allocation; - if (pixbuf) { + if (pix) { cr = gtkwb->priv->cr; if (cr) cairo_destroy(cr); - g_object_unref(pixbuf); + g_object_unref(pix); } gtk_widget_get_allocation(widget, &allocation); - pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, - FALSE, gdk_visual_get_depth(GDK_VISUAL(window)), - allocation.width, allocation.height); +#if GTK_CHECK_VERSION(3,0,0) + pix = gdk_pixbuf_new(GDK_COLORSPACE_RGB, + FALSE, gdk_visual_get_depth(GDK_VISUAL(window)), + allocation.width, allocation.height); +#else + pix = gdk_pixmap_new(widget->window, + allocation.width, + allocation.height, + -1); +#endif - gtkwb->priv->pixbuf = pixbuf; + gtkwb->priv->pix = pix; +#if GTK_CHECK_VERSION(3,0,0) cr = gdk_cairo_create(gtk_widget_get_window(widget)); +#else + cr = gdk_cairo_create(GDK_DRAWABLE(pix)); +#endif gtkwb->priv->cr = cr; gdk_cairo_set_source_color(cr, >k_widget_get_style(widget)->white); cairo_rectangle(cr, @@ -396,11 +412,16 @@ static gboolean pidgin_whiteboard_configure_event(GtkWidget *widget, GdkEventCon static gboolean pidgin_whiteboard_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) { PidginWhiteboard *gtkwb = (PidginWhiteboard*)(data); - GdkPixbuf *pixbuf = gtkwb->priv->pixbuf; + GdkPixType *pix = gtkwb->priv->pix; cairo_t *cr; +#if GTK_CHECK_VERSION(3,0,0) cr = gdk_cairo_create(gtk_widget_get_window(widget)); - gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0); + gdk_cairo_set_source_pixbuf(cr, pix, 0, 0); +#else + cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); + gdk_cairo_set_source_pixmap(cr, pix, 0, 0); +#endif cairo_rectangle(cr, event->area.x, event->area.y, event->area.width, event->area.height); @@ -413,7 +434,6 @@ static gboolean pidgin_whiteboard_expose_event(GtkWidget *widget, GdkEventExpose static gboolean pidgin_whiteboard_brush_down(GtkWidget *widget, GdkEventButton *event, gpointer data) { PidginWhiteboard *gtkwb = (PidginWhiteboard*)data; - GdkPixbuf *pixbuf = gtkwb->priv->pixbuf; PurpleWhiteboard *wb = gtkwb->wb; GList *draw_list = purple_whiteboard_get_draw_list(wb); @@ -428,7 +448,7 @@ static gboolean pidgin_whiteboard_brush_down(GtkWidget *widget, GdkEventButton * BrushState = BRUSH_STATE_DOWN; - if(event->button == 1 && pixbuf != NULL) + if(event->button == 1 && gtkwb->priv->pix != NULL) { /* Check if draw_list has contents; if so, clear it */ if(draw_list) @@ -466,7 +486,6 @@ static gboolean pidgin_whiteboard_brush_motion(GtkWidget *widget, GdkEventMotion GdkModifierType state; PidginWhiteboard *gtkwb = (PidginWhiteboard*)data; - GdkPixbuf *pixbuf = gtkwb->priv->pixbuf; PurpleWhiteboard *wb = gtkwb->wb; GList *draw_list = purple_whiteboard_get_draw_list(wb); @@ -480,7 +499,7 @@ static gboolean pidgin_whiteboard_brush_motion(GtkWidget *widget, GdkEventMotion state = event->state; } - if(state & GDK_BUTTON1_MASK && pixbuf != NULL) + if(state & GDK_BUTTON1_MASK && gtkwb->priv->pix != NULL) { if((BrushState != BRUSH_STATE_DOWN) && (BrushState != BRUSH_STATE_MOTION)) { @@ -546,7 +565,6 @@ static gboolean pidgin_whiteboard_brush_motion(GtkWidget *widget, GdkEventMotion static gboolean pidgin_whiteboard_brush_up(GtkWidget *widget, GdkEventButton *event, gpointer data) { PidginWhiteboard *gtkwb = (PidginWhiteboard*)data; - GdkPixbuf *pixbuf = gtkwb->priv->pixbuf; PurpleWhiteboard *wb = gtkwb->wb; GList *draw_list = purple_whiteboard_get_draw_list(wb); @@ -561,7 +579,7 @@ static gboolean pidgin_whiteboard_brush_up(GtkWidget *widget, GdkEventButton *ev } BrushState = BRUSH_STATE_UP; - if(event->button == 1 && pixbuf != NULL) + if(event->button == 1 && gtkwb->priv->pix != NULL) { /* If the brush was never moved, express two sets of two deltas That's a * 'point,' but not for Yahoo! @@ -723,9 +741,9 @@ static void pidgin_whiteboard_clear(PurpleWhiteboard *wb) cairo_fill(cr); gtk_widget_queue_draw_area(drawing_area, - 0, 0, - allocation.width, - allocation.height); + 0, 0, + allocation.width, + allocation.height); } static void pidgin_whiteboard_button_clear_press(GtkWidget *widget, gpointer data) @@ -791,7 +809,16 @@ static void pidgin_whiteboard_button_save_press(GtkWidget *widget, gpointer data gtk_widget_destroy(dialog); /* Makes an icon from the whiteboard's canvas 'image' */ - pixbuf = gtkwb->priv->pixbuf; +#if GTK_CHECK_VERSION(3,0,0) + pixbuf = gtkwb->priv->pix; +#else + pixbuf = gdk_pixbuf_get_from_drawable(NULL, + (GdkDrawable*)(gtkwb->priv->pixmap), + gdk_drawable_get_colormap(gtkwb->priv->pixmap), + 0, 0, + 0, 0, + gtkwb->width, gtkwb->height); +#endif if(gdk_pixbuf_save(pixbuf, filename, "jpeg", NULL, "quality", "100", NULL)) purple_debug_info("gtkwhiteboard", "File Saved...\n"); @@ -812,7 +839,17 @@ static void pidgin_whiteboard_set_canvas_as_icon(PidginWhiteboard *gtkwb) GdkPixbuf *pixbuf; /* Makes an icon from the whiteboard's canvas 'image' */ - pixbuf = gtkwb->priv->pixbuf; +#if GTK_CHECK_VERSION(3,0,0) + pixbuf = gtkwb->priv->pix; +#else + pixbuf = gdk_pixbuf_get_from_drawable(NULL, + (GdkDrawable*)(gtkwb->priv->pixmap), + gdk_drawable_get_colormap(gtkwb->priv->pixmap), + 0, 0, + 0, 0, + gtkwb->width, gtkwb->height); +#endif + gtk_window_set_icon((GtkWindow*)(gtkwb->window), pixbuf); } @@ -863,7 +900,7 @@ static void color_select_dialog(GtkWidget *widget, PidginWhiteboard *gtkwb) g_object_get(G_OBJECT(dialog), "ok-button", &ok_button, NULL); g_signal_connect(G_OBJECT(ok_button), "clicked", - G_CALLBACK(color_selection_dialog_destroy), gtkwb); + G_CALLBACK(color_selection_dialog_destroy), gtkwb); gtk_color_selection_set_has_palette(GTK_COLOR_SELECTION(gtk_color_selection_dialog_get_color_selection(dialog)), TRUE); diff --git a/pidgin/minidialog.c b/pidgin/minidialog.c index f6136cbe0c..fb3e0c4888 100644 --- a/pidgin/minidialog.c +++ b/pidgin/minidialog.c @@ -184,7 +184,12 @@ struct _mini_dialog_button_clicked_cb_data guint pidgin_mini_dialog_get_num_children(PidginMiniDialog *mini_dialog) { - return g_list_length(gtk_container_get_children(GTK_CONTAINER(mini_dialog->contents))); + GList *tmp; + guint len; + tmp = gtk_container_get_children(GTK_CONTAINER(mini_dialog->contents)); + len = g_list_length(tmp); + g_list_free(tmp); + return len; } static gboolean diff --git a/pidgin/pidgintooltip.c b/pidgin/pidgintooltip.c index de86d12a0c..75692007ea 100644 --- a/pidgin/pidgintooltip.c +++ b/pidgin/pidgintooltip.c @@ -100,6 +100,7 @@ void pidgin_tooltip_destroy() } } +#if GTK_CHECK_VERSION(3,0,0) static gboolean pidgin_tooltip_draw_cb(GtkWidget *widget, cairo_t *cr, gpointer data) { @@ -109,12 +110,27 @@ pidgin_tooltip_draw_cb(GtkWidget *widget, cairo_t *cr, gpointer data) if (pidgin_tooltip.paint_tooltip) { gtk_paint_flat_box(gtk_widget_get_style(widget), cr, - GTK_STATE_NORMAL, GTK_SHADOW_OUT, - widget, "tooltip", 0, 0, allocation.width, allocation.height); + GTK_STATE_NORMAL, GTK_SHADOW_OUT, + widget, "tooltip", + 0, 0, allocation.width, allocation.height); pidgin_tooltip.paint_tooltip(widget, cr, data); } return FALSE; } +#else +static gboolean +pidgin_tooltip_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data) +{ + if (pidgin_tooltip.paint_tooltip) { + cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget))); + gtk_paint_flat_box(widget->style, widget->window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, + NULL, widget, "tooltip", 0, 0, -1, -1); + pidgin_tooltip.paint_tooltip(widget, cr, data); + cairo_destroy(cr); + } + return FALSE; +} +#endif static GtkWidget* setup_tooltip_window(void) @@ -194,8 +210,13 @@ setup_tooltip_window_position(gpointer data, int w, int h) gtk_window_move(GTK_WINDOW(tipwindow), x, y); gtk_widget_show(tipwindow); +#if GTK_CHECK_VERSION(3,0,0) g_signal_connect(G_OBJECT(tipwindow), "draw", G_CALLBACK(pidgin_tooltip_draw_cb), data); +#else + g_signal_connect(G_OBJECT(tipwindow), "expose_event", + G_CALLBACK(pidgin_tooltip_expose_event), data); +#endif /* Hide the tooltip when the widget is destroyed */ sig = g_signal_connect(G_OBJECT(pidgin_tooltip.widget), "destroy", G_CALLBACK(pidgin_tooltip_destroy), NULL); diff --git a/pidgin/plugins/disco/gtkdisco.c b/pidgin/plugins/disco/gtkdisco.c index 8a5c9084a0..70c5b6ce76 100644 --- a/pidgin/plugins/disco/gtkdisco.c +++ b/pidgin/plugins/disco/gtkdisco.c @@ -430,11 +430,19 @@ static gboolean disco_paint_tooltip(GtkWidget *tipwindow, cairo_t *cr, gpointer data) { PangoLayout *layout = g_object_get_data(G_OBJECT(tipwindow), "tooltip-plugin"); +#if GTK_CHECK_VERSION(3,0,0) gtk_paint_layout(gtk_widget_get_style(tipwindow), - cr, - GTK_STATE_NORMAL, FALSE, - tipwindow, "tooltip", - 6, 6, layout); + cr, + GTK_STATE_NORMAL, FALSE, + tipwindow, "tooltip", + 6, 6, layout); +#else + gtk_paint_layout(gtk_widget_get_style(tipwindow), + gtk_widget_get_window(tipwindow), + GTK_STATE_NORMAL, FALSE, + NULL, tipwindow, "tooltip", + 6, 6, layout); +#endif return TRUE; } diff --git a/pidgin/plugins/gestures/stroke-draw.c b/pidgin/plugins/gestures/stroke-draw.c index 2b30b3b337..f7f2674eec 100644 --- a/pidgin/plugins/gestures/stroke-draw.c +++ b/pidgin/plugins/gestures/stroke-draw.c @@ -19,6 +19,8 @@ #include <X11/Xlib.h> #include <X11/Xutil.h> +#include "gtk3compat.h" + static void gstroke_invisible_window_init (GtkWidget *widget); /*FIXME: Maybe these should be put in a structure, and not static...*/ static Display * gstroke_disp = NULL; diff --git a/pidgin/plugins/ticker/gtkticker.c b/pidgin/plugins/ticker/gtkticker.c index efc3c4749b..30ff4a5e0e 100644 --- a/pidgin/plugins/ticker/gtkticker.c +++ b/pidgin/plugins/ticker/gtkticker.c @@ -24,17 +24,24 @@ #include "gtkticker.h" #include <gtk/gtk.h> +#include "gtk3compat.h" + static void gtk_ticker_compute_offsets (GtkTicker *ticker); static void gtk_ticker_class_init (GtkTickerClass *klass); static void gtk_ticker_init (GtkTicker *ticker); static void gtk_ticker_map (GtkWidget *widget); static void gtk_ticker_realize (GtkWidget *widget); +#if GTK_CHECK_VERSION(3,0,0) static void gtk_ticker_get_preferred_width (GtkWidget *widget, gint *minimal_width, gint *natural_width); static void gtk_ticker_get_preferred_height (GtkWidget *widget, gint *minimal_height, gint *natural_height); +#else +static void gtk_ticker_size_request (GtkWidget *widget, + GtkRequisition *requisition); +#endif static void gtk_ticker_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static void gtk_ticker_add_real (GtkContainer *container, @@ -107,8 +114,12 @@ static void gtk_ticker_class_init (GtkTickerClass *class) widget_class->map = gtk_ticker_map; widget_class->realize = gtk_ticker_realize; +#if GTK_CHECK_VERSION(3,0,0) widget_class->get_preferred_width = gtk_ticker_get_preferred_width; widget_class->get_preferred_height = gtk_ticker_get_preferred_height; +#else + widget_class->size_request = gtk_ticker_size_request; +#endif widget_class->size_allocate = gtk_ticker_size_allocate; container_class->add = gtk_ticker_add_real; @@ -299,22 +310,29 @@ static void gtk_ticker_realize (GtkWidget *widget) attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); +#if !GTK_CHECK_VERSION(3,0,0) + attributes.colormap = gtk_widget_get_colormap (widget); +#endif attributes.event_mask = gtk_widget_get_events (widget); attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK; +#if GTK_CHECK_VERSION(3,0,0) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; +#else + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; +#endif window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gtk_widget_set_window (widget, window); gdk_window_set_user_data (window, widget); - style = gtk_widget_get_style (widget); - style = gtk_style_attach (style, window); + style = gtk_style_attach (gtk_widget_get_style (widget), window); gtk_widget_set_style (widget, style); gtk_style_set_background (style, window, GTK_STATE_NORMAL); } +#if GTK_CHECK_VERSION(3,0,0) static void gtk_ticker_get_preferred_width (GtkWidget *widget, gint *minimal_width, @@ -387,6 +405,48 @@ gtk_ticker_get_preferred_height (GtkWidget *widget, *minimal_height = *natural_height = height; } +#else + +static void gtk_ticker_size_request (GtkWidget *widget, GtkRequisition *requisition) +{ + GtkTicker *ticker; + GtkTickerChild *child; + GList *children; + GtkRequisition child_requisition; + guint border_width; + + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_TICKER (widget)); + g_return_if_fail (requisition != NULL); + + ticker = GTK_TICKER (widget); + requisition->width = 0; + requisition->height = 0; + + children = ticker->children; + while (children) + { + child = children->data; + children = children->next; + + if (gtk_widget_get_visible (child->widget)) + { + gtk_widget_size_request (child->widget, &child_requisition); + + requisition->height = MAX (requisition->height, + child_requisition.height); + requisition->width += child_requisition.width + ticker->spacing; + } + } + if ( requisition->width > ticker->spacing ) + requisition->width -= ticker->spacing; + + border_width = gtk_container_get_border_width (GTK_CONTAINER (ticker)); + requisition->height += border_width * 2; + requisition->width += border_width * 2; +} +#endif + static void gtk_ticker_compute_offsets (GtkTicker *ticker) { GtkAllocation allocation; diff --git a/pidgin/plugins/timestamp_format.c b/pidgin/plugins/timestamp_format.c index e32cd959dd..3268efec5d 100644 --- a/pidgin/plugins/timestamp_format.c +++ b/pidgin/plugins/timestamp_format.c @@ -155,7 +155,6 @@ menu_cb(GtkWidget *item, gpointer data) if (!frame) return; - /* GTK_DIALOG_NO_SEPARATOR seems to be gone in gtk+ 3.0... */ dialog = gtk_dialog_new_with_buttons(PIDGIN_ALERT_TITLE, NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, diff --git a/pidgin/plugins/xmppconsole.c b/pidgin/plugins/xmppconsole.c index dd38fbe2cb..2de4eea0ba 100644 --- a/pidgin/plugins/xmppconsole.c +++ b/pidgin/plugins/xmppconsole.c @@ -31,6 +31,8 @@ #include <gdk/gdkkeysyms.h> +#include "gtk3compat.h" + typedef struct { PurpleConnection *gc; GtkWidget *window; |