From: Christian Dywan Date: Mon, 18 Oct 2010 20:42:10 +0000 (+0200) Subject: Use accessors for window and allocation of a widget X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32988e55af4685acd5ddaf2f29d9f5f29adf4442;p=midori Use accessors for window and allocation of a widget --- diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 9a0b6cec..f8ae1c2f 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -3337,10 +3337,10 @@ _action_fullscreen_activate (GtkAction* action, { GdkWindowState state; - if (!GTK_WIDGET (browser)->window) + if (!gtk_widget_get_window (GTK_WIDGET (browser))) return; - state = gdk_window_get_state (GTK_WIDGET (browser)->window); + state = gdk_window_get_state (gtk_widget_get_window (GTK_WIDGET (browser))); if (state & GDK_WINDOW_STATE_FULLSCREEN) gtk_window_unfullscreen (GTK_WINDOW (browser)); else @@ -4610,7 +4610,11 @@ midori_panel_notify_right_aligned_cb (MidoriPanel* panel, GtkWidget* hpaned = gtk_widget_get_parent (browser->panel); GtkWidget* vpaned = gtk_widget_get_parent (browser->notebook); gint paned_position = gtk_paned_get_position (GTK_PANED (hpaned)); - gint paned_size = hpaned->allocation.width; + GtkAllocation allocation; + gint paned_size; + + gtk_widget_get_allocation (hpaned, &allocation); + paned_size = allocation.width; g_object_set (browser->settings, "right-align-sidepanel", right_aligned, NULL); @@ -5083,22 +5087,24 @@ static gboolean midori_browser_alloc_timeout (MidoriBrowser* browser) { GtkWidget* widget = GTK_WIDGET (browser); - GdkWindowState state = gdk_window_get_state (widget->window); + GdkWindowState state = gdk_window_get_state (gtk_widget_get_window (widget)); if (!(state & (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN))) { - if (widget->allocation.width != browser->last_window_width) + GtkAllocation allocation; + gtk_widget_get_allocation (widget, &allocation); + if (allocation.width != browser->last_window_width) { - browser->last_window_width = widget->allocation.width; + browser->last_window_width = allocation.width; g_object_set (browser->settings, "last-window-width", browser->last_window_width, NULL); } - if (widget->allocation.height != browser->last_window_height) + if (allocation.height != browser->last_window_height) { - browser->last_window_height = widget->allocation.height; + browser->last_window_height = allocation.height; g_object_set (browser->settings, - "last-window-height", widget->allocation.height, NULL); + "last-window-height", allocation.height, NULL); } } @@ -5276,7 +5282,7 @@ midori_browser_realize_cb (GtkStyle* style, #ifdef HAVE_HILDON_2_2 /* hildon_gtk_window_enable_zoom_keys */ guint32 set = 1; - gdk_property_change (GTK_WIDGET (browser)->window, + gdk_property_change (gtk_widget_get_window (GTK_WIDGET (browser)), gdk_atom_intern ("_HILDON_ZOOM_KEY_ATOM", FALSE), gdk_x11_xatom_to_atom (XA_INTEGER), 32, GDK_PROP_MODE_REPLACE, diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c index 1ceb772f..9785e196 100644 --- a/midori/midori-locationaction.c +++ b/midori/midori-locationaction.c @@ -276,19 +276,21 @@ static void midori_location_action_popup_position (GtkWidget* popup, GtkWidget* widget) { + GdkWindow* window = gtk_widget_get_window (widget); gint wx, wy; GtkRequisition menu_req; GtkRequisition widget_req; GdkScreen* screen; gint monitor_num; GdkRectangle monitor; + GtkAllocation allocation; - gdk_window_get_origin (widget->window, &wx, &wy); + gdk_window_get_origin (window, &wx, &wy); gtk_widget_size_request (popup, &menu_req); gtk_widget_size_request (widget, &widget_req); screen = gtk_widget_get_screen (widget); - monitor_num = gdk_screen_get_monitor_at_window (screen, widget->window); + monitor_num = gdk_screen_get_monitor_at_window (screen, window); gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); if (wy + widget_req.height + menu_req.height <= monitor.y + monitor.height @@ -297,7 +299,8 @@ midori_location_action_popup_position (GtkWidget* popup, else wy -= menu_req.height; gtk_window_move (GTK_WINDOW (popup), wx, wy); - gtk_window_resize (GTK_WINDOW (popup), widget->allocation.width, 1); + gtk_widget_get_allocation (widget, &allocation); + gtk_window_resize (GTK_WINDOW (popup), allocation.width, 1); } static gboolean diff --git a/midori/midori-view.c b/midori/midori-view.c index a72e57b8..bb04d90e 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -1585,12 +1585,12 @@ midori_view_ensure_link_uri (MidoriView* view, g_return_if_fail (MIDORI_IS_VIEW (view)); #if WEBKIT_CHECK_VERSION (1, 1, 15) - if (view->web_view && view->web_view->window) + if (view->web_view && gtk_widget_get_window (view->web_view)) { gint ex, ey; GdkEventButton event; - gdk_window_get_pointer (view->web_view->window, &ex, &ey, NULL); + gdk_window_get_pointer (gtk_widget_get_window (view->web_view), &ex, &ey, NULL); if (x != NULL) *x = ex; if (y != NULL) @@ -2635,15 +2635,14 @@ midori_view_web_view_tap_and_hold_cb (GtkWidget* web_view, /* Emulate a pointer motion above the tap position and a right click at the according position. */ - gdk_window_get_pointer (web_view->window, &x, &y, NULL); + event.any.window = gtk_widget_get_window (web_view); + gdk_window_get_pointer (event.any.window, &x, &y, NULL); event.any.type = GDK_MOTION_NOTIFY; - event.any.window = web_view->window; event.motion.x = x; event.motion.y = y; g_signal_emit_by_name (web_view, "motion-notify-event", &event, &result); event.any.type = GDK_BUTTON_PRESS; - event.any.window = web_view->window; event.button.axes = NULL; event.button.x = x; event.button.y = y; @@ -5090,6 +5089,8 @@ midori_view_get_snapshot (MidoriView* view, gint height) { GtkWidget* web_view; + GdkWindow* window; + GtkAllocation allocation; gboolean fast; gint x, y, w, h; GdkRectangle rect; @@ -5101,12 +5102,14 @@ midori_view_get_snapshot (MidoriView* view, g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL); web_view = view->web_view; - g_return_val_if_fail (web_view->window, NULL); + window = gtk_widget_get_window (web_view); + g_return_val_if_fail (window != NULL, NULL); - x = web_view->allocation.x; - y = web_view->allocation.y; - w = web_view->allocation.width; - h = web_view->allocation.height; + gtk_widget_get_allocation (web_view, &allocation); + x = allocation.x; + y = allocation.y; + w = allocation.width; + h = allocation.height; /* If width and height are both negative, we try to render faster at the cost of correctness or beauty. Only a part of the page is @@ -5126,15 +5129,14 @@ midori_view_get_snapshot (MidoriView* view, rect.width = w; rect.height = h; - pixmap = gdk_pixmap_new (web_view->window, w, h, - gdk_drawable_get_depth (web_view->window)); + pixmap = gdk_pixmap_new (window, w, h, gdk_drawable_get_depth (window)); event.expose.type = GDK_EXPOSE; event.expose.window = pixmap; event.expose.send_event = FALSE; event.expose.count = 0; event.expose.area.x = 0; event.expose.area.y = 0; - gdk_drawable_get_size (GDK_DRAWABLE (web_view->window), + gdk_drawable_get_size (GDK_DRAWABLE (window), &event.expose.area.width, &event.expose.area.height); event.expose.region = gdk_region_rectangle (&event.expose.area); diff --git a/midori/sokoke.h b/midori/sokoke.h index fa319601..5515486d 100644 --- a/midori/sokoke.h +++ b/midori/sokoke.h @@ -54,6 +54,7 @@ #define gtk_widget_get_sensitive(widget) GTK_WIDGET_IS_SENSITIVE (widget) #define gtk_widget_set_can_focus(widget,flag) \ GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS) + #define gtk_widget_get_allocation(wdgt, alloc) *alloc = wdgt->allocation #endif #if !GTK_CHECK_VERSION (2, 20, 0)