2000-10-30 21:02:08 +00:00
|
|
|
#include <config.h>
|
|
|
|
#include "gststatusarea.h"
|
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
static void gst_status_area_class_init (GstStatusAreaClass *klass);
|
|
|
|
static void gst_status_area_init (GstStatusArea *status_area);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
static void gst_status_area_set_arg (GtkObject *object, GtkArg *arg, guint id);
|
|
|
|
static void gst_status_area_get_arg (GtkObject *object, GtkArg *arg, guint id);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
static void gst_status_area_realize (GtkWidget *status_area);
|
|
|
|
static gint gst_status_area_expose (GtkWidget *widget, GdkEventExpose *event);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
|
|
|
#define DEFAULT_HEIGHT 20
|
2000-11-08 19:53:48 +00:00
|
|
|
#define DEFAULT_EXPANDED_HEIGHT 100
|
2000-10-30 21:02:08 +00:00
|
|
|
|
|
|
|
/* signals and args */
|
|
|
|
enum {
|
2001-05-21 01:19:06 +00:00
|
|
|
LAST_SIGNAL
|
2000-10-30 21:02:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2001-05-21 01:19:06 +00:00
|
|
|
ARG_0,
|
2000-10-30 21:02:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static GtkDrawingArea *parent_class = NULL;
|
2001-12-14 21:09:18 +00:00
|
|
|
/* static guint gst_status_area_signals[LAST_SIGNAL] = { 0 }; */
|
2000-10-30 21:02:08 +00:00
|
|
|
|
|
|
|
GtkType
|
|
|
|
gst_status_area_get_type (void)
|
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
static GtkType status_area_type = 0;
|
|
|
|
|
|
|
|
if (!status_area_type) {
|
|
|
|
static const GtkTypeInfo status_area_info = {
|
|
|
|
"GstStatusArea",
|
|
|
|
sizeof(GstStatusArea),
|
|
|
|
sizeof(GstStatusAreaClass),
|
|
|
|
(GtkClassInitFunc)gst_status_area_class_init,
|
|
|
|
(GtkObjectInitFunc)gst_status_area_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(GtkClassInitFunc)NULL,
|
|
|
|
};
|
|
|
|
status_area_type = gtk_type_unique (gtk_widget_get_type (),&status_area_info);
|
|
|
|
}
|
|
|
|
return status_area_type;
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_status_area_class_init (GstStatusAreaClass *klass)
|
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
GtkObjectClass *object_class;
|
|
|
|
GtkWidgetClass *widget_class;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
parent_class = gtk_type_class (gtk_widget_get_type ());
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
object_class = (GtkObjectClass*)klass;
|
|
|
|
widget_class = (GtkWidgetClass*)klass;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
object_class->set_arg = gst_status_area_set_arg;
|
|
|
|
object_class->get_arg = gst_status_area_get_arg;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
widget_class->realize = gst_status_area_realize;
|
|
|
|
widget_class->expose_event = gst_status_area_expose;
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_status_area_init (GstStatusArea *status_area)
|
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
GTK_WIDGET(status_area)->requisition.height = DEFAULT_HEIGHT;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
status_area->state = GST_STATUS_AREA_STATE_INIT;
|
|
|
|
status_area->expanded = FALSE;
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GstStatusArea *
|
|
|
|
gst_status_area_new (void)
|
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
return GST_STATUS_AREA (gtk_type_new (GST_TYPE_STATUS_AREA));
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_status_area_realize (GtkWidget *widget)
|
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
GdkWindowAttr attributes;
|
|
|
|
gint attributes_mask;
|
|
|
|
GstStatusArea *status_area;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
g_return_if_fail (widget != NULL);
|
|
|
|
g_return_if_fail(GST_IS_STATUS_AREA(widget));
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
|
|
|
|
status_area = GST_STATUS_AREA(widget);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
attributes.x = widget->allocation.x;
|
|
|
|
attributes.y = widget->allocation.y;
|
|
|
|
attributes.width = widget->allocation.width;
|
|
|
|
attributes.height = widget->allocation.height;
|
|
|
|
attributes.wclass = GDK_INPUT_OUTPUT;
|
|
|
|
attributes.window_type = GDK_WINDOW_CHILD;
|
|
|
|
attributes.event_mask = gtk_widget_get_events (widget)
|
|
|
|
| GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
|
|
|
|
| GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
attributes.visual = gtk_widget_get_visual (widget);
|
|
|
|
attributes.colormap = gtk_widget_get_colormap (widget);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
|
|
|
|
widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
widget->style = gtk_style_attach (widget->style, widget->window);
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
2001-05-21 01:19:06 +00:00
|
|
|
gst_status_area_expose(GtkWidget *widget, GdkEventExpose *event)
|
2000-10-30 21:02:08 +00:00
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
GstStatusArea *status_area;
|
|
|
|
guchar *statustext;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
g_return_val_if_fail (GST_IS_STATUS_AREA (widget), FALSE);
|
|
|
|
g_return_val_if_fail (event != NULL, FALSE);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
status_area = GST_STATUS_AREA (widget);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-12-13 23:14:39 +00:00
|
|
|
#ifndef USE_GLIB2
|
2001-05-21 01:19:06 +00:00
|
|
|
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget)) {
|
|
|
|
gdk_draw_rectangle (widget->window,
|
|
|
|
widget->style->black_gc,
|
|
|
|
TRUE,
|
|
|
|
0, 0,
|
|
|
|
widget->allocation.width,
|
|
|
|
widget->allocation.height);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
if (status_area->expanded) {
|
|
|
|
gint width;
|
2000-11-08 19:53:48 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
gdk_draw_line (widget->window,
|
|
|
|
widget->style->dark_gc[0],
|
|
|
|
0, widget->allocation.height - 20,
|
|
|
|
widget->allocation.width, widget->allocation.height - 20);
|
|
|
|
|
|
|
|
width = gdk_string_width (widget->style->font, "Show:");
|
|
|
|
|
|
|
|
gdk_draw_string (widget->window,
|
|
|
|
widget->style->font,
|
|
|
|
widget->style->white_gc,
|
|
|
|
80-width, 15,
|
|
|
|
"Show:");
|
|
|
|
|
|
|
|
width = gdk_string_width (widget->style->font, "Clip:");
|
|
|
|
|
|
|
|
gdk_draw_string (widget->window,
|
|
|
|
widget->style->font,
|
|
|
|
widget->style->white_gc,
|
|
|
|
80-width, 40,
|
|
|
|
"Clip:");
|
|
|
|
|
|
|
|
width = gdk_string_width (widget->style->font, "Author:");
|
|
|
|
|
|
|
|
gdk_draw_string (widget->window,
|
|
|
|
widget->style->font,
|
|
|
|
widget->style->white_gc,
|
|
|
|
80-width, 55,
|
|
|
|
"Author:");
|
|
|
|
|
|
|
|
width = gdk_string_width (widget->style->font, "Copyright:");
|
|
|
|
|
|
|
|
gdk_draw_string (widget->window,
|
|
|
|
widget->style->font,
|
|
|
|
widget->style->white_gc,
|
|
|
|
80-width, 70,
|
|
|
|
"Copyright:");
|
|
|
|
|
|
|
|
gdk_draw_line (widget->window,
|
|
|
|
widget->style->dark_gc[0],
|
|
|
|
0, widget->allocation.height - 80,
|
|
|
|
widget->allocation.width, widget->allocation.height - 80);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (status_area->state) {
|
|
|
|
case GST_STATUS_AREA_STATE_INIT:
|
|
|
|
statustext = "Initializing";
|
|
|
|
break;
|
|
|
|
case GST_STATUS_AREA_STATE_PLAYING:
|
|
|
|
statustext = "Playing";
|
|
|
|
break;
|
|
|
|
case GST_STATUS_AREA_STATE_PAUSED:
|
|
|
|
statustext = "Paused";
|
|
|
|
break;
|
|
|
|
case GST_STATUS_AREA_STATE_STOPPED:
|
|
|
|
statustext = "Stopped";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
statustext = "";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gdk_draw_string (widget->window,
|
|
|
|
widget->style->font,
|
|
|
|
widget->style->white_gc,
|
|
|
|
8, widget->allocation.height-5,
|
|
|
|
statustext);
|
|
|
|
|
|
|
|
if (status_area->playtime) {
|
|
|
|
gint width = gdk_string_width (widget->style->font, status_area->playtime);
|
|
|
|
|
|
|
|
gdk_draw_string (widget->window,
|
|
|
|
widget->style->font,
|
|
|
|
widget->style->white_gc,
|
|
|
|
widget->allocation.width-width-20,
|
|
|
|
widget->allocation.height-5,
|
|
|
|
status_area->playtime);
|
|
|
|
}
|
|
|
|
}
|
2001-12-13 23:14:39 +00:00
|
|
|
#else
|
|
|
|
#warning this needs pangoizing.
|
|
|
|
#endif
|
2001-05-21 01:19:06 +00:00
|
|
|
|
|
|
|
return FALSE;
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-05-21 01:19:06 +00:00
|
|
|
gst_status_area_set_state (GstStatusArea *area, GstStatusAreaState state)
|
2000-10-30 21:02:08 +00:00
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
g_return_if_fail(area != NULL);
|
|
|
|
g_return_if_fail(GST_IS_STATUS_AREA(area));
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
area->state = state;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
if (GTK_WIDGET_VISIBLE(area))
|
|
|
|
gtk_widget_queue_draw(GTK_WIDGET(area));
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-05-21 01:19:06 +00:00
|
|
|
gst_status_area_set_playtime (GstStatusArea *area, const guchar *time)
|
2000-10-30 21:02:08 +00:00
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
g_return_if_fail(area != NULL);
|
|
|
|
g_return_if_fail(GST_IS_STATUS_AREA(area));
|
|
|
|
g_return_if_fail(time != NULL);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
if (area->playtime) g_free (area->playtime);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
area->playtime = g_strdup (time);
|
2000-11-01 13:49:41 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
if (GTK_WIDGET_VISIBLE(area))
|
|
|
|
gtk_widget_queue_draw(GTK_WIDGET(area));
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-05-21 01:19:06 +00:00
|
|
|
gst_status_area_set_streamtype (GstStatusArea *area, const guchar *type)
|
2000-10-30 21:02:08 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-05-21 01:19:06 +00:00
|
|
|
gst_status_area_show_extended (GstStatusArea *area, gboolean show)
|
2000-10-30 21:02:08 +00:00
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
area->expanded = show;
|
|
|
|
|
|
|
|
if (show) {
|
|
|
|
GTK_WIDGET(area)->requisition.height = DEFAULT_EXPANDED_HEIGHT;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GTK_WIDGET(area)->requisition.height = DEFAULT_HEIGHT;
|
|
|
|
}
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (area));
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-05-21 01:19:06 +00:00
|
|
|
gst_status_area_set_arg(GtkObject *object, GtkArg *arg, guint id)
|
2000-10-30 21:02:08 +00:00
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
GstStatusArea *status_area;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
status_area = GST_STATUS_AREA(object);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
switch (id) {
|
|
|
|
default:
|
|
|
|
g_warning("GstStatusArea: unknown arg!");
|
|
|
|
break;
|
|
|
|
}
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-05-21 01:19:06 +00:00
|
|
|
gst_status_area_get_arg(GtkObject *object, GtkArg *arg, guint id)
|
2000-10-30 21:02:08 +00:00
|
|
|
{
|
2001-05-21 01:19:06 +00:00
|
|
|
GstStatusArea *status_area;
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
status_area = GST_STATUS_AREA(object);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2001-05-21 01:19:06 +00:00
|
|
|
switch (id) {
|
|
|
|
default:
|
|
|
|
arg->type = GTK_TYPE_INVALID;
|
|
|
|
break;
|
|
|
|
}
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|