removed return_if_fail (label->words != NULL) since that's a valid case

Sat Dec 19 05:37:51 1998  Tim Janik  <timj@gtk.org>

        * gtk/gtklabel.c (gtk_label_expose): removed return_if_fail
        (label->words != NULL) since that's a valid case when the label
        is empty, or just default constructed.
        fixed indentation prototype arguments and braces in some places.
        also, pointer comparisions and initializations are done with NULL
        not 0, there's a reason GLib defines NULL.

        * gdk/gdkevents.c (gdk_events_pending): return (queued_events ||
        putback_events) so this again returns whether events are pending,
        not whether other sources like idles are pending.

        * gtk/gtkmain.c (gtk_main_iteration_do):
        (gtk_main_iteration): return whether the loop is done, not whether
        something got dispatch to restore the original behaviour (yosh: this
        fixes code like in GleSelector).
This commit is contained in:
Tim Janik 1998-12-19 05:15:15 +00:00 committed by Tim Janik
parent ee173b486f
commit 8fc5066a69
11 changed files with 208 additions and 72 deletions

View File

@ -1,3 +1,21 @@
Sat Dec 19 05:37:51 1998 Tim Janik <timj@gtk.org>
* gtk/gtklabel.c (gtk_label_expose): removed return_if_fail
(label->words != NULL) since that's a valid case when the label
is empty, or just default constructed.
fixed indentation prototype arguments and braces in some places.
also, pointer comparisions and initializations are done with NULL
not 0, there's a reason GLib defines NULL.
* gdk/gdkevents.c (gdk_events_pending): return (queued_events ||
putback_events) so this again returns whether events are pending,
not whether other sources like idles are pending.
* gtk/gtkmain.c (gtk_main_iteration_do):
(gtk_main_iteration): return whether the loop is done, not whether
something got dispatch to restore the original behaviour (yosh: this
fixes code like in GleSelector).
Fri Dec 18 19:20:45 PST 1998 Manish Singh <yosh@gimp.org> Fri Dec 18 19:20:45 PST 1998 Manish Singh <yosh@gimp.org>
* gtkbutton.[ch] * gtkbutton.[ch]

View File

@ -1,3 +1,21 @@
Sat Dec 19 05:37:51 1998 Tim Janik <timj@gtk.org>
* gtk/gtklabel.c (gtk_label_expose): removed return_if_fail
(label->words != NULL) since that's a valid case when the label
is empty, or just default constructed.
fixed indentation prototype arguments and braces in some places.
also, pointer comparisions and initializations are done with NULL
not 0, there's a reason GLib defines NULL.
* gdk/gdkevents.c (gdk_events_pending): return (queued_events ||
putback_events) so this again returns whether events are pending,
not whether other sources like idles are pending.
* gtk/gtkmain.c (gtk_main_iteration_do):
(gtk_main_iteration): return whether the loop is done, not whether
something got dispatch to restore the original behaviour (yosh: this
fixes code like in GleSelector).
Fri Dec 18 19:20:45 PST 1998 Manish Singh <yosh@gimp.org> Fri Dec 18 19:20:45 PST 1998 Manish Singh <yosh@gimp.org>
* gtkbutton.[ch] * gtkbutton.[ch]

View File

@ -1,3 +1,21 @@
Sat Dec 19 05:37:51 1998 Tim Janik <timj@gtk.org>
* gtk/gtklabel.c (gtk_label_expose): removed return_if_fail
(label->words != NULL) since that's a valid case when the label
is empty, or just default constructed.
fixed indentation prototype arguments and braces in some places.
also, pointer comparisions and initializations are done with NULL
not 0, there's a reason GLib defines NULL.
* gdk/gdkevents.c (gdk_events_pending): return (queued_events ||
putback_events) so this again returns whether events are pending,
not whether other sources like idles are pending.
* gtk/gtkmain.c (gtk_main_iteration_do):
(gtk_main_iteration): return whether the loop is done, not whether
something got dispatch to restore the original behaviour (yosh: this
fixes code like in GleSelector).
Fri Dec 18 19:20:45 PST 1998 Manish Singh <yosh@gimp.org> Fri Dec 18 19:20:45 PST 1998 Manish Singh <yosh@gimp.org>
* gtkbutton.[ch] * gtkbutton.[ch]

View File

@ -1,3 +1,21 @@
Sat Dec 19 05:37:51 1998 Tim Janik <timj@gtk.org>
* gtk/gtklabel.c (gtk_label_expose): removed return_if_fail
(label->words != NULL) since that's a valid case when the label
is empty, or just default constructed.
fixed indentation prototype arguments and braces in some places.
also, pointer comparisions and initializations are done with NULL
not 0, there's a reason GLib defines NULL.
* gdk/gdkevents.c (gdk_events_pending): return (queued_events ||
putback_events) so this again returns whether events are pending,
not whether other sources like idles are pending.
* gtk/gtkmain.c (gtk_main_iteration_do):
(gtk_main_iteration): return whether the loop is done, not whether
something got dispatch to restore the original behaviour (yosh: this
fixes code like in GleSelector).
Fri Dec 18 19:20:45 PST 1998 Manish Singh <yosh@gimp.org> Fri Dec 18 19:20:45 PST 1998 Manish Singh <yosh@gimp.org>
* gtkbutton.[ch] * gtkbutton.[ch]

View File

@ -1,3 +1,21 @@
Sat Dec 19 05:37:51 1998 Tim Janik <timj@gtk.org>
* gtk/gtklabel.c (gtk_label_expose): removed return_if_fail
(label->words != NULL) since that's a valid case when the label
is empty, or just default constructed.
fixed indentation prototype arguments and braces in some places.
also, pointer comparisions and initializations are done with NULL
not 0, there's a reason GLib defines NULL.
* gdk/gdkevents.c (gdk_events_pending): return (queued_events ||
putback_events) so this again returns whether events are pending,
not whether other sources like idles are pending.
* gtk/gtkmain.c (gtk_main_iteration_do):
(gtk_main_iteration): return whether the loop is done, not whether
something got dispatch to restore the original behaviour (yosh: this
fixes code like in GleSelector).
Fri Dec 18 19:20:45 PST 1998 Manish Singh <yosh@gimp.org> Fri Dec 18 19:20:45 PST 1998 Manish Singh <yosh@gimp.org>
* gtkbutton.[ch] * gtkbutton.[ch]

View File

@ -1,3 +1,21 @@
Sat Dec 19 05:37:51 1998 Tim Janik <timj@gtk.org>
* gtk/gtklabel.c (gtk_label_expose): removed return_if_fail
(label->words != NULL) since that's a valid case when the label
is empty, or just default constructed.
fixed indentation prototype arguments and braces in some places.
also, pointer comparisions and initializations are done with NULL
not 0, there's a reason GLib defines NULL.
* gdk/gdkevents.c (gdk_events_pending): return (queued_events ||
putback_events) so this again returns whether events are pending,
not whether other sources like idles are pending.
* gtk/gtkmain.c (gtk_main_iteration_do):
(gtk_main_iteration): return whether the loop is done, not whether
something got dispatch to restore the original behaviour (yosh: this
fixes code like in GleSelector).
Fri Dec 18 19:20:45 PST 1998 Manish Singh <yosh@gimp.org> Fri Dec 18 19:20:45 PST 1998 Manish Singh <yosh@gimp.org>
* gtkbutton.[ch] * gtkbutton.[ch]

View File

@ -1,3 +1,21 @@
Sat Dec 19 05:37:51 1998 Tim Janik <timj@gtk.org>
* gtk/gtklabel.c (gtk_label_expose): removed return_if_fail
(label->words != NULL) since that's a valid case when the label
is empty, or just default constructed.
fixed indentation prototype arguments and braces in some places.
also, pointer comparisions and initializations are done with NULL
not 0, there's a reason GLib defines NULL.
* gdk/gdkevents.c (gdk_events_pending): return (queued_events ||
putback_events) so this again returns whether events are pending,
not whether other sources like idles are pending.
* gtk/gtkmain.c (gtk_main_iteration_do):
(gtk_main_iteration): return whether the loop is done, not whether
something got dispatch to restore the original behaviour (yosh: this
fixes code like in GleSelector).
Fri Dec 18 19:20:45 PST 1998 Manish Singh <yosh@gimp.org> Fri Dec 18 19:20:45 PST 1998 Manish Singh <yosh@gimp.org>
* gtkbutton.[ch] * gtkbutton.[ch]

View File

@ -163,7 +163,7 @@ gdk_events_init (void)
gint gint
gdk_events_pending (void) gdk_events_pending (void)
{ {
return g_main_pending(); return (queued_events || putback_events);
} }
/* /*

View File

@ -163,7 +163,7 @@ gdk_events_init (void)
gint gint
gdk_events_pending (void) gdk_events_pending (void)
{ {
return g_main_pending(); return (queued_events || putback_events);
} }
/* /*

View File

@ -341,7 +341,7 @@ gtk_label_finalize (GtkObject *object)
(* GTK_OBJECT_CLASS (parent_class)->finalize) (object); (* GTK_OBJECT_CLASS (parent_class)->finalize) (object);
} }
static GtkLabelWord * static GtkLabelWord*
gtk_label_word_alloc () gtk_label_word_alloc ()
{ {
GtkLabelWord * word; GtkLabelWord * word;
@ -370,7 +370,7 @@ gtk_label_word_alloc ()
} }
static void static void
gtk_label_free_words (GtkLabel * label) gtk_label_free_words (GtkLabel *label)
{ {
GtkLabelWord * last; GtkLabelWord * last;
@ -380,11 +380,11 @@ gtk_label_free_words (GtkLabel * label)
gtk_label_free_ulines (label->words); gtk_label_free_ulines (label->words);
last->next = free_words; last->next = free_words;
free_words = label->words; free_words = label->words;
label->words = 0; label->words = NULL;
} }
} }
static GtkLabelULine * static GtkLabelULine*
gtk_label_uline_alloc () gtk_label_uline_alloc (void)
{ {
GtkLabelULine * uline; GtkLabelULine * uline;
@ -406,7 +406,8 @@ gtk_label_uline_alloc ()
uline = g_mem_chunk_alloc (uline_chunk); uline = g_mem_chunk_alloc (uline_chunk);
} }
uline->next = 0; uline->next = NULL;
return uline; return uline;
} }
@ -425,21 +426,19 @@ gtk_label_free_ulines (GtkLabelWord *word)
} }
static gint static gint
gtk_label_split_text (GtkLabel * label) gtk_label_split_text (GtkLabel *label)
{ {
GtkLabelWord *word, **tailp; GtkLabelWord *word, **tailp;
gint space_width, line_width, max_line_width; gint space_width, line_width, max_line_width;
GdkWChar *str, *p; GdkWChar *str, *p;
g_return_val_if_fail (GTK_WIDGET (label)->style->font != 0, 0); g_return_val_if_fail (GTK_WIDGET (label)->style->font != NULL, 0);
gtk_label_free_words (label); gtk_label_free_words (label);
if (label->label == 0) if (label->label == NULL)
return 0; return 0;
/* /* Split text at new-lines. */
* Split text at new-lines.
*/
space_width = gdk_string_width (GTK_WIDGET (label)->style->font, " "); space_width = gdk_string_width (GTK_WIDGET (label)->style->font, " ");
line_width = 0; line_width = 0;
@ -450,7 +449,7 @@ gtk_label_split_text (GtkLabel * label)
{ {
word = gtk_label_word_alloc (); word = gtk_label_word_alloc ();
if ((str == label->label_wc) || (str[-1] == '\n')) if (str == label->label_wc || str[-1] == '\n')
{ {
/* Paragraph break */ /* Paragraph break */
word->space = 0; word->space = 0;
@ -476,7 +475,7 @@ gtk_label_split_text (GtkLabel * label)
word->length = 0; word->length = 0;
p = word->beginning; p = word->beginning;
while (*p && (*p != '\n')) while (*p && *p != '\n')
{ {
word->length++; word->length++;
p++; p++;
@ -486,7 +485,7 @@ gtk_label_split_text (GtkLabel * label)
str += word->length; str += word->length;
if (*str) if (*str)
str++; str++;
line_width += word->space + word->width; line_width += word->space + word->width;
@ -498,22 +497,20 @@ gtk_label_split_text (GtkLabel * label)
} }
static gint static gint
gtk_label_split_text_wrapped (GtkLabel * label) gtk_label_split_text_wrapped (GtkLabel *label)
{ {
/* this needs to handle white space better. */ /* this needs to handle white space better. */
GtkLabelWord *word, **tailp; GtkLabelWord *word, **tailp;
gint space_width, line_width, max_line_width; gint space_width, line_width, max_line_width;
GdkWChar *str, *p; GdkWChar *str, *p;
g_return_val_if_fail (GTK_WIDGET (label)->style->font != 0, 0); g_return_val_if_fail (GTK_WIDGET (label)->style->font != NULL, 0);
gtk_label_free_words (label); gtk_label_free_words (label);
if (label->label == 0) if (label->label == NULL)
return 0; return 0;
/* /* Split text at new-lines. (Or at spaces in the case of paragraphs). */
* Split text at new-lines. (Or at spaces in the case of paragraphs).
*/
space_width = gdk_string_width (GTK_WIDGET (label)->style->font, " "); space_width = gdk_string_width (GTK_WIDGET (label)->style->font, " ");
line_width = 0; line_width = 0;
@ -556,7 +553,7 @@ gtk_label_split_text_wrapped (GtkLabel * label)
word->beginning = str; word->beginning = str;
word->length = 0; word->length = 0;
p = word->beginning; p = word->beginning;
while (*p && (!gdk_iswspace (*p))) while (*p && !gdk_iswspace (*p))
{ {
word->length++; word->length++;
p++; p++;
@ -565,7 +562,7 @@ gtk_label_split_text_wrapped (GtkLabel * label)
str += word->length; str += word->length;
if (*str) if (*str)
str++; str++;
line_width += word->space + word->width; line_width += word->space + word->width;
@ -576,8 +573,7 @@ gtk_label_split_text_wrapped (GtkLabel * label)
return MAX (line_width, max_line_width); return MAX (line_width, max_line_width);
} }
/* /* gtk_label_pick_width
* gtk_label_pick_width
* *
* Split paragraphs, trying to make each line at least min_width, * Split paragraphs, trying to make each line at least min_width,
* and trying even harder to make each line no longer than max_width. * and trying even harder to make each line no longer than max_width.
@ -589,7 +585,9 @@ gtk_label_split_text_wrapped (GtkLabel * label)
* short final line.) * short final line.)
*/ */
static gint static gint
gtk_label_pick_width (GtkLabel * label, gint min_width, gint max_width) gtk_label_pick_width (GtkLabel *label,
gint min_width,
gint max_width)
{ {
GtkLabelWord *word; GtkLabelWord *word;
gint width, line_width; gint width, line_width;
@ -615,15 +613,15 @@ gtk_label_pick_width (GtkLabel * label, gint min_width, gint max_width)
return MAX (width, line_width); return MAX (width, line_width);
} }
/* /* Here, we finalize the lines.
* Here, we finalize the lines.
* This is only for non-wrap labels. Wrapped labels * This is only for non-wrap labels. Wrapped labels
* use gtk_label_finalize_wrap instead. * use gtk_label_finalize_wrap instead.
*/ */
static void static void
gtk_label_finalize_lines (GtkLabel * label, gint line_width) gtk_label_finalize_lines (GtkLabel *label,
gint line_width)
{ {
GtkLabelWord * line; GtkLabelWord *line;
gint y, baseline_skip, y_max; gint y, baseline_skip, y_max;
gint i, j; gint i, j;
gchar *ptrn; gchar *ptrn;
@ -647,9 +645,9 @@ gtk_label_finalize_lines (GtkLabel * label, gint line_width)
y_max = 0; y_max = 0;
/* now we deal with the underline stuff; */ /* now we deal with the underline stuff; */
if (ptrn && (ptrn[0] != '\0')) if (ptrn && ptrn[0] != '\0')
{ {
for (i=0;i<line->length;i++) for (i = 0; i < line->length; i++)
{ {
if (ptrn[i] == '\0') if (ptrn[i] == '\0')
break; break;
@ -662,15 +660,15 @@ gtk_label_finalize_lines (GtkLabel * label, gint line_width)
gint offset; gint offset;
GtkLabelULine *uline; GtkLabelULine *uline;
for (j=i+1;j<line->length;j++) for (j = i + 1; j < line->length; j++)
{ {
if (ptrn[j] == '\0') if (ptrn[j] == '\0')
break; break;
else if (ptrn[j] == ' ') else if (ptrn[j] == ' ')
break; break;
} }
/*
* good. Now we have an underlined segment. /* good. Now we have an underlined segment.
* let's measure it and record it. * let's measure it and record it.
*/ */
offset = gdk_text_width_wc (GTK_WIDGET (label)->style->font, offset = gdk_text_width_wc (GTK_WIDGET (label)->style->font,
@ -707,7 +705,8 @@ gtk_label_finalize_lines (GtkLabel * label, gint line_width)
/* this finalizes word-wrapped words */ /* this finalizes word-wrapped words */
static void static void
gtk_label_finalize_lines_wrap (GtkLabel * label, gint line_width) gtk_label_finalize_lines_wrap (GtkLabel *label,
gint line_width)
{ {
GtkLabelWord *word, *line, *next_line; GtkLabelWord *word, *line, *next_line;
GtkWidget *widget; GtkWidget *widget;
@ -831,11 +830,10 @@ gtk_label_size_request (GtkWidget *widget,
} }
gtk_label_finalize_lines_wrap (label, label->max_width); gtk_label_finalize_lines_wrap (label, label->max_width);
} }
else if (label->words == 0) else if (label->words == NULL)
{ {
label->max_width = gtk_label_split_text (label); label->max_width = gtk_label_split_text (label);
gtk_label_finalize_lines (label, label->max_width); gtk_label_finalize_lines (label, label->max_width);
} }
if (requisition != &widget->requisition) if (requisition != &widget->requisition)
@ -888,8 +886,6 @@ gtk_label_expose (GtkWidget *widget,
{ {
misc = GTK_MISC (widget); misc = GTK_MISC (widget);
g_return_val_if_fail ((label->words != NULL), FALSE);
/* /*
* GC Clipping * GC Clipping
*/ */

View File

@ -526,13 +526,27 @@ gtk_events_pending (void)
gint gint
gtk_main_iteration (void) gtk_main_iteration (void)
{ {
return g_main_iteration (TRUE); if (main_loops)
{
g_main_iteration (TRUE);
return !g_main_is_running (main_loops->data);
}
else
return TRUE;
} }
gint gint
gtk_main_iteration_do (gboolean blocking) gtk_main_iteration_do (gboolean blocking)
{ {
return g_main_iteration (blocking); if (main_loops)
{
g_main_iteration (blocking);
return !g_main_is_running (main_loops->data);
}
else
return TRUE;
} }
void void