Commit 009212ad authored by Jonathan Blandford's avatar Jonathan Blandford Committed by Jonathan Blandford

It's the worlds ugliest highlighting code!!!! The result is okay so long

Thu May 17 16:20:04 2001  Jonathan Blandford  <jrb@redhat.com>

	* demos/gtk-demo/main.c (fontify): It's the worlds ugliest
	highlighting code!!!!  The result is okay so long as you don't try
	to stress it.  It also highlights a bug in the TextView so it's in
	an unproportional font right now until it's fixed.

	*demos/gtk-demo/*.c: Clean up code a bit to make it
	ugly-parser(TM) friendly. (-:
parent 288ff7e0
Thu May 17 16:20:04 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/main.c (fontify): It's the worlds ugliest
highlighting code!!!! The result is okay so long as you don't try
to stress it. It also highlights a bug in the TextView so it's in
an unproportional font right now until it's fixed.
*demos/gtk-demo/*.c: Clean up code a bit to make it
ugly-parser(TM) friendly. (-:
2001-05-17 Joe Shaw <joe@ximian.com>
* gtk/gtktextdisplay.c (gtk_text_layout_draw): Remove the assertions
......
Thu May 17 16:20:04 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/main.c (fontify): It's the worlds ugliest
highlighting code!!!! The result is okay so long as you don't try
to stress it. It also highlights a bug in the TextView so it's in
an unproportional font right now until it's fixed.
*demos/gtk-demo/*.c: Clean up code a bit to make it
ugly-parser(TM) friendly. (-:
2001-05-17 Joe Shaw <joe@ximian.com>
* gtk/gtktextdisplay.c (gtk_text_layout_draw): Remove the assertions
......
Thu May 17 16:20:04 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/main.c (fontify): It's the worlds ugliest
highlighting code!!!! The result is okay so long as you don't try
to stress it. It also highlights a bug in the TextView so it's in
an unproportional font right now until it's fixed.
*demos/gtk-demo/*.c: Clean up code a bit to make it
ugly-parser(TM) friendly. (-:
2001-05-17 Joe Shaw <joe@ximian.com>
* gtk/gtktextdisplay.c (gtk_text_layout_draw): Remove the assertions
......
Thu May 17 16:20:04 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/main.c (fontify): It's the worlds ugliest
highlighting code!!!! The result is okay so long as you don't try
to stress it. It also highlights a bug in the TextView so it's in
an unproportional font right now until it's fixed.
*demos/gtk-demo/*.c: Clean up code a bit to make it
ugly-parser(TM) friendly. (-:
2001-05-17 Joe Shaw <joe@ximian.com>
* gtk/gtktextdisplay.c (gtk_text_layout_draw): Remove the assertions
......
Thu May 17 16:20:04 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/main.c (fontify): It's the worlds ugliest
highlighting code!!!! The result is okay so long as you don't try
to stress it. It also highlights a bug in the TextView so it's in
an unproportional font right now until it's fixed.
*demos/gtk-demo/*.c: Clean up code a bit to make it
ugly-parser(TM) friendly. (-:
2001-05-17 Joe Shaw <joe@ximian.com>
* gtk/gtktextdisplay.c (gtk_text_layout_draw): Remove the assertions
......
Thu May 17 16:20:04 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/main.c (fontify): It's the worlds ugliest
highlighting code!!!! The result is okay so long as you don't try
to stress it. It also highlights a bug in the TextView so it's in
an unproportional font right now until it's fixed.
*demos/gtk-demo/*.c: Clean up code a bit to make it
ugly-parser(TM) friendly. (-:
2001-05-17 Joe Shaw <joe@ximian.com>
* gtk/gtktextdisplay.c (gtk_text_layout_draw): Remove the assertions
......
Thu May 17 16:20:04 2001 Jonathan Blandford <jrb@redhat.com>
* demos/gtk-demo/main.c (fontify): It's the worlds ugliest
highlighting code!!!! The result is okay so long as you don't try
to stress it. It also highlights a bug in the TextView so it's in
an unproportional font right now until it's fixed.
*demos/gtk-demo/*.c: Clean up code a bit to make it
ugly-parser(TM) friendly. (-:
2001-05-17 Joe Shaw <joe@ximian.com>
* gtk/gtktextdisplay.c (gtk_text_layout_draw): Remove the assertions
......
......@@ -7,7 +7,7 @@
static GtkWidget *
create_bbox (gint horizontal,
char* title,
char *title,
gint spacing,
gint layout)
{
......@@ -43,7 +43,7 @@ create_bbox (gint horizontal,
GtkWidget *
do_button_box (void)
{
static GtkWidget* window = NULL;
static GtkWidget *window = NULL;
GtkWidget *main_vbox;
GtkWidget *vbox;
GtkWidget *hbox;
......@@ -72,19 +72,19 @@ do_button_box (void)
gtk_container_add (GTK_CONTAINER (frame_horz), vbox);
gtk_box_pack_start (GTK_BOX (vbox),
create_bbox (TRUE, "Spread", 40, GTK_BUTTONBOX_SPREAD),
create_bbox (TRUE, "Spread", 40, GTK_BUTTONBOX_SPREAD),
TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox),
create_bbox (TRUE, "Edge", 40, GTK_BUTTONBOX_EDGE),
create_bbox (TRUE, "Edge", 40, GTK_BUTTONBOX_EDGE),
TRUE, TRUE, 5);
gtk_box_pack_start (GTK_BOX (vbox),
create_bbox (TRUE, "Start", 40, GTK_BUTTONBOX_START),
create_bbox (TRUE, "Start", 40, GTK_BUTTONBOX_START),
TRUE, TRUE, 5);
gtk_box_pack_start (GTK_BOX (vbox),
create_bbox (TRUE, "End", 40, GTK_BUTTONBOX_END),
create_bbox (TRUE, "End", 40, GTK_BUTTONBOX_END),
TRUE, TRUE, 5);
frame_vert = gtk_frame_new ("Vertical Button Boxes");
......@@ -95,19 +95,19 @@ do_button_box (void)
gtk_container_add (GTK_CONTAINER (frame_vert), hbox);
gtk_box_pack_start (GTK_BOX (hbox),
create_bbox (FALSE, "Spread", 30, GTK_BUTTONBOX_SPREAD),
create_bbox (FALSE, "Spread", 30, GTK_BUTTONBOX_SPREAD),
TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox),
create_bbox (FALSE, "Edge", 30, GTK_BUTTONBOX_EDGE),
create_bbox (FALSE, "Edge", 30, GTK_BUTTONBOX_EDGE),
TRUE, TRUE, 5);
gtk_box_pack_start (GTK_BOX (hbox),
create_bbox (FALSE, "Start", 30, GTK_BUTTONBOX_START),
create_bbox (FALSE, "Start", 30, GTK_BUTTONBOX_START),
TRUE, TRUE, 5);
gtk_box_pack_start (GTK_BOX (hbox),
create_bbox (FALSE, "End", 30, GTK_BUTTONBOX_END),
create_bbox (FALSE, "End", 30, GTK_BUTTONBOX_END),
TRUE, TRUE, 5);
}
......@@ -116,11 +116,10 @@ do_button_box (void)
gtk_widget_show_all (window);
}
else
{
{
gtk_widget_destroy (window);
window = NULL;
}
return window;
}
......@@ -14,7 +14,7 @@ static GtkWidget *frame;
static void
change_color_callback (GtkWidget *button,
gpointer data)
gpointer data)
{
GtkWidget *dialog;
GtkColorSelection *colorsel;
......@@ -35,7 +35,7 @@ change_color_callback (GtkWidget *button,
if (response == GTK_RESPONSE_OK)
{
gtk_color_selection_get_current_color (colorsel,
&color);
&color);
gtk_widget_modify_bg (da, GTK_STATE_NORMAL, &color);
}
......@@ -92,8 +92,8 @@ do_colorsel (void)
gtk_box_pack_start (GTK_BOX (vbox), alignment, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (change_color_callback),
NULL);
GTK_SIGNAL_FUNC (change_color_callback),
NULL);
}
if (!GTK_WIDGET_VISIBLE (window))
......
......@@ -10,7 +10,8 @@ static GtkWidget *entry1 = NULL;
static GtkWidget *entry2 = NULL;
static void
message_dialog_clicked (GtkButton *button, gpointer user_data)
message_dialog_clicked (GtkButton *button,
gpointer user_data)
{
GtkWidget *dialog;
static gint i = 1;
......@@ -28,7 +29,8 @@ message_dialog_clicked (GtkButton *button, gpointer user_data)
}
static void
interactive_dialog_clicked (GtkButton *button, gpointer user_data)
interactive_dialog_clicked (GtkButton *button,
gpointer user_data)
{
GtkWidget *dialog;
GtkWidget *hbox;
......@@ -59,7 +61,7 @@ interactive_dialog_clicked (GtkButton *button, gpointer user_data)
gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, TRUE, 0);
label = gtk_label_new_with_mnemonic ("_Entry 1");
gtk_table_attach_defaults (GTK_TABLE (table),
label,
label,
0, 1, 0, 1);
local_entry1 = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (local_entry1), gtk_entry_get_text (GTK_ENTRY (entry1)));
......@@ -68,7 +70,7 @@ interactive_dialog_clicked (GtkButton *button, gpointer user_data)
label = gtk_label_new_with_mnemonic ("E_ntry 2");
gtk_table_attach_defaults (GTK_TABLE (table),
label,
label,
0, 1, 1, 2);
local_entry2 = gtk_entry_new ();
......@@ -142,8 +144,8 @@ do_dialog (void)
label = gtk_label_new_with_mnemonic ("_Entry 1");
gtk_table_attach_defaults (GTK_TABLE (table),
label,
0, 1, 0, 1);
label,
0, 1, 0, 1);
entry1 = gtk_entry_new ();
gtk_table_attach_defaults (GTK_TABLE (table), entry1, 1, 2, 0, 1);
......@@ -152,8 +154,8 @@ do_dialog (void)
label = gtk_label_new_with_mnemonic ("E_ntry 2");
gtk_table_attach_defaults (GTK_TABLE (table),
label,
0, 1, 1, 2);
label,
0, 1, 1, 2);
entry2 = gtk_entry_new ();
gtk_table_attach_defaults (GTK_TABLE (table), entry2, 1, 2, 1, 2);
......@@ -165,7 +167,7 @@ do_dialog (void)
gtk_widget_show_all (window);
}
else
{
{
gtk_widget_destroy (window);
window = NULL;
}
......
......@@ -21,17 +21,17 @@ static GdkPixmap *pixmap = NULL;
/* Create a new pixmap of the appropriate size to store our scribbles */
static gboolean
scribble_configure_event (GtkWidget *widget,
GdkEventConfigure *event,
gpointer data)
scribble_configure_event (GtkWidget *widget,
GdkEventConfigure *event,
gpointer data)
{
if (pixmap)
g_object_unref (G_OBJECT (pixmap));
pixmap = gdk_pixmap_new (widget->window,
widget->allocation.width,
widget->allocation.height,
-1);
widget->allocation.width,
widget->allocation.height,
-1);
/* Initialize the pixmap to white */
gdk_draw_rectangle (pixmap,
......@@ -48,8 +48,8 @@ scribble_configure_event (GtkWidget *widget,
/* Redraw the screen from the pixmap */
static gboolean
scribble_expose_event (GtkWidget *widget,
GdkEventExpose *event,
gpointer data)
GdkEventExpose *event,
gpointer data)
{
/* We use the "foreground GC" for the widget since it already exists,
* but honestly any GC would work. The only thing to worry about
......@@ -57,12 +57,12 @@ scribble_expose_event (GtkWidget *widget,
*/
gdk_draw_drawable (widget->window,
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
pixmap,
/* Only copy the area that was exposed. */
event->area.x, event->area.y,
event->area.x, event->area.y,
event->area.width, event->area.height);
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
pixmap,
/* Only copy the area that was exposed. */
event->area.x, event->area.y,
event->area.x, event->area.y,
event->area.width, event->area.height);
return FALSE;
}
......@@ -70,8 +70,8 @@ scribble_expose_event (GtkWidget *widget,
/* Draw a rectangle on the screen */
static void
draw_brush (GtkWidget *widget,
gdouble x,
gdouble y)
gdouble x,
gdouble y)
{
GdkRectangle update_rect;
......@@ -89,14 +89,14 @@ draw_brush (GtkWidget *widget,
/* Now invalidate the affected region of the drawing area. */
gdk_window_invalidate_rect (widget->window,
&update_rect,
FALSE);
&update_rect,
FALSE);
}
static gboolean
scribble_button_press_event (GtkWidget *widget,
GdkEventButton *event,
gpointer data)
scribble_button_press_event (GtkWidget *widget,
GdkEventButton *event,
gpointer data)
{
if (pixmap == NULL)
return FALSE; /* paranoia check, in case we haven't gotten a configure event */
......@@ -109,9 +109,9 @@ scribble_button_press_event (GtkWidget *widget,
}
static gboolean
scribble_motion_notify_event (GtkWidget *widget,
GdkEventMotion *event,
gpointer data)
scribble_motion_notify_event (GtkWidget *widget,
GdkEventMotion *event,
gpointer data)
{
int x, y;
GdkModifierType state;
......@@ -141,9 +141,9 @@ scribble_motion_notify_event (GtkWidget *widget,
static gboolean
checkerboard_expose (GtkWidget *da,
GdkEventExpose *event,
gpointer data)
checkerboard_expose (GtkWidget *da,
GdkEventExpose *event,
gpointer data)
{
gint i, j, xcount, ycount;
GdkGC *gc1, *gc2;
......@@ -182,28 +182,28 @@ checkerboard_expose (GtkWidget *da,
j = SPACING;
ycount = xcount % 2; /* start with even/odd depending on row */
while (j < da->allocation.height)
{
GdkGC *gc;
if (ycount % 2)
gc = gc1;
else
gc = gc2;
/* If we're outside event->area, this will do nothing.
* It might be mildly more efficient if we handled
* the clipping ourselves, but again we're feeling lazy.
*/
gdk_draw_rectangle (da->window,
gc,
TRUE,
i, j,
CHECK_SIZE,
CHECK_SIZE);
j += CHECK_SIZE + SPACING;
++ycount;
}
{
GdkGC *gc;
if (ycount % 2)
gc = gc1;
else
gc = gc2;
/* If we're outside event->area, this will do nothing.
* It might be mildly more efficient if we handled
* the clipping ourselves, but again we're feeling lazy.
*/
gdk_draw_rectangle (da->window,
gc,
TRUE,
i, j,
CHECK_SIZE,
CHECK_SIZE);
j += CHECK_SIZE + SPACING;
++ycount;
}
i += CHECK_SIZE + SPACING;
++xcount;
......@@ -245,7 +245,7 @@ do_drawingarea (void)
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>Checkerboard pattern</u>");
"<u>Checkerboard pattern</u>");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
frame = gtk_frame_new (NULL);
......@@ -259,9 +259,9 @@ do_drawingarea (void)
gtk_container_add (GTK_CONTAINER (frame), da);
gtk_signal_connect (GTK_OBJECT (da),
"expose_event",
GTK_SIGNAL_FUNC (checkerboard_expose),
NULL);
"expose_event",
GTK_SIGNAL_FUNC (checkerboard_expose),
NULL);
/*
* Create the scribble area
......@@ -269,7 +269,7 @@ do_drawingarea (void)
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>Scribble area</u>");
"<u>Scribble area</u>");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
frame = gtk_frame_new (NULL);
......@@ -285,26 +285,26 @@ do_drawingarea (void)
/* Signals used to handle backing pixmap */
gtk_signal_connect (GTK_OBJECT (da), "expose_event",
GTK_SIGNAL_FUNC (scribble_expose_event), NULL);
GTK_SIGNAL_FUNC (scribble_expose_event), NULL);
gtk_signal_connect (GTK_OBJECT (da),"configure_event",
GTK_SIGNAL_FUNC (scribble_configure_event), NULL);
GTK_SIGNAL_FUNC (scribble_configure_event), NULL);
/* Event signals */
gtk_signal_connect (GTK_OBJECT (da), "motion_notify_event",
GTK_SIGNAL_FUNC (scribble_motion_notify_event), NULL);
GTK_SIGNAL_FUNC (scribble_motion_notify_event), NULL);
gtk_signal_connect (GTK_OBJECT (da), "button_press_event",
GTK_SIGNAL_FUNC (scribble_button_press_event), NULL);
GTK_SIGNAL_FUNC (scribble_button_press_event), NULL);
/* Ask to receive events the drawing area doesn't normally
* subscribe to
*/
gtk_widget_set_events (da, gtk_widget_get_events (da)
| GDK_LEAVE_NOTIFY_MASK
| GDK_BUTTON_PRESS_MASK
| GDK_POINTER_MOTION_MASK
| GDK_POINTER_MOTION_HINT_MASK);
| GDK_LEAVE_NOTIFY_MASK
| GDK_BUTTON_PRESS_MASK
| GDK_POINTER_MOTION_MASK
| GDK_POINTER_MOTION_HINT_MASK);
}
......
......@@ -22,10 +22,11 @@ static guint load_timeout = 0;
static FILE* image_stream = NULL;
static void
progressive_prepared_callback (GdkPixbufLoader* loader, gpointer data)
progressive_prepared_callback (GdkPixbufLoader *loader,
gpointer data)
{
GdkPixbuf* pixbuf;
GtkWidget* image;
GdkPixbuf *pixbuf;
GtkWidget *image;
image = GTK_WIDGET (data);
......@@ -39,12 +40,14 @@ progressive_prepared_callback (GdkPixbufLoader* loader, gpointer data)
gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
}
static void
progressive_updated_callback (GdkPixbufLoader* loader,
gint x, gint y, gint width, gint height,
gpointer data)
static void progressive_updated_callback (GdkPixbufLoader *loader,
gint x,
gint y,
gint width,
gint height,
gpointer data)
{
GtkWidget* image;
GtkWidget *image;
image = GTK_WIDGET (data);
......@@ -80,158 +83,158 @@ progressive_timeout (gpointer data)
bytes_read = fread (buf, 1, 256, image_stream);
if (ferror (image_stream))
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"Failure reading image file 'alphatest.png': %s",
g_strerror (errno));
gtk_signal_connect (GTK_OBJECT (dialog),
"response",
GTK_SIGNAL_FUNC (gtk_widget_destroy),
NULL);
fclose (image_stream);
image_stream = NULL;
gtk_widget_show (dialog);
load_timeout = 0;
return FALSE; /* uninstall the timeout */
}
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"Failure reading image file 'alphatest.png': %s",
g_strerror (errno));
gtk_signal_connect (GTK_OBJECT (dialog),
"response",
GTK_SIGNAL_FUNC (gtk_widget_destroy),
NULL);
fclose (image_stream);
image_stream = NULL;
gtk_widget_show (dialog);
load_timeout = 0;
return FALSE; /* uninstall the timeout */
}
if (!gdk_pixbuf_loader_write (pixbuf_loader,
buf, bytes_read,
&error))
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"Failed to load image: %s",
error->message);
g_error_free (error);
gtk_signal_connect (GTK_OBJECT (dialog),
"response",
GTK_SIGNAL_FUNC (gtk_widget_destroy),
NULL);
fclose (image_stream);
image_stream = NULL;
gtk_widget_show (dialog);
load_timeout = 0;
return FALSE; /* uninstall the timeout */
}
buf, bytes_read,
&error))
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"Failed to load image: %s",
error->message);
g_error_free (error);
gtk_signal_connect (GTK_OBJECT (dialog),
"response",
GTK_SIGNAL_FUNC (gtk_widget_destroy),
NULL);
fclose (image_stream);
image_stream = NULL;
gtk_widget_show (dialog);
load_timeout = 0;
return FALSE; /* uninstall the timeout */
}
if (feof (image_stream))
{
fclose (image_stream);
image_stream = NULL;
/* Errors can happen on close, e.g. if the image
* file was truncated we'll know on close that
* it was incomplete.
*/
error = NULL;
if (!gdk_pixbuf_loader_close (pixbuf_loader,
&error))