Use accessors for window and allocation of a widget

This commit is contained in:
Christian Dywan 2010-10-18 22:42:10 +02:00
parent f079d9c48a
commit 32988e55af
4 changed files with 38 additions and 26 deletions

View file

@ -3337,10 +3337,10 @@ _action_fullscreen_activate (GtkAction* action,
{ {
GdkWindowState state; GdkWindowState state;
if (!GTK_WIDGET (browser)->window) if (!gtk_widget_get_window (GTK_WIDGET (browser)))
return; 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) if (state & GDK_WINDOW_STATE_FULLSCREEN)
gtk_window_unfullscreen (GTK_WINDOW (browser)); gtk_window_unfullscreen (GTK_WINDOW (browser));
else else
@ -4610,7 +4610,11 @@ midori_panel_notify_right_aligned_cb (MidoriPanel* panel,
GtkWidget* hpaned = gtk_widget_get_parent (browser->panel); GtkWidget* hpaned = gtk_widget_get_parent (browser->panel);
GtkWidget* vpaned = gtk_widget_get_parent (browser->notebook); GtkWidget* vpaned = gtk_widget_get_parent (browser->notebook);
gint paned_position = gtk_paned_get_position (GTK_PANED (hpaned)); 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); g_object_set (browser->settings, "right-align-sidepanel", right_aligned, NULL);
@ -5083,22 +5087,24 @@ static gboolean
midori_browser_alloc_timeout (MidoriBrowser* browser) midori_browser_alloc_timeout (MidoriBrowser* browser)
{ {
GtkWidget* widget = GTK_WIDGET (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 & if (!(state &
(GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN))) (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, g_object_set (browser->settings,
"last-window-width", browser->last_window_width, NULL); "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, 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 #ifdef HAVE_HILDON_2_2
/* hildon_gtk_window_enable_zoom_keys */ /* hildon_gtk_window_enable_zoom_keys */
guint32 set = 1; 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_atom_intern ("_HILDON_ZOOM_KEY_ATOM", FALSE),
gdk_x11_xatom_to_atom (XA_INTEGER), gdk_x11_xatom_to_atom (XA_INTEGER),
32, GDK_PROP_MODE_REPLACE, 32, GDK_PROP_MODE_REPLACE,

View file

@ -276,19 +276,21 @@ static void
midori_location_action_popup_position (GtkWidget* popup, midori_location_action_popup_position (GtkWidget* popup,
GtkWidget* widget) GtkWidget* widget)
{ {
GdkWindow* window = gtk_widget_get_window (widget);
gint wx, wy; gint wx, wy;
GtkRequisition menu_req; GtkRequisition menu_req;
GtkRequisition widget_req; GtkRequisition widget_req;
GdkScreen* screen; GdkScreen* screen;
gint monitor_num; gint monitor_num;
GdkRectangle monitor; 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 (popup, &menu_req);
gtk_widget_size_request (widget, &widget_req); gtk_widget_size_request (widget, &widget_req);
screen = gtk_widget_get_screen (widget); 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); gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
if (wy + widget_req.height + menu_req.height <= monitor.y + monitor.height if (wy + widget_req.height + menu_req.height <= monitor.y + monitor.height
@ -297,7 +299,8 @@ midori_location_action_popup_position (GtkWidget* popup,
else else
wy -= menu_req.height; wy -= menu_req.height;
gtk_window_move (GTK_WINDOW (popup), wx, wy); 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 static gboolean

View file

@ -1585,12 +1585,12 @@ midori_view_ensure_link_uri (MidoriView* view,
g_return_if_fail (MIDORI_IS_VIEW (view)); g_return_if_fail (MIDORI_IS_VIEW (view));
#if WEBKIT_CHECK_VERSION (1, 1, 15) #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; gint ex, ey;
GdkEventButton event; 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) if (x != NULL)
*x = ex; *x = ex;
if (y != NULL) 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 /* Emulate a pointer motion above the tap position
and a right click at the according 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.type = GDK_MOTION_NOTIFY;
event.any.window = web_view->window;
event.motion.x = x; event.motion.x = x;
event.motion.y = y; event.motion.y = y;
g_signal_emit_by_name (web_view, "motion-notify-event", &event, &result); g_signal_emit_by_name (web_view, "motion-notify-event", &event, &result);
event.any.type = GDK_BUTTON_PRESS; event.any.type = GDK_BUTTON_PRESS;
event.any.window = web_view->window;
event.button.axes = NULL; event.button.axes = NULL;
event.button.x = x; event.button.x = x;
event.button.y = y; event.button.y = y;
@ -5090,6 +5089,8 @@ midori_view_get_snapshot (MidoriView* view,
gint height) gint height)
{ {
GtkWidget* web_view; GtkWidget* web_view;
GdkWindow* window;
GtkAllocation allocation;
gboolean fast; gboolean fast;
gint x, y, w, h; gint x, y, w, h;
GdkRectangle rect; GdkRectangle rect;
@ -5101,12 +5102,14 @@ midori_view_get_snapshot (MidoriView* view,
g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL); g_return_val_if_fail (MIDORI_IS_VIEW (view), NULL);
web_view = view->web_view; 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; gtk_widget_get_allocation (web_view, &allocation);
y = web_view->allocation.y; x = allocation.x;
w = web_view->allocation.width; y = allocation.y;
h = web_view->allocation.height; w = allocation.width;
h = allocation.height;
/* If width and height are both negative, we try to render faster at /* 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 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.width = w;
rect.height = h; rect.height = h;
pixmap = gdk_pixmap_new (web_view->window, w, h, pixmap = gdk_pixmap_new (window, w, h, gdk_drawable_get_depth (window));
gdk_drawable_get_depth (web_view->window));
event.expose.type = GDK_EXPOSE; event.expose.type = GDK_EXPOSE;
event.expose.window = pixmap; event.expose.window = pixmap;
event.expose.send_event = FALSE; event.expose.send_event = FALSE;
event.expose.count = 0; event.expose.count = 0;
event.expose.area.x = 0; event.expose.area.x = 0;
event.expose.area.y = 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.area.width, &event.expose.area.height);
event.expose.region = gdk_region_rectangle (&event.expose.area); event.expose.region = gdk_region_rectangle (&event.expose.area);

View file

@ -54,6 +54,7 @@
#define gtk_widget_get_sensitive(widget) GTK_WIDGET_IS_SENSITIVE (widget) #define gtk_widget_get_sensitive(widget) GTK_WIDGET_IS_SENSITIVE (widget)
#define gtk_widget_set_can_focus(widget,flag) \ #define gtk_widget_set_can_focus(widget,flag) \
GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS) GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS)
#define gtk_widget_get_allocation(wdgt, alloc) *alloc = wdgt->allocation
#endif #endif
#if !GTK_CHECK_VERSION (2, 20, 0) #if !GTK_CHECK_VERSION (2, 20, 0)