*/
#include <config.h>
-#include <glib/gprintf.h>
#include <math.h>
#include <string.h>
-#include "gtkalias.h"
+#undef GTK_DISABLE_DEPRECATED
#include "gtkprogress.h"
+#include "gtkprivate.h"
#include "gtkintl.h"
+#include "gtkalias.h"
#define EPSILON 1e-5
#define DEFAULT_FORMAT "%P %%"
};
-static void gtk_progress_class_init (GtkProgressClass *klass);
-static void gtk_progress_init (GtkProgress *progress);
static void gtk_progress_set_property (GObject *object,
guint prop_id,
const GValue *value,
static void gtk_progress_destroy (GtkObject *object);
static void gtk_progress_finalize (GObject *object);
static void gtk_progress_realize (GtkWidget *widget);
-static gint gtk_progress_expose (GtkWidget *widget,
+static gboolean gtk_progress_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_progress_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_progress_changed (GtkAdjustment *adjustment,
GtkProgress *progress);
-
-static GtkWidgetClass *parent_class = NULL;
-
-
-GType
-gtk_progress_get_type (void)
-{
- static GType progress_type = 0;
-
- if (!progress_type)
- {
- static const GTypeInfo progress_info =
- {
- sizeof (GtkProgressClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) gtk_progress_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GtkProgress),
- 0, /* n_preallocs */
- (GInstanceInitFunc) gtk_progress_init,
- };
-
- progress_type = g_type_register_static (GTK_TYPE_WIDGET, "GtkProgress",
- &progress_info, 0);
- }
-
- return progress_type;
-}
+G_DEFINE_TYPE (GtkProgress, gtk_progress, GTK_TYPE_WIDGET)
static void
gtk_progress_class_init (GtkProgressClass *class)
object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
- parent_class = gtk_type_class (GTK_TYPE_WIDGET);
-
gobject_class->finalize = gtk_progress_finalize;
gobject_class->set_property = gtk_progress_set_property;
class->paint = NULL;
class->update = NULL;
class->act_mode_enter = NULL;
-
+
g_object_class_install_property (gobject_class,
PROP_ACTIVITY_MODE,
- g_param_spec_boolean ("activity_mode",
+ g_param_spec_boolean ("activity-mode",
P_("Activity mode"),
- P_("If TRUE the GtkProgress is in activity mode, meaning that it signals something is happening, but not how much of the activity is finished. This is used when you're doing something that you don't know how long it will take"),
+ P_("If TRUE, the GtkProgress is in activity mode, meaning that it signals "
+ "something is happening, but not how much of the activity is finished. "
+ "This is used when you're doing something but don't know how long it will take."),
FALSE,
- G_PARAM_READWRITE));
-
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_SHOW_TEXT,
- g_param_spec_boolean ("show_text",
+ g_param_spec_boolean ("show-text",
P_("Show text"),
- P_("Whether the progress is shown as text"),
+ P_("Whether the progress is shown as text."),
FALSE,
- G_PARAM_READWRITE));
-
+ GTK_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_TEXT_XALIGN,
- g_param_spec_float ("text_xalign",
+ g_param_spec_float ("text-xalign",
P_("Text x alignment"),
- P_("A number between 0.0 and 1.0 specifying the horizontal alignment of the text in the progress widget"),
- 0.0,
- 1.0,
- 0.5,
- G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class,
+ P_("The horizontal text alignment, from 0 (left) to 1 (right). Reversed for RTL layouts."),
+ 0.0, 1.0, 0.5,
+ GTK_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class,
PROP_TEXT_YALIGN,
- g_param_spec_float ("text_yalign",
+ g_param_spec_float ("text-yalign",
P_("Text y alignment"),
- P_("A number between 0.0 and 1.0 specifying the vertical alignment of the text in the progress widget"),
- 0.0,
- 1.0,
- 0.5,
- G_PARAM_READWRITE));
+ P_("The vertical text alignment, from 0 (top) to 1 (bottom)."),
+ 0.0, 1.0, 0.5,
+ GTK_PARAM_READWRITE));
}
static void
static void
gtk_progress_realize (GtkWidget *widget)
{
- GtkProgress *progress;
+ GtkProgress *progress = GTK_PROGRESS (widget);
GdkWindowAttr attributes;
gint attributes_mask;
- g_return_if_fail (GTK_IS_PROGRESS (widget));
-
- progress = GTK_PROGRESS (widget);
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
attributes.window_type = GDK_WINDOW_CHILD;
static void
gtk_progress_destroy (GtkObject *object)
{
- GtkProgress *progress;
-
- g_return_if_fail (GTK_IS_PROGRESS (object));
-
- progress = GTK_PROGRESS (object);
+ GtkProgress *progress = GTK_PROGRESS (object);
if (progress->adjustment)
{
progress->adjustment = NULL;
}
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
+ GTK_OBJECT_CLASS (gtk_progress_parent_class)->destroy (object);
}
static void
gtk_progress_finalize (GObject *object)
{
- GtkProgress *progress;
-
- g_return_if_fail (GTK_IS_PROGRESS (object));
-
- progress = GTK_PROGRESS (object);
+ GtkProgress *progress = GTK_PROGRESS (object);
if (progress->offscreen_pixmap)
g_object_unref (progress->offscreen_pixmap);
- if (progress->format)
- g_free (progress->format);
+ g_free (progress->format);
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (gtk_progress_parent_class)->finalize (object);
}
-static gint
+static gboolean
gtk_progress_expose (GtkWidget *widget,
GdkEventExpose *event)
{
- g_return_val_if_fail (GTK_IS_PROGRESS (widget), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
-
if (GTK_WIDGET_DRAWABLE (widget))
gdk_draw_drawable (widget->window,
widget->style->black_gc,
gtk_progress_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
- g_return_if_fail (GTK_IS_PROGRESS (widget));
- g_return_if_fail (allocation != NULL);
-
widget->allocation = *allocation;
if (GTK_WIDGET_REALIZED (widget))
widget->allocation.width,
widget->allocation.height,
-1);
+
+ /* clear the pixmap for transparent themes */
+ gtk_paint_flat_box (widget->style,
+ progress->offscreen_pixmap,
+ GTK_STATE_NORMAL, GTK_SHADOW_NONE,
+ NULL, widget, "trough", 0, 0, -1, -1);
+
GTK_PROGRESS_GET_CLASS (progress)->paint (progress);
}
}
progress->adjustment = adjustment;
if (adjustment)
{
- g_object_ref (adjustment);
- gtk_object_sink (GTK_OBJECT (adjustment));
+ g_object_ref_sink (adjustment);
g_signal_connect (adjustment, "changed",
G_CALLBACK (gtk_progress_changed),
progress);
gtk_widget_queue_resize (GTK_WIDGET (progress));
- g_object_notify (G_OBJECT (progress), "show_text");
+ g_object_notify (G_OBJECT (progress), "show-text");
}
}
if (progress->x_align != x_align)
{
progress->x_align = x_align;
- g_object_notify (G_OBJECT (progress), "text_xalign");
+ g_object_notify (G_OBJECT (progress), "text-xalign");
}
if (progress->y_align != y_align)
{
progress->y_align = y_align;
- g_object_notify (G_OBJECT (progress), "text_yalign");
+ g_object_notify (G_OBJECT (progress), "text-yalign");
}
g_object_thaw_notify (G_OBJECT (progress));
if (GTK_WIDGET_DRAWABLE (GTK_WIDGET (progress)))
gtk_widget_queue_resize (GTK_WIDGET (progress));
- g_object_notify (G_OBJECT (progress), "activity_mode");
+ g_object_notify (G_OBJECT (progress), "activity-mode");
}
}
+
+#define __GTK_PROGRESS_C__
+#include "gtkaliasdef.c"