diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2003-01-24 03:30:48 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2003-01-24 03:30:48 +0800 |
commit | b110f7e404759128793256335e7bff866ce97d81 (patch) | |
tree | 1ea0326f2de7de7b6afebd70256c98febccff03e | |
parent | 82978ed2aeeaca044d3df85b21c59c9c8f0d3b2b (diff) | |
download | gsoc2013-evolution-b110f7e404759128793256335e7bff866ce97d81.tar.gz gsoc2013-evolution-b110f7e404759128793256335e7bff866ce97d81.tar.zst gsoc2013-evolution-b110f7e404759128793256335e7bff866ce97d81.zip |
Make the label bold using the new args to e_clipped_label_new().
* e-title-bar.c (e_title_bar_construct): Make the label bold using
the new args to e_clipped_label_new().
* e-clipped-label.c (build_layout): Honor ->font_size and ->layout
in the newly created PangoLayout.
(e_clipped_label_new): New args font_weight, font_size.
(e_clipped_label_size_request): Removed unused variables.
(e_clipped_label_expose): Likewise.
(e_clipped_label_expose): Likewise.
(e_clipped_label_set_text): Likewise.
(e_clipped_label_recalc_chars_displayed): Likewise.
* e-clipped-label.h (struct _EClippedLabel): Add font_size, layout
members.
svn path=/trunk/; revision=19591
-rw-r--r-- | widgets/misc/ChangeLog | 17 | ||||
-rw-r--r-- | widgets/misc/e-clipped-label.c | 43 | ||||
-rw-r--r-- | widgets/misc/e-clipped-label.h | 18 | ||||
-rw-r--r-- | widgets/misc/e-title-bar.c | 2 |
4 files changed, 48 insertions, 32 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog index 53f34e53b9..6ff9920510 100644 --- a/widgets/misc/ChangeLog +++ b/widgets/misc/ChangeLog @@ -1,3 +1,20 @@ +2003-01-23 Ettore Perazzoli <ettore@ximian.com> + + * e-title-bar.c (e_title_bar_construct): Make the label bold using + the new args to e_clipped_label_new(). + + * e-clipped-label.c (build_layout): Honor ->font_size and ->layout + in the newly created PangoLayout. + (e_clipped_label_new): New args font_weight, font_size. + (e_clipped_label_size_request): Removed unused variables. + (e_clipped_label_expose): Likewise. + (e_clipped_label_expose): Likewise. + (e_clipped_label_set_text): Likewise. + (e_clipped_label_recalc_chars_displayed): Likewise. + + * e-clipped-label.h (struct _EClippedLabel): Add font_size, layout + members. + 2003-01-22 Ettore Perazzoli <ettore@ximian.com> * Makefile.am (widgetsincludedir): Version using $(BASE_VERSION). diff --git a/widgets/misc/e-clipped-label.c b/widgets/misc/e-clipped-label.c index e650b4ee96..30c7eb6bba 100644 --- a/widgets/misc/e-clipped-label.c +++ b/widgets/misc/e-clipped-label.c @@ -131,7 +131,9 @@ e_clipped_label_init (EClippedLabel *label) * Creates a new #EClippedLabel with the given text. **/ GtkWidget * -e_clipped_label_new (const gchar *text) +e_clipped_label_new (const gchar *text, + PangoWeight font_weight, + gfloat font_size) { GtkWidget *label; EClippedLabel *clipped; @@ -140,6 +142,9 @@ e_clipped_label_new (const gchar *text) clipped = E_CLIPPED_LABEL (label); + clipped->font_size = font_size; + clipped->font_weight = font_weight; + build_layout (clipped, e_clipped_label_ellipsis); pango_layout_get_pixel_size (clipped->layout, &clipped->ellipsis_width, NULL); @@ -153,26 +158,19 @@ static void build_layout (EClippedLabel *label, const char *text) { if (!label->layout) { + GtkStyle *style = gtk_widget_get_style (GTK_WIDGET (label)); + PangoFontDescription *desc = pango_font_description_copy (style->font_desc); + label->layout = gtk_widget_create_pango_layout (GTK_WIDGET (label), text); -#ifdef FROB_FONT_DESC - { - /* this makes the font used a little bigger than the - default style for this widget, as well as makes it - bold... */ - GtkStyle *style = gtk_widget_get_style (GTK_WIDGET (label)); - PangoFontDescription *desc = pango_font_description_copy (style->font_desc); - pango_font_description_set_size (desc, - pango_font_description_get_size (desc) * 1.2); + + pango_font_description_set_size (desc, pango_font_description_get_size (desc) * label->font_size); - pango_font_description_set_weight (desc, PANGO_WEIGHT_BOLD); - pango_layout_set_font_description (layout, desc); - pango_font_description_free (desc); - } -#endif - } - else { - pango_layout_set_text (label->layout, text, -1); + pango_font_description_set_weight (desc, label->font_weight); + pango_layout_set_font_description (label->layout, desc); + pango_font_description_free (desc); } + + pango_layout_set_text (label->layout, text, -1); } static void @@ -180,7 +178,6 @@ e_clipped_label_size_request (GtkWidget *widget, GtkRequisition *requisition) { EClippedLabel *label; - GdkFont *font; int height; int width; @@ -217,8 +214,7 @@ e_clipped_label_expose (GtkWidget *widget, { EClippedLabel *label; GtkMisc *misc; - gint x, y; - gchar *tmp_str, tmp_ch; + gint x; PangoRectangle rect; g_return_val_if_fail (E_IS_CLIPPED_LABEL (widget), FALSE); @@ -335,8 +331,6 @@ void e_clipped_label_set_text (EClippedLabel *label, const gchar *text) { - gint len; - g_return_if_fail (E_IS_CLIPPED_LABEL (label)); if (label->label != text || !label->label || !text @@ -363,7 +357,7 @@ e_clipped_label_set_text (EClippedLabel *label, static void e_clipped_label_recalc_chars_displayed (EClippedLabel *label) { - gint max_width, width, ch, last_width, ellipsis_width; + gint max_width, width; GSList *lines; PangoLayoutLine *line; int index; @@ -426,4 +420,3 @@ e_clipped_label_recalc_chars_displayed (EClippedLabel *label) label->ellipsis_x = width; } - diff --git a/widgets/misc/e-clipped-label.h b/widgets/misc/e-clipped-label.h index ab0d741ebf..b0165b3e7d 100644 --- a/widgets/misc/e-clipped-label.h +++ b/widgets/misc/e-clipped-label.h @@ -51,6 +51,11 @@ struct _EClippedLabel gchar *label; + /* Font size multiplication factor; 1.0 means "default GTK font + size" */ + gfloat font_size; + PangoWeight font_weight; + /* Our PangoLayout */ PangoLayout *layout; @@ -81,13 +86,14 @@ struct _EClippedLabelClass }; -GtkType e_clipped_label_get_type (void); -GtkWidget* e_clipped_label_new (const gchar *text); - -gchar* e_clipped_label_get_text (EClippedLabel *label); -void e_clipped_label_set_text (EClippedLabel *label, - const gchar *text); +GtkType e_clipped_label_get_type (void); +GtkWidget *e_clipped_label_new (const gchar *text, + PangoWeight font_weight, + gfloat font_size); +gchar *e_clipped_label_get_text (EClippedLabel *label); +void e_clipped_label_set_text (EClippedLabel *label, + const gchar *text); #ifdef __cplusplus } diff --git a/widgets/misc/e-title-bar.c b/widgets/misc/e-title-bar.c index f5ce0f97c4..4d4e36e45b 100644 --- a/widgets/misc/e-title-bar.c +++ b/widgets/misc/e-title-bar.c @@ -305,7 +305,7 @@ e_title_bar_construct (ETitleBar *title_bar, priv = title_bar->priv; - priv->label = e_clipped_label_new (title); + priv->label = e_clipped_label_new (title, PANGO_WEIGHT_BOLD, 1.0); gtk_misc_set_alignment (GTK_MISC (priv->label), 0.0, 0.5); gtk_misc_set_padding (GTK_MISC (priv->label), 2, 0); gtk_widget_show (priv->label); |