diff --git a/ChangeLog b/ChangeLog index c8f52e87f2..acc6727ac5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Sun May 16 22:27:17 2004 Matthias Clasen + + * gtk/gtkintl.h (Q_): Add a Q_() macro. + + * gtk/gtkcellrendererprogress.h: Remove GTK_PROGRESS_CELL_UNKNOWN + and GTK_PROGRESS_CELL_FAILED. With the ability the set the label, + they are not really needed. + + * gtk/gtkcellrendererprogress.c: Use the xpad and ypad properties + instead of hardwired padding, use Q_() for the default label, + compute a reasonable minimal size. (#142571, #142572, #142573, + Tommi Komulainen, Christian Persch) + 2004-05-15 Tor Lillqvist * gdk/win32/gdkdnd-win32.c: Put back the ref_count field in the diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index c8f52e87f2..acc6727ac5 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,16 @@ +Sun May 16 22:27:17 2004 Matthias Clasen + + * gtk/gtkintl.h (Q_): Add a Q_() macro. + + * gtk/gtkcellrendererprogress.h: Remove GTK_PROGRESS_CELL_UNKNOWN + and GTK_PROGRESS_CELL_FAILED. With the ability the set the label, + they are not really needed. + + * gtk/gtkcellrendererprogress.c: Use the xpad and ypad properties + instead of hardwired padding, use Q_() for the default label, + compute a reasonable minimal size. (#142571, #142572, #142573, + Tommi Komulainen, Christian Persch) + 2004-05-15 Tor Lillqvist * gdk/win32/gdkdnd-win32.c: Put back the ref_count field in the diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index c8f52e87f2..acc6727ac5 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,16 @@ +Sun May 16 22:27:17 2004 Matthias Clasen + + * gtk/gtkintl.h (Q_): Add a Q_() macro. + + * gtk/gtkcellrendererprogress.h: Remove GTK_PROGRESS_CELL_UNKNOWN + and GTK_PROGRESS_CELL_FAILED. With the ability the set the label, + they are not really needed. + + * gtk/gtkcellrendererprogress.c: Use the xpad and ypad properties + instead of hardwired padding, use Q_() for the default label, + compute a reasonable minimal size. (#142571, #142572, #142573, + Tommi Komulainen, Christian Persch) + 2004-05-15 Tor Lillqvist * gdk/win32/gdkdnd-win32.c: Put back the ref_count field in the diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index c8f52e87f2..acc6727ac5 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,16 @@ +Sun May 16 22:27:17 2004 Matthias Clasen + + * gtk/gtkintl.h (Q_): Add a Q_() macro. + + * gtk/gtkcellrendererprogress.h: Remove GTK_PROGRESS_CELL_UNKNOWN + and GTK_PROGRESS_CELL_FAILED. With the ability the set the label, + they are not really needed. + + * gtk/gtkcellrendererprogress.c: Use the xpad and ypad properties + instead of hardwired padding, use Q_() for the default label, + compute a reasonable minimal size. (#142571, #142572, #142573, + Tommi Komulainen, Christian Persch) + 2004-05-15 Tor Lillqvist * gdk/win32/gdkdnd-win32.c: Put back the ref_count field in the diff --git a/gtk/gtkcellrendererprogress.c b/gtk/gtkcellrendererprogress.c index 64116d2ed2..c76f4b6d1d 100644 --- a/gtk/gtkcellrendererprogress.c +++ b/gtk/gtkcellrendererprogress.c @@ -34,9 +34,6 @@ GTK_TYPE_CELL_RENDERER_PROGRESS, \ GtkCellRendererProgressPrivate)) -#define XPAD 4 -#define YPAD 8 - enum { PROP_0, @@ -65,8 +62,9 @@ static void gtk_cell_renderer_progress_set_property (GObject *ob static void gtk_cell_renderer_progress_set_value (GtkCellRendererProgress *cellprogress, gint value); static void gtk_cell_renderer_progress_set_text (GtkCellRendererProgress *cellprogress, - gchar *text); -static void compute_dimensions (GtkWidget *widget, + const gchar *text); +static void compute_dimensions (GtkCellRenderer *cell, + GtkWidget *widget, const gchar *text, gint *width, gint *height); @@ -114,7 +112,7 @@ gtk_cell_renderer_progress_class_init (GtkCellRendererProgressClass *klass) g_param_spec_int ("value", P_("Value"), P_("Value of the progress bar"), - -2, 100, 0, + 0, 100, 0, G_PARAM_READWRITE)); /** @@ -147,6 +145,7 @@ gtk_cell_renderer_progress_init (GtkCellRendererProgress *cellprogress) cellprogress->priv->text = NULL; cellprogress->priv->label = NULL; cellprogress->priv->min_w = -1; + cellprogress->priv->min_h = -1; } @@ -230,19 +229,9 @@ gtk_cell_renderer_progress_set_value (GtkCellRendererProgress *cellprogress, if (cellprogress->priv->text) text = g_strdup (cellprogress->priv->text); - else if (cellprogress->priv->value == GTK_PROGRESS_CELL_FAILED) - /* Translator hint: this is a label on progress bars inside a tree view. - */ - text = g_strdup (_("Failed")); - else if (cellprogress->priv->value == GTK_PROGRESS_CELL_UNKNOWN) - /* Translator hint: this is a label on progress bars inside a tree view. - */ - text = g_strdup (_("Unknown")); else - /* Translator hint: this is the default label on progress bars - * inside a tree view. %d will be replaced by the percentage - */ - text = g_strdup_printf (_("%d %%"), cellprogress->priv->value); + text = g_strdup_printf (Q_("progress bar label|%d %%"), + cellprogress->priv->value); g_free (cellprogress->priv->label); cellprogress->priv->label = text; @@ -250,7 +239,7 @@ gtk_cell_renderer_progress_set_value (GtkCellRendererProgress *cellprogress, static void gtk_cell_renderer_progress_set_text (GtkCellRendererProgress *cellprogress, - gchar *text) + const gchar *text) { gchar *new_text; @@ -263,10 +252,11 @@ gtk_cell_renderer_progress_set_text (GtkCellRendererProgress *cellprogress, } static void -compute_dimensions (GtkWidget *widget, - const gchar *text, - gint *width, - gint *height) +compute_dimensions (GtkCellRenderer *cell, + GtkWidget *widget, + const gchar *text, + gint *width, + gint *height) { PangoRectangle logical_rect; PangoLayout *layout; @@ -275,10 +265,10 @@ compute_dimensions (GtkWidget *widget, pango_layout_get_pixel_extents (layout, NULL, &logical_rect); if (width) - *width = logical_rect.width + XPAD * 2 + widget->style->xthickness * 2; + *width = logical_rect.width + cell->xpad * 2 + widget->style->xthickness * 2; if (height) - *height = logical_rect.height + YPAD * 2 + widget->style->ythickness * 2; + *height = logical_rect.height + cell->ypad * 2 + widget->style->ythickness * 2; g_object_unref (G_OBJECT (layout)); } @@ -294,13 +284,18 @@ gtk_cell_renderer_progress_get_size (GtkCellRenderer *cell, { GtkCellRendererProgress *cellprogress = GTK_CELL_RENDERER_PROGRESS (cell); gint w, h; - + gchar *text; + if (cellprogress->priv->min_w < 0) - compute_dimensions (widget, _("Unknown"), - &cellprogress->priv->min_w, - &cellprogress->priv->min_h); + { + text = g_strdup_printf (Q_("progress bar label|%d %%"), 100); + compute_dimensions (cell, widget, text, + &cellprogress->priv->min_w, + &cellprogress->priv->min_h); + g_free (text); + } - compute_dimensions (widget, cellprogress->priv->label, &w, &h); + compute_dimensions (cell, widget, cellprogress->priv->label, &w, &h); if (width) *width = MAX (cellprogress->priv->min_w, w); @@ -330,11 +325,11 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell, gc = gdk_gc_new (window); - x = cell_area->x + XPAD; - y = cell_area->y + YPAD; + x = cell_area->x + cell->xpad; + y = cell_area->y + cell->ypad; - w = cell_area->width - XPAD * 2; - h = cell_area->height - YPAD * 2; + w = cell_area->width - cell->xpad * 2; + h = cell_area->height - cell->ypad * 2; gdk_gc_set_rgb_fg_color (gc, &widget->style->fg[GTK_STATE_NORMAL]); gdk_draw_rectangle (window, gc, TRUE, x, y, w, h); @@ -347,7 +342,7 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell, gdk_draw_rectangle (window, gc, TRUE, x, y, w, h); gdk_gc_set_rgb_fg_color (gc, &widget->style->bg[GTK_STATE_SELECTED]); - perc_w = w * cellprogress->priv->value / 100; + perc_w = w * MAX (0, cellprogress->priv->value) / 100; gdk_draw_rectangle (window, gc, TRUE, is_rtl ? (x + w - perc_w) : x, y, perc_w, h); layout = gtk_widget_create_pango_layout (widget, cellprogress->priv->label); diff --git a/gtk/gtkcellrendererprogress.h b/gtk/gtkcellrendererprogress.h index 7417f79063..dddc71ea80 100644 --- a/gtk/gtkcellrendererprogress.h +++ b/gtk/gtkcellrendererprogress.h @@ -42,12 +42,6 @@ typedef struct _GtkCellRendererProgress GtkCellRendererProgress; typedef struct _GtkCellRendererProgressClass GtkCellRendererProgressClass; typedef struct _GtkCellRendererProgressPrivate GtkCellRendererProgressPrivate; -enum -{ - GTK_PROGRESS_CELL_UNKNOWN = -1, - GTK_PROGRESS_CELL_FAILED = -2 -}; - struct _GtkCellRendererProgress { GtkCellRenderer parent_instance; diff --git a/gtk/gtkintl.h b/gtk/gtkintl.h index 8ac9475939..9f66ec1e7f 100644 --- a/gtk/gtkintl.h +++ b/gtk/gtkintl.h @@ -2,11 +2,13 @@ #define __GTKINTL_H__ #include "config.h" +#include #ifdef ENABLE_NLS -#include +#include #define _(String) dgettext(GETTEXT_PACKAGE,String) #define P_(String) dgettext(GETTEXT_PACKAGE "-properties",String) +#define Q_(String) g_strip_context ((String), gettext (String)) #ifdef gettext_noop #define N_(String) gettext_noop(String) #else @@ -16,6 +18,7 @@ #define _(String) (String) #define P_(String) (String) #define N_(String) (String) +#define Q_(String) (String) #define textdomain(String) (String) #define gettext(String) (String) #define dgettext(Domain,String) (String)