Added gdk_text_extents_wc()

Tue Dec 15 14:30:35 1998  Owen Taylor  <otaylor@redhat.com>

	* gdk/gdk.h gdk/gdkfonts.c: Added gdk_text_extents_wc()

        * Patch from Jonathan Blanford <jrb@redhat.com> to add line wrapping
	  to label. (Based on patch from Jeff Dairiki
	  <dairiki@mac-ceope.apl.washington.edu> gtk-dairiki-971208-0)

	- Adds new function gtk_label_set_line_wrap()
	- implement GTK_JUSTIFY_FILL.
	- rename gtk_label_set to gtk_label_set_text() add
	   gtk_label_set() to gtkcompat.h.

	* Use an internal wc representation in the label, so
	  that we handle underlining and line breaks correctly
	  for multi-byte strings.
This commit is contained in:
Owen Taylor 1998-12-15 20:31:26 +00:00 committed by Owen Taylor
parent 7eec796cbd
commit a3c1e86ffa
26 changed files with 1155 additions and 477 deletions

View File

@ -1,3 +1,20 @@
Tue Dec 15 14:30:35 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdkfonts.c: Added gdk_text_extents_wc()
* Patch from Jonathan Blanford <jrb@redhat.com> to add line wrapping
to label. (Based on patch from Jeff Dairiki
<dairiki@mac-ceope.apl.washington.edu> gtk-dairiki-971208-0)
- Adds new function gtk_label_set_line_wrap()
- implement GTK_JUSTIFY_FILL.
- rename gtk_label_set to gtk_label_set_text() add
gtk_label_set() to gtkcompat.h.
* Use an internal wc representation in the label, so
that we handle underlining and line breaks correctly
for multi-byte strings.
Tue Dec 15 13:32:28 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Added GTK_USER_DRAW flag.

View File

@ -1,3 +1,20 @@
Tue Dec 15 14:30:35 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdkfonts.c: Added gdk_text_extents_wc()
* Patch from Jonathan Blanford <jrb@redhat.com> to add line wrapping
to label. (Based on patch from Jeff Dairiki
<dairiki@mac-ceope.apl.washington.edu> gtk-dairiki-971208-0)
- Adds new function gtk_label_set_line_wrap()
- implement GTK_JUSTIFY_FILL.
- rename gtk_label_set to gtk_label_set_text() add
gtk_label_set() to gtkcompat.h.
* Use an internal wc representation in the label, so
that we handle underlining and line breaks correctly
for multi-byte strings.
Tue Dec 15 13:32:28 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Added GTK_USER_DRAW flag.

View File

@ -1,3 +1,20 @@
Tue Dec 15 14:30:35 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdkfonts.c: Added gdk_text_extents_wc()
* Patch from Jonathan Blanford <jrb@redhat.com> to add line wrapping
to label. (Based on patch from Jeff Dairiki
<dairiki@mac-ceope.apl.washington.edu> gtk-dairiki-971208-0)
- Adds new function gtk_label_set_line_wrap()
- implement GTK_JUSTIFY_FILL.
- rename gtk_label_set to gtk_label_set_text() add
gtk_label_set() to gtkcompat.h.
* Use an internal wc representation in the label, so
that we handle underlining and line breaks correctly
for multi-byte strings.
Tue Dec 15 13:32:28 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Added GTK_USER_DRAW flag.

View File

@ -1,3 +1,20 @@
Tue Dec 15 14:30:35 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdkfonts.c: Added gdk_text_extents_wc()
* Patch from Jonathan Blanford <jrb@redhat.com> to add line wrapping
to label. (Based on patch from Jeff Dairiki
<dairiki@mac-ceope.apl.washington.edu> gtk-dairiki-971208-0)
- Adds new function gtk_label_set_line_wrap()
- implement GTK_JUSTIFY_FILL.
- rename gtk_label_set to gtk_label_set_text() add
gtk_label_set() to gtkcompat.h.
* Use an internal wc representation in the label, so
that we handle underlining and line breaks correctly
for multi-byte strings.
Tue Dec 15 13:32:28 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Added GTK_USER_DRAW flag.

View File

@ -1,3 +1,20 @@
Tue Dec 15 14:30:35 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdkfonts.c: Added gdk_text_extents_wc()
* Patch from Jonathan Blanford <jrb@redhat.com> to add line wrapping
to label. (Based on patch from Jeff Dairiki
<dairiki@mac-ceope.apl.washington.edu> gtk-dairiki-971208-0)
- Adds new function gtk_label_set_line_wrap()
- implement GTK_JUSTIFY_FILL.
- rename gtk_label_set to gtk_label_set_text() add
gtk_label_set() to gtkcompat.h.
* Use an internal wc representation in the label, so
that we handle underlining and line breaks correctly
for multi-byte strings.
Tue Dec 15 13:32:28 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Added GTK_USER_DRAW flag.

View File

@ -1,3 +1,20 @@
Tue Dec 15 14:30:35 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdkfonts.c: Added gdk_text_extents_wc()
* Patch from Jonathan Blanford <jrb@redhat.com> to add line wrapping
to label. (Based on patch from Jeff Dairiki
<dairiki@mac-ceope.apl.washington.edu> gtk-dairiki-971208-0)
- Adds new function gtk_label_set_line_wrap()
- implement GTK_JUSTIFY_FILL.
- rename gtk_label_set to gtk_label_set_text() add
gtk_label_set() to gtkcompat.h.
* Use an internal wc representation in the label, so
that we handle underlining and line breaks correctly
for multi-byte strings.
Tue Dec 15 13:32:28 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Added GTK_USER_DRAW flag.

View File

@ -1,3 +1,20 @@
Tue Dec 15 14:30:35 1998 Owen Taylor <otaylor@redhat.com>
* gdk/gdk.h gdk/gdkfonts.c: Added gdk_text_extents_wc()
* Patch from Jonathan Blanford <jrb@redhat.com> to add line wrapping
to label. (Based on patch from Jeff Dairiki
<dairiki@mac-ceope.apl.washington.edu> gtk-dairiki-971208-0)
- Adds new function gtk_label_set_line_wrap()
- implement GTK_JUSTIFY_FILL.
- rename gtk_label_set to gtk_label_set_text() add
gtk_label_set() to gtkcompat.h.
* Use an internal wc representation in the label, so
that we handle underlining and line breaks correctly
for multi-byte strings.
Tue Dec 15 13:32:28 1998 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.h: Added GTK_USER_DRAW flag.

View File

@ -604,6 +604,14 @@ void gdk_text_extents (GdkFont *font,
gint *width,
gint *ascent,
gint *descent);
void gdk_text_extents_wc (GdkFont *font,
const GdkWChar *text,
gint text_length,
gint *lbearing,
gint *rbearing,
gint *width,
gint *ascent,
gint *descent);
void gdk_string_extents (GdkFont *font,
const gchar *string,
gint *lbearing,

View File

@ -503,6 +503,80 @@ gdk_text_extents (GdkFont *font,
}
void
gdk_text_extents_wc (GdkFont *font,
const GdkWChar *text,
gint text_length,
gint *lbearing,
gint *rbearing,
gint *width,
gint *ascent,
gint *descent)
{
GdkFontPrivate *private;
XCharStruct overall;
XFontStruct *xfont;
XFontSet fontset;
XRectangle ink, logical;
int direction;
int font_ascent;
int font_descent;
gint i;
g_return_if_fail (font != NULL);
g_return_if_fail (text != NULL);
private = (GdkFontPrivate*) font;
switch (font->type)
{
case GDK_FONT_FONT:
{
gchar *text_8bit;
gint i;
xfont = (XFontStruct *) private->xfont;
g_return_if_fail ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0));
text_8bit = g_new (gchar, text_length);
for (i=0; i<text_length; i++)
text_8bit[i] = text[i];
XTextExtents (xfont, text_8bit, text_length,
&direction, &font_ascent, &font_descent,
&overall);
g_free (text_8bit);
if (lbearing)
*lbearing = overall.lbearing;
if (rbearing)
*rbearing = overall.rbearing;
if (width)
*width = overall.width;
if (ascent)
*ascent = overall.ascent;
if (descent)
*descent = overall.descent;
break;
}
case GDK_FONT_FONTSET:
fontset = (XFontSet) private->xfont;
XwcTextExtents (fontset, text, text_length, &ink, &logical);
if (lbearing)
*lbearing = ink.x;
if (rbearing)
*rbearing = ink.x + ink.width;
if (width)
*width = logical.width;
if (ascent)
*ascent = -ink.y;
if (descent)
*descent = ink.y + ink.height;
break;
}
}
void
gdk_string_extents (GdkFont *font,
const gchar *string,

View File

@ -503,6 +503,80 @@ gdk_text_extents (GdkFont *font,
}
void
gdk_text_extents_wc (GdkFont *font,
const GdkWChar *text,
gint text_length,
gint *lbearing,
gint *rbearing,
gint *width,
gint *ascent,
gint *descent)
{
GdkFontPrivate *private;
XCharStruct overall;
XFontStruct *xfont;
XFontSet fontset;
XRectangle ink, logical;
int direction;
int font_ascent;
int font_descent;
gint i;
g_return_if_fail (font != NULL);
g_return_if_fail (text != NULL);
private = (GdkFontPrivate*) font;
switch (font->type)
{
case GDK_FONT_FONT:
{
gchar *text_8bit;
gint i;
xfont = (XFontStruct *) private->xfont;
g_return_if_fail ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0));
text_8bit = g_new (gchar, text_length);
for (i=0; i<text_length; i++)
text_8bit[i] = text[i];
XTextExtents (xfont, text_8bit, text_length,
&direction, &font_ascent, &font_descent,
&overall);
g_free (text_8bit);
if (lbearing)
*lbearing = overall.lbearing;
if (rbearing)
*rbearing = overall.rbearing;
if (width)
*width = overall.width;
if (ascent)
*ascent = overall.ascent;
if (descent)
*descent = overall.descent;
break;
}
case GDK_FONT_FONTSET:
fontset = (XFontSet) private->xfont;
XwcTextExtents (fontset, text, text_length, &ink, &logical);
if (lbearing)
*lbearing = ink.x;
if (rbearing)
*rbearing = ink.x + ink.width;
if (width)
*width = logical.width;
if (ascent)
*ascent = -ink.y;
if (descent)
*descent = ink.y + ink.height;
break;
}
}
void
gdk_string_extents (GdkFont *font,
const gchar *string,

View File

@ -172,7 +172,7 @@ gtk_accel_label_new (const gchar *string)
accel_label = gtk_type_new (GTK_TYPE_ACCEL_LABEL);
gtk_label_set (GTK_LABEL (accel_label), string);
gtk_label_set_text (GTK_LABEL (accel_label), string);
return GTK_WIDGET (accel_label);
}

View File

@ -244,7 +244,7 @@ gtk_button_set_arg (GtkObject *object,
"parent", button,
NULL);
if (GTK_IS_LABEL (child))
gtk_label_set (GTK_LABEL (child),
gtk_label_set_text (GTK_LABEL (child),
GTK_VALUE_STRING (*arg) ? GTK_VALUE_STRING (*arg) : "");
break;
case ARG_RELIEF:

View File

@ -36,7 +36,7 @@ extern "C" {
#define gtk_paned_handle_size gtk_paned_set_handle_size
#define gtk_scale_value_width gtk_scale_get_value_width
#define gtk_window_position gtk_window_set_position
#define gtk_label_set gtk_label_set_text
#ifdef __cplusplus
}

View File

@ -1,125 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "gtkdrawwindow.h"
static void gtk_draw_window_class_init (GtkDrawWindowClass *klass);
static void gtk_draw_window_init (GtkDrawWindow *draw_window);
static void gtk_draw_window_draw (GtkWidget *widget,
GdkRectangle *area);
static gint gtk_draw_window_expose (GtkWidget *widget,
GdkEventExpose *event);
GtkType
gtk_draw_window_get_type (void)
{
static GtkType draw_window_type = 0;
if (!draw_window_type)
{
static const GtkTypeInfo draw_window_info =
{
"GtkDrawWindow",
sizeof (GtkDrawWindow),
sizeof (GtkDrawWindowClass),
(GtkClassInitFunc) gtk_draw_window_class_init,
(GtkObjectInitFunc) gtk_draw_window_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
draw_window_type = gtk_type_unique (GTK_TYPE_WINDOW, &draw_window_info);
}
return draw_window_type;
}
static void
gtk_draw_window_class_init (GtkDrawWindowClass *class)
{
GtkWidgetClass *widget_class;
widget_class = (GtkWidgetClass*) class;
widget_class->draw = gtk_draw_window_draw;
widget_class->expose_event = gtk_draw_window_expose;
}
static void
gtk_draw_window_init (GtkDrawWindow *draw_window)
{
}
static gint
gtk_draw_window_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GtkBin *bin;
GdkEventExpose child_event;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_BIN (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
if (GTK_WIDGET_DRAWABLE (widget))
{
bin = GTK_BIN (widget);
child_event = *event;
if (bin->child &&
GTK_WIDGET_NO_WINDOW (bin->child) &&
gtk_widget_intersect (bin->child, &event->area, &child_event.area))
gtk_widget_event (bin->child, (GdkEvent*) &child_event);
}
return FALSE;
}
static void
gtk_draw_window_draw (GtkWidget *widget,
GdkRectangle *area)
{
GtkBin *bin;
GdkRectangle child_area;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_BIN (widget));
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget))
{
bin = GTK_BIN (widget);
if (bin->child &&
gtk_widget_intersect (bin->child, area, &child_area))
gtk_widget_draw (bin->child, &child_area);
}
}
GtkWidget*
gtk_draw_window_new (GtkWindowType type)
{
GtkWindow *window;
window = gtk_type_new (GTK_TYPE_DRAW_WINDOW);
window->type = type;
return GTK_WIDGET (window);
}

View File

@ -1,63 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GTK_DRAW_WINDOW_H__
#define __GTK_DRAW_WINDOW_H__
#include <gdk/gdk.h>
#include <gtk/gtkwindow.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define GTK_TYPE_DRAW_WINDOW (gtk_draw_window_get_type ())
#define GTK_DRAW_WINDOW(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_DRAW_WINDOW, GtkDrawWindow))
#define GTK_DRAW_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_DRAW_WINDOW, GtkDrawWindowClass))
#define GTK_IS_DRAW_WINDOW(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_DRAW_WINDOW))
#define GTK_IS_DRAW_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_DRAW_WINDOW))
typedef struct _GtkDrawWindow GtkDrawWindow;
typedef struct _GtkDrawWindowClass GtkDrawWindowClass;
typedef struct _GtkDrawWindowButton GtkDrawWindowButton;
struct _GtkDrawWindow
{
GtkWindow window;
};
struct _GtkDrawWindowClass
{
GtkWindowClass parent_class;
};
GtkType gtk_draw_window_get_type (void);
GtkWidget* gtk_draw_window_new (GtkWindowType type);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GTK_DRAW_WINDOW_H__ */

View File

@ -499,7 +499,7 @@ gtk_file_selection_init (GtkFileSelection *filesel)
sprintf (err_buf, _("Directory unreadable: %s"), cmpl_strerror (cmpl_errno));
gtk_label_set (GTK_LABEL (filesel->selection_text), err_buf);
gtk_label_set_text (GTK_LABEL (filesel->selection_text), err_buf);
}
else
{
@ -1435,7 +1435,7 @@ gtk_file_selection_populate (GtkFileSelection *fs,
strcpy (sel_text, "Selection: ");
strcat (sel_text, cmpl_reference_position (cmpl_state));
gtk_label_set (GTK_LABEL (fs->selection_text), sel_text);
gtk_label_set_text (GTK_LABEL (fs->selection_text), sel_text);
g_free (sel_text);
}
@ -1457,7 +1457,7 @@ gtk_file_selection_abort (GtkFileSelection *fs)
/* BEEP gdk_beep(); */
if (fs->selection_entry)
gtk_label_set (GTK_LABEL (fs->selection_text), err_buf);
gtk_label_set_text (GTK_LABEL (fs->selection_text), err_buf);
}
/**********************************************************************/

View File

@ -1752,19 +1752,19 @@ gtk_font_selection_load_font (GtkFontSelection *fontsel)
it's necessary as it results in a resize of the whole window! */
gtk_label_get(GTK_LABEL(fontsel->message_label), &label_text);
if (strcmp(label_text, ""))
gtk_label_set(GTK_LABEL(fontsel->message_label), "");
gtk_label_set_text(GTK_LABEL(fontsel->message_label), "");
gtk_font_selection_update_preview (fontsel);
return TRUE;
}
else
{
gtk_label_set(GTK_LABEL(fontsel->message_label),
gtk_label_set_text(GTK_LABEL(fontsel->message_label),
"The selected font is not available.");
}
}
else
{
gtk_label_set(GTK_LABEL(fontsel->message_label),
gtk_label_set_text(GTK_LABEL(fontsel->message_label),
"The selected font is not a valid font.");
}
@ -1822,7 +1822,7 @@ gtk_font_selection_update_preview (GtkFontSelection *fontsel)
displayed properly. */
xfs = GDK_FONT_XFONT(fontsel->font);
if (xfs->min_byte1 != 0 || xfs->max_byte1 != 0)
gtk_label_set(GTK_LABEL(fontsel->message_label),
gtk_label_set_text(GTK_LABEL(fontsel->message_label),
"This is a 2-byte font and may not be displayed correctly.");
}
@ -2135,12 +2135,12 @@ gtk_font_selection_update_filter (GtkFontSelection *fontsel)
if (default_filter)
{
gtk_widget_set_sensitive(fontsel->filter_button, FALSE);
gtk_label_set(GTK_LABEL(fontsel->font_label), "Font:");
gtk_label_set_text(GTK_LABEL(fontsel->font_label), "Font:");
}
else
{
gtk_widget_set_sensitive(fontsel->filter_button, TRUE);
gtk_label_set(GTK_LABEL(fontsel->font_label), "Font: (Filter Applied)");
gtk_label_set_text(GTK_LABEL(fontsel->font_label), "Font: (Filter Applied)");
}
gtk_font_selection_show_available_fonts(fontsel);
}
@ -2365,7 +2365,7 @@ gtk_font_selection_clear_filter (GtkFontSelection *fontsel)
/* Update the main notebook page. */
gtk_widget_set_sensitive(fontsel->filter_button, FALSE);
gtk_label_set(GTK_LABEL(fontsel->font_label), "Font:");
gtk_label_set_text(GTK_LABEL(fontsel->font_label), "Font:");
gtk_font_selection_show_available_fonts(fontsel);
}

File diff suppressed because it is too large Load Diff

View File

@ -8,13 +8,12 @@
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __GTK_LABEL_H__
#define __GTK_LABEL_H__
@ -28,6 +27,7 @@
extern "C" {
#endif /* __cplusplus */
#define GTK_TYPE_LABEL (gtk_label_get_type ())
#define GTK_LABEL(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_LABEL, GtkLabel))
#define GTK_LABEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_LABEL, GtkLabelClass))
@ -38,16 +38,21 @@ extern "C" {
typedef struct _GtkLabel GtkLabel;
typedef struct _GtkLabelClass GtkLabelClass;
typedef struct _GtkLabelWord GtkLabelWord;
struct _GtkLabel
{
GtkMisc misc;
gchar *label;
gchar *label;
GdkWChar *label_wc;
gchar *pattern;
GSList *row;
GtkLabelWord *words;
guint max_width : 16;
guint jtype : 2;
gboolean wrap;
};
struct _GtkLabelClass
@ -56,17 +61,18 @@ struct _GtkLabelClass
};
GtkType gtk_label_get_type (void);
GtkWidget* gtk_label_new (const gchar *string);
void gtk_label_set (GtkLabel *label,
const gchar *string);
void gtk_label_set_pattern (GtkLabel *label,
const gchar *pattern);
void gtk_label_set_justify (GtkLabel *label,
GtkJustification jtype);
void gtk_label_get (GtkLabel *label,
gchar **string);
guint gtk_label_get_type (void);
GtkWidget* gtk_label_new (const char *str);
void gtk_label_set_text (GtkLabel *label,
const char *str);
void gtk_label_set_justify (GtkLabel *label,
GtkJustification jtype);
void gtk_label_set_pattern (GtkLabel *label,
const gchar *pattern);
void gtk_label_set_line_wrap (GtkLabel *label,
gboolean wrap);
void gtk_label_get (GtkLabel *label,
char **str);
/* Convenience function to set the name and pattern by parsing
* a string with embedded underscores, and return the appropriate

View File

@ -1955,7 +1955,7 @@ gtk_notebook_update_labels (GtkNotebook *notebook)
GTK_WIDGET (notebook));
}
else
gtk_label_set (GTK_LABEL (page->tab_label), string);
gtk_label_set_text (GTK_LABEL (page->tab_label), string);
}
if (GTK_WIDGET_VISIBLE (page->child) &&
@ -1968,10 +1968,10 @@ gtk_notebook_update_labels (GtkNotebook *notebook)
if (notebook->menu && page->default_menu)
{
if (page->tab_label && GTK_IS_LABEL (page->tab_label))
gtk_label_set (GTK_LABEL (page->menu_label),
gtk_label_set_text (GTK_LABEL (page->menu_label),
GTK_LABEL (page->tab_label)->label);
else
gtk_label_set (GTK_LABEL (page->menu_label), string);
gtk_label_set_text (GTK_LABEL (page->menu_label), string);
}
}
}

View File

@ -155,7 +155,7 @@ gtk_statusbar_update (GtkStatusbar *statusbar,
if (!text)
text = "";
gtk_label_set (GTK_LABEL (statusbar->label), text);
gtk_label_set_text (GTK_LABEL (statusbar->label), text);
}
guint

View File

@ -173,7 +173,7 @@ gtk_tips_query_init (GtkTipsQuery *tips_query)
tips_query->last_crossed = NULL;
tips_query->query_cursor = NULL;
gtk_label_set (GTK_LABEL (tips_query), tips_query->label_inactive);
gtk_label_set_text (GTK_LABEL (tips_query), tips_query->label_inactive);
}
static void
@ -367,7 +367,7 @@ gtk_tips_query_real_stop_query (GtkTipsQuery *tips_query)
tips_query->last_crossed = NULL;
}
gtk_label_set (GTK_LABEL (tips_query), tips_query->label_inactive);
gtk_label_set_text (GTK_LABEL (tips_query), tips_query->label_inactive);
}
static void
@ -383,7 +383,7 @@ gtk_tips_query_widget_entered (GtkTipsQuery *tips_query,
tip_text = tips_query->label_no_tip;
if (!g_str_equal (GTK_LABEL (tips_query)->label, (gchar*) tip_text))
gtk_label_set (GTK_LABEL (tips_query), tip_text);
gtk_label_set_text (GTK_LABEL (tips_query), tip_text);
}
static void

View File

@ -1622,6 +1622,96 @@ create_handle_box (void)
gtk_widget_destroy (window);
}
/*
* Label Demo
*/
void create_labels (void)
{
static GtkWidget *window = NULL;
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *frame;
GtkWidget *label;
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
&window);
gtk_window_set_title (GTK_WINDOW (window), "Label");
vbox = gtk_vbox_new (FALSE, 5);
hbox = gtk_hbox_new (FALSE, 5);
gtk_container_add (GTK_CONTAINER (window), hbox);
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (window), 5);
frame = gtk_frame_new ("Normal Label");
label = gtk_label_new ("This is a Normal label");
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
frame = gtk_frame_new ("Multi-line Label");
label = gtk_label_new ("This is a Multi-line label.\nSecond line\nThird line");
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
frame = gtk_frame_new ("Left Justified Label");
label = gtk_label_new ("This is a Left-Justified\nMulti-line label.\nThird line");
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
frame = gtk_frame_new ("Right Justified Label");
label = gtk_label_new ("This is a Right-Justified\nMulti-line label.\nFourth line, (j/k)");
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT);
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
vbox = gtk_vbox_new (FALSE, 5);
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
frame = gtk_frame_new ("Line wrapped label");
label = gtk_label_new ("This is an example of a line-wrapped label. It should not be taking "\
"up the entire "/* big space to test spacing */\
"width allocated to it, but automatically wraps the words to fit. "\
"The time has come, for all good men, to come to the aid of their party. "\
"The sixth sheik's six sheep's sick.\n"\
" It supports multiple paragraphs correctly, and correctly adds "\
"many extra spaces. ");
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
frame = gtk_frame_new ("Filled, wrapped label");
label = gtk_label_new ("This is an example of a line-wrapped, filled label. It should be taking "\
"up the entire width allocated to it. Here is a seneance to prove "\
"my point. Here is another sentence. "\
"Here comes the sun, do de do de do.\n"\
" This is a new paragraph.\n"\
" This is another newer, longer, better paragraph. It is coming to an end, "\
"unfortunately.");
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_FILL);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
frame = gtk_frame_new ("Underlined label");
label = gtk_label_new ("This label is underlined!\n"
"This one is underlined in ÆüËܸì¤ÎÆþÍÑquite a funky fashion");
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
gtk_label_set_pattern (GTK_LABEL (label), "_________________________ _ _________ _ _____ _ __ __ ___ ____ _____");
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
}
if (!GTK_WIDGET_VISIBLE (window))
gtk_widget_show_all (window);
else
gtk_widget_destroy (window);
}
/*
* Reparent demo
*/
@ -1755,9 +1845,9 @@ uposition_configure (GtkWidget *window)
gdk_window_get_root_origin (window->window, &upositionx, &upositiony);
sprintf (buffer, "%d", upositionx);
gtk_label_set (lx, buffer);
gtk_label_set_text (lx, buffer);
sprintf (buffer, "%d", upositiony);
gtk_label_set (ly, buffer);
gtk_label_set_text (ly, buffer);
return FALSE;
}
@ -1935,7 +2025,7 @@ tips_query_widget_entered (GtkTipsQuery *tips_query,
{
if (GTK_TOGGLE_BUTTON (toggle)->active)
{
gtk_label_set (GTK_LABEL (tips_query), tip_text ? "There is a Tip!" : "There is no Tip!");
gtk_label_set_text (GTK_LABEL (tips_query), tip_text ? "There is a Tip!" : "There is no Tip!");
/* don't let GtkTipsQuery reset it's label */
gtk_signal_emit_stop_by_name (GTK_OBJECT (tips_query), "widget_entered");
}
@ -2772,7 +2862,7 @@ get_value (GtkWidget *widget, gpointer data)
else
sprintf (buf, "%0.*f", spin->digits,
gtk_spin_button_get_value_as_float (spin));
gtk_label_set (label, buf);
gtk_label_set_text (label, buf);
}
static void
@ -2939,7 +3029,7 @@ create_spins (void)
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 5);
gtk_box_pack_start (GTK_BOX (vbox), val_label, TRUE, TRUE, 0);
gtk_label_set (GTK_LABEL (val_label), "0");
gtk_label_set_text (GTK_LABEL (val_label), "0");
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, TRUE, 0);
@ -3026,9 +3116,9 @@ set_cursor (GtkWidget *spinner,
while (vals && vals->value != c)
vals++;
if (vals)
gtk_label_set (GTK_LABEL (label), vals->value_nick);
gtk_label_set_text (GTK_LABEL (label), vals->value_nick);
else
gtk_label_set (GTK_LABEL (label), "<unknown>");
gtk_label_set_text (GTK_LABEL (label), "<unknown>");
cursor = gdk_cursor_new (c);
gdk_window_set_cursor (widget->window, cursor);
@ -4153,16 +4243,16 @@ void after_press (GtkCTree *ctree, gpointer data)
char buf[80];
sprintf (buf, "%d", g_list_length (GTK_CLIST (ctree)->selection));
gtk_label_set (GTK_LABEL (sel_label), buf);
gtk_label_set_text (GTK_LABEL (sel_label), buf);
sprintf (buf, "%d", g_list_length (GTK_CLIST (ctree)->row_list));
gtk_label_set (GTK_LABEL (vis_label), buf);
gtk_label_set_text (GTK_LABEL (vis_label), buf);
sprintf (buf, "%d", books);
gtk_label_set (GTK_LABEL (book_label), buf);
gtk_label_set_text (GTK_LABEL (book_label), buf);
sprintf (buf, "%d", pages);
gtk_label_set (GTK_LABEL (page_label), buf);
gtk_label_set_text (GTK_LABEL (page_label), buf);
}
void after_move (GtkCTree *ctree, GtkCTreeNode *child, GtkCTreeNode *parent,
@ -6930,7 +7020,7 @@ progress_value_changed (GtkAdjustment *adj, ProgressData *pdata)
else
sprintf (buf, "%.0f%%", 100 *
gtk_progress_get_current_percentage (GTK_PROGRESS (pdata->pbar)));
gtk_label_set (GTK_LABEL (pdata->label), buf);
gtk_label_set_text (GTK_LABEL (pdata->label), buf);
}
static void
@ -7795,7 +7885,7 @@ timeout_test (GtkWidget *label)
static char buffer[32];
sprintf (buffer, "count: %d", ++count);
gtk_label_set (GTK_LABEL (label), buffer);
gtk_label_set_text (GTK_LABEL (label), buffer);
return TRUE;
}
@ -7902,7 +7992,7 @@ idle_test (GtkWidget *label)
static char buffer[32];
sprintf (buffer, "count: %d", ++count);
gtk_label_set (GTK_LABEL (label), buffer);
gtk_label_set_text (GTK_LABEL (label), buffer);
return TRUE;
}
@ -8347,6 +8437,7 @@ create_main_window (void)
{ "gamma curve", create_gamma_curve },
{ "handle box", create_handle_box },
{ "item factory", create_item_factory },
{ "labels", create_labels },
{ "layout", create_layout },
{ "list", create_list },
{ "menus", create_menus },

View File

@ -82,7 +82,7 @@ counter (void *data)
while (!flag)
{
sprintf(buffer, "%d", counter);
gtk_label_set (GTK_LABEL (label), buffer);
gtk_label_set_text (GTK_LABEL (label), buffer);
gtk_threads_leave();
counter++;
/* Give someone else a chance to get the lock next time.

View File

@ -1622,6 +1622,96 @@ create_handle_box (void)
gtk_widget_destroy (window);
}
/*
* Label Demo
*/
void create_labels (void)
{
static GtkWidget *window = NULL;
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *frame;
GtkWidget *label;
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
&window);
gtk_window_set_title (GTK_WINDOW (window), "Label");
vbox = gtk_vbox_new (FALSE, 5);
hbox = gtk_hbox_new (FALSE, 5);
gtk_container_add (GTK_CONTAINER (window), hbox);
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (window), 5);
frame = gtk_frame_new ("Normal Label");
label = gtk_label_new ("This is a Normal label");
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
frame = gtk_frame_new ("Multi-line Label");
label = gtk_label_new ("This is a Multi-line label.\nSecond line\nThird line");
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
frame = gtk_frame_new ("Left Justified Label");
label = gtk_label_new ("This is a Left-Justified\nMulti-line label.\nThird line");
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
frame = gtk_frame_new ("Right Justified Label");
label = gtk_label_new ("This is a Right-Justified\nMulti-line label.\nFourth line, (j/k)");
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT);
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
vbox = gtk_vbox_new (FALSE, 5);
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
frame = gtk_frame_new ("Line wrapped label");
label = gtk_label_new ("This is an example of a line-wrapped label. It should not be taking "\
"up the entire "/* big space to test spacing */\
"width allocated to it, but automatically wraps the words to fit. "\
"The time has come, for all good men, to come to the aid of their party. "\
"The sixth sheik's six sheep's sick.\n"\
" It supports multiple paragraphs correctly, and correctly adds "\
"many extra spaces. ");
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
frame = gtk_frame_new ("Filled, wrapped label");
label = gtk_label_new ("This is an example of a line-wrapped, filled label. It should be taking "\
"up the entire width allocated to it. Here is a seneance to prove "\
"my point. Here is another sentence. "\
"Here comes the sun, do de do de do.\n"\
" This is a new paragraph.\n"\
" This is another newer, longer, better paragraph. It is coming to an end, "\
"unfortunately.");
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_FILL);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
frame = gtk_frame_new ("Underlined label");
label = gtk_label_new ("This label is underlined!\n"
"This one is underlined in ÆüËܸì¤ÎÆþÍÑquite a funky fashion");
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
gtk_label_set_pattern (GTK_LABEL (label), "_________________________ _ _________ _ _____ _ __ __ ___ ____ _____");
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
}
if (!GTK_WIDGET_VISIBLE (window))
gtk_widget_show_all (window);
else
gtk_widget_destroy (window);
}
/*
* Reparent demo
*/
@ -1755,9 +1845,9 @@ uposition_configure (GtkWidget *window)
gdk_window_get_root_origin (window->window, &upositionx, &upositiony);
sprintf (buffer, "%d", upositionx);
gtk_label_set (lx, buffer);
gtk_label_set_text (lx, buffer);
sprintf (buffer, "%d", upositiony);
gtk_label_set (ly, buffer);
gtk_label_set_text (ly, buffer);
return FALSE;
}
@ -1935,7 +2025,7 @@ tips_query_widget_entered (GtkTipsQuery *tips_query,
{
if (GTK_TOGGLE_BUTTON (toggle)->active)
{
gtk_label_set (GTK_LABEL (tips_query), tip_text ? "There is a Tip!" : "There is no Tip!");
gtk_label_set_text (GTK_LABEL (tips_query), tip_text ? "There is a Tip!" : "There is no Tip!");
/* don't let GtkTipsQuery reset it's label */
gtk_signal_emit_stop_by_name (GTK_OBJECT (tips_query), "widget_entered");
}
@ -2772,7 +2862,7 @@ get_value (GtkWidget *widget, gpointer data)
else
sprintf (buf, "%0.*f", spin->digits,
gtk_spin_button_get_value_as_float (spin));
gtk_label_set (label, buf);
gtk_label_set_text (label, buf);
}
static void
@ -2939,7 +3029,7 @@ create_spins (void)
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 5);
gtk_box_pack_start (GTK_BOX (vbox), val_label, TRUE, TRUE, 0);
gtk_label_set (GTK_LABEL (val_label), "0");
gtk_label_set_text (GTK_LABEL (val_label), "0");
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, TRUE, 0);
@ -3026,9 +3116,9 @@ set_cursor (GtkWidget *spinner,
while (vals && vals->value != c)
vals++;
if (vals)
gtk_label_set (GTK_LABEL (label), vals->value_nick);
gtk_label_set_text (GTK_LABEL (label), vals->value_nick);
else
gtk_label_set (GTK_LABEL (label), "<unknown>");
gtk_label_set_text (GTK_LABEL (label), "<unknown>");
cursor = gdk_cursor_new (c);
gdk_window_set_cursor (widget->window, cursor);
@ -4153,16 +4243,16 @@ void after_press (GtkCTree *ctree, gpointer data)
char buf[80];
sprintf (buf, "%d", g_list_length (GTK_CLIST (ctree)->selection));
gtk_label_set (GTK_LABEL (sel_label), buf);
gtk_label_set_text (GTK_LABEL (sel_label), buf);
sprintf (buf, "%d", g_list_length (GTK_CLIST (ctree)->row_list));
gtk_label_set (GTK_LABEL (vis_label), buf);
gtk_label_set_text (GTK_LABEL (vis_label), buf);
sprintf (buf, "%d", books);
gtk_label_set (GTK_LABEL (book_label), buf);
gtk_label_set_text (GTK_LABEL (book_label), buf);
sprintf (buf, "%d", pages);
gtk_label_set (GTK_LABEL (page_label), buf);
gtk_label_set_text (GTK_LABEL (page_label), buf);
}
void after_move (GtkCTree *ctree, GtkCTreeNode *child, GtkCTreeNode *parent,
@ -6930,7 +7020,7 @@ progress_value_changed (GtkAdjustment *adj, ProgressData *pdata)
else
sprintf (buf, "%.0f%%", 100 *
gtk_progress_get_current_percentage (GTK_PROGRESS (pdata->pbar)));
gtk_label_set (GTK_LABEL (pdata->label), buf);
gtk_label_set_text (GTK_LABEL (pdata->label), buf);
}
static void
@ -7795,7 +7885,7 @@ timeout_test (GtkWidget *label)
static char buffer[32];
sprintf (buffer, "count: %d", ++count);
gtk_label_set (GTK_LABEL (label), buffer);
gtk_label_set_text (GTK_LABEL (label), buffer);
return TRUE;
}
@ -7902,7 +7992,7 @@ idle_test (GtkWidget *label)
static char buffer[32];
sprintf (buffer, "count: %d", ++count);
gtk_label_set (GTK_LABEL (label), buffer);
gtk_label_set_text (GTK_LABEL (label), buffer);
return TRUE;
}
@ -8347,6 +8437,7 @@ create_main_window (void)
{ "gamma curve", create_gamma_curve },
{ "handle box", create_handle_box },
{ "item factory", create_item_factory },
{ "labels", create_labels },
{ "layout", create_layout },
{ "list", create_list },
{ "menus", create_menus },

View File

@ -82,7 +82,7 @@ counter (void *data)
while (!flag)
{
sprintf(buffer, "%d", counter);
gtk_label_set (GTK_LABEL (label), buffer);
gtk_label_set_text (GTK_LABEL (label), buffer);
gtk_threads_leave();
counter++;
/* Give someone else a chance to get the lock next time.