Commit 5f32493c authored by David Odin's avatar David Odin

remove the GIMP_ZOOM_LABEL value from GimpZoomWidgetType.

* libgimpwidgets/gimpwidgetsenums.h: remove the GIMP_ZOOM_LABEL value
  from GimpZoomWidgetType.

* libgimpwidgets/gimpwidgetsenums.c: regenerated.

* libgimp/gimpzoompreview.c: provides two read only properties,
  "fraction" and "percentage" to be used with prop widgets.

* libgimpwidgets/gimpzoommodel.c: use a gimp_prop_label to show the
  zoom fraction.
parent 96b347a0
2005-09-24 DindinX <dindinx@gimp.org>
* libgimpwidgets/gimpwidgetsenums.h: remove the GIMP_ZOOM_LABEL value
from GimpZoomWidgetType.
* libgimpwidgets/gimpwidgetsenums.c: regenerated.
* libgimp/gimpzoompreview.c: provides two read only properties,
"fraction" and "percentage" to be used with prop widgets.
* libgimpwidgets/gimpzoommodel.c: use a gimp_prop_label to show the
zoom fraction.
2005-09-24 Michael Natterer <mitch@gimp.org>
* app/actions/file-actions.c: set "Close all" insensitive when
......@@ -71,10 +84,6 @@
* libgimpwidgets/gimpwidgets.def: added gimp_zoom_model_zoom_step
(gimp_zoom_model_get_fraction was already there)
* devel-docs/app/app-sections.txt: removed
gimp_display_shell_scale_zoom_step and
gimp_display_shell_scale_get_fraction.
2005-09-24 Michael Natterer <mitch@gimp.org>
* app/paint/gimppaintcore.h
......
2005-09-24 DindinX <dindinx@gimp.org>
* app/app-sections.txt: removed gimp_display_shell_scale_zoom_step and
gimp_display_shell_scale_get_fraction.
2005-09-20 Sven Neumann <sven@gimp.org>
* app/app-docs.sgml:
......
......@@ -120,7 +120,8 @@ gimp_zoom_preview_init (GimpZoomPreview *preview)
gtk_widget_show (button);
/* label */
label = gimp_zoom_widget_new (priv->zoom, GIMP_ZOOM_LABEL);
label = gimp_prop_label_new (G_OBJECT (priv->zoom), "fraction");
gtk_misc_set_padding (GTK_MISC (label), 6, 6);
gtk_box_pack_start (GTK_BOX (button_bar), label,
FALSE, FALSE, 0);
gtk_widget_show (label);
......
......@@ -178,7 +178,6 @@ gimp_zoom_widget_type_get_type (void)
{
{ GIMP_ZOOM_IN_BUTTON, "GIMP_ZOOM_IN_BUTTON", "in-button" },
{ GIMP_ZOOM_OUT_BUTTON, "GIMP_ZOOM_OUT_BUTTON", "out-button" },
{ GIMP_ZOOM_LABEL, "GIMP_ZOOM_LABEL", "label" },
{ 0, NULL, NULL }
};
......@@ -186,7 +185,6 @@ gimp_zoom_widget_type_get_type (void)
{
{ GIMP_ZOOM_IN_BUTTON, "GIMP_ZOOM_IN_BUTTON", NULL },
{ GIMP_ZOOM_OUT_BUTTON, "GIMP_ZOOM_OUT_BUTTON", NULL },
{ GIMP_ZOOM_LABEL, "GIMP_ZOOM_LABEL", NULL },
{ 0, NULL, NULL }
};
......
......@@ -97,8 +97,7 @@ GType gimp_zoom_widget_type_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_ZOOM_IN_BUTTON,
GIMP_ZOOM_OUT_BUTTON,
GIMP_ZOOM_LABEL
GIMP_ZOOM_OUT_BUTTON
} GimpZoomWidgetType;
#define GIMP_TYPE_ZOOM_TYPE (gimp_zoom_type_get_type ())
......
......@@ -39,7 +39,9 @@ enum
PROP_0,
PROP_VALUE,
PROP_MINIMUM,
PROP_MAXIMUM
PROP_MAXIMUM,
PROP_FRACTION,
PROP_PERCENTAGE
};
typedef struct _GimpZoomModelPrivate GimpZoomModelPrivate;
......@@ -95,6 +97,17 @@ gimp_zoom_model_class_init (GimpZoomModelClass *klass)
256.0,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_FRACTION,
g_param_spec_string ("fraction",
"Fraction", NULL,
"1:1",
G_PARAM_READABLE));
g_object_class_install_property (object_class, PROP_PERCENTAGE,
g_param_spec_string ("percentage",
"Percentage", NULL,
"100%",
G_PARAM_READABLE));
g_type_class_add_private (object_class, sizeof (GimpZoomModelPrivate));
}
......@@ -120,6 +133,8 @@ gimp_zoom_model_set_property (GObject *object,
case PROP_VALUE:
priv->value = g_value_get_double (value);
g_object_notify (object, "value");
g_object_notify (object, "fraction");
g_object_notify (object, "percentage");
break;
case PROP_MINIMUM:
......@@ -139,6 +154,8 @@ gimp_zoom_model_set_property (GObject *object,
{
priv->value = CLAMP (priv->value, priv->minimum, priv->maximum);
g_object_notify (object, "value");
g_object_notify (object, "fraction");
g_object_notify (object, "percentage");
}
}
......@@ -149,6 +166,9 @@ gimp_zoom_model_get_property (GObject *object,
GParamSpec *pspec)
{
GimpZoomModelPrivate *priv = GIMP_ZOOM_MODEL_GET_PRIVATE (object);
gint numerator;
gint denominator;
gchar *tmp;
switch (property_id)
{
......@@ -164,6 +184,19 @@ gimp_zoom_model_get_property (GObject *object,
g_value_set_double (value, priv->maximum);
break;
case PROP_FRACTION:
gimp_zoom_model_get_fraction (priv->value, &numerator, &denominator);
tmp = g_strdup_printf (_("%d:%d"), numerator, denominator);
g_value_set_string (value, tmp);
g_free (tmp);
break;
case PROP_PERCENTAGE:
tmp = g_strdup_printf (_("%d%%"), (gint)(priv->value * 100.0));
g_value_set_string (value, tmp);
g_free (tmp);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -182,6 +215,8 @@ gimp_zoom_model_zoom_in (GimpZoomModel *model)
priv->value = gimp_zoom_model_zoom_step (GIMP_ZOOM_IN,
priv->value);
g_object_notify (G_OBJECT (model), "value");
g_object_notify (G_OBJECT (model), "fraction");
g_object_notify (G_OBJECT (model), "percentage");
}
}
......@@ -197,30 +232,11 @@ gimp_zoom_model_zoom_out (GimpZoomModel *model)
priv->value = gimp_zoom_model_zoom_step (GIMP_ZOOM_OUT,
priv->value);
g_object_notify (G_OBJECT (model), "value");
g_object_notify (G_OBJECT (model), "fraction");
g_object_notify (G_OBJECT (model), "percentage");
}
}
static void
gimp_zoom_model_update_label (GimpZoomModel *model,
GParamSpec *pspec,
GtkLabel *label)
{
gint numerator;
gint denominator;
gchar *txt;
GimpZoomModelPrivate *priv = GIMP_ZOOM_MODEL_GET_PRIVATE (model);
g_return_if_fail (GIMP_IS_ZOOM_MODEL (model));
g_return_if_fail (GTK_IS_LABEL (label));
gimp_zoom_model_get_fraction (priv->value,
&numerator,
&denominator);
txt = g_strdup_printf (_("zoom factor %d:%d"), numerator, denominator);
gtk_label_set_text (label, txt);
g_free (txt);
}
void
gimp_zoom_model_get_fraction (gdouble zoom_factor,
gint *numerator,
......@@ -404,11 +420,6 @@ gimp_zoom_widget_new (GimpZoomModel *model,
{
GtkWidget *button;
GtkWidget *image;
GtkWidget *label;
gint numerator;
gint denominator;
gchar *txt;
GimpZoomModelPrivate *priv = GIMP_ZOOM_MODEL_GET_PRIVATE (model);
g_return_val_if_fail (GIMP_IS_ZOOM_MODEL (model), NULL);
......@@ -435,19 +446,6 @@ gimp_zoom_widget_new (GimpZoomModel *model,
G_CALLBACK (gimp_zoom_model_zoom_out),
model);
return button;
case GIMP_ZOOM_LABEL:
gimp_zoom_model_get_fraction (priv->value,
&numerator,
&denominator);
txt = g_strdup_printf (_("zoom factor %d:%d"), numerator, denominator);
label = gtk_label_new (txt);
g_free (txt);
gtk_misc_set_padding (GTK_MISC (label), 6, 6);
g_signal_connect (model, "notify::value",
G_CALLBACK (gimp_zoom_model_update_label),
label);
return label;
}
return NULL;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment