[Xfce4-commits] <xfce4-panel:nick/gtk3> More porting to Gtk+-3 for the panel code.
Peter de Ridder
noreply at xfce.org
Mon Apr 8 00:52:31 CEST 2013
Updating branch refs/heads/nick/gtk3
to 4266d3766f4e0222391967e034e1d396ae16b5a2 (commit)
from 0ff5a96563d2779bbbb775b182ae87bb0229be1d (commit)
commit 4266d3766f4e0222391967e034e1d396ae16b5a2
Author: Peter de Ridder <peter at xfce.org>
Date: Sun Apr 7 22:41:55 2013 +0200
More porting to Gtk+-3 for the panel code.
panel/panel-base-window.c | 104 ++++++++++--------
panel/panel-dialogs.c | 10 +-
panel/panel-item-dialog.c | 7 +-
panel/panel-itembar.c | 164 ++++++++++++++++------------
panel/panel-plugin-external-46.c | 8 +-
panel/panel-plugin-external-wrapper.c | 2 +-
panel/panel-plugin-external.c | 8 +-
panel/panel-plugin-external.h | 1 +
panel/panel-preferences-dialog.c | 8 +-
panel/panel-tic-tac-toe.c | 55 +++++-----
panel/panel-window.c | 193 ++++++++++++++++++++-------------
11 files changed, 323 insertions(+), 237 deletions(-)
diff --git a/panel/panel-base-window.c b/panel/panel-base-window.c
index a48456d..24a0801 100644
--- a/panel/panel-base-window.c
+++ b/panel/panel-base-window.c
@@ -48,8 +48,8 @@ static void panel_base_window_set_property (GObject
static void panel_base_window_finalize (GObject *object);
static void panel_base_window_screen_changed (GtkWidget *widget,
GdkScreen *previous_screen);
-static gboolean panel_base_window_expose_event (GtkWidget *widget,
- GdkEventExpose *event);
+static gboolean panel_base_window_draw (GtkWidget *widget,
+ cairo_t *cr);
static gboolean panel_base_window_enter_notify_event (GtkWidget *widget,
GdkEventCrossing *event);
static gboolean panel_base_window_leave_notify_event (GtkWidget *widget,
@@ -118,7 +118,7 @@ panel_base_window_class_init (PanelBaseWindowClass *klass)
gobject_class->finalize = panel_base_window_finalize;
gtkwidget_class = GTK_WIDGET_CLASS (klass);
- gtkwidget_class->expose_event = panel_base_window_expose_event;
+ gtkwidget_class->draw = panel_base_window_draw;
gtkwidget_class->enter_notify_event = panel_base_window_enter_notify_event;
gtkwidget_class->leave_notify_event = panel_base_window_leave_notify_event;
gtkwidget_class->composited_changed = panel_base_window_composited_changed;
@@ -229,6 +229,9 @@ panel_base_window_get_property (GObject *object,
PanelBaseWindow *window = PANEL_BASE_WINDOW (object);
PanelBaseWindowPrivate *priv = window->priv;
GdkColor *color;
+ GdkColor bg_color;
+ GdkRGBA bg_rgba;
+ GtkStyleContext *ctx;
switch (prop_id)
{
@@ -252,7 +255,14 @@ panel_base_window_get_property (GObject *object,
if (window->background_color != NULL)
color = window->background_color;
else
- color = &(GTK_WIDGET (window)->style->bg[GTK_STATE_NORMAL]);
+ {
+ ctx = gtk_widget_get_style_context (GTK_WIDGET (window));
+ gtk_style_context_get_background_color (ctx, GTK_STATE_NORMAL, &bg_rgba);
+ bg_color.red = CLAMP(bg_rgba.red * 65536, 65535, 0);
+ bg_color.green = CLAMP(bg_rgba.green * 65536, 65535, 0);
+ bg_color.blue = CLAMP(bg_rgba.blue * 65536, 65535, 0);
+ color = &bg_color;
+ }
g_value_set_boxed (value, color);
break;
@@ -442,7 +452,7 @@ static void
panel_base_window_screen_changed (GtkWidget *widget, GdkScreen *previous_screen)
{
PanelBaseWindow *window = PANEL_BASE_WINDOW (widget);
- GdkColormap *colormap;
+ GdkVisual *visual;
GdkScreen *screen;
if (GTK_WIDGET_CLASS (panel_base_window_parent_class)->screen_changed != NULL)
@@ -450,58 +460,55 @@ panel_base_window_screen_changed (GtkWidget *widget, GdkScreen *previous_screen)
/* set the rgba colormap if supported by the screen */
screen = gtk_window_get_screen (GTK_WINDOW (window));
- colormap = gdk_screen_get_rgba_colormap (screen);
- if (colormap != NULL)
+ visual = gdk_screen_get_rgba_visual (screen);
+ if (visual != NULL)
{
- gtk_widget_set_colormap (widget, colormap);
+ gtk_widget_set_visual (widget, visual);
window->is_composited = gtk_widget_is_composited (widget);
}
panel_debug (PANEL_DEBUG_BASE_WINDOW,
- "%p: rgba colormap=%p, compositing=%s", window,
- colormap, PANEL_DEBUG_BOOL (window->is_composited));
+ "%p: rgba visual=%p, compositing=%s", window,
+ visual, PANEL_DEBUG_BOOL (window->is_composited));
}
static gboolean
-panel_base_window_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
+panel_base_window_draw (GtkWidget *widget,
+ cairo_t *cr)
{
- cairo_t *cr;
const GdkColor *color;
+ GdkRGBA bg_rgba;
+ GtkSymbolicColor *literal;
+ GtkSymbolicColor *shade;
PanelBaseWindow *window = PANEL_BASE_WINDOW (widget);
PanelBaseWindowPrivate *priv = window->priv;
gdouble alpha;
- gdouble width = widget->allocation.width;
- gdouble height = widget->allocation.height;
+ gdouble width = gtk_widget_get_allocated_width (widget);
+ gdouble height = gtk_widget_get_allocated_height (widget);
const gdouble dashes[] = { 4.00, 4.00 };
GTimeVal timeval;
GdkPixbuf *pixbuf;
GError *error = NULL;
cairo_matrix_t matrix = { 1, 0, 0, 1, 0, 0 }; /* identity matrix */
+ GtkStyleContext *ctx;
- if (!GTK_WIDGET_DRAWABLE (widget))
+ if (!gtk_widget_is_drawable (widget))
return FALSE;
+ ctx = gtk_widget_get_style_context (widget);
+
/* create cairo context and set some default properties */
- cr = gdk_cairo_create (widget->window);
- panel_return_val_if_fail (cr != NULL, FALSE);
cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_set_line_width (cr, 1.00);
- /* set rectangle to clip the drawing area */
- gdk_cairo_rectangle (cr, &event->area);
-
/* get background alpha */
alpha = window->is_composited ? window->background_alpha : 1.00;
if (window->background_style == PANEL_BG_STYLE_IMAGE)
{
- /* clip the drawing area */
- cairo_clip (cr);
-
if (G_LIKELY (priv->bg_image_cache != NULL))
{
if (G_UNLIKELY (priv->active_timeout_id != 0))
@@ -543,25 +550,22 @@ panel_base_window_expose_event (GtkWidget *widget,
/* get the background color */
if (window->background_style == PANEL_BG_STYLE_COLOR
&& window->background_color != NULL)
- color = window->background_color;
+ {
+ color = window->background_color;
+ panel_util_set_source_rgba (cr, color, alpha);
+ }
else
- color = &(widget->style->bg[GTK_STATE_NORMAL]);
+ {
+ gtk_style_context_get_background_color (ctx, GTK_STATE_NORMAL, &bg_rgba);
+ gdk_cairo_set_source_rgba (cr, &bg_rgba);
+ }
/* only do something with the background when compositing is enabled */
if (G_UNLIKELY (alpha < 1.00
|| window->background_style != PANEL_BG_STYLE_NONE))
{
- /* clip the drawing area, but preserve the rectangle */
- cairo_clip_preserve (cr);
-
/* draw the background */
- panel_util_set_source_rgba (cr, color, alpha);
- cairo_fill (cr);
- }
- else
- {
- /* clip the drawing area */
- cairo_clip (cr);
+ cairo_paint (cr);
}
}
@@ -585,8 +589,14 @@ panel_base_window_expose_event (GtkWidget *widget,
if (PANEL_HAS_FLAG (priv->borders, PANEL_BORDER_BOTTOM | PANEL_BORDER_RIGHT))
{
/* use dark color for buttom and right line */
- color = &(widget->style->dark[GTK_STATE_NORMAL]);
- panel_util_set_source_rgba (cr, color, alpha);
+ gtk_style_context_get_background_color (ctx, GTK_STATE_NORMAL, &bg_rgba);
+ literal = gtk_symbolic_color_new_literal (&bg_rgba);
+ shade = gtk_symbolic_color_new_shade (literal, 0.7);
+ gtk_symbolic_color_unref (literal);
+ gtk_symbolic_color_resolve (shade, NULL, &bg_rgba);
+ gtk_symbolic_color_unref (shade);
+ bg_rgba.alpha = alpha;
+ gdk_cairo_set_source_rgba (cr, &bg_rgba);
if (PANEL_HAS_FLAG (priv->borders, PANEL_BORDER_BOTTOM))
{
@@ -606,8 +616,14 @@ panel_base_window_expose_event (GtkWidget *widget,
if (PANEL_HAS_FLAG (priv->borders, PANEL_BORDER_TOP | PANEL_BORDER_LEFT))
{
/* use light color for top and left line */
- color = &(widget->style->light[GTK_STATE_NORMAL]);
- panel_util_set_source_rgba (cr, color, alpha);
+ gtk_style_context_get_background_color (ctx, GTK_STATE_NORMAL, &bg_rgba);
+ literal = gtk_symbolic_color_new_literal (&bg_rgba);
+ shade = gtk_symbolic_color_new_shade (literal, 1.3);
+ gtk_symbolic_color_unref (literal);
+ gtk_symbolic_color_resolve (shade, NULL, &bg_rgba);
+ gtk_symbolic_color_unref (shade);
+ bg_rgba.alpha = alpha;
+ gdk_cairo_set_source_rgba (cr, &bg_rgba);
if (PANEL_HAS_FLAG (priv->borders, PANEL_BORDER_LEFT))
{
@@ -625,8 +641,6 @@ panel_base_window_expose_event (GtkWidget *widget,
}
}
- cairo_destroy (cr);
-
return FALSE;
}
@@ -674,6 +688,7 @@ panel_base_window_composited_changed (GtkWidget *widget)
PanelBaseWindow *window = PANEL_BASE_WINDOW (widget);
gboolean was_composited = window->is_composited;
GdkWindow *gdkwindow;
+ GtkAllocation allocation;
/* set new compositing state */
window->is_composited = gtk_widget_is_composited (widget);
@@ -703,9 +718,10 @@ panel_base_window_composited_changed (GtkWidget *widget)
gdk_window_invalidate_rect (gdkwindow, NULL, TRUE);
/* HACK: invalid the geometry, so the wm notices it */
+ gtk_widget_get_allocation (widget, &allocation);
gtk_window_move (GTK_WINDOW (window),
- widget->allocation.x,
- widget->allocation.y);
+ allocation.x,
+ allocation.y);
gtk_widget_queue_resize (widget);
}
diff --git a/panel/panel-dialogs.c b/panel/panel-dialogs.c
index 5cec79c..dabea51 100644
--- a/panel/panel-dialogs.c
+++ b/panel/panel-dialogs.c
@@ -36,7 +36,7 @@
-#ifn GTK_CHECK_VERSION (3, 0, 0)
+#if !GTK_CHECK_VERSION (3, 0, 0)
static void
panel_dialogs_show_about_email_hook (GtkAboutDialog *dialog,
const gchar *uri,
@@ -78,7 +78,7 @@ panel_dialogs_show_about (void)
"Jasper Huijsmans <jasper at xfce.org>",
"Tic-tac-toe <tictactoe at xfce.org>");
-#ifn GTK_CHECK_VERSION (3, 0, 0)
+#if !GTK_CHECK_VERSION (3, 0, 0)
gtk_about_dialog_set_email_hook (panel_dialogs_show_about_email_hook, NULL, NULL);
#endif
@@ -161,7 +161,7 @@ panel_dialogs_choose_panel (PanelApplication *application)
/* setup the dialog */
dialog = gtk_dialog_new_with_buttons (_("Add New Item"), NULL,
- GTK_DIALOG_NO_SEPARATOR,
+ 0,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_ADD, GTK_RESPONSE_OK, NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
@@ -169,8 +169,8 @@ panel_dialogs_choose_panel (PanelApplication *application)
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
/* create widgets */
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox, FALSE, FALSE, 0);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), vbox, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
gtk_widget_show (vbox);
diff --git a/panel/panel-item-dialog.c b/panel/panel-item-dialog.c
index 170b67d..6ecb8b1 100644
--- a/panel/panel-item-dialog.c
+++ b/panel/panel-item-dialog.c
@@ -190,7 +190,6 @@ panel_item_dialog_init (PanelItemDialog *dialog)
xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (dialog),
_("Add new plugins to the panel"));
gtk_window_set_icon_name (GTK_WINDOW (dialog), GTK_STOCK_ADD);
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
gtk_window_set_default_size (GTK_WINDOW (dialog), 350, 450);
gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_NORMAL);
@@ -202,13 +201,13 @@ panel_item_dialog_init (PanelItemDialog *dialog)
gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
- main_vbox = gtk_vbox_new (FALSE, BORDER * 2);
- gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), main_vbox);
+ main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, BORDER * 2);
+ gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), main_vbox);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), BORDER);
gtk_widget_show (main_vbox);
/* search widget */
- hbox = gtk_hbox_new (FALSE, BORDER);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, BORDER);
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
diff --git a/panel/panel-itembar.c b/panel/panel-itembar.c
index 8440462..52233ab 100644
--- a/panel/panel-itembar.c
+++ b/panel/panel-itembar.c
@@ -38,42 +38,48 @@ typedef struct _PanelItembarChild PanelItembarChild;
-static void panel_itembar_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void panel_itembar_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void panel_itembar_finalize (GObject *object);
-static void panel_itembar_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void panel_itembar_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static gboolean panel_itembar_expose_event (GtkWidget *widget,
- GdkEventExpose *event);
-static void panel_itembar_add (GtkContainer *container,
- GtkWidget *child);
-static void panel_itembar_remove (GtkContainer *container,
- GtkWidget *child);
-static void panel_itembar_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-static GType panel_itembar_child_type (GtkContainer *container);
-static void panel_itembar_set_child_property (GtkContainer *container,
- GtkWidget *widget,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void panel_itembar_get_child_property (GtkContainer *container,
- GtkWidget *widget,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static PanelItembarChild *panel_itembar_get_child (PanelItembar *itembar,
- GtkWidget *widget);
+static void panel_itembar_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void panel_itembar_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void panel_itembar_finalize (GObject *object);
+static void panel_itembar_size_request (GtkWidget *widget,
+ GtkRequisition *requisition);
+static void panel_itembar_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width);
+static void panel_itembar_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height);
+static void panel_itembar_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
+static gboolean panel_itembar_draw (GtkWidget *widget,
+ cairo_t *cr);
+static void panel_itembar_add (GtkContainer *container,
+ GtkWidget *child);
+static void panel_itembar_remove (GtkContainer *container,
+ GtkWidget *child);
+static void panel_itembar_forall (GtkContainer *container,
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data);
+static GType panel_itembar_child_type (GtkContainer *container);
+static void panel_itembar_set_child_property (GtkContainer *container,
+ GtkWidget *widget,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void panel_itembar_get_child_property (GtkContainer *container,
+ GtkWidget *widget,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static PanelItembarChild *panel_itembar_get_child (PanelItembar *itembar,
+ GtkWidget *widget);
@@ -160,9 +166,10 @@ panel_itembar_class_init (PanelItembarClass *klass)
gobject_class->finalize = panel_itembar_finalize;
gtkwidget_class = GTK_WIDGET_CLASS (klass);
- gtkwidget_class->size_request = panel_itembar_size_request;
+ gtkwidget_class->get_preferred_width = panel_itembar_get_preferred_width;
+ gtkwidget_class->get_preferred_height = panel_itembar_get_preferred_height;
gtkwidget_class->size_allocate = panel_itembar_size_allocate;
- gtkwidget_class->expose_event = panel_itembar_expose_event;
+ gtkwidget_class->draw = panel_itembar_draw;
gtkcontainer_class = GTK_CONTAINER_CLASS (klass);
gtkcontainer_class->add = panel_itembar_add;
@@ -330,11 +337,11 @@ panel_itembar_size_request (GtkWidget *widget,
if (G_LIKELY (child != NULL))
{
- if (!GTK_WIDGET_VISIBLE (child->widget))
+ if (!gtk_widget_get_visible (child->widget))
continue;
/* get the child's size request */
- gtk_widget_size_request (child->widget, &child_req);
+ gtk_widget_get_preferred_size (child->widget, &child_req, NULL);
/* check if the small child fits in a row */
if (child->option == CHILD_OPTION_SMALL
@@ -377,7 +384,7 @@ panel_itembar_size_request (GtkWidget *widget,
rows_size = itembar->size * itembar->nrows;
/* return the total size */
- border_width = GTK_CONTAINER (widget)->border_width * 2;
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)) * 2;
if (IS_HORIZONTAL (itembar))
{
requisition->width = total_len + border_width;
@@ -393,6 +400,36 @@ panel_itembar_size_request (GtkWidget *widget,
static void
+panel_itembar_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
+{
+ GtkRequisition request;
+
+ panel_itembar_size_request (widget, &request);
+
+ *minimum_width = request.width;
+ *natural_width = request.width;
+}
+
+
+
+static void
+panel_itembar_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ GtkRequisition request;
+
+ panel_itembar_size_request (widget, &request);
+
+ *minimum_height = request.height;
+ *natural_height = request.height;
+}
+
+
+
+static void
panel_itembar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
@@ -416,9 +453,9 @@ panel_itembar_size_allocate (GtkWidget *widget,
/* the maximum allocation is limited by that of the
* panel window, so take over the assigned allocation */
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
- border_width = GTK_CONTAINER (widget)->border_width;
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
if (IS_HORIZONTAL (itembar))
itembar_len = allocation->width - 2 * border_width;
@@ -443,10 +480,10 @@ panel_itembar_size_allocate (GtkWidget *widget,
child = lp->data;
if (G_LIKELY (child != NULL))
{
- if (!GTK_WIDGET_VISIBLE (child->widget))
+ if (!gtk_widget_get_visible (child->widget))
continue;
- gtk_widget_get_child_requisition (child->widget, &child_req);
+ gtk_widget_get_preferred_size (child->widget, &child_req, NULL);
child_len = CHILD_LENGTH (child_req, itembar);
@@ -560,10 +597,10 @@ panel_itembar_size_allocate (GtkWidget *widget,
continue;
}
- if (!GTK_WIDGET_VISIBLE (child->widget))
+ if (!gtk_widget_get_visible (child->widget))
continue;
- gtk_widget_get_child_requisition (child->widget, &child_req);
+ gtk_widget_get_preferred_size (child->widget, &child_req, NULL);
child_len = CHILD_LENGTH (child_req, itembar);
@@ -680,17 +717,15 @@ panel_itembar_size_allocate (GtkWidget *widget,
static gboolean
-panel_itembar_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
+panel_itembar_draw (GtkWidget *widget,
+ cairo_t *cr)
{
PanelItembar *itembar = PANEL_ITEMBAR (widget);
gboolean result;
- cairo_t *cr;
- GdkWindow *window;
GdkRectangle rect;
gint row_size;
- result = (*GTK_WIDGET_CLASS (panel_itembar_parent_class)->expose_event) (widget, event);
+ result = (*GTK_WIDGET_CLASS (panel_itembar_parent_class)->draw) (widget, cr);
if (itembar->highlight_index != -1)
{
@@ -714,17 +749,10 @@ panel_itembar_expose_event (GtkWidget *widget,
}
/* draw highlight box */
- window = gtk_widget_get_window (widget);
- cr = gdk_cairo_create (window);
cairo_set_source_rgb (cr, 1.00, 0.00, 0.00);
- gdk_cairo_rectangle (cr, &event->area);
- cairo_clip (cr);
-
gdk_cairo_rectangle (cr, &rect);
cairo_fill (cr);
-
- cairo_destroy (cr);
}
return result;
@@ -750,7 +778,7 @@ panel_itembar_remove (GtkContainer *container,
panel_return_if_fail (PANEL_IS_ITEMBAR (itembar));
panel_return_if_fail (GTK_IS_WIDGET (widget));
- panel_return_if_fail (widget->parent == GTK_WIDGET (container));
+ panel_return_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (container));
panel_return_if_fail (itembar->children != NULL);
child = panel_itembar_get_child (itembar, widget);
@@ -898,7 +926,7 @@ panel_itembar_get_child (PanelItembar *itembar,
panel_return_val_if_fail (PANEL_IS_ITEMBAR (itembar), NULL);
panel_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
- panel_return_val_if_fail (widget->parent == GTK_WIDGET (itembar), NULL);
+ panel_return_val_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (itembar), NULL);
for (li = itembar->children; li != NULL; li = g_slist_next (li))
{
@@ -930,7 +958,7 @@ panel_itembar_insert (PanelItembar *itembar,
panel_return_if_fail (PANEL_IS_ITEMBAR (itembar));
panel_return_if_fail (GTK_IS_WIDGET (widget));
- panel_return_if_fail (widget->parent == NULL);
+ panel_return_if_fail (gtk_widget_get_parent (widget) == NULL);
child = g_slice_new0 (PanelItembarChild);
child->widget = widget;
@@ -954,7 +982,7 @@ panel_itembar_reorder_child (PanelItembar *itembar,
panel_return_if_fail (PANEL_IS_ITEMBAR (itembar));
panel_return_if_fail (GTK_IS_WIDGET (widget));
- panel_return_if_fail (widget->parent == GTK_WIDGET (itembar));
+ panel_return_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (itembar));
child = panel_itembar_get_child (itembar, widget);
if (G_LIKELY (child != NULL))
@@ -980,7 +1008,7 @@ panel_itembar_get_child_index (PanelItembar *itembar,
panel_return_val_if_fail (PANEL_IS_ITEMBAR (itembar), -1);
panel_return_val_if_fail (GTK_IS_WIDGET (widget), -1);
- panel_return_val_if_fail (widget->parent == GTK_WIDGET (itembar), -1);
+ panel_return_val_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (itembar), -1);
for (idx = 0, li = itembar->children; li != NULL; li = g_slist_next (li), idx++)
{
@@ -1028,7 +1056,7 @@ panel_itembar_get_drop_index (PanelItembar *itembar,
panel_return_val_if_fail (PANEL_IS_ITEMBAR (itembar), 0);
/* add the itembar position */
- alloc = GTK_WIDGET (itembar)->allocation;
+ gtk_widget_get_allocation (GTK_WIDGET (itembar), &alloc);
if (!IS_HORIZONTAL (itembar))
{
@@ -1054,7 +1082,7 @@ panel_itembar_get_drop_index (PanelItembar *itembar,
continue;
panel_assert (child->widget != NULL);
- alloc = child->widget->allocation;
+ gtk_widget_get_allocation (child->widget, &alloc);
if (!IS_HORIZONTAL (itembar))
TRANSPOSE_AREA (alloc);
@@ -1081,9 +1109,9 @@ panel_itembar_get_drop_index (PanelItembar *itembar,
panel_assert (child2->widget != NULL);
col_end_idx++;
if (IS_HORIZONTAL (itembar))
- col_width = MAX (col_width, child2->widget->allocation.width);
+ col_width = MAX (col_width, gtk_widget_get_allocated_width (child2->widget));
else
- col_width = MAX (col_width, child2->widget->allocation.height);
+ col_width = MAX (col_width, gtk_widget_get_allocated_height (child2->widget));
}
}
diff --git a/panel/panel-plugin-external-46.c b/panel/panel-plugin-external-46.c
index 3e2c335..ca2a2e0 100644
--- a/panel/panel-plugin-external-46.c
+++ b/panel/panel-plugin-external-46.c
@@ -184,7 +184,7 @@ panel_plugin_external_46_get_argv (PanelPluginExternal *external,
argv[PLUGIN_ARGV_0] = g_strdup (panel_module_get_filename (external->module));
argv[PLUGIN_ARGV_FILENAME] = g_strdup (""); /* unused, for wrapper only */
argv[PLUGIN_ARGV_UNIQUE_ID] = g_strdup_printf ("%d", external->unique_id);;
- argv[PLUGIN_ARGV_SOCKET_ID] = g_strdup_printf ("%u", gtk_socket_get_id (GTK_SOCKET (external)));;
+ argv[PLUGIN_ARGV_SOCKET_ID] = g_strdup_printf ("%lu", gtk_socket_get_id (GTK_SOCKET (external)));;
argv[PLUGIN_ARGV_NAME] = g_strdup (panel_module_get_name (external->module));
argv[PLUGIN_ARGV_DISPLAY_NAME] = g_strdup (panel_module_get_display_name (external->module));
argv[PLUGIN_ARGV_COMMENT] = g_strdup (panel_module_get_comment (external->module));
@@ -221,12 +221,12 @@ panel_plugin_external_46_set_properties (PanelPluginExternal *external,
panel_return_if_fail (panel_atom != GDK_NONE);
panel_return_if_fail (PANEL_IS_MODULE (external->module));
- if (!GTK_WIDGET_REALIZED (external))
+ if (!gtk_widget_get_realized (GTK_WIDGET (external)))
return;
event.type = GDK_CLIENT_EVENT;
- panel_return_if_fail (GDK_IS_WINDOW (GTK_WIDGET (external)->window));
- event.window = GTK_WIDGET (external)->window;
+ panel_return_if_fail (GDK_IS_WINDOW (gtk_widget_get_window (GTK_WIDGET (external))));
+ event.window = gtk_widget_get_window (GTK_WIDGET (external));
event.send_event = TRUE;
event.message_type = panel_atom;
event.data_format = 16;
diff --git a/panel/panel-plugin-external-wrapper.c b/panel/panel-plugin-external-wrapper.c
index a97e90e..7260252 100644
--- a/panel/panel-plugin-external-wrapper.c
+++ b/panel/panel-plugin-external-wrapper.c
@@ -220,7 +220,7 @@ panel_plugin_external_wrapper_get_argv (PanelPluginExternal *external,
argv[PLUGIN_ARGV_0] = g_strdup (WRAPPER_BIN);
argv[PLUGIN_ARGV_FILENAME] = g_strdup (panel_module_get_filename (external->module));
argv[PLUGIN_ARGV_UNIQUE_ID] = g_strdup_printf ("%d", external->unique_id);;
- argv[PLUGIN_ARGV_SOCKET_ID] = g_strdup_printf ("%u", gtk_socket_get_id (GTK_SOCKET (external)));;
+ argv[PLUGIN_ARGV_SOCKET_ID] = g_strdup_printf ("%lu", gtk_socket_get_id (GTK_SOCKET (external)));;
argv[PLUGIN_ARGV_NAME] = g_strdup (panel_module_get_name (external->module));
argv[PLUGIN_ARGV_DISPLAY_NAME] = g_strdup (panel_module_get_display_name (external->module));
argv[PLUGIN_ARGV_COMMENT] = g_strdup (panel_module_get_comment (external->module));
diff --git a/panel/panel-plugin-external.c b/panel/panel-plugin-external.c
index 0c4bc6c..3debd5c 100644
--- a/panel/panel-plugin-external.c
+++ b/panel/panel-plugin-external.c
@@ -521,7 +521,7 @@ panel_plugin_external_child_spawn (PanelPluginExternal *external)
GTimeVal timestamp;
panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (external));
- panel_return_if_fail (GTK_WIDGET_REALIZED (external));
+ panel_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (external)));
/* set plugin specific arguments */
argv = (*PANEL_PLUGIN_EXTERNAL_GET_CLASS (external)->get_argv) (external, external->priv->arguments);
@@ -639,7 +639,7 @@ panel_plugin_external_child_respawn (gpointer user_data)
panel_return_val_if_fail (PANEL_IS_PLUGIN_EXTERNAL (external), FALSE);
/* abort startup if the plugin is not realized */
- if (!GTK_WIDGET_REALIZED (external))
+ if (!gtk_widget_get_realized (GTK_WIDGET (external)))
return FALSE;
/* delay startup if the old child is still embedded */
@@ -760,7 +760,7 @@ panel_plugin_external_child_watch (GPid pid,
}
}
- if (GTK_WIDGET_REALIZED (external)
+ if (gtk_widget_get_realized (GTK_WIDGET (external))
&& (auto_restart || panel_plugin_external_child_ask_restart (external)))
{
panel_plugin_external_child_respawn_schedule (external);
@@ -1082,7 +1082,7 @@ panel_plugin_external_set_sensitive (PanelPluginExternal *external)
panel_return_if_fail (PANEL_IS_PLUGIN_EXTERNAL (external));
g_value_init (&value, G_TYPE_BOOLEAN);
- g_value_set_boolean (&value, GTK_WIDGET_IS_SENSITIVE (external));
+ g_value_set_boolean (&value, gtk_widget_is_sensitive (GTK_WIDGET (external)));
panel_plugin_external_queue_add (external, PROVIDER_PROP_TYPE_SET_SENSITIVE,
&value);
diff --git a/panel/panel-plugin-external.h b/panel/panel-plugin-external.h
index 5163447..afa591d 100644
--- a/panel/panel-plugin-external.h
+++ b/panel/panel-plugin-external.h
@@ -20,6 +20,7 @@
#define __PANEL_PLUGIN_EXTERNAL_H__
#include <gtk/gtk.h>
+#include <gtk/gtkx.h>
#include <libxfce4panel/libxfce4panel.h>
#include <libxfce4panel/xfce-panel-plugin-provider.h>
#include <panel/panel-module.h>
diff --git a/panel/panel-preferences-dialog.c b/panel/panel-preferences-dialog.c
index 6a131c5..49e905c 100644
--- a/panel/panel-preferences-dialog.c
+++ b/panel/panel-preferences-dialog.c
@@ -1309,8 +1309,8 @@ panel_preferences_dialog_plug_deleted (GtkWidget *plug)
static void
-panel_preferences_dialog_show_internal (PanelWindow *active,
- GdkNativeWindow socket_window)
+panel_preferences_dialog_show_internal (PanelWindow *active,
+ Window socket_window)
{
gint panel_id = 0;
GObject *window, *combo;
@@ -1419,12 +1419,12 @@ panel_preferences_dialog_show_from_id (gint panel_id,
{
PanelApplication *application;
PanelWindow *window;
- GdkNativeWindow socket_window = 0;
+ Window socket_window = 0;
/* x11 windows are ulong on 64 bit platforms
* or uint32 on other platforms */
if (socket_id != NULL)
- socket_window = (GdkNativeWindow) strtoul (socket_id, NULL, 0);
+ socket_window = (Window) strtoul (socket_id, NULL, 0);
application = panel_application_get ();
window = panel_application_get_window (application, panel_id);
diff --git a/panel/panel-tic-tac-toe.c b/panel/panel-tic-tac-toe.c
index 87d757a..704b8b2 100644
--- a/panel/panel-tic-tac-toe.c
+++ b/panel/panel-tic-tac-toe.c
@@ -105,7 +105,7 @@ static void
panel_tic_tac_toe_init (PanelTicTacToe *dialog)
{
GtkWidget *button;
- GtkWidget *table;
+ GtkWidget *grid;
GtkWidget *separator;
guint i;
GtkWidget *label;
@@ -118,54 +118,54 @@ panel_tic_tac_toe_init (PanelTicTacToe *dialog)
gtk_window_set_title (GTK_WINDOW (dialog), "Tic-tac-toe");
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
gtk_window_set_icon_name (GTK_WINDOW (dialog), "applications-games");
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
button = xfce_gtk_button_new_mixed (GTK_STOCK_NEW, _("_New Game"));
gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_ACCEPT);
gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
- vbox = gtk_vbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox, TRUE, TRUE, 0);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), vbox, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
- hbox = gtk_hbox_new (FALSE, 12);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
label = gtk_label_new_with_mnemonic (_("_Level:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- dialog->level = combo = gtk_combo_box_new_text ();
+ dialog->level = combo = gtk_combo_box_text_new ();
gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
- gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Novice"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Intermediate"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Experienced"));
- gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Expert"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Novice"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Intermediate"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Experienced"));
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), _("Expert"));
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), LEVEL_EXPERIENCED);
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_box_pack_start (GTK_BOX (vbox), align, TRUE, TRUE, 0);
- table = gtk_table_new (5, 5, FALSE);
- gtk_table_set_col_spacings (GTK_TABLE (table), 1);
- gtk_table_set_row_spacings (GTK_TABLE (table), 1);
- gtk_container_add (GTK_CONTAINER (align), table);
+ grid = gtk_grid_new ();
+ gtk_grid_set_column_spacing (GTK_GRID (grid), 1);
+ gtk_grid_set_row_spacing (GTK_GRID (grid), 1);
+ gtk_container_add (GTK_CONTAINER (align), grid);
- separator = gtk_hseparator_new ();
- gtk_table_attach (GTK_TABLE (table), separator, 0, 5, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
- separator = gtk_hseparator_new ();
- gtk_table_attach (GTK_TABLE (table), separator, 0, 5, 3, 4, GTK_FILL, GTK_FILL, 0, 0);
- separator = gtk_vseparator_new ();
- gtk_table_attach (GTK_TABLE (table), separator, 1, 2, 0, 5, GTK_FILL, GTK_FILL, 0, 0);
- separator = gtk_vseparator_new ();
- gtk_table_attach (GTK_TABLE (table), separator, 3, 4, 0, 5, GTK_FILL, GTK_FILL, 0, 0);
+ separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+ gtk_grid_attach (GTK_GRID (grid), separator, 0, 5, 1, 2);
+ separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+ gtk_grid_attach (GTK_GRID (grid), separator, 0, 5, 3, 4);
+ separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
+ gtk_grid_attach (GTK_GRID (grid), separator, 1, 2, 0, 5);
+ separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
+ gtk_grid_attach (GTK_GRID (grid), separator, 3, 4, 0, 5);
for (i = 0; i < 9; i++)
{
button = dialog->buttons[i] = gtk_button_new ();
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
gtk_widget_set_size_request (button, 70, 70);
- GTK_WIDGET_UNSET_FLAGS (button, GTK_CAN_DEFAULT | GTK_CAN_FOCUS);
+ gtk_widget_set_can_default (button, FALSE);
+ gtk_widget_set_can_focus (button, FALSE);
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (panel_tic_tac_toe_button_clicked), dialog);
@@ -175,12 +175,9 @@ panel_tic_tac_toe_init (PanelTicTacToe *dialog)
row = (i / 3) * 2;
col = (i % 3) * 2;
- gtk_table_attach (GTK_TABLE (table), button,
- col, col + 1,
- row, row + 1,
- GTK_EXPAND | GTK_FILL,
- GTK_EXPAND | GTK_FILL,
- 0, 0);
+ gtk_grid_attach (GTK_GRID (grid), button,
+ col, col + 1,
+ row, row + 1);
}
/* set label attributes */
diff --git a/panel/panel-window.c b/panel/panel-window.c
index 93964ed..339e1c7 100644
--- a/panel/panel-window.c
+++ b/panel/panel-window.c
@@ -85,8 +85,8 @@ static void panel_window_set_property (GObject *o
const GValue *value,
GParamSpec *pspec);
static void panel_window_finalize (GObject *object);
-static gboolean panel_window_expose_event (GtkWidget *widget,
- GdkEventExpose *event);
+static gboolean panel_window_draw (GtkWidget *widget,
+ cairo_t *cr);
static gboolean panel_window_delete_event (GtkWidget *widget,
GdkEventAny *event);
static gboolean panel_window_enter_notify_event (GtkWidget *widget,
@@ -109,8 +109,12 @@ static gboolean panel_window_button_release_event (GtkWidget *w
GdkEventButton *event);
static void panel_window_grab_notify (GtkWidget *widget,
gboolean was_grabbed);
-static void panel_window_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
+static void panel_window_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width);
+static void panel_window_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height);
static void panel_window_size_allocate (GtkWidget *widget,
GtkAllocation *alloc);
static void panel_window_size_allocate_set_xy (PanelWindow *window,
@@ -336,7 +340,7 @@ panel_window_class_init (PanelWindowClass *klass)
gobject_class->finalize = panel_window_finalize;
gtkwidget_class = GTK_WIDGET_CLASS (klass);
- gtkwidget_class->expose_event = panel_window_expose_event;
+ gtkwidget_class->draw = panel_window_draw;
gtkwidget_class->delete_event = panel_window_delete_event;
gtkwidget_class->enter_notify_event = panel_window_enter_notify_event;
gtkwidget_class->leave_notify_event = panel_window_leave_notify_event;
@@ -346,7 +350,8 @@ panel_window_class_init (PanelWindowClass *klass)
gtkwidget_class->button_press_event = panel_window_button_press_event;
gtkwidget_class->button_release_event = panel_window_button_release_event;
gtkwidget_class->grab_notify = panel_window_grab_notify;
- gtkwidget_class->size_request = panel_window_size_request;
+ gtkwidget_class->get_preferred_width = panel_window_get_preferred_width;
+ gtkwidget_class->get_preferred_height = panel_window_get_preferred_height;
gtkwidget_class->size_allocate = panel_window_size_allocate;
gtkwidget_class->screen_changed = panel_window_screen_changed;
gtkwidget_class->style_set = panel_window_style_set;
@@ -750,22 +755,24 @@ panel_window_finalize (GObject *object)
static gboolean
-panel_window_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
+panel_window_draw (GtkWidget *widget,
+ cairo_t *cr)
{
- PanelWindow *window = PANEL_WINDOW (widget);
- cairo_t *cr;
- GdkColor *color;
- guint xx, yy, i;
- gint xs, xe, ys, ye;
- gint handle_w, handle_h;
- gdouble alpha = 1.00;
- GtkWidget *child;
+ PanelWindow *window = PANEL_WINDOW (widget);
+ GdkRGBA bg_rgba, light_rgba, dark_rgba;
+ GtkSymbolicColor *literal;
+ GtkSymbolicColor *shade;
+ guint xx, yy, i;
+ gint xs, xe, ys, ye;
+ gint handle_w, handle_h;
+ gdouble alpha = 1.00;
+ GtkWidget *child;
+ GtkStyleContext *ctx;
/* expose the background and borders handled in PanelBaseWindow */
- (*GTK_WIDGET_CLASS (panel_window_parent_class)->expose_event) (widget, event);
+ (*GTK_WIDGET_CLASS (panel_window_parent_class)->draw) (widget, cr);
- if (window->position_locked || !GTK_WIDGET_DRAWABLE (widget))
+ if (window->position_locked || !gtk_widget_is_drawable (widget))
goto end;
if (IS_HORIZONTAL (window))
@@ -776,11 +783,6 @@ panel_window_expose_event (GtkWidget *widget,
xs = HANDLE_SPACING + 1;
xe = window->alloc.width - HANDLE_SIZE - HANDLE_SIZE;
ys = ye = (window->alloc.height - handle_h) / 2;
-
- /* dirty check if we have to redraw the handles */
- if (event->area.x > xs + HANDLE_SIZE
- && event->area.x + event->area.width < xe)
- goto end;
}
else
{
@@ -790,35 +792,36 @@ panel_window_expose_event (GtkWidget *widget,
xs = xe = (window->alloc.width - handle_w) / 2;
ys = HANDLE_SPACING + 1;
ye = window->alloc.height - HANDLE_SIZE - HANDLE_SIZE;
-
- /* dirty check if we have to redraw the handles */
- if (event->area.y > ys + HANDLE_SIZE
- && event->area.y + event->area.height < ye)
- goto end;
}
/* create cairo context and set some default properties */
- cr = gdk_cairo_create (widget->window);
- panel_return_val_if_fail (cr != NULL, FALSE);
cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- /* clip the drawing area */
- gdk_cairo_rectangle (cr, &event->area);
- cairo_clip (cr);
-
/* alpha color */
if (PANEL_BASE_WINDOW (window)->is_composited)
alpha = MAX (0.50, PANEL_BASE_WINDOW (window)->background_alpha);
+ ctx = gtk_widget_get_style_context (widget);
+ gtk_style_context_get_background_color (ctx, GTK_STATE_NORMAL, &bg_rgba);
+ literal = gtk_symbolic_color_new_literal (&bg_rgba);
+ shade = gtk_symbolic_color_new_shade (literal, 1.3);
+ gtk_symbolic_color_resolve (shade, NULL, &light_rgba);
+ gtk_symbolic_color_unref (shade);
+ shade = gtk_symbolic_color_new_shade (literal, 0.7);
+ gtk_symbolic_color_resolve (shade, NULL, &dark_rgba);
+ gtk_symbolic_color_unref (shade);
+ gtk_symbolic_color_unref (literal);
+ light_rgba.alpha = alpha;
+ dark_rgba.alpha = alpha;
+
for (i = HANDLE_PIXELS; i >= HANDLE_PIXELS - 1; i--)
{
/* set the source color */
if (i == HANDLE_PIXELS)
- color = &(widget->style->light[GTK_STATE_NORMAL]);
+ gdk_cairo_set_source_rgba (cr, &light_rgba);
else
- color = &(widget->style->dark[GTK_STATE_NORMAL]);
- panel_util_set_source_rgba (cr, color, alpha);
+ gdk_cairo_set_source_rgba (cr, &dark_rgba);
/* draw the dots */
for (xx = 0; xx < (guint) handle_w; xx += HANDLE_PIXELS + HANDLE_PIXEL_SPACE)
@@ -832,13 +835,11 @@ panel_window_expose_event (GtkWidget *widget,
cairo_fill (cr);
}
- cairo_destroy (cr);
-
end:
/* send the expose event to the child */
child = gtk_bin_get_child (GTK_BIN (widget));
if (G_LIKELY (child != NULL))
- gtk_container_propagate_expose (GTK_CONTAINER (widget), child, event);
+ gtk_container_propagate_draw (GTK_CONTAINER (widget), child, cr);
return FALSE;
}
@@ -1015,7 +1016,7 @@ panel_window_button_press_event (GtkWidget *widget,
guint modifiers;
/* leave if the event is not for this window */
- if (event->window != widget->window)
+ if (event->window != gtk_widget_get_window (widget))
goto end;
modifiers = event->state & gtk_accelerator_get_default_mod_mask ();
@@ -1155,26 +1156,26 @@ panel_window_grab_notify (GtkWidget *widget,
static void
-panel_window_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+panel_window_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
{
PanelWindow *window = PANEL_WINDOW (widget);
- GtkRequisition child_requisition = { 0, 0 };
+ gint m_width = 0;
+ gint n_width = 0;
gint length;
- gint extra_width = 0, extra_height = 0;
+ gint extra_width = 0;
PanelBorders borders;
/* get the child requisition */
- if (GTK_BIN (widget)->child != NULL)
- gtk_widget_size_request (GTK_BIN (widget)->child, &child_requisition);
+ if (gtk_bin_get_child (GTK_BIN (widget)) != NULL)
+ gtk_widget_get_preferred_width (gtk_bin_get_child (GTK_BIN (widget)), &m_width, &n_width);
/* handle size */
if (!window->position_locked)
{
if (IS_HORIZONTAL (window))
extra_width += 2 * HANDLE_SIZE_TOTAL;
- else
- extra_height += 2 * HANDLE_SIZE_TOTAL;
}
/* get the active borders */
@@ -1183,31 +1184,77 @@ panel_window_size_request (GtkWidget *widget,
extra_width++;
if (PANEL_HAS_FLAG (borders, PANEL_BORDER_RIGHT))
extra_width++;
- if (PANEL_HAS_FLAG (borders, PANEL_BORDER_TOP))
- extra_height++;
- if (PANEL_HAS_FLAG (borders, PANEL_BORDER_BOTTOM))
- extra_height++;
- requisition->height = child_requisition.height + extra_height;
- requisition->width = child_requisition.width + extra_width;
+ m_width += extra_width;
+ n_width += extra_width;
/* respect the length and monitor/screen size */
if (IS_HORIZONTAL (window))
{
if (!window->length_adjust)
- requisition->width = extra_width;
+ {
+ m_width = n_width = extra_width;
+ }
length = window->area.width * window->length;
- requisition->width = CLAMP (requisition->width, length, window->area.width);
+ m_width = CLAMP (m_width, length, window->area.width);
+ n_width = CLAMP (n_width, length, window->area.width);
}
- else
+
+ *minimum_width = m_width;
+ *natural_width = n_width;
+}
+
+
+
+static void
+panel_window_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ PanelWindow *window = PANEL_WINDOW (widget);
+ gint m_height = 0;
+ gint n_height = 0;
+ gint length;
+ gint extra_height = 0;
+ PanelBorders borders;
+
+ /* get the child requisition */
+ if (gtk_bin_get_child (GTK_BIN (widget)) != NULL)
+ gtk_widget_get_preferred_height (gtk_bin_get_child (GTK_BIN (widget)), &m_height, &n_height);
+
+ /* handle size */
+ if (!window->position_locked)
+ {
+ if (!IS_HORIZONTAL (window))
+ extra_height += 2 * HANDLE_SIZE_TOTAL;
+ }
+
+ /* get the active borders */
+ borders = panel_base_window_get_borders (PANEL_BASE_WINDOW (window));
+ if (PANEL_HAS_FLAG (borders, PANEL_BORDER_TOP))
+ extra_height++;
+ if (PANEL_HAS_FLAG (borders, PANEL_BORDER_BOTTOM))
+ extra_height++;
+
+ m_height += extra_height;
+ n_height += extra_height;
+
+ /* respect the length and monitor/screen size */
+ if (!IS_HORIZONTAL (window))
{
if (!window->length_adjust)
- requisition->height = extra_height;
+ {
+ m_height = n_height = extra_height;
+ }
length = window->area.height * window->length;
- requisition->height = CLAMP (requisition->height, length, window->area.height);
+ m_height = CLAMP (m_height, length, window->area.height);
+ n_height = CLAMP (n_height, length, window->area.height);
}
+
+ *minimum_height = m_height;
+ *natural_height = n_height;
}
@@ -1222,7 +1269,7 @@ panel_window_size_allocate (GtkWidget *widget,
PanelBorders borders;
GtkWidget *child;
- widget->allocation = *alloc;
+ gtk_widget_set_allocation (widget, alloc);
window->alloc = *alloc;
if (G_UNLIKELY (window->autohide_state == AUTOHIDE_HIDDEN
@@ -1554,7 +1601,7 @@ panel_window_screen_struts_set (PanelWindow *window)
panel_return_if_fail (cardinal_atom != 0 && net_wm_strut_partial_atom != 0);
panel_return_if_fail (GDK_IS_SCREEN (window->screen));
- if (!GTK_WIDGET_REALIZED (window))
+ if (!gtk_widget_get_realized (GTK_WIDGET (window)))
return;
/* set the struts */
@@ -1608,15 +1655,15 @@ panel_window_screen_struts_set (PanelWindow *window)
gdk_error_trap_push ();
/* set the wm strut partial */
- panel_return_if_fail (GDK_IS_WINDOW (GTK_WIDGET (window)->window));
- gdk_property_change (GTK_WIDGET (window)->window,
+ panel_return_if_fail (GDK_IS_WINDOW (gtk_widget_get_window (GTK_WIDGET (window))));
+ gdk_property_change (gtk_widget_get_window (GTK_WIDGET (window)),
net_wm_strut_partial_atom,
cardinal_atom, 32, GDK_PROP_MODE_REPLACE,
(guchar *) &struts, N_STRUTS);
#if SET_OLD_WM_STRUTS
/* set the wm strut (old window managers) */
- gdk_property_change (GTK_WIDGET (window)->window,
+ gdk_property_change (gtk_widget_get_window (GTK_WIDGET (window)),
net_wm_strut_atom,
cardinal_atom, 32, GDK_PROP_MODE_REPLACE,
(guchar *) &struts, 4);
@@ -1808,11 +1855,9 @@ panel_window_display_layout_debug (GtkWidget *widget)
if (panel_debug_has_domain (PANEL_DEBUG_DISPLAY_LAYOUT))
{
- g_string_append_printf (str, "{comp=%s, sys=%p:%p, rgba=%p:%p}",
+ g_string_append_printf (str, "{comp=%s, sys=%p, rgba=%p}",
PANEL_DEBUG_BOOL (gdk_screen_is_composited (screen)),
- gdk_screen_get_system_colormap (screen),
gdk_screen_get_system_visual (screen),
- gdk_screen_get_rgba_colormap (screen),
gdk_screen_get_rgba_visual (screen));
}
@@ -1923,7 +1968,7 @@ panel_window_screen_layout_changed (GdkScreen *screen,
window, screen_num);
/* out of range, hide the window */
- if (GTK_WIDGET_VISIBLE (window))
+ if (gtk_widget_get_visible (GTK_WIDGET (window)))
gtk_widget_hide (GTK_WIDGET (window));
return;
}
@@ -2011,7 +2056,7 @@ panel_window_screen_layout_changed (GdkScreen *screen,
window, window->output_name);
/* hide the panel if the monitor was not found */
- if (GTK_WIDGET_VISIBLE (window))
+ if (gtk_widget_get_visible (GTK_WIDGET (window)))
gtk_widget_hide (GTK_WIDGET (window));
return;
}
@@ -2080,7 +2125,7 @@ panel_window_screen_layout_changed (GdkScreen *screen,
if (force_struts_update)
panel_window_screen_struts_set (window);
- if (!GTK_WIDGET_VISIBLE (window))
+ if (!gtk_widget_get_visible (GTK_WIDGET (window)))
gtk_widget_show (GTK_WIDGET (window));
}
@@ -2742,20 +2787,20 @@ panel_window_focus (PanelWindow *window)
XClientMessageEvent event;
panel_return_if_fail (PANEL_IS_WINDOW (window));
- panel_return_if_fail (GTK_WIDGET_REALIZED (window));
+ panel_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (window)));
/* we need a slightly custom version of the call through Gtk+ to
* properly focus the panel when a plugin calls
* xfce_panel_plugin_focus_widget() */
event.type = ClientMessage;
- event.window = GDK_WINDOW_XID (GTK_WIDGET (window)->window);
+ event.window = GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (window)));
event.message_type = gdk_x11_get_xatom_by_name ("_NET_ACTIVE_WINDOW");
event.format = 32;
event.data.l[0] = 0;
gdk_error_trap_push ();
- XSendEvent (GDK_DISPLAY (), GDK_ROOT_WINDOW (), False,
+ XSendEvent (gdk_x11_get_default_xdisplay (), GDK_ROOT_WINDOW (), False,
StructureNotifyMask, (XEvent *) &event);
gdk_flush ();
More information about the Xfce4-commits
mailing list