on_alpha_window_expose (GtkWidget *widget,
GdkEventExpose *expose)
{
+ GtkAllocation allocation;
cairo_t *cr;
cairo_pattern_t *pattern;
int radius;
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
- radius = MIN (widget->allocation.width, widget->allocation.height) / 2;
- pattern = cairo_pattern_create_radial (widget->allocation.width / 2,
- widget->allocation.height / 2,
+ gtk_widget_get_allocation (widget, &allocation);
+
+ radius = MIN (allocation.width, allocation.height) / 2;
+ pattern = cairo_pattern_create_radial (allocation.width / 2,
+ allocation.height / 2,
0.0,
- widget->allocation.width / 2,
- widget->allocation.height / 2,
+ allocation.width / 2,
+ allocation.height / 2,
radius * 1.33);
if (gdk_screen_get_rgba_colormap (gtk_widget_get_screen (widget)) &&
return table;
}
-static gboolean
-on_alpha_drawing_expose (GtkWidget *widget,
- GdkEventExpose *expose)
-{
- int x = widget->allocation.x;
- int y = widget->allocation.y;
- int width = widget->allocation.width;
- int height = widget->allocation.height;
- GdkPixbuf *pixbuf;
- guchar *buffer;
- guchar *p;
- int i, j;
-
- buffer = g_malloc (64 * 64 * 4);
-
- gdk_draw_rectangle (widget->window, widget->style->black_gc, FALSE,
- x, y,
- width - 1, height - 1);
-
- p = buffer;
- for (i = 0; i < 64; i++) {
- for (j = 0; j < 64; j++) {
- *(p++) = i * 4 + 3;
- *(p++) = 0;
- *(p++) = j + 4 + 3;
- *(p++) = MIN (255, ((32 - i) * (32 - i) + (32 - j) * (32 - j)) / 8);
- }
- }
- p++;
-
- gdk_draw_rgb_32_image (widget->window, widget->style->black_gc,
- x + 18, y + (height - 64) /2,
- 64, 64, GDK_RGB_DITHER_NORMAL, buffer, 64 * 4);
-
- pixbuf = gdk_pixbuf_new_from_data (buffer, GDK_COLORSPACE_RGB, TRUE,
- 8, 64, 64, 4 * 64, NULL, NULL);
-
- gdk_draw_pixbuf (widget->window, widget->style->black_gc, pixbuf,
- 0, 0, x + width - 18 - 64, y + (height - 64) /2,
- 64, 64, GDK_RGB_DITHER_NORMAL, 0, 0);
-
- g_object_unref (pixbuf);
-
- g_free (buffer);
-
- return FALSE;
-}
-
-static GtkWidget *
-build_alpha_drawing ()
-{
- GtkWidget *hbox;
-
- hbox = gtk_hbox_new (FALSE, 0);
- gtk_widget_set_size_request (hbox, 100, 100);
-
- g_signal_connect (hbox, "expose-event",
- G_CALLBACK (on_alpha_drawing_expose), NULL);
-
- return hbox;
-}
-
static void
on_alpha_screen_changed (GtkWidget *widget,
GdkScreen *old_screen,
if (!colormap)
{
- colormap = gdk_screen_get_rgb_colormap (screen);
+ colormap = gdk_screen_get_default_colormap (screen);
gtk_label_set_markup (GTK_LABEL (label), "<b>Screen doesn't support alpha</b>");
}
else
g_signal_connect (window, "composited_changed", G_CALLBACK (on_composited_changed), label);
gtk_box_pack_start (GTK_BOX (vbox), build_alpha_widgets (), TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), build_alpha_drawing (), TRUE, TRUE, 0);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed),
{
cairo_t *cr;
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
gdk_cairo_region (cr, event->region);
cairo_fill (cr);
window_expose_event (GtkWidget *widget,
GdkEventExpose *event)
{
+ GtkAllocation allocation;
cairo_region_t *region;
GtkWidget *child;
cairo_t *cr;
child = gtk_bin_get_child (GTK_BIN (widget));
/* create a cairo context to draw to the window */
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
+
+ gtk_widget_get_allocation (child, &allocation);
/* the source data is the (composited) event box */
- gdk_cairo_set_source_pixmap (cr, child->window,
- child->allocation.x,
- child->allocation.y);
+ gdk_cairo_set_source_pixmap (cr, gtk_widget_get_window (child),
+ allocation.x,
+ allocation.y);
/* draw no more than our expose event intersects our child */
- region = cairo_region_create_rectangle (&child->allocation);
+ region = cairo_region_create_rectangle (&allocation);
cairo_region_intersect (region, event->region);
gdk_cairo_region (cr, region);
cairo_clip (cr);
/* set the event box GdkWindow to be composited.
* obviously must be performed after event box is realised.
*/
- gdk_window_set_composited (event->window, TRUE);
+ gdk_window_set_composited (gtk_widget_get_window (event),
+ TRUE);
/* set up the compositing handler.
* note that we do _after so that the normal (red) background is drawn
color = g_object_get_data (G_OBJECT (window), "pattern-color");
if (color)
{
- GdkGC *tmp_gc = gdk_gc_new (window);
- gdk_gc_set_rgb_fg_color (tmp_gc, color);
+ cairo_t *cr = gdk_cairo_create (window);
- gdk_draw_rectangle (window, tmp_gc, TRUE,
- event->area.x, event->area.y,
- event->area.width, event->area.height);
+ gdk_cairo_set_source_color (cr, color);
+ gdk_cairo_rectangle (cr, &event->area);
+ cairo_fill (cr);
- g_object_unref (tmp_gc);
+ cairo_destroy (cr);
}
return FALSE;
if (gtk_widget_get_realized (darea))
{
- gdk_window_scroll (darea->window, *old_value - new_value, 0);
+ gdk_window_scroll (gtk_widget_get_window (darea),
+ *old_value - new_value, 0);
*old_value = new_value;
}
}
if (gtk_widget_get_realized (darea))
{
- gdk_window_scroll (darea->window, 0, *old_value - new_value);
+ gdk_window_scroll (gtk_widget_get_window (darea),
+ 0, *old_value - new_value);
*old_value = new_value;
}
}
pattern_realize (GtkWidget *widget,
gpointer data)
{
- pattern_set_bg (widget, widget->window, 0);
- create_pattern (widget, widget->window, 1, PATTERN_SIZE, PATTERN_SIZE);
+ GdkWindow *window;
+
+ window = gtk_widget_get_window (widget);
+ pattern_set_bg (widget, window, 0);
+ create_pattern (widget, window, 1, PATTERN_SIZE, PATTERN_SIZE);
}
static void
*/
static GtkWidget*
-new_pixmap (char *filename,
+new_pixbuf (char *filename,
GdkWindow *window,
GdkColor *background)
{
- GtkWidget *wpixmap;
- GdkPixmap *pixmap;
- GdkBitmap *mask;
+ GtkWidget *widget;
+ GdkPixbuf *pixbuf;
- if (strcmp (filename, "test.xpm") == 0 ||
- !file_exists (filename))
- {
- pixmap = gdk_pixmap_create_from_xpm_d (window, &mask,
- background,
- openfile);
- }
+ if (strcmp (filename, "test.xpm") == 0)
+ pixbuf = NULL;
else
- pixmap = gdk_pixmap_create_from_xpm (window, &mask,
- background,
- filename);
+ pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
+
+ if (pixbuf == NULL)
+ pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) openfile);
- wpixmap = gtk_image_new_from_pixmap (pixmap, mask);
+ widget = gtk_image_new_from_pixbuf (pixbuf);
- return wpixmap;
+ g_object_unref (pixbuf);
+
+ return widget;
}
{
GtkWidget *icon;
- icon = new_pixmap ("test.xpm", window->window,
- &window->style->bg[GTK_STATE_NORMAL]);
+ icon = new_pixbuf ("test.xpm", gtk_widget_get_window (window),
+ >k_widget_get_style (window)->bg[GTK_STATE_NORMAL]);
toolitem = gtk_tool_button_new (icon, create_toolbar_items[i].label);
}
if (create_toolbar_items[i].callback)
toolitem = gtk_separator_tool_item_new ();
continue;
}
- icon = new_pixmap ("test.xpm", window->window,
- &window->style->bg[GTK_STATE_NORMAL]);
+ icon = new_pixbuf ("test.xpm", gtk_widget_get_window (window),
+ >k_widget_get_style (window)->bg[GTK_STATE_NORMAL]);
toolitem = gtk_tool_button_new (icon, make_toolbar_items[i].label);
gtk_tool_item_set_tooltip_text (toolitem, make_toolbar_items[i].tooltip);
if (make_toolbar_items[i].callback != NULL)
guint context_id,
const gchar *text)
{
- if (!statusbar->messages)
+ if (!text)
statusbar_counter = 1;
}
gridded_geometry_expose (GtkWidget *widget,
GdkEventExpose *event)
{
+ GtkAllocation allocation;
+ GtkStateType state;
+ GtkStyle *style;
+ cairo_t *cr;
int i, j;
- gdk_draw_rectangle (widget->window, widget->style->base_gc[widget->state], TRUE,
- 0, 0, widget->allocation.width, widget->allocation.height);
-
- for (i = 0 ; i * GRID_SIZE < widget->allocation.width; i++)
- for (j = 0 ; j * GRID_SIZE < widget->allocation.height; j++)
+ gtk_widget_get_allocation (widget, &allocation);
+ style = gtk_widget_get_style (widget);
+ state = gtk_widget_get_state (widget);
+
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
+
+ cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
+ gdk_cairo_set_source_color (cr, &style->base[state]);
+ cairo_fill (cr);
+
+ for (i = 0 ; i * GRID_SIZE < allocation.width; i++)
+ for (j = 0 ; j * GRID_SIZE < allocation.height; j++)
{
if ((i + j) % 2 == 0)
- gdk_draw_rectangle (widget->window, widget->style->text_gc[widget->state], TRUE,
- i * GRID_SIZE, j * GRID_SIZE, GRID_SIZE, GRID_SIZE);
+ cairo_rectangle (cr, i * GRID_SIZE, j * GRID_SIZE, GRID_SIZE, GRID_SIZE);
}
+ gdk_cairo_set_source_color (cr, &style->text[state]);
+ cairo_fill (cr);
+
+ cairo_destroy (cr);
+
return FALSE;
}
gtk_widget_destroy (window);
}
-/*
- * Test for getting an image from a drawable
- */
-
-struct GetImageData
-{
- GtkWidget *src;
- GtkWidget *snap;
- GtkWidget *sw;
-};
-
-static void
-take_snapshot (GtkWidget *button,
- gpointer data)
-{
- struct GetImageData *gid = data;
- GdkRectangle visible;
- int width_fraction;
- int height_fraction;
- GdkGC *gc;
- GdkGC *black_gc;
- GdkColor color = { 0, 30000, 0, 0 };
- GdkRectangle target;
- GdkImage *shot;
-
- /* Do some begin_paint_rect on some random rects, draw some
- * distinctive stuff into those rects, then take the snapshot.
- * figure out whether any rects were overlapped and report to
- * user.
- */
-
- visible = gid->sw->allocation;
-
- visible.x = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (gid->sw))->value;
- visible.y = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (gid->sw))->value;
-
- width_fraction = visible.width / 4;
- height_fraction = visible.height / 4;
-
- gc = gdk_gc_new (gid->src->window);
- black_gc = gid->src->style->black_gc;
-
- gdk_gc_set_rgb_fg_color (gc, &color);
-
-
- target.x = visible.x + width_fraction;
- target.y = visible.y + height_fraction * 3;
- target.width = width_fraction;
- target.height = height_fraction / 2;
-
- gdk_window_begin_paint_rect (gid->src->window,
- &target);
-
- gdk_draw_rectangle (gid->src->window,
- gc,
- TRUE,
- target.x, target.y,
- target.width, target.height);
-
- gdk_draw_rectangle (gid->src->window,
- black_gc,
- FALSE,
- target.x + 10, target.y + 10,
- target.width - 20, target.height - 20);
-
- target.x = visible.x + width_fraction;
- target.y = visible.y + height_fraction;
- target.width = width_fraction;
- target.height = height_fraction;
-
- gdk_window_begin_paint_rect (gid->src->window,
- &target);
-
- gdk_draw_rectangle (gid->src->window,
- gc,
- TRUE,
- target.x, target.y,
- target.width, target.height);
-
- gdk_draw_rectangle (gid->src->window,
- black_gc,
- FALSE,
- target.x + 10, target.y + 10,
- target.width - 20, target.height - 20);
-
- target.x = visible.x + width_fraction * 3;
- target.y = visible.y + height_fraction;
- target.width = width_fraction / 2;
- target.height = height_fraction;
-
- gdk_window_begin_paint_rect (gid->src->window,
- &target);
-
- gdk_draw_rectangle (gid->src->window,
- gc,
- TRUE,
- target.x, target.y,
- target.width, target.height);
-
- gdk_draw_rectangle (gid->src->window,
- black_gc,
- FALSE,
- target.x + 10, target.y + 10,
- target.width - 20, target.height - 20);
-
- target.x = visible.x + width_fraction * 2;
- target.y = visible.y + height_fraction * 2;
- target.width = width_fraction / 4;
- target.height = height_fraction / 4;
-
- gdk_window_begin_paint_rect (gid->src->window,
- &target);
-
- gdk_draw_rectangle (gid->src->window,
- gc,
- TRUE,
- target.x, target.y,
- target.width, target.height);
-
- gdk_draw_rectangle (gid->src->window,
- black_gc,
- FALSE,
- target.x + 10, target.y + 10,
- target.width - 20, target.height - 20);
-
- target.x += target.width / 2;
- target.y += target.width / 2;
-
- gdk_window_begin_paint_rect (gid->src->window,
- &target);
-
- gdk_draw_rectangle (gid->src->window,
- gc,
- TRUE,
- target.x, target.y,
- target.width, target.height);
-
- gdk_draw_rectangle (gid->src->window,
- black_gc,
- FALSE,
- target.x + 10, target.y + 10,
- target.width - 20, target.height - 20);
-
- /* Screen shot area */
-
- target.x = visible.x + width_fraction * 1.5;
- target.y = visible.y + height_fraction * 1.5;
- target.width = width_fraction * 2;
- target.height = height_fraction * 2;
-
- shot = gdk_drawable_get_image (gid->src->window,
- target.x, target.y,
- target.width, target.height);
-
- gtk_image_set_from_image (GTK_IMAGE (gid->snap),
- shot, NULL);
-
- g_object_unref (shot);
-
- gdk_window_end_paint (gid->src->window);
- gdk_window_end_paint (gid->src->window);
- gdk_window_end_paint (gid->src->window);
- gdk_window_end_paint (gid->src->window);
- gdk_window_end_paint (gid->src->window);
-
- gdk_draw_rectangle (gid->src->window,
- gid->src->style->black_gc,
- FALSE,
- target.x, target.y,
- target.width, target.height);
-
- g_object_unref (gc);
-}
-
-static gint
-image_source_expose (GtkWidget *da,
- GdkEventExpose *event,
- gpointer data)
-{
- int x = event->area.x;
- GdkColor red = { 0, 65535, 0, 0 };
- GdkColor green = { 0, 0, 65535, 0 };
- GdkColor blue = { 0, 0, 0, 65535 };
- GdkGC *gc;
-
- gc = gdk_gc_new (event->window);
-
- while (x < (event->area.x + event->area.width))
- {
- switch (x % 7)
- {
- case 0:
- case 1:
- case 2:
- gdk_gc_set_rgb_fg_color (gc, &red);
- break;
-
- case 3:
- case 4:
- case 5:
- gdk_gc_set_rgb_fg_color (gc, &green);
- break;
-
- case 6:
- case 7:
- case 8:
- gdk_gc_set_rgb_fg_color (gc, &blue);
- break;
-
- default:
- g_assert_not_reached ();
- break;
- }
-
- gdk_draw_line (event->window,
- gc,
- x, event->area.y,
- x, event->area.y + event->area.height);
-
- ++x;
- }
-
- g_object_unref (gc);
-
- return TRUE;
-}
-
-static void
-create_get_image (GtkWidget *widget)
-{
- static GtkWidget *window = NULL;
-
- if (window)
- gtk_widget_destroy (window);
- else
- {
- GtkWidget *sw;
- GtkWidget *src;
- GtkWidget *snap;
- GtkWidget *hbox;
- GtkWidget *vbox;
- GtkWidget *button;
- struct GetImageData *gid;
-
- gid = g_new (struct GetImageData, 1);
-
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-
- gtk_window_set_screen (GTK_WINDOW (window),
- gtk_widget_get_screen (widget));
-
- g_signal_connect (window,
- "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &window);
-
- g_object_set_data_full (G_OBJECT (window),
- "testgtk-get-image-data",
- gid,
- g_free);
-
- hbox = gtk_hbox_new (FALSE, 0);
-
- gtk_container_add (GTK_CONTAINER (window), hbox);
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
-
- gid->sw = sw;
-
- gtk_widget_set_size_request (sw, 400, 400);
-
- src = gtk_drawing_area_new ();
- gtk_widget_set_size_request (src, 10000, 10000);
-
- g_signal_connect (src,
- "expose_event",
- G_CALLBACK (image_source_expose),
- gid);
-
- gid->src = src;
-
- gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw),
- src);
-
- gtk_box_pack_start (GTK_BOX (hbox),
- sw, TRUE, TRUE, 0);
-
-
- vbox = gtk_vbox_new (FALSE, 3);
-
- snap = g_object_new (GTK_TYPE_IMAGE, NULL);
-
- gid->snap = snap;
-
- sw = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
- GTK_POLICY_AUTOMATIC,
- GTK_POLICY_AUTOMATIC);
- gtk_widget_set_size_request (sw, 300, 300);
-
- gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), snap);
-
- gtk_box_pack_end (GTK_BOX (vbox), sw, FALSE, FALSE, 5);
-
- button = gtk_button_new_with_label ("Get image from drawable");
-
- g_signal_connect (button,
- "clicked",
- G_CALLBACK (take_snapshot),
- gid);
-
- gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
-
- gtk_box_pack_end (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
-
- gtk_widget_show_all (window);
- }
-}
-
/*
* Label Demo
*/
GdkEventExpose *event,
GdkPixbuf *tile_pixbuf)
{
+ GtkAllocation allocation;
static const gchar *words[] = { "The", "grand", "old", "Duke", "of", "York",
"had", "10,000", "men" };
- PangoRenderer *renderer;
- GdkGC *gc;
int n_words;
int i;
double radius;
- PangoMatrix matrix = PANGO_MATRIX_INIT;
PangoLayout *layout;
PangoContext *context;
PangoFontDescription *desc;
+ cairo_t *cr;
- gc = g_object_get_data (G_OBJECT (widget), "text-gc");
- if (!gc)
- {
- static GdkColor black = { 0, 0, 0, 0 };
-
- gc = gdk_gc_new (widget->window);
- gdk_gc_set_rgb_fg_color (gc, &black);
-
- if (tile_pixbuf)
- {
- GdkPixmap *tile;
-
- gint width = gdk_pixbuf_get_width (tile_pixbuf);
- gint height = gdk_pixbuf_get_height (tile_pixbuf);
-
- tile = gdk_pixmap_new (widget->window, width, height, -1);
- gdk_draw_pixbuf (tile, gc, tile_pixbuf,
- 0, 0, 0, 0, width, height,
- GDK_RGB_DITHER_NORMAL, 0, 0);
-
- gdk_gc_set_tile (gc, tile);
- gdk_gc_set_fill (gc, GDK_TILED);
-
- g_object_unref (tile);
- }
+ cr = gdk_cairo_create (event->window);
- g_object_set_data_full (G_OBJECT (widget), "text-gc", gc, (GDestroyNotify)g_object_unref);
+ if (tile_pixbuf)
+ {
+ gdk_cairo_set_source_pixbuf (cr, tile_pixbuf, 0, 0);
+ cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
}
+ else
+ cairo_set_source_rgb (cr, 0, 0, 0);
- renderer = gdk_pango_renderer_get_default (gtk_widget_get_screen (widget));
- gdk_pango_renderer_set_drawable (GDK_PANGO_RENDERER (renderer), widget->window);
- gdk_pango_renderer_set_gc (GDK_PANGO_RENDERER (renderer), gc);
+ gtk_widget_get_allocation (widget, &allocation);
- radius = MIN (widget->allocation.width, widget->allocation.height) / 2.;
+ radius = MIN (allocation.width, allocation.height) / 2.;
- pango_matrix_translate (&matrix,
- radius + (widget->allocation.width - 2 * radius) / 2,
- radius + (widget->allocation.height - 2 * radius) / 2);
- pango_matrix_scale (&matrix, radius / DEFAULT_TEXT_RADIUS, radius / DEFAULT_TEXT_RADIUS);
+ cairo_translate (cr,
+ radius + (allocation.width - 2 * radius) / 2,
+ radius + (allocation.height - 2 * radius) / 2);
+ cairo_scale (cr, radius / DEFAULT_TEXT_RADIUS, radius / DEFAULT_TEXT_RADIUS);
context = gtk_widget_get_pango_context (widget);
layout = pango_layout_new (context);
n_words = G_N_ELEMENTS (words);
for (i = 0; i < n_words; i++)
{
- PangoMatrix rotated_matrix = matrix;
int width, height;
-
- pango_matrix_rotate (&rotated_matrix, - (360. * i) / n_words);
- pango_context_set_matrix (context, &rotated_matrix);
- pango_layout_context_changed (layout);
+ cairo_save (cr);
+
+ cairo_rotate (cr, 2 * G_PI * i / n_words);
+ pango_cairo_update_layout (cr, layout);
+
pango_layout_set_text (layout, words[i], -1);
-
pango_layout_get_size (layout, &width, &height);
- pango_renderer_draw_layout (renderer, layout,
- - width / 2, - DEFAULT_TEXT_RADIUS * PANGO_SCALE);
- }
+ cairo_move_to (cr, - width / 2 / PANGO_SCALE, - DEFAULT_TEXT_RADIUS);
+ pango_cairo_show_layout (cr, layout);
- gdk_pango_renderer_set_drawable (GDK_PANGO_RENDERER (renderer), NULL);
- gdk_pango_renderer_set_gc (GDK_PANGO_RENDERER (renderer), NULL);
+ cairo_restore (cr);
+ }
g_object_unref (layout);
+ cairo_destroy (cr);
return FALSE;
}
GtkWidget *old_parent,
gpointer func_data)
{
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (child);
g_message ("set_parent for \"%s\": new parent: \"%s\", old parent: \"%s\", data: %d\n",
g_type_name (G_OBJECT_TYPE (child)),
- child->parent ? g_type_name (G_OBJECT_TYPE (child->parent)) : "NULL",
+ parent ? g_type_name (G_OBJECT_TYPE (parent)) : "NULL",
old_parent ? g_type_name (G_OBJECT_TYPE (old_parent)) : "NULL",
GPOINTER_TO_INT (func_data));
}
static gboolean
grippy_expose (GtkWidget *area, GdkEventExpose *event, GdkWindowEdge edge)
{
- gtk_paint_resize_grip (area->style,
- area->window,
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (area, &allocation);
+ gtk_paint_resize_grip (gtk_widget_get_style (area),
+ gtk_widget_get_window (area),
gtk_widget_get_state (area),
&event->area,
area,
"statusbar",
edge,
0, 0,
- area->allocation.width,
- area->allocation.height);
+ allocation.width, allocation.height);
return TRUE;
}
lx = g_object_get_data (G_OBJECT (window), "x");
ly = g_object_get_data (G_OBJECT (window), "y");
- gdk_window_get_root_origin (window->window, &upositionx, &upositiony);
+ gdk_window_get_root_origin (gtk_widget_get_window (window),
+ &upositionx, &upositiony);
sprintf (buffer, "%d", upositionx);
gtk_label_set_text (lx, buffer);
sprintf (buffer, "%d", upositiony);
*/
static void
-create_pixmap (GtkWidget *widget)
+create_pixbuf (GtkWidget *widget)
{
static GtkWidget *window = NULL;
GtkWidget *box1;
GtkWidget *button;
GtkWidget *label;
GtkWidget *separator;
- GtkWidget *pixmapwid;
+ GtkWidget *pixbufwid;
+ GdkWindow *gdk_window;
if (!window)
{
button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (box2), button, FALSE, FALSE, 0);
- pixmapwid = new_pixmap ("test.xpm", window->window, NULL);
+ gdk_window = gtk_widget_get_window (window);
- label = gtk_label_new ("Pixmap\ntest");
+ pixbufwid = new_pixbuf ("test.xpm", gdk_window, NULL);
+
+ label = gtk_label_new ("Pixbuf\ntest");
box3 = gtk_hbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (box3), 2);
- gtk_container_add (GTK_CONTAINER (box3), pixmapwid);
+ gtk_container_add (GTK_CONTAINER (box3), pixbufwid);
gtk_container_add (GTK_CONTAINER (box3), label);
gtk_container_add (GTK_CONTAINER (button), box3);
button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (box2), button, FALSE, FALSE, 0);
-
- pixmapwid = new_pixmap ("test.xpm", window->window, NULL);
- label = gtk_label_new ("Pixmap\ntest");
+ pixbufwid = new_pixbuf ("test.xpm", gdk_window, NULL);
+
+ label = gtk_label_new ("Pixbuf\ntest");
box3 = gtk_hbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (box3), 2);
- gtk_container_add (GTK_CONTAINER (box3), pixmapwid);
+ gtk_container_add (GTK_CONTAINER (box3), pixbufwid);
gtk_container_add (GTK_CONTAINER (box3), label);
gtk_container_add (GTK_CONTAINER (button), box3);
"GtkWindow::type", GTK_WINDOW_TOPLEVEL,
"GtkContainer::border_width", 0,
"GtkWindow::title", "Tooltips",
- "GtkWindow::allow_shrink", TRUE,
- "GtkWindow::allow_grow", FALSE,
+ "GtkWindow::resizable", FALSE,
NULL);
gtk_window_set_screen (GTK_WINDOW (window),
if (window == NULL)
{
GtkWidget *vbox;
- GdkPixmap *pixmap;
- GdkBitmap *mask;
+ GdkPixbuf *pixbuf;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
/* this is bogus for testing drawing when allocation < request,
* don't copy into real code
*/
- g_object_set (window, "allow_shrink", TRUE, "allow_grow", TRUE, NULL);
-
+ gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
+
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&window);
gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
GTK_ICON_SIZE_DIALOG));
- pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL,
- gtk_widget_get_colormap (window),
- &mask,
- NULL,
- openfile);
+ pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **) openfile);
- pack_image (vbox, "Pixmap",
- gtk_image_new_from_pixmap (pixmap, mask));
+ pack_image (vbox, "Pixbuf",
+ gtk_image_new_from_pixbuf (pixbuf));
+
+ g_object_unref (pixbuf);
}
if (!gtk_widget_get_visible (window))
}
else
{
- sw_parent = scrollwin->parent;
+ sw_parent = gtk_widget_get_parent (scrollwin);
sw_float_parent = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_screen (GTK_WINDOW (sw_float_parent),
gtk_widget_get_screen (widget));
if (GPOINTER_TO_INT (data) == 1)
sprintf (buf, "%d", gtk_spin_button_get_value_as_int (spin));
else
- sprintf (buf, "%0.*f", spin->digits, gtk_spin_button_get_value (spin));
+ sprintf (buf, "%0.*f",
+ gtk_spin_button_get_digits (spin),
+ gtk_spin_button_get_value (spin));
+
gtk_label_set_text (label, buf);
}
spin = GTK_SPIN_BUTTON (widget);
label = GTK_LABEL (data);
- buffer = g_strdup_printf ("%0.*f", spin->digits,
+ buffer = g_strdup_printf ("%0.*f",
+ gtk_spin_button_get_digits (spin),
gtk_spin_button_get_value (spin));
gtk_label_set_text (label, buffer);
static gint
spin_button_time_output_func (GtkSpinButton *spin_button)
{
+ GtkAdjustment *adjustment;
static gchar buf[6];
gdouble hours;
gdouble minutes;
- hours = spin_button->adjustment->value / 60.0;
+ adjustment = gtk_spin_button_get_adjustment (spin_button);
+ hours = gtk_adjustment_get_value (adjustment) / 60.0;
minutes = (fabs(floor (hours) - hours) < 1e-5) ? 0.0 : 30;
sprintf (buf, "%02.0f:%02.0f", floor (hours), minutes);
if (strcmp (buf, gtk_entry_get_text (GTK_ENTRY (spin_button))))
static gint
spin_button_month_output_func (GtkSpinButton *spin_button)
{
+ GtkAdjustment *adjustment;
+ gdouble value;
gint i;
static gchar *month[12] = { "January", "February", "March", "April",
"May", "June", "July", "August", "September",
"October", "November", "December" };
+ adjustment = gtk_spin_button_get_adjustment (spin_button);
+ value = gtk_adjustment_get_value (adjustment);
for (i = 1; i <= 12; i++)
- if (fabs (spin_button->adjustment->value - (double)i) < 1e-5)
+ if (fabs (value - (double)i) < 1e-5)
{
if (strcmp (month[i-1], gtk_entry_get_text (GTK_ENTRY (spin_button))))
gtk_entry_set_text (GTK_ENTRY (spin_button), month[i-1]);
static gint
spin_button_hex_output_func (GtkSpinButton *spin_button)
{
+ GtkAdjustment *adjustment;
static gchar buf[7];
gint val;
- val = (gint) spin_button->adjustment->value;
+ adjustment = gtk_spin_button_get_adjustment (spin_button);
+ val = (gint) gtk_adjustment_get_value (adjustment);
if (fabs (val) < 1e-5)
sprintf (buf, "0x00");
else
GdkEvent *event,
gpointer user_data)
{
+ GtkAllocation allocation;
GtkDrawingArea *darea;
GdkDrawable *drawable;
- GdkGC *black_gc;
- GdkGC *gray_gc;
- GdkGC *white_gc;
guint max_width;
guint max_height;
+ cairo_t *cr;
g_return_val_if_fail (widget != NULL, TRUE);
g_return_val_if_fail (GTK_IS_DRAWING_AREA (widget), TRUE);
darea = GTK_DRAWING_AREA (widget);
- drawable = widget->window;
- white_gc = widget->style->white_gc;
- gray_gc = widget->style->bg_gc[GTK_STATE_NORMAL];
- black_gc = widget->style->black_gc;
- max_width = widget->allocation.width;
- max_height = widget->allocation.height;
-
- gdk_draw_rectangle (drawable, white_gc,
- TRUE,
- 0,
- 0,
- max_width,
- max_height / 2);
-
- gdk_draw_rectangle (drawable, black_gc,
- TRUE,
- 0,
- max_height / 2,
- max_width,
- max_height / 2);
-
- gdk_draw_rectangle (drawable, gray_gc,
- TRUE,
- max_width / 3,
- max_height / 3,
- max_width / 3,
- max_height / 3);
+ drawable = gtk_widget_get_window (widget);
+
+ gtk_widget_get_allocation (widget, &allocation);
+ max_width = allocation.width;
+ max_height = allocation.height;
+
+ cr = gdk_cairo_create (drawable);
+
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_rectangle (cr, 0, 0, max_width, max_height / 2);
+ cairo_fill (cr);
+
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_rectangle (cr, 0, max_height / 2, max_width, max_height / 2);
+ cairo_fill (cr);
+
+ gdk_cairo_set_source_color (cr, >k_widget_get_style (widget)->bg[GTK_STATE_NORMAL]);
+ cairo_rectangle (cr, max_width / 3, max_height / 3, max_width / 3, max_height / 3);
+ cairo_fill (cr);
+
+ cairo_destroy (cr);
return TRUE;
}
g_type_class_unref (class);
cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), c);
- gdk_window_set_cursor (widget->window, cursor);
+ gdk_window_set_cursor (gtk_widget_get_window (widget),
+ cursor);
gdk_cursor_unref (cursor);
}
gtk_window_set_screen (GTK_WINDOW (window),
gtk_widget_get_screen (widget));
- g_object_set (window, "allow_shrink", TRUE, "allow_grow", TRUE, NULL);
+ gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed),
* GtkNotebook
*/
-static char * book_open_xpm[] = {
+static const char * book_open_xpm[] = {
"16 16 4 1",
" c None s None",
". c black",
" .. ",
" "};
-static char * book_closed_xpm[] = {
+static const char * book_closed_xpm[] = {
"16 16 6 1",
" c None s None",
". c black",
gtk_widget_realize (sample_notebook);
if (!book_open)
- book_open = gdk_pixbuf_new_from_xpm_data ((const char **)book_open_xpm);
+ book_open = gdk_pixbuf_new_from_xpm_data (book_open_xpm);
if (!book_closed)
- book_closed = gdk_pixbuf_new_from_xpm_data ((const char **)book_closed_xpm);
+ book_closed = gdk_pixbuf_new_from_xpm_data (book_closed_xpm);
create_pages (GTK_NOTEBOOK (sample_notebook), 1, 5);
const gchar *label1,
const gchar *label2)
{
+ GtkWidget *child1, *child2;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *label;
GtkWidget *button;
GtkWidget *check_button;
-
+
+ child1 = gtk_paned_get_child1 (paned);
+ child2 = gtk_paned_get_child2 (paned);
+
frame = gtk_frame_new (frame_label);
gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
0, 1, 1, 2);
g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_resize),
- paned->child1);
-
+ child1);
+
check_button = gtk_check_button_new_with_label ("Shrink");
gtk_table_attach_defaults (GTK_TABLE (table), check_button,
0, 1, 2, 3);
TRUE);
g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_shrink),
- paned->child1);
-
+ child1);
+
label = gtk_label_new (label2);
gtk_table_attach_defaults (GTK_TABLE (table), label,
1, 2, 0, 1);
TRUE);
g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_resize),
- paned->child2);
-
+ child2);
+
check_button = gtk_check_button_new_with_label ("Shrink");
gtk_table_attach_defaults (GTK_TABLE (table), check_button,
1, 2, 2, 3);
TRUE);
g_signal_connect (check_button, "toggled",
G_CALLBACK (toggle_shrink),
- paned->child2);
+ child2);
button = gtk_button_new_with_mnemonic ("_Properties");
gtk_table_attach_defaults (GTK_TABLE (table), button,
p->y = (int) event->y;
gtk_grab_add (widget);
- gdk_pointer_grab (widget->window, TRUE,
+ gdk_pointer_grab (gtk_widget_get_window (widget), TRUE,
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK,
gint window_type)
{
GtkWidget *window;
- GtkWidget *pixmap;
+ GtkWidget *image;
GtkWidget *fixed;
CursorOffset* icon_pos;
- GdkGC* gc;
- GdkBitmap *gdk_pixmap_mask;
- GdkPixmap *gdk_pixmap;
- GtkStyle *style;
-
- style = gtk_widget_get_default_style ();
- gc = style->black_gc;
+ GdkBitmap *mask;
+ GdkPixbuf *pixbuf;
/*
* GDK_WINDOW_TOPLEVEL works also, giving you a title border
GDK_BUTTON_PRESS_MASK);
gtk_widget_realize (window);
- gdk_pixmap = gdk_pixmap_create_from_xpm (window->window, &gdk_pixmap_mask,
- &style->bg[GTK_STATE_NORMAL],
- xpm_file);
- pixmap = gtk_image_new_from_pixmap (gdk_pixmap, gdk_pixmap_mask);
- gtk_fixed_put (GTK_FIXED (fixed), pixmap, px,py);
- gtk_widget_show (pixmap);
+ pixbuf = gdk_pixbuf_new_from_file (xpm_file, NULL);
+ g_assert (pixbuf); /* FIXME: error handling */
+
+ gdk_pixbuf_render_pixmap_and_mask_for_colormap (pixbuf,
+ gtk_widget_get_colormap (window),
+ NULL,
+ &mask,
+ 128);
+
+ image = gtk_image_new_from_pixbuf (pixbuf);
+ gtk_fixed_put (GTK_FIXED (fixed), image, px,py);
+ gtk_widget_show (image);
- gtk_widget_shape_combine_mask (window, gdk_pixmap_mask, px, py);
+ gtk_widget_shape_combine_mask (window, mask, px, py);
- g_object_unref (gdk_pixmap_mask);
- g_object_unref (gdk_pixmap);
+ g_object_unref (mask);
+ g_object_unref (pixbuf);
g_signal_connect (window, "button_press_event",
G_CALLBACK (shape_pressed), NULL);
x += 20;
}
- gdk_window_shape_combine_region (with_region->window,
+ gdk_window_shape_combine_region (gtk_widget_get_window (with_region),
region,
0, 0);
}
GtkWidget *button;
GtkWidget *box1;
GtkWidget *box2;
-
GdkBitmap *circles;
+ GdkWindow *gdk_window;
+ cairo_surface_t *image;
+ cairo_t *cr;
if (!window)
{
gtk_container_set_border_width (GTK_CONTAINER (window), 0);
gtk_widget_realize (window);
-
- circles = gdk_bitmap_create_from_data (window->window,
- (gchar *) circles_bits,
- circles_width,
- circles_height);
- gdk_window_set_icon (window->window, NULL,
+
+ gdk_window = gtk_widget_get_window (window);
+ circles = gdk_pixmap_new (gdk_window, circles_width, circles_height, 1);
+ cr = gdk_cairo_create (circles);
+ image = cairo_image_surface_create_for_data (circles_bits, CAIRO_FORMAT_A1,
+ circles_width, circles_height,
+ circles_width / 8);
+ cairo_set_source_surface (cr, image, 0, 0);
+ cairo_surface_destroy (image);
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+ cairo_paint (cr);
+ cairo_destroy (cr);
+
+ gdk_window_set_icon (gdk_window, NULL,
circles, circles);
-
- gdk_window_set_icon_name (window->window, "WMHints Test Icon");
-
- gdk_window_set_decorations (window->window, GDK_DECOR_ALL | GDK_DECOR_MENU);
- gdk_window_set_functions (window->window, GDK_FUNC_ALL | GDK_FUNC_RESIZE);
-
+
+ gdk_window_set_icon_name (gdk_window, "WMHints Test Icon");
+
+ gdk_window_set_decorations (gdk_window, GDK_DECOR_ALL | GDK_DECOR_MENU);
+ gdk_window_set_functions (gdk_window, GDK_FUNC_ALL | GDK_FUNC_RESIZE);
+
box1 = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), box1);
gtk_widget_show (box1);
GtkWidget *label = data;
gchar *msg;
- msg = g_strconcat (GTK_WINDOW (widget)->title, ": ",
+ msg = g_strconcat (gtk_window_get_title (GTK_WINDOW (widget)), ": ",
(event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN) ?
"withdrawn" : "not withdrawn", ", ",
(event->new_window_state & GDK_WINDOW_STATE_ICONIFIED) ?
}
static void
-allow_shrink_callback (GtkWidget *widget,
- gpointer data)
-{
- g_object_set (g_object_get_data (data, "target"),
- "allow_shrink",
- GTK_TOGGLE_BUTTON (widget)->active,
- NULL);
-}
-
-static void
-allow_grow_callback (GtkWidget *widget,
+resizable_callback (GtkWidget *widget,
gpointer data)
{
g_object_set (g_object_get_data (data, "target"),
- "allow_grow",
- GTK_TOGGLE_BUTTON (widget)->active,
+ "resizable", GTK_TOGGLE_BUTTON (widget)->active,
NULL);
}
G_CALLBACK (move_to_position_callback),
control_window);
gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
-
- button = gtk_check_button_new_with_label ("Allow shrink");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
- g_signal_connect (button,
- "toggled",
- G_CALLBACK (allow_shrink_callback),
- control_window);
- gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
- button = gtk_check_button_new_with_label ("Allow grow");
+ button = gtk_check_button_new_with_label ("Allow resize");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
g_signal_connect (button,
"toggled",
- G_CALLBACK (allow_grow_callback),
+ G_CALLBACK (resizable_callback),
control_window);
gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
i = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
- gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (pdata->pbar),
- (GtkProgressBarOrientation) i);
+ if (i == 0 || i == 1)
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (pdata->pbar), GTK_ORIENTATION_HORIZONTAL);
+ else
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (pdata->pbar), GTK_ORIENTATION_VERTICAL);
+
+ if (i == 1 || i == 2)
+ gtk_progress_bar_set_inverted (GTK_PROGRESS_BAR (pdata->pbar), TRUE);
+ else
+ gtk_progress_bar_set_inverted (GTK_PROGRESS_BAR (pdata->pbar), FALSE);
}
static void
gint x_offset = 0;
gint y_offset = 0;
- new_allocation = widget->allocation;
+ gtk_widget_get_allocation (widget, &new_allocation);
if (data->found || !gtk_widget_get_mapped (widget))
return;
new_allocation.x = 0;
new_allocation.y = 0;
}
-
- if (widget->parent && !data->first)
+
+ if (gtk_widget_get_parent (widget) && !data->first)
{
- GdkWindow *window = widget->window;
- while (window != widget->parent->window)
+ GdkWindow *window = gtk_widget_get_window (widget);
+ while (window != gtk_widget_get_window (gtk_widget_get_parent (widget)))
{
gint tx, ty, twidth, theight;
gdk_drawable_get_size (window, &twidth, &theight);
x_offset += tx;
new_allocation.y += ty;
y_offset += ty;
-
+
window = gdk_window_get_parent (window);
}
}
if (widget)
{
- gdk_window_get_pointer (widget->window,
+ gdk_window_get_pointer (gtk_widget_get_window (widget),
&x, &y, NULL);
data.x = x;
query_properties (GtkButton *button,
struct PropertiesData *data)
{
+ GtkWidget *widget = GTK_WIDGET (button);
gint failure;
g_signal_connect (button, "event",
if (!data->cursor)
- data->cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (button)),
+ data->cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
GDK_TARGET);
-
- failure = gdk_pointer_grab (GTK_WIDGET (button)->window,
+
+ failure = gdk_pointer_grab (gtk_widget_get_window (widget),
TRUE,
GDK_BUTTON_RELEASE_MASK,
NULL,
data->cursor,
GDK_CURRENT_TIME);
- gtk_grab_add (GTK_WIDGET (button));
+ gtk_grab_add (widget);
data->in_query = TRUE;
}
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
pixmap = gtk_widget_get_snapshot (res_widget, NULL);
gtk_widget_realize (window);
- if (gdk_drawable_get_depth (window->window) != gdk_drawable_get_depth (pixmap))
+ if (gdk_drawable_get_depth (gtk_widget_get_window (window)) != gdk_drawable_get_depth (pixmap))
{
/* this branch is needed to convert ARGB -> RGB */
int width, height;
snapshot_widget (GtkButton *button,
struct SnapshotData *data)
{
+ GtkWidget *widget = GTK_WIDGET (button);
gint failure;
g_signal_connect (button, "event",
G_CALLBACK (snapshot_widget_event), data);
- data->is_toplevel = GTK_WIDGET (button) == data->toplevel_button;
-
+ data->is_toplevel = widget == data->toplevel_button;
+
if (!data->cursor)
- data->cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (button)),
+ data->cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
GDK_TARGET);
-
- failure = gdk_pointer_grab (GTK_WIDGET (button)->window,
+
+ failure = gdk_pointer_grab (gtk_widget_get_window (widget),
TRUE,
GDK_BUTTON_RELEASE_MASK,
NULL,
data->cursor,
GDK_CURRENT_TIME);
- gtk_grab_add (GTK_WIDGET (button));
+ gtk_grab_add (widget);
data->in_query = TRUE;
}
scroll_test_expose (GtkWidget *widget, GdkEventExpose *event,
GtkAdjustment *adj)
{
+ GdkWindow *window;
gint i,j;
gint imin, imax, jmin, jmax;
+ cairo_t *cr;
imin = (event->area.x) / 10;
imax = (event->area.x + event->area.width + 9) / 10;
jmin = ((int)adj->value + event->area.y) / 10;
jmax = ((int)adj->value + event->area.y + event->area.height + 9) / 10;
- gdk_window_clear_area (widget->window,
+ window = gtk_widget_get_window (widget);
+
+ gdk_window_clear_area (window,
event->area.x, event->area.y,
event->area.width, event->area.height);
+ cr = gdk_cairo_create (window);
+
for (i=imin; i<imax; i++)
for (j=jmin; j<jmax; j++)
if ((i+j) % 2)
- gdk_draw_rectangle (widget->window,
- widget->style->black_gc,
- TRUE,
- 10*i, 10*j - (int)adj->value, 1+i%10, 1+j%10);
+ cairo_rectangle (cr, 10*i, 10*j - (int)adj->value, 1+i%10, 1+j%10);
+
+ cairo_fill (cr);
+
+ cairo_destroy (cr);
return TRUE;
}
scroll_test_configure (GtkWidget *widget, GdkEventConfigure *event,
GtkAdjustment *adj)
{
- adj->page_increment = 0.9 * widget->allocation.height;
- adj->page_size = widget->allocation.height;
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (widget, &allocation);
+ adj->page_increment = 0.9 * allocation.height;
+ adj->page_size = allocation.height;
g_signal_emit_by_name (adj, "changed");
}
static void
scroll_test_adjustment_changed (GtkAdjustment *adj, GtkWidget *widget)
{
- /* gint source_min = (int)adj->value - scroll_test_pos; */
+ GdkWindow *window;
gint dy;
dy = scroll_test_pos - (int)adj->value;
if (!gtk_widget_is_drawable (widget))
return;
- gdk_window_scroll (widget->window, 0, dy);
- gdk_window_process_updates (widget->window, FALSE);
+
+ window = gtk_widget_get_window (widget);
+ gdk_window_scroll (window, 0, dy);
+ gdk_window_process_updates (window, FALSE);
}
{
GtkLayout *layout;
GdkWindow *bin_window;
+ cairo_t *cr;
+
gint i,j;
gint imin, imax, jmin, jmax;
layout = GTK_LAYOUT (widget);
-
bin_window = gtk_layout_get_bin_window (layout);
if (event->window != bin_window)
jmin = (event->area.y) / 10;
jmax = (event->area.y + event->area.height + 9) / 10;
+ cr = gdk_cairo_create (bin_window);
+
for (i=imin; i<imax; i++)
for (j=jmin; j<jmax; j++)
if ((i+j) % 2)
- gdk_draw_rectangle (bin_window,
- widget->style->black_gc,
- TRUE,
- 10*i, 10*j,
- 1+i%10, 1+j%10);
+ cairo_rectangle (cr,
+ 10*i, 10*j,
+ 1+i%10, 1+j%10);
+ cairo_fill (cr);
+
+ cairo_destroy (cr);
+
return FALSE;
}
{ "font selection", create_font_selection },
{ "gridded geometry", create_gridded_geometry },
{ "handle box", create_handle_box },
- { "image from drawable", create_get_image },
{ "image", create_image },
{ "key lookup", create_key_lookup },
{ "labels", create_labels },
{ "notebook", create_notebook },
{ "panes", create_panes },
{ "paned keyboard", create_paned_keyboard_navigation },
- { "pixmap", create_pixmap },
+ { "pixbuf", create_pixbuf },
{ "progress bar", create_progress_bar },
{ "properties", create_properties },
{ "radio buttons", create_radio_buttons },