#include "gtkprivate.h"
#include "gtkintl.h"
-#include "gtkalias.h"
#define DEFAULT_ICON_SIZE GTK_ICON_SIZE_SMALL_TOOLBAR
#define DEFAULT_ORIENTATION GTK_ORIENTATION_VERTICAL
gtk_tool_palette_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
- const gint border_width = GTK_CONTAINER (widget)->border_width;
GtkToolPalette *palette = GTK_TOOL_PALETTE (widget);
GtkRequisition child_requisition;
+ guint border_width;
guint i;
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
requisition->width = 0;
requisition->height = 0;
gtk_tool_palette_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
- const gint border_width = GTK_CONTAINER (widget)->border_width;
GtkToolPalette *palette = GTK_TOOL_PALETTE (widget);
GtkAdjustment *adjustment = NULL;
GtkAllocation child_allocation;
gint page_start, page_size = 0;
gint offset = 0;
guint i;
+ guint border_width;
gint min_offset = -1, max_offset = -1;
gint *group_sizes = g_newa (gint, palette->priv->groups->len);
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
GtkTextDirection direction = gtk_widget_get_direction (widget);
GTK_WIDGET_CLASS (gtk_tool_palette_parent_class)->size_allocate (widget, allocation);
{
GtkToolPalette *palette = GTK_TOOL_PALETTE (widget);
GdkDisplay *display;
+ GdkWindow *window;
cairo_t *cr;
guint i;
- display = gdk_drawable_get_display (widget->window);
+ window = gtk_widget_get_window (widget);
+
+ display = gdk_drawable_get_display (window);
if (!gdk_display_supports_composite (display))
return FALSE;
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (window);
gdk_cairo_region (cr, event->region);
cairo_clip (cr);
static void
gtk_tool_palette_realize (GtkWidget *widget)
{
- const gint border_width = GTK_CONTAINER (widget)->border_width;
- gint attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+ GtkAllocation allocation;
+ GdkWindow *window;
GdkWindowAttr attributes;
+ gint attributes_mask;
+ guint border_width;
+
+ gtk_widget_set_realized (widget, TRUE);
+
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
+ gtk_widget_get_allocation (widget, &allocation);
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x + border_width;
- attributes.y = widget->allocation.y + border_width;
- attributes.width = widget->allocation.width - border_width * 2;
- attributes.height = widget->allocation.height - border_width * 2;
+ attributes.x = allocation.x + border_width;
+ attributes.y = allocation.y + border_width;
+ attributes.width = allocation.width - border_width * 2;
+ attributes.height = allocation.height - border_width * 2;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
- attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK
- | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
- | GDK_BUTTON_MOTION_MASK;
+ attributes.event_mask = gtk_widget_get_events (widget)
+ | GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK
+ | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
+ | GDK_BUTTON_MOTION_MASK;
+ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gdk_window_set_user_data (window, widget);
- gdk_window_set_user_data (widget->window, widget);
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+ gtk_widget_style_attach (widget);
+ gtk_style_set_background (gtk_widget_get_style (widget),
+ window, GTK_STATE_NORMAL);
gtk_container_forall (GTK_CONTAINER (widget),
(GtkCallback) gtk_widget_set_parent_window,
- widget->window);
+ window);
gtk_widget_queue_resize_no_redraw (widget);
}
gtk_tool_palette_adjustment_value_changed (GtkAdjustment *adjustment,
gpointer data)
{
+ GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (data);
- gtk_tool_palette_size_allocate (widget, &widget->allocation);
+
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_tool_palette_size_allocate (widget, &allocation);
}
static void
switch (prop_id)
{
case CHILD_PROP_EXCLUSIVE:
- gtk_tool_palette_set_exclusive (palette, child, g_value_get_boolean (value));
+ gtk_tool_palette_set_exclusive (palette, GTK_TOOL_ITEM_GROUP (child),
+ g_value_get_boolean (value));
break;
case CHILD_PROP_EXPAND:
- gtk_tool_palette_set_expand (palette, child, g_value_get_boolean (value));
+ gtk_tool_palette_set_expand (palette, GTK_TOOL_ITEM_GROUP (child),
+ g_value_get_boolean (value));
break;
default:
switch (prop_id)
{
case CHILD_PROP_EXCLUSIVE:
- g_value_set_boolean (value, gtk_tool_palette_get_exclusive (palette, child));
+ g_value_set_boolean (value,
+ gtk_tool_palette_get_exclusive (palette, GTK_TOOL_ITEM_GROUP (child)));
break;
case CHILD_PROP_EXPAND:
- g_value_set_boolean (value, gtk_tool_palette_get_expand (palette, child));
+ g_value_set_boolean (value,
+ gtk_tool_palette_get_expand (palette, GTK_TOOL_ITEM_GROUP (child)));
break;
default:
* Since: 2.20
*/
void
-gtk_tool_palette_set_group_position (GtkToolPalette *palette,
- GtkWidget *group,
- gint position)
+gtk_tool_palette_set_group_position (GtkToolPalette *palette,
+ GtkToolItemGroup *group,
+ gint position)
{
GtkToolItemGroupInfo *group_new;
GtkToolItemGroupInfo *group_old;
* Since: 2.20
*/
void
-gtk_tool_palette_set_exclusive (GtkToolPalette *palette,
- GtkWidget *group,
- gboolean exclusive)
+gtk_tool_palette_set_exclusive (GtkToolPalette *palette,
+ GtkToolItemGroup *group,
+ gboolean exclusive)
{
GtkToolItemGroupInfo *group_info;
gint position;
}
gtk_tool_palette_group_notify_collapsed (group_info->widget, NULL, palette);
- gtk_widget_child_notify (group, "exclusive");
+ gtk_widget_child_notify (GTK_WIDGET (group), "exclusive");
}
/**
* Since: 2.20
*/
void
-gtk_tool_palette_set_expand (GtkToolPalette *palette,
- GtkWidget *group,
+gtk_tool_palette_set_expand (GtkToolPalette *palette,
+ GtkToolItemGroup *group,
gboolean expand)
{
GtkToolItemGroupInfo *group_info;
{
group_info->expand = expand;
gtk_widget_queue_resize (GTK_WIDGET (palette));
- gtk_widget_child_notify (group, "expand");
+ gtk_widget_child_notify (GTK_WIDGET (group), "expand");
}
}
* Since: 2.20
*/
gint
-gtk_tool_palette_get_group_position (GtkToolPalette *palette,
- GtkWidget *group)
+gtk_tool_palette_get_group_position (GtkToolPalette *palette,
+ GtkToolItemGroup *group)
{
guint i;
* Since: 2.20
*/
gboolean
-gtk_tool_palette_get_exclusive (GtkToolPalette *palette,
- GtkWidget *group)
+gtk_tool_palette_get_exclusive (GtkToolPalette *palette,
+ GtkToolItemGroup *group)
{
gint position;
GtkToolItemGroupInfo *info;
* Since: 2.20
*/
gboolean
-gtk_tool_palette_get_expand (GtkToolPalette *palette,
- GtkWidget *group)
+gtk_tool_palette_get_expand (GtkToolPalette *palette,
+ GtkToolItemGroup *group)
{
gint position;
GtkToolItemGroupInfo *info;
gint x,
gint y)
{
- GtkWidget *group = gtk_tool_palette_get_drop_group (palette, x, y);
+ GtkAllocation allocation;
+ GtkToolItemGroup *group = gtk_tool_palette_get_drop_group (palette, x, y);
+ GtkWidget *widget = GTK_WIDGET (group);
if (group)
- return gtk_tool_item_group_get_drop_item (GTK_TOOL_ITEM_GROUP (group),
- x - group->allocation.x,
- y - group->allocation.y);
+ {
+ gtk_widget_get_allocation (widget, &allocation);
+ return gtk_tool_item_group_get_drop_item (group,
+ x - allocation.x,
+ y - allocation.y);
+ }
return NULL;
}
*
* Since: 2.20
*/
-GtkWidget*
+GtkToolItemGroup*
gtk_tool_palette_get_drop_group (GtkToolPalette *palette,
gint x,
gint y)
{
- GtkAllocation *allocation;
+ GtkAllocation allocation;
guint i;
g_return_val_if_fail (GTK_IS_TOOL_PALETTE (palette), NULL);
- allocation = >K_WIDGET (palette)->allocation;
+ gtk_widget_get_allocation (GTK_WIDGET (palette), &allocation);
- g_return_val_if_fail (x >= 0 && x < allocation->width, NULL);
- g_return_val_if_fail (y >= 0 && y < allocation->height, NULL);
+ g_return_val_if_fail (x >= 0 && x < allocation.width, NULL);
+ g_return_val_if_fail (y >= 0 && y < allocation.height, NULL);
for (i = 0; i < palette->priv->groups->len; ++i)
{
continue;
widget = GTK_WIDGET (group->widget);
+ gtk_widget_get_allocation (widget, &allocation);
- x0 = x - widget->allocation.x;
- y0 = y - widget->allocation.y;
+ x0 = x - allocation.x;
+ y0 = y - allocation.y;
- if (x0 >= 0 && x0 < widget->allocation.width &&
- y0 >= 0 && y0 < widget->allocation.height)
- return widget;
+ if (x0 >= 0 && x0 < allocation.width &&
+ y0 >= 0 && y0 < allocation.height)
+ return GTK_TOOL_ITEM_GROUP (widget);
}
return NULL;
return palette->priv->text_size_group;
}
-
-
-#define __GTK_TOOL_PALETTE_C__
-#include "gtkaliasdef.c"