[xchat-gnome] Bug 637427 - [PATCH] Stop using deprecated GDK/GTK API
- From: Ritesh Khadgaray <rkhadgaray src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [xchat-gnome] Bug 637427 - [PATCH] Stop using deprecated GDK/GTK API
- Date: Mon, 17 Jan 2011 12:11:25 +0000 (UTC)
commit 23aa5dd1a3033c0badd750bedea8ba1b7a677a74
Author: Robert Ancell <robert ancell gmail com>
Date: Mon Jan 17 17:40:30 2011 +0530
Bug 637427 - [PATCH] Stop using deprecated GDK/GTK API
removed a bit of deprecated apis, and minor indentation fixes
src/fe-gnome/channel-list-window.c | 2 +-
src/fe-gnome/connect-dialog.c | 2 +
src/fe-gnome/conversation-panel.c | 12 ++++-
src/fe-gnome/irc-network-editor.c | 9 +++
src/fe-gnome/preferences-page-colors.c | 8 +++
src/fe-gnome/text-entry.c | 16 ++++++
src/fe-gnome/userlist-gui.c | 5 ++
src/fe-gnome/xtext.c | 93 +++++++++++++++++++++++--------
8 files changed, 121 insertions(+), 26 deletions(-)
---
diff --git a/src/fe-gnome/channel-list-window.c b/src/fe-gnome/channel-list-window.c
index e7e7c31..652f549 100644
--- a/src/fe-gnome/channel-list-window.c
+++ b/src/fe-gnome/channel-list-window.c
@@ -497,7 +497,7 @@ channel_list_window_finalize (GObject *object)
g_source_remove (win->refresh_timeout);
}
chanlists = g_slist_remove (chanlists, (gpointer) win);
- gtk_widget_hide_all (win->window);
+ gtk_widget_hide (win->window);
g_object_unref (win->xml);
G_OBJECT_CLASS (channel_list_window_parent_class)->finalize (object);
diff --git a/src/fe-gnome/connect-dialog.c b/src/fe-gnome/connect-dialog.c
index 35b90a6..22895e8 100644
--- a/src/fe-gnome/connect-dialog.c
+++ b/src/fe-gnome/connect-dialog.c
@@ -159,7 +159,9 @@ connect_dialog_init (ConnectDialog *dialog)
gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_OK);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 6);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), dialog->toplevel);
+#if !GTK_CHECK_VERSION (2, 23, 0)
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+#endif
g_signal_connect (G_OBJECT (dialog->server_list), "row-activated", G_CALLBACK (row_activated), dialog);
diff --git a/src/fe-gnome/conversation-panel.c b/src/fe-gnome/conversation-panel.c
index fb013c7..59e1bcd 100644
--- a/src/fe-gnome/conversation-panel.c
+++ b/src/fe-gnome/conversation-panel.c
@@ -584,13 +584,23 @@ conversation_panel_set_background (ConversationPanel *panel)
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
if (pixbuf) {
gint width, height;
+#if GTK_CHECK_VERSION (2, 23, 0)
+ cairo_t *context;
+#endif
GdkPixmap *image;
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
image = gdk_pixmap_new (NULL, width, height, 24);
+#if GTK_CHECK_VERSION (2, 23, 0)
+ context = gdk_cairo_create (GDK_DRAWABLE (image));
+ gdk_cairo_set_source_pixbuf (context, pixbuf, 0, 0);
+ cairo_paint (context);
+ cairo_destroy (context);
+#else
gdk_draw_pixbuf (image, NULL, pixbuf, 0, 0, 0, 0, width, height, GDK_RGB_DITHER_NONE, 0, 0);
+#endif
gtk_xtext_set_background (GTK_XTEXT (panel->priv->xtext), image, FALSE);
g_object_unref (pixbuf);
@@ -602,7 +612,7 @@ conversation_panel_set_background (ConversationPanel *panel)
float transparency = gconf_client_get_float (client, "/apps/xchat/main_window/background_transparency", NULL);
int value = 255 - ((int) (transparency * 255));
- if (gdk_drawable_get_visual (gui.main_window->window)->depth == 32) {
+ if (gdk_drawable_get_depth (gui.main_window->window) == 32) {
gtk_xtext_set_tint (GTK_XTEXT (panel->priv->xtext), 0, 0, 0);
gtk_xtext_set_background (GTK_XTEXT (panel->priv->xtext), NULL, FALSE);
gtk_xtext_set_alpha (GTK_XTEXT (panel->priv->xtext), transparency);
diff --git a/src/fe-gnome/irc-network-editor.c b/src/fe-gnome/irc-network-editor.c
index 0f424d0..4fa132b 100644
--- a/src/fe-gnome/irc-network-editor.c
+++ b/src/fe-gnome/irc-network-editor.c
@@ -322,13 +322,22 @@ irc_network_editor_init (IrcNetworkEditor *dialog)
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (dialog->autojoin_channels), 1, _("Key"), dialog->autojoin_key_renderer, "text", 1, NULL);
g_object_set (G_OBJECT (dialog->autojoin_key_renderer), "editable", TRUE, NULL);
+#if GTK_CHECK_VERSION (2, 23, 0)
+ dialog->encoding = gtk_combo_box_text_new ();
+#else
dialog->encoding = gtk_combo_box_new_text ();
+#endif
+
gtk_widget_show (dialog->encoding);
gtk_table_attach_defaults (GTK_TABLE (dialog->network_settings_table), dialog->encoding, 1, 2, 5, 6);
enc = (gchar **) encodings;
do {
+#if GTK_CHECK_VERSION (2, 23, 0)
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (dialog->encoding), _(*enc));
+#else
gtk_combo_box_append_text (GTK_COMBO_BOX (dialog->encoding), _(*enc));
+#endif
enc++;
} while (*enc);
diff --git a/src/fe-gnome/preferences-page-colors.c b/src/fe-gnome/preferences-page-colors.c
index 51afb4f..33186c9 100644
--- a/src/fe-gnome/preferences-page-colors.c
+++ b/src/fe-gnome/preferences-page-colors.c
@@ -255,10 +255,18 @@ preferences_page_colors_new (gpointer prefs_dialog, GtkBuilder *xml)
gtk_list_store_set (p->page_store, &iter, 0, PREFERENCES_PAGE (page)->icon, 1, _("Colors"), 2, 1, -1);
page->combo = gtk_combo_box_new_text ();
+#if GTK_CHECK_VERSION (2, 23, 0)
+ page->combo = gtk_combo_box_text_new ();
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (page->combo), _("Black on White"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (page->combo), _("White on Black"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (page->combo), _("Custom"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (page->combo), _("System Theme Colors"));
+#else
gtk_combo_box_append_text (GTK_COMBO_BOX (page->combo), _("Black on White"));
gtk_combo_box_append_text (GTK_COMBO_BOX (page->combo), _("White on Black"));
gtk_combo_box_append_text (GTK_COMBO_BOX (page->combo), _("Custom"));
gtk_combo_box_append_text (GTK_COMBO_BOX (page->combo), _("System Theme Colors"));
+#endif
gtk_widget_show (page->combo);
gtk_label_set_mnemonic_widget (GTK_LABEL (page->color_label_1), page->combo);
gtk_box_pack_start (GTK_BOX (page->foreground_background_hbox), page->combo, FALSE, TRUE, 0);
diff --git a/src/fe-gnome/text-entry.c b/src/fe-gnome/text-entry.c
index 24c192b..ad24c6c 100644
--- a/src/fe-gnome/text-entry.c
+++ b/src/fe-gnome/text-entry.c
@@ -624,19 +624,35 @@ get_color_icon (int c, GtkStyle *style)
{
GtkWidget *image;
GdkPixmap *pixmap;
+#if GTK_CHECK_VERSION (2, 23, 0)
+ cairo_t *context;
+#else
GdkGC *color;
+#endif
pixmap = gdk_pixmap_new (NULL, 16, 16, 24);
+#if GTK_CHECK_VERSION (2, 23, 0)
+ context = gdk_cairo_create (GDK_DRAWABLE (pixmap));
+ gdk_cairo_set_source_color (context, &style->dark[GTK_STATE_NORMAL]);
+ cairo_rectangle (context, 0, 0, 16, 16);
+ cairo_fill (context);
+ gdk_cairo_set_source_color (context, &colors[c]);
+ cairo_rectangle (context, 1, 1, 14, 14);
+ cairo_fill (context);
+ cairo_destroy (context);
+#else
color = gdk_gc_new (GDK_DRAWABLE (pixmap));
gdk_gc_set_foreground (color, &style->dark[GTK_STATE_NORMAL]);
gdk_draw_rectangle (GDK_DRAWABLE (pixmap), color, TRUE, 0, 0, 16, 16);
gdk_gc_set_foreground (color, &colors[c]);
gdk_draw_rectangle (GDK_DRAWABLE (pixmap), color, TRUE, 1, 1, 14, 14);
g_object_unref (color);
+#endif
image = gtk_image_new_from_pixmap (pixmap, NULL);
g_object_unref (pixmap);
+
return image;
}
diff --git a/src/fe-gnome/userlist-gui.c b/src/fe-gnome/userlist-gui.c
index c6671df..3e1dd66 100644
--- a/src/fe-gnome/userlist-gui.c
+++ b/src/fe-gnome/userlist-gui.c
@@ -402,7 +402,12 @@ userlist_button_release (GtkWidget *widget, GdkEventButton *button, gpointer dat
gint x, y, width, height;
gdk_window_get_root_origin (gui.userlist_window->window, &x, &y);
+#if GTK_CHECK_VERSION (2, 23, 0)
+ width = gdk_window_get_width (gui.userlist_window->window);
+ height = gdk_window_get_height (gui.userlist_window->window);
+#else
gdk_drawable_get_size (gui.userlist_window->window, &width, &height);
+#endif
/* If the event happened on top of the userlist window, we don't want to
* close it */
diff --git a/src/fe-gnome/xtext.c b/src/fe-gnome/xtext.c
index a7e2caf..06b00c5 100644
--- a/src/fe-gnome/xtext.c
+++ b/src/fe-gnome/xtext.c
@@ -978,28 +978,28 @@ gtk_xtext_realize (GtkWidget * widget)
attributes.visual = gtk_widget_get_visual (widget);
widget->window = gdk_window_new (widget->parent->window, &attributes,
- GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL |
- GDK_WA_COLORMAP);
+ GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL |
+ GDK_WA_COLORMAP);
gdk_window_set_user_data (widget->window, widget);
- xtext->depth = gdk_drawable_get_visual (widget->window)->depth;
+ xtext->depth = gdk_drawable_get_depth (widget->window);
val.subwindow_mode = GDK_INCLUDE_INFERIORS;
val.graphics_exposures = 0;
xtext->bgc = gdk_gc_new_with_values (widget->window, &val,
- GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
+ GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
xtext->fgc = gdk_gc_new_with_values (widget->window, &val,
- GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
+ GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
xtext->light_gc = gdk_gc_new_with_values (widget->window, &val,
- GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
+ GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
xtext->dark_gc = gdk_gc_new_with_values (widget->window, &val,
- GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
+ GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
xtext->thin_gc = gdk_gc_new_with_values (widget->window, &val,
- GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
+ GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
xtext->marker_gc = gdk_gc_new_with_values (widget->window, &val,
- GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
+ GDK_GC_EXPOSURES | GDK_GC_SUBWINDOW);
/* for the separator bar (light) */
col.red = 0xffff; col.green = 0xffff; col.blue = 0xffff;
@@ -1041,9 +1041,9 @@ gtk_xtext_realize (GtkWidget * widget)
gdk_gc_set_fill (xtext->bgc, GDK_TILED);
}
-#if (GTK_MAJOR_VERSION == 2) && (GTK_MINOR_VERSION == 0)
- xtext->hand_cursor = gdk_cursor_new (GDK_HAND1);
- xtext->resize_cursor = gdk_cursor_new (GDK_LEFT_SIDE);
+#if GTK_CHECK_VERSION (2, 23, 0)
+ xtext->hand_cursor = gdk_cursor_new_for_display (gdk_window_get_display (widget->window), GDK_HAND1);
+ xtext->resize_cursor = gdk_cursor_new_for_display (gdk_window_get_display (widget->window), GDK_LEFT_SIDE);
#else
xtext->hand_cursor = gdk_cursor_new_for_display (gdk_drawable_get_display (widget->window), GDK_HAND1);
xtext->resize_cursor = gdk_cursor_new_for_display (gdk_drawable_get_display (widget->window), GDK_LEFT_SIDE);
@@ -1718,7 +1718,11 @@ gtk_xtext_scrolldown_timeout (GtkXText * xtext)
int p_y, win_height;
gdk_window_get_pointer (GTK_WIDGET (xtext)->window, 0, &p_y, 0);
+#if GTK_CHECK_VERSION (2, 23, 0)
+ win_height = gdk_window_get_height (GTK_WIDGET (xtext)->window);
+#else
gdk_drawable_get_size (GTK_WIDGET (xtext)->window, 0, &win_height);
+#endif
if (p_y > win_height &&
xtext->adj->value < (xtext->adj->upper - xtext->adj->page_size))
@@ -1758,7 +1762,11 @@ gtk_xtext_selection_update (GtkXText * xtext, GdkEventMotion * event, int p_y, g
int win_height;
int moved;
+#if GTK_CHECK_VERSION (2, 16, 0)
+ win_height = gdk_window_get_height (GTK_WIDGET (xtext)->window);
+#else
gdk_drawable_get_size (GTK_WIDGET (xtext)->window, 0, &win_height);
+#endif
/* selecting past top of window, scroll up! */
if (p_y < 0 && xtext->adj->value >= 0)
@@ -2372,8 +2380,8 @@ gtk_xtext_selection_get_text (GtkXText *xtext, int *len_ret)
static void
gtk_xtext_selection_get (GtkWidget * widget,
- GtkSelectionData * selection_data_ptr,
- guint info, guint time)
+ GtkSelectionData * selection_data_ptr,
+ guint info, guint time)
{
GtkXText *xtext = GTK_XTEXT (widget);
char *stripped;
@@ -2398,16 +2406,16 @@ gtk_xtext_selection_get (GtkWidget * widget,
gint format;
gint new_length;
-#if (GTK_MAJOR_VERSION == 2) && (GTK_MINOR_VERSION == 0)
- gdk_string_to_compound_text (
+ gdk_string_to_compound_text_for_display (
+#if GTK_CHECK_VERSION (2, 23, 0)
+ gdk_window_get_display (widget->window),
#else
- gdk_string_to_compound_text_for_display (
- gdk_drawable_get_display (widget->window),
+ gdk_drawable_get_display (widget->window),
#endif
- stripped, &encoding, &format, &new_text,
- &new_length);
+ stripped, &encoding, &format, &new_text,
+ &new_length);
gtk_selection_data_set (selection_data_ptr, encoding, format,
- new_text, new_length);
+ new_text, new_length);
gdk_free_compound_text (new_text);
}
break;
@@ -3750,7 +3758,13 @@ gtk_xtext_load_trans (GtkXText * xtext)
if (xtext->shaded)
{
int width, height;
+#if GTK_CHECK_VERSION (2, 23, 0)
+ width = gdk_window_get_width (GTK_WIDGET (xtext)->window);
+ height = gdk_window_get_height (GTK_WIDGET (xtext)->window);
+#else
gdk_drawable_get_size (GTK_WIDGET (xtext)->window, &width, &height);
+#endif
+
xtext->pixmap = shade_pixmap (xtext, rootpix, x, y, width+105, height);
if (xtext->pixmap == NULL)
{
@@ -3763,8 +3777,8 @@ gtk_xtext_load_trans (GtkXText * xtext)
} else
{
noshade:
-#if (GTK_MAJOR_VERSION == 2) && (GTK_MINOR_VERSION == 0)
- xtext->pixmap = gdk_pixmap_foreign_new (rootpix);
+#if GTK_CHECK_VERSION (2, 23, 0)
+ xtext->pixmap = gdk_pixmap_foreign_new_for_display (gdk_window_get_display (GTK_WIDGET (xtext)->window), rootpix);
#else
xtext->pixmap = gdk_pixmap_foreign_new_for_display (gdk_drawable_get_display (GTK_WIDGET (xtext)->window), rootpix);
#endif
@@ -3910,7 +3924,11 @@ gtk_xtext_find_subline (GtkXText *xtext, textentry *ent, int line)
if (line <= RECORD_WRAPS)
return ent->wrap_offset[line - 1];
+#if GTK_CHECK_VERSION (2, 16, 0)
+ win_width = gdk_window_get_width (GTK_WIDGET (xtext)->window);
+#else
gdk_drawable_get_size (GTK_WIDGET (xtext)->window, &win_width, 0);
+#endif
win_width -= MARGIN;
/* indent = ent->indent;
@@ -4329,7 +4347,12 @@ gtk_xtext_calc_lines (xtext_buffer *buf, int fire_signal)
int height;
int lines;
+#if GTK_CHECK_VERSION (2, 23, 0)
+ width = gdk_window_get_width (GTK_WIDGET (buf->xtext)->window);
+ height = gdk_window_get_height (GTK_WIDGET (buf->xtext)->window);
+#else
gdk_drawable_get_size (GTK_WIDGET (buf->xtext)->window, &width, &height);
+#endif
width -= MARGIN;
if (width < 30 || height < buf->xtext->fontsize || width < buf->indent + 30)
@@ -4424,7 +4447,12 @@ gtk_xtext_render_ents (GtkXText * xtext, textentry * enta, textentry * entb)
if (xtext->buffer->indent < MARGIN)
xtext->buffer->indent = MARGIN; /* 2 pixels is our left margin */
+#if GTK_CHECK_VERSION (2, 23, 0)
+ width = gdk_window_get_width (GTK_WIDGET (xtext)->window);
+ height = gdk_window_get_height (GTK_WIDGET (xtext)->window);
+#else
gdk_drawable_get_size (GTK_WIDGET (xtext)->window, &width, &height);
+#endif
width -= MARGIN;
if (width < 32 || height < xtext->fontsize || width < xtext->buffer->indent + 30)
@@ -4511,7 +4539,12 @@ gtk_xtext_render_page (GtkXText * xtext)
if (xtext->buffer->indent < MARGIN)
xtext->buffer->indent = MARGIN; /* 2 pixels is our left margin */
+#if GTK_CHECK_VERSION (2, 23, 0)
+ width = gdk_window_get_width (GTK_WIDGET (xtext)->window);
+ height = gdk_window_get_height (GTK_WIDGET (xtext)->window);
+#else
gdk_drawable_get_size (GTK_WIDGET (xtext)->window, &width, &height);
+#endif
if (width < 34 || height < xtext->fontsize || width < xtext->buffer->indent + 32)
return;
@@ -4563,8 +4596,11 @@ gtk_xtext_render_page (GtkXText * xtext)
#endif
#endif
{
+
+#if !GTK_CHECK_VERSION (2, 13, 0)
/* so the obscured regions are exposed */
gdk_gc_set_exposures (xtext->fgc, TRUE);
+#endif
if (overlap < 1) /* DOWN */
{
int remainder;
@@ -4719,7 +4755,12 @@ gtk_xtext_check_ent_visibility (GtkXText * xtext, textentry *find_ent, int add)
int width;
int height;
+#if GTK_CHECK_VERSION (2, 16, 0)
+ width = gdk_window_get_width (GTK_WIDGET (xtext)->window);
+ height = gdk_window_get_height (GTK_WIDGET (xtext)->window);
+#else
gdk_drawable_get_size (GTK_WIDGET (xtext)->window, &width, &height);
+#endif
lines_max = ((height + xtext->pixel_offset) / xtext->fontsize) + add;
ent = xtext->buffer->pagetop_ent;
@@ -5191,8 +5232,12 @@ gtk_xtext_buffer_show (GtkXText *xtext, xtext_buffer *buf, int render)
if (!gtk_widget_get_realized (GTK_WIDGET (xtext)))
gtk_widget_realize (GTK_WIDGET (xtext));
-
+#if GTK_CHECK_VERSION (2, 23, 0)
+ w = gdk_window_get_width (GTK_WIDGET (xtext)->window);
+ h = gdk_window_get_height (GTK_WIDGET (xtext)->window);
+#else
gdk_drawable_get_size (GTK_WIDGET (xtext)->window, &w, &h);
+#endif
/* after a font change */
if (buf->needs_recalc)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]