2007-06-15  Matthew Barnes  <mbarnes@redhat.com>

	** Fixes bug #447727

	* po/POTFILES.in: Remove e-clipped-label.c

	* mail/mail-send-recv.c:
	* shell/e-shell-folder-title-bar.c:
	* widgets/misc/e-info-label.c:
	* widgets/misc/e-multi-config-dialog.c:
	* widgets/misc/e-task-bar.c:
	Use ellipsized GtkLabels instead of EClippedLabels.

	* widgets/misc/e-clipped-label.[ch]:
	Remove these files.  GTK+ provides this functionality now.

	* widgets/misc/Makefile.am:
	Remove e-clipped-label.[ch].


svn path=/trunk/; revision=33680
This commit is contained in:
Matthew Barnes
2007-06-15 13:58:34 +00:00
committed by Matthew Barnes
parent a3f0966a69
commit 60f7f10f45
13 changed files with 112 additions and 608 deletions

View File

@ -1,3 +1,8 @@
2007-06-15 Matthew Barnes <mbarnes@redhat.com>
* mail-send-recv.c:
Use ellipsized GtkLabels instead of EClippedLabels (#447727).
2007-06-13 Sankar P <psankar@novell.com>
* em-folder-view.c:

View File

@ -43,7 +43,6 @@
#include "libedataserver/e-account-list.h"
#include "misc/e-clipped-label.h"
#include "em-filter-rule.h"
#include "camel/camel-filter-driver.h"
#include "camel/camel-folder.h"
@ -156,8 +155,8 @@ receive_cancel(GtkButton *button, struct _send_info *info)
if (info->state == SEND_ACTIVE) {
camel_operation_cancel(info->cancel);
if (info->status_label)
e_clipped_label_set_text (
E_CLIPPED_LABEL (info->status_label),
gtk_label_set_text (
GTK_LABEL (info->status_label),
_("Canceling..."));
info->state = SEND_CANCELLED;
}
@ -267,8 +266,8 @@ operation_status_timeout(void *data)
GTK_PROGRESS_BAR (info->progress_bar),
info->pc / 100.0);
if (info->what)
e_clipped_label_set_text (
E_CLIPPED_LABEL (info->status_label),
gtk_label_set_text (
GTK_LABEL (info->status_label),
info->what);
return TRUE;
}
@ -496,10 +495,11 @@ build_dialog (EAccountList *accounts, CamelFolder *outbox, const char *destinati
cancel_button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
status_label = e_clipped_label_new (
status_label = gtk_label_new (
(info->type == SEND_UPDATE) ?
_("Updating...") : _("Waiting..."),
PANGO_WEIGHT_NORMAL, 1.0);
_("Updating...") : _("Waiting..."));
gtk_label_set_ellipsize (
GTK_LABEL (status_label), PANGO_ELLIPSIZE_END);
/* g_object_set(data->label, "bold", TRUE, NULL); */
gtk_misc_set_alignment (GTK_MISC (label), 0, .5);
@ -566,8 +566,9 @@ build_dialog (EAccountList *accounts, CamelFolder *outbox, const char *destinati
progress_bar = gtk_progress_bar_new ();
cancel_button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
status_label = e_clipped_label_new (
_("Waiting..."), PANGO_WEIGHT_NORMAL, 1.0);
status_label = gtk_label_new (_("Waiting..."));
gtk_label_set_ellipsize (
GTK_LABEL (status_label), PANGO_ELLIPSIZE_END);
gtk_misc_set_alignment (GTK_MISC (label), 0, .5);
gtk_misc_set_alignment (GTK_MISC (status_label), 0, .5);
@ -692,8 +693,7 @@ receive_done (char *uri, void *data)
info->state = SEND_COMPLETE;
}
e_clipped_label_set_text (
E_CLIPPED_LABEL (info->status_label), text);
gtk_label_set_text (GTK_LABEL (info->status_label), text);
}
if (info->cancel_button)

View File

@ -1,3 +1,7 @@
2007-06-15 Matthew Barnes <mbarnes@redhat.com>
* POTFILES.in: Remove e-clipped-label.c
2007-06-15 Jorge Gonzalez <jorgegonz@svn.gnome.org>
* es.po: Updated Spanish translation

View File

@ -467,7 +467,6 @@ widgets/misc/e-canvas-vbox.c
widgets/misc/e-cell-date-edit.c
widgets/misc/e-cell-percent.c
widgets/misc/e-charset-picker.c
widgets/misc/e-clipped-label.c
widgets/misc/e-dateedit.c
widgets/misc/e-expander.c
widgets/misc/e-filter-bar.c

View File

@ -1,3 +1,8 @@
2007-06-15 Matthew Barnes <mbarnes@redhat.com>
* e-shell-folder-title-bar.c:
Use ellipsized GtkLabels instead of EClippedLabels (#447727).
2007-06-03 Srinivasa Ragavan <sragavan@novell.com>
** Fix for bug #386503 from Matthew Barnes

View File

@ -34,7 +34,6 @@
#include <glib/gi18n.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "misc/e-clipped-label.h"
#include "e-shell-constants.h"
#include "e-shell-marshal.h"
#include "e-shell-folder-title-bar.h"
@ -117,13 +116,15 @@ new_empty_image_widget (void)
/* Utility functions. */
static int
get_max_clipped_label_width (EClippedLabel *clipped_label)
static gint
get_max_label_width (GtkWidget *label)
{
int width;
PangoLayout *layout;
gint width;
pango_layout_get_pixel_size (clipped_label->layout, &width, NULL);
width += 2 * GTK_MISC (clipped_label)->xpad;
layout = gtk_label_get_layout (GTK_LABEL (label));
pango_layout_get_pixel_size (layout, &width, NULL);
width += 2 * GTK_MISC (label)->xpad;
return width;
}
@ -152,7 +153,7 @@ size_allocate_title_button (EShellFolderTitleBar *title_bar,
child_allocation.height = allocation->height - 2 * border_width;
child_allocation.width = child_requisition.width;
child_allocation.width += get_max_clipped_label_width (E_CLIPPED_LABEL (priv->title_button_label));
child_allocation.width += get_max_label_width (priv->title_button_label);
child_allocation.width = MIN (child_allocation.width, *available_width_inout);
@ -218,7 +219,7 @@ size_allocate_label (EShellFolderTitleBar *title_bar,
child_allocation.y = allocation->y + border_width;
child_allocation.height = allocation->height - 2 * border_width;
child_allocation.width = MIN (get_max_clipped_label_width (E_CLIPPED_LABEL (priv->title_label)),
child_allocation.width = MIN (get_max_label_width (priv->title_label),
*available_width_inout);
gtk_widget_size_allocate (priv->title_label, & child_allocation);
@ -478,6 +479,7 @@ e_shell_folder_title_bar_construct (EShellFolderTitleBar *folder_title_bar)
{
EShellFolderTitleBarPrivate *priv;
GtkWidget *title_button_hbox;
GtkWidget *label;
g_return_if_fail (folder_title_bar != NULL);
g_return_if_fail (E_IS_SHELL_FOLDER_TITLE_BAR (folder_title_bar));
@ -489,18 +491,24 @@ e_shell_folder_title_bar_construct (EShellFolderTitleBar *folder_title_bar)
gtk_misc_set_padding (GTK_MISC (priv->title_icon), 2, 0);
gtk_widget_show (priv->title_icon);
priv->title_label = e_clipped_label_new ("", PANGO_WEIGHT_BOLD, 1.2);
gtk_misc_set_padding (GTK_MISC (priv->title_label), 0, 0);
gtk_misc_set_alignment (GTK_MISC (priv->title_label), 0.0, 0.5);
label = gtk_label_new ("");
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
gtk_misc_set_padding (GTK_MISC (label), 0, 0);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
priv->title_label = label;
priv->title_button_label = e_clipped_label_new ("", PANGO_WEIGHT_BOLD, 1.2);
gtk_misc_set_padding (GTK_MISC (priv->title_button_label), 2, 0);
gtk_misc_set_alignment (GTK_MISC (priv->title_button_label), 0.0, 0.5);
gtk_widget_show (priv->title_button_label);
label = gtk_label_new ("");
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
gtk_misc_set_padding (GTK_MISC (label), 2, 0);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_widget_show (label);
priv->title_button_label = label;
priv->folder_bar_label = e_clipped_label_new ("", PANGO_WEIGHT_NORMAL, 1.0);
gtk_misc_set_alignment (GTK_MISC (priv->folder_bar_label), 1.0, 0.5);
gtk_widget_show (priv->folder_bar_label);
label = gtk_label_new ("");
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_widget_show (label);
priv->folder_bar_label = label;
priv->title_button_icon = new_empty_image_widget ();
gtk_widget_show (priv->title_button_icon);
@ -574,21 +582,21 @@ e_shell_folder_title_bar_set_title (EShellFolderTitleBar *folder_title_bar,
const char *title)
{
EShellFolderTitleBarPrivate *priv;
gchar *markup;
g_return_if_fail (folder_title_bar != NULL);
g_return_if_fail (E_IS_SHELL_FOLDER_TITLE_BAR (folder_title_bar));
priv = folder_title_bar->priv;
if (title == NULL) {
e_clipped_label_set_text (E_CLIPPED_LABEL (priv->title_button_label), _("(Untitled)"));
e_clipped_label_set_text (E_CLIPPED_LABEL (priv->title_label), _("(Untitled)"));
} else {
e_clipped_label_set_text (E_CLIPPED_LABEL (priv->title_button_label), title);
e_clipped_label_set_text (E_CLIPPED_LABEL (priv->title_label), title);
}
if (title == NULL)
title = _("Untitled");
markup = g_markup_printf_escaped ("<big><b>%s</b></big>", title);
gtk_label_set_markup (GTK_LABEL (priv->title_button_label), markup);
gtk_label_set_markup (GTK_LABEL (priv->title_label), markup);
g_free (markup);
/* FIXME: There seems to be a bug in EClippedLabel, this is just a workaround. */
gtk_widget_queue_resize (GTK_WIDGET (folder_title_bar));
}
@ -611,10 +619,7 @@ e_shell_folder_title_bar_set_folder_bar_label (EShellFolderTitleBar *folder_titl
priv = folder_title_bar->priv;
if (text == NULL)
e_clipped_label_set_text (E_CLIPPED_LABEL (priv->folder_bar_label), "");
else
e_clipped_label_set_text (E_CLIPPED_LABEL (priv->folder_bar_label), text);
gtk_label_set_text (GTK_LABEL (priv->folder_bar_label), text);
/* FIXME: Might want to set the styles somewhere in here too,
black text on grey background isn't the best combination */

View File

@ -1,3 +1,18 @@
2007-06-15 Matthew Barnes <mbarnes@redhat.com>
** Fixes part of bug #447727
* e-info-label.c:
* e-multi-config-dialog.c:
* e-task-bar.c:
Use ellipsized GtkLabels instead of EClippedLabels.
* e-clipped-label.[ch]:
Remove these files. GTK+ provides this functionality now.
* Makefile.am:
Remove e-clipped-label.[ch].
2007-06-04 Chenthill Palanisamy <pchenthill@novell.com>
* e-filter-bar.[c]: (e_filter_bar_new), (e_filter_bar_new_construct):

View File

@ -45,7 +45,6 @@ widgetsinclude_HEADERS = \
e-cell-percent.h \
e-cell-renderer-combo.h \
e-charset-picker.h \
e-clipped-label.h \
e-combo-cell-editable.h \
e-config-page.h \
e-combo-button.h \
@ -91,7 +90,6 @@ libemiscwidgets_la_SOURCES = \
e-cell-percent.c \
e-cell-renderer-combo.c \
e-charset-picker.c \
e-clipped-label.c \
e-combo-cell-editable.c \
e-config-page.c \
e-combo-button.c \

View File

@ -1,420 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Author :
* Damon Chaplin <damon@ximian.com>
*
* Copyright 1999, Ximian, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
/*
* This is similar to GtkLabel but clips itself and displays '...' if it
* can't fit inside its allocated area. The intended use is for inside buttons
* that are a fixed size. The GtkLabel would normally display only the middle
* part of the text, which doesn't look very good. This only supports one line
* of text (so no wrapping/justification), without underlined characters.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "e-clipped-label.h"
#include <math.h>
#include <string.h>
#include <glib.h>
#include <gdk/gdki18n.h>
#include <glib/gi18n.h>
static void e_clipped_label_class_init (EClippedLabelClass *class);
static void e_clipped_label_init (EClippedLabel *label);
static void e_clipped_label_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void e_clipped_label_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static gint e_clipped_label_expose (GtkWidget *widget,
GdkEventExpose *event);
static void e_clipped_label_recalc_chars_displayed (EClippedLabel *label);
static void e_clipped_label_finalize (GObject *object);
static void build_layout (EClippedLabel *label, const char *text);
static GtkMiscClass *parent_class;
/* This is the string to draw when the label is clipped, e.g. '...'. */
static gchar *e_clipped_label_ellipsis;
/* Flags used in chars_displayed field. Must be negative. */
#define E_CLIPPED_LABEL_NEED_RECALC -1
#define E_CLIPPED_LABEL_SHOW_ENTIRE_LABEL -2
GtkType
e_clipped_label_get_type (void)
{
static GtkType e_clipped_label_type = 0;
if (!e_clipped_label_type){
GtkTypeInfo e_clipped_label_info = {
"EClippedLabel",
sizeof (EClippedLabel),
sizeof (EClippedLabelClass),
(GtkClassInitFunc) e_clipped_label_class_init,
(GtkObjectInitFunc) e_clipped_label_init,
NULL, /* reserved 1 */
NULL, /* reserved 2 */
(GtkClassInitFunc) NULL
};
parent_class = g_type_class_ref(GTK_TYPE_MISC);
e_clipped_label_type = gtk_type_unique (GTK_TYPE_MISC,
&e_clipped_label_info);
}
return e_clipped_label_type;
}
static void
e_clipped_label_class_init (EClippedLabelClass *class)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
/* Method override */
widget_class->size_request = e_clipped_label_size_request;
widget_class->size_allocate = e_clipped_label_size_allocate;
widget_class->expose_event = e_clipped_label_expose;
object_class->finalize = e_clipped_label_finalize;
/* Translators: This is the string to draw when the label
* of a fixed-size button is clipped, e.g. '...'.
*/
e_clipped_label_ellipsis = _("...");
}
static void
e_clipped_label_init (EClippedLabel *label)
{
GTK_WIDGET_SET_FLAGS (label, GTK_NO_WINDOW);
label->label = NULL;
label->chars_displayed = E_CLIPPED_LABEL_NEED_RECALC;
}
/**
* e_clipped_label_new:
*
* @text: The label text.
* @Returns: A new #EClippedLabel.
*
* Creates a new #EClippedLabel with the given text.
**/
GtkWidget *
e_clipped_label_new (const gchar *text,
PangoWeight font_weight,
gfloat font_size)
{
GtkWidget *label;
EClippedLabel *clipped;
label = g_object_new (e_clipped_label_get_type (), NULL);
clipped = E_CLIPPED_LABEL (label);
clipped->font_size = font_size;
clipped->font_weight = font_weight;
clipped->layout = NULL;
build_layout (clipped, e_clipped_label_ellipsis);
pango_layout_get_pixel_size (clipped->layout, &clipped->ellipsis_width, NULL);
if (text && *text)
e_clipped_label_set_text (clipped, text);
return label;
}
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);
pango_font_description_set_size (desc, pango_font_description_get_size (desc) * label->font_size);
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
e_clipped_label_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
EClippedLabel *label;
int height;
int width;
g_return_if_fail (E_IS_CLIPPED_LABEL (widget));
g_return_if_fail (requisition != NULL);
label = E_CLIPPED_LABEL (widget);
pango_layout_get_pixel_size (label->layout, &width, &height);
requisition->width = 0;
requisition->height = height + 2 * GTK_MISC (widget)->ypad;
}
static void
e_clipped_label_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
EClippedLabel *label;
label = E_CLIPPED_LABEL (widget);
widget->allocation = *allocation;
/* Flag that we need to recalculate how many characters to display. */
label->chars_displayed = E_CLIPPED_LABEL_NEED_RECALC;
}
static gint
e_clipped_label_expose (GtkWidget *widget,
GdkEventExpose *event)
{
EClippedLabel *label;
GtkMisc *misc;
gint x;
PangoRectangle rect;
g_return_val_if_fail (E_IS_CLIPPED_LABEL (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
label = E_CLIPPED_LABEL (widget);
misc = GTK_MISC (widget);
/* If the label isn't visible or has no text, just return. */
if (!GTK_WIDGET_VISIBLE (widget) || !GTK_WIDGET_MAPPED (widget)
|| !label->label || (*label->label == '\0'))
return TRUE;
/* Recalculate the number of characters displayed, if necessary. */
if (label->chars_displayed == E_CLIPPED_LABEL_NEED_RECALC)
e_clipped_label_recalc_chars_displayed (label);
/*
* GC Clipping
*/
gdk_gc_set_clip_rectangle (widget->style->white_gc,
&event->area);
gdk_gc_set_clip_rectangle (widget->style->fg_gc[widget->state],
&event->area);
pango_layout_get_pixel_extents (label->layout, &rect, NULL);
if (label->chars_displayed == E_CLIPPED_LABEL_SHOW_ENTIRE_LABEL) {
x = floor (widget->allocation.x + (gint)misc->xpad
+ (((gint)widget->allocation.width -
(gint)label->label_width - 2 * (gint)misc->xpad)
* misc->xalign) + 0.5);
gdk_draw_layout (widget->window, widget->style->fg_gc[widget->state],
x, label->label_y, label->layout);
} else {
int layout_width;
x = widget->allocation.x + (gint)misc->xpad;
/* trim the layout to the number of characters we're displaying */
pango_layout_set_text (label->layout, label->label, label->chars_displayed);
/* draw it */
gdk_draw_layout (widget->window, widget->style->fg_gc[widget->state],
x, label->label_y, label->layout);
pango_layout_get_pixel_size (label->layout, &layout_width, NULL);
/* offset the X position for the ellipsis */
x = widget->allocation.x + (gint)misc->xpad
+ label->ellipsis_x;
/* then draw the ellipsis */
pango_layout_set_text (label->layout, e_clipped_label_ellipsis, strlen (e_clipped_label_ellipsis));
gdk_draw_layout (widget->window, widget->style->fg_gc[widget->state],
x, label->label_y, label->layout);
/* then reset the layout to our original label text */
pango_layout_set_text (label->layout, label->label, -1);
}
gdk_gc_set_clip_mask (widget->style->white_gc, NULL);
gdk_gc_set_clip_mask (widget->style->fg_gc[widget->state], NULL);
return TRUE;
}
static void
e_clipped_label_finalize (GObject *object)
{
EClippedLabel *label;
g_return_if_fail (E_IS_CLIPPED_LABEL (object));
label = E_CLIPPED_LABEL(object);
g_free (label->label);
g_object_unref (label->layout);
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
/**
* e_clipped_label_get_text:
*
* @label: An #EClippedLabel.
* @Return: The label text.
*
* Returns the label text, or NULL.
**/
gchar*
e_clipped_label_get_text (EClippedLabel *label)
{
g_return_val_if_fail (E_IS_CLIPPED_LABEL (label), NULL);
return label->label;
}
/**
* e_clipped_label_set_text:
*
* @label: An #EClippedLabel.
* @text: The new label text.
*
* Sets the label text.
**/
void
e_clipped_label_set_text (EClippedLabel *label,
const gchar *text)
{
g_return_if_fail (E_IS_CLIPPED_LABEL (label));
if (label->label != text || !label->label || !text
|| strcmp (label->label, text)) {
g_free (label->label);
label->label = NULL;
if (text)
label->label = g_strdup (text);
build_layout (label, text);
/* Reset the number of characters displayed, so it is
recalculated when needed. */
label->chars_displayed = E_CLIPPED_LABEL_NEED_RECALC;
/* We don't queue a resize, since the label should not affect
the widget size, but we queue a draw. */
gtk_widget_queue_draw (GTK_WIDGET (label));
}
}
static void
e_clipped_label_recalc_chars_displayed (EClippedLabel *label)
{
gint max_width, width;
GSList *lines;
PangoLayoutLine *line;
int index;
PangoRectangle rect;
GtkWidget *widget = GTK_WIDGET (label);
GtkMisc *misc = GTK_MISC (label);
max_width = GTK_WIDGET (label)->allocation.width
- 2 * GTK_MISC (label)->xpad;
if (!label->label) {
label->chars_displayed = 0;
return;
}
/* See if the entire label fits in the allocated width. */
pango_layout_set_text (label->layout, label->label, -1);
pango_layout_get_pixel_extents (label->layout, &rect, NULL);
label->label_y = floor (widget->allocation.y + (gint)misc->ypad
+ (((gint)widget->allocation.height - 2 * (gint)misc->ypad
+ (gint)PANGO_ASCENT (rect) - PANGO_DESCENT(rect))
* misc->yalign) + 0.5);
pango_layout_get_pixel_size (label->layout, &label->label_width, NULL);
if (label->label_width <= max_width) {
label->chars_displayed = E_CLIPPED_LABEL_SHOW_ENTIRE_LABEL;
return;
}
label->chars_displayed = 0;
label->ellipsis_x = 0;
if (max_width <= 0)
return;
max_width -= label->ellipsis_width;
lines = pango_layout_get_lines (label->layout);
line = lines->data;
if (!pango_layout_line_x_to_index (line,
max_width * PANGO_SCALE,
&index,
NULL)) {
return;
}
label->chars_displayed = index;
pango_layout_set_text (label->layout, label->label, label->chars_displayed);
pango_layout_get_pixel_size (label->layout, &width, NULL);
label->ellipsis_x = width;
}

View File

@ -1,102 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Author :
* Damon Chaplin <damon@ximian.com>
*
* Copyright 1999, Ximian, Inc.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
/*
* This is similar to GtkLabel but clips itself and displays '...' if it
* can't fit inside its allocated area. The intended use is for inside buttons
* that are a fixed size. The GtkLabel would normally display only the middle
* part of the text, which doesn't look very good. This only supports one line
* of text (so no wrapping/justification), without underlined characters.
*/
#ifndef _E_CLIPPED_LABEL_H_
#define _E_CLIPPED_LABEL_H_
#include <gtk/gtkmisc.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define E_CLIPPED_LABEL(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, e_clipped_label_get_type (), EClippedLabel)
#define E_CLIPPED_LABEL_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, e_clipped_label_get_type (), EClippedLabelClass)
#define E_IS_CLIPPED_LABEL(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, e_clipped_label_get_type ())
typedef struct _EClippedLabel EClippedLabel;
typedef struct _EClippedLabelClass EClippedLabelClass;
struct _EClippedLabel
{
GtkMisc misc;
gchar *label;
/* Font size multiplication factor; 1.0 means "default GTK font
size" */
gfloat font_size;
PangoWeight font_weight;
/* Our PangoLayout */
PangoLayout *layout;
/* This is the width of the entire label string, in pixels. */
gint label_width;
/* This is the label's y coord. we store it here so it won't
change as the label's baseline changes (for example if we
ellide the 'y' from 'Summary' the baseline drops) */
gint label_y;
/* This is the number of characters we can fit in, or
E_CLIPPED_LABEL_NEED_RECALC if it needs to be recalculated, or
E_CLIPPED_LABEL_SHOW_ENTIRE_LABEL to show the entire label. */
gint chars_displayed;
/* This is the x position to display the ellipsis string, e.g. '...',
relative to the start of the label. */
gint ellipsis_x;
/* This is the width of the ellipsis, in pixels */
gint ellipsis_width;
};
struct _EClippedLabelClass
{
GtkMiscClass parent_class;
};
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
}
#endif /* __cplusplus */
#endif /* _E_CLIPPED_LABEL_H_ */

View File

@ -28,7 +28,6 @@
#include "e-info-label.h"
#include <gtk/gtklabel.h>
#include "e-clipped-label.h"
#include <e-util/e-icon-factory.h>
@ -142,29 +141,37 @@ e_info_label_new(const char *icon)
void
e_info_label_set_info(EInfoLabel *el, const char *location, const char *info)
{
char *tmp;
gchar *markup;
if (el->location == NULL) {
el->location = e_clipped_label_new(location, PANGO_WEIGHT_BOLD, 1.0);
el->info = gtk_label_new(NULL);
el->location = gtk_label_new (NULL);
el->info = gtk_label_new (NULL);
gtk_misc_set_alignment((GtkMisc *)el->location, 0.0, 0.0);
gtk_misc_set_padding((GtkMisc *)el->location, 0, 6);
gtk_misc_set_alignment((GtkMisc *)el->info, 0.0, 1.0);
gtk_misc_set_padding((GtkMisc *)el->info, 0, 6);
gtk_label_set_ellipsize (
GTK_LABEL (el->location), PANGO_ELLIPSIZE_END);
gtk_misc_set_alignment (GTK_MISC (el->location), 0.0, 0.0);
gtk_misc_set_padding (GTK_MISC (el->location), 0, 6);
gtk_misc_set_alignment (GTK_MISC (el->info), 0.0, 1.0);
gtk_misc_set_padding (GTK_MISC (el->info), 0, 6);
gtk_widget_show(el->location);
gtk_widget_show(el->info);
gtk_widget_show (el->location);
gtk_widget_show (el->info);
gtk_box_pack_start((GtkBox *)el, (GtkWidget *)el->location, TRUE, TRUE, 0);
gtk_box_pack_end((GtkBox *)el, (GtkWidget *)el->info, FALSE, TRUE, 6);
gtk_widget_set_state((GtkWidget *)el, GTK_STATE_ACTIVE);
} else {
e_clipped_label_set_text((EClippedLabel *)el->location, location);
gtk_box_pack_start (
GTK_BOX (el), GTK_WIDGET (el->location),
TRUE, TRUE, 0);
gtk_box_pack_end (
GTK_BOX (el), GTK_WIDGET (el->info),
FALSE, TRUE, 6);
gtk_widget_set_state (GTK_WIDGET (el), GTK_STATE_ACTIVE);
}
tmp = g_strdup_printf("<span size=\"smaller\">%s</span>", info);
gtk_label_set_markup((GtkLabel *)el->info, tmp);
g_free(tmp);
markup = g_markup_printf_escaped ("<b>%s</b>", location);
gtk_label_set_markup (GTK_LABEL (el->location), markup);
g_free (markup);
markup = g_markup_printf_escaped ("<small>%s</small>", info);
gtk_label_set_markup (GTK_LABEL (el->info), markup);
g_free (markup);
}

View File

@ -26,8 +26,6 @@
#include "e-multi-config-dialog.h"
#include "e-clipped-label.h"
#include <table/e-table-scrolled.h>
#include <table/e-table-memory-store.h>
#include <table/e-cell-pixbuf.h>
@ -87,18 +85,6 @@ create_page_container (const char *description,
vbox = gtk_vbox_new (FALSE, 0);
#if 0
label = e_clipped_label_new (description);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, TRUE, 0);
gtk_widget_show (label);
gtk_widget_show (separator);
#endif
gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);
gtk_widget_show (widget);

View File

@ -26,11 +26,12 @@
#include "e-task-bar.h"
#include "misc/e-clipped-label.h"
#include <gtk/gtklabel.h>
#include <gtk/gtkmisc.h>
struct _ETaskBarPrivate
{
EClippedLabel *message_label;
GtkWidget *message_label;
GtkHBox *hbox;
};
@ -96,11 +97,12 @@ e_task_bar_init (ETaskBar *task_bar)
task_bar->priv = g_new (ETaskBarPrivate, 1);
gtk_box_set_spacing (GTK_BOX (task_bar), 10);
label = e_clipped_label_new ("", PANGO_WEIGHT_NORMAL, 1.0);
label = gtk_label_new (NULL);
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
gtk_box_pack_start (GTK_BOX (task_bar), label, TRUE, TRUE, 0);
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
task_bar->priv->message_label = E_CLIPPED_LABEL (label);
task_bar->priv->message_label = label;
hbox = gtk_hbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (task_bar), hbox);
@ -133,9 +135,9 @@ e_task_bar_set_message (ETaskBar *task_bar,
const char *message)
{
if (message) {
gtk_widget_show (GTK_WIDGET (task_bar->priv->message_label));
e_clipped_label_set_text (task_bar->priv->message_label,
message);
gtk_label_set_text (
GTK_LABEL (task_bar->priv->message_label), message);
gtk_widget_show (task_bar->priv->message_label);
} else {
e_task_bar_unset_message (task_bar);
}
@ -144,7 +146,7 @@ e_task_bar_set_message (ETaskBar *task_bar,
void
e_task_bar_unset_message (ETaskBar *task_bar)
{
gtk_widget_hide (GTK_WIDGET (task_bar->priv->message_label));
gtk_widget_hide (task_bar->priv->message_label);
}
void