X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=tests%2Ftestellipsise.c;h=5680e1321601167a49dc26dfdba447eb20f5b7b4;hb=HEAD;hp=805998c1c0db030a4dad7ea4f10667621c18bb7b;hpb=edd57602b881f45253e00706d2aed51470fce413;p=~andy%2Fgtk
diff --git a/tests/testellipsise.c b/tests/testellipsise.c
index 805998c1c..5680e1321 100644
--- a/tests/testellipsise.c
+++ b/tests/testellipsise.c
@@ -12,8 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * License along with this library. If not, see .Free
*/
/*
@@ -64,30 +63,27 @@ scale_changed_cb (GtkRange *range,
}
static gboolean
-ebox_expose_event_cb (GtkWidget *widget,
- GdkEventExpose *event,
- gpointer data)
+ebox_draw_cb (GtkWidget *widget,
+ cairo_t *cr,
+ gpointer data)
{
PangoLayout *layout;
const double dashes[] = { 6, 18 };
+ GtkAllocation label_allocation;
GtkRequisition minimum_size, natural_size;
GtkWidget *label = data;
- cairo_t *cr;
gint x, y;
- cr = gdk_cairo_create (widget->window);
cairo_translate (cr, -0.5, -0.5);
cairo_set_line_width (cr, 1);
cairo_set_source_rgb (cr, 1, 1, 1);
- cairo_rectangle (cr, 0, 0, widget->allocation.width, widget->allocation.height);
- cairo_fill (cr);
+ cairo_paint (cr);
gtk_widget_translate_coordinates (label, widget, 0, 0, &x, &y);
layout = gtk_widget_create_pango_layout (widget, "");
- gtk_size_request_get_size (GTK_SIZE_REQUEST (label),
- &minimum_size, &natural_size);
+ gtk_widget_get_preferred_size (label, &minimum_size, &natural_size);
pango_layout_set_markup (layout,
"\342\227\217 requisition\n"
@@ -97,29 +93,29 @@ ebox_expose_event_cb (GtkWidget *widget,
pango_cairo_show_layout (cr, layout);
g_object_unref (layout);
+ gtk_widget_get_allocation (label, &label_allocation);
+
cairo_rectangle (cr,
- x + 0.5 * (label->allocation.width - minimum_size.width),
- y + 0.5 * (label->allocation.height - minimum_size.height),
+ x + 0.5 * (label_allocation.width - minimum_size.width),
+ y + 0.5 * (label_allocation.height - minimum_size.height),
minimum_size.width, minimum_size.height);
cairo_set_source_rgb (cr, 0.8, 0.2, 0.2);
cairo_set_dash (cr, NULL, 0, 0);
cairo_stroke (cr);
- cairo_rectangle (cr, x, y, label->allocation.width, label->allocation.height);
+ cairo_rectangle (cr, x, y, label_allocation.width, label_allocation.height);
cairo_set_source_rgb (cr, 0.2, 0.2, 0.8);
cairo_set_dash (cr, dashes, 2, 0.5);
cairo_stroke (cr);
cairo_rectangle (cr,
- x + 0.5 * (label->allocation.width - natural_size.width),
- y + 0.5 * (label->allocation.height - natural_size.height),
+ x + 0.5 * (label_allocation.width - natural_size.width),
+ y + 0.5 * (label_allocation.height - natural_size.height),
natural_size.width, natural_size.height);
cairo_set_source_rgb (cr, 0.2, 0.8, 0.2);
cairo_set_dash (cr, dashes, 2, 12.5);
cairo_stroke (cr);
- cairo_destroy (cr);
-
return FALSE;
}
@@ -136,17 +132,18 @@ main (int argc, char *argv[])
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
- vbox = gtk_vbox_new (FALSE, 6);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_container_add (GTK_CONTAINER (window), vbox);
- combo = gtk_combo_box_new_text ();
- scale = gtk_hscale_new_with_range (0, 360, 1);
+ combo = gtk_combo_box_text_new ();
+ scale = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
+ 0, 360, 1);
label = gtk_label_new ("This label may be ellipsized\nto make it fit.");
- gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "NONE");
- gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "START");
- gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "MIDDLE");
- gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "END");
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "NONE");
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "START");
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "MIDDLE");
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "END");
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
@@ -164,7 +161,7 @@ main (int argc, char *argv[])
g_signal_connect (combo, "changed", G_CALLBACK (combo_changed_cb), label);
g_signal_connect (scale, "value-changed", G_CALLBACK (scale_changed_cb), label);
- g_signal_connect (ebox, "expose-event", G_CALLBACK (ebox_expose_event_cb), label);
+ g_signal_connect (ebox, "draw", G_CALLBACK (ebox_draw_cb), label);
gtk_widget_show_all (window);