[gnome-power-manager] Use accessor functions instead direct access.
- From: Luis Medinas <lmedinas src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-power-manager] Use accessor functions instead direct access.
- Date: Thu, 10 Sep 2009 02:17:07 +0000 (UTC)
commit 0549df3002fc358469e71f0338b0a9604aa11bee
Author: Javier Jardón <javierjc1982 gmail com>
Date: Wed Sep 9 05:16:29 2009 +0200
Use accessor functions instead direct access.
GTK+ 2.17.7 is now the required version
http://bugzilla.gnome.org/show_bug.cgi?id=594585
applets/brightness/brightness-applet.c | 72 ++++++++++++++++---------------
applets/inhibit/inhibit-applet.c | 33 ++++++++------
configure.ac | 2 +-
src/gpm-graph-widget.c | 10 +++--
src/gpm-popup-window.c | 30 +++++++------
5 files changed, 80 insertions(+), 67 deletions(-)
---
diff --git a/applets/brightness/brightness-applet.c b/applets/brightness/brightness-applet.c
index f8f6615..ae4c841 100644
--- a/applets/brightness/brightness-applet.c
+++ b/applets/brightness/brightness-applet.c
@@ -224,17 +224,20 @@ gpm_applet_get_icon (GpmBrightnessApplet *applet)
static void
gpm_applet_check_size (GpmBrightnessApplet *applet)
{
+ GtkAllocation allocation;
+
/* we don't use the size function here, but the yet allocated size because the
size value is false (kind of rounded) */
+ gtk_widget_get_allocation (GTK_WIDGET (applet), &allocation);
if (PANEL_APPLET_VERTICAL(panel_applet_get_orient (PANEL_APPLET (applet)))) {
- if (applet->size != GTK_WIDGET(applet)->allocation.width) {
- applet->size = GTK_WIDGET(applet)->allocation.width;
+ if (applet->size != allocation.width) {
+ applet->size = allocation.width;
gpm_applet_get_icon (applet);
gtk_widget_set_size_request (GTK_WIDGET(applet), applet->size, applet->icon_height + 2);
}
} else {
- if (applet->size != GTK_WIDGET(applet)->allocation.height) {
- applet->size = GTK_WIDGET(applet)->allocation.height;
+ if (applet->size != allocation.height) {
+ applet->size = allocation.height;
gpm_applet_get_icon (applet);
gtk_widget_set_size_request (GTK_WIDGET(applet), applet->icon_width + 2, applet->size);
}
@@ -254,8 +257,9 @@ gpm_applet_draw_cb (GpmBrightnessApplet *applet)
GdkColor color;
GdkGC *gc;
GdkPixmap *background;
+ GtkAllocation allocation;
- if (GTK_WIDGET(applet)->window == NULL) {
+ if (gtk_widget_get_window (GTK_WIDGET(applet)) == NULL) {
return FALSE;
}
@@ -271,23 +275,24 @@ gpm_applet_draw_cb (GpmBrightnessApplet *applet)
return FALSE;
}
- w = GTK_WIDGET(applet)->allocation.width;
- h = GTK_WIDGET(applet)->allocation.height;
+ gtk_widget_get_allocation (GTK_WIDGET (applet), &allocation);
+ w = allocation.width;
+ h = allocation.height;
- gc = gdk_gc_new (GTK_WIDGET(applet)->window);
+ gc = gdk_gc_new (gtk_widget_get_window (GTK_WIDGET(applet)));
/* draw pixmap background */
bg_type = panel_applet_get_background (PANEL_APPLET (applet), &color, &background);
if (bg_type == PANEL_PIXMAP_BACKGROUND && !applet->popped) {
/* fill with given background pixmap */
- gdk_draw_drawable (GTK_WIDGET(applet)->window, gc, background, 0, 0, 0, 0, w, h);
+ gdk_draw_drawable (gtk_widget_get_window (GTK_WIDGET(applet)), gc, background, 0, 0, 0, 0, w, h);
}
/* draw color background */
if (bg_type == PANEL_COLOR_BACKGROUND && !applet->popped) {
gdk_gc_set_rgb_fg_color (gc,&color);
gdk_gc_set_fill (gc,GDK_SOLID);
- gdk_draw_rectangle (GTK_WIDGET(applet)->window, gc, TRUE, 0, 0, w, h);
+ gdk_draw_rectangle (gtk_widget_get_window (GTK_WIDGET(applet)), gc, TRUE, 0, 0, w, h);
}
/* fill with selected color if popped */
@@ -295,11 +300,11 @@ gpm_applet_draw_cb (GpmBrightnessApplet *applet)
color = gtk_rc_get_style (GTK_WIDGET(applet))->bg[GTK_STATE_SELECTED];
gdk_gc_set_rgb_fg_color (gc,&color);
gdk_gc_set_fill (gc,GDK_SOLID);
- gdk_draw_rectangle (GTK_WIDGET(applet)->window, gc, TRUE, 0, 0, w, h);
+ gdk_draw_rectangle (gtk_widget_get_window (GTK_WIDGET(applet)), gc, TRUE, 0, 0, w, h);
}
/* draw icon at center */
- gdk_draw_pixbuf (GTK_WIDGET(applet)->window, gc, applet->icon,
+ gdk_draw_pixbuf (gtk_widget_get_window (GTK_WIDGET(applet)), gc, applet->icon,
0, 0, (w - applet->icon_width)/2, (h - applet->icon_height)/2,
applet->icon_width, applet->icon_height,
GDK_RGB_DITHER_NONE, 0, 0);
@@ -605,6 +610,7 @@ gpm_applet_create_popup (GpmBrightnessApplet *applet)
static gboolean
gpm_applet_popup_cb (GpmBrightnessApplet *applet, GdkEventButton *event)
{
+ GtkAllocation allocation, popup_allocation;
gint orientation, x, y;
/* react only to left mouse button */
@@ -644,36 +650,32 @@ gpm_applet_popup_cb (GpmBrightnessApplet *applet, GdkEventButton *event)
/* retrieve geometry parameters and move window appropriately */
orientation = panel_applet_get_orient (PANEL_APPLET (PANEL_APPLET (applet)));
- gdk_window_get_origin (GTK_WIDGET(applet)->window, &x, &y);
+ gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET(applet)), &x, &y);
+ gtk_widget_get_allocation (GTK_WIDGET (applet), &allocation);
+ gtk_widget_get_allocation (GTK_WIDGET (applet->popup), &popup_allocation);
switch (orientation) {
case PANEL_APPLET_ORIENT_DOWN:
- x += GTK_WIDGET(applet)->allocation.x
- + GTK_WIDGET(applet)->allocation.width/2;
- y += GTK_WIDGET(applet)->allocation.y
- + GTK_WIDGET(applet)->allocation.height;
- x -= applet->popup->allocation.width/2;
+ x += allocation.x + allocation.width/2;
+ y += allocation.y + allocation.height;
+ x -= popup_allocation.width/2;
break;
case PANEL_APPLET_ORIENT_UP:
- x += GTK_WIDGET(applet)->allocation.x
- + GTK_WIDGET(applet)->allocation.width/2;
- y += GTK_WIDGET(applet)->allocation.y;
- x -= applet->popup->allocation.width/2;
- y -= applet->popup->allocation.height;
+ x += allocation.x + allocation.width/2;
+ y += allocation.y;
+ x -= popup_allocation.width/2;
+ y -= popup_allocation.height;
break;
case PANEL_APPLET_ORIENT_RIGHT:
- y += GTK_WIDGET(applet)->allocation.y
- + GTK_WIDGET(applet)->allocation.height/2;
- x += GTK_WIDGET(applet)->allocation.x
- + GTK_WIDGET(applet)->allocation.width;
- y -= applet->popup->allocation.height/2;
+ y += allocation.y + allocation.height/2;
+ x += allocation.x + allocation.width;
+ y -= popup_allocation.height/2;
break;
case PANEL_APPLET_ORIENT_LEFT:
- y += GTK_WIDGET(applet)->allocation.y
- + GTK_WIDGET(applet)->allocation.height/2;
- x += GTK_WIDGET(applet)->allocation.x;
- x -= applet->popup->allocation.width;
- y -= applet->popup->allocation.height/2;
+ y += allocation.y + allocation.height/2;
+ x += allocation.x;
+ x -= popup_allocation.width;
+ y -= popup_allocation.height/2;
break;
default:
g_assert_not_reached ();
@@ -684,12 +686,12 @@ gpm_applet_popup_cb (GpmBrightnessApplet *applet, GdkEventButton *event)
/* grab input */
gtk_widget_grab_focus (GTK_WIDGET(applet));
gtk_grab_add (GTK_WIDGET(applet));
- gdk_pointer_grab (GTK_WIDGET(applet)->window, TRUE,
+ gdk_pointer_grab (gtk_widget_get_window (GTK_WIDGET(applet)), TRUE,
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK,
NULL, NULL, GDK_CURRENT_TIME);
- gdk_keyboard_grab (GTK_WIDGET(applet)->window,
+ gdk_keyboard_grab (gtk_widget_get_window (GTK_WIDGET(applet)),
TRUE, GDK_CURRENT_TIME);
gtk_widget_set_state (GTK_WIDGET(applet), GTK_STATE_SELECTED);
diff --git a/applets/inhibit/inhibit-applet.c b/applets/inhibit/inhibit-applet.c
index 31042d6..b46f66a 100644
--- a/applets/inhibit/inhibit-applet.c
+++ b/applets/inhibit/inhibit-applet.c
@@ -240,26 +240,29 @@ gpm_applet_get_icon (GpmInhibitApplet *applet)
static void
gpm_applet_check_size (GpmInhibitApplet *applet)
{
+ GtkAllocation allocation;
+
/* we don't use the size function here, but the yet allocated size because the
size value is false (kind of rounded) */
+ gtk_widget_get_allocation (GTK_WIDGET (applet), &allocation);
if (PANEL_APPLET_VERTICAL(panel_applet_get_orient (PANEL_APPLET (applet)))) {
- if (applet->size != GTK_WIDGET(applet)->allocation.width) {
- applet->size = GTK_WIDGET(applet)->allocation.width;
+ if (applet->size != allocation.width) {
+ applet->size = allocation.width;
gpm_applet_get_icon (applet);
gtk_widget_set_size_request (GTK_WIDGET(applet), applet->size, applet->icon_height + 2);
}
/* Adjusting incase the icon size has changed */
- if (GTK_WIDGET(applet)->allocation.height < applet->icon_height + 2) {
+ if (allocation.height < applet->icon_height + 2) {
gtk_widget_set_size_request (GTK_WIDGET(applet), applet->size, applet->icon_height + 2);
}
} else {
- if (applet->size != GTK_WIDGET(applet)->allocation.height) {
- applet->size = GTK_WIDGET(applet)->allocation.height;
+ if (applet->size != allocation.height) {
+ applet->size = allocation.height;
gpm_applet_get_icon (applet);
gtk_widget_set_size_request (GTK_WIDGET(applet), applet->icon_width + 2, applet->size);
}
/* Adjusting incase the icon size has changed */
- if (GTK_WIDGET(applet)->allocation.width < applet->icon_width + 2) {
+ if (allocation.width < applet->icon_width + 2) {
gtk_widget_set_size_request (GTK_WIDGET(applet), applet->icon_width + 2, applet->size);
}
}
@@ -278,13 +281,14 @@ gpm_applet_draw_cb (GpmInhibitApplet *applet)
GdkColor color;
GdkGC *gc;
GdkPixmap *background;
+ GtkAllocation allocation;
- if (GTK_WIDGET(applet)->window == NULL) {
+ if (gtk_widget_get_window (GTK_WIDGET(applet)) == NULL) {
return FALSE;
}
/* Clear the window so we can draw on it later */
- gdk_window_clear(GTK_WIDGET(applet)->window);
+ gdk_window_clear(gtk_widget_get_window (GTK_WIDGET (applet)));
/* retrieve applet size */
gpm_applet_get_icon (applet);
@@ -298,27 +302,28 @@ gpm_applet_draw_cb (GpmInhibitApplet *applet)
return FALSE;
}
- w = GTK_WIDGET(applet)->allocation.width;
- h = GTK_WIDGET(applet)->allocation.height;
+ gtk_widget_get_allocation (GTK_WIDGET (applet), &allocation);
+ w = allocation.width;
+ h = allocation.height;
- gc = gdk_gc_new (GTK_WIDGET(applet)->window);
+ gc = gdk_gc_new (gtk_widget_get_window (GTK_WIDGET(applet)));
/* draw pixmap background */
bg_type = panel_applet_get_background (PANEL_APPLET (applet), &color, &background);
if (bg_type == PANEL_PIXMAP_BACKGROUND) {
/* fill with given background pixmap */
- gdk_draw_drawable (GTK_WIDGET(applet)->window, gc, background, 0, 0, 0, 0, w, h);
+ gdk_draw_drawable (gtk_widget_get_window (GTK_WIDGET(applet)), gc, background, 0, 0, 0, 0, w, h);
}
/* draw color background */
if (bg_type == PANEL_COLOR_BACKGROUND) {
gdk_gc_set_rgb_fg_color (gc,&color);
gdk_gc_set_fill (gc,GDK_SOLID);
- gdk_draw_rectangle (GTK_WIDGET(applet)->window, gc, TRUE, 0, 0, w, h);
+ gdk_draw_rectangle (gtk_widget_get_window (GTK_WIDGET(applet)), gc, TRUE, 0, 0, w, h);
}
/* draw icon at center */
- gdk_draw_pixbuf (GTK_WIDGET(applet)->window, gc, applet->icon,
+ gdk_draw_pixbuf (gtk_widget_get_window (GTK_WIDGET(applet)), gc, applet->icon,
0, 0, (w - applet->icon_width)/2, (h - applet->icon_height)/2,
applet->icon_width, applet->icon_height,
GDK_RGB_DITHER_NONE, 0, 0);
diff --git a/configure.ac b/configure.ac
index 4fe66ef..ef40c6b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -91,7 +91,7 @@ dnl ---------------------------------------------------------------------------
dnl - Library dependencies
dnl ---------------------------------------------------------------------------
GLIB_REQUIRED=2.13.0
-GTK_REQUIRED=2.11.0
+GTK_REQUIRED=2.17.7
GDK_REQUIRED=2.11.0
GCONF_REQUIRED=2.10.0
GNOME_KEYRING_REQUIRED=0.6.0
diff --git a/src/gpm-graph-widget.c b/src/gpm-graph-widget.c
index 90b9d40..fea600e 100644
--- a/src/gpm-graph-widget.c
+++ b/src/gpm-graph-widget.c
@@ -1082,6 +1082,7 @@ gpm_graph_widget_legend_calculate_size (GpmGraphWidget *graph, cairo_t *cr,
static void
gpm_graph_widget_draw_graph (GtkWidget *graph_widget, cairo_t *cr)
{
+ GtkAllocation allocation;
gint legend_x = 0;
gint legend_y = 0;
guint legend_height = 0;
@@ -1105,16 +1106,17 @@ gpm_graph_widget_draw_graph (GtkWidget *graph_widget, cairo_t *cr)
graph->priv->box_x = gpm_graph_widget_get_y_label_max_width (graph, cr) + 10;
graph->priv->box_y = 5;
- graph->priv->box_height = graph_widget->allocation.height - (20 + graph->priv->box_y);
+ gtk_widget_get_allocation (graph_widget, &allocation);
+ graph->priv->box_height = allocation.height - (20 + graph->priv->box_y);
/* make size adjustment for legend */
if (graph->priv->use_legend && legend_height > 0) {
- graph->priv->box_width = graph_widget->allocation.width -
+ graph->priv->box_width = allocation.width -
(3 + legend_width + 5 + graph->priv->box_x);
legend_x = graph->priv->box_x + graph->priv->box_width + 6;
legend_y = graph->priv->box_y;
} else {
- graph->priv->box_width = graph_widget->allocation.width -
+ graph->priv->box_width = allocation.width -
(3 + graph->priv->box_x);
}
@@ -1152,7 +1154,7 @@ gpm_graph_widget_expose (GtkWidget *graph, GdkEventExpose *event)
cairo_t *cr;
/* get a cairo_t */
- cr = gdk_cairo_create (graph->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (graph));
cairo_rectangle (cr,
event->area.x, event->area.y,
event->area.width, event->area.height);
diff --git a/src/gpm-popup-window.c b/src/gpm-popup-window.c
index 9fd2f3f..6cc4038 100644
--- a/src/gpm-popup-window.c
+++ b/src/gpm-popup-window.c
@@ -71,15 +71,17 @@ gpm_popup_window_fade_timeout_cb (GpmPopupWindow *popup)
} else {
GdkRectangle rect;
GtkWidget *widget = GTK_WIDGET (popup);
+ GtkAllocation allocation;
popup->priv->fade_out_alpha -= 0.10;
rect.x = 0;
rect.y = 0;
- rect.width = widget->allocation.width;
- rect.height = widget->allocation.height;
+ gtk_widget_get_allocation (widget, &allocation);
+ rect.width = allocation.width;
+ rect.height = allocation.height;
- gdk_window_invalidate_rect (widget->window, &rect, FALSE);
+ gdk_window_invalidate_rect (gtk_widget_get_window (widget), &rect, FALSE);
}
return TRUE;
@@ -304,7 +306,7 @@ gpm_popup_window_draw_progress_bar (GpmPopupWindow *popup, cairo_t *cr, gdouble
xw = width * percentage;
/* bar background */
- color = GTK_WIDGET (popup)->style->dark [GTK_STATE_NORMAL];
+ color = gtk_widget_get_style (GTK_WIDGET (popup))->dark [GTK_STATE_NORMAL];
r = (float)color.red / 65535.0;
g = (float)color.green / 65535.0;
b = (float)color.blue / 65535.0;
@@ -313,7 +315,7 @@ gpm_popup_window_draw_progress_bar (GpmPopupWindow *popup, cairo_t *cr, gdouble
cairo_fill (cr);
/* bar border */
- color = GTK_WIDGET (popup)->style->dark [GTK_STATE_SELECTED];
+ color = gtk_widget_get_style (GTK_WIDGET (popup))->dark [GTK_STATE_SELECTED];
r = (float)color.red / 65535.0;
g = (float)color.green / 65535.0;
b = (float)color.blue / 65535.0;
@@ -323,7 +325,7 @@ gpm_popup_window_draw_progress_bar (GpmPopupWindow *popup, cairo_t *cr, gdouble
cairo_stroke (cr);
/* bar progress */
- color = GTK_WIDGET (popup)->style->bg [GTK_STATE_SELECTED];
+ color = gtk_widget_get_style (GTK_WIDGET (popup))->bg [GTK_STATE_SELECTED];
r = (float)color.red / 65535.0;
g = (float)color.green / 65535.0;
b = (float)color.blue / 65535.0;
@@ -390,7 +392,7 @@ gpm_popup_window_expose_event_cb (GtkWidget *widget, GdkEventExpose *event, GpmP
if (!popup->priv->is_composited)
goto out;
- context = gdk_cairo_create (GTK_WIDGET (popup)->window);
+ context = gdk_cairo_create (gtk_widget_get_window (GTK_WIDGET (popup)));
cairo_set_operator (context, CAIRO_OPERATOR_SOURCE);
gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
@@ -412,14 +414,14 @@ gpm_popup_window_expose_event_cb (GtkWidget *widget, GdkEventExpose *event, GpmP
/* draw a box */
gpm_popup_window_curved_rectangle (cr, 0.5, 0.5, width-1, height-1, height / 10);
- color = GTK_WIDGET (popup)->style->bg [GTK_STATE_NORMAL];
+ color = gtk_widget_get_style (GTK_WIDGET (popup))->bg [GTK_STATE_NORMAL];
r = (float)color.red / 65535.0;
g = (float)color.green / 65535.0;
b = (float)color.blue / 65535.0;
cairo_set_source_rgba (cr, r, g, b, GPM_POPUP_WINDOW_BG_ALPHA);
cairo_fill_preserve (cr);
- color = GTK_WIDGET (popup)->style->fg [GTK_STATE_NORMAL];
+ color = gtk_widget_get_style (GTK_WIDGET (popup))->fg [GTK_STATE_NORMAL];
r = (float)color.red / 65535.0;
g = (float)color.green / 65535.0;
b = (float)color.blue / 65535.0;
@@ -535,6 +537,7 @@ gpm_popup_window_hide (GtkWidget *widget)
static void
gpm_popup_window_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
GdkColormap *colormap;
GdkBitmap *mask;
cairo_t *cr;
@@ -547,9 +550,10 @@ gpm_popup_window_realize (GtkWidget *widget)
if (GTK_WIDGET_CLASS (gpm_popup_window_parent_class)->realize)
GTK_WIDGET_CLASS (gpm_popup_window_parent_class)->realize (widget);
- mask = gdk_pixmap_new (widget->window,
- widget->allocation.width,
- widget->allocation.height, 1);
+ gtk_widget_get_allocation (widget, &allocation);
+ mask = gdk_pixmap_new (gtk_widget_get_window (widget),
+ allocation.width,
+ allocation.height, 1);
cr = gdk_cairo_create (mask);
cairo_set_source_rgba (cr, 1.0f, 1.0f, 1.0f, 0.0f);
@@ -557,7 +561,7 @@ gpm_popup_window_realize (GtkWidget *widget)
cairo_paint (cr);
/* make the whole window ignore events */
- gdk_window_input_shape_combine_mask (widget->window, mask, 0, 0);
+ gdk_window_input_shape_combine_mask (gtk_widget_get_window (widget), mask, 0, 0);
g_object_unref (mask);
cairo_destroy (cr);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]