54
54
struct gxineinfo_private_s
56
56
gxineinfo_cb postinit, update;
57
GtkWidget *line[MAX_LINES];
57
GtkLabel *line[MAX_LINES];
60
int time, length, tcount, tno, ccount, cno;
61
gboolean remaining, seekable;
60
65
typedef struct gxineinfo_private_s gxineinfo_private_t;
184
189
for (i = 0; i < height; ++i)
186
191
GtkWidget *ev = (buttons & 1 << i) ? gtk_event_box_new () : NULL;
187
GtkWidget *line = priv->line[i] = gtk_label_new (NULL);
192
GtkWidget *line = ui_label_new_with_xalign ("", 0);
193
priv->line[i] = GTK_LABEL (line);
188
194
gtk_widget_set_name (line, i ? small : large);
189
gtk_misc_set_alignment (GTK_MISC (line), 0, 0.5);
190
195
gtk_label_set_ellipsize (GTK_LABEL (line), ellipsize);
192
197
gtk_label_set_width_chars (GTK_LABEL (line), width);
389
395
!!(xine_config_lookup_entry
390
396
(xine, "gui.show_time_remaining", &entry)
391
397
&& entry.num_value);
392
gtk_widget_set_state (widget, state ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL);
398
gboolean seekable = xine_get_stream_info (stream, XINE_STREAM_INFO_SEEKABLE);
399
gtk_widget_set_state ((GtkWidget *)widget, state ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL);
394
401
if (xine_get_status (stream) == XINE_STATUS_PLAY && !playlist_showing_logo ())
397
403
if (!xine_get_pos_length (stream, &pos_stream, &pos_time, &length_time))
398
404
pos_stream = pos_time = length_time = 0;
401
407
pos_time = length_time - pos_time;
403
409
pos_time -= pos_time % 1000;
410
if (!priv->force && pos_time == priv->prev.time
411
&& length_time == priv->prev.length && state == priv->prev.remaining
412
&& seekable == priv->prev.seekable)
413
goto finish; /* no need to redisplay the time */
415
priv->prev.time = pos_time;
416
priv->prev.length = length_time;
417
priv->prev.remaining = state;
418
priv->prev.seekable = seekable;
404
420
int_to_timestring (pos_time, time.current, sizeof (time.current));
406
422
length_time = round_second (length_time);
408
424
int_to_timestring (length_time, time.length, sizeof (time.length));
410
426
snprintf (time.length, sizeof (time.length), "%s",
411
xine_get_stream_info (stream, XINE_STREAM_INFO_SEEKABLE)
412
? _("??:??:??") : _("live"));
427
seekable ? _("??:??:??") : _("live"));
431
if (!priv->force && priv->prev.time == -1 && priv->prev.length == -1)
432
goto finish; /* no need to redisplay the (lack of) time */
433
priv->prev.time = priv->prev.length = -1;
415
434
strcpy (time.current, "•");
416
437
if (priv->line[1])
418
gtk_label_set_text (GTK_LABEL (priv->line[0]), time.current);
419
gtk_label_set_text (GTK_LABEL (priv->line[1]), time.length);
439
gtk_label_set_text (priv->line[0], time.current);
440
gtk_label_set_text (priv->line[1], time.length);
421
442
else if (time.current[0])
423
444
strcat (time.full, " / ");
424
445
memmove (time.full + strlen (time.full), time.length, sizeof (time.length));
425
gtk_label_set_text (GTK_LABEL (priv->line[0]), time.full);
446
gtk_label_set_text (priv->line[0], time.full);
428
gtk_label_set_text (GTK_LABEL (priv->line[0]), "");
449
gtk_label_set_text (priv->line[0], "");
430
452
#ifdef XINE_STREAM_INFO_DVD_TITLE_NUMBER
431
453
time.full[0] = 0;
432
int count = xine_get_stream_info (stream, XINE_STREAM_INFO_DVD_TITLE_COUNT);
433
if (count) /* "T" = DVD title number */
434
sprintf (time.full, _("T%d/%d "),
435
xine_get_stream_info (stream, XINE_STREAM_INFO_DVD_TITLE_NUMBER),
437
count = xine_get_stream_info (stream, XINE_STREAM_INFO_DVD_CHAPTER_COUNT);
438
if (count) /* "C" = DVD chapter number */
439
sprintf (time.full + strlen (time.full), _("C%d/%d "),
440
xine_get_stream_info (stream, XINE_STREAM_INFO_DVD_CHAPTER_NUMBER),
442
gtk_label_set_text (GTK_LABEL (priv->line[2]), time.full);
454
int tcount = xine_get_stream_info (stream, XINE_STREAM_INFO_DVD_TITLE_COUNT);
455
int tno = tcount ? xine_get_stream_info (stream, XINE_STREAM_INFO_DVD_TITLE_NUMBER) : 0;
456
int ccount = xine_get_stream_info (stream, XINE_STREAM_INFO_DVD_CHAPTER_COUNT);
457
int cno = ccount ? xine_get_stream_info (stream, XINE_STREAM_INFO_DVD_CHAPTER_NUMBER) : 0;
459
if (priv->force || tcount != priv->prev.tcount || tno != priv->prev.tno
460
|| ccount != priv->prev.ccount || cno != priv->prev.cno)
462
priv->prev.tcount = tcount;
463
priv->prev.tno = tno;
464
priv->prev.ccount = ccount;
465
priv->prev.cno = cno;
466
if (tcount) /* "T" = DVD title number */
467
sprintf (time.full, _("T%d/%d "), tno, tcount);
468
if (ccount) /* "C" = DVD chapter number */
469
sprintf (time.full + strlen (time.full), _("C%d/%d "), cno, ccount);
470
gtk_label_set_text (priv->line[2], time.full);
445
475
gdk_threads_leave ();
446
476
pthread_mutex_unlock (&widgets_update_lock);
462
509
postinit_time_widget (gpointer widget)
464
511
gxineinfo_private_t *priv = GET_PRIVATE (widget);
465
g_signal_connect (G_OBJECT (priv->line[0]->parent), "button-press-event",
512
GtkWidget *line = GTK_WIDGET (priv->line[0]);
513
g_signal_connect (G_OBJECT (line->parent), "button-press-event",
466
514
G_CALLBACK (frob_format_cb), widget);
468
GdkWindow *window = priv->line[0]->window;
516
GdkWindow *window = line->window;
469
517
GdkDisplay *display = gdk_drawable_get_display ((GdkDrawable *)window);
470
518
GdkCursor *ptr = gdk_cursor_new_for_display (display, GDK_CLOCK);
471
519
gdk_window_set_cursor (window, ptr);
472
520
gdk_cursor_unref (ptr);
474
g_timeout_add (500, update_time_widget_cb, widget);
479
create_time_widget (gboolean small)
526
create_time_widget (gboolean small, const GList *const *const listp)
481
return gxineinfo_new (small ? 1 : 3, PANGO_ELLIPSIZE_NONE, small ? 16 : 8,
482
postinit_time_widget, update_time_widget_cb, "time",
483
1 /* line 0 has an event box */);
528
GtkWidget *w = gxineinfo_new (small ? 1 : 3, PANGO_ELLIPSIZE_NONE,
529
small ? 16 : 8, postinit_time_widget,
530
update_time_widget_cb, "time",
531
1 /* line 0 has an event box */);
533
g_object_set_data ((GObject *) w, "gxine-chain", (gpointer) listp);