[gnome-panel] [bonobo] More GSeal work
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] [bonobo] More GSeal work
- Date: Thu, 1 Jul 2010 18:16:41 +0000 (UTC)
commit aff48c71e427d074b74fba0b2323dcbf88c20859
Author: Vincent Untz <vuntz gnome org>
Date: Thu Jul 1 20:15:05 2010 +0200
[bonobo] More GSeal work
bonobo/libpanel-applet/panel-applet.c | 89 +++++++++++++++-----------
bonobo/libpanel-applet/test-bonobo-applet.c | 8 ++-
2 files changed, 56 insertions(+), 41 deletions(-)
---
diff --git a/bonobo/libpanel-applet/panel-applet.c b/bonobo/libpanel-applet/panel-applet.c
index f876cb7..7f8c7b7 100644
--- a/bonobo/libpanel-applet/panel-applet.c
+++ b/bonobo/libpanel-applet/panel-applet.c
@@ -399,7 +399,7 @@ panel_applet_find_toplevel_dock_window (PanelApplet *applet,
if (!gtk_widget_get_realized (toplevel))
return None;
- xwin = GDK_WINDOW_XID (toplevel->window);
+ xwin = GDK_WINDOW_XID (gtk_widget_get_window (toplevel));
child = NULL;
parent = root = None;
@@ -626,6 +626,7 @@ panel_applet_position_menu (GtkMenu *menu,
GtkWidget *widget)
{
PanelApplet *applet;
+ GtkAllocation allocation;
GtkRequisition requisition;
GdkScreen *screen;
int menu_x = 0;
@@ -641,25 +642,28 @@ panel_applet_position_menu (GtkMenu *menu,
gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
- gdk_window_get_origin (widget->window, &menu_x, &menu_y);
+ gdk_window_get_origin (gtk_widget_get_window (widget),
+ &menu_x, &menu_y);
gtk_widget_get_pointer (widget, &pointer_x, &pointer_y);
- menu_x += widget->allocation.x;
- menu_y += widget->allocation.y;
+ gtk_widget_get_allocation (widget, &allocation);
+
+ menu_x += allocation.x;
+ menu_y += allocation.y;
if (applet->priv->orient == PANEL_APPLET_ORIENT_UP ||
applet->priv->orient == PANEL_APPLET_ORIENT_DOWN) {
if (gtk_widget_get_direction (GTK_WIDGET (menu)) != GTK_TEXT_DIR_RTL) {
- if (pointer_x < widget->allocation.width &&
+ if (pointer_x < allocation.width &&
requisition.width < pointer_x)
menu_x += MIN (pointer_x,
- widget->allocation.width - requisition.width);
+ allocation.width - requisition.width);
} else {
- menu_x += widget->allocation.width - requisition.width;
- if (pointer_x > 0 && pointer_x < widget->allocation.width &&
- pointer_x < widget->allocation.width - requisition.width) {
- menu_x -= MIN (widget->allocation.width - pointer_x,
- widget->allocation.width - requisition.width);
+ menu_x += allocation.width - requisition.width;
+ if (pointer_x > 0 && pointer_x < allocation.width &&
+ pointer_x < allocation.width - requisition.width) {
+ menu_x -= MIN (allocation.width - pointer_x,
+ allocation.width - requisition.width);
}
}
menu_x = MIN (menu_x, gdk_screen_get_width (screen) - requisition.width);
@@ -667,17 +671,17 @@ panel_applet_position_menu (GtkMenu *menu,
if (menu_y > gdk_screen_get_height (screen) / 2)
menu_y -= requisition.height;
else
- menu_y += widget->allocation.height;
+ menu_y += allocation.height;
} else {
- if (pointer_y < widget->allocation.height &&
+ if (pointer_y < allocation.height &&
requisition.height < pointer_y)
- menu_y += MIN (pointer_y, widget->allocation.height - requisition.height);
+ menu_y += MIN (pointer_y, allocation.height - requisition.height);
menu_y = MIN (menu_y, gdk_screen_get_height (screen) - requisition.height);
if (menu_x > gdk_screen_get_width (screen) / 2)
menu_x -= requisition.width;
else
- menu_x += widget->allocation.width;
+ menu_x += allocation.width;
}
@@ -710,7 +714,7 @@ panel_applet_button_press (GtkWidget *widget,
if (!container_has_focusable_child (GTK_CONTAINER (applet))) {
if (!gtk_widget_has_focus (widget)) {
- GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
+ gtk_widget_set_can_focus (widget, TRUE);
gtk_widget_grab_focus (widget);
}
}
@@ -777,6 +781,7 @@ panel_applet_size_allocate (GtkWidget *widget,
{
GtkAllocation child_allocation;
GtkBin *bin;
+ GtkWidget *child;
int border_width;
int focus_width = 0;
PanelApplet *applet;
@@ -792,9 +797,9 @@ panel_applet_size_allocate (GtkWidget *widget,
"focus-line-width", &focus_width,
NULL);
- border_width = GTK_CONTAINER (widget)->border_width;
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
bin = GTK_BIN (widget);
child_allocation.x = focus_width;
@@ -804,17 +809,18 @@ panel_applet_size_allocate (GtkWidget *widget,
child_allocation.height = MAX (allocation->height - border_width * 2, 0);
if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (widget->window,
- allocation->x + GTK_CONTAINER (widget)->border_width,
- allocation->y + GTK_CONTAINER (widget)->border_width,
+ gdk_window_move_resize (gtk_widget_get_window (widget),
+ allocation->x + border_width,
+ allocation->y + border_width,
child_allocation.width,
child_allocation.height);
child_allocation.width = MAX (child_allocation.width - 2 * focus_width, 0);
child_allocation.height = MAX (child_allocation.height - 2 * focus_width, 0);
- if (bin->child)
- gtk_widget_size_allocate (bin->child, &child_allocation);
+ child = gtk_bin_get_child (bin);
+ if (child)
+ gtk_widget_size_allocate (child, &child_allocation);
}
applet = PANEL_APPLET (widget);
@@ -832,6 +838,7 @@ static gboolean
panel_applet_expose (GtkWidget *widget,
GdkEventExpose *event)
{
+ GtkAllocation allocation;
int border_width;
int focus_width = 0;
int x, y, width, height;
@@ -845,6 +852,8 @@ panel_applet_expose (GtkWidget *widget,
if (!gtk_widget_has_focus (widget))
return FALSE;
+ gtk_widget_get_allocation (widget, &allocation);
+
/*
* We are deliberately ignoring focus-padding here to
* save valuable panel real estate.
@@ -853,15 +862,16 @@ panel_applet_expose (GtkWidget *widget,
"focus-line-width", &focus_width,
NULL);
- border_width = GTK_CONTAINER (widget)->border_width;
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- x = widget->allocation.x;
- y = widget->allocation.y;
+ x = allocation.x;
+ y = allocation.y;
- width = widget->allocation.width - 2 * border_width;
- height = widget->allocation.height - 2 * border_width;
+ width = allocation.width - 2 * border_width;
+ height = allocation.height - 2 * border_width;
- gtk_paint_focus (widget->style, widget->window,
+ gtk_paint_focus (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
gtk_widget_get_state (widget),
&event->area, widget, "panel_applet",
x, y, width, height);
@@ -889,12 +899,12 @@ panel_applet_focus (GtkWidget *widget,
return FALSE;
}
- previous_focus_child = GTK_CONTAINER (widget)->focus_child;
+ previous_focus_child = gtk_container_get_focus_child (GTK_CONTAINER (widget));
if (!previous_focus_child && !gtk_widget_has_focus (widget)) {
if (gtk_widget_get_has_tooltip (widget)) {
- GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
+ gtk_widget_set_can_focus (widget, TRUE);
gtk_widget_grab_focus (widget);
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
+ gtk_widget_set_can_focus (widget, FALSE);
return TRUE;
}
}
@@ -907,9 +917,9 @@ panel_applet_focus (GtkWidget *widget,
* the focus on the applet unless it already had focus
* because it had a tooltip.
*/
- GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
+ gtk_widget_set_can_focus (widget, TRUE);
gtk_widget_grab_focus (widget);
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_CAN_FOCUS);
+ gtk_widget_set_can_focus (widget, FALSE);
ret = TRUE;
}
}
@@ -989,6 +999,7 @@ panel_applet_get_pixmap (PanelApplet *applet,
GdkPixmap *pixmap;
GdkDisplay *display;
GdkPixmap *retval;
+ GdkWindow *window;
int width;
int height;
cairo_t *cr;
@@ -1002,6 +1013,8 @@ panel_applet_get_pixmap (PanelApplet *applet,
display = gdk_display_get_default ();
display_grabbed = FALSE;
+ window = gtk_widget_get_window (GTK_WIDGET (applet));
+
pixmap = gdk_pixmap_lookup_for_display (display, xid);
if (pixmap)
g_object_ref (pixmap);
@@ -1019,14 +1032,14 @@ panel_applet_get_pixmap (PanelApplet *applet,
return NULL;
}
- gdk_drawable_get_size (GDK_DRAWABLE (GTK_WIDGET (applet)->window),
+ gdk_drawable_get_size (GDK_DRAWABLE (window),
&width, &height);
- retval = gdk_pixmap_new (GTK_WIDGET (applet)->window,
+ retval = gdk_pixmap_new (window,
width, height, -1);
/* the pixmap has no colormap, and we need one */
gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap),
- gdk_drawable_get_colormap (GTK_WIDGET (applet)->window));
+ gdk_drawable_get_colormap (window));
cr = gdk_cairo_create (GDK_DRAWABLE (retval));
gdk_cairo_set_source_pixmap (cr, pixmap, -x, -y);
@@ -1189,7 +1202,7 @@ panel_applet_update_background_for_widget (GtkWidget *widget,
gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, color);
break;
case PANEL_PIXMAP_BACKGROUND:
- style = gtk_style_copy (widget->style);
+ style = gtk_style_copy (gtk_widget_get_style (widget));
if (style->bg_pixmap[GTK_STATE_NORMAL])
g_object_unref (style->bg_pixmap[GTK_STATE_NORMAL]);
style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref (pixmap);
diff --git a/bonobo/libpanel-applet/test-bonobo-applet.c b/bonobo/libpanel-applet/test-bonobo-applet.c
index 9ddb2bc..2567586 100644
--- a/bonobo/libpanel-applet/test-bonobo-applet.c
+++ b/bonobo/libpanel-applet/test-bonobo-applet.c
@@ -125,19 +125,21 @@ test_applet_handle_background_change (TestApplet *applet,
GdkPixmap *pixmap,
gpointer dummy)
{
+ GdkWindow *window = gtk_widget_get_window (applet->label);
+
switch (type) {
case PANEL_NO_BACKGROUND:
g_message ("Setting background to default");
- gdk_window_set_back_pixmap (applet->label->window, NULL, FALSE);
+ gdk_window_set_back_pixmap (window, NULL, FALSE);
break;
case PANEL_COLOR_BACKGROUND:
g_message ("Setting background to #%2x%2x%2x",
color->red, color->green, color->blue);
- gdk_window_set_back_pixmap (applet->label->window, NULL, FALSE);
+ gdk_window_set_back_pixmap (window, NULL, FALSE);
break;
case PANEL_PIXMAP_BACKGROUND:
g_message ("Setting background to '%p'", pixmap);
- gdk_window_set_back_pixmap (applet->label->window, pixmap, FALSE);
+ gdk_window_set_back_pixmap (window, pixmap, FALSE);
break;
default:
g_assert_not_reached ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]