mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 05:01:09 +00:00
Add a Q_() macro.
Sun May 16 22:27:17 2004 Matthias Clasen <maclas@gmx.de> * 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)
This commit is contained in:
parent
b99e54f2dd
commit
d9d8bda57e
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
|||||||
|
Sun May 16 22:27:17 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* 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 <tml@iki.fi>
|
2004-05-15 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* gdk/win32/gdkdnd-win32.c: Put back the ref_count field in the
|
* gdk/win32/gdkdnd-win32.c: Put back the ref_count field in the
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
Sun May 16 22:27:17 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* 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 <tml@iki.fi>
|
2004-05-15 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* gdk/win32/gdkdnd-win32.c: Put back the ref_count field in the
|
* gdk/win32/gdkdnd-win32.c: Put back the ref_count field in the
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
Sun May 16 22:27:17 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* 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 <tml@iki.fi>
|
2004-05-15 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* gdk/win32/gdkdnd-win32.c: Put back the ref_count field in the
|
* gdk/win32/gdkdnd-win32.c: Put back the ref_count field in the
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
Sun May 16 22:27:17 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* 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 <tml@iki.fi>
|
2004-05-15 Tor Lillqvist <tml@iki.fi>
|
||||||
|
|
||||||
* gdk/win32/gdkdnd-win32.c: Put back the ref_count field in the
|
* gdk/win32/gdkdnd-win32.c: Put back the ref_count field in the
|
||||||
|
@ -34,9 +34,6 @@
|
|||||||
GTK_TYPE_CELL_RENDERER_PROGRESS, \
|
GTK_TYPE_CELL_RENDERER_PROGRESS, \
|
||||||
GtkCellRendererProgressPrivate))
|
GtkCellRendererProgressPrivate))
|
||||||
|
|
||||||
#define XPAD 4
|
|
||||||
#define YPAD 8
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
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,
|
static void gtk_cell_renderer_progress_set_value (GtkCellRendererProgress *cellprogress,
|
||||||
gint value);
|
gint value);
|
||||||
static void gtk_cell_renderer_progress_set_text (GtkCellRendererProgress *cellprogress,
|
static void gtk_cell_renderer_progress_set_text (GtkCellRendererProgress *cellprogress,
|
||||||
gchar *text);
|
const gchar *text);
|
||||||
static void compute_dimensions (GtkWidget *widget,
|
static void compute_dimensions (GtkCellRenderer *cell,
|
||||||
|
GtkWidget *widget,
|
||||||
const gchar *text,
|
const gchar *text,
|
||||||
gint *width,
|
gint *width,
|
||||||
gint *height);
|
gint *height);
|
||||||
@ -114,7 +112,7 @@ gtk_cell_renderer_progress_class_init (GtkCellRendererProgressClass *klass)
|
|||||||
g_param_spec_int ("value",
|
g_param_spec_int ("value",
|
||||||
P_("Value"),
|
P_("Value"),
|
||||||
P_("Value of the progress bar"),
|
P_("Value of the progress bar"),
|
||||||
-2, 100, 0,
|
0, 100, 0,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -147,6 +145,7 @@ gtk_cell_renderer_progress_init (GtkCellRendererProgress *cellprogress)
|
|||||||
cellprogress->priv->text = NULL;
|
cellprogress->priv->text = NULL;
|
||||||
cellprogress->priv->label = NULL;
|
cellprogress->priv->label = NULL;
|
||||||
cellprogress->priv->min_w = -1;
|
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)
|
if (cellprogress->priv->text)
|
||||||
text = g_strdup (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
|
else
|
||||||
/* Translator hint: this is the default label on progress bars
|
text = g_strdup_printf (Q_("progress bar label|%d %%"),
|
||||||
* inside a tree view. %d will be replaced by the percentage
|
cellprogress->priv->value);
|
||||||
*/
|
|
||||||
text = g_strdup_printf (_("%d %%"), cellprogress->priv->value);
|
|
||||||
|
|
||||||
g_free (cellprogress->priv->label);
|
g_free (cellprogress->priv->label);
|
||||||
cellprogress->priv->label = text;
|
cellprogress->priv->label = text;
|
||||||
@ -250,7 +239,7 @@ gtk_cell_renderer_progress_set_value (GtkCellRendererProgress *cellprogress,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_cell_renderer_progress_set_text (GtkCellRendererProgress *cellprogress,
|
gtk_cell_renderer_progress_set_text (GtkCellRendererProgress *cellprogress,
|
||||||
gchar *text)
|
const gchar *text)
|
||||||
{
|
{
|
||||||
gchar *new_text;
|
gchar *new_text;
|
||||||
|
|
||||||
@ -263,10 +252,11 @@ gtk_cell_renderer_progress_set_text (GtkCellRendererProgress *cellprogress,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
compute_dimensions (GtkWidget *widget,
|
compute_dimensions (GtkCellRenderer *cell,
|
||||||
const gchar *text,
|
GtkWidget *widget,
|
||||||
gint *width,
|
const gchar *text,
|
||||||
gint *height)
|
gint *width,
|
||||||
|
gint *height)
|
||||||
{
|
{
|
||||||
PangoRectangle logical_rect;
|
PangoRectangle logical_rect;
|
||||||
PangoLayout *layout;
|
PangoLayout *layout;
|
||||||
@ -275,10 +265,10 @@ compute_dimensions (GtkWidget *widget,
|
|||||||
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
|
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
|
||||||
|
|
||||||
if (width)
|
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)
|
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));
|
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);
|
GtkCellRendererProgress *cellprogress = GTK_CELL_RENDERER_PROGRESS (cell);
|
||||||
gint w, h;
|
gint w, h;
|
||||||
|
gchar *text;
|
||||||
|
|
||||||
if (cellprogress->priv->min_w < 0)
|
if (cellprogress->priv->min_w < 0)
|
||||||
compute_dimensions (widget, _("Unknown"),
|
{
|
||||||
&cellprogress->priv->min_w,
|
text = g_strdup_printf (Q_("progress bar label|%d %%"), 100);
|
||||||
&cellprogress->priv->min_h);
|
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)
|
if (width)
|
||||||
*width = MAX (cellprogress->priv->min_w, w);
|
*width = MAX (cellprogress->priv->min_w, w);
|
||||||
@ -330,11 +325,11 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell,
|
|||||||
|
|
||||||
gc = gdk_gc_new (window);
|
gc = gdk_gc_new (window);
|
||||||
|
|
||||||
x = cell_area->x + XPAD;
|
x = cell_area->x + cell->xpad;
|
||||||
y = cell_area->y + YPAD;
|
y = cell_area->y + cell->ypad;
|
||||||
|
|
||||||
w = cell_area->width - XPAD * 2;
|
w = cell_area->width - cell->xpad * 2;
|
||||||
h = cell_area->height - YPAD * 2;
|
h = cell_area->height - cell->ypad * 2;
|
||||||
|
|
||||||
gdk_gc_set_rgb_fg_color (gc, &widget->style->fg[GTK_STATE_NORMAL]);
|
gdk_gc_set_rgb_fg_color (gc, &widget->style->fg[GTK_STATE_NORMAL]);
|
||||||
gdk_draw_rectangle (window, gc, TRUE, x, y, w, h);
|
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_draw_rectangle (window, gc, TRUE, x, y, w, h);
|
||||||
|
|
||||||
gdk_gc_set_rgb_fg_color (gc, &widget->style->bg[GTK_STATE_SELECTED]);
|
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);
|
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);
|
layout = gtk_widget_create_pango_layout (widget, cellprogress->priv->label);
|
||||||
|
@ -42,12 +42,6 @@ typedef struct _GtkCellRendererProgress GtkCellRendererProgress;
|
|||||||
typedef struct _GtkCellRendererProgressClass GtkCellRendererProgressClass;
|
typedef struct _GtkCellRendererProgressClass GtkCellRendererProgressClass;
|
||||||
typedef struct _GtkCellRendererProgressPrivate GtkCellRendererProgressPrivate;
|
typedef struct _GtkCellRendererProgressPrivate GtkCellRendererProgressPrivate;
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
GTK_PROGRESS_CELL_UNKNOWN = -1,
|
|
||||||
GTK_PROGRESS_CELL_FAILED = -2
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GtkCellRendererProgress
|
struct _GtkCellRendererProgress
|
||||||
{
|
{
|
||||||
GtkCellRenderer parent_instance;
|
GtkCellRenderer parent_instance;
|
||||||
|
@ -2,11 +2,13 @@
|
|||||||
#define __GTKINTL_H__
|
#define __GTKINTL_H__
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#ifdef ENABLE_NLS
|
#ifdef ENABLE_NLS
|
||||||
#include<libintl.h>
|
#include <libintl.h>
|
||||||
#define _(String) dgettext(GETTEXT_PACKAGE,String)
|
#define _(String) dgettext(GETTEXT_PACKAGE,String)
|
||||||
#define P_(String) dgettext(GETTEXT_PACKAGE "-properties",String)
|
#define P_(String) dgettext(GETTEXT_PACKAGE "-properties",String)
|
||||||
|
#define Q_(String) g_strip_context ((String), gettext (String))
|
||||||
#ifdef gettext_noop
|
#ifdef gettext_noop
|
||||||
#define N_(String) gettext_noop(String)
|
#define N_(String) gettext_noop(String)
|
||||||
#else
|
#else
|
||||||
@ -16,6 +18,7 @@
|
|||||||
#define _(String) (String)
|
#define _(String) (String)
|
||||||
#define P_(String) (String)
|
#define P_(String) (String)
|
||||||
#define N_(String) (String)
|
#define N_(String) (String)
|
||||||
|
#define Q_(String) (String)
|
||||||
#define textdomain(String) (String)
|
#define textdomain(String) (String)
|
||||||
#define gettext(String) (String)
|
#define gettext(String) (String)
|
||||||
#define dgettext(Domain,String) (String)
|
#define dgettext(Domain,String) (String)
|
||||||
|
Loading…
Reference in New Issue
Block a user