From 6f9fe3b417a3870ce48288f1273843af05d39624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Fri, 13 Nov 2009 06:29:35 +0100 Subject: Use accessor functions instead direct access. Some functions still remaining because there is not API in GTK+ 2.19.0 yet. http://bugzilla.gnome.org/show_bug.cgi?id=586476 Reviewed-By: Danielle Madeley --- libempathy-gtk/empathy-avatar-image.c | 6 ++++-- libempathy-gtk/empathy-cell-renderer-expander.c | 4 +++- libempathy-gtk/empathy-chat.c | 10 ++++++---- libempathy-gtk/empathy-contact-dialogs.c | 6 +++--- libempathy-gtk/empathy-contact-menu.c | 2 +- libempathy-gtk/empathy-kludge-label.c | 9 ++++++--- libempathy-gtk/empathy-presence-chooser.c | 6 +++--- libempathy-gtk/empathy-status-preset-dialog.c | 2 +- libempathy-gtk/empathy-ui-utils.c | 4 ++-- libempathy-gtk/empathy-video-widget.c | 6 ++++-- src/empathy-call-window.c | 21 ++++++++++++++------- src/empathy-chat-window.c | 4 ++-- src/empathy-chatrooms-window.c | 2 +- src/empathy-sidebar.c | 12 ++++++++---- src/ephy-spinner.c | 18 ++++++++++-------- 15 files changed, 68 insertions(+), 44 deletions(-) diff --git a/libempathy-gtk/empathy-avatar-image.c b/libempathy-gtk/empathy-avatar-image.c index 03f638336..ef4185ae9 100644 --- a/libempathy-gtk/empathy-avatar-image.c +++ b/libempathy-gtk/empathy-avatar-image.c @@ -190,6 +190,7 @@ avatar_image_button_press_event (GtkWidget *widget, GdkEventButton *event) gint popup_width, popup_height; gint width, height; GdkPixbuf *pixbuf; + GtkAllocation allocation; priv = GET_PRIV (widget); @@ -205,8 +206,9 @@ avatar_image_button_press_event (GtkWidget *widget, GdkEventButton *event) popup_width = gdk_pixbuf_get_width (priv->pixbuf); popup_height = gdk_pixbuf_get_height (priv->pixbuf); - width = priv->image->allocation.width; - height = priv->image->allocation.height; + gtk_widget_get_allocation (priv->image, &allocation); + width = allocation.width; + height = allocation.height; /* Don't show a popup if the popup is smaller then the currently avatar * image. diff --git a/libempathy-gtk/empathy-cell-renderer-expander.c b/libempathy-gtk/empathy-cell-renderer-expander.c index 481bb8a49..fb360431f 100644 --- a/libempathy-gtk/empathy-cell-renderer-expander.c +++ b/libempathy-gtk/empathy-cell-renderer-expander.c @@ -354,13 +354,15 @@ invalidate_node (GtkTreeView *tree_view, { GdkWindow *bin_window; GdkRectangle rect; + GtkAllocation allocation; bin_window = gtk_tree_view_get_bin_window (tree_view); gtk_tree_view_get_background_area (tree_view, path, NULL, &rect); rect.x = 0; - rect.width = GTK_WIDGET (tree_view)->allocation.width; + gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation); + rect.width = allocation.width; gdk_window_invalidate_rect (bin_window, &rect, TRUE); } diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 67c8426cb..07bd35711 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -1822,6 +1822,7 @@ chat_update_contacts_visibility (EmpathyChat *chat) { EmpathyChatPriv *priv = GET_PRIV (chat); gboolean show; + GtkAllocation allocation; show = priv->remote_contact == NULL && priv->show_contacts; @@ -1839,7 +1840,8 @@ chat_update_contacts_visibility (EmpathyChat *chat) * chat view is bigger the contact list will take some space on * it but we make sure the chat view don't become smaller than * 250. Relax the size request once the resize is done */ - min_width = MIN (priv->vbox_left->allocation.width, 250); + gtk_widget_get_allocation (priv->vbox_left, &allocation); + min_width = MIN (allocation.width, 250); gtk_widget_set_size_request (priv->vbox_left, min_width, -1); g_idle_add (chat_reset_size_request, priv->vbox_left); @@ -2053,7 +2055,7 @@ chat_size_request (GtkWidget *widget, child = gtk_bin_get_child (bin); - if (child && GTK_WIDGET_VISIBLE (child)) + if (child && gtk_widget_get_visible (child)) { GtkRequisition child_requisition; @@ -2072,11 +2074,11 @@ chat_size_allocate (GtkWidget *widget, GtkAllocation child_allocation; GtkWidget *child; - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); child = gtk_bin_get_child (bin); - if (child && GTK_WIDGET_VISIBLE (child)) + if (child && gtk_widget_get_visible (child)) { child_allocation.x = allocation->x + gtk_container_get_border_width (GTK_CONTAINER (widget)); child_allocation.y = allocation->y + gtk_container_get_border_width (GTK_CONTAINER (widget)); diff --git a/libempathy-gtk/empathy-contact-dialogs.c b/libempathy-gtk/empathy-contact-dialogs.c index b7108d8f3..c00558402 100644 --- a/libempathy-gtk/empathy-contact-dialogs.c +++ b/libempathy-gtk/empathy-contact-dialogs.c @@ -184,7 +184,7 @@ empathy_contact_information_dialog_show (EmpathyContact *contact, gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_CLOSE); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default (button, TRUE); gtk_window_set_default (GTK_WINDOW (dialog), button); gtk_widget_show (button); @@ -243,7 +243,7 @@ empathy_contact_edit_dialog_show (EmpathyContact *contact, gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_CLOSE); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default (button, TRUE); gtk_window_set_default (GTK_WINDOW (dialog), button); gtk_widget_show (button); @@ -294,7 +294,7 @@ empathy_contact_personal_dialog_show (GtkWindow *parent) gtk_dialog_add_action_widget (GTK_DIALOG (personal_dialog), button, GTK_RESPONSE_CLOSE); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default (button, TRUE); gtk_window_set_default (GTK_WINDOW (personal_dialog), button); gtk_widget_show (button); diff --git a/libempathy-gtk/empathy-contact-menu.c b/libempathy-gtk/empathy-contact-menu.c index d261d5554..4e1adfa90 100644 --- a/libempathy-gtk/empathy-contact-menu.c +++ b/libempathy-gtk/empathy-contact-menu.c @@ -140,7 +140,7 @@ empathy_contact_add_menu_item_activated (GtkMenuItem *item, GtkWidget *toplevel; toplevel = gtk_widget_get_toplevel (GTK_WIDGET (item)); - if (!GTK_WIDGET_TOPLEVEL (toplevel) || !GTK_IS_WINDOW (toplevel)) { + if (!gtk_widget_is_toplevel (toplevel) || !GTK_IS_WINDOW (toplevel)) { toplevel = NULL; } diff --git a/libempathy-gtk/empathy-kludge-label.c b/libempathy-gtk/empathy-kludge-label.c index f4a29dec2..7ed4be62f 100644 --- a/libempathy-gtk/empathy-kludge-label.c +++ b/libempathy-gtk/empathy-kludge-label.c @@ -44,6 +44,7 @@ empathy_kludge_label_expose_event (GtkWidget *self, PangoLayout *layout; PangoRectangle rect; GtkAllocation real_allocation; + GtkAllocation allocation; gboolean r; layout = gtk_label_get_layout (GTK_LABEL (self)); @@ -54,13 +55,15 @@ empathy_kludge_label_expose_event (GtkWidget *self, * layout when painting it. This really sucks. We're going to compensate by * adding this value to the allocation. */ - real_allocation = self->allocation; - self->allocation.x += rect.x; + gtk_widget_get_allocation (self, &allocation); + real_allocation = allocation; + allocation.x += rect.x; + gtk_widget_set_allocation (self, &allocation); r = GTK_WIDGET_CLASS (empathy_kludge_label_parent_class)->expose_event ( self, event); - self->allocation = real_allocation; + gtk_widget_set_allocation (self, &real_allocation); return r; } diff --git a/libempathy-gtk/empathy-presence-chooser.c b/libempathy-gtk/empathy-presence-chooser.c index 33e533273..08c328681 100644 --- a/libempathy-gtk/empathy-presence-chooser.c +++ b/libempathy-gtk/empathy-presence-chooser.c @@ -385,7 +385,7 @@ presence_chooser_set_status_editing (EmpathyPresenceChooser *self, /* attempt to get the toplevel for this widget */ window = gtk_widget_get_toplevel (GTK_WIDGET (self)); - if (GTK_WIDGET_TOPLEVEL (window) && GTK_IS_WINDOW (window)) { + if (gtk_widget_is_toplevel (window) && GTK_IS_WINDOW (window)) { /* unset the focus */ gtk_window_set_focus (GTK_WINDOW (window), NULL); } @@ -530,7 +530,7 @@ presence_chooser_entry_button_press_event_cb (EmpathyPresenceChooser *self, if (!priv->editing_status && event->button == 1 && - !GTK_WIDGET_HAS_FOCUS (entry)) { + !gtk_widget_has_focus (entry)) { gtk_widget_grab_focus (entry); gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1); @@ -598,7 +598,7 @@ presence_chooser_changed_cb (GtkComboBox *self, gpointer user_data) /* attempt to get the toplevel for this widget */ window = gtk_widget_get_toplevel (GTK_WIDGET (self)); - if (!GTK_WIDGET_TOPLEVEL (window) || !GTK_IS_WINDOW (window)) { + if (!gtk_widget_is_toplevel (window) || !GTK_IS_WINDOW (window)) { window = NULL; } diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index 0337d16a3..4a4893b57 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -477,7 +477,7 @@ status_preset_dialog_add_combo_press_event (GtkWidget *widget, GdkEventButton *event, EmpathyStatusPresetDialog *self) { - if (!GTK_WIDGET_HAS_FOCUS (widget)) { + if (!gtk_widget_has_focus (widget)) { /* if the widget isn't focused, focus it and select the text */ gtk_widget_grab_focus (widget); gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1); diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c index 4bbc3b81c..523b89351 100644 --- a/libempathy-gtk/empathy-ui-utils.c +++ b/libempathy-gtk/empathy-ui-utils.c @@ -1322,7 +1322,7 @@ empathy_get_toplevel_window (GtkWidget *widget) toplevel = gtk_widget_get_toplevel (widget); if (GTK_IS_WINDOW (toplevel) && - GTK_WIDGET_TOPLEVEL (toplevel)) { + gtk_widget_is_toplevel (toplevel)) { return GTK_WINDOW (toplevel); } @@ -1496,7 +1496,7 @@ empathy_send_file_with_file_chooser (EmpathyContact *contact) gtk_widget_show (button); gtk_dialog_add_action_widget (GTK_DIALOG (widget), button, GTK_RESPONSE_OK); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); + gtk_widget_set_can_default (button, TRUE); gtk_dialog_set_default_response (GTK_DIALOG (widget), GTK_RESPONSE_OK); diff --git a/libempathy-gtk/empathy-video-widget.c b/libempathy-gtk/empathy-video-widget.c index 915aa33da..902e5cd7f 100644 --- a/libempathy-gtk/empathy-video-widget.c +++ b/libempathy-gtk/empathy-video-widget.c @@ -96,7 +96,7 @@ empathy_video_widget_init (EmpathyVideoWidget *obj) gtk_widget_modify_bg (GTK_WIDGET (obj), GTK_STATE_NORMAL, &black); - GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (obj), GTK_DOUBLE_BUFFERED); + gtk_widget_set_double_buffered (GTK_WIDGET (obj), FALSE); } static void @@ -425,14 +425,16 @@ empathy_video_widget_expose_event (GtkWidget *widget, GdkEventExpose *event) { EmpathyVideoWidget *self = EMPATHY_VIDEO_WIDGET (widget); EmpathyVideoWidgetPriv *priv = GET_PRIV (self); + GtkAllocation allocation; if (event != NULL && event->count > 0) return TRUE; if (priv->overlay == NULL) { + gtk_widget_get_allocation (widget, &allocation); gdk_window_clear_area (gtk_widget_get_window (widget), 0, 0, - widget->allocation.width, widget->allocation.height); + allocation.width, allocation.height); return TRUE; } diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c index 07cad91f6..e1f8cd268 100644 --- a/src/empathy-call-window.c +++ b/src/empathy-call-window.c @@ -2086,8 +2086,12 @@ empathy_call_window_state_event_cb (GtkWidget *widget, if (set_fullscreen) { gboolean sidebar_was_visible; - gint original_width = GTK_WIDGET (window)->allocation.width; - gint original_height = GTK_WIDGET (window)->allocation.height; + GtkAllocation allocation; + gint original_width, original_height; + + gtk_widget_get_allocation (GTK_WIDGET (window), &allocation); + original_width = allocation.width; + original_height = allocation.height; g_object_get (priv->sidebar, "visible", &sidebar_was_visible, NULL); @@ -2132,23 +2136,26 @@ empathy_call_window_sidebar_toggled_cb (GtkToggleButton *toggle, { EmpathyCallWindowPriv *priv = GET_PRIV (window); GtkWidget *arrow; - int w,h, handle_size; + int w, h, handle_size; + GtkAllocation allocation, sidebar_allocation; - w = GTK_WIDGET (window)->allocation.width; - h = GTK_WIDGET (window)->allocation.height; + gtk_widget_get_allocation (GTK_WIDGET (window), &allocation); + w = allocation.width; + h = allocation.height; gtk_widget_style_get (priv->pane, "handle_size", &handle_size, NULL); + gtk_widget_get_allocation (priv->sidebar, &sidebar_allocation); if (gtk_toggle_button_get_active (toggle)) { arrow = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_NONE); gtk_widget_show (priv->sidebar); - w += priv->sidebar->allocation.width + handle_size; + w += sidebar_allocation.width + handle_size; } else { arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE); - w -= priv->sidebar->allocation.width + handle_size; + w -= sidebar_allocation.width + handle_size; gtk_widget_hide (priv->sidebar); } diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index ca3375306..278c8f044 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -268,8 +268,8 @@ chat_window_create_label (EmpathyChatWindow *window, /* We don't want focus/keynav for the button to avoid clutter, and * Ctrl-W works anyway. */ - GTK_WIDGET_UNSET_FLAGS (close_button, GTK_CAN_FOCUS); - GTK_WIDGET_UNSET_FLAGS (close_button, GTK_CAN_DEFAULT); + gtk_widget_set_can_focus (close_button, FALSE); + gtk_widget_set_can_default (close_button, FALSE); /* Set the name to make the special rc style match. */ gtk_widget_set_name (close_button, "empathy-close-button"); diff --git a/src/empathy-chatrooms-window.c b/src/empathy-chatrooms-window.c index 278a1d686..6f2c8c24c 100644 --- a/src/empathy-chatrooms-window.c +++ b/src/empathy-chatrooms-window.c @@ -450,7 +450,7 @@ chatrooms_window_row_activated_cb (GtkTreeView *tree_view, GtkTreeViewColumn *column, EmpathyChatroomsWindow *window) { - if (GTK_WIDGET_IS_SENSITIVE (window->button_edit)) { + if (gtk_widget_is_sensitive (window->button_edit)) { chatrooms_window_model_action_selected (window); } } diff --git a/src/empathy-sidebar.c b/src/empathy-sidebar.c index 11fcbd6bb..7960c4ad9 100644 --- a/src/empathy-sidebar.c +++ b/src/empathy-sidebar.c @@ -238,16 +238,18 @@ empathy_sidebar_menu_position_under (GtkMenu *menu, gpointer user_data) { GtkWidget *widget; + GtkAllocation allocation; g_return_if_fail (GTK_IS_BUTTON (user_data)); - g_return_if_fail (GTK_WIDGET_NO_WINDOW (user_data)); + g_return_if_fail (gtk_widget_get_has_window (user_data)); widget = GTK_WIDGET (user_data); gdk_window_get_origin (gtk_widget_get_window (widget), x, y); - *x += widget->allocation.x; - *y += widget->allocation.y + widget->allocation.height; + gtk_widget_get_allocation (widget, &allocation); + *x += allocation.x; + *y += allocation.y + allocation.height; *push_in = FALSE; } @@ -263,8 +265,10 @@ empathy_sidebar_select_button_press_cb (GtkWidget *widget, { GtkRequisition requisition; gint width; + GtkAllocation allocation; - width = widget->allocation.width; + gtk_widget_get_allocation (widget, &allocation); + width = allocation.width; gtk_widget_set_size_request (sidebar->priv->menu, -1, -1); gtk_widget_size_request (sidebar->priv->menu, &requisition); diff --git a/src/ephy-spinner.c b/src/ephy-spinner.c index d2d50453c..7efacb18a 100644 --- a/src/ephy-spinner.c +++ b/src/ephy-spinner.c @@ -601,7 +601,7 @@ ephy_spinner_init (EphySpinner *spinner) details = spinner->details = EPHY_SPINNER_GET_PRIVATE (spinner); - GTK_WIDGET_SET_FLAGS (GTK_WIDGET (spinner), GTK_NO_WINDOW); + gtk_widget_set_has_window (GTK_WIDGET (spinner), FALSE); details->cache = ephy_spinner_cache_ref (); details->size = GTK_ICON_SIZE_DIALOG; @@ -621,8 +621,9 @@ ephy_spinner_expose (GtkWidget *widget, GdkGC *gc; int x_offset, y_offset, width, height; GdkRectangle pix_area, dest; + GtkAllocation allocation; - if (!GTK_WIDGET_DRAWABLE (spinner)) + if (!gtk_widget_is_drawable (GTK_WIDGET (spinner))) { return FALSE; } @@ -652,11 +653,12 @@ ephy_spinner_expose (GtkWidget *widget, height = gdk_pixbuf_get_height (pixbuf); /* Compute the offsets for the image centered on our allocation */ - x_offset = (widget->allocation.width - width) / 2; - y_offset = (widget->allocation.height - height) / 2; + gtk_widget_get_allocation (widget, &allocation); + x_offset = (allocation.width - width) / 2; + y_offset = (allocation.height - height) / 2; - pix_area.x = x_offset + widget->allocation.x; - pix_area.y = y_offset + widget->allocation.y; + pix_area.x = x_offset + allocation.x; + pix_area.y = y_offset + allocation.y; pix_area.width = width; pix_area.height = height; @@ -667,8 +669,8 @@ ephy_spinner_expose (GtkWidget *widget, gc = gdk_gc_new (gtk_widget_get_window (widget)); gdk_draw_pixbuf (gtk_widget_get_window (widget), gc, pixbuf, - dest.x - x_offset - widget->allocation.x, - dest.y - y_offset - widget->allocation.y, + dest.x - x_offset - allocation.x, + dest.y - y_offset - allocation.y, dest.x, dest.y, dest.width, dest.height, GDK_RGB_DITHER_MAX, 0, 0); -- cgit v1.2.3