From 9a2acad8eca2c670a0935baa744bcfb2b2edee10 Mon Sep 17 00:00:00 2001 From: Sean Middleditch Date: Fri, 4 Mar 2011 23:32:51 -0800 Subject: [PATCH 3/6] Update libxfce4panel to GTK 2.24 with GSEAL Compile against GTK 2.24. Changes made to work with GSEAL_ENABLE, GTK_DISABLE_DEPRECATED, and the other *_DISABLE_DEPRECATED macros. --- libxfce4panel/xfce-arrow-button.c | 42 +++++++++++++++++-------------- libxfce4panel/xfce-panel-convenience.c | 6 +++- libxfce4panel/xfce-panel-image.c | 36 ++++++++++++++++----------- libxfce4panel/xfce-panel-plugin.c | 24 ++++++++++-------- 4 files changed, 61 insertions(+), 47 deletions(-) diff --git a/libxfce4panel/xfce-arrow-button.c b/libxfce4panel/xfce-arrow-button.c index 615a9d3..f6c126f 100644 --- a/libxfce4panel/xfce-arrow-button.c +++ b/libxfce4panel/xfce-arrow-button.c @@ -176,8 +176,9 @@ xfce_arrow_button_init (XfceArrowButton *button) button->priv->last_relief = GTK_RELIEF_NORMAL; /* set some widget properties */ - GTK_WIDGET_SET_FLAGS (GTK_WIDGET (button), GTK_NO_WINDOW); - GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_DEFAULT | GTK_CAN_FOCUS); + gtk_widget_set_has_window (GTK_WIDGET (button), FALSE); + gtk_widget_set_can_default (GTK_WIDGET (button), FALSE); + gtk_widget_set_can_focus (GTK_WIDGET (button), FALSE); gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE); } @@ -246,43 +247,46 @@ xfce_arrow_button_expose_event (GtkWidget *widget, { XfceArrowButton *button = XFCE_ARROW_BUTTON (widget); GtkWidget *child; + GtkAllocation allocation; gint x, y, width; /* draw the button */ (*GTK_WIDGET_CLASS (xfce_arrow_button_parent_class)->expose_event) (widget, event); + gtk_widget_get_allocation (widget, &allocation); + if (button->priv->arrow_type != GTK_ARROW_NONE - && GTK_WIDGET_DRAWABLE (widget)) + && gtk_widget_is_drawable (widget)) { child = gtk_bin_get_child (GTK_BIN (widget)); - if (child != NULL && GTK_WIDGET_VISIBLE (child)) + if (child != NULL && gtk_widget_get_visible (child)) { if (button->priv->arrow_type == GTK_ARROW_UP || button->priv->arrow_type == GTK_ARROW_DOWN) { width = ARROW_WIDTH; - x = widget->allocation.x + widget->style->xthickness; - y = widget->allocation.y + (widget->allocation.height - width) / 2; + x = allocation.x + gtk_widget_get_style (widget)->xthickness; + y = allocation.y + (allocation.height - width) / 2; } else { width = ARROW_WIDTH; - x = widget->allocation.x + (widget->allocation.width - width) / 2; - y = widget->allocation.y + widget->style->ythickness; + x = allocation.x + (allocation.width - width) / 2; + y = allocation.y + gtk_widget_get_style (widget)->ythickness; } } else { - width = MIN (widget->allocation.height - 2 * widget->style->ythickness, - widget->allocation.width - 2 * widget->style->xthickness); + width = MIN (allocation.height - 2 * gtk_widget_get_style (widget)->ythickness, + allocation.width - 2 * gtk_widget_get_style (widget)->xthickness); width = CLAMP (width, 1, ARROW_WIDTH); - x = widget->allocation.x + (widget->allocation.width - width) / 2; - y = widget->allocation.y + (widget->allocation.height - width) / 2; + x = allocation.x + (allocation.width - width) / 2; + y = allocation.y + (allocation.height - width) / 2; } - gtk_paint_arrow (widget->style, widget->window, - GTK_WIDGET_STATE (widget), GTK_SHADOW_NONE, + gtk_paint_arrow (gtk_widget_get_style (widget), gtk_widget_get_window (widget), + gtk_widget_get_state (widget), GTK_SHADOW_NONE, &(event->area), widget, "xfce_arrow_button", button->priv->arrow_type, FALSE, x, y, width, width); @@ -301,7 +305,7 @@ xfce_arrow_button_size_request (GtkWidget *widget, GtkWidget *child; child = gtk_bin_get_child (GTK_BIN (widget)); - if (child != NULL && GTK_WIDGET_VISIBLE (child)) + if (child != NULL && gtk_widget_get_visible (child)) { /* use gtk for the widget size */ (*GTK_WIDGET_CLASS (xfce_arrow_button_parent_class)->size_request) (widget, requisition); @@ -325,8 +329,8 @@ xfce_arrow_button_size_request (GtkWidget *widget, } else if (button->priv->arrow_type != GTK_ARROW_NONE) { - requisition->height = ARROW_WIDTH + 2 * widget->style->xthickness; - requisition->width = ARROW_WIDTH + 2 * widget->style->ythickness; + requisition->height = ARROW_WIDTH + 2 * gtk_widget_get_style (widget)->xthickness; + requisition->width = ARROW_WIDTH + 2 * gtk_widget_get_style (widget)->ythickness; } } @@ -346,10 +350,10 @@ xfce_arrow_button_size_allocate (GtkWidget *widget, if (button->priv->arrow_type != GTK_ARROW_NONE) { child = gtk_bin_get_child (GTK_BIN (widget)); - if (child != NULL && GTK_WIDGET_VISIBLE (child)) + if (child != NULL && gtk_widget_get_visible (child)) { /* copy the child allocation */ - child_allocation = child->allocation; + gtk_widget_get_allocation (child, &child_allocation); /* update the allocation to make space for the arrow */ switch (button->priv->arrow_type) diff --git a/libxfce4panel/xfce-panel-convenience.c b/libxfce4panel/xfce-panel-convenience.c index dc26ff8..f127a9d 100644 --- a/libxfce4panel/xfce-panel-convenience.c +++ b/libxfce4panel/xfce-panel-convenience.c @@ -57,7 +57,8 @@ xfce_panel_create_button (void) { GtkWidget *button = gtk_button_new (); - GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_DEFAULT | GTK_CAN_FOCUS); + gtk_widget_set_can_default (GTK_WIDGET(button), FALSE); + gtk_widget_set_can_focus (GTK_WIDGET(button), FALSE); gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE); gtk_widget_set_name (button, "xfce-panel-button"); @@ -80,7 +81,8 @@ xfce_panel_create_toggle_button (void) { GtkWidget *button = gtk_toggle_button_new (); - GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_DEFAULT | GTK_CAN_FOCUS); + gtk_widget_set_can_default (GTK_WIDGET(button), FALSE); + gtk_widget_set_can_focus (GTK_WIDGET(button), FALSE); gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE); gtk_widget_set_name (button, "xfce-panel-toggle-button"); diff --git a/libxfce4panel/xfce-panel-image.c b/libxfce4panel/xfce-panel-image.c index 1126d1e..c70f2b6 100644 --- a/libxfce4panel/xfce-panel-image.c +++ b/libxfce4panel/xfce-panel-image.c @@ -189,7 +189,7 @@ xfce_panel_image_class_init (XfcePanelImageClass *klass) static void xfce_panel_image_init (XfcePanelImage *image) { - GTK_WIDGET_SET_FLAGS (image, GTK_NO_WINDOW); + gtk_widget_set_has_window (GTK_WIDGET (image), FALSE); image->priv = G_TYPE_INSTANCE_GET_PRIVATE (image, XFCE_TYPE_PANEL_IMAGE, XfcePanelImagePrivate); @@ -293,8 +293,12 @@ xfce_panel_image_size_request (GtkWidget *widget, } else { - requisition->width = widget->allocation.width; - requisition->height = widget->allocation.height; + GtkAllocation allocation; + + gtk_widget_get_allocation (widget, &allocation); + + requisition->width = allocation.width; + requisition->height = allocation.height; } } @@ -310,7 +314,7 @@ xfce_panel_image_size_allocate (GtkWidget *widget, GtkIconTheme *icon_theme = NULL; gint size; - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); /* check if the available size changed */ if ((priv->pixbuf != NULL || priv->source != NULL) @@ -374,26 +378,30 @@ xfce_panel_image_expose_event (GtkWidget *widget, GtkIconSource *source; GdkPixbuf *rendered = NULL; GdkPixbuf *pixbuf = priv->cache; + GtkAllocation allocation; + cairo_t *cr; if (G_LIKELY (pixbuf != NULL)) { + /* get the size of the cache pixbuf */ source_width = gdk_pixbuf_get_width (priv->cache); source_height = gdk_pixbuf_get_height (priv->cache); /* position */ - dest_x = widget->allocation.x + (priv->width - source_width) / 2; - dest_y = widget->allocation.y + (priv->height - source_height) / 2; + gtk_widget_get_allocation (widget, &allocation); + dest_x = allocation.x + (priv->width - source_width) / 2; + dest_y = allocation.y + (priv->height - source_height) / 2; - if (GTK_WIDGET_STATE (widget) == GTK_STATE_INSENSITIVE) + if (gtk_widget_get_state (widget) == GTK_STATE_INSENSITIVE) { source = gtk_icon_source_new (); gtk_icon_source_set_pixbuf (source, pixbuf); - rendered = gtk_style_render_icon (widget->style, + rendered = gtk_style_render_icon (gtk_widget_get_style (widget), source, gtk_widget_get_direction (widget), - GTK_WIDGET_STATE (widget), + gtk_widget_get_state (widget), -1, widget, "xfce-panel-image"); gtk_icon_source_free (source); @@ -402,12 +410,10 @@ xfce_panel_image_expose_event (GtkWidget *widget, } /* draw the pixbuf */ - gdk_draw_pixbuf (widget->window, - widget->style->black_gc, - pixbuf, 0, 0, - dest_x, dest_y, - source_width, source_height, - GDK_RGB_DITHER_NORMAL, 0, 0); + cr = gdk_cairo_create (gtk_widget_get_window (widget)); + gdk_cairo_set_source_pixbuf (cr, pixbuf, dest_x, dest_y); + cairo_paint (cr); + cairo_destroy (cr); if (rendered != NULL) g_object_unref (G_OBJECT (rendered)); diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c index 360ed7d..4c5bf71 100644 --- a/libxfce4panel/xfce-panel-plugin.c +++ b/libxfce4panel/xfce-panel-plugin.c @@ -2009,11 +2009,11 @@ xfce_panel_plugin_arrow_type (XfcePanelPlugin *plugin) { /* get the monitor geometry */ screen = gtk_widget_get_screen (GTK_WIDGET (plugin)); - monitor_num = gdk_screen_get_monitor_at_window (screen, GTK_WIDGET (plugin)->window); + monitor_num = gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (GTK_WIDGET (plugin))); gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); /* get the plugin root origin */ - gdk_window_get_root_origin (GTK_WIDGET (plugin)->window, &x, &y); + gdk_window_get_root_origin (gtk_widget_get_window (GTK_WIDGET (plugin)), &x, &y); /* detect arrow type */ if (screen_position == XFCE_SCREEN_POSITION_FLOATING_H) @@ -2053,6 +2053,7 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin, GtkRequisition requisition; GdkScreen *screen; GdkRectangle monitor; + GtkAllocation attach_allocation; gint monitor_num; GTimeVal now_t, end_t; @@ -2066,18 +2067,18 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin, attach_widget = GTK_WIDGET (plugin); /* make sure the menu is realized to get valid rectangle sizes */ - if (!GTK_WIDGET_REALIZED (menu_widget)) + if (!gtk_widget_get_realized (menu_widget)) gtk_widget_realize (menu_widget); /* make sure the attach widget is realized for the gdkwindow */ - if (!GTK_WIDGET_REALIZED (attach_widget)) + if (!gtk_widget_get_realized (attach_widget)) gtk_widget_realize (attach_widget); /* get the menu/widget size request */ gtk_widget_size_request (menu_widget, &requisition); /* get the root position of the attach widget */ - gdk_window_get_position (GDK_WINDOW (attach_widget->window), x, y); + gdk_window_get_position (gtk_widget_get_window (attach_widget), x, y); /* if the panel is hidden (auto hide is enabled) and we requested a * panel lock, wait for gtk to position the panel before we actually @@ -2092,7 +2093,7 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin, while (gtk_events_pending ()) gtk_main_iteration (); - gdk_window_get_position (GDK_WINDOW (attach_widget->window), x, y); + gdk_window_get_position (gtk_widget_get_window (attach_widget), x, y); /* don't try longer then 1/2 a second */ g_get_current_time (&now_t); @@ -2104,8 +2105,9 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin, } /* add the widgets allocation */ - *x += attach_widget->allocation.x; - *y += attach_widget->allocation.y; + gtk_widget_get_allocation (attach_widget, &attach_allocation); + *x += attach_allocation.x; + *y += attach_allocation.y; switch (xfce_panel_plugin_arrow_type (plugin)) { @@ -2114,7 +2116,7 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin, break; case GTK_ARROW_DOWN: - *y += attach_widget->allocation.height; + *y += attach_allocation.height; break; case GTK_ARROW_LEFT: @@ -2122,13 +2124,13 @@ xfce_panel_plugin_position_widget (XfcePanelPlugin *plugin, break; default: /* GTK_ARROW_RIGHT and GTK_ARROW_NONE */ - *x += attach_widget->allocation.width; + *x += attach_allocation.width; break; } /* get the monitor geometry */ screen = gtk_widget_get_screen (attach_widget); - monitor_num = gdk_screen_get_monitor_at_window (screen, attach_widget->window); + monitor_num = gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (attach_widget)); gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); /* keep the menu inside the screen */ -- 1.7.4.1